Source Code
#include <bits/stdc++.h>
using namespace std;


int main(){
    int n,d;
    cin>>n>>d;
    vector<int> a(n);
    map<int,int> freq;
    for(int i =0; i<n; i++){
    	cin>>a[i];
    	freq[a[i]]++;
    }
    int k = freq[d];
    if(k && k%2==0)
    	k--;
    cout<<k<<endl;
   

    return 0;
}
Copy
Legendary Saq
GNU G++17
3 ms
688 KB
Wrong Answer