Problem p03459 (C++)

Buggy submission (status: Runtime Error):
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 0X3F3F3F3F
#define N 10005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for (int i = a; i <= b; ++i)
#define RR(i, a, b) for (int i = a; i >= b; --i)
#define FJ(i, a, b) for (int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n) {
  char ch = getchar();
  n = 0;
  bool t = 0;
  for (; ch < '0'; ch = getchar())
    if (ch == '-')
      t = 1;
  for (; ch >= '0'; n = n * 10 + ch - '0', ch = getchar())
    ;
  if (t)
    n = -n;
}
inline void OO(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10)
    OO(a / 10);
  putchar(a % 10 + '0');
}
const double EPS = 1e-8;
bool sgn(double x) { return x > EPS - x < EPS; }
int n, a[N][3];
int main() {
  // IN;
  SC(n);
  FF(i, 1, n) SCCC(a[i][0], a[i][1], a[i][2]);
  bool ok = 1;
  FF(i, 1, n) {
    int t = abs(a[i][1] - a[i - 1][1]) + abs(a[i][2] - a[i - 1][2]);
    if (t > a[i][0] - a[i - 1][0])
      ok = 0;
    else if ((a[i][0] - a[i - 1][0] - t) % 2)
      ok = 0;
  }
  puts(ok ? "Yes" : "No");
  return 0;
}


Fixed submission:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 0X3F3F3F3F
#define N 200005
#define M 200005
#define LL long long
#define ULL unsigned long long
#define FF(i, a, b) for (int i = a; i <= b; ++i)
#define RR(i, a, b) for (int i = a; i >= b; --i)
#define FJ(i, a, b) for (int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define VI vector<int>
#define db double
#define PII pair<int, int>
#define PLL pair<unsigned long long, unsigned long long>
#define MP make_pair
#define PB push_back
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
inline void II(int &n) {
  char ch = getchar();
  n = 0;
  bool t = 0;
  for (; ch < '0'; ch = getchar())
    if (ch == '-')
      t = 1;
  for (; ch >= '0'; n = n * 10 + ch - '0', ch = getchar())
    ;
  if (t)
    n = -n;
}
inline void OO(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10)
    OO(a / 10);
  putchar(a % 10 + '0');
}
const double EPS = 1e-8;
bool sgn(double x) { return x > EPS - x < EPS; }
int n, a[N][3];
int main() {
  // IN;
  SC(n);
  FF(i, 1, n) SCCC(a[i][0], a[i][1], a[i][2]);
  bool ok = 1;
  FF(i, 1, n) {
    int t = abs(a[i][1] - a[i - 1][1]) + abs(a[i][2] - a[i - 1][2]);
    if (t > a[i][0] - a[i - 1][0])
      ok = 0;
    else if ((a[i][0] - a[i - 1][0] - t) % 2)
      ok = 0;
  }
  puts(ok ? "Yes" : "No");
  return 0;
}