Source Code

#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
      ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   ll n,d;
   cin>>n>>d;
    ll arr[n];map<ll,ll>m;
    for(int i=0;i<n;i++){
    cin>>arr[i];
    m[arr[i]]++;
    }
    if(m[d]==0)
    cout<<0;
    else if(m[d]%2==0)
    cout<<m[d]-1;
    else
    cout<<m[d];
   
    
    return 0;
}
Copy
Legendary ateeq
GNU G++17
3 ms
908 KB
Wrong Answer