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())
plan = [tuple(map(int, input().split())) for _ in range(n)]
plan = [(0, 0, 0)] + plan
for i in range(n):
    ct, cx, cy = plan[i]
    nt, nx, ny = plan[i+1]
    t = nt - ct
    x = nx - cx
    y = ny - cy
    if abs(x) + abs(y) > t or (abs(x) + abs(y) - t) % 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
INF = 10**18

N = ri()
ans = 1
t,x,y=0,0,0
for i in range(N):
    t_,x_,y_=rl()
    if t_%2 != (x_+y_)%2:
        ans = 0
    if (t_ - t) < abs(x_-x)+abs(y_-y):
        ans = 0
    t,x,y=t_,x_,y_

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

Solution (Python):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)

def dist(start,goal):
    return abs(start[0]-goal[0])+abs(start[1]-goal[1])

n=int(input())
T=[0]
XY=[[0,0]]
for _ in range(n):
    t,x,y=map(int,input().split())
    T.append(t)
    XY.append([x,y])
for i in range(n):
    dxy=dist(XY[i],XY[i+1])
    dt=T[i+1]-T[i]
    if dxy>dt or dxy%2!=dt%2:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def traveling(n, m):
    t = range(1, len(m))
    for i in t:
        xdif = abs(m[i][1]-m[i-1][1])
        ydif = abs(m[i][2]-m[i-1][2])
        tdif = m[i][0]-m[i-1][0]
        dif = xdif+ydif
        if tdif < dif:
            return 'No'
        elif (tdif > dif) and (((tdif - dif) % 2) != 0):
            return 'No'
    return 'Yes'
N = int(input())
deer = [list(map(int, input().split())) for i in range(N)]
deer.insert(0, [0,0,0])
print(traveling(N, deer))

Solution (Python):
N = int(input())
L = []
for _ in range(N):
    l = list(map(int,input().split()))
    L.append(l)
 
now_x = 0
now_y = 0
now_time = 0
for x in L:
    if x[0] % 2 != (x[1] + x[2]) % 2:
        print("No")
        quit()
    if abs(now_x-x[1]) + abs(now_y-x[2]) > x[0] - now_time:
        print("No")
        quit()
    now_time = x[0]
    now_x = x[1]
    now_y = x[2]
print("Yes")

Solution (Python):
n = int(input())
t = []
x = []
y = []
t_b = 0
x_b = 0
y_b = 0
flag = 0
for i in range(n):
    t_a,x_a,y_a = map(int,input().split())
    t_d = t_a - t_b
    if x_a - x_b + y_a - y_b == t_a - t_b:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    elif (t_a - t_b) - (x_a - x_b + y_a - y_b) > 0 and ((t_a - t_b) - (x_a - x_b + y_a - y_b))%2 == 0:
        t_b = t_a
        x_b = x_a
        y_b = y_a
    else:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
array_t = []
array_x = []
array_y = []
for i in range(N):
    t,x,y = map(int, input().split(" "))
    array_t.append(t)
    array_x.append(x)
    array_y.append(y)
flag = True
for i in range(N):
    if i ==0:
        added = abs(array_x[0])+abs(array_y[0])
        gap = array_t[0] - added
    else:
        added = abs(array_x[i]-array_x[i-1])+abs(array_y[i]-array_y[i-1])
        gap = array_t[i]-array_t[i-1] - added
    if gap>=0 and gap%2 == 0:
        continue
    else:
        print('No')
        flag = False
        break
if flag:
    print('Yes')

Solution (Python):
N = int(input())
routes = [(0,0,0)]
append = routes.append
for _ in range(0, N):
    t, x, y = map(int, input().split())
    append((t, x, y))
for i in range(1, N+1):
    bt, bx, by = routes[i-1]
    t, x, y = routes[i]
    ct = t - bt
    
    cx = abs(x - bx)
    cy = abs(y - by)
    if cx > ct or cy > ct:
        print ("No")
        exit()
    if (cx+cy) % 2 != ct % 2:
        print ("No")
        exit()
print ("Yes")

Solution (Python):
n = int(input())
flag = True
for _ in range(n):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2==1:
        flag = False


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

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

isTravel = True
t, x, y = 0, 0, 0
for i in range( N ):
    ti, xi, yi = map( int, input().split() )
    if abs(xi-x)+abs(yi-y) > ti-t or (abs(xi-x)+abs(yi-y)) % 2 != (ti-t) % 2:
        isTravel = False
    t, x, y = ti, xi, yi

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

Solution (Python):
n=int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
can = True
for i in range(len(l)-1):
    dt = l[i+1][0] - l[i][0]
    dist = abs(l[i+1][1] - l[i][1]) + abs(l[i+1][2]-l[i][2])
    if dt < dist:
        can = False
        break
    if dist % 2 != dt % 2:
        can = False
        break
print('Yes') if can else print('No')

Solution (Python):
n=int(input())
l = [list(map(int,input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
can = True
for i in range(len(l)-1):
    dt = l[i+1][0] - l[i][0]
    dist = abs(l[i+1][1] - l[i][1]) + abs(l[i+1][2]-l[i][2])
    if dt < dist:
        can = False
        break
    if dist % 2 != dt % 2:
        can = False
print('Yes') if can else print('No')

Solution (Python):
N = int(input())
t, x, y = 0, 0, 0
for _ in range(N):
    nt, nx, ny = map(int, input().split())
    if (nt-t)%2 != (nx-x+ny-y)%2 or (nt-t) < abs(nx-x) + abs(ny-y):
        print("No")
        break
else:
    print("Yes")

Solution (Python):

"""
Created on Thu Feb 28 18:15:06 2019

@author: yuta
"""

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

def main(p):
    count = 0
    for i in range(len(p)):
        t = p[i][0]
        sum_xy = p[i][1] + p[i][2]
        if t % 2 == 0:
            if sum_xy <= t and sum_xy % 2 == 0:
                count += 1
        else:
            if sum_xy <= t and sum_xy % 2 != 0:
                count += 1
    if count == len(p):
        print("Yes")
    else:
        print("No")

main(place)

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())
    X = abs(x_ - x)
    Y = abs(y_ - y)
    T = t_ - t
    if ( X + Y > T ) or (T % 2 != ( X + Y ) % 2):
        print("No")
        exit()
    t = t_
    x = x_
    y = y_
print("Yes")

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

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

t,x,y=0,0,0
s=0

for i in range(N):
    tn,xn,yn=map(int,input().split())
    
    if ((tn-t)-(xn-x+yn-y))%2==1 or ((tn-t)-(xn-x+yn-y))<0:
        s=1

if s==0:
    print('Yes')
else:
    print('No')

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

no = 0
for i in range(1,n+1):
    if (A[i][0]-A[i-1][0])%2 != (abs(A[i][1]-A[i-1][1]) + abs(A[i][2]-A[i-1][2]))%2 :
        no = 1
    elif A[i][0]-A[i-1][0] < abs(A[i][1]-A[i-1][1]) + abs(A[i][2]-A[i-1][2]) :
        no = 1
if no == 1 :
    print("No")
else :
    print("Yes")

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

now = 0
x, y = 0, 0
flag = True

for _ in range(n):
    t, x_target, y_target = map(int, input().split())

    distance = abs(x_target - x) + abs(y_target - y)
    duration = t - now

    if distance > duration:
        flag = False
        break
    
    elif distance % 2 != duration % 2:
        flag = False

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

Solution (Python):
n = float(input())
a = []
a.append([0,0,0])
for i in range(int(n)):
    in1, in2, in3 = map(float, input().split())
    a.append([in1,in2,in3])

for j in range(int(n)):
    i = j+1
    point_dif = abs(a[i][1]-a[i-1][1]) + abs(a[i][2] - a[i-1][2])
    time_dif = a[i][0]-a[i-1][0]
    if time_dif %2 != point_dif % 2:
        print('No')
        exit()
    if point_dif > time_dif:
        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())
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())
for i in range(n):
    t,x,y=map(int,input().split())
    if not((x+y)<=t and (x+y)%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(not((x+y)<=t and (x+y)%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(not((x+y)<=t and (x+y)%2 == t%2)):
        print("No")
        exit()
print("Yes")

Solution (Python):

N=int(input())
txy=[[0,0,0]]
for n in range(N):
	txy.append(list(map(int,input().split())))
for n in range(N):
	tt=txy[n+1][0]-txy[n][0]
	xy=abs(txy[n+1][1]-txy[n][1])+abs(txy[n+1][2]-txy[n][2])
	if tt>=xy:
		if (xy-tt)%2==0:
			continue
	print('No')
	exit()
print('Yes')

Solution (Python):
n = int(input())
p = [list(map(int,input().split())) for i in range(n)]
x = 0
y = 0
t = 0
for i in range(n):
    l = abs(p[i][1]-x) + abs(p[i][2]-y)
    if p[i][0] - t >= l and (p[i][0]-t) %2 == l %2:
        t = p[i][0]
        x = p[i][1]
        y = p[i][2]
    else:
        print("No")
        break
else:print("Yes")

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

Solution (Python):

if __name__ == "__main__":
    N = int(input())
    x = 0
    y = 0
    t = 0
    flag = True
    for i in range(N):
        ti, xi, yi = [int(i) for i in input().split()]
        d = abs(xi - x) + abs(yi - y)

        if flag and (ti - t) >= d and ((ti - t) - d) % 2 == 0:
            t = ti
            x = xi
            y = yi
        else:
            flag = False
    print("Yes" if flag else "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+t)%2!=0:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
mx = [i for i in [input().split() for _ in range(n)]]
for i in range(n):
    mx[i] = [int(h) for h in mx[i]]
current_point = [0, 0, 0]
distance = [0, 0, 0]
canArriveAt = True
for p in mx:
    next_point = p
    for i in range(3):
        distance[i] = next_point[i] - current_point[i]
    if distance[0]%2 == (abs(distance[1])+abs(distance[2]))%2 and distance[0] >= abs(distance[1])+abs(distance[2]):
        current_point = next_point
    else:
        canArriveAt = False
print("Yes" if canArriveAt == True else "No")

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

flag=True

for i in range(0,N):
  dt=A[i+1][0]-A[i][0]
  dx=abs(A[i+1][1]-A[i][1])
  dy=abs(A[i+1][2]-A[i][2])
  if not (dx+dy<=dt and (dx+dy-dt)%2==0):
    flag=False
    break
    
print('Yes' if flag else 'No')

Solution (Python):


import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    t.insert(0, 0)
    x.insert(0, 0)
    y.insert(0, 0)
    print(trabelable(N, t, x, y))

def trabelable(N, t, x, y):
    for i in range(N):
        delta_t = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if delta_t < dist:
            return NO
        if delta_t % 2 != dist % 2:
            return NO
    return YES

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    t = [int()] * (N)  
    x = [int()] * (N)  
    y = [int()] * (N)  
    for i in range(N):
        t[i] = int(next(tokens))
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

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

Solution (Python):
n=int(input())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append([a,b,c])
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")

Solution (Python):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
switch = 0
for li in L:
    t = li[0]
    co = li[1]+li[2]
    if t >= co:
        if co % 2 == 0 and t % 2 == 0:
            pass
        elif co % 2 != 0 and t % 2 != 0:
            pass
        else:
            switch += 1
            break
    else:
        switch += 1
        break
if switch == 0:
    print('Yes')
else:
    print('No')

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

    for _ in range(n):
        ti, xi, yi = map(int, input().split())
        t.append(ti)
        x.append(xi)
        y.append(yi)
    
    if solve(n, t, x, y):
        print('Yes')
    else:
        print('No')

def solve(n, t, x, y):
    cur_t, cur_x, cur_y = 0, 0, 0

    for i in range(n):
        if t[i] % 2 != (x[i] + y[i]) % 2:
            return False
        
        if abs(x[i] - cur_x) + abs(y[i] - cur_y) > t[i] - cur_t:
            return False

    return True
        
main()

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

plan_list.append([0,0,0])

for i in range(n):
    plan_list.append(list(map(int,input().split())))
    
for i in range(n):
    t_margin = abs(plan_list[i+1][0] - plan_list[i][0])
    x_margin = abs(plan_list[i+1][1] - plan_list[i][1])
    y_margin = abs(plan_list[i+1][2] - plan_list[i][2])
    xy_margin = x_margin + y_margin
    if t_margin < xy_margin or xy_margin % 2 != t_margin % 2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

n = int(input())

ls = [[0, 0, 0]]

for i in range(n):
    temp = input_numbers()
    ls += [temp]

ls.sort(key = lambda x:x[0])

for i in range(1, n + 1):
    dis = abs(ls[i][1] - ls[i - 1][1]) + abs(ls[i][2] - ls[i - 1][2])
    time = abs(ls[i][0] - ls[i - 1][0])

    flag = 0
    if(dis > time):
        flag = 1
    elif((time - dis) % 2 == 1):
        flag = 1
    
    if(flag == 1):
        print('No')
        break

if(flag == 0):
    print('Yes')

Solution (Python):
N = int(input())
time = 0
place = [0, 0]
for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - time
    distance = abs(x-place[0]) + abs(y-place[1])
    if (distance > dt) or ((distance%2) != (dt%2)):
        print('No')
        break
    place = [x, y]
    time = t
else:
    print('Yes')

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

Solution (Python):
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = [IL() for i in range(N)]

t,x,y = 0,0,0
for i in range(N):
	ti,xi,yi = l[i]
	if 0 <= ti-t\
		and (ti-t -abs(xi-x)-abs(yi-y)) >= 0\
		and (ti-t -abs(xi-x)-abs(yi-y)) %2 == 0:
		t,x,y = ti,xi,yi
	else:
		print("No")
		exit()
print("Yes")

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

N = int(input())
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    if (t < x + y) or (x + y + t) % 2:
        flag = False


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

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

class Deer:
    def __init__(self):
        self.x = 0
        self.y = 0
        self.t = 0

    def move(self, ti, xi, yi):
        time_interval = ti - self.t
        manhattan_distance = abs(xi - self.x) + abs(yi - self.y)
        val = time_interval - manhattan_distance
        if (val >= 0) and (val % 2 == 0):
            self.x = xi
            self.y = yi
            self.t = ti
            return True
        else:
            return False

AtCoDeer = Deer()
N = int(input())
flag = True
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    flag = flag and AtCoDeer.move(ti, xi, yi)


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

Solution (Python):
N = int(input())
data_ls = list()
flg = 0
for i in range(N):
    data_ls.append([int(i) for i in input().split()])
t,x,y = zip(*data_ls)
data_ls = [(t[0], x[0], y[0])]
for i in range(len(t) - 1):
    data_ls.append((t[i+1] - t[i], x[i+1] - x[i], y[i+1] - y[i]))

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

for i in data_ls:
    result = detect_possible(i)
    if not result:
        flg += 1
        break

if flg > 0:
    print("No")
else:
    print("Yes")

Solution (Python):
n = int(input())
ti, xi, yi = 0, 0, 0

ans = 'Yes'
for i in range(n):
  t, x, y = map(int, input().split())
  t_diff = t - ti
  x_diff = x - xi
  y_diff = y - yi
  dis_diff = abs(x_diff) + abs(y_diff)
  if not(t_diff >= dis_diff and t_diff % 2 == dis_diff % 2):
    ans = 'No'
    break
print(ans)

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

Solution (Python):
N=int(input())
list=[]
flag=True
for i in range (N):
    tuple=input()
    input_list=tuple.split()
    input_list=[int(i) for i in input_list]
    list.append(input_list)
for i in range(N):
    time=list[i][0]
    distance=abs(list[i][1])+abs(list[i][2])
    if distance<=time:
        if distance%2==time%2:
            continue
        else:
            flag=False
    else:
        flag=False
if flag:
    print("Yes")
else:
    print("No")

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

for i in range(n):
    t = rn[i + 1][0] - rn[i][0]
    distx = rn[i + 1][1] - rn[i][1]
    disty = rn[i + 1][2] - rn[i][2]
    k = abs(distx) + abs(disty)
    if (t >= k) and ((t + k) % 2 == 0):
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
x = 0
y = 0
t = 0
for i in range(n):
 t_new, x_new, y_new = map(int, input().split())
 l = abs(x_new - x) + abs(y_new - y)
 dt = t_new - t
 if (l <= dt) and (l % 2 == dt % 2 ):
  x = x_new
  y = y_new
  t = t_new
 else:
  
  print('No')
  exit()
print('Yes')

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

Plan = [list(map(int, input().split())) for _ in range(N)]
Plan.append([0,0,0])
flag = True
for i in range(N):
    if abs(Plan[i][0] - Plan[i + 1][0]) < abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]):
        flag = False
        break
    elif abs(Plan[i][0] - Plan[i + 1][0])%2 != (abs(Plan[i][1] - Plan[i + 1][1]) + abs(Plan[i][2] - Plan[i + 1][2]))%2:
        flag = False
        break

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

Solution (Python):
n=int(input())
plan=[list(map(int,input().split())) for i in range(n)]
pret=0
prexy=0
for t,x,y in plan:
  t_diff=t-pret
  xy_diff=abs((x+y)-prexy)
  if t_diff>=xy_diff:
    if t_diff%2==0 and xy_diff%2==0:
      pass
    elif t_diff%2==1 and xy_diff%2==1:
      pass
    else:
      print('No')
      exit()
  else:
    print('No')
    exit()
  pret=t
  prexy=x+y
print('Yes')

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

now = [0,0,0]
for txy in TXY:     
    time = txy[0]-now[0]
    dist = abs(txy[1]-now[1])+abs(txy[2]-now[2])
    if time>=dist and (time%2)==(dist%2):
        now = txy
        continue 
    else:
        print("No") 
        break
else:
    print("Yes")

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

start_x, start_y = (0, 0)
isReachAble = False
for n in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-start_x) + abs(y-start_y)
    if (dist > t):
        print('No')
        exit()
    isTimeEven = t % 2 == 0
    isDestEven = (x + y) % 2 == 0
    if (isTimeEven and isDestEven) or (not isTimeEven and not isDestEven):
        isReachAble = True
    else:
        print('No')
        exit()

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

Solution (Python):
import numpy as np

n = int(input())
input_X = [[int(i) for i in input().split()] for i in range(n)]
X = np.array(input_X)

pre_t = 0
pre_x = 0
pre_y = 0
for i in range(n):
    x_move = abs(X[i][1] - pre_x)
    y_move = abs(X[i][2] - pre_y)
    xy_sum = x_move + y_move
    spend_time = X[i][0]-pre_t
    if xy_sum%2 == spend_time%2 and spend_time >= xy_sum:
        pre_t = X[i][0]
        pre_x = X[i][1]
        pre_y = X[i][2]
        if i+1 == n:
            print('Yes')
        else:
            continue
    else:
        print('No')
        break

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")
    break
else:
  print("Yes")

Solution (Python):
N = int(input())
flag = 1
t_,x_,y_ = [0,0,0]
for _ in range(N):
    t,x,y = list(map(int,input().split()))
    if ((t-t_)-abs(x-x_)-abs(y-y_))%2 == 1 or ((t-t_)-abs(x-x_)-abs(y-y_)) < 0:
        flag = 0
    t_,x_,y_ = [t,x,y]

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

Solution (Python):
N=int(input())
_t = 0
_x = 0
_y = 0
flag = True
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x - _x) + abs(y - _y) > t - _t or (t - _t - (x - _x + y - _y))%2 !=0 :
        flag = False
        break
    _t, _x, _y = t, x, y
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
N = int(input())

origin_x = 0
origin_y = 0
origin_t = 0

for i in range(0,N):
    t,x,y = map(int, input().split())
    distance_x = abs(x - origin_x)
    distance_y = abs(y - origin_y)
    sub_t = t - origin_t
    if distance_x + distance_y > sub_t:
        print('No')
        sys.exit()
    elif (sub_t - distance_x - distance_y) % 2 == 0:
        origin_x = x
        origin_y = y
        origin_t = t
    else:
        print('No')
        sys.exit()

print('Yes')

Solution (Python):

N = int(input())
from collections import defaultdict, Counter

t = [ list(map(int, input().split())) for _ in range(N)]
diff = lambda a,b : abs(a[0] - b[0]) + abs(a[1] - b[1])

pos = (0,0)
tim = 0

for i in range(N):
    distance = diff(pos, t[i][1:])
    dis_time = t[i][0] - tim
    if not dis_time % 2 == distance %2 or not dis_time>=distance:
        print("No")
        exit(0)
print("Yes")
exit(0)









ans = 0
charlist = list("MARCH")
for i in range(1<<5):
    if not Counter( list ( "{0:05b}".format(i)) )["1"] == 3:
        continue
    
    s = 1
    for e,i in enumerate(list("{0:05b}".format(i))):
        if i == "1":
            s *= d[ charlist[e] ]

    ans += s
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+t)%2:
        print("No")
        exit()
print("Yes")

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

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

def distance(x1,y1, x2,y2):
    return abs(x1-x2) + abs(y1-y2)

def check_route(n,t,x,y):
    for i in range(n):
        dist = distance(x[i],y[i], x[i+1],y[i+1])
        if t[i+1] < dist: return "No"
        if (t[i+1] - t[i])%2 != dist%2: return "No"
    return "Yes"
        
print(check_route(n,t,x,y))

Solution (Python):
import math


def solve(N, TXYs):
    now = 0
    p = (0, 0)
    for t, x, y in TXYs:
        td = t - now
        dd = abs(p[0] - x) + abs(p[1] - y)
        if td % 2 != dd % 2 or td < dd:
            return "No"
        now = t
        p = (x, y)
    return "Yes"

if __name__ == "__main__":
    N = int(input())
    TXYs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(N, TXYs))

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

p = [None]*n

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

plan = [[0,0,0]]
plan.extend(p)

for i in range(n):
    diff = [plan[i+1][k] - plan[i][k] for k in range(len(plan[0]))]
    if (abs(diff[1])+abs(diff[2]))>diff[0] or (diff[0]-(abs(diff[1])+abs(diff[2])))%2==1:
        print('No')
        exit()

print('Yes')

Solution (Python):
N=int(input())
t=[0]*N
x=[0]*N
y=[0]*N
for i in range(N):
    t[i],x[i],y[i]=map(int,input().split())
sx=0
sy=0
st=0
flag=True
for i in range(N):
    l=abs(x[i]-sx)+abs(y[i]-sy)
    if flag==False:
        break
    if l<=(t[i]-st) and ((t[i]-st)-l)%2==0:
        flag=True
    else:
        flag=False
    sx=x[i]
    sy=y[i]
    st=t[i]
if flag==True:
    print('Yes')
else:
    print('No')

Solution (Python):
def create_decrement_list(num):
    decrement_list = []
    while(num >= 0):
        decrement_list.append(num)
        num -=2
    return decrement_list

def check_route(num_list, offset):
    is_path_possible = False
    for num in num_list:
        if offset == num:
            is_path_possible = True
            break
    return is_path_possible

def route_checker(N, list_t, list_x, list_y):
    for n in range(N):
        if n == 0:
            offset_x = abs(list_x[n])
            offset_y = abs(list_y[n])
        else:
            offset_x = abs (list_x[n] - list_x[n-1])
            offset_y = abs (list_y[n] - list_y[n-1])
        offset_total = offset_x + offset_y
        time_offset = list_t[n] if n==0 else list_t[n] - list_t[n-1]
        time_offset_list = create_decrement_list(time_offset)
        if check_route(time_offset_list, offset_total)==False:
            print("No")
            break
    else:
        print("Yes")

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

for i in range(N):
    a_list = list(map(int, input().split()))
    t.append(a_list[0])
    x.append(a_list[1])
    y.append(a_list[2])

route_checker(N, t, x, y)

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

for i in range(N):
    t_tmp = 0
    x_tmp = 0
    y_tmp = 0

    t_tmp, x_tmp, y_tmp = map(int, input().split())

    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

flag = 0

for i in range(N):
    judge = (t[i+1] - t[i]) - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])
    if judge % 2 == 1 or judge < 0:
        flag = 1
        break

if flag == 0:
    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 (x+y+t) % 2:
		print("No")
		exit()

print("Yes")

Solution (Python):


N = int(input())


def is_reachable(src, dst):
    can_go = True
    dt = dst[0] - src[0]
    dist = abs(dst[1] - src[1]) + abs(dst[2] - src[2])
    if dt < dist:
        can_go = False
    if dt % 2 != dist % 2:
        can_go = False
    return can_go


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



reachable = True

for i in range(N):
    source = route[i]
    destination = route[i + 1]
    if not is_reachable(source, destination):
        reachable = False

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

Solution (Python):
def solve():
    N = int(input())
    plan = [
        [int(x) for x in input().split()] for _ in range(N)
    ]
    plan = [[0, 0, 0]] + plan

    for i in range(1, N+1):
        t0, x0, y0 = plan[i-1]
        t, x, y = plan[i]
        dx = x - x0
        dy = y - y0
        d = abs(dx) + abs(dy)

        if t - t0 < d:
            return False

        if (t-t0-d)%2 != 0:
            return False

    return True


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

Solution (Python):
from collections import deque
N = int(input())
A = deque([list(map(int, input().split())) for _ in range(N)])
A.appendleft([0, 0, 0])
counter = 0
for i in range(N):
    if not (sum(A[i]) + sum(A[i + 1])) % 2:
        d = sum([abs(A[i][j] - A[i + 1][j]) for j in range(1, 3)])
        if A[i + 1][0] - A[i][0] >= d:
            counter += 1
if counter == N:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

N = int(sys.stdin.readline())
TXY = [
    tuple(map(int, sys.stdin.readline().split())) for _ in range(N)
]

def check(st, sx, sy, et, ex, ey):
    timespan = et - st
    diff = abs(sx - ex) + abs(sy - ey)
    if diff > timespan:
        return False
    if (timespan - diff) % 2 == 0:
        return True
    return False


def main():
    TXY.insert(0, (0, 0, 0))
    for i in range(len(TXY) - 1):
        args = TXY[i] + TXY[i + 1]
        if not check(*args):
            print('No')
            return
    print('Yes')

main()

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

data = []

for i in range(N):
    t, x, y = map(int, raw_input().split())
    data.append((t, x, y))


for d in data:
    t, x, y = d
    if t < x + y:
        print('No')
        exit()
    if (x+y)%2 != t%2:
        print('No')
        exit()
print('Yes')

Solution (Python):


import numpy as np
import random

n = int(input())
x = []
t = []
y = []
for i in range(n):
    t_tem,x_tem,y_tem = map(int,input().split())
    t.append(t_tem)
    x.append(x_tem)
    y.append(y_tem)

def check_move(t,x,y):
    check = True
    
    if x+y > t:
        check = False
    
    elif x+y+t%2 == 1:
        check = False

    return check

answer = True
x_now = 0
y_now = 0
t_now = 0
for i in range(n):
    answer *= check_move(t[i]-t_now,x[i]-x_now,y[i]-y_now)
    t_now = t[i]
    x_now = x[i]
    y_now = y[i]

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

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

ans = 'Yes'
t0, x0, y0 = 0, 0, 0
for t, x, y in li:
    d = abs(x - x0) + abs(y - y0)
    if d > t - t0 or d % 2 != (t - t0) % 2:
        ans = 'No'
        break
    t0, x0, y0 = t, x, y

print(ans)

Solution (Python):
N = int(input())
pos = "Yes"


for l in range(1, N+1):
  t1, x1, y1 = [int(l) for l in input().split()]
  result = abs(x1) + abs(y1)
  if result > t1:
    pos = "No"
    break
  elif result <= t1:
    if t1 % 2 == 0 and result %2 != 0:
    	pos = "No"
    	break
    elif t1 % 2 != 0 and result %2 == 0:
    	pos = "No"
    	break
    else:
      continue
  else:
      print("Error")

print(pos)