Source Code
#include "bits/stdc++.h"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

void solve(){
    int n,k;
    cin>>n>>k;
    map<int,int> m;
    for (int i = 0; i < n; ++i)
    {
        int a;
        cin>>a;
        m[a]++;
    }
    if(k == 0)
     cout<<m[k]<<endl;
    else if(m[k] == 0)
      cout<<0;
    else
    {
        if(m[k]&2==0)
            m[k]--;
        cout<<m[k];
    }
}

int main(){
    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("out.txt", "w",stdout);
    #endif
    FAST;

    int t = 1;
    // cin>>t;
    while(t--)
     solve(); 
}


Copy
Legendary moathhamudah
GNU G++17
4 ms
996 KB
Wrong Answer