Problem:
 Score : 300 points    Problem Statement AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0 , then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i .  If AtCoDeer is at point (x, y) at time t , he can be at one of the following points at time t+1 : (x+1,y) , (x-1,y) , (x,y+1) and (x,y-1) .
Note that he cannot stay at his place .
Determine whether he can carry out his plan.      Constraints  1  ≤  N  ≤  10^5  0  ≤  x_i  ≤  10^5  0  ≤  y_i  ≤  10^5  1  ≤  t_i  ≤  10^5  t_i  <  t_{i+1} ( 1  ≤  i  ≤  N-1 )  All input values are integers.         Input Input is given from Standard Input in the following format:  N  t_1  x_1  y_1  t_2  x_2  y_2  :  t_N  x_N  y_N       Output If AtCoDeer can carry out his plan, print Yes ; if he cannot, print No .        Sample Input 1 2
3 1 2
6 1 1      Sample Output 1 Yes  For example, he can travel as follows: (0,0) , (0,1) , (1,1) , (1,2) , (1,1) , (1,0) , then (1,1) .       Sample Input 2 1
2 100 100      Sample Output 2 No  It is impossible to be at (100,100) two seconds after being at (0,0) .       Sample Input 3 2
5 1 1
100 1 1      Sample Output 3 No

Solution (Python):

import sys

n = int(input())
t = []
x = []
y = []

t.append(0)
x.append(0)
y.append(0)

for i in range(n):
    a, b, c = map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)
    
for i in range(n):
    if t[i+1]-t[i] < (x[i+1] + y[i+1]) -(x[i] + y[i]) or (t[i+1]-t[i]-((x[i+1] + y[i+1]) -(x[i] + y[i])))%2 == 1:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
import numpy as np
import math






N = int(input())
T = []
X = []
Y = []

for n in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

curT = 0
curX = 0
curY = 0
for n in range(N):
    nextT = T[n]
    nextX = X[n]
    nextY = Y[n]

    minD = abs(curX - nextX) + abs(curY - nextY)
    deltaT = nextT - curT

    
    
    if deltaT >= minD and ((deltaT - minD) % 2 == 0):
        curT = nextT
        curX = nextX
        curY = nextY
    else:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]

ans = 'Yes'
t_cur, x_cur, y_cur = 0, 0, 0
for t, x, y in txy:
    d = abs(x-x_cur) + abs(y-y_cur)
    if t-t_cur >= d and ((t-t_cur)-d)%2 == 0:
        t_cur = t
        x_cur = x
        y_cur = y
    else:
        ans = 'No'
        break
    
print(ans)

Solution (Python):
N = int(raw_input())
data = []
for i in range(N):
    data.append(map(int, raw_input().split()))

for d in data:
    if d[0] < d[1] + d[2]:
        print("No")
        exit(0)
    elif d[0] > d[1] + d[2]:
        even0 = d[0] % 2 == 0
        even12 = (d[1] + d[2]) % 2 == 0
        if even0 ^ even12:
            print("No")
            exit(0)
print("Yes")

Solution (Python):
N=int(input())
for i in range(N):
  t,x,y = map(int,input().split())
  if x+y<=t and t%2==(x+y)%2:
    pass
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):
T=X=Y=f=0
for i in[0]*input():t,x,y=map(int,raw_input().split());f+=t-T<abs(x-X)+abs(y-Y)or(x+y+t+X+Y+T)%2;T,X,Y=t,x,y
print["Yes","No"][f>0]

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

t_ = x_ = y_ = flag = 0
for i in range(input()):
    t, x, y = map(int, raw_input().split())
    if t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2:
        print "No"
        exit()
    t_, x_, y_ = t, x, y

print "Yes"

Solution (Python):
t_ = x_ = y_ = flag = 0
for i in range(input()):
    t, x, y = map(int, raw_input().split())
    flag += t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2
    t_, x_, y_ = t, x, y

print ["Yes", "No"][flag > 0]

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

N = input()
t_, x_, y_ = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, raw_input().split())
    if t - t_ < abs(x - x_) + abs(y - y_) or (x + y + t + x_ + y_ + t_) % 2:
        flag = False
    t_, x_, y_ = t, x, y

print "Yes" if flag else "No"

Solution (Python):
N = int(input())

for _ in range(N):
    t, x, y = map(int, input().split())
    distance = x + y

    if distance > t or t % 2 != distance % 2:
        print("No")
        exit()

print("Yes")

Solution (Python):
n = int(input())
txy = []
for i in range(n):
    txy.append(list(map(int, input().split())))

for i in range(n):
    t = txy[i][0]
    t -= txy[i][1]
    t -= txy[i][2]
    if t < 0:
        print("No")
        break
    if t % 2 != 0:
        print("No")
        break
    if i == n-1:
        print("Yes")
        break
    else:
        txy[i+1][0] -= txy[i][0]
        txy[i+1][1] = abs(txy[i+1][1] - txy[i][1])
        txy[i+1][2] = abs(txy[i+1][2] - txy[i][2])

Solution (Python):
n = int(input())
pt = 0
px = 0
py = 0
l = []
for i in range(n):
    t,x,y = map(int,input().split())
    l.append((t,x,y))

for i in range(n):
    t,x,y = l[i]
    d = abs(x - px) + abs(y - py)
    dt = t - pt
    if d % 2 != dt % 2 or dt < d:
        print('No')
        exit()
print('Yes')

Solution (Python):


N = int(input())

now_txy = [0, 0, 0]

plan = []
for _ in range(N):
    plan.append(list(map(int, input().split())))

for i in range(N):
    next_txy = plan[i]
    diff = abs(next_txy[1] - now_txy[1]) + abs(next_txy[2] - now_txy[2]) - (next_txy[0] - now_txy[0])
    if (diff <= 0) & (diff % 2 == 0):
        now_txy = next_txy.copy()
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
n = int(input())
lists = [[0,0,0]]
for i in range(n):
  a = list(map(int,input().split()))
  lists.append(a)

diffs = []  
for i in range(1,n+1,1):
  diff = [ x - y for (x,y) in zip(lists[i], lists[i-1])]
  diffs.append(diff) 
  
for diff in diffs:
  if diff[0] < abs(diff[1]) + abs(diff[2]):
    print('No')
    exit()
  elif diff[0] % 2 != (abs(diff[1]) + abs(diff[2])) % 2:
    print('No')
    exit()
print('Yes')

Solution (Python):
N = int(input())
for i in range(N):
    t,x,y=map(int,input().split())
    if x+y>t or (t+x+y)%2 != 0:
        print("No")
        exit()
print("Yes")

Solution (Python):
from sys import stdin

N = int(stdin.readline().rstrip())
lst = [[0, 0, 0]]
for _ in range(N):
    t, x, y = [int(a) for a in stdin.readline().strip().split()]
    lst.append([t, x, y])

ans = True
for i in range(len(lst) - 1):
    dt = abs(lst[i + 1][0] - lst[i][0])
    dx = abs(lst[i + 1][1] - lst[i][1])
    dy = abs(lst[i + 1][2] - lst[i][2])

    if dx + dy > dt or dt % 2 != (dx + dy) % 2:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
t = [0];x = [0]
for _ in range(N):
    a,b,c = map(int,input().split())
    t.append(a)
    x.append(b+c)
flg = 1
for i in range(N):
    if ((x[i+1]-x[i])-(t[i+1]-t[i]))%2==1 or x[i+1]>t[i+1]:
        print("No")
        flg = 0
        break
if flg: print("Yes")

Solution (Python):

N = int(input())
Z=[]
for i in range(N):
	t, x, y = map(int, input().split())
	if t % 2 == 0:
		if x + y <= t and (x + y) % 2 == 0:
			Z.append(1)
		else:
			Z.append(0)
	else:
		if x + y <= t and (x + y) % 2 == 1:
			Z.append(1)
		else:
			Z.append(0)
	i += 1
if Z.count(0) >=1:
	print('No')
else:
	print('Yes')

Solution (Python):
N = int(input())
t0, x0, y0 = (0, 0, 0)

for _ in range(N):
	t1, x1, y1 = map(int, input().split())
	if abs(x1-x0)+abs(y1-y0) > t1-t0 or (abs(x1-x0)+abs(y1-y0))%2 != (t1-t0)%2:
		print('No')
		break
	t0, x0, y0 = t1, x1, y1
else:
	print('Yes')

Solution (Python):
n = int(input())
t1 = 0
x1 = 0
y1 = 0
boolean = True

for __ in range(n):
    t, x, y = [int(_) for _ in input().split()]
    if boolean:
        temp1 = x
        temp2 = t
        x = abs(x - x1) + abs(y - y1)
        t -= t1
        x1 = temp1
        y1 = y
        t1 = temp2
        if x > t or (x + t) % 2 == 1:
            boolean = False
if boolean:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
n = int(input())
T = []
X = []
Y = []
t1 = 0
x1 = 0
y1 = 0
for i in range(n):
    m = input().split()
    T.append(int(m[0]) - t1)
    t1 = int(m[0])
    X.append(abs(int(m[1]) - x1))
    x1 = int(m[1])
    Y.append(abs(int(m[2]) - y1))
    y1 = int(m[2])
T = np.array(T)
X = np.array(X)
Y = np.array(Y)
for i in range(n):
    if X[i] + Y[i] > T[i] or (X[i] + Y[i] + T[i]) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
N = int(input())
L = [list(map(int,input().split())) for i in range(N)]
flag = True

for i in range(0,N-1):
  T = L[i+1][0]-L[i][0]
  X = L[i+1][1]-L[i][1]
  Y = L[i+1][2]-L[i][2]
  if (T % 2 != (X+Y) % 2):
    flag = False
    break
  else:
    if (T < X+Y):
      flag = False
      break
if flag:
  if(L[0][0] % 2 != (L[0][1]+L[0][2]) % 2):
    flag = False
  else:
    if (L[0][0] < L[0][1]+L[0][2]):
      flag = False

if flag:
  print('Yes')
else:
  print('No')

Solution (Python):
(lambda ft: print(ft.reduce(lambda p, c: (p[0] < 0 or (lambda t, d: (d > t or d % 2 != t % 2))(c[0] - p[0], abs(c[1] - p[1]) + abs(c[2] - p[2]))) and [-1, -1, -1] or c, [list(map(int, input().split())) for _ in range(int(input()))], [0, 0, 0])[0] < 0 and "No" or "Yes"))(__import__("functools"))

Solution (Python):
t0 = 0
x0=0
y0=0
N = int(input())

ans='Yes'

for _ in range(N):
    t, x, y = [int(x) for x in input().split()]
    dist = abs(x-x0)+abs(y-y0)
    tt = t-t0
    if dist <= tt and (tt - dist)%2==0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Solution (Python):
'''input
2
3 1 2
6 1 1
'''
n = input()
arr = []
for i in range(n):
	t,x,y = map(int,raw_input().split())
	arr.append((t,x,y))
arr.sort()
cx,cy = 0,0
ct = 0
flag = False
for i in range(n):
	td = arr[i][0]-ct
	if abs(cx-arr[i][1])+abs(cy-arr[i][2]) > td or (td%2 != (abs(cx-arr[i][1])+abs(cy-arr[i][2]))%2):
		flag = True
		break
	else:
		cx,cy = arr[i][1],arr[i][2]
		ct = arr[i][0]
print "No" if flag else "Yes"

Solution (Python):
n=int(input())
a=[[0]*3 for i in range(n+1)]
for i in range(1,n+1):
    t,x,y=map(int,input().split())
    a[i][0]=t
    a[i][1]=x
    a[i][2]=y

for i in range(n):
    dist=abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])
    if dist>a[i+1][0]-a[i][0] or (dist-a[i+1][0]-a[i][0])%2==1 :
        print("No")
        exit()
print("Yes")

Solution (Python):


def main():
    N = int(input())

    pre_t, pre_x, pre_y = 0, 0, 0
    for i in range(N):
        t, x, y = list(map(int, input().split()))
        diff = abs(x-pre_x) + abs(y-pre_y)
        amari = (t-pre_t) - diff
        if amari < 0:
            
            print("No")
            exit()
        elif amari == 0:
            continue
        elif amari%2 == 0:
            
            continue
        else:
            print("No")
            exit()
    print("Yes")

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
P = [[int(c) for c in input().split()] for _ in range(N)]
current = [0, 0, 0]
accept = True

for t, x, y in P:
    dt = t - current[0]
    d = abs(current[1] - x) + abs(current[2] - y)
    if d > dt:
        accept = False
        break
    elif d % 2 != dt % 2:
        accept = False
        break
    else:
        current = [t, x, y]

if accept:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

N = int(input())
t = [0 for i in range(N+1)]
x = [0 for i in range(N+1)]
y = [0 for i in range(N+1)]

for i in range(1, N+1):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(N):
    time = t[i+1] - t[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if (time - dist) >= 0 and (time - dist) % 2 == 0:
        pass
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
n = int(input())

feasible = True
x = 0
y = 0
t = 0

for i in range(n):
    cp_t, cp_x, cp_y = map(int, input().split())
    if not feasible:
        continue

    step = abs(x - cp_x) + abs(y - cp_y)
    dt = cp_t - t
    if dt < step:
        feasible = False
    if (dt - step) % 2 != 0:
        feasible = False
    x = cp_x
    y = cp_y
    t = cp_t

if feasible:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
T = [0] * (N+1)
X = [0] * (N+1)
Y = [0] * (N+1)
flag = True
for i in range(1, N+1):
    T[i], X[i], Y[i] = list(map(int, input().split()))
for i in range(N):
    DIST = abs(X[i+1] - X[i]) + abs(Y[i+1]- Y[i])
    DIFF = T[i+1] - T[i]
    if (DIFF - DIST) % 2 == 1 or DIFF < DIST:
        flag = False
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
plan = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
diff = [[plan[i + 1][j] - plan[i][j] for j in range(3)] for i in range(N)]

def is_possible(t, x, y):
    if (t + x + y) % 2 == 0 and abs(x) + abs(y) <= t:
        return True
    else:
        return False

for i in range(N):
    ti, xi, yi = diff[i]
    if not is_possible(ti, xi, yi):
        print('No')
        exit()
print('Yes')

Solution (Python):
import numpy as np
N = int(input())
plan = np.array([[0, 0, 0]] + [list(map(int, input().split())) for i in range(N)])

diff = np.diff(plan, axis = 0)

def is_possible(t, x, y):
    if (t + x + y) % 2 == 0 and abs(x) + abs(y) <= t:
        return True
    else:
        return False

for i in range(N):
    ti, xi, yi = diff[i]
    if not is_possible(ti, xi, yi):
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if t < x + y or t % 2 != (x + y) % 2:
        print("No")
        exit()
        
print("Yes")

Solution (Python):
n = int(input())
data = [ list(map(int, input().split())) for i in range(n)]
data.insert(0, [0,0,0])
for i in range(n):
    differ = [(data[i+1][j] - data[i][j]) for j in range(3)]
    if abs(differ[0]) < (differ[1] + differ[2]):
        print("No")
        exit()
    elif differ[0] % 2 != (differ[1] + differ[2]) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
t = [0 for _ in range(n+1)]
x = [0 for _ in range(n+1)]
y = [0 for _ in range(n+1)]
for i in range(n):
    t[i+1], x[i+1], y[i+1] = [int(z) for z in input().split()]
    if t[i+1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) or (t[i+1] % 2 != (abs(x[i+1]) + abs(y[i+1])) % 2):
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
plan = []
for i in range(N):
    p = list(map(int, input().split()))
    plan.append(p)
x = 0
y = 0
t = 0
for p in plan:
    margin = p[0]-t
    if (abs(p[1] - x) + abs(p[2] - y)) > margin:
        print("No")
        exit()
    if (abs(p[1] - x) + abs(p[2] - y)) % 2 != margin % 2:
        print("No")
        exit()
    t = p[0]
    x = p[1]
    y = p[2]

print("Yes")

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N = int(input())
    now_t, now_x, now_y = 0, 0, 0
    for i in range(N):
        t, x, y = map(int, input().split())

        a = abs(now_x - x) + abs(now_y - y)
        b = t - now_t
        if a > b or a % 2 != b % 2:
            print(No)
            return

        now_t, now_x, now_y = t, x, y

    print(Yes)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

for i in range(n):
  t[i+1], x[i+1], y[i+1] = map(int, input().split())
  
for i in range(n):
  tdiff = t[i+1]-t[i]
  ddiff = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
  if tdiff < ddiff or (tdiff % 2) != (ddiff % 2):
    print("No")
    exit(0)

print("Yes")

Solution (Python):
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):
    a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i]
    if a>0 or a%2:flag=0;break
print("Yes" if flag else "No")

Solution (Python):
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):
    dl=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    dt=t[i+1]-t[i]
    if dl>dt or (dl-dt)%2 == 1:
        flag = 0
        break
print("Yes" if flag else "No")

Solution (Python):
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1)
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
flag=1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
txy = [[0,0,0] if i==0 else list(map(int,input().split())) for i in range(n+1)]

flag = True
for i in range(n):
	dist = abs(txy[i][1]-txy[i+1][1]) + abs(txy[i][2]-txy[i+1][2])
	time = txy[i+1][0] - txy[i][0]
	dif = time - dist
	if dif<0 or dif%2==1:			
		flag = False
		break

print('Yes' if flag else 'No')

Solution (Python):
n = int(input())
ti=0
xi=0
yi=0
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(x-xi) + abs(y-yi) > abs(t-ti) or (abs(x-xi) + abs(y-yi) + abs(t-ti)) % 2 != 0:
        print("No")
        exit()
    ti=t
    xi=x
    yi=y
print("Yes")

Solution (Python):
N = int(input())
f = True
t1,x1,y1 = 0,0,0
for i in range(N):
  t0,x0,y0 = t1,x1,y1
  t1,x1,y1 = map(int,input().split())
  d=(t1-t0)-abs(x0-x1)-abs(y0-y1)
  if 0<=d and (d&1)==0:
    pass
  else:
    f = False
print('Yes' if f else 'No')

Solution (Python):
N=int(input())
txy=[list(map(int, input().split())) for _ in range(N)]
is_No=0
for row in txy:
    if row[0]%2==0:
        if row[1]+row[2]<=row[0] and (row[1]+row[2])%2==0:
            continue
        else:
            is_No=1
            break
    elif row[0]%2==1:
        if row[1]+row[2]<=row[0] and (row[1]+row[2])%2==1:
            continue
        else:
            is_No=1
            break
    else:
        is_No=1
        break
print("No" if is_No else "Yes")

Solution (Python):
n = int(input())
data_list = [[0, 0, 0]]
for i in range(n):
    t, x, y = map(int, input().split())
    data_list.append([t, x, y])

flag = False
for i in range(n):
    for j in range(data_list[i+1][0] - data_list[i][0]):
        t_diff = abs(data_list[i+1][0] - data_list[i][0])
        x_diff = abs(data_list[i+1][1] - data_list[i][1])
        y_diff = abs(data_list[i+1][2] - data_list[i][2])
        if x_diff + y_diff <= t_diff:
            if ((x_diff + y_diff) % 2 == 0 and t_diff % 2 == 0) or ((x_diff + y_diff) % 2 == 1 and t_diff % 2 == 1):
                pass
            else:
                print('No')
                flag = True
                break
        else:
            print('No')
            flag = True
            break
    if flag:
        break
if flag == False:
    print('Yes')

Solution (Python):
def main():
    N = int(input())

    pt = 0
    px = 0
    py = 0
    for i in range(N):
        tin = input().split(" ")
        t, x, y = int(tin[0]), int(tin[1]), int(tin[2])
        d = abs(px-x) + abs(py-y)
        dr = t - pt - d
        if dr < 0 or dr % 2 != 0:
            print("No")
            return
    print("Yes")
    return
main()

Solution (Python):
n = int(input())
txy = [[int(x) for x in input().split()] for _ in range(n)]

b = [0,0,0]
for a in txy:
    t = a[0] - b[0]
    d = abs(a[1] - b[1]) + abs(a[2] - b[2])
    if d > t or d % 2 != t % 2:
        print('No')
        exit()

print('Yes')

Solution (Python):
N=int(input())
for i in range(N):
    t,x,y=map(int,input().split())
    if x+y>t or (t+x+y)%2!=0:
        print('No')
        quit()
print('Yes')

Solution (Python):

"""
Created on Thu Aug  9 01:39:56 2018

@author: Yuki
"""

N = int(input())
plans = [[0, 0, 0]]
for i in range(N):
    plans.append([int(ii) for ii in input().split()])

Yes_flag = True

for i in range(N):
    if (abs(plans[i+1][1] - plans[i][1]) + abs(plans[i+1][2] - plans[i][2])) > (plans[i+1][0] - plans[i][0]):
        Yes_flag = False
        break
for i in range(1, N+1):
    if plans[i][0] % 2 == 0:
        if (plans[i][1] + plans[i][2]) % 2 != 0:
            Yes_flag = False
            break
    else:
        if (plans[i][1] + plans[i][2]) % 2 == 0:
            Yes_flag = False
            break
if Yes_flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n =  int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or (x + y) % 2 != t % 2:
        print('No')
        exit()
print("Yes")

Solution (Python):
n = int(input())

nt, nx, ny = 0, 0, 0
l = [list(map(int, input().split())) for _ in range(n)]
for t, x, y in l:
    dist =  abs(nx - x) + abs(ny - y)
    if dist > t - nt:
        print("No")
        exit()
    elif (dist - (t-nt)) % 2 != 0:
        print("No")
        exit()
    nt, nx, ny = t, x, y
print("Yes")

Solution (Python):
N = int(input())

t_old = 0
x_old = 0
y_old = 0

possible = True

for _ in range(N):
    t, x, y = list(map(int, input().split()))

    t_diff = t - t_old
    x_diff = x - x_old
    y_diff = y - y_old

    xy_diff = x_diff + y_diff

    checker = t_diff - xy_diff

    if (checker >= 0) & (checker % 2 == 0):
        pass

    else:
        possible = False
        break

    t_old = t
    x_old = x
    y_old = y

if possible:
    print("Yes")

else:
    print("No")

Solution (Python):
N = int(input())
TXY = [(0,0,0)]
for i in range(N):
    TXY.append(tuple(map(int, input().split())))

def judge(N:int, TXY:tuple) -> bool:
    for i in range(N):
        delta_t = TXY[i+1][0] - TXY[i][0]
        delta_x = abs(TXY[i+1][1] - TXY[i][1])
        delta_y = abs(TXY[i+1][2] - TXY[i][2])
        
        if (delta_t%2 != (delta_x+delta_y)%2)\
          or (delta_t < (delta_x+delta_y)):
            return False
        
    return True

if judge(N,TXY):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
x1 = y1 = t1 = 0

for _ in range(N):
	t2,x2,y2 = inpl()
	dt = t2 - t1
	d = abs(x2 - x1) + abs(y2 - y1)
	if dt < d:
		print('No')
		sys.exit()
	else:
		if (dt-d)%2 != 0:
			print('No')
			sys.exit()
	x1,y1,t1 = x2,y2,t2

print('Yes')

Solution (Python):
n = int(input())
txy = [tuple(map(int, input().split(" "))) for i in range(n)]

for txy_i in txy:
	t, x, y = txy_i
	remain = t - x - y
	if not (0 <= remain and remain % 2 == 0):
		print("No")
		exit()
print("Yes")

Solution (Python):
N = int(input())
st, sx, sy = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    distance = abs(x - sx) + abs(y - sy)
    dt = t - st
    if dt < distance or (dt - distance) % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n = int(input())
k = 0
t2 = 0
x2 = 0
y2 = 0

for i in range(n):
    t1,x1,y1 = map(int,input().split())
    t = t1 - t2
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    if t < x + y or t % 2 != (x + y) %2:
        print('No')
        break
    t2 = t1
    x2 = x1
    y2 = y1
    if i == n-1:
        print('Yes')

Solution (Python):
n = int(input())
k = 0
for i in range(n):
    t,x,y = map(int,input().split())
    if t < x + y or t % 2 != (x + y) %2:
        print('No')
        break
    if i == n-1:
        print('Yes')

Solution (Python):
n = int(input())
for i in range(n):
  t, x, y = map(int, input().split())
  if x + y > t:
    print("No")
    exit()
  elif t % 2 != (x + y) % 2:
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())
c = True
for i in range(n):
  t, x, y = map(int, input().split())
  if x + y == t:
    c = True
  elif x + y < t and (t - x - y) % 2 == 0:
    c = True
  else:
    c = False
    break
if c == True:
  print("Yes")
else:
  print("No")

Solution (Python):
N=int(input())
x,y,e=0,0,0
f=True
for _ in range(N):
    a,b,c=map(int,input().split())
    d=(a-e)-(b-x)-(c-y)
    x=b
    y=c
    e=a
    if d%2 or d<0:
        f=False
if f:print("Yes")
else:print("No")

Solution (Python):
n=int(input())
t=[list(map(int,input().split()))for i in range(n)]
t.insert(0,[0,0,0])
for i in range(n):
    dxy=abs(t[i][1]-t[i+1][1])+abs(t[i][2]-t[i+1][2])
    dt=abs(t[i][0]-t[i+1][0])
    dd=dt-dxy
    if dxy<=dt and dd%2==0:
        pass
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):

n = int(input())
r = 'Yes'

for i in range(n):
    t, a, b = map(int, input().split())
    s = abs(a) + abs(b)
    if s > t or (t - s) % 2 != 0:
        r = 'No'
print(r)

Solution (Python):


n = int(input())

T = []
X = []
Y = []
for _ in range(n):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

prev_t = 0
prev_x = 0
prev_y = 0
ans = 'Yes'
for i in range(n):
    dt = T[i] - prev_t
    dis = abs(X[i] - prev_x) + abs(Y[i] - prev_y)
    if dt < dis or (dt - dis)%2 == 1:
        ans = 'No'
        break
    prev_t = T[i]
    prev_x = X[i]
    prev_y = Y[i]

print(ans)

Solution (Python):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or ((x + y) % 2 != t % 2):                                                                       
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
f = True
for i in range(n):
    t, x, y = map(int, input().split())
    if t < x + y or t % 2 != (x+y) % 2:
        f = False
        break
if f == True:
    print('Yes')
else:
    print('No')

Solution (Python):
def getinputdata():

    
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

chkflg=True
for i in range(1,1+n):
    
    t=int(arr_data[i][0])
    x=int(arr_data[i][1])
    y=int(arr_data[i][2])
    
    if not((t%2==0 and (x+y) % 2==0 and t>=x+y) or (t%2!=0 and (x+y) % 2!=0 and t>=x+y)):
        
        chkflg=False
        break
        
print("Yes" if chkflg else "No")

Solution (Python):


def main():
    
    N = int(input())
    lists = []
    for i in range(N):
        lists.append(list(map(int, input().split())))
    
    
    position = [0, 0]
    begin_time = 0
    move_flag = 0

    
    for i in range(N):
        
        time_diff = lists[i][0] - begin_time
        begin_time = lists[i][0]
        
        distance = abs(lists[i][1] - position[0]) + abs(lists[i][2] - position[1])
        position = [lists[i][1], lists[i][2]]
        if time_diff - distance >= 0 and (time_diff - distance) % 2 == 0:
            move_flag = 1
        else:
            move_flag = 0
            break
    
    if move_flag == 1:
        print('Yes')
    elif move_flag == 0:
        print('No')

    
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
pre_t,pre_x,pre_y=0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d_t = t-pre_t
    d_x = abs(x-pre_x)
    d_y = abs(y-pre_y)
    if d_x + d_y > d_t or (d_x + d_y + d_t) % 2:
        print("No")
        quit()
    pre_t,pre_x,pre_y=t, x, y
print("Yes")

Solution (Python):
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        quit()
print("Yes")

Solution (Python):
N = int(input())
B = [[0]*3]*N
for i in range(N):
    B[i] = list(map(int,input().split()))
ans = 'Yes'
B.insert(0,[0,0,0])
for i in range(N):
    T = B[i+1][0] - B[i][0] 
    S = abs(B[i+1][1] - B[i][1]) + abs(B[i+1][2] - B[i][2])
    if T >= S and (T - S)%2 == 0:
        pass
    else:
        ans = 'No'
        break
print(ans)

Solution (Python):
t = x = y = 0
T = [0]
X = [0]
Y = [0]

N = int(input())
for i in range(N):
    t,x,y = map(int,input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

f = True
d = s = 0
for i in range(N):
    d = (T[i+1]-T[i]) - abs(X[i+1]-X[i]) - abs(Y[i+1]-Y[i])
    if f and d >= 0 and d%2 == 0:
        f = True
    else:
        f = False

if f:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())

s_x = 0
s_y = 0
s_t = 0
travel_flag = True

def judge_ok(d_p, d_t):
  if d_p > d_t:
    return False
  if d_p % 2 != d_t % 2:
    return False
  return True

for n in range(N):
  n_t, n_x, n_y = list(map(lambda x:int(x), input().split(" ")))

  if not judge_ok(abs(n_x - s_x) + abs(n_y - s_y), n_t - s_t):
    travel_flag = False
  
  s_x = n_x
  s_y = n_y
  s_t = n_t

if travel_flag:
  print("Yes")
else:
  print("No")

Solution (Python):
def goal_check(start,goal):
  distance = abs(start[1]-goal[1]) + abs(start[2]-goal[2])
  time = goal[0] - start[0]
  if time < distance: return False
  if (time-distance)%2 == 1: return False
  return True


N = int(input())
ans = "Yes"
dest = []
dest.append([0,0,0])
for i in range(N):
    dest.append(list(map(int,(input().split()))))
    
dest.sort(key=lambda point: point[0]) 

for p,q in zip(dest[:-1],dest[1:]):
  if goal_check(p,q):
    pass
  else:
    ans = "No"
    break

print(ans)

Solution (Python):
n = int(input())


def main():
    t0, x0, y0 = 0, 0, 0
    for i in range(n):
        t1, x1, y1 = map(int, input().split())
        l = abs(x1 - x0) + abs(y1 - y0)
        t = t1 - t0
        if l - t > 0 or (t - l) % 2 != 0:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


main()

Solution (Python):
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

pt,px,py = 0,0,0
for t,x,y in src:
    d = abs(x-px) + abs(y-py)
    if t-pt < d or (t-pt)%2 != d%2:
        print('No')
        exit()
    pt,px,py = t,x,y
print('Yes')

Solution (Python):
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
travel_plan = []
for i in range(n):
    travel_plan.append(tuple(map(int, input().split())))
travel_plan = [(0, 0, 0)] + travel_plan

for i in range(n):
    t1 = travel_plan[i][0]
    x1 = travel_plan[i][1]
    y1 = travel_plan[i][2]
    t2 = travel_plan[i+1][0]
    x2 = travel_plan[i+1][1]
    y2 = travel_plan[i+1][2]
    x = abs(x1 - x2)
    y = abs(y1 - y2)
    t = t2 - t1
    if x + y > t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")