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):
N = int(input())
S = []
S.append([0,0,0])
for _ in range(N):
    S.append(list(map(int, input().split())))

cnt = 0
for i in range(len(S)-1):
  time = S[i+1][0]-S[i][0]
  distance = abs(S[i+1][1]-S[i][1])+abs(S[i+1][2]-S[i][2])
  if distance>time or distance%2 != time%2:
    print('No')
    break
  else:
    cnt+=1
if cnt == len(S)-1:
  print('Yes')

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

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

for i in range(N):
    ti,xi,yi=map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)

can=True

for i in range(N):
    dt=t[i+1]-t[i]
    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:
    print('Yes')
else:
    print('No')

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

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

for i in range(N):
    tt, xx, yy = map(int, input().split())
    t.append(tt)
    x.append(xx)
    y.append(yy)

suc = True

for i in range(N):
    dt = t[i+1] - t[i]
    dxy = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dxy:
        suc = False
    if dxy % 2 != dt % 2:
        suc = False

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

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n=int(input())
t0,x0,y0=0,0,0
for i in range(n):
    t,x,y=map(int,input().split())
    d=abs(x0-x)+abs(y0-y)
    if d%2!=(t-t0)%2 or (t-t0)<d:
        print("No")
        exit()
    t0,x0,y0=t,x,y
print("Yes")

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

Solution (Python):
now = {"t":0,"x":0,"y":0}
can = True
for i in range(int(input())):
    t,x,y = map(int,input().split())
    dx = abs(x - now["x"]) 
    dy = abs(y - now["y"]) 
    d = dx + dy 
    if d > t-now["t"] or d%2 != (t-now["t"])%2:
        print("No")
        can = False
        break
    now = {"t":t,"x":x,"y":y}
if can:
    print("Yes")

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

li = [[0, 0, 0]]
for i in range(n):
    array = list(map(int, input().split()))
    li.append(array)

for i in range(n):
    period = li[i+1][0] - li[i][0]
    dist = abs(li[i+1][1] - li[i][1]) + abs(li[i+1][2] - li[i][2])
    if period % 2 == 0 and dist % 2 == 0 and period >= dist:
        continue
    elif period % 2 != 0 and dist % 2 != 0 and period >= dist:
        continue
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
n = int(input())
Plan = []
for i in range(n):
  Plan.append(list(map(int, input().split())))
Plan.sort(lambda x: x[0])
x = 0
y = 0
t = 0
for txy in Plan:
  t_new, x_new, y_new = txy
  dx = abs(x_new - x)
  dy = abs(y_new - y)
  dt = abs(t_new - t)
  if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
    continue
  else:
    print("No")
    break
else:
  print("Yes")

Solution (Python):

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

def can_exist(before_point, after_point):
    def_t = after_point[0] - before_point[0]
    def_x = after_point[1] - before_point[1]
    def_y = after_point[2] - before_point[2]
    def_total = abs(def_x) + abs(def_y)
    if def_total <= def_t and def_total % 2 == def_t % 2:
        return True
    else:
        return False

out = 'Yes'
for i in range(n):
    if can_exist(points[i], points[i+1]):
        continue
    else:
        out = 'No'
        break

print(out)

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

x1,y1 = 0,0
t1 = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    if abs(x1-x) + abs(y1-y) <= t - t1 and (abs(x1-x) + abs(y1-y) - (t - t1)) % 2 == 0:
        x1 = x
        y1 = y
        t1 = t
        continue
    else:
        print("No")
        import sys
        sys.exit()

print("Yes")

Solution (Python):
import numpy as np

N = int(input())
travel_list = [np.array([0, 0, 0])]
add_list = [np.array([int(i) for i in input().split()]) for i in range(N)] 
travel_list.extend(add_list)

def is_travel(arr1, arr2):
    dt, dx, dy = abs(arr2 - arr1)
    if dt < dx + dy:
        return False
    elif dt % 2 != (dx + dy) % 2:
        return False
    else:
        return True
        
travel = 'Yes'
for i in range(N):
    if is_travel(travel_list[i], travel_list[i+1]):
        continue
    else:
        travel = 'No'
        break
print(travel)

Solution (Python):
N=int(input())
T,X,Y=[0], [0], [0]
flag=0
for i in range(N):
    t,x,y = list(map(int,input().split()))
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    if X[i+1]-X[i]+Y[i+1]-Y[i]<=(T[i+1]-T[i]) and (X[i+1]-X[i]+Y[i+1]-Y[i]-(T[i+1]-T[i]))%2==0:
        continue
    else:
        flag+=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
mod = 10**9+7


N = int(input())
TXY = [[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]

ans = "Yes"
for i in range(N):
    t0,x0,y0 = TXY[i]
    t1,x1,y1 = TXY[i+1]
    t = t1-t0
    d = abs(x1-x0)+abs(y1-y0)
    if t<d or d%2!=t%2:
        ans = "No"
        break

print(ans)

Solution (Python):
row_length = int(input())
point = {}
for i in range(row_length):
    point[i] = list(map(int, input().split()))
from math import ceil
def feasible_point(t, x, y):
    if t % 2 == 0:  
        k = t / 2
        
        
        if ((x+y)%2 == 0)&(x+y <= t):
            return True
        else:
            return False
    else:
        k = ceil(t / 2)
        
        if ((x+y)%2 == 1)&(x+y<= t):
            return True
        else:
            return False

check_list = []
for j in range(len(point)):
    check_list.append(feasible_point(point[j][0], point[j][1], point[j][2]))

if all(check_list):
    
    check_list_2 = []
    for l in range(len(point)-1):
        t_gap = point[l+1][0] - point[l][0]
        xy_gap = point[l+1][1] + point[l+1][2] - point[l][1] - point[l][2]
        if abs(xy_gap) <= abs(t_gap):
            check_list_2.append(True)
        else:
            check_list_2.append(False)
    if all(check_list_2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
N = int(input())
plan = [[int(i) for i in input().split()] for j in range(N)]
x = 0
y = 0
t = 0
 
for i in range(N):
    newT = plan[i][0]
    x_t = plan[i][1]
    y_t = plan[i][2]
    distance = abs((x_t+y_t) - (x+y))
    time_lag = newT - t
 
    if distance % 2 == time_lag % 2:
        if distance <= time_lag:
            t = newT
            x = x_t
            y = y_t
            continue
    
    print("No")
    exit()
 
print("Yes")

Solution (Python):

N = int(input())

now_x = 0
now_y = 0
now_t = 0

for i in range(N):
    t,x,y = map(int, input().split())
    margin = (t- now_t) - abs(x - now_x) - abs(y - now_y)
    
    if margin < 0 or margin%2!=0:
        print("No")
        break
    else:
        now_x = x
        now_y = y
        now_t = t
else:
    print("Yes")

Solution (Python):
N = int(input())
t_x_y = [0]*N
for n in range(N):
    t_x_y[n] = [int(x) for x in input().split()]
    
can_flag = 1
for t, x, y in t_x_y: 
    if (t%2 == (x+y)%2) & ((x+y)<=t):
        continue
    else:
        can_flag=0
        break

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

Solution (Python):
t, x, y = 0, 0, 0
for i in range(int(input())):
    t_next, x_next, y_next = map(int, input().split())
    dif = abs(x - x_next) + abs(y - y_next)
    if dif > abs(t - t_next) or (dif - (t- t_next))%2 == 1:
        print('No')
        exit(0)
    t, x, y = t_next, x_next, y_next
print('Yes')

Solution (Python):
N = int(input())
TXY = []
for n in range(N):
    TXY.append([int(i) for i in input().split()])
temp = [0,0,0]
ans = True
for txy in TXY:
    dist = (txy[1]-temp[1]) + (txy[2]-temp[2])
    if (txy[0]-temp[0]) % 2 == dist % 2 and (txy[0]-temp[0]) >= dist:
        temp = txy
    else:
        ans = False
print("Yes") if ans else print("No")

Solution (Python):
N = int(input())
txy = [(0, 0, 0)] + [tuple(map(int, input().split())) for _ in range(N)]


for i in range(N):
    now = txy[i]
    next = txy[i + 1]
    root = abs(next[1] - now[1]) + abs(next[2] - now[2])
    time = next[0] - now[0]
    if time < root:
        print("No")
        break
    else:
        if time == root:
            pass
        else:
            if (time - root) % 2 != 0:
                print("No")
                break
else:
    if N == 1:
        root = txy[1][1] + txy[1][2]
        time = txy[1][0]
        if time < root:
            print("No")
        else:
            if (time - root) % 2 == 0:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Solution (Python):
n=int(input())
info=[[0,0,0]]
for i in range(n):
    t,x,y=map(int,input().split())
    info.append([t,x,y])
ans="Yes"
for i in range(1,n+1):
    t=info[i][0]-info[i-1][0]
    kyori=abs(info[i][1]-info[i-1][1])+abs(info[i][2]-info[i-1][2])
    zan=t-kyori
    if zan<0:
        ans="No"
        break
    if zan%2!=0:
        ans="No"
        break
print(ans)

Solution (Python):
num = int(input())
a, b, c = 0, 0, 0
for i in range(num):
  d, e, f = map(int, input().split())
  times = d - a
  distance = (e-b) + (f-c)
  if times>=distance and times%2 == distance%2:
    continue
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input()) 
pre_t = 0
pre_x = 0
pre_y = 0

for i in range(N):
    now_t,now_x,now_y = list(map(int,input().split()))
    d = abs(now_x - pre_x) + abs(now_y - pre_y)
    t = now_t - pre_t
    if d <= t and t % 2 == d % 2:
        flg = 1
    else:
        flg = 0
        break

if flg == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
def examC():
    N = I()
    ans = "Yes"
    now = [0,0,0]
    for _ in range(N):
        t, x, y = LI()
        T = t - now[0]
        X = x - now[1]
        Y = y - now[2]
        if abs(X)+abs(Y)>T or (abs(X)+abs(Y)-T)%2==1:
            ans = "No"
            break
        else:
            now = [t,x,y]
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Solution (Python):
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np
import math

n = int(stdin.readline().rstrip())

t = [0]*n
x = [0]*n
y = [0]*n
for i in range(n):
    t[i],x[i],y[i] = [int(x) for x in stdin.readline().rstrip().split()]

t = [0] + t
x = [0] + x
y = [0] + y

if n == 1:
    if x[1]+y[1] > t[1]:
        print("No")
        exit()
    elif t[1]%2 != (x[1]+y[1])%2:
        print("No")
        exit()
    else:
        print("Yes")
        exit()

for i in range(1,n):
    if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i]-t[i-1]:
        print("No")
        exit()
    elif (t[i]-t[i-1])%2 != (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
t,x,y = 0,0,0
for i in range(N):
    T,X,Y = map(int,input().split())
    d = abs(x-X)+abs(y-Y)
    if (T-t)-d >= 0 and ((T-t)-d)%2 == 0:
        t,x,y = T,X,Y
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
t,x,y = 0,0,0
for i in range(N):
    T,X,Y = map(int,input().split())
    d = abs(x-X)+abs(y-Y)
    if (T-t)-d >= 0 and ((T-t)-d)%2 == 0:
        t,x,y = T,X,Y
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
t,x,y = 0,0,0
for i in range(n):
  pt,px,py = t,x,y
  t,x,y = map(int,input().split())
  if t-pt < abs(x-px)+abs(y-py) or ((t-pt) - abs(x-px) - abs(y-py)) % 2:
    print('No')
    break
  if i == n-1:
    print('Yes')

Solution (Python):
n=int(input())
a=[[int(i) for i in input().split()] for i in range(n)]
for i in a:
    if i[0]%2!=(i[1]+i[2])%2 or i[0]<i[1]+i[2]:
        print("No")
        exit()
print("Yes")

Solution (Python):
def is_reachable(dept, dest):
    distance = abs(dest[1] - dept[1]) + abs(dest[2] - dept[2])
    time = dest[0] - dept[0]
    if (time - distance >= 0) and ((time - distance) % 2 == 0):
        return True
    else:
        return False


N = int(input())
itin = [(0, 0, 0)]
itin_append = itin.append
for n in range(N):
    itin_append(tuple(map(int, input().split())))

for n in range(N):
    if is_reachable(itin[n], itin[n + 1]):
        continue
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n=int(input())
t=[0]*n
x=[0]*n
y=[0]*n
c=0
a=0
b=0
ans='Yes'
for i in range(n):
    t[i],x[i],y[i]=map(int,input().split())
for j in range(n):
    if t[j]-c>=x[j]+y[j]-a-b:
        if (t[j]-c-(x[j]+y[j]-a-b))%2==0:
            a=x[j]
            b=y[j]
            c=t[j]
        else:
            ans='No'
            break
    else:
        ans='No'
        break
print(ans)

Solution (Python):
N = int(input())
nowT = 0
nowX = 0
nowY  = 0
for _ in range(N):
  nextT, nextX, nextY = map(int, input().split())
  d = abs(nowX - nextX) + abs(nowY - nextY)
  if d > (nextT - nowT) or (nextT - nowT) % 2 != d % 2:
    print('No')
    exit()
  nowT = nextT
  nowX = nextX
  nowY = nextY
print('Yes')

Solution (Python):

class Check():
    def __init__(self):
        self.now_t, self.now_x, self.now_y = 0, 0, 0

    def do(self, t, x, y):
        distance = ((x - self.now_x) + (y - self.now_y))
        duration = t - self.now_t
        if duration < distance:
            return False

        if (distance - duration) % 2 != 0:
            return False

        self.now_t, self.now_x, self.now_y = t, x, y
        return True


N = int(input())
c = Check()
for i in range(N):
    a = [int(x) for x in input().split()]
    if not c.do(a[0], a[1], a[2]):
        print('No')
        exit()
print('Yes')

Solution (Python):

class Check():
    def __init__(self):
        self.now_t, self.now_x, self.now_y = 0, 0, 0

    def do(self, t, x, y):
        distance = ((x - self.now_x) + (y - self.now_y))
        duration = t - self.now_t
        if duration < distance:
            return False

        if distance % 2 != duration % 2:
            return False

        self.now_t, self.now_x, self.now_y = t, x, y
        return True


N = int(input())
c = Check()
for i in range(N):
    a = [int(x) for x in input().split()]
    if not c.do(a[0], a[1], a[2]):
        print('No')
        exit()
print('Yes')

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

s_x = 0
s_y = 0
s_t = 0

for i in range(n):
    t = t_li[i][0]
    x = t_li[i][1]
    y = t_li[i][2]
    
    s = abs(x-s_x)+abs(y-s_y)
    
    if s > t or (t-s_t-s)%2 == 1:
        print("No")
        exit()
        
    s_x = x
    s_y = y
    s_t = t
        
print("Yes")

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

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

    
    if x + y > t:
        flag = 0

    
    if (t + x + y) % 2 != 0:
        flag = 0

print("Yes") if flag == 1 else print("No")

Solution (Python):
import sys
l = sys.stdin.readlines()
for i in l[1:]:
    t, x, y = map(int, i.split())
    if (x + y > t) or ((x + y) % 2 != t % 2):
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
cx, cy, ct = 0, 0, 0
for _ in range(N):
  t, x, y = map(int, input().split())
  if abs(x - cx) + abs(y - cy) <= t - ct and ((t - ct - (abs(x - cx) + abs(y - cy))) % 2 == 0):
    continue
  print("No")
  exit(0)
print("Yes")

Solution (Python):
N = int(input())
txy = []
for i in range(N):
    txy.append(list(map(int,input().split())))
ans = "Yes"
t = 0
x = 0
y = 0
for i in range(N):
    deft = txy[i][0] - t
    defx = abs(txy[i][1] - x)
    defy = abs(txy[i][2] - y)
    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]
    if (defx + defy) > deft:
        ans = "No"
        break
    elif (deft - defx - defy)%2 != 0:
        ans = "No"
        break
print(ans)

Solution (Python):
N = int(input())
t,x,y = [],[],[]

for _ in range(N):
	t_tmp, x_tmp, y_tmp = map(int, input().split())
	t.append(t_tmp)
	x.append(x_tmp)
	y.append(y_tmp)

ct,cx,cy = 0,0,0
cond = True
for i in range(N):
	dt = t[i] - ct
	dx = abs(cx - x[i])
	dy = abs(cy - y[i])

	if dt < dx + dy:
		cond = False
		break

	buff = dx+dy-dt

	if buff % 2 == 1:
		cond = False
		break

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

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

print("Yes")

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

List = []
point = [0,(0,0)]
Answer = 'Yes'
for _ in range(N):
  t,x,y = map(int,input().split())
  List.append([t,(x,y)])

for item in List:
  ability = item[0] -point[0]
  length = item[1][0]+item[1][1]-point[1][0]-point[1][1]
  if length > ability:
    Answer = 'No'
    break
  elif (ability - length) % 2 == 1:
    Answer = 'No'
    break
  else:
    point = item

print(Answer)

Solution (Python):
import numpy as np


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])
    d = np.diff(TXY, 1, 0)
    dd = d[:, 0] - np.abs(d[:, 1]) - np.abs(d[:, 2])
    b1 = np.any(dd < 0)
    b2 = np.any(dd % 2 != 0)
    if b1 or b2:
        print('No')
    else:
        print('Yes')


main()

Solution (Python):
import numpy as np


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])
    d = np.diff(TXY, 1, 0)
    dd = d[:, 0] - np.abs(d[:, 1]) - np.abs(d[:, 2])
    b1 = np.all(dd >= 0)
    b2 = np.all(dd % 2 == 0)
    if b1 and b2:
        print('Yes')
    else:
        print('No')


main()

Solution (Python):
import sys


def main():
    N = int(input())
    TXY = [[int(x) for x in input().split()] for _ in range(N)]
    TXY.insert(0, [0, 0, 0])

    for i in range(N):
        dt = TXY[i+1][0] - TXY[i][0]
        dl = abs(TXY[i+1][1] - TXY[i][1])
        dl += (TXY[i+1][2] - TXY[i][2])

        if dt < dl or (dt-dl) % 2 == 1:
            print('No')
            sys.exit()

    print('Yes')


main()

Solution (Python):
import sys
n=int(input())
lst=[]
for i in range(n):
  T,X,Y=map(int,input().split())
  lst.append([T,X,Y])
if (abs(lst[0][1])+abs(lst[0][2]))%2==lst[0][0]%2:
  if abs(lst[0][1])+abs(lst[0][2])<=lst[0][0]:
    pass
  else:
    print('No')
    sys.exit()
else:
  print('No')
  sys.exit()

for j in range(n-1):
  if (abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2]))%2==(lst[j+1][0]-lst[j][0])%2:
    if abs(lst[j][1]-lst[j+1][1])+abs(lst[j][2]-lst[j+1][2])<=(lst[j+1][0]-lst[j][0]):
      pass
    else:
      print('No')
      sys.exit()
  else:
    print('No')
    sys.exit()
print('Yes')

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

Solution (Python):
n=int(input())
t=0
x=0
y=0
for i in range(n):
  g,h,j=map(int,input().split())
  if (g-t)%2==(abs(h-x)+abs(j-y))%2 and (abs(h-x)+abs(j-y))<=(g-t):
    t=g
    x=h
    y=j
  else:
    print("No")
    exit()

print("Yes")

Solution (Python):
import sys

def main():
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        ti, xi, yi = map(lambda i: int(i), input().split(' '))
        t.append(ti)
        x.append(xi)
        y.append(yi)
    current_t = 0
    current_point = [0, 0]
    for i in range(N):
        next_t = t[i]
        next_point = [x[i], y[i]]
        distance = abs(next_point[0] - current_point[0]) + abs(next_point[1] - current_point[1])
        time_diff = next_t - current_t
        if distance > time_diff:
            print('No')
            sys.exit()
        elif distance < time_diff:
            diff = time_diff - distance
            if diff % 2 == 1:
                print('No')
                sys.exit()
        current_t = t[i]
        current_point = [x[i], y[i]]
    print('Yes')

main()

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input().strip())
x_ = 0
y_ = 0
t_ = 0

def f(t, x, y):
    t -= (abs(x) + abs(y))
    if t < 0 or t % 2 == 1:
        return False
    else:
        return True

ans = 'No'
for n in range(N):
    t, x, y = [int(x) for x in input().strip().split()]
    t, t_, x, x_, y, y_ = t - t_, t, x - x_, x, y - y_, y
    if not f(t, x, y):
        break

else:
    ans = 'Yes'

print(ans)

Solution (Python):
N = int(input())
b = [list(map(int,input().split())) for i in range(N)]
txy = [[0,0,0]] + b
ans = "Yes"
for i in range(N):
    dt = txy[i+1][0]-txy[i][0]
    dx = abs(txy[i+1][1]-txy[i][1])
    dy = abs(txy[i+1][2]-txy[i][2])
    if dt < dx + dy or dt%2 != (dx + dy)%2:
        ans ="No"
print(ans)

Solution (Python):
def z(a):
  return max(a,-a)
N=int(input())
l=[list(map(int,input().split())) for _ in range(N)]
l=[[0,0,0]]+l
n=True
for i in range(N):
  a=z(l[i][1]-l[i+1][1])+z(l[i][2]-l[i+1][2])
  if not(l[i+1][0]-l[i][0]-a>=0 and (l[i+1][0]-l[i][0]-a)%2==0):
    n=False
if n:
  print("Yes")
else:
  print("No")

Solution (Python):
from itertools import chain

n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
ls.insert(0,[0,0,0])
ls = list(chain.from_iterable(ls))


time = [(ls[i+3]-ls[i]) for i in range(0,len(ls)-3,3)]
cost = [abs(ls[i+1]-ls[i+4])+abs(ls[i+2]-ls[i+5]) for i in range(0,len(ls)-4,3)]


result = 'Yes' if all(time[i]%2==cost[i]%2 and time[i] >= cost[i] for i in range(len(time))) else 'No'
print(result)

Solution (Python):
N=int(input())
prev=[0,0,0]
for i in range(N):
  t,x,y=map(int,input().split())
  dis = abs(x-prev[0]) + abs(y -prev[1])
  time= t-prev[2]
  if dis <= time and (time-dis)%2==0:
    prev=[x,y,t]
  else:
    print("No")
    exit(0)
print("Yes")

Solution (Python):
n = int(input())
list_place = []
max_t = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  if t > max_t:
    max_t = t
  list_place.append([t, x, y])

t = 0
place = [0, 0]
for tgt_t, tgt_x, tgt_y in list_place:
  while t < tgt_t:
    dif_x = tgt_x - place[0]
    dif_y = tgt_y - place[1]
    if dif_x > 0:
      place[0] += 1
    elif dif_x < 0:
      place[0] -= 1
    else:
      if dif_y > 0:
        place[1] += 1
      else:
        place[1] -= 1
    t += 1
  if place[0] != tgt_x or place[1] != tgt_y:
    print("No")
    exit()
print("Yes")

Solution (Python):


import sys








def main():
    n, *txy = (int(x) for x in sys.stdin.read().split())
    t, x, y = [0], [0], [0]
    for i in range(0, n * 3, 3):
        t.append(txy[i])
        x.append(txy[i+1])
        y.append(txy[i+2])
    for i in range(n):
        dt = t[i+1] - t[i]
        distx = abs(x[i+1] - x[i])
        disty = abs(y[i+1] - y[i])
        if dt - (distx + disty) >= 0 and (dt - (distx + disty)) % 2 == 0:
            continue
        else:
            ans = 'No'        
            break
    else:
        ans = 'Yes'
    
    print(ans)

if __name__ == "__main__":
    
    main()

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0

for i in range(0, n):
    t_next, x_next, y_next = map(int, input().split())
    xy_diff = abs(x_next-x)+abs(y_next-y)
    t_diff = t_next - t
    if(xy_diff > t_diff or (xy_diff - t_diff)%2!=0):
        print('No')
        exit(0)
    else:
        t, x, y = t_next, x_next, y_next

print('Yes')

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

t1, x1, y1 = 0, 0, 0
for _ in range(N):
    t2, x2, y2 = list(map(lambda x: int(x), input().split(' ')))
    dist = abs(x1 - x2) + abs(y1 - y2)
    t_diff = t2 - t1

    
    if t_diff < dist:
        print('No')
        exit()

    elif (t_diff - dist) % 2 == 1:
        print('No')
        exit()

    else:
        t1, x1, y1 = t2, x2, y2

print('Yes')

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

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

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

flag = 1
for i in range(n):
    t_tmp,x_tmp,y_tmp = map(int,input().split())
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)
    time = abs(t[i+1] - t[i])
    d = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if d > time or (d % 2) != (time%2): 
        flag = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
a = int(input())
l = []
for i in range(a):
    dist = [int(i) for i in input().split()]
    l.append(dist)
 
start = [0,0,0]
flg = True
for i in l:
    i[0] = i[0] -start[0]
    i[1] = i[1] -start[1]
    i[2] = i[2] -start[2]
    if (i[1]+ i[2])%2 != i[0]%2:
        print('No')
        flg = False
        break
    elif i[0] < abs(i[1]) + abs(i[2]):
        print('No')
        flg = False
        break
    else:
        start = [i[0],i[1],i[2]]
if flg:
    print('Yes')

Solution (Python):
N=int(input())
x=[0]
y=[0]
t=[0]

flag=1
for i in range(1,N+1):
  t_tmp,x_tmp,y_tmp=map(int,input().split())
  t.append(t_tmp)
  x.append(x_tmp)
  y.append(y_tmp)
  time=abs(t[i-1]-t[i])
  d=abs(x[i-1]-x[i])+abs(y[i-1]-y[i])
  if d>time or (d%2)!=(time%2):
    print("No")
    flag=0
    break
    
if flag==1:
  print("Yes")

Solution (Python):
N = int(input())
a = 0
for i in range(N):
  a = list(map(int, input().split()))
  if a[0] < sum(a) - a[0]:
    print("No")
    exit()
  if (sum(a) - a[0] - a[0])%2 != 0:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input())
prv = [0,0,0]
for _ in range(N):
  t, x, y = map(int,input().split())
  n = 0
  dif = (t- prv[2]) - (abs(prv[0]-x) + abs(prv[1]-y))
  if dif >= 0 and dif%2 == 0:
    prv = [x,y,t]
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):
n = int(input())
pre_x = 0
pre_y = 0
pre_t = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    way_min = x-pre_x+y-pre_y
    if (t-pre_t-way_min) % 2 == 0 and t-pre_t>=way_min:
        pre_x=x
        pre_y=y
        pre_t=t
    else :
        flag=False
        break
if(flag):
    print("Yes")
else:
    print("No")

Solution (Python):
manhattan = lambda x,y: abs(x[0] - y[0]) + abs(x[1] - y[1])

def solve():
    n = int(input())
    table = [[0, 0, 0]] + [list(map(int, input().rstrip("\n").split())) for i in range(n)]

    for i in range(1, len(table)):
        t = (table[i][0] - table[i - 1][0] - manhattan(table[i - 1][1:], table[i][1:]))
        if t < 0 or t % 2 != 0:
            return "No"
    return "Yes"

print(solve())

Solution (Python):
N = int(input())
a = 0
for i in range(N):
  a = list(map(int, input().split()))
  if a[0] < sum(a) - a[0]:
    print("No")
    exit()
  if (sum(a) - a[0] - a[0])%2 != 0:
    print("No")
    exit()
print("Yes")

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

Next=TXY.pop(0)
Flag=1

for i in range(N):
    D=Next[0]-abs(Next[1])-abs(Next[2])
    if D<0 or D%2!=0:
        Flag=0
        break
    else:
        if TXY==[]:
            break
        else:
            Next2=TXY.pop(0)
            Next=[Next2[0]-Next[0],Next2[1]-Next[1],Next2[2]-Next[2]]

print(['No','Yes'][Flag])

Solution (Python):
def fun():

  x = int(input())
  y = [input().split() for i in range(x)]

  place = [0,0]
  time = 0
  
  for i in y:
    move = abs(int(i[1]) - place[0]) + abs(int(i[2]) - place[1])
    if (int(i[0]) - time) >= move and ((int(i[0]) - time) - move) % 2 == 0:
      place[0] = int(i[1])
      place[1] = int(i[2])
      time = int(i[0])
    else:
      return "No"
  return "Yes"

print(fun())

Solution (Python):
import sys
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]

t0,x0,y0 = 0,0,0

for i in range(N):
    t,x,y = TXY[i][0],TXY[i][1],TXY[i][2]
    if t-t0 >= abs(x-x0)+abs(y-y0) and (t-t0)%2 == abs(x-x0+y-y0)%2:
        t0,x0,y0 = t,x,y
        continue
    else:
        print("No")
        sys.exit()

print("Yes")

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

t = []
x = []
y = []


can = True

for i in range(N):
    t1, x1, y1 = [int(j) for j in input().split()]
    t.append(t1)
    x.append(x1)
    y.append(y1)

    if x[i] + y[i] <= t[i]:
        if (t[i] - x[i] - y[i]) % 2 == 1:
            can = False
    else:
        can = False

if can == True:
    print('Yes')
else:
    print('No')

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

r = 'Yes'

cur = [0, 0]
now = 0
for t, x, y in X:
    td = t - now
    d = abs(x - cur[0]) + abs(y - cur[1])
    
    if d > td or d % 2 != td % 2:
        r = 'No'

    cur[0], cur[1] = x, y
    now = t

print(r)

Solution (Python):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y) > t or (x + y + 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 (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
txy = []
for i in range(n):
    t,x,y = map(int, input().split())
    txy.append([t, x, y])
txy.sort()
if n==1:
    if txy[0][1]+txy[0][2]!=txy[0][0]:
        print("No")
    else:
        print("Yes")
    exit()
for i in range(n-1):
    a = txy[i+1][0] - txy[i][0]
    ds = abs(txy[i+1][1]-txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    if a >= ds and (a-ds)%2==0:
        continue
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
px=0 
py=0 
f=1 
pt=0 
n=int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    z=abs(x-px)+abs(y-py)
    px=x 
    py=y  
  
   
    if z<=(t-pt) and z%2==(t-pt)%2:
        pass 
    else:
       
        f=0 
    pt=t  
print('Yes' if f else 'No')

Solution (Python):
n=int(input())
x0=0
y0=0
t0=0
ans='Yes'
for i in range(n):
    t1,x1,y1=map(lambda x: int(x), input().split())
    dt=t1-t0
    dx=x1-x0
    dy=y1-y0
    if dt<abs(dx)+abs(dy):
        ans='No'
    if dt%2!=(abs(dx)+abs(dy))%2:
        ans='No'
    t0=t1
    x0=x1
    y0=y1
print(ans)