Source Code
#include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;

int main() {
	int n, d;
	cin >> n >> d;
	map<int, int>mp;
	vector<pair<int, int>> v;
	for(int i = 0, x; i < n; ++i){
		cin >> x;
		++mp[x];
	}
	if(d == 0 || mp[d] % 2)
	cout << mp[d];
	else if(mp[d] > 0){
		cout << mp[d] - 1;
	}
	else{
		cout << 0;
	}
	return 0;
}
Copy
Legendary Bahou
GNU G++17
230 ms
10.3 MB
Accepted