prithivMLmods/Coder-Stat huggingface dataset:
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int a1, a2, b1, b2, c1, c2;
  int counter = 0;
  cin >> a1 >> b1 >> c1;

  if (a1 % 2 == 1 || b1 % 2 == 1 || c1 % 2 == 1) {
    cout << counter << endl;
    return 0;
  }

  if (a1 == (b1 + c1) / 2 && b1 == (a1 + c1) / 2 && c1 == (a1 + b2) / 2) {
    cout << counter << endl;
    return 0;
  }

  while (1) {
    a2 = (b1 + c1) / 2;
    b2 = (a1 + c1) / 2;
    c2 = (a1 + b1) / 2;
    counter++;
    if (a2 % 2 == 1 || b2 % 2 == 1 || c2 % 2 == 1) {
      cout << counter << endl;
      return 0;
    }
    a1 = a2;
    b1 = b2;
    c1 = c2;
  }

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int a1, a2, b1, b2, c1, c2;
  int counter = 0;
  cin >> a1 >> b1 >> c1;

  if (a1 % 2 == 1 || b1 % 2 == 1 || c1 % 2 == 1) {
    cout << counter << endl;
    return 0;
  }

  if (a1 + b1 == b1 + c1 && b1 + c1 == a1 + c1) {
    cout << -1 << endl;
    return 0;
  }

  while (1) {
    a2 = (b1 + c1) / 2;
    b2 = (a1 + c1) / 2;
    c2 = (a1 + b1) / 2;
    counter++;
    if (a2 % 2 == 1 || b2 % 2 == 1 || c2 % 2 == 1) {
      cout << counter << endl;
      return 0;
    }
    a1 = a2;
    b1 = b2;
    c1 = c2;
  }

  return 0;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long a, b, c;
  cin >> a >> b >> c;
  int i;
  for (i = 0;; i++) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      cout << i << endl;
      return 0;
    } else if (a == 0 && b == 0 && c == 0) {
      cout << -1 << endl;
      return 0;
    }
    int d = a / 2;
    int e = b / 2;
    int f = c / 2;
    a = e + f;
    b = d + f;
    c = d + e;
  }
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long a, b, c;
  cin >> a >> b >> c;
  int i;
  for (i = 0;; i++) {
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      cout << i << endl;
      return 0;
    } else if (a == b && c == b) {
      cout << -1 << endl;
      return 0;
    }
    int d = a / 2;
    int e = b / 2;
    int f = c / 2;
    a = e + f;
    b = d + f;
    c = d + e;
  }
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  unsigned long long a, b, c;
  unsigned long long h_a, h_b, h_c, cnt = 0;

  cin >> a >> b >> c;
  while (!(a & 1) && !(b & 1) && !(c & 1)) {
    if (a == b == c) {
      cout << -1 << endl;
      return 0;
    }
    h_a = a / 2;
    h_b = b / 2;
    h_c = c / 2;
    a = h_b + h_c;
    b = h_a + h_c;
    c = h_a + h_b;
    cnt++;
  }
  cout << cnt << endl;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  unsigned long long a, b, c;
  unsigned long long h_a, h_b, h_c, cnt = 0;

  cin >> a >> b >> c;
  while (!(a & 1) && !(b & 1) && !(c & 1)) {
    if (a == b && b == c) {
      cout << -1 << endl;
      return 0;
    }
    h_a = a / 2;
    h_b = b / 2;
    h_c = c / 2;
    a = h_b + h_c;
    b = h_a + h_c;
    c = h_a + h_b;
    cnt++;
  }
  cout << cnt << endl;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int aa, bb, cc;
    aa = a;
    bb = b;
    cc = c;
    a = bb / 2 + cc / 2;
    b = aa / 2 + cc / 2;
    c = aa / 2 + bb / 2;
    count++;
    if (count > 1e9) {
      count = -1;
      a = 1;
      break;
    }
  }

  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int count = 0;
  while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
    int aa, bb, cc;
    aa = a;
    bb = b;
    cc = c;
    a = bb / 2 + cc / 2;
    b = aa / 2 + cc / 2;
    c = aa / 2 + bb / 2;
    count++;
    if (count > 1e8) {
      count = -1;
      a = 1;
      break;
    }
  }

  cout << count << endl;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  for (ll i = 0; i < MOD; i++) {
    if ((a + b) % 2 || (b + c) % 2 || (c + a) % 2) {
      cout << i << endl;
      return 0;
    }
    ll x = (b + c) / 2, y = (a + c) / 2, z = (a + b) / 2;
    a = x;
    b = y;
    c = z;
  }
  cout << -1 << endl;
}


Fixed submission:
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (a % 2 || b % 2 || c % 2) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < 9999999; i++) {
    if ((a + b) % 2 || (b + c) % 2 || (c + a) % 2) {
      cout << i << endl;
      return 0;
    }
    ll x = (b + c) / 2, y = (a + c) / 2, z = (a + b) / 2;
    a = x;
    b = y;
    c = z;
  }
  cout << -1 << endl;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const ll INF = 2e15;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll count = 0;
  if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
    print(count);
    return 0;
  }
  if (a == b == c) {
    print(-1);
    return 0;
  }
  while (1) {
    ll A = a;
    ll B = b;
    ll C = c;
    a = B / 2 + C / 2;
    b = A / 2 + C / 2;
    c = A / 2 + B / 2;
    count++;
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      print(count);
      return 0;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int)x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9 + 7;
const ll INF = 2e15;
template <class T> void print(const T &t) { cout << t << endl; }
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll count = 0;
  if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
    print(count);
    return 0;
  }
  if (a == b && b == c) {
    print(-1);
    return 0;
  }
  while (1) {
    ll A = a;
    ll B = b;
    ll C = c;
    a = B / 2 + C / 2;
    b = A / 2 + C / 2;
    c = A / 2 + B / 2;
    count++;
    if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
      print(count);
      return 0;
    }
  }
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  set<tuple<long long int, long long int, long long int>> s;
  for (int i = 0;; i++) {
    auto x = make_tuple(a, b, c);
    if (s.count(x)) {
      cout << -1 << endl;
      return 0;
    }

    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      int newa = (b + c) / 2;
      int newb = (a + c) / 2;
      int newc = (a + b) / 2;
      a = newa;
      b = newb;
      c = newc;
    } else {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int a, b, c;
  cin >> a >> b >> c;
  set<tuple<long long int, long long int, long long int>> s;
  for (int i = 0;; i++) {
    auto x = make_tuple(a, b, c);
    if (s.count(x)) {
      cout << -1 << endl;
      return 0;
    }
    s.insert(x);

    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
      int newa = (b + c) / 2;
      int newb = (a + c) / 2;
      int newc = (a + b) / 2;
      a = newa;
      b = newb;
      c = newc;
    } else {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// #include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};

//-----------------------------------------------------------------------------

ll a, b, c;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;
  if (a % 2 == 0 && a == b && b == c)
    cout << -1 << endl;
  else {
    int t = 0;
    while (true) {
      if ((a + b) % 2 || (b + c) % 2 || (a + c) % 2) {
        cout << t << endl;
        break;
      }
      ll x = (a + b) / 2, y = (b + c) / 2, z = (a + c) / 2;
      z = x, b = y, c = z;
      t++;
    }
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
// #include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};

//-----------------------------------------------------------------------------

ll a, b, c;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b >> c;
  if (a % 2 == 0 && a == b && b == c)
    cout << -1 << endl;
  else {
    int t = 0;
    while (true) {
      if (a % 2 || b % 2 || c % 2) {
        cout << t << endl;
        break;
      }
      ll x = (a + b) / 2, y = (b + c) / 2, z = (a + c) / 2;
      z = x, b = y, c = z;
      t++;
    }
  }

  return 0;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
int main() {
  long long x, y, z, x1, y1, z1;
  int temp = -1;
  scanf("%lld %lld %lld", &x, &y, &z);
  for (int i = 1;; i++) {
    temp++;
    if (x % 2 == 1 || y % 2 == 1 || z % 2 == 1) {
      if (temp >= 10000) {
        printf("-1");
        break;
      } else {
        printf("%d", temp);
        break;
      }
    } else {
      x1 = x / 2;
      y1 = y / 2;
      z1 = z / 2;
      x = y1 + z1;
      y = x1 + z1;
      z = x1 + y1;
    }
  }
}


Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
using namespace std;
int main() {
  long long x, y, z, x1, y1, z1;
  int temp = -1;
  scanf("%lld %lld %lld", &x, &y, &z);
  for (int i = 1;; i++) {
    temp++;
    if (temp >= 100000) {
      printf("-1");
      break;
    } else if (x % 2 == 1 || y % 2 == 1 || z % 2 == 1) {
      printf("%d", temp);
      break;
    } else {
      x1 = x / 2;
      y1 = y / 2;
      z1 = z / 2;
      x = y1 + z1;
      y = x1 + z1;
      z = x1 + y1;
    }
  }
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))

#define RFOR(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair

using namespace std;

const int INF = INT_MAX / 4;
const int MOD = 1000000007;
const double EPS = 1e-14;

const bool debug_flag = true;

void debug(string str) {
  if (debug_flag) {
    cout << str << endl;
  }
}

void debugs(string str) {
  if (debug_flag) {
    cout << str;
  }
}

int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.precision(10);

  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c && a & 1 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  while (!(a & 1 || b & 1 || c & 1)) {
    int A, B, C;
    A = (b + c) / 2;
    B = (a + c) / 2;
    C = (a + b) / 2;
    a = A;
    b = B;
    c = C;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define REP(i, n) FOR((i), 0, (n))

#define RFOR(i, b, a) for (int(i) = (b); (i) >= (a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair

using namespace std;

const int INF = INT_MAX / 4;
const int MOD = 1000000007;
const double EPS = 1e-14;

const bool debug_flag = true;

void debug(string str) {
  if (debug_flag) {
    cout << str << endl;
  }
}

void debugs(string str) {
  if (debug_flag) {
    cout << str;
  }
}

int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.precision(10);

  int a, b, c;
  cin >> a >> b >> c;

  if (a == b && b == c && a % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  int cnt = 0;
  while (!(a & 1 || b & 1 || c & 1)) {
    int A, B, C;
    A = (b + c) / 2;
    B = (a + c) / 2;
    C = (a + b) / 2;
    a = A;
    b = B;
    c = C;
    cnt++;
  }
  cout << cnt << endl;

  return 0;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0 && A == B == C) {
    cout << -1 << endl;
  } else if (!(A % 2 == 0 && B % 2 == 0 && C % 2 == 0)) {
    cout << 0 << endl;
  } else {
    bool ok = true;
    ll nA, nB, nC;
    ll ans = 1;
    while (ok) {

      nA = (B + C) / 2;
      nB = (C + A) / 2;
      nC = (A + B) / 2;

      if (nA % 2 == 0 && nB % 2 == 0 && nC % 2 == 0) {
        ans++;
        A = nA;
        B = nB;
        C = nC;
      } else {
        ok = false;
      }
    }

    cout << ans << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const ll INF = 1LL << 60;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll A, B, C;
  cin >> A >> B >> C;
  if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0 && (A == B) && (B == C)) {
    cout << -1 << endl;
  } else if (!(A % 2 == 0 && B % 2 == 0 && C % 2 == 0)) {
    cout << 0 << endl;
  } else {
    bool ok = true;
    ll nA, nB, nC;
    ll ans = 1;
    while (ok) {

      nA = (B + C) / 2;
      nB = (C + A) / 2;
      nC = (A + B) / 2;

      if (nA % 2 == 0 && nB % 2 == 0 && nC % 2 == 0) {
        ans++;
        A = nA;
        B = nB;
        C = nC;
      } else {
        ok = false;
      }
    }

    cout << ans << endl;
  }

  return 0;
}
Problem p03723 (C++)

Buggy submission (status: Time Limit Exceeded):
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\n'
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std;

inline void solve() {
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  while (true) {
    if ((a == b) and (b == c) and (a & 1) and ans > 0) {
      cout << "-1" << endl;
      return;
    }
    if ((a & 1) or (b & 1) or (c & 1))
      break;
    ans++;
    int ta = a, tb = b, tc = c;
    b = c = ta / 2;
    b += tc / 2;
    a = tb / 2;
    a += tc / 2;
    c += tb / 2;
  }
  // cout << a<< " "<<b<< " "<<c<<endl;
  cout << ans << endl;
  return;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}


Fixed submission:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define vi vector<int>
#define dbg(x) cerr << #x << " = " << x << '\n'
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std;

inline void solve() {
  int a, b, c, ans = 0;
  cin >> a >> b >> c;
  while (true) {
    if ((a == b) and (b == c) and ((a & 1) ^ 1)) {
      cout << "-1" << endl;
      return;
    }
    if ((a & 1) or (b & 1) or (c & 1))
      break;
    ans++;
    int ta = a, tb = b, tc = c;
    b = c = ta / 2;
    b += tc / 2;
    a = tb / 2;
    a += tc / 2;
    c += tb / 2;
  }
  // cout << a<< " "<<b<< " "<<c<<endl;
  cout << ans << endl;
  return;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
typedef long long ll;
ll gi() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch))
    f ^= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
int c[100010];
int main() {
#ifdef XZZSB
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
  int n = gi(), m = gi(), a, b;
  for (int i = 1; i <= n; ++i) {
    a = gi(), b = gi();
    if (a > b)
      std::swap(a, b);
    ++c[a], --c[b];
  }
  for (int i = 1; i <= n; ++i)
    if ((c[i] += c[i - 1]) & 1)
      return puts("NO"), 0;
  return puts("YES"), 0;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
ll gi() {
  ll x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch))
    f ^= ch == '-', ch = getchar();
  while (isdigit(ch))
    x = x * 10 + ch - '0', ch = getchar();
  return f ? x : -x;
}
int c[100010];
int main() {
#ifdef XZZSB
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
  int n = gi(), m = gi(), a, b;
  for (int i = 1; i <= m; ++i) {
    a = gi(), b = gi();
    if (a > b)
      std::swap(a, b);
    ++c[a], --c[b];
  }
  for (int i = 1; i <= n; ++i)
    if ((c[i] += c[i - 1]) & 1)
      return puts("NO"), 0;
  return puts("YES"), 0;
}
Problem p03724 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m, a, b;
  cin >> n >> m;
  int p[n - 1];
  for (int i = 0; i < n - 1; ++i)
    p[i] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (a > b) {
      int d = a;
      a = b;
      b = d;
    }
    for (int j = a - 1; j < b - 1; ++j)
      p[j]++;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (p[i] % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 over = 1000000007;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n, m, a, b;
  cin >> n >> m;
  int p[n - 1];
  for (int i = 0; i < n - 1; ++i)
    p[i] = 0;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    if (a > b) {
      int d = a;
      a = b;
      b = d;
    }
    if (a != 1)
      p[a - 2]++;
    p[b - 2]++;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (p[i] % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);
const ld EPS = 0.0000000001;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; 0 <= i; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> v(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a] += 1;
    v[b] += 1;
  }
  string ans = "YES";

  REP(i, m)
  if (v[i] & 1)
    ans = "NO";

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);
const ld EPS = 0.0000000001;
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; 0 <= i; i--)
#define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; (ll)(b) <= i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
  int n, m;
  cin >> n >> m;

  vector<int> v(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    v[a] += 1;
    v[b] += 1;
  }
  string ans = "YES";

  REP(i, n)
  if (v[i] & 1)
    ans = "NO";

  cout << ans << endl;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

const int MAXN = 11111;
vector<pair<int, int>> G[MAXN];
int itr[MAXN];
bool done[MAXN];

bool dfs(int v, int s) {
  for (; itr[v] < G[v].size(); ++itr[v]) {
    auto e = G[v][itr[v]];
    if (done[e.second])
      continue;
    done[e.second] = true;
    return dfs(e.first, s);
  }
  if (itr[v] == G[v].size()) {
    return v == s;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  for (int i = 0; i < N; i++) {
    if (G[i].size() > itr[i]) {
      if (!dfs(i, i)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

const int MAXN = 111111;
vector<pair<int, int>> G[MAXN];
int itr[MAXN];
bool done[MAXN];

bool dfs(int v, int s) {
  for (; itr[v] < G[v].size(); ++itr[v]) {
    auto e = G[v][itr[v]];
    if (done[e.second])
      continue;
    done[e.second] = true;
    return dfs(e.first, s);
  }
  if (itr[v] == G[v].size()) {
    return v == s;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a].emplace_back(b, i);
    G[b].emplace_back(a, i);
  }
  for (int i = 0; i < N; i++) {
    if (G[i].size() > itr[i]) {
      if (!dfs(i, i)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
  int to;     // 辺の行先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    v[a[i]]++, v[b[i]]++;
  }
  bool ok = true;
  for (auto &it : v)
    if (it % 2 != 0)
      ok = false;
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
  int to;     // 辺の行先
  int weight; // 辺の重み
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  vector<int> v(N);
  for (int i = 0; i < M; i++) {
    v[a[i]]++, v[b[i]]++;
  }
  bool ok = true;
  for (auto &it : v)
    if (it % 2 != 0)
      ok = false;
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
Problem p03724 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(N):
        a, b = map(int, input().split())
        count[a] += 1
        count[b] += 1

    if all(c % 2 == 0 for c in count):
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(M):
        a, b = map(int, input().split())
        count[a] += 1
        count[b] += 1

    if all(c % 2 == 0 for c in count):
        ans = "YES"
    else:
        ans = "NO"
    print(ans)


if __name__ == "__main__":
    main()
Problem p03724 (Python)

Buggy submission (status: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, m = map(int, input().split())

    cnt = [0] * n
    for i in range(n):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == "__main__":
    resolve()


Fixed submission:
import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, m = map(int, input().split())

    cnt = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        cnt[a - 1] += 1
        cnt[b - 1] += 1

    for i in cnt:
        if i % 2:
            print("NO")
            break
    else:
        print("YES")


if __name__ == "__main__":
    resolve()
Problem p03724 (Python)

Buggy submission (status: Runtime Error):
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * n
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")


Fixed submission:
import sys

input = sys.stdin.readline
n, m = map(int, input().split())
a = [0] * (n + 1)
for _ in range(m):
    x, y = map(int, input().split())
    a[x] = (a[x] + 1) & 1
    a[y] = (a[y] + 1) & 1
print("YES" if sum(a) == 0 else "NO")
Problem p03724 (Python)

Buggy submission (status: Time Limit Exceeded):
from collections import Counter

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr = Counter(sum(X, []))
if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")


Fixed submission:
from collections import Counter

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr = Counter()
for a, b in X:
    ctr[a] += 1
    ctr[b] += 1

if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M;
ll a[10005], b[10005];
ll c[10005];
bool flag = true;
int main() {
  cin.sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    c[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    c[a[i]] += 1;
    c[b[i]] += 1;
  }

  for (int i = 0; i < N; i++) {
    if (c[i] % 2 != 0) {
      cout << "NO" << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, M;
ll a[100005], b[100005];
ll c[100005];
bool flag = true;
int main() {
  cin.sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    c[i] = 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    c[a[i]] += 1;
    c[b[i]] += 1;
  }

  for (int i = 0; i < N; i++) {
    if (c[i] % 2 != 0) {
      cout << "NO" << endl;
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "YES" << endl;
  }
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i <= n; i++)
#define rep3(i, x, n) for (int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main() {
  int N, M;
  cin >> N >> M;
  int cnt[N];
  fill(cnt, cnt + M, 0);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cnt[a]++, cnt[b]++;
  }
  rep(i, N) {
    if (cnt[i] & 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, x, n) for (int i = x; i <= n; i++)
#define rep3(i, x, n) for (int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main() {
  int N, M;
  cin >> N >> M;
  int cnt[N];
  fill(cnt, cnt + N, 0);
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    cnt[a]++, cnt[b]++;
  }
  rep(i, N) {
    if (cnt[i] & 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, cnt;
int pot[10005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    pot[x] ^= 1, pot[y] ^= 1;
  }
  for (int i = 1; i <= n; i++, cnt += pot[i]) {
    if (pot[i] && cnt) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, cnt;
int pot[100005];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    pot[x] ^= 1, pot[y] ^= 1;
  }
  for (int i = 1; i <= n; i++, cnt += pot[i]) {
    if (pot[i] && cnt) {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
using namespace std;

int s[100005];

int main() {
  int n, m;
  memset(s, 0, sizeof(s));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", a, b);
    s[a]++;
    s[b]++;
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] % 2 != 0) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
using namespace std;

int s[100005];

int main() {
  int n, m;
  memset(s, 0, sizeof(s));
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    s[a]++;
    s[b]++;
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] % 2 != 0) {
      printf("NO");
      return 0;
    }
  }
  printf("YES");
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N (100000)                 // 10^5
#define BASE (1000000000 + 7)          // 10^9 + 7
#define INFI (1000000000 + 7)          // 10^9 + 7
#define INFL (1000000000000000000 + 7) // 10^18 + 7

ll N, M;
Vl G[MAX_N];

void solve() {
  for (int i = 0; i < N; i++) {
    if (G[i].size() % 2 != 0) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}

int main() {
  cin >> N >> M;

  for (int i = 0; i < N; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  solve();

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>

// #define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N (100000)                 // 10^5
#define BASE (1000000000 + 7)          // 10^9 + 7
#define INFI (1000000000 + 7)          // 10^9 + 7
#define INFL (1000000000000000000 + 7) // 10^18 + 7

ll N, M;
Vl G[MAX_N];

void solve() {
  for (int i = 0; i < N; i++) {
    if (G[i].size() % 2 != 0) {
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}

int main() {
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  solve();

  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> edges(N + 1, false);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    int minab = min(a, b);
    int maxab = max(a, b);
    for (int j = minab; j < maxab; j++) {
      edges.at(j) = !edges.at(j);
    }
  }
  for (int i = 1; i <= N; i++) {
    if (edges.at(i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> edges(N + 1, false);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edges.at(a) = !edges.at(a);
    edges.at(b) = !edges.at(b);
  }
  for (int i = 1; i <= N; i++) {
    if (edges.at(i)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n)-1; (i) >= (m); i--)
#define debug(x) cerr << #x << " = " << x << endl
// #define int long long

typedef long long ll;
// ll const MOD = 998244353;
ll const MOD = 1e9 + 7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
template <typename T> int size(const T &a) { return (int)a.size(); }
template <typename T> T Div(T a, T b) { return (a + b - 1) / b; }
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    v[a - 1]++;
    v[b - 1]++;
  }

  bool y = true;
  REP(i, m) { y &= ~(v[i] % 2); }

  cout << (y ? "YES" : "NO") << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for (int(i) = (n)-1; (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define FORR(i, m, n) for (int(i) = (n)-1; (i) >= (m); i--)
#define debug(x) cerr << #x << " = " << x << endl
// #define int long long

typedef long long ll;
// ll const MOD = 998244353;
ll const MOD = 1e9 + 7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
template <typename T> int size(const T &a) { return (int)a.size(); }
template <typename T> T Div(T a, T b) { return (a + b - 1) / b; }
template <typename T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);

  REP(i, m) {
    int a, b;
    cin >> a >> b;
    v[a - 1]++;
    v[b - 1]++;
  }

  bool y = true;
  REP(i, n) { y &= ~(v[i] % 2); }

  cout << (y ? "YES" : "NO") << endl;

  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
  int N, M;
  cin >> N >> M;

  vector<int> cnt(M);
  REP(i, M) {
    int A, B;
    cin >> A >> B;
    cnt.at(A - 1) += 1;
    cnt.at(B - 1) += 1;
  }

  REP(i, N) {
    if (cnt.at(i) % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

// #define int ll
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FORE(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'
#define hyphen() cerr << "--\n"

#define fst first
#define pb push_back

const int MOD = (int)1e9 + 7;

signed main() {
  int N, M;
  cin >> N >> M;

  vector<int> cnt(N);
  REP(i, M) {
    int A, B;
    cin >> A >> B;
    cnt.at(A - 1) += 1;
    cnt.at(B - 1) += 1;
  }

  REP(i, N) {
    if (cnt.at(i) % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
using namespace std;

const static int MAX = 10005;
int num[MAX];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  int t1, t2;

  for (int i = 0; i < m; i++) {
    scanf("%d %d", &t1, &t2);

    if (t1 != 1 && t2 != 1) {
      num[t1]++;
      num[t2]++;
    }

    else if (t1 == 1) {
      num[t2]++;
    }

    else {
      num[t1]++;
    }
  }

  for (int i = 2; i <= n; i++) {
    if (num[i] % 2) {
      printf("NO");
      return 0;
    }
  }

  printf("YES");
  return 0;
}


Fixed submission:
#include <cstdio>
using namespace std;

const static int MAX = 100005;
int num[MAX];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  int t1, t2;

  for (int i = 0; i < m; i++) {
    scanf("%d %d", &t1, &t2);

    if (t1 != 1 && t2 != 1) {
      num[t1]++;
      num[t2]++;
    }

    else if (t1 == 1) {
      num[t2]++;
    }

    else {
      num[t1]++;
    }
  }

  for (int i = 2; i <= n; i++) {
    if (num[i] % 2) {
      printf("NO");
      return 0;
    }
  }

  printf("YES");
  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define CH(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)

using namespace std;

int N, M, a[100010], b[100010];

int main() {
  cin >> N >> M;
  REP(i, 0, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  int d[10010];
  REP(i, 0, N) d[i] = 0;
  REP(i, 0, M) {
    if (a[i] != 0)
      d[a[i]]++;
    if (b[i] != 0)
      d[b[i]]++;
  }

  REP(i, 1, N) {
    if (d[i] % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define CH(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)

using namespace std;

int N, M, a[100010], b[100010];

int main() {
  cin >> N >> M;
  REP(i, 0, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }

  int d[100010];
  REP(i, 0, N) d[i] = 0;
  REP(i, 0, M) {
    if (a[i] != 0)
      d[a[i]]++;
    if (b[i] != 0)
      d[b[i]]++;
  }

  REP(i, 1, N) {
    if (d[i] % 2 == 1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}
Problem p03724 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    t = true, ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, m, f[MAX];
int getf(int x) { return x == f[x] ? x : f[x] = getf(f[x]); }
vector<int> E[MAX];
int U[MAX], V[MAX], a[MAX];
void dfs(int u, int ff) {
  for (int v : E[u])
    if (v != ff)
      dfs(v, u), a[u] ^= a[v];
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i)
    f[i] = i;
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    if (getf(u) != getf(v))
      E[u].push_back(v), E[v].push_back(u), f[getf(u)] = getf(v);
    U[i] = u;
    V[i] = v;
  }
  for (int i = 1; i <= n; ++i)
    if (getf(i) != getf(1))
      E[1].push_back(i), E[i].push_back(1);
  for (int i = 1; i <= m; ++i) {
    int u = U[i], v = V[i];
    a[u] ^= 1;
    a[v] ^= 1;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i)
    if (a[i]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-')
    ch = getchar();
  if (ch == '-')
    t = true, ch = getchar();
  while (ch <= '9' && ch >= '0')
    x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, m, f[MAX];
int getf(int x) { return x == f[x] ? x : f[x] = getf(f[x]); }
vector<int> E[MAX];
int U[MAX], V[MAX], a[MAX];
void dfs(int u, int ff) {
  for (int v : E[u])
    if (v != ff)
      dfs(v, u), a[u] ^= a[v];
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i)
    f[i] = i;
  for (int i = 1; i <= m; ++i) {
    int u = read(), v = read();
    if (getf(u) != getf(v))
      E[u].push_back(v), E[v].push_back(u), f[getf(u)] = getf(v);
    U[i] = u;
    V[i] = v;
  }
  for (int i = 1; i <= n; ++i)
    if (getf(i) != getf(1))
      E[1].push_back(i), E[i].push_back(1), f[getf(i)] = getf(1);
  for (int i = 1; i <= m; ++i) {
    int u = U[i], v = V[i];
    a[u] ^= 1;
    a[v] ^= 1;
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i)
    if (a[i]) {
      puts("NO");
      return 0;
    }
  puts("YES");
  return 0;
}