Source Code
#include<iostream>
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int mod=1e9+7;
const ll INF=1e18;
const double pi=3.14159265358979323846;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define pb push_back
#define Go ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

using namespace std;

ll a[200010];

int main()
{
Go

ll n,d; cin >> n >> d;
for(int i=0;i<n;i++)cin >> a[i];

map<ll,ll>mp;
for(int i=0;i<n;i++)mp[a[i]]++;

ll ans=0;

if(d==0)ans=mp[0];
else{
    ans=mp[d];
    if(mp[d]>0&&mp[d]%2==0)ans--;
}

cout << ans;

return 0;
}
Copy
Legendary yumna08
GNU G++17
182 ms
15.0 MB
Accepted