Source Code
#include <iostream>
 
using namespace std;
 
int main() {
	long long n,d,ans=0;
	cin>>n>>d;
	for(long long i=0;i<n;i++){
		long long x;
		cin>>x;
		if(x==d)ans++;
	}
	if(ans==0)cout<<0;
	else if (ans%2)cout<<ans;
	else if(ans%2==0)cout<<ans-1;
 
 
	return 0;
}
Copy
Legendary fakher20
GNU G++17
3 ms
780 KB
Wrong Answer