Source Code
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<utility>
#include<list>
#include<set>
#include<functional>
#include<assert.h>

using namespace std;
using ll = long long;
using ld = long double;

const int N = (int)2e5 + 5;

using namespace std;

ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


void solve() {
  int n, d;
  cin >> n >> d;
  map<int, int> fr;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    fr[x]++;
  }
  if (fr[d] < 1)cout << 0;
  else cout << fr[d] - !(fr[d] % 2);
}


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int _ = 1;
  //cin >> _;

  while (_--) {
    solve();
    cout << '\n';
  }
}
Copy
Legendary iyaad
GNU G++17
3 ms
820 KB
Wrong Answer