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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a + b);
  for (int i = 1; i * i <= x; i++) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 1;
    }
  }
  cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int x = stoi(a + b);
  for (int i = 1; i * i <= x; i++) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}
Problem p03456 (C++)

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

int main() {
  string a, b, n;
  cin >> a >> b;
  n = a + b;
  int num = stoi(n);
  bool flag = false;
  for (int i = 0; i < 1e5; i++) {
    if (num % i == 0 && num / i == i) {
      flag = true;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  string a, b, n;
  cin >> a >> b;
  n = a + b;
  int num = stoi(n);
  bool flag = false;
  for (int i = 1; i < 1e5; i++) {
    if (num % i == 0 && num / i == i) {
      flag = true;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03456 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int a, b, n, sq;
  char *c;
  scanf("%d%d", &a, &b);
  sprintf(c, "%d%d", a, b);
  n = atoi(c);
  sq = (int)sqrt(n);
  if (sq * sq == n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  int a, b, n, sq;
  char c[100];
  scanf("%d%d", &a, &b);
  sprintf(c, "%d%d", a, b);
  n = atoi(c);
  sq = (int)sqrt(n);
  if (sq * sq == n)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03456 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char a[5], b[5], s[10];
  cin >> a >> b;
  strcat(a, b);
  int c = atoi(a);
  int flag = 0;
  for (int i = 0; i <= 10000; i++)
    if (i * i == c)
      flag = 1;
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char a[10], b[5], s[10];
  cin >> a >> b;
  strcat(a, b);
  int c = atoi(a);
  int flag = 0;
  for (int i = 0; i <= 10000; i++)
    if (i * i == c)
      flag = 1;
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03456 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a - b) % c << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;

int main() {
  string s, t;
  cin >> s >> t;
  int x = stoi(s + t);
  for (int i = 1; i <= 1000; ++i) {
    if (i * i == x) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}
Problem p03456 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int n = 1;
  while (true) {
    string s = to_string(n * n);
    if (s == a + b) {
      cout << "Yes" << endl;
      return 0;
    }
    if (s.size() > 6)
      break;
  }
  cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  int n = 1;
  while (true) {
    string s = to_string(n * n);
    if (s == a + b) {
      cout << "Yes" << endl;
      return 0;
    }
    if (s.size() > 6)
      break;
    n++;
  }
  cout << "No" << endl;
  return 0;
}
Problem p03456 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
char a[5], b[5];
int main() {
  cin >> a >> b;
  strcat(a, b);
  int ai = atoi(a);
  for (int i = 1; i * i <= ai; i++)
    if (i * i == ai) {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
using namespace std;
char a[7], b[7];
int main() {
  cin >> a >> b;
  strcat(a, b);
  int ai = atoi(a);
  for (int i = 1; i * i <= ai; i++)
    if (i * i == ai) {
      cout << "Yes" << endl;
      return 0;
    }
  cout << "No" << endl;
  return 0;
}
Problem p03456 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[5], b[5];
  cin >> a >> b;
  strcat(a, b);
  int c = atoi(a);
  if ((int)(sqrt(c)) * (int)(sqrt(c)) == c)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[10], b[10];
  cin >> a >> b;
  strcat(a, b);
  int c = atoi(a);
  if ((int)(sqrt(c)) * (int)(sqrt(c)) == c)
    puts("Yes");
  else
    puts("No");
  return 0;
}
Problem p03457 (C++)

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

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

  vector<int> t(11000);
  vector<int> x(11000);
  vector<int> y(11000);
  t.at(0) = 0, x.at(0) = 0, y.at(0) = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  bool can = true;

  for (int i = 0; i < N; i++) {
    int time = abs(t.at(i + 1) - t.at(i));
    int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
    if (dist > time)
      can = false;
    if (time % 2 != dist % 2)
      can = false;
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

  vector<int> t(110000);
  vector<int> x(110000);
  vector<int> y(110000);
  t.at(0) = 0, x.at(0) = 0, y.at(0) = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t.at(i) >> x.at(i) >> y.at(i);
  }
  bool can = true;

  for (int i = 0; i < N; i++) {
    int time = abs(t.at(i + 1) - t.at(i));
    int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
    if (dist > time)
      can = false;
    if (time % 2 != dist % 2)
      can = false;
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = b - 1; i >= a; i--)
#define REP(i, n) for (int i = 0; i < n; i++)
#define rREP(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 10001
typedef long long ll;
using namespace std;

int main(void) {
  int n;
  cin >> n;
  int t[MAX], x[MAX], y[MAX];
  bool flag = true;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  rep(i, 1, n + 1) { cin >> t[i] >> x[i] >> y[i]; }
  rep(i, 1, n + 1) {
    if (!flag)
      break;
    int dTime = t[i] - t[i - 1];
    int dis = abs(x[i] + y[i] - x[i - 1] - y[i - 1]);
    if (dis > dTime || dTime % 2 != dis % 2) {
      flag = false;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = b - 1; i >= a; i--)
#define REP(i, n) for (int i = 0; i < n; i++)
#define rREP(i, n) for (int i = n - 1; i >= 0; i--)
#define MAX 100001
typedef long long ll;
using namespace std;

int main(void) {
  int n;
  cin >> n;
  int t[MAX], x[MAX], y[MAX];
  bool flag = true;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  rep(i, 1, n + 1) { cin >> t[i] >> x[i] >> y[i]; }
  rep(i, 1, n + 1) {
    if (!flag)
      break;
    int dTime = t[i] - t[i - 1];
    int dis = abs(x[i] + y[i] - x[i - 1] - y[i - 1]);
    if (dis > dTime || dTime % 2 != dis % 2) {
      flag = false;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int, int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1, 0), x(n + 1, 0), y(n, 0);
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  for (int i = 1; i < n + 1; i++) {
    int dis = abs(x[i] - x[i - 1] + y[i] - y[i - 1]);
    int dif = t[i] - t[i - 1];
    if (dis % 2 != dif % 2 || dif < dis) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int, int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1, 0), x(n + 1, 0), y(n + 1, 0);
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  for (int i = 1; i < n + 1; i++) {
    int dis = abs(x[i] - x[i - 1] + y[i] - y[i - 1]);
    int dif = t[i] - t[i - 1];
    if (dis % 2 != dif % 2 || dif < dis) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p03457 (C++)

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  vector<int> Y(N);
  vector<int> T(N);
  X[0] = Y[0] = T[0] = 0;
  for (int i = 0; i < N; i++)
    cin >> T[i + 1] >> X[i + 1] >> Y[i + 1];

  bool f = true;
  for (int i = 0; i < N; i++) {
    int d = T[i + 1] - T[i];
    int dist = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]);
    if (dist > d)
      f = false;
    if (dist % 2 != d % 2)
      f = false;
  }

  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N + 1);
  vector<int> Y(N + 1);
  vector<int> T(N + 1);
  X[0] = Y[0] = T[0] = 0;
  for (int i = 0; i < N; i++)
    cin >> T[i + 1] >> X[i + 1] >> Y[i + 1];

  bool f = true;
  for (int i = 0; i < N; i++) {
    int d = T[i + 1] - T[i];
    int dist = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i]);
    if (dist > d)
      f = false;
    if (dist % 2 != d % 2)
      f = false;
  }

  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03457 (C++)

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

int main() {
  int i, n, array[10001], array2[10001], array3[10001];
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> array[i] >> array2[i] >> array3[i];
  }
  if (array2[0] + array3[0] > array[0] ||
      (array[0] - array2[0] - array3[0]) % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 0; i < n - 1; i++) {
    if ((array2[i + 1] - array2[i] + array3[i + 1] - array3[i]) <=
            array[i + 1] &&
        (array[i + 1] - array[i] -
         (array2[i + 1] - array2[i] + array3[i + 1] - array3[i])) %
                2 ==
            0) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
  int i, n, array[100001], array2[100001], array3[100001];
  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> array[i] >> array2[i] >> array3[i];
  }
  if (array2[0] + array3[0] > array[0] ||
      (array[0] - array2[0] - array3[0]) % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (i = 0; i < n - 1; i++) {
    if ((array2[i + 1] - array2[i] + array3[i + 1] - array3[i]) <=
            array[i + 1] &&
        (array[i + 1] - array[i] -
         (array2[i + 1] - array2[i] + array3[i + 1] - array3[i])) %
                2 ==
            0) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;

int main() {

  int n, t[10000], x[10000], y[10000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (t[i] < (abs(x[i]) + abs(y[i])) ||
          (t[i] % 2 != 0 && (abs(x[i]) + abs(y[i])) % 2 == 0) ||
          t[i] % 2 != 0 && (abs(x[i]) + abs(y[i])) % 2 == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (i != 0) {
      if ((t[i] - t[i - 1]) < (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) ||
          (((t[i] - t[i - 1]) % 2 == 0 &&
            (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 != 0) ||
           ((t[i] - t[i - 1]) % 2 != 0 &&
            (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 == 0))) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;

int main() {

  int n, t[100000], x[100000], y[100000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (t[i] < (abs(x[i]) + abs(y[i])) ||
          (t[i] % 2 != 0 && (abs(x[i]) + abs(y[i])) % 2 == 0) ||
          t[i] % 2 != 0 && (abs(x[i]) + abs(y[i])) % 2 == 0) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (i != 0) {
      if ((t[i] - t[i - 1]) < (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) ||
          (((t[i] - t[i - 1]) % 2 == 0 &&
            (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 != 0) ||
           ((t[i] - t[i - 1]) % 2 != 0 &&
            (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 == 0))) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}
Problem p03457 (C++)

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

int main() {
  int travel_count;
  int time[travel_count];
  int x_pos[travel_count];
  int y_pos[travel_count];
  int now_xpos = 0;
  int now_ypos = 0;
  int now_time = 0;
  cin >> travel_count;
  for (int i = 0; i < travel_count; i++) {
    cin >> time[i] >> x_pos[i] >> y_pos[i];
  }
  for (int i = 0; i < travel_count; i++) {
    int need_minimum_travel =
        abs(x_pos[i] - now_xpos) + abs(y_pos[i] - now_ypos);
    int can_travel_num = time[i] - now_time;

    if (can_travel_num < need_minimum_travel) {
      cout << "No" << endl;
      return 0;
    } else {
      if ((can_travel_num - need_minimum_travel) % 2 == 1) {
        cout << "No" << endl;
        return 0;
      }
    }

    now_xpos = x_pos[i];
    now_ypos = y_pos[i];
    now_time = time[i];
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main() {
  long travel_count;
  long time[travel_count];
  long x_pos[travel_count];
  long y_pos[travel_count];
  int now_xpos = 0;
  int now_ypos = 0;
  int now_time = 0;
  cin >> travel_count;
  for (int i = 0; i < travel_count; i++) {
    cin >> time[i] >> x_pos[i] >> y_pos[i];
  }
  for (int i = 0; i < travel_count; i++) {
    int need_minimum_travel =
        abs(x_pos[i] - now_xpos) + abs(y_pos[i] - now_ypos);
    int can_travel_num = time[i] - now_time;

    if (can_travel_num < need_minimum_travel) {
      cout << "No" << endl;
      return 0;
    } else {
      if ((can_travel_num - need_minimum_travel) % 2 == 1) {
        cout << "No" << endl;
        return 0;
      }
    }

    now_xpos = x_pos[i];
    now_ypos = y_pos[i];
    now_time = time[i];
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
  int n;
  int t[10001], x[10001], y[10001];

  t[0] = x[0] = y[0] = 0;

  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool can = true;
  // t[i]秒で(x[i],y[i])に移動できるか調べていく
  for (int i = 1; i < n + 1; i++) {
    int dt = t[i] - t[i - 1];
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
  int n;
  int t[110000], x[110000], y[110000];

  t[0] = x[0] = y[0] = 0;

  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool can = true;
  // t[i]秒で(x[i],y[i])に移動できるか調べていく
  for (int i = 1; i < n + 1; i++) {
    int dt = t[i] - t[i - 1];
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03457 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }

  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  int t[110000], x[110000], y[110000];
  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }

  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03457 (C++)

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

int n;
int t[10000];
int x[10000];
int y[10000];

int main() {
  cin >> n;
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool can = 1;
  int dt, dist;
  for (int i = 0; i < n; i++) {
    dt = t[i + 1] - t[i];
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist || dt % 2 != dist % 2) {
      can = 0;
      break;
    }
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int n;
int t[100010];
int x[100010];
int y[100010];

int main() {
  cin >> n;
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool can = 1;
  int dt, dist;
  for (int i = 0; i < n; i++) {
    dt = t[i + 1] - t[i];
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist || dt % 2 != dist % 2) {
      can = 0;
      break;
    }
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03457 (C++)

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

using namespace std;

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

  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);

  for (int i = 1; i <= N; i++)
    cin >> t[i] >> x[i] >> y[i];

  bool can = true;
  for (int i = 1; i <= N; i++) {
    if (t[i] < x[i] + y[i]) {
      can = false;
    }
    if ((t[i] - x[i] - y[i]) % 2 != 0) {
      can = false;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

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

using namespace std;

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

  int t[N];
  int x[N];
  int y[N];

  for (int i = 1; i <= N; i++)
    cin >> t[i] >> x[i] >> y[i];

  bool can = true;
  for (int i = 1; i <= N; i++) {
    if (t[i] < x[i] + y[i]) {
      can = false;
    }
    if ((t[i] - x[i] - y[i]) % 2 != 0) {
      can = false;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03457 (C++)

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

using namespace std;

int main() {
  int N = 0;
  cin >> N;

  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);

  for (int i = 0; i < N; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }

  bool flag = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      flag = false;
    if (dist % 2 != dt % 2)
      flag = false;
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

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

using namespace std;

int main() {
  int N = 0;
  cin >> N;

  vector<int> t(N + 1);
  vector<int> x(N + 1);
  vector<int> y(N + 1);

  for (int i = 0; i < N; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }

  bool flag = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      flag = false;
    if (dist % 2 != dt % 2)
      flag = false;
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03457 (C++)

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

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

  vector<int> t(n), x(n), y(n);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i <= n; i++) {
    if (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) > t[i] - t[i - 1] ||
        (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 !=
            (t[i] - t[i - 1]) % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

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

  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i <= n; i++) {
    if (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]) > t[i] - t[i - 1] ||
        (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 !=
            (t[i] - t[i - 1]) % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n, t[10001], x[10001], y[10001], a, b, c, i, j, k, tr;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (i = 1; i <= n; i++) {
    if ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) <= (t[i] - t[i - 1]) &&
        ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) - (t[i] - t[i - 1])) %
                2 ==
            0) {
      a = 0;
    } else {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Fixed submission:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  int n, t[1000001], x[1000001], y[1000001], a, b, c, i, j, k, tr;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (i = 1; i <= n; i++) {
    if ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) <= (t[i] - t[i - 1]) &&
        ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) - (t[i] - t[i - 1])) %
                2 ==
            0) {
      a = 0;
    } else {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
Problem p03457 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool at = true;
  for (int i = 0; i < n; i++) {
    int dist = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
    int d = t[i + 1] - t[i];
    if (d < dist)
      at = false;
    if (dist % 2 != d % 2)
      at = false;
  }
  if (at)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool at = true;
  for (int i = 0; i < n; i++) {
    int dist = abs(x[i] - x[i + 1]) + abs(y[i] - y[i + 1]);
    int d = t[i + 1] - t[i];
    if (d < dist)
      at = false;
    if (dist % 2 != d % 2)
      at = false;
  }
  if (at)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  x[0] = 0;
  t[0] = 0;
  y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool planex = true;
  rep(i, n) {
    int dt = t[i + 1] - t[i];
    int f = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (f > dt)
      planex = false;
    if (f % 2 != dt % 2)
      planex = false;
  }
  if (planex == false)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> t(110000);
  vector<int> x(110000);
  vector<int> y(110000);
  x[0] = t[0] = y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool planex = true;
  rep(i, n) {
    int dt = t[i + 1] - t[i];
    int f = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (f > dt)
      planex = false;
    if (f % 2 != dt % 2)
      planex = false;
  }
  if (planex == false)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
Problem p03457 (C++)

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

struct Point {
  int t;
  int x;
  int y;
  int dif;
  int dif_t;

  Point(int t = 0, int x = 0, int y = 0, int dif = 0, int dif_t = 0) {
    this->t = t;
    this->x = x;
    this->y = y;
    this->dif = dif;
    this->dif_t = dif_t;
  }
  bool operator<(const Point &p) const { return t < p.t; }
};

int main() {
  int n;
  cin >> n;
  vector<Point> points(n);
  rep(i, n) {
    cin >> points[i + 1].t >> points[i + 1].x >> points[i + 1].y;
    points[i + 1].dif =
        abs(points[i + 1].x - points[i].x) + abs(points[i + 1].y - points[i].y);
    points[i + 1].dif_t = points[i + 1].t - points[i].t;
    if ((points[i + 1].dif % 2 != points[i + 1].dif_t % 2) ||
        points[i + 1].dif > points[i + 1].dif_t) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

struct Point {
  int t;
  int x;
  int y;
  int dif;
  int dif_t;

  Point(int t = 0, int x = 0, int y = 0, int dif = 0, int dif_t = 0) {
    this->t = t;
    this->x = x;
    this->y = y;
    this->dif = dif;
    this->dif_t = dif_t;
  }
  bool operator<(const Point &p) const { return t < p.t; }
};

int main() {
  int n;
  cin >> n;
  vector<Point> points(n + 1);
  rep(i, n) {
    cin >> points[i + 1].t >> points[i + 1].x >> points[i + 1].y;
    points[i + 1].dif =
        abs(points[i + 1].x - points[i].x) + abs(points[i + 1].y - points[i].y);
    points[i + 1].dif_t = points[i + 1].t - points[i].t;
    if ((points[i + 1].dif % 2 != points[i + 1].dif_t % 2) ||
        points[i + 1].dif > points[i + 1].dif_t) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
#include <string>

std::string solve(int n) {
  int prev_t{0};
  int prev_x{0};
  int prev_y{0};
  for (int i = 0; i < n++; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    const auto dt{t - prev_t};
    const auto dx{abs(x - prev_x)};
    const auto dy{abs(y - prev_y)};
    const auto remaining_time{dt - (dx + dy)};
    if (0 <= remaining_time && remaining_time % 2 == 0) {
      prev_t = t;
      prev_x = x;
      prev_y = y;
    } else {
      return "No";
    }
  }
  return "Yes";
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}

Fixed submission:
#include <cmath>
#include <iostream>
#include <string>

std::string solve(int n) {
  int prev_t{0};
  int prev_x{0};
  int prev_y{0};
  for (int i = 0; i < n; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    const auto dt{t - prev_t};
    const auto dx{abs(x - prev_x)};
    const auto dy{abs(y - prev_y)};
    const auto remaining_time{dt - (dx + dy)};
    if (0 <= remaining_time && remaining_time % 2 == 0) {
      prev_t = t;
      prev_x = x;
      prev_y = y;
    } else {
      return "No";
    }
  }
  return "Yes";
}

int main() {
  int n;
  std::cin >> n;
  std::cout << solve(n) << std::endl;
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#define cinf(n, x, y, z)                                                       \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i] >> y[i] >> z[i];
typedef long long int ll;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }
  t[0] = x[0] = y[0] = 0;
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#define cinf(n, x, y, z)                                                       \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i] >> y[i] >> z[i];
typedef long long int ll;
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
  }
  t[0] = x[0] = y[0] = 0;
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

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

int main() {
  int N, t[N + 2], x[N + 2], y[N + 2];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  bool a = true;

  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < N; i++) {
    if (a) {
      bool b = false;
      int T = t[i + 1] - t[i];
      int R = x[i + 1] - x[i] + y[i + 1] - y[i];
      if (-T <= R & R <= T & (R - T) % 2 == 0) {
        b = true;
      }
      a = b;
    } else {
      break;
    }
  }

  if (a) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}

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

int main() {
  int N, t[100010], x[100010], y[100010];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  bool a = true;

  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 0; i < N; i++) {
    if (a) {
      bool b = false;
      int T = t[i + 1] - t[i];
      int R = x[i + 1] - x[i] + y[i + 1] - y[i];
      if (-T <= R & R <= T & (R - T) % 2 == 0) {
        b = true;
      }
      a = b;
    } else {
      break;
    }
  }

  if (a) {
    cout << "Yes" << endl;
  }

  else {
    cout << "No" << endl;
  }
}
Problem p03457 (C++)

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

ll N;
vector<ll> t, x, y;

int main() {
  cin >> N;
  t.resize(N), x.resize(N), y.resize(N);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++)
    scanf("%Ld%Ld%Ld", &t[i], &x[i], &y[i]);
  int flag = 1;
  for (int i = 0; i < N && flag; i++) {
    int dt = t[i + 1] - t[i];
    int dx = abs(x[i + 1] - x[i]);
    int dy = abs(y[i + 1] - y[i]);
    if (dt < dx + dy)
      flag = 0;
    else if (dt % 2 != (dx + dy) % 2)
      flag = 0;
  }
  cout << (flag ? "Yes" : "No") << endl;
}

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

ll N;
vector<ll> t, x, y;

int main() {
  cin >> N;
  t.resize(N + 1), x.resize(N + 1), y.resize(N + 1);
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++)
    scanf("%Ld%Ld%Ld", &t[i], &x[i], &y[i]);
  int flag = 1;
  for (int i = 0; i < N && flag; i++) {
    int dt = t[i + 1] - t[i];
    int dx = abs(x[i + 1] - x[i]);
    int dy = abs(y[i + 1] - y[i]);
    if (dt < dx + dy)
      flag = 0;
    else if (dt % 2 != (dx + dy) % 2)
      flag = 0;
  }
  cout << (flag ? "Yes" : "No") << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[550][550];

int main() {
  cin >> n;
  s = "Yes";
  ll q, p, r;
  q = p = r = 0;
  rep(i, 0, n) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (abs(q - a) % abs(abs(p - b) + abs(r - c)))
      s = "No";
    q = a;
    p = b;
    r = c;
  }
  print(s);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <exception>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define per(i, a, n) for (ll i = (a); i > (n); i--)
#define lep(i, a, n) for (ll i = (a); i <= (n); i++)
#define pel(i, a, n) for (ll i = (a); i >= (n); i--)
#define clr(a, b) memset((a), (b), sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9 + 7;
ll n, m, l;
string s, t;
ll d[200010], dp[550][550];

int main() {
  cin >> n;
  s = "Yes";
  ll q, p, r;
  q = p = r = 0;
  rep(i, 0, n) {
    ll a, b, c;
    cin >> a >> b >> c;
    if (abs(abs(p - b) + abs(r - c)) == 0) {
      s = "No";
      break;
    }
    if (abs(q - a) % abs(abs(p - b) + abs(r - c)))
      s = "No";
    q = a;
    p = b;
    r = c;
  }
  print(s);
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;
int f(int t1, int x1, int y1, int t2, int x2, int y2) {
  if (t2 < t1) {
    return 0;
  }
  if (t2 == t1 && x2 == x1 && y2 == y1) {
    return 1;
  }
  if (f(t1, x1, y1, t2 - 1, x2, y2 - 1) == 1 ||
      f(t1, x1, y1, t2 - 1, x2, y2 + 1) == 1 ||
      f(t1, x1, y1, t2 - 1, x2 - 1, y2) == 1 ||
      f(t1, x1, y1, t2 - 1, x2 + 1, y2) == 1) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int a[100100][3];
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  for (int j = 0; j < N; j++) {
    if (j == 0) {
      if (f(0, 0, 0, a[0][0], a[0][1], a[0][2]) == 0) {
        printf("No");
        return 0;
      }
    } else {
      if (f(a[j - 1][0], a[j - 1][1], a[j - 1][2], a[j][0], a[j][1], a[j][2]) ==
          0) {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
int f(int t1, int x1, int y1, int t2, int x2, int y2) {
  int t = t2 - t1;
  int d = abs(x2 - x1) + abs(y2 - y1);
  if (t >= d && t % 2 == d % 2) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int a[100100][3];
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  for (int j = 0; j < N; j++) {
    if (j == 0) {
      if (f(0, 0, 0, a[0][0], a[0][1], a[0][2]) == 0) {
        printf("No");
        return 0;
      }
    } else {
      if (f(a[j - 1][0], a[j - 1][1], a[j - 1][2], a[j][0], a[j][1], a[j][2]) ==
          0) {
        printf("No");
        return 0;
      }
    }
  }
  printf("Yes");
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i < n + 1; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }
  rep(i, n) {
    if (t[i + 1] - t[i] < x[i + 1] - x[i] + y[i + 1] - y[i]) {
      cout << "No" << endl;
      return 0;
    } else if ((t[i + 1] - t[i] - (x[i + 1] - x[i] + y[i + 1] - y[i])) % 2 !=
               0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1);
  vector<int> x(n + 1);
  vector<int> y(n + 1);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i < n + 1; ++i) {
    cin >> t[i] >> x[i] >> y[i];
  }
  rep(i, n) {
    if (t[i + 1] - t[i] < x[i + 1] - x[i] + y[i + 1] - y[i]) {
      cout << "No" << endl;
      return 0;
    } else if ((t[i + 1] - t[i] - (x[i + 1] - x[i] + y[i + 1] - y[i])) % 2 !=
               0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REP1(j, n) for (int j = 0; j < (int)n; ++j)
#define REPD(i, n) for (int i = n; i >= 0; --i)
#define REPD1(j, n) for (int j = n; j = > 0; --j)
#define REPS(i, n) for (int i = 1; i <= (int)n; ++i)
#define REPS1(j, n) for (int j = 1; j <= (int)n; ++j)
#define rep(i, a, n) for (int i = a; i <= (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define DescSort(a) sort(a.begin(), a.end(), std::greater<int>())

using namespace std;
typedef long long ll;

typedef struct Plan {
  int t;
  int x;
  int y;
} Plan;
int main(void) {
  int n;
  cin >> n;
  vector<Plan> p(n);
  int dt, dist = 0;
  p[0].t = p[0].x = p[0].y = 0;
  REPS(i, n) { cin >> p[i].t >> p[i].x >> p[i].y; }
  bool can = true;
  REP(i, n) {
    dt = abs(p[i + 1].t - p[i].t);
    dist = abs(p[i].x - p[i + 1].x) + abs((p[i].y - p[i + 1].y));
    if (dt < dist || (dt % 2 != dist % 2)) {
      can = false;
      break;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <iostream>
#include <map>
#include <stdlib.h>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define REP1(j, n) for (int j = 0; j < (int)n; ++j)
#define REPD(i, n) for (int i = n; i >= 0; --i)
#define REPD1(j, n) for (int j = n; j = > 0; --j)
#define REPS(i, n) for (int i = 1; i <= (int)n; ++i)
#define REPS1(j, n) for (int j = 1; j <= (int)n; ++j)
#define rep(i, a, n) for (int i = a; i <= (int)n; ++i)
#define SZ(x) ((int)(x).size()) // size() unsigned -> int
#define DescSort(a) sort(a.begin(), a.end(), std::greater<int>())

using namespace std;
typedef long long ll;

typedef struct Plan {
  int t;
  int x;
  int y;
} Plan;
int main(void) {
  int n;
  cin >> n;
  vector<Plan> p(100005);
  int dt, dist = 0;
  p[0].t = p[0].x = p[0].y = 0;
  REPS(i, n) { cin >> p[i].t >> p[i].x >> p[i].y; }
  bool can = true;
  REP(i, n) {
    dt = abs(p[i + 1].t - p[i].t);
    dist = abs(p[i].x - p[i + 1].x) + abs((p[i].y - p[i + 1].y));
    if (dt < dist || (dt % 2 != dist % 2)) {
      can = false;
      break;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p03457 (C++)

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

int main() {
  int N, t[10010], x[10010], y[10010];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool can = true;
  int dt, dx, dy, dd;
  for (int i = 0; i < N; i++) {
    dt = t[i + 1] - t[i];
    dx = abs(x[i + 1] - x[i]);
    dy = abs(y[i + 1] - y[i]);

    dd = dx + dy;
    if (dt < dd || (dt % 2 != dd % 2)) {
      can = false;
      break;
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main() {
  int N, t[100100], x[100100], y[100100];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  bool can = true;
  int dt, dx, dy, dd;
  for (int i = 0; i < N; i++) {
    dt = t[i + 1] - t[i];
    dx = abs(x[i + 1] - x[i]);
    dy = abs(y[i + 1] - y[i]);

    dd = dx + dy;
    if (dt < dd || (dt % 2 != dd % 2)) {
      can = false;
      break;
    }
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p03457 (C++)

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

int t[11000], x[11000], y[11000];
int main() {
  int n;
  cin >> n;
  t[0] = x[0] = x[0] = 0;
  for (int i = 1; i < n + 1; i++)
    cin >> t[i] >> x[i] >> y[i];
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist || dist % 2 != dt % 2)
      can = false;
  }
  cout << (can ? "Yes" : "No") << endl;
}


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

int t[110000], x[110000], y[110000];
int main() {
  int n;
  cin >> n;
  t[0] = x[0] = x[0] = 0;
  for (int i = 1; i < n + 1; i++)
    cin >> t[i] >> x[i] >> y[i];
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist || dist % 2 != dt % 2)
      can = false;
  }
  cout << (can ? "Yes" : "No") << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  x[0] = t[0] = y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool planex = true;
  rep(i, n) {
    int dt = t[i + 1] - t[i];
    int f = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (f > dt)
      planex = false;
    if (f % 2 != dt % 2)
      planex = false;
  }
  if (planex == false)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1);
  vector<int> x(n + 1);
  vector<int> y(n + 1);
  x[0] = 0;
  t[0] = 0;
  y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool planex = true;
  rep(i, n) {
    int dt = t[i + 1] - t[i];
    int f = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (f > dt)
      planex = false;
    if (f % 2 != dt % 2)
      planex = false;
  }
  if (planex == false)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[11000], x[11000], y[11000];
  t[0] = x[0] = y[0] = 0;
  bool can = true;

  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

  for (int i = 0; i < N; ++i) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dt % 2 != dist % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Fixed submission:
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  t[0] = x[0] = y[0] = 0;
  bool can = true;

  cin >> N;
  for (int i = 0; i < N; ++i)
    cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

  for (int i = 0; i < N; ++i) {
    int dt = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dist)
      can = false;
    if (dt % 2 != dist % 2)
      can = false;
  }

  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}