Source Code
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    vector<int> v(n);
    for(int i = 0 ;i < n ;i++)
     cin>>v[i];
    map<int,int> freq;
    for(int i = 0 ; i < n; i++)
    {
        if(v[i] == d)
        freq[d]++;
    }
    if(freq[d] == 0)
     cout<<0;
    else
     cout<<(freq[d]&1?freq[d]:freq[d]-1);
}
Copy
Legendary moathhamudah
GNU G++17
4 ms
940 KB
Wrong Answer