Source Code
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI acos(-1)
#define fr first
#define se second
#define int long long
const int MAXN = 2e5+7;
const int MOD = 1e9 + 7;
typedef tree<int , null_type ,  less<int> , rb_tree_tag ,
	tree_order_statistics_node_update> os;


signed main() {

	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n,d;
	cin >> n >> d;
	map<int,int> mp;
	int z = 0;
	for (int i = 0 ; i < n ; i++){
		int x;
		cin >> x;
		z = (z|x);
		mp[x]++;
	}
	if (mp.find(d) != mp.end()){
		if (mp[d] & 1){
			cout << mp[d] << endl;
		} else {
			if (d == 0){
				cout << mp[d] << endl;
			} else {
				cout << mp[d] - 1 << endl;
			}
		}
	} else cout << 0 << endl;
	


	/*




	*/


}
Copy
Legendary MysteRrion
GNU G++17
245 ms
13.5 MB
Accepted