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

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

int main() {

  int N;
  cin >> N;

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

  bool flag = true;
  for (int i = 0; i < N; i++) {
    int dt = 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 (dt < dist)
      flag = false;
    if (dt % 2 != dist % 2)
      flag = false;
  }

  if (flag)
    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), x(110000), y(110000);
  for (int i = 0; i < N; i++) {
    cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1);
  }

  bool flag = true;
  for (int i = 0; i < N; i++) {
    int dt = 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 (dt < dist)
      flag = false;
    if (dt % 2 != dist % 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;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool f = true;
  rep(i, n) {
    if ((t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) ||
        ((t[i + 1] - t[i]) % 2 !=
         (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) % 2)) {
      f = false;
      break;
    }
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool f = true;
  rep(i, n) {
    if ((t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) ||
        ((t[i + 1] - t[i]) % 2 !=
         (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) % 2)) {
      f = false;
      break;
    }
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

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

int main(int argc, char const *argv[]) {
  int N;
  int t[10010], x[10010], y[10010];
  scanf("%d", &N);
  t[0] = 0;
  x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  bool ans = true;
  for (int i = 1; i <= N; i++) {
    int difft = abs(t[i] - t[i - 1]);
    int diffx = abs(x[i] - x[i - 1]);
    int diffy = abs(y[i] - y[i - 1]);
    if (diffx + diffy > difft) {
      ans = false;
    }
    if ((diffx + diffy + difft) % 2 != 0) {
      ans = false;
    }
  }

  printf(ans ? "Yes" : "No");

  return 0;
}


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

int main(int argc, char const *argv[]) {
  int N;
  int t[100010], x[100010], y[100010];
  scanf("%d", &N);
  t[0] = 0;
  x[0] = y[0] = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%d %d %d", &t[i], &x[i], &y[i]);
  }
  bool ans = true;
  for (int i = 1; i <= N; i++) {
    int difft = abs(t[i] - t[i - 1]);
    int diffx = abs(x[i] - x[i - 1]);
    int diffy = abs(y[i] - y[i - 1]);
    if (diffx + diffy > difft) {
      ans = false;
    }
    if ((diffx + diffy + difft) % 2 != 0) {
      ans = false;
    }
  }

  printf(ans ? "Yes" : "No");

  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 < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(), (x).end()
int INF = 100000000;

int main() {
  ll N;
  cin >> N;
  vector<ll> t(N), x(N), y(N);
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep2(i, 1, N + 1) { cin >> t[i] >> x[i] >> y[i]; }
  bool flag = true;
  rep(i, N) {
    ll time = t[i + 1] - t[i];
    ll x_tmp = abs(x[i + 1] - x[i]);
    ll y_tmp = abs(y[i + 1] - y[i]);
    if (time % 2 != (x_tmp + y_tmp) % 2) {
      flag = false;
      break;
    } else if (x_tmp + y_tmp > time) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(), (x).end()
int INF = 100000000;

int main() {
  ll N;
  cin >> N;
  vector<ll> t(N + 1), x(N + 1), y(N + 1);
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep2(i, 1, N + 1) { cin >> t[i] >> x[i] >> y[i]; }
  bool flag = true;
  rep(i, N) {
    ll time = t[i + 1] - t[i];
    ll x_tmp = abs(x[i + 1] - x[i]);
    ll y_tmp = abs(y[i + 1] - y[i]);
    if (time % 2 != (x_tmp + y_tmp) % 2) {
      flag = false;
      break;
    } else if (x_tmp + y_tmp > time) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < b; i++)
inline constexpr int intpow(ll a, ll b) {
  if (b == 0)
    return 1;
  ll ans = intpow(a, b / 2);
  return ans * ans * (b & 1 ? a : 1);
}
int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  t[0] = 0, x[0] = 0, y[0] = 0;
  rep(i, 1, n + 1) { cin >> t[i] >> x[i] >> y[i]; }
  rep(i, 0, n) {
    if (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i] ||
        (x[i] + y[i]) % 2 != t[i] % 2) {
      cout << "No";
      return 0;
    }
  }
  if ((x[n] + y[n]) % 2 != t[n] % 2) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (ll i = a; i < b; i++)
inline constexpr int intpow(ll a, ll b) {
  if (b == 0)
    return 1;
  ll ans = intpow(a, b / 2);
  return ans * ans * (b & 1 ? a : 1);
}
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;
  rep(i, 1, n + 1) { cin >> t[i] >> x[i] >> y[i]; }
  rep(i, 0, n) {
    if (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i] ||
        (x[i] + y[i]) % 2 != t[i] % 2) {
      cout << "No";
      return 0;
    }
  }
  if ((x[n] + y[n]) % 2 != t[n] % 2) {
    cout << "No";
    return 0;
  }
  cout << "Yes";
}
Problem p03457 (C++)

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

using namespace std;

int main() {
  int N;
  int t[10001];
  int x[10001];
  int y[10001];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool is_ok = true;
  // cout << "-------------" << endl;
  for (int i = 0; i <= N - 1; i++) {
    // cout << t[i] << "," << x[i] << ',' << y[i] << endl;
    int z = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    int t_diff = t[i + 1] - t[i];
    // cout << "z:" << z << ",t_diff:" << t_diff << endl;
    if (z == t_diff) {
      // cout << i << ":OK" << endl;
    } else if (z < t_diff && (t_diff - z) % 2 == 0) {
      // cout << i << ":OK" << endl;
    } else {
      // cout << i << ":NG" << endl;
      is_ok = false;
    }
    if (!is_ok) {
      cout << "No" << endl;
      break;
    }
  }
  if (is_ok) {
    cout << "Yes" << endl;
  }
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int N;
  int t[100001];
  int x[100001];
  int y[100001];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool is_ok = true;
  // cout << "-------------" << endl;
  for (int i = 0; i <= N - 1; i++) {
    // cout << t[i] << "," << x[i] << ',' << y[i] << endl;
    int z = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    int t_diff = t[i + 1] - t[i];
    // cout << "z:" << z << ",t_diff:" << t_diff << endl;
    if (z == t_diff) {
      // cout << i << ":OK" << endl;
    } else if (z < t_diff && (t_diff - z) % 2 == 0) {
      // cout << i << ":OK" << endl;
    } else {
      // cout << i << ":NG" << endl;
      is_ok = false;
    }
    if (!is_ok) {
      cout << "No" << endl;
      break;
    }
  }
  if (is_ok) {
    cout << "Yes" << endl;
  }
}
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;

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  t[0] = x[0] = y[0] = 0;                            // 初期状態
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; // 1-index にしておく

  bool can = true;
  rep(i, n) {
    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; // dist と dt の偶奇は一致する必要あり！
  }

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


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

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;                            // 初期状態
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; // 1-index にしておく

  bool can = true;
  rep(i, n) {
    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; // dist と dt の偶奇は一致する必要あり！
  }

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

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

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

  std::vector<int> x(N);
  std::vector<int> y(N);
  std::vector<int> t(N);
  x[0] = 0;
  y[0] = 0;
  t[0] = 0;
  for (int i = 1; i < N + 1; ++i) {
    std::cin >> t[i] >> x[i] >> y[i];
  }
  bool can = true;
  for (int i = 1; i < N + 1; ++i) {
    int time = t[i] - t[i - 1];
    int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (((time - dis) % 2 != 0) || (time - dis < 0)) {
      // std::cout << "No" << "\n";
      // exit(1);
      can = false;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
using namespace std;

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

  std::vector<int> x(110000);
  std::vector<int> y(110000);
  std::vector<int> t(110000);
  x[0] = 0;
  y[0] = 0;
  t[0] = 0;
  for (int i = 1; i < N + 1; ++i) {
    std::cin >> t[i] >> x[i] >> y[i];
  }
  bool can = true;
  for (int i = 1; i < N + 1; ++i) {
    int time = t[i] - t[i - 1];
    int dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (((time - dis) % 2 != 0) || (time - dis < 0)) {
      // std::cout << "No" << "\n";
      // exit(1);
      can = false;
    }
  }
  if (can)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Time Limit Exceeded):

// https://atcoder.jp/contests/abc086/tasks/arc089_a

#include <iostream>
#include <vector>
using namespace std;

bool is_reachable_at_shortest_path(int t, int x, int y) {
  if (abs(x) + abs(y) != t) {
    return false;
  }
  return true;
}

bool is_travelable(int t, int x, int y) {
  if (t < 0) {
    return false;
  }
  if (t == 0) {
    return x == 0 && y == 0;
  }
  return is_reachable_at_shortest_path(t, x, y) || is_travelable(t - 2, x, y);
}
int main() {
  int N;
  cin >> N;
  int t{}, x{}, y{};
  int tt{}, xx{}, yy{};
  for (int i = 0; i < N; ++i) {
    cin >> tt;
    cin >> xx;
    cin >> yy;
    if (!is_travelable(tt - t, xx - x, yy - y)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Fixed submission:

// https://atcoder.jp/contests/abc086/tasks/arc089_a

#include <iostream>
#include <vector>
using namespace std;

bool is_reachable_at_shortest_path(int t, int x, int y) {
  if (abs(x) + abs(y) != t) {
    return false;
  }
  return true;
}

bool is_travelable(int t, int x, int y) {
  if (t < 0) {
    return false;
  }
  if (t == 0) {
    return x == 0 && y == 0;
  }
  return is_reachable_at_shortest_path(t, x, y) || is_travelable(t - 2, x, y);
}
int main() {
  int N;
  cin >> N;
  int t{}, x{}, y{};
  int tt{}, xx{}, yy{};
  for (int i = 0; i < N; ++i) {
    cin >> tt;
    cin >> xx;
    cin >> yy;
    if (!is_travelable(tt - t, xx - x, yy - y)) {
      cout << "No" << endl;
      return 0;
    }
    t = tt;
    x = xx;
    y = yy;
  }
  cout << "Yes" << endl;
}
Problem p03457 (C++)

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

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

  t[0] = x[0] = y[0] = 0;
  for (int i = 0; i < n; i++)
    cin >> t[i + 1] >> x[i + 1] >> y[i + 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)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }

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

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

int main() {
  int n, t[110000], x[110000], y[110000];
  cin >> 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 == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p03457 (C++)

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

#define lim 10010
struct point {
  int x, y, t;
};

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

  // 移動する絶対量が十分にあるうえで余りが偶数ならば移動可能
  point start = {};
  for (int i = 0; i < N; i++) {
    int delta_t = t[i] - start.t;
    int delta_x = abs(x[i] - start.x);
    int delta_y = abs(y[i] - start.y);
    int margin = delta_t - (delta_x + delta_y);
    if (margin >= 0 && margin % 2 == 0) {
      start = {x[i], y[i], t[i]};
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

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

#define lim 100100
struct point {
  int x, y, t;
};

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

  // 移動する絶対量が十分にあるうえで余りが偶数ならば移動可能
  point start = {};
  for (int i = 0; i < N; i++) {
    int delta_t = t[i] - start.t;
    int delta_x = abs(x[i] - start.x);
    int delta_y = abs(y[i] - start.y);
    int margin = delta_t - (delta_x + delta_y);
    if (margin >= 0 && margin % 2 == 0) {
      start = {x[i], y[i], t[i]};
    } else {
      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 N;
  int t[10010];
  int x[10010];
  int y[10010];
  bool available = true;

  cin >> N;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
    if (t[i] % 2 == 0 && (x[i] + y[i]) % 2 == 1) {
      available = false;
      break;
    } else if (t[i] % 2 == 1 && (x[i] + y[i]) % 2 == 0) {
      available = false;
      break;
    }
  }

  if (available) {
    for (int i = 1; i <= N; i++) {
      if (t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) {
        available = false;
        break;
      }
    }
  }

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

  return 0;
}


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

int main() {
  int N;
  int t[100010];
  int x[100010];
  int y[100010];
  bool available = true;

  cin >> N;
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
    if (t[i] % 2 == 0 && (x[i] + y[i]) % 2 == 1) {
      available = false;
      break;
    } else if (t[i] % 2 == 1 && (x[i] + y[i]) % 2 == 0) {
      available = false;
      break;
    }
  }

  if (available) {
    for (int i = 1; i <= N; i++) {
      if (t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) {
        available = false;
        break;
      }
    }
  }

  if (available) {
    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;
  int x[10010];
  int y[10010];
  int t[10010];
  x[0] = 0;
  y[0] = 0;
  t[0] = 0;
  cin >> n;
  for (int i = 1; i < n + 1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }

  for (int i = 1; i < n + 1; i++) {
    int distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int time = t[i] - t[i - 1];
    int po = time - distance;

    if (po >= 0 && po % 2 == 0) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

  for (int i = 1; i < n + 1; i++) {
    int distance = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    int time = t[i] - t[i - 1];
    int po = time - distance;

    if (po >= 0 && po % 2 == 0) {
      continue;
    } else {
      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>
#include <string.h>

int main() {
  int n;
  int t, x, y;
  int _t = 0, _x = 0, _y = 0;
  int dt, dx, dy;
  int dist;

  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    // printf("%d",i);
    scanf("%d%d%d", t, x, y);
    dt = t - _t;
    dx = x - _x;
    dy = y - _y;

    dist = abs(dx) + abs(dy);

    if (dt < dist) {
      printf("No");
      return 0;
    }
    if ((dist % 2) ^ (dt % 2)) {
      printf("No");
      return 0;
    }
  }
  printf("Yes");

  return 0;
}

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

int main() {
  int n;
  int t, x, y;
  int _t = 0, _x = 0, _y = 0;
  int dt, dx, dy;
  int dist;

  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    // printf("%d",i);
    scanf("%d%d%d", &t, &x, &y);
    dt = t - _t;
    dx = x - _x;
    dy = y - _y;

    dist = abs(dx) + abs(dy);

    if (dt < dist) {
      printf("No");
      return 0;
    }
    if ((dist % 2) ^ (dt % 2)) {
      printf("No");
      return 0;
    }
  }
  printf("Yes");

  return 0;
}
Problem p03457 (C++)

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

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

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

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

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

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

Fixed submission:
#include <iostream>
#include <math.h>

using namespace std;
int t[100005];
int x[100005];
int y[100005];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for (int i = 1; i <= n; i++) {
    if ((abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) % 2 !=
            (t[i] - t[i - 1]) % 2 ||
        (abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])) > t[i] - t[i - 1]) {
      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> t(n), x(n), y(n);
  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 dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dis) {
      can = false;
      break;
    }
    if (dt % 2 != dis % 2) {
      can = false;
      break;
    }
  }
  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(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];
  }
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i];
    int dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (dt < dis) {
      can = false;
      break;
    }
    if (dt % 2 != dis % 2) {
      can = false;
      break;
    }
  }
  if (can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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;
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

  bool ans = true;
  rep(i, n) {
    int time = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (t[i + 1] - t[i] < time)
      ans = false;
    if (((t[i + 1] - t[i]) % 2) != (time % 2))
      ans = false;
  }

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

  return 0;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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;
  rep(i, n) cin >> t[i + 1] >> x[i + 1] >> y[i + 1];

  bool ans = true;
  rep(i, n) {
    int time = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (t[i + 1] - t[i] < time)
      ans = false;
    if (((t[i + 1] - t[i]) % 2) != (time % 2))
      ans = false;
  }

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

  return 0;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
  int n, t[10005] = {0}, x[10005] = {0}, y[10005] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> t[i] >> x[i] >> y[i];
  bool check = true;
  for (int i = 1; i <= n; i++) {
    int dis = x[i] - x[i - 1] + y[i] - y[i - 1], tdis = t[i] - t[i - 1];
    if ((tdis < dis) || ((tdis - dis) % 2 != 0)) {
      check = false;
      break;
    }
  }
  if (check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;

int main() {
  int n, t[100005] = {0}, x[100005] = {0}, y[100005] = {0};
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> t[i] >> x[i] >> y[i];
  bool check = true;
  for (int i = 1; i <= n; i++) {
    int dis = x[i] - x[i - 1] + y[i] - y[i - 1], tdis = t[i] - t[i - 1];
    if ((tdis < dis) || ((tdis - dis) % 2 != 0)) {
      check = false;
      break;
    }
  }
  if (check)
    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 < n; i++)

int main() {
  int N;
  cin >> N;
  vector<int> t(N);
  vector<int> x(N);
  vector<int> y(N);
  t.at(0) = x.at(0) = y.at(0) = 0;
  rep(i, N) { cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1); }

  rep(i, N) {
    int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
    int dt = t.at(i + 1) - t.at(i);
    if (dt < dist) {
      cout << "No" << endl;
      return 0;
    }
    if (dt % 2 != dist % 2) {
      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++)

int main() {
  int N;
  cin >> N;
  vector<int> t(N + 1);
  vector<int> x(N + 1);
  vector<int> y(N + 1);
  t.at(0) = x.at(0) = y.at(0) = 0;
  rep(i, N) { cin >> t.at(i + 1) >> x.at(i + 1) >> y.at(i + 1); }

  rep(i, N) {
    int dist = abs(x.at(i + 1) - x.at(i)) + abs(y.at(i + 1) - y.at(i));
    int dt = t.at(i + 1) - t.at(i);
    if (dt < dist) {
      cout << "No" << endl;
      return 0;
    }
    if (dt % 2 != dist % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
Problem p03457 (C++)

Buggy submission (status: Runtime Error):
/* Author rumoisen */
/* created 2018/10/20 */

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no() {
  cout << "No" << endl;
  exit(0);
}
void yes() {
  cout << "Yes" << endl;
  exit(0);
}
void No() {
  cout << "NO" << endl;
  exit(0);
}
void Yes() {
  cout << "YES" << endl;
  exit(0);
}

using namespace std;

int main(void) {
  int n, t[11451], x[11451], y[11451];
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> t[i] >> x[i] >> y[i];
  t[0] = x[0] = y[0];
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i],
        dist = abs(x[i + 1] - x[i] + abs(y[i + 1] - y[i]));
    if (dist > dt)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }
  if (can)
    yes();
  else
    no();
  return 0;
}

Fixed submission:
/* Author rumoisen */
/* created 2018/10/20 */

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

void no() {
  cout << "No" << endl;
  exit(0);
}
void yes() {
  cout << "Yes" << endl;
  exit(0);
}
void No() {
  cout << "NO" << endl;
  exit(0);
}
void Yes() {
  cout << "YES" << endl;
  exit(0);
}

using namespace std;

int main(void) {
  int n, t[114514], x[114514], y[114514];
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> t[i] >> x[i] >> y[i];
  t[0] = x[0] = y[0];
  bool can = true;
  for (int i = 0; i < n; i++) {
    int dt = t[i + 1] - t[i],
        dist = abs(x[i + 1] - x[i] + abs(y[i + 1] - y[i]));
    if (dist > dt)
      can = false;
    if (dist % 2 != dt % 2)
      can = false;
  }
  if (can)
    yes();
  else
    no();
  return 0;
}
Problem p03457 (C++)

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

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

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

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n), x(n), y(n);
  t[0] = x[0] = y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool flag = true;
  rep(i, n) {
    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 (dt % 2 != dist % 2)
      flag = false;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = x[0] = y[0] = 0;
  rep(i, n) { cin >> t[i + 1] >> x[i + 1] >> y[i + 1]; }
  bool flag = true;
  rep(i, n) {
    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 (dt % 2 != dist % 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;
  int t[11000], x[11000], y[11000];
  cin >> 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 kyan = 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)
      kyan = 0;
    if (dt % 2 != dist % 2)
      kyan = 0;
  }

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

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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> 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 kyan = 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)
      kyan = 0;
    if (dt % 2 != dist % 2)
      kyan = 0;
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 10000000;

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

  bool ok = 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)
      ok = false;
    if (dt % 2 != dist % 2)
      ok = false;
  }

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


Fixed submission:
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const int INF = 10000000;

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

  bool ok = 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)
      ok = false;
    if (dt % 2 != dist % 2)
      ok = false;
  }

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

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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> 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]; // 1-indexにしておく

  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; // distとdtの偶奇は一致する必要あり
  }

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


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

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> 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]; // 1-indexにしておく

  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; // distとdtの偶奇は一致する必要あり
  }

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

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

int main(void) {
  int n;
  cin >> n;
  int t[10010], x[10010], y[10010];
  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 check = true;

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

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

int main(void) {
  int n;
  cin >> n;
  int t[100100], x[100100], y[100100];
  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 check = true;

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

Buggy submission (status: Runtime Error):

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[10001];
  int b[10001];
  int c[10001];
  a[0] = 0;
  b[0] = 0;
  c[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  for (int i = 0; i < n; i++) {
    int dt = a[i + 1] - a[i];
    int dx = b[i + 1] - b[i];
    int dy = c[i + 1] - c[i];
    if (dt < abs(dx) + abs(dy) || abs(dt + dy + dx) % 2 == 1) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Fixed submission:

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int a[100001];
  int b[100001];
  int c[100001];
  a[0] = 0;
  b[0] = 0;
  c[0] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  for (int i = 0; i < n; i++) {
    int dt = a[i + 1] - a[i];
    int dx = b[i + 1] - b[i];
    int dy = c[i + 1] - c[i];
    if (dt < abs(dx) + abs(dy) || abs(dt + dy + dx) % 2 == 1) {
      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 a[10001][3];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int z, x, y;
    cin >> z >> x >> y;
    a[i][0] = z;
    a[i][1] = x;
    a[i][2] = y;
    if (x + y > z) {
      cout << "No";
      return 0;
    }
    if (x + y - a[i - 1][1] - a[i - 1][2] > a[i][0] - a[i - 1][0] && i != 1) {
      cout << "No";
      return 0;
    }
    if ((x + y) % 2 != z % 2) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int a[100001][3];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int z, x, y;
    cin >> z >> x >> y;
    a[i][0] = z;
    a[i][1] = x;
    a[i][2] = y;
    if (x + y > z) {
      cout << "No";
      return 0;
    }
    if (x + y - a[i - 1][1] - a[i - 1][2] > a[i][0] - a[i - 1][0] && i != 1) {
      cout << "No";
      return 0;
    }
    if ((x + y) % 2 != z % 2) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
Problem p03457 (C++)

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

int main() {
  int N;
  int x[11000], y[11000], t[11000];
  cin >> 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 time = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (time < dist || time % 2 != dist % 2)
      can = false;
  }

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

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

int main() {
  int N;
  int x[110000], y[110000], t[110000];
  cin >> 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 time = t[i + 1] - t[i];
    int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if (time < dist || time % 2 != dist % 2)
      can = false;
  }

  if (can)
    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 = 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;
      break;
    }
    if (dist % 2 != dt % 2) {
      flag = false;
      break;
    }
  }

  if (flag)
    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(100010), x(100010), y(100010);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  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;
      break;
    }
    if (dist % 2 != dt % 2) {
      flag = false;
      break;
    }
  }

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

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

struct E {
  int t, x, y;
};
int main() {
  int N;
  std::cin >> N;
  std::vector<E> v;
  v.push_back(E{0, 0, 0});
  for (int i = 0; i < N; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    v.push_back(E{t, x, y});
  }
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N + 1; ++j) {
      if (std::abs(v[j].x - v[i].x) + std::abs(v[j].y - v[i].y) >
          v[j].t - v[i].t) {
        std::cout << "No" << std::endl;
        return 0;
      }
      if ((std::abs(v[j].x - v[i].x) + std::abs(v[j].y - v[i].y)) % 2 !=
          (v[j].t - v[i].t) % 2) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

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

struct E {
  int t, x, y;
};
int main() {
  int N;
  std::cin >> N;
  std::vector<E> v;
  v.push_back(E{0, 0, 0});
  for (int i = 0; i < N; ++i) {
    int t, x, y;
    std::cin >> t >> x >> y;
    v.push_back(E{t, x, y});
  }
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < i + 2; ++j) {
      if (std::abs(v[j].x - v[i].x) + std::abs(v[j].y - v[i].y) >
          v[j].t - v[i].t) {
        std::cout << "No" << std::endl;
        return 0;
      }
      if ((std::abs(v[j].x - v[i].x) + std::abs(v[j].y - v[i].y)) % 2 !=
          (v[j].t - v[i].t) % 2) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
Problem p03457 (C++)

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

int main() {
  int N;
  cin >> N;
  int t[MAX_N];
  int a[MAX_N];
  int b[MAX_N];
  for (int i = 1; i <= N; i++)
    cin >> t[i] >> a[i] >> b[i];

  for (int i = 0; i < N; i++) {
    int T = t[i + 1] - t[i];
    int D = abs(a[i + 1] - a[i]) + abs(b[i + 1] - b[i]);
    if (T < D || T % 2 != D % 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 100010

int main() {
  int N;
  cin >> N;
  int t[MAX_N];
  int a[MAX_N];
  int b[MAX_N];
  for (int i = 1; i <= N; i++)
    cin >> t[i] >> a[i] >> b[i];

  for (int i = 0; i < N; i++) {
    int T = t[i + 1] - t[i];
    int D = abs(a[i + 1] - a[i]) + abs(b[i + 1] - b[i]);
    if (T < D || T % 2 != D % 2) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}
Problem p03457 (C++)

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

int main(void) {
  int n;
  int t[10010];
  int x[10010];
  int y[10010];

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

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

  int dist, time;
  bool flag = true;

  for (int i = 0; i < n; i++) {
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    time = t[i + 1] - t[i];

    if ((dist <= time) && ((time % 2) == (dist % 2))) {
    } else {
      flag = false;
    }
  }

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

  return 0;
}

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

int main(void) {
  int n;
  int t[100010];
  int x[100010];
  int y[100010];

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

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

  int dist, time;
  bool flag = true;

  for (int i = 0; i < n; i++) {
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    time = t[i + 1] - t[i];

    if ((dist <= time) && ((time % 2) == (dist % 2))) {
    } else {
      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>
using namespace std;

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

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

int main(int argc, char **argv) {
  cin >> 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];
  std::cout << (solve() ? "Yes" : "No") << std::endl;
}

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

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

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

int main(int argc, char **argv) {
  cin >> 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];
  std::cout << (solve() ? "Yes" : "No") << std::endl;
}