Source Code
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(),x.end()
#define answer(x) cout << (x ? "YES\n" : "NO\n")
#define test ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; while(T--)
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define F first
#define S second
using namespace std;

const int N = 200100;
ll n, d, a[N];
vector<int> v; 


int main()
{
	int ans = 0;

	cin >> n >> d;
	for(int i=1 ; i<=n;i ++) cin >> a[i], ans += (a[i] == d);  
	
	
	if(d && ans && (ans % 2 == 0))
		ans --;

	cout << ans;
}
Copy
Legendary MuhammedAlajam
GNU G++17
58 ms
2.6 MB
Accepted