Source Code
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, d;
    cin >> n >> d;

    int cnt = 0;
    for(int i = 0; i < n; ++i){
        int t; cin >> t;
        if( t == d ) cnt += 1;
    }
    if((cnt&1)==0&&cnt&& d != 0)
        cnt=cnt-1;
    cout << cnt << endl;
	return 0;
}
Copy
Legendary Mohamedmaher
GNU G++17
87 ms
992 KB
Accepted