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;
	for (int i = 0 ; i < n ; i++){
		int x;
		cin >> x;
		mp[x]++;
	}
	if (mp.find(d) != mp.end()){
		if (mp[d] == 1 or mp[d] % 2 == 0){
			cout << mp[d] << endl;
		} else cout << mp[d] - 1 << endl;
	} else cout << 0 << endl;
	


	/*




	*/


}
Copy
Legendary MysteRrion
GNU G++17
3 ms
816 KB
Wrong Answer