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())
matrix = []
for i in range(n):
    matrix.append([int(i) for i in input().split()])

can = True
t = 0
pos = [0, 0]
for row in matrix:
    t_diff = row[0] - t
    max_step = abs(row[1] - pos[0]) + abs(row[2] - pos[1])
    if max_step > t_diff:
        can = False
        break
    elif max_step % 2 != t_diff % 2:
        can = False
        break
    else:
        t = row[0]
        pos = row[1:3]

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

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

moves = []
for i in range(N):
	moves.append(tuple(map(int, input().split())))
	
current = (0, 0, 0)
for nextPosition in moves:
	dt = nextPosition[0] - current[0]
	dist = abs(nextPosition[1] - current[1]) + abs(nextPosition[2] - current[2])
	if (dist > dt):
		print('No')
		exit()
	if (dt%2 != dist%2):
		print('No')
		exit()

print('Yes')

Solution (Python):
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    t_, x_, y_ = map(int, input().split())
    t.append(t_)
    x.append(x_)
    y.append(y_)

flag = True
for i in range(n):
    t_diff = t[i+1] - t[i]
    x_diff = x[i+1] - x[i]
    y_diff = y[i+1] - y[i]

    if abs(x_diff) + abs(y_diff) > t_diff:
        flag = False
        break

    if (x_diff % 2 == 0 and y_diff % 2 == 0) or (x_diff % 2 != 0 and y_diff % 2 != 0):
        match = True
    else:
        match = False

    if t_diff % 2 == 0 and not match:
        flag = False
        break
    elif t_diff % 2 != 0 and match:
        flag = False
        break

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

Solution (Python):
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dx = x - prev_x
    dy = y - prev_y
    if dt < dx + dy:
        print("No")
        break
    elif (dx + dy - dt) % 2 == 0:
        prev_t, prev_x, prev_y = t, x, y
    else:
        print("No")
        break
else:
    print("Yes")

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

for i in range(N) :
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)
    

cur_x = 0
cur_y = 0
cur_time = 0 
flg_possible = True

for i in range(N) :
    min_dist = abs(x[i] - cur_x) + abs(y[i] - cur_y)

    if min_dist > t[i] or not((t[i] - cur_time) % 2 == min_dist % 2):
        print("No")
        flg_possible = False
        break
    else :
        cur_x, cur_y, cur_time = x[i], y[i], t[i]
        
if flg_possible == True :
    print("Yes")

Solution (Python):


def main():
    n = int(input().strip())
    z = [[int(i) for i in input().split()] for _ in range(n)]

    def func(z, z0):
        t0, x0, y0 = z0
        t, x, y = z
        dist = abs(x - x0) + abs(y - y0)
        t = t - t0
        if dist > t:
            return False

        if dist % 2 == t % 2:
            return True
        else:
            return False

    z = [[0, 0, 0]]  + z
    for i in range(1, len(z)):
        if not func(z[i], z[i-1]):
            print("No")
            return

    print("Yes")
        

if __name__ == '__main__':
    main()

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

for i in range(N) :
    _t, _x, _y = map(int, input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)

cur_x, cur_y = 0, 0
cur_t = 0
flg_impossible = "Yes"

for i in range(N) :
    dloc = (x[i] - cur_x) + (y[i] - cur_y)
    dt = t[i] - cur_t
    
    if ((dloc % 2 == 0 and dt % 2 == 0) or (dloc % 2 != 0 and dt % 2 != 0)) and dloc <= dt :
        cur_x, cur_y, cur_t = x[i], y[i], t[i]
    else :
        flg_impossible = "No"
        
print(flg_impossible)

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

def distance(x1,y1,x2,y2):
    return(abs(x1-x2)+abs(y1-y2))
flag = True
for  i in range(1,n+1):
    dis = distance(txy[i][1],txy[i][2],txy[i-1][1],txy[i-1][2])
    if  not (dis <= txy[i][0]-txy[i-1][0] and (txy[i][0]-txy[i-1][0] - dis)%2==0):
        flag=False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
past_x = 0
past_y = 0
past_t = 0
for _ in range(n):
    t, x, y = tuple(map(int, input().split(" ")))
    diff = abs(past_x - x) + abs(past_y - y)
    if (t - past_t) >= diff and ((t - past_t) - diff) % 2 == 0:
        past_t, past_x, past_y = t, x, y
        continue
    else:
        print("No")
        exit(0)

print("Yes")

Solution (Python):
N = int(raw_input())
T = [0]
X = [0]
Y = [0]
for i in range(N):
  t, x, y = map(int, raw_input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
ret = "Yes"
for i in range(N):
  d = abs(X[i+1]-X[i]) + abs(Y[i+1]-Y[i])
  dt = T[i+1]-T[i]
  if d > dt or (dt-d)%2==1:
    ret = "No"
print ret

Solution (Python):
import sys
N = int(input().strip())
grid = []
for i in range(N):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
t = [0]
x = [0]
y = [0]
for lists in grid:
  t.append(lists[0])
  x.append(lists[1])
  y.append(lists[2])
i = 0
while i < N:
  d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
  dt = t[i+1]-t[i]
  if dt >= d and (dt-d)%2==0:
    i += 1
  else:
    print('No')
    sys.exit()
print('Yes')

Solution (Python):

import sys

n = int(sys.stdin.readline())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = sys.stdin.readline().split()
	t, x, y = tuple(map(int, txy_strs))

	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Solution (Python):
import sys

n = int(input())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = input().split()
	t, x, y = tuple(map(int, txy_strs))
	
	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Solution (Python):
import sys

n = int(input())
before_t, before_x, before_y = 0, 0, 0
for i in range(n):
	txy_strs = input().split()
	t, x, y = tuple(map(int, txy_strs))
	
	movable = t - before_t
	min_move = abs(x - before_x) + abs(y - before_y)

	remaining = movable - min_move
	if 0 <= remaining and remaining % 2 == 0:
		before_t, before_x, before_y = t, x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Solution (Python):

import sys

n = int(input())
txy_list = [[int(n) for n in input().split()] for i in range(n)]
times_list = [txy_list[0][0]] + [txy_list[i+1][0] - txy_list[i][0] for i in range(n-1)]

before_x, before_y = 0, 0
for i, txy in enumerate(txy_list):
	t, x, y = txy
	rela_x, rela_y = x - before_x, y - before_y
	remaining = times_list[i] - (abs(rela_x) + abs(rela_y))
	if 0 <= remaining and remaining % 2 == 0:
		before_x, before_y = x, y
	else:
		print("No")
		sys.exit()
print("Yes")

Solution (Python):
n=int(input())
def md(x,y):
    return abs(x)+abs(y)
def isOdd(a,b):
    if a%2==b%2:
        return False
    else:
        return True 
pt=0
px=0
py=0
for _ in range(n):
    t,x,y=map(int,input().split())
    dt=t-pt
    dx=x-px
    dy=y-py
    pt=t
    px=x
    py=y
    if dt<md(dx,dy) or isOdd(dt,md(dx,dy)):
        print('No')
        break
else:
    print('Yes')

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

t_pre,x_pre,y_pre = 0,0,0 
for i in range(n):
    t,x,y = map(int, input().split())
    t_dif, x_dif, y_dif = abs(t_pre-t), abs(x_pre-x), abs(y_pre-y)
    
    if 0 <= x_dif+y_dif <= t_dif:
        if (x_dif+y_dif)%2 == t_dif%2: 
            t_pre, x_pre, y_pre = t, x, y
            continue
    print('No')
    sys.exit()
    
print('Yes')

Solution (Python):
import sys

def dis(x0, y0, x1, y1):
    d = 0
    d += abs(x0 - x1)
    d += abs(y0 - y1)
    return d

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    lines = sys.stdin.readlines()

    ls = [[0, 0, 0]]
    for line in lines:
        ls.append([int(i) for i in line.split()])

    for i in range(1, len(ls)):
        d = dis(ls[i][1], ls[i][2], ls[i-1][1], ls[i-1][2])
        t = ls[i][0] - ls[i-1][0]
        
        if d <= t and t % 2 == d %  2:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')

Solution (Python):
import sys
n = int(input())
x = 0
y = 0
t = 0
for i in range(n):
	nt,nx,ny = map(int,input().split())
	k = abs(nx-x) + abs(ny-y)
	can = nt - t
	if k>can:
		print("No")
		sys.exit()
	elif k%2!=can%2:
		print("No")
		sys.exit()
	else:
		x = nx
		y = ny
		t = nt
print("Yes")

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

plan = True

pret = 0
prex = 0
prey = 0
for i in range(N):
    t,x,y = (int(k) for k in input().split())
    distance = abs(prex - x) + abs(prey - y)
    if distance > (t - pret):
        plan = False
    elif (distance - (t - pret)) % 2 != 0:
        plan = False
    pret = t
    prex = x
    prey = y

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

Solution (Python):
N = int(input())
txy = [[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    t = txy[i+1][0] - txy[i][0]
    move = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if t < move or (t - move)%2 != 0:
        print('No')
        exit()
print('Yes')

Solution (Python):


N = input()
N = int(N)
a = [input().split() for _ in range(N)]
b = [[0,0,0]]
b.extend(a)
rtn = 'Yes'
for i in range(N):
    t1 = int(b[i][0])
    x1 = int(b[i][1])
    y1 = int(b[i][2])
    t2 = int(b[i+1][0])
    x2 = int(b[i+1][1])
    y2 = int(b[i+1][2])

    td = t2-t1
    xyd = (x2+y2) - (x1+y1)

    
    if((td%2==xyd%2) & (td>=xyd)):
        rtn = rtn
    else:
        rtn = 'No'

print(rtn)

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




def move(xy1, xy2):
    return abs(xy1[0]-xy2[0]) + abs(xy1[1]-xy2[1])

for i in range(N):
    move_distance = move(txy[i+1][1:], txy[i][1:])
    tmp = txy[i+1][0]-txy[i][0]
    if tmp < move_distance:
        print("No")
        exit()
    if move_distance%2==0: 
        if tmp%2==1:
            print("No")
            exit()
    else: 
        if tmp%2==0:
            print("No")
            exit()

    
print("Yes")

Solution (Python):
N = int(input())
tmp = [0,0,0]
data = [0,0,0]
flag = True
for i in range(N):
  tmp = list(map(int,(input()).split()))
  if (tmp[0] - data[0])%2 == (tmp[1] + tmp[2] - data[1] - data[2]) % 2 + 1 or (tmp[1] - data[1] + tmp[2] - data[2] > tmp[0] - data[0]):
    flag = False
    break
  else:
    data = tmp

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

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

pt=0
px=0
py=0

flag=1

for i in range(N):
    t,x,y=map(int,input().split())
    lt=t-pt
    lxy=abs(x-px)+abs(y-py)
    if lxy>lt or abs(lxy%2-lt%2) >0:
        flag=-1

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

Solution (Python):
n = int(input())
txys = [[0, 0, 0]] + [[int(x) for x in input().split()] for _ in range(n)]

def check(txy1, txy2):
    dt = txy2[0] - txy1[0]
    dx = abs(txy2[1] - txy1[1])
    dy = abs(txy2[2] - txy1[2])
    return (dt >= dx + dy) and (dt % 2 == (dx + dy) % 2)

print('Yes' if all(check(*rows) for rows in zip(txys, txys[1:])) else 'No')

Solution (Python):










N = int(input())
val = [[int(i) for i in input().split()] for i in range(N)]
val.insert(0, [0, 0, 0])

def abs(a):
    if(a < 0):
        return (-a)
    else:
        return a

dist = 0
t = 0
flag = 1
j = 0
for j in range(N):
    t = val[j+1][0] - val[j][0]
    dist = abs(val[j+1][1] - val[j][1]) + abs(val[j+1][2] - val[j][2])
    if(flag==1 and dist<=t and t%2==dist%2):
        flag = 1
    else:
        flag = 0

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

Solution (Python):
t,x,y,f=0,0,0,1
for i in [0]*int(input()):
    a,b,c=map(int,input().split())
    d=abs(x-b)+abs(y-c)
    e=abs(t-a)
    if e<d or e%2!=d%2:f=0
    else:t,x,y=a,b,c
print(['No','Yes'][f])

Solution (Python):
prev_t = 0
prev_x = 0
prev_y = 0

n = int(input())
ans = True
for _ in range(n):
    t, x, y = map(int, input().split())
    dist = (x - prev_x) + (y - prev_y)
    time = t - prev_t
    if dist > time or dist % 2 != time % 2:
        ans = False
        break

    prev_x = x
    prev_y = y
    prev_t = t

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

Solution (Python):
N = int(input())
T,X,Y = [0],[0],[0]
a = 1
for n in range(N):
    t,x,y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

for m in range(N):
    dt = T[m+1]-T[m]
    ds = abs(X[m+1]-X[m]) + abs(Y[m+1]-Y[m])
    if dt < ds:
        a = 0
    if dt%2 != ds%2:
        a = 0

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

Solution (Python):
N = int(input())
arr = [ list(map(int, input().split())) for i in range(N)]
arr.insert(0, [0, 0, 0])
res = 'Yes'

for i in range(N):
    x = arr[i+1][1] - arr[i][1]
    y = arr[i+1][2] - arr[i][2]
    t = arr[i+1][0] - arr[i][0]
    
    if x+y <= t:
        if (x+y-t)%2 == 0:
            pass
        else:
            res = 'No'
            break
    else:
        res = 'No'
        break
        
print(res)

Solution (Python):


cnt = int(input())

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

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

flag = True
t, x, y = 0, 0, 0

for _ in range(N):
    t_nxt, x_nxt, y_nxt = map(int, input().split())
    dist = abs(x_nxt - x) + abs(y_nxt - y)
    if dist == 0 or not (dist <= t_nxt and (t_nxt - dist) % 2 == 0):
        flag = False

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

Solution (Python):
n = int(input())
t1, x1, y1=map(int, input().split())
if t1<x1+y1 or (x1+y1+t1)%2==1:
  print("No")
  exit()
for i in range(n-1):
  t2, x2, y2=map(int, input().split())
  if t2<x2+y2 or (abs(x2-x1)+abs(y2-y1))>t2-t1 or (x2+y2+t2)%2==1:
    print("No")
    exit()
print("Yes")

Solution (Python):
import numpy
import re
import math

def main():
	"""
	テストコード実行
	:return:
	"""
	
	
	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")

if __name__ == '__main__':
	main()

Solution (Python):


import math

n=int(input())

S=[]

NowT=0
Dist=0
Sx=0
Sy=0

for i in range(n):
    S.append(list(map(int,input().split())))

for i in range(n):
    NowT=S[i][0]-NowT
    Dist=abs(S[i][1]-Sx)+abs(S[i][2]-Sy)
    if NowT>=Dist and NowT%2 ==Dist%2:
        pass
    else:
        
        print("No")
        exit()
    NowT=S[i][0]
    Sx=S[i][1]
    Sy=S[i][2]
    
print("Yes")

Solution (Python):
import sys
ans = 'Yes'; input()
for e in sys.stdin:
    t, x, y = map(int, e.split())
    t = t - x - y
    if t < 0 or t % 2 == 1: ans = 'No'; break
print(ans)

Solution (Python):
import sys
can = True; input()
e = [[0, 0, 0]] + [list(map(int, e.split())) for e in sys.stdin]
for a, b in zip(e[1:], e):
    t = a[0] - b[0] - abs(a[1] - b[1]) - abs(a[2] - b[2])
    if t < 0 or t % 2 == 1: can = False; break
print(['No', 'Yes'][can])

Solution (Python):
can = True
e = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(int(input()))]
for a, b in zip(e[1:], e):
    dt = a[0] - b[0]
    dist = abs(a[1] - b[1]) + abs(a[2] - b[2])
    if dt < dist: can = False; break
    if dt % 2 != dist % 2: can = False; break
print(['No', 'Yes'][can])

Solution (Python):
N = int(input())
it, ix, iy = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = abs(it - t)
    dx = abs(ix - x)
    dy = abs(iy - y)
    d = dt - (dx + dy)
    if d < 0 or d % 2 != 0:
        ans = 'No'
        break
    it, ix, iy = t, x, y
print(ans)

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

for i in range(N):
    x_distance = Destinations[i+1][1] - Destinations[i][1]
    y_distance = Destinations[i+1][2] - Destinations[i][2]
    if x_distance < 0:
        x_distance = -x_distance
    if y_distance < 0:
        y_distance = -y_distance
    move_distance = x_distance+y_distance

    move_time = Destinations[i+1][0] - Destinations[i][0]

    if move_distance == 0:
        print("No")
        break

    if move_distance > move_time*1:
        print("No")
        break
    elif move_distance%2 == move_time%2:
        pass
    else:
        print("No")
        break

    if i == N-1:
        print("Yes")

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

j=0
for i in range(n):
    
    
    
    l=list(map(int,input().split()))
    if l[1]+l[2]>l[0] or (l[0]+l[1]+l[2])%2!=0:
        print("No")
        j=1
        break
if j==0:
    print("Yes")

Solution (Python):
def main():
    num_n = int(input())
    plan_lists = [[0, 0, 0]]
    for i in range(num_n):
        plan_lists.append(list(map(int, input().split())))
    for i in range(num_n):
        if sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:]) > (plan_lists[i+1][0] - plan_lists[i][0]):
            return print("No")
        if (plan_lists[i+1][0] - plan_lists[i][0]) % 2 == 0:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 0:
                continue
            else:
                return print("No")
        else:
            if (sum(plan_lists[i+1][1:]) - sum(plan_lists[i][1:])) % 2 == 1:
                continue
            else:
                return print("No")
    print("Yes")





if __name__ == '__main__':
    main()

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


def distance(p1, p2):
    return abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])


def judge(T, points, N):
    for i in range(N):
        delta_t = T[i + 1] - T[i]
        d = distance(points[i + 1], points[i])
        if not (delta_t >= d and (delta_t - d) % 2 == 0):
            return "No"
    return "Yes"


print(judge(T, points, N))

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):
def m():
    n = int(input())
    nowt = 0
    nowx = 0
    nowy = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        divt = abs(nowt - t)
        divx = abs(nowx - x)
        divy = abs(nowy - y)
        if divt < divx + divy:
            return "No"
        if divt == divx + divy:
            continue
        if (divt - divx + divy) % 2 == 0:
            continue
        return "No"
    return "Yes"

print(m())

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

if N == 1:
    timeInterval = list[1][0] - list[0][0]
    distance = abs(list[1][1]+list[1][2]-list[0][1]-list[0][2])
    if timeInterval < distance:
        print("No")
    elif (timeInterval - distance)%2 == 0:
        print("Yes")
    else:
        print("No")
else:
    for i in range(N):
        timeInterval = list[i+1][0] - list[i][0]
        distance = abs(list[i+1][1]+list[i+1][2]-list[i][1]-list[i][2])
        if timeInterval < distance:
            print("No")
            break
        elif (timeInterval - distance)%2 == 0:
            if i == N-1:
                print("Yes")
        else:
            print("No")
            break

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    tl, xl, yl = [], [], []
    for i in range(n):
        t, x, y = map(int, input().split())
        tl.append(t)
        xl.append(x)
        yl.append(y)

    prex, prey, pret = 0, 0, 0
    for t, x, y in zip(tl, xl, yl):
        sumxy = x + y - prex - prey
        sumt = t - pret
        prex, prey, pret = x, y, t
        if sumxy > sumt or sumt % 2 != sumxy % 2:
            print('No')
            exit()
    print('Yes')

Solution (Python):
def pred(t,x,y):
    return (t >= x + y and (y + x - t)%2 == 0)
result = True

t = 0
x = 0
y = 0

N = input()
for i in range(N):
    nt,nx,ny = map(int ,raw_input().split())
    if not pred(nt -t, abs(nx-x), abs(ny-y)):
        result = False
        break
    t, x, y =nt, nx, ny
print (['No','Yes'][result])

Solution (Python):
import sys

N = int(input())
place_info_list = list()

for _ in range(N):
    t, x, y = list(map(int, input().split()))
    place_info_list.append({
        't': t,
        'x': x,
        'y': y,
    })

place_info_list.sort(key=lambda place: place["t"])

current_place_info = {
    't': 0,
    'x': 0,
    'y': 0,
}

for place_info in place_info_list:
    distance = abs(place_info['x'] - current_place_info['x']) +\
               abs(place_info['y'] - current_place_info['y']) 
    necessary_time = distance / 1.0
    remained_time = place_info['t'] - current_place_info['t']

    if remained_time < necessary_time:
        print("No")
        sys.exit()

    if (remained_time - necessary_time) % 2 == 1:
        print("No")
        sys.exit()
    
    current_place_info['t'] = place_info['t']
    current_place_info['x'] = place_info['x']
    current_place_info['y'] = place_info['y']

print("Yes")

Solution (Python):

N = int(input())

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

point = [0,0]
flag = "Yes"
t = 0
for i in txy:
    t_, x, y = i
    t__ = t_ - t 
    move = abs(x-point[0])+abs(y-point[1])
    if move > t__:
        flag = "No"
        break
    elif (t__ - move) % 2 == 1:
        flag = "No"
        break
    point = [x,y]
    t = t_

print(flag)

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

c = (0, 0, 0)
check = True
for i in range(n):
    ct, cx, cy = c
    t, x, y = [int(i) for i in input().strip().split(' ')]
    dt = t - ct
    d = abs(cx - x) + abs(cy - y)
    if dt < d or (dt - d) % 2 != 0:
        check = False

print("Yes" if check else "No")

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())
src = [tuple(map(int,input().split())) for i in range(N)]

x = y = t = 0
for ti,xi,yi in src:
    dist = abs(x-xi) + abs(y-yi)
    if ti - t >= dist and (ti-t)%2 == dist%2:
        t,x,y = ti,xi,yi
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
s_list = [list(map(int, input().split())) for i in range(n)]
ans = "Yes"
for s in s_list:
    if s[0] < s[1] + s[2]:
        ans = "No"
        break
    elif s[0] % 2 == 0 and (s[1] + s[2]) % 2 == 1:
        ans = "No"
        break
    elif s[0] % 2 == 1 and (s[1] + s[2]) % 2 == 0:
        ans = "No"
        break
print(ans)

Solution (Python):
n = int(input())
a = []
for i in range(n):
    a.append([int(num) for num in input().split()])


ans = True
for i in range(n):


    if(a[i][0] >= (a[i][1] + a[i][2])):
        if(a[i][0]%2 != (a[i][1] + a[i][2])%2):
            ans = False
            break
    else:
        ans = False
        break
    
if(ans):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import math
l = []
for i in range(int(input())):
    l.append(list(map(int,input().split())))
start = [0,0]
back = 0
for i in l:
    dist = math.fabs((start[0] - i[1]) + (start[1] -i[2]))
    if(dist > (i[0]-back)):
        print("No")
        sys.exit()
    else:
        if((dist-(i[0]-back))%2 == 0):
            start = [i[1],i[2]]
            back = i[0]
        else:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
def c_traveling(N, P):
    t = x = y = 0  
    for t_next, x_next, y_next in P:
        dt = t_next - t
        dd = abs(x_next - x) + abs(y_next - y)
        if dt >= dd and dt % 2 == dd % 2:
            
            
            t, x, y = t_next, x_next, y_next
        else:
            return 'No'
    return 'Yes'

N = int(input())
P = [[int(i) for i in input().split()] for j in range(N)]
print(c_traveling(N, P))

Solution (Python):
N=int(input().strip())
txy=[]
t1,x1,y1 = 0,0,0
flag=True
for i in range(N):
    t2,x2,y2 = map(int,input().split())
    dt=t2-t1
    dist=abs(x2-x1)+abs(y2-y1)
    if dist>dt or (dist-dt)%2!=0:
        flag=False
        break
print(["No", "Yes"][flag])

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())
t = [[0, 0, 0]]
for i in range(n):
    t.append(list(map(int, input().split())))
for i in range(0, n):
    time = t[i+1][0] - t[i][0]
    move = t[i+1][1] + t[i+1][2] - (t[i][1] + t[i][2])
    if(move > time or move%2 != time%2):
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
t = [0]
x = [0]
y = [0]
ans = "Yes"
for i in range(n):
    t_i, x_i, y_i = map(int,input().split())
    t.append(int(t_i))
    x.append(int(x_i))
    y.append(int(y_i))

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 dist > dt:
        ans = "No"
        break
    if dist%2 != dt%2:
        ans = "No"
        break
print(ans)

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

flag = 1

for i in range(1,len(trv)):
    time = trv[i][0]-trv[i-1][0]
    dist = abs(trv[i][1]-trv[i-1][1]) + abs(trv[i][2]-trv[i-1][2])
    if time < dist:
        flag = 0
    elif time >= dist and (time-dist) % 2 == 0:
        None
    else:
        flag = 0
        break
        
if flag == 0:
    print('No')
else:
    print('Yes')

Solution (Python):
n = int(input())
data = [tuple(map(int, input().split())) for _ in range(n)] 
flag = True
for i in range(n):
    dt,dx,dy = [data[i][k]-(0 if i==0 else data[i-1][k]) for k in range(3)]
    if not(dx+dy<=dt and (dt-dx-dy)%2==0):
        flag = False
        break
print('Yes' if flag else 'No')

Solution (Python):
N = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
result = 'Yes'
for i in range(N + 1):
    if i == 0:
        pass
    else:
        d_t = t_list[i] - t_list[i-1]
        d_x = x_list[i] - x_list[i-1]
        d_y = y_list[i] - y_list[i-1]
        if d_t >= d_x + d_y:
            if (d_t - (d_x + d_y)) % 2 == 0:
                pass
            else:
                result = 'No'
        else:
            result = 'No'
print(result)

Solution (Python):

n = int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
t = [i[0] for i in a]
x = [i[1] for i in a]
y = [i[2] for i in a]
tmpt=0
tmpx=0
tmpy=0
for i in range(n):
    tmp = (t[i] - tmpt) - abs(x[i] - tmpx) - abs(y[i] - tmpy)
    tmpt = t[i]
    tmpx = x[i]
    tmpy = y[i]
    if tmp >= 0 and tmp%2 == 0:
        continue
    print("No")
    break
else:
    
    print("Yes")

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

Solution (Python):
n=int(raw_input())
m=flag=f=0
temp=[[0,0,0]]
for i in range(n):
	ip=map(int,raw_input().split())
	temp.append(ip)
	
for i in range(1,n+1):
	if temp[i][0]-temp[i-1][0] >=abs(temp[i][1]+temp[i][2]-temp[i-1][1]-temp[i-1][2]):
		flag=1
	if ((temp[i][0]-temp[i][1]-temp[i][2])%2==0):
		f=1
	if flag==1 and f==1:
		m=m+1
	flag=f=0
	
if n==m:
	print 'Yes'
else:
	print 'No'

Solution (Python):
n=int(input())
kh=[]
dif=[]
current=0
for i in range(n):
    kh.append(list(map(int,input().split())))
    dif.append(kh[-1][0]-current)
    current=kh[-1][0]
    
   
current=[0,0]
flag=True
for i in range(n):
    need=abs(kh[i][1]-current[0])+abs(kh[i][2]-current[1])
    current=[kh[i][1],kh[i][2]]
    
    if dif[i] < need :
        flag = False
        break
    elif (dif[i] - need) % 2 != 0 :
        flag = False 
        break
if flag :
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
travel=[]
dif=[]
current=0
for i in range(n):
    travel.append(list(map(int,input().split())))
    dif.append(travel[-1][0]-current)
    current=travel[-1][0]
    
   
current=[0,0]
tamam=True
for i in range(n):
    need=abs(travel[i][1]-current[0])+abs(travel[i][2]-current[1])
    current=[travel[i][1],travel[i][2]]
    
    if dif[i] < need :
        tamam = False
        break
    elif (dif[i] - need) % 2 != 0 :
        tamam = False 
        break
if tamam :
    print("Yes")
else:
    print("No")

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

for i in range(1, n+1):
    distance = abs(data[i][1] - data[i-1][1]) + abs(data[i][2] - data[i-1][2])
    time = abs(data[i][0] - data[i-1][0])
    if not (distance <= time and distance % 2 == time % 2):
        print('No')
        exit()

print('Yes')

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

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

for i in range(0,n):
    tin, xin, yin = (int(i) for i in input().split())
    t.append(tin)
    x.append(xin)
    y.append(yin)

for i in range(1,n+1):
    TimeGap = t[i]-t[i-1]
    DisGap = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if TimeGap%2 != DisGap%2 or TimeGap < DisGap:
        ok = False
if ok == True:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
listT = [0]
listX = [0]
listY = [0]

for i in range(N):
    A,B,C = map(int,input().split())
    listT.append(A)
    listX.append(B)
    listY.append(C)

'''
for j in range(N+1):
    print(listT[j])
    print(listX[j])
    print(listY[j])
'''

flag = 'Yes'

for j in range(1,N+1):
    m = listT[j]-listT[j-1] -listX[j]-listY[j] +listX[j-1]+listY[j-1]


    if m%2==0 and m>=0:

        continue
    else:
        flag = 'No'

print(flag)

Solution (Python):
N = int(input())
t_bef = 0
x_bef = 0
y_bef = 0

flag = False
for i in range(N):
    t, x, y = map(int, input().split())
    t_diff = t - t_bef
    dist = abs(x - x_bef) + abs(y - y_bef)
    if (t_diff - dist)%2 != 0 or dist > t_diff:
        flag = True
    else:
        t_bef = t
        x_bef = x
        y_bef = y

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