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):
flag = False
n = int(input())
t = [[0,0,0]]
for i in range(n):
    t.append( [int(x) for x in input().split()])
 
for  i in range(n):
    if (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2])) /  (t[i+1][0]-t[i][0]) > 1:
            flag = False
            break
    elif (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))   / ( t[i+1][0]-t[i][0])  == 1:
            flag = True
            continue
    else:
            if not (( t[i+1][0]-t[i][0]) - (abs(t[i+1][1]-t[i][1])+abs(t[i+1][2]-t[i][2]))  )  &1:
                flag = True
                continue
            else:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
L = [tuple(map(int, input().split())) for _ in range(n)]
for t, x, y in L:
    vio1 = x + y > t
    vio2 = t % 2 == 0 and (x + y) % 2 != 0
    vio3 = t % 2 != 0 and (x + y) % 2 == 0
    if vio1 or vio2 or vio3:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
P = [[0, 0, 0]]
f = True
for i in range(n):
    t, x, y = map(int, input().split())
    s = abs(x - P[i][1]) + abs(y-P[i][2])
    if s > t-P[i][0] or (t-P[i][0] - s)%2 == 1:
        f = False
    P.append([t, x, y])
if f: print("Yes")
else: print("No")

Solution (Python):
N = int(input())
t0, x0, y0 = 0, 0, 0
flg = True
for i in range(N):
  t, x, y = input().split()
  t, x, y = int(t),int(x),int(y)
  dt = t - t0
  dx = abs(x - x0)
  dy = abs(y - y0)
  if dx + dy > dt or (dt + dx + dy) % 2 != 0:
    flg = False
    break
print("Yes" if flg else "No")

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

ans = 'Yes'

for i in range(1,n+1):
	t[i],x[i],y[i] = map(int,input().split())
	saitan = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
	if t[i]-t[i-1] < saitan:
		ans = 'No'
	elif (t[i]-t[i-1])%2 != saitan%2:
		ans = 'No'

print(ans)

Solution (Python):
def Traveling(n , txyl):

    ans = "No"
    count = 0
    for i in range(n):
        if txyl[i][0] >= txyl[i][1] + txyl[i][2] and txyl[i][0] % 2 == (txyl[i][1] + txyl[i][2]) % 2:
            count += 1

    if count == n:
        ans = "Yes"

    return ans

def main():
    n = int(input())
    txyl = [list(map(int , input().split())) for i in range(n)]
    print(Traveling(n , txyl))

if __name__ == '__main__':
    main()

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

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

f = 0 

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

n = 0

for i in range(1,N+1):    
    tdiff = t[i] - t[i-1] 
    ddiff = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]) 

    
    

    if tdiff >= ddiff and (tdiff - ddiff) % 2 == 0: 
        continue
    else:
        f = 1
        break

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

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


t = 0
x = 1
y = 2

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

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

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

for i in range(N):
    tadd, xadd, yadd = map(int, input().split())
    t.append(tadd)
    x.append(xadd)
    y.append(yadd)

ans = 'Yes'

for j in range(N):
    dt = t[j+1] - t[j]
    dist = abs(x[j+1] - x[j]) + abs(y[j+1] - y[j])

    if dt % 2 != dist % 2 or dt < dist:
        ans = 'No'
        break

print(ans)

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

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

for i in range(N):
    tadd, xadd, yadd = map(int, input().split())
    t.append(tadd)
    x.append(xadd)
    y.append(yadd)

ans = 'Yes'

for j in range(N):
    if t[j] % 2 != (x[j] + y[j]) % 2 or t[j] < abs(x[j]) + abs(y[j]):
        ans = 'No'
        break

print(ans)

Solution (Python):

N = int(input())
a = []

a.append([0,0,0])
for i in range(N):
    a.append([int(x) for x in input().split()])




def hantei(l1, l2): 
    if( (abs(l2[1] - l1[1]) + abs(l2[2] - l1[2]))  <= (l2[0] - l1[0])  ): 
        
        
        return 'OK'
    else:
        return 'NG'

def evenoddhantei(l): 
    if(l[0] % 2 == (l[1]+l[2]) % 2):
        return 'OK'
    else:
        return 'NG'







answer = 'Yes'
for i in range(N):
    if(  hantei(a[i], a[i+1]) == 'NG'  ):
        answer = 'No'

for i in range(N+1):
    if(evenoddhantei(a[i]) == 'NG'):
        answer = 'No'

print(answer)

Solution (Python):

n=int(input())
flag=True
lists=[(0,0,0)]
for i in range(n):
    a=list(map(int,input().split()))
    lists.append(tuple(a))
for i in range(1,n+1):
    x,y,z=lists[i-1][0],lists[i-1][1],lists[i-1][2]
    a,b,c=lists[i][0],lists[i][1],lists[i][2]
    if abs(b-y)+abs(c-z)<=abs(a-x) and (abs(b-y)+abs(c-z))%2==abs(a-x)%2:
        pass
    else:
        flag=False
        break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):

import numpy as np

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

ans = 'Yes'
for i in range(1,N+1):
    x_delta = abs(it[i,1] - it[i-1, 1])
    y_delta = abs(it[i,2] - it[i-1, 2])
    t_delta = it[i,0] - it[i-1,0]
    if t_delta - x_delta - y_delta >= 0:
      if (t_delta - x_delta - y_delta )%2 != 0:
        ans = 'No'
        break
    else:
      ans = 'No'
      break

print(ans)

Solution (Python):
n = int(input())
a = [list(map(int,input().split())) for i in range(n)]
a.insert(0,[0,0,0])
ans = True
for i in range(1,n+1):
  t = a[i][0]-a[i-1][0]
  xy = a[i][1]+a[i][2]-a[i-1][1]-a[i-1][2]
  if not (t >= xy and t%2 == xy%2):
    ans = False
    break
print("Yes" if ans else "No")

Solution (Python):
n = int(input())
t = 0
x = 0
y = 0
for i in range(n):
    t_in,x_in,y_in = map(int,input().split())
    diff_t = t_in - t
    diff_x = abs(x_in-x)
    diff_y = abs(y_in-y)
    sum_xy = diff_x + diff_y
    if diff_t < sum_xy:
        print('No')
        exit()
    else:
        if diff_t%2 != sum_xy%2:
            print('No')
            exit()
print('Yes')

Solution (Python):
N = int(input())
a = []
for i in range(N):
  a.append(map(int,input().split()))
pt,px,py=0,0,0
for t,x,y in a:
  dt,dx,dy = t-pt,x-px,y-py
  if dt < abs(dx)+abs(dy):
    print("No")
    exit()
  if dt%2 != (abs(dx)+abs(dy))%2:
    print("No")
    exit()
  pt,px,py = t,x,y
print("Yes")

Solution (Python):
n = int(input())
t_,x_,y_ = 0,0,0

def trip(t,x,y):
  l = abs(x)+abs(y)
  if t-l >= 0 and (t-l)%2 == 0:
    return 1
  else:
    return 0
  
e = 0
for _ in range(n):
  t,x,y = map(int,input().split())
  t_ = t - t_
  x_ = x - x_
  y_ = y - y_
  if trip(t_,x_,y_) == 1:
    continue
  else:
    e = 1
    print('No')
    break
if e == 0:
  print('Yes')

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

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

Solution (Python):
N = int(input())
D = [input().split() for i in range(N)]

DD = []

for i in range(N):
    DD.append([int(D[i][0]),int(D[i][1]),int(D[i][2])])

diff = [[0,0,0],[DD[0][0]-0,DD[0][1]-0,DD[0][2]-0]]

for i in range(N-1):
    diff.append([DD[i+1][0]-DD[i][0],DD[i+1][1]-DD[i][1],DD[i+1][2]-DD[i][2]])

def judge(t, x, y):
    if t < (abs(x) + abs(y)):
        return 1
    else:
        if (t % 2) == ((abs(x) + abs(y)) % 2):
            return 0
        else:
            return 1

count = 0
for i in range(N+1):
    count += judge(diff[i][0], diff[i][1], diff[i][2])

if count >= 1:
    print("No")
else:
    print("Yes")

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

for _ in range(n):
    nt, nx, ny = map(int, input().split())

    dt = nt - t
    dx = nx - x
    dy = ny - y

    distance = abs(dx) + abs(dy)
    if distance > dt:
        print('No')
        exit()
    
    left_over = nt - distance
    if left_over % 2 != 0:
        print('No')
        exit()

print('Yes')

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

if n==1:
    d=l[0][1]+l[0][2]
    tt=l[0][0]
    if tt%2==1:
        if d<=tt and d%2==1:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
    elif tt%2==0:
        if d<=tt and d%2==0:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

for i in range(n-1):
    d=abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])
    tt=l[i+1][0]-l[i][0]
    if tt%2==1:
        if d<=tt and d%2==1:
            continue
        else:
            print('No')
            exit()
    elif tt%2==0:
        if d<=tt and d%2==0:
            continue
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines






def main():
	n=int(input())
	li=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]
	
	ans="Yes"
	
	li2=[]
	for i in range(n):
		li2.append([li[i+1][0]-li[i][0],abs(li[i+1][1]-li[i][1])+abs(li[i+1][2]-li[i][2])])
	
	for t,k in li2:
		if t%2!=k%2 or t<k:
			ans="No"
	
	print(ans)
	
	
if __name__ == "__main__":
	main()

Solution (Python):
import sys
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
txy = sorted(txy)
t, x, y = 0, 0, 0
for i in range(n):
    T, X, Y = txy[i]
    delta_t = T-t
    delta_xy = abs(X-x)+abs(Y-y)
    if delta_xy <= delta_t and delta_t%2 == delta_xy%2:
        t, x, y = T, X, Y
    else:
        print("No")
        sys.exit()
print("Yes")

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

M = []
for _ in range(N):
  t, x, y = map(int, input().split())
  M.append([t, x, y])

current = [0, 0, 0]
can = True
for m in M:
  dt = m[0] - current[0]
  dist = abs(m[1] - current[1]) + abs(m[2] - current[2])
  if (dist > dt):
    can = False
    break
  else:
    if (dist % 2 != dt % 2):
      can = False
      break
  current = m

result = "Yes" if (can == True) else "No"
print(result)

Solution (Python):
n = int(input())
prev_dst = prev_t = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    dst = x + y
    ddst = abs(dst - prev_dst)
    dt = t - prev_t
    if t % 2 != dst % 2 or ddst > dt:
        print('No')
        exit()
    prev_t, prev_dst = t, dst
print('Yes')

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

Solution (Python):
import sys
n = int(input())
pret = 0
prex = 0
prey = 0
for i in range(n):
    t,x,y = map(int,input().split())
    tmp = t - pret - abs(x - prex) - abs(y - prey)
    
    if tmp >= 0 and tmp % 2 == 0:
        pret = t
        prex = x
        prey = y
    else:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
N=int(input())
count=0
for i in range(N):
	T,X,Y=map(int,input().split())
	if T%2==(X+Y)%2 and T>=(X+Y):
		count+=1
if count==N:
	print("Yes")
else:
	print("No")

Solution (Python):
def main():
    N = int(input())
    posi = [0, 0]
    time = 0
    txy = [[int(i) for i in input().split()] for _ in range(N)]
    for t, x, y in txy:
        move = abs(posi[0] - x) + abs(posi[1] - y)
        if (t - time) < move or (t - time) % 2 != move % 2:
            return print("No")
        time = t
        posi = [x, y]
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
pret = 0
prex = 0
prey = 0
flag = True
for i in range(n):
    t,x,y = map(int,input().split())
    if flag:
        tmp = t - pret - abs(x - prex) - abs(y - prey)
        
        if tmp >= 0 and tmp % 2 == 0:
            pret = t
            prex = x
            prey = y
        else:
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

def solve():
    N = int(input())
    cx, cy = 0, 0
    nt = 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        rem = t - nt - abs(x - cx) - abs(y - cy)
        if rem < 0 or rem % 2 > 0:
            print("No")
            break
        cx, cy = x, y
        nt = t
    else: print("Yes")
        
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
N=int(input())
T,X,Y=0,0,0
ans=True
for i in range(N):
  t,x,y=map(int,input().split())
  dt,dx,dy=t-T,abs(X-x),abs(Y-y)
  if dt<dx+dy:
    ans=False
    
  if dt%2!=(dx+dy)%2:
    ans=False
    
  T,X,Y=t,x,y
print('Yes' if ans else 'No')

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

Solution (Python):
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
tnow, xnow, ynow = 0, 0, 0
for _ in range(n):
    t, x, y = na()
    l = abs(xnow - x) + abs(ynow - y)
    if (t - tnow) < l or (t - tnow) % 2 != l % 2:
        print("No")
        quit()
print("Yes")

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

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

for i in range(n):
    a,b,c=map(int,input().split())
    t.append(a)
    x.append(b)
    y.append(c)

current=[0,0]
for i in range(n):
    next=[x[i]-current[0],y[i]-current[1]]
    if abs(sum(next))>t[i] or (abs(sum(next))+t[i])%2!=0:
        print('No')
        exit()
print('Yes')

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

for i in range(n):
    if i==0:
        if a[i][0]%2!=(a[i][1]+a[i][2])%2:
            my_bool=False
            break
        else:
            if (a[i][1]+a[i][2])>a[i][0]:
                my_bool=False
                break
            
    else:
        if (a[i][0]-a[i-1][0])%2!=((a[i][1]+a[i][2])-(a[i-1][1]+a[i-1][2]))%2:
            my_bool=False
            break
        else:
            if (a[i][0]-a[i-1][0])<((a[i][1]+a[i][2])-(a[i-1][1]+a[i-1][2])):
                my_bool=False
                break
if my_bool:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
prev_dst = 0
prev_time = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    if t % 2 == 0 and (x + y) % 2 != 0:
        print('No')
        exit()
    if t % 2 == 1 and (x + y) % 2 != 1:
        print('No')
        exit()
    if (t - prev_time) < abs(x + y - prev_dst):
        print('No')
        exit()
    prev_time = t
    prev_dst = x + y
print('Yes')

Solution (Python):
n = int(input())
t_ = 0
x_ = 0
y_ = 0
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(x-x_)+abs(y-y_) > t-t_:
        print('No')
        exit()
    else:
        r = (t-t_) - abs(x-x_)-abs(y-y_)
        if r%2 == 0:
            t_ = t
            x_ = x
            y_ = y
        else:
            print('No')
            exit()
else:
    print('Yes')

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    plan = list()
    for i in range(n):
        plan.append(list(map(int, input().split())))

    pos = [0, 0]
    time = 0
    for i in range(n):
        delta_t = plan[i][0] - time
        delta_x = plan[i][1] - pos[0]
        delta_y = plan[i][2] - pos[1]
        if delta_t < delta_x + delta_y:
            print('No')
            exit()
        elif (delta_t - delta_x - delta_y) % 2 == 1:
            print('No')
            exit()
        pos[0] = plan[i][1]
        pos[1] = plan[i][2]
        time = plan[i][0]

    print('Yes')

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

flag = True
for i in range(N):
    if i == 0:
        dist = TXY[i][1] + TXY[i][2]
        if TXY[i][0] >= dist and (TXY[i][0] - dist) % 2 == 0:
            continue
        flag = False
        break
    dist = abs(TXY[i][1]-TXY[i-1][1]) + abs(TXY[i][2]-TXY[i-1][2])
    if TXY[i][0] >= TXY[i-1][0]+dist and (TXY[i][0]-TXY[i-1][0]-dist) % 2 == 0:
        continue
    flag = False
    break

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

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

tx, ty, now = 0, 0, 0
cant = 0
for i in range(n):
        t, x, y = map(int, input().split())
        a, b = t-now, abs(x-tx) + abs(y-ty)
        if not(a>=b and a%2==b%2): cant = 1
        tx, ty, now = x, y, t
print("YNeos"[cant::2])

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

ct = cx = cy = 0
for t,x,y in TXY:
    dt = t-ct
    d = abs(cx-x)+abs(cy-y)
    if dt < d or dt%2 != d%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y
print('Yes')

Solution (Python):
N, = map(int, input().split())
tt, aa, bb = 0, 0, 0
for i in range(N):
    t, a, b = map(int, input().split())
    if abs(a-aa) + abs(b-bb) > t - tt or (abs(a-aa) + abs(b-bb) + t - tt) % 2 != 0:
        print("No")
        break
    tt, aa, bb = t, a, b
else:
    print("Yes")

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

ans = "Yes"
a = 0
b = 0
T = 0
for _ in range(N):
    t,x,y = map(int, input().split())
    if abs(a-x)+abs(b-y) <= t-T and (abs(a-x)+abs(b-y))%2 == (t-T)%2:
        a = x
        b = y
        T = t
    else:
        ans = "No"

print(ans)

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

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

N = int(input())
t, x, y = 0, 0, 0

for _ in range(N):
    nt, nx, ny = map(int, input().split())
    d = abs(nx-x)+abs(ny-y)
    
    if nt-t<d or d%2!=(nt-t)%2:
        print('No')
        exit()
    
    t, x, y = nt, nx, ny

print('Yes')

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

now=0
nowx=0
nowy=0
for txy in l:
    t = txy[0] - now
    x = abs(txy[1] - nowx)
    y = abs(txy[2] - nowy)

    if t<x+y or (t-x-y) % 2 != 0:
        print("No")
        exit()

    now  = txy[0]
    nowx = txy[1]
    nowy = txy[2]
print("Yes")

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

flag=1
point=[0,0,0]   
cur=[0,0,0]
for i in range(N):
    
    needtime=schedule[i][0]-point[0]
    basetime=abs(point[1]-schedule[i][1])+abs(point[2]-schedule[i][2])
    if (needtime>=basetime)and(needtime%2==basetime%2):
        point=schedule[i]
    else:
        flag=0
        break
if flag==1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
s = [[0,0,0]]
for i in range(N):
    s.append(list(map(int,list(input().split()))))
err = 0
for i in range(N):
    dt = s[i+1][0] - s[i][0]
    dist = abs(s[i+1][1] - s[i][1]) + abs(s[i+1][2] - s[i][2])
    if(dt < dist):
        err = 1
    if(dist % 2 != dt % 2):
        err = 1

if(err == 0):
    print("Yes")
else:
    print("No")

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

t = [0]
x = [0]
y = [0]
for i in range(N):
    t_, x_, y_ = map(int, input().split())
    t.append(t_)
    x.append(x_)
    y.append(y_)

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=x=y=0
ans = 'Yes'
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    dis = abs(nx - x) + abs(ny - y)
    time = nt - t
    if dis <= time and dis%2 == time%2:
        t = nt
        x, y = nx, ny
        continue
    else:
        ans = 'No'
print(ans)

Solution (Python):
N = int(input())
T,X,Y = 0,0,0

ans = "Yes"
for _ in range(N):
    t,x,y = map(int,input().split())
    t_need = abs(x - X) + abs(y - Y)
    if t - T < t_need:
        ans = "No"
        break
    if t - T > t_need:
        if ((t - T) - t_need) % 2 == 1:
            ans = "No"
            break
    T,X,Y = t,x,y

print(ans)

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())
last_x = 0
last_y = 0

def load(t,x,y,last_x,last_y):
    dif = abs(last_x - x) + abs(last_y - y)
    if (dif <= t) and (dif % 2 == t % 2):
        return 'Yes'
    else:
        return 'No'
ans = 'Yes'
for i in range(n):
    if i == 0:
        test = load(t[i],x[i],y[i],last_x,last_y)
    else:
        test = load(t[i] - t[i - 1], x[i], y[i], last_x, last_y)
    if test == 'No':
        ans = 'No'
        break
    else:
        last_x = x[i]
        last_y = y[i]
print(ans)

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

txy.insert(0, [0,0,0])
for i in range(n-1):
    
    t_now = txy[i][0]
    x_now = txy[i][1]
    y_now = txy[i][2]
    
    t = txy[i+1][0]
    x = txy[i+1][1]
    y = txy[i+1][2]
    if (t - t_now) % 2 == (x - x_now + y - y_now) % 2 and (t - t_now) >= abs(x - x_now) + abs(y - y_now):
        continue
    else:
        print('No')
        exit()
print('Yes')

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

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

pre_x = 0
pre_y = 0
pre_t = 0
flag = True

for i in range(N):
    t, x, y = [int(i) for i in input().split()]  
    dist_diff = abs(x-pre_x) + abs(y-pre_y)
    time_diff = abs(t - pre_t)
    dist_odd_even = dist_diff % 2
    time_odd_even = time_diff % 2
    if dist_diff <= time_diff and dist_odd_even == time_odd_even:
        pre_x = x
        pre_y = y
        pre_t = t
    else :
        flag = False
        break
            
if flag :
    print('Yes')
else :
    print('No')

Solution (Python):
N = int(input())
Time = 0
t = [0]
xy = [[0, 0]]
judge = 'Yes'

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

for i in range(N):
    diff_xy = abs(xy[i + 1][0] - xy[i][0]) + abs(xy[i + 1][1] - xy[i][1])
    diff_t = t[i + 1] - t[i]
    
    if (diff_t < diff_xy or (diff_t - diff_xy) % 2 != 0):
        judge = 'No'
    
print(judge)

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

for j in range(n):
    if (x[j+1] + y[j+1] - x[j] - y[j])%2 == 1:
        if (t[j + 1] - t[j])%2 == 1 and (x[j+1] + y[j+1] - x[j] - y[j]) <= (t[j + 1] - t[j]):
            ans+=0
        else:
            ans+=1
    else:
        if (t[j + 1] - t[j])%2 == 0 and (x[j+1] + y[j+1] - x[j] - y[j]) <= (t[j + 1] - t[j]):
            ans+=0
        else:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

Solution (Python):


def main():
    n = int(input())
    for _ in range(n):
        t, x, y = map(int, input().split())
        if t < x + y:
            print('No')
            return
        if (x+y-t)%2 != 0:
            print('No')
            return
    print('Yes')
main()

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
before=[0,0,0]
for i in range(n):
    after=list(map(int,input().split()))
    dt=after[0]-before[0]
    dx=abs(after[1]-before[1])
    dy=abs(after[2]-before[2])
    if dt<dx+dy or (dt-dx-dy)%2==1:
        print('No')
        exit()  
    before=after
print('Yes')

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

if (t[0]-x[0]-y[0])%2==1 or t[0]-x[0]-y[0]<0:
  print("No")
  exit()
 
for i in range(n-1):
  k=t[i+1]-t[i]
  dx=abs(x[i+1]-x[i])
  dy=abs(y[i+1]-y[i])
  if (k-(dx+dy))%2==1 or k-(dx+dy)<0:
    print("No")
    exit()

print("Yes")

Solution (Python):



def main():
    
    t, x, y = 0, 0, 0
    N = int(input())

    flag = True

    for i in range(N):
        n_t, n_x, n_y = map(int, input().split())
        diff_d = abs(n_x - x) + abs(n_y - y)
        diff_t = abs(n_t - t)
        

        
        if diff_d > diff_t:
            flag = False

        
        elif (diff_t - diff_d) % 2 == 1:
            flag = False
        else:
            t,x,y = n_t,n_x,n_y

    if flag == True:
        print('Yes')
    else:
        print('No')
main()

Solution (Python):
n = int(input())
t, x, y = [0], [0], [0]
for i in range(n):
    te, xe, ye = [int(e) for e in input().split()]
    t.append(te)
    x.append(xe)
    y.append(ye)

for i in range(1, n + 1):
    dt = t[i] - t[i-1]
    dx = abs(x[i] - x[i-1])
    dy = abs(y[i] - y[i-1])
    if dt < (dx + dy) or dt % 2 != (dx + dy) % 2:
        print('No')
        exit()

print('Yes')

Solution (Python):
def resolve():
    n = int(input())
    t_b, x_b, y_b = 0, 0, 0
    count = 0
    for i in range(1, n+1):
        t, x, y = map(int, input().split())
        dist = abs(x-x_b) + abs(y-y_b)
        dt = abs(t-t_b)
        if dist <= dt and dist % 2 == dt % 2:
            t_b, x_b, y_b = t, x, y
            count += 1
    print("Yes" if count == n else "No")

if __name__ == '__main__':
    resolve()

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


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

flg = 1
for i in range(1,N+1):
    dist = abs(A[i][1]-A[i-1][1])+abs(A[i][2]-A[i-1][2])
    time = A[i][0]-A[i-1][0]
    if time < dist:
        flg = 0
    else:
        if dist%2 != time%2:
            flg = 0

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

Solution (Python):
N = int(input())
yes = True
for _ in range(N):
  t, x, y = map(int, input().split())
  margin = t - (x + y)
  if margin < 0 or margin % 2 != 0:
    yes = False
if yes:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np

N = int(input())
t_target = [0] * N
x_target = [0] * N
y_target = [0] * N
for i in range(N):
    t_target[i], x_target[i], y_target[i] = map(int, input().split())

t = 0
x_t = 0
y_t = 0
for i in range(N):
    time_surplus = (t_target[i] - t) - (np.abs(x_target[i] - x_t) + np.abs(y_target[i] - y_t))
    if time_surplus >= 0 and time_surplus % 2 == 0:
        t = t_target[i]
        x_t = x_target[i]
        y_t = y_target[i]
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
def boolean(a,b):
    D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
    if(D >= 0 and D %2 == 0):
        return 0
    else:
        return 1

N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
    a=list(map(int,input().split()))
    txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
    if(boolean(txy[i-1],txy[i])):
        ans = "No"
        break
print(ans)

Solution (Python):
def check(a,b):
    distance = abs(a[1]-b[1]) + abs(a[2]-b[2])
    time = abs(b[0]-a[0])
    
    c = time - distance
    if((c >= 0) and (c%2==0)):
        return 0
    else:
        return 1
    

def main():
    n = int(input())
    plan = [list(map(int, input().split())) for i in range(n)]
    if(check([0,0,0],plan[0])==1):
        print("No")
        return
    
    flag = 0
    for i in range(n-1):
        flag += check(plan[i],plan[i+1])
        if (flag >0):
            break
    
    if (flag == 0):
        print("Yes")
    else:
        print("No")
main()

Solution (Python):
def main():
    N = int(input())
    steps = [list(map(int, input().split())) for _ in range(N)]
    steps.insert(0, [0, 0, 0])
    ans = "Yes"
    for i in range(1, N+1):
        t_diff = steps[i][0] - steps[i-1][0]
        x_diff = abs(steps[i][1] - steps[i-1][1])
        y_diff = abs(steps[i][2] - steps[i-1][2])
        if x_diff + y_diff > t_diff or (t_diff - x_diff - y_diff) % 2 != 0:
            ans = "No"
            break
    print(ans)

if __name__ == '__main__':
    main()

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

ans = "Yes"
for i in range(N):
    if i == 0:
        last = [0, 0, 0]
    else:
        last = txy[i-1]

    t = txy[i][0] - last[0]
    x = abs(txy[i][1] - last[1])
    y = abs(txy[i][2] - last[2])

    if x+y > t or not t%2 == (x+y)%2:
        ans = "No"
        break

print(ans)

Solution (Python):
define = [1]
def dekiru(numbers):
  t, x, y = map(int, numbers.split())
  time_x = t - x
  time_y = time_x - y
  if time_y%2 == 0 and time_y >=0:
    define.append(1)
  else:
    define.append(-1)
N = int(input())
count = 0
while count < N:
  dekiru(input())
  count += 1

if define.count(1) == N+1:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
T, X, Y = [0], [0], [0]
for i in range(n):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(n):
    d = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
    e = T[i + 1] - T[i]
    if d > e or (d + e) % 2 == 1:
        print('No')
        break
else:
    print('Yes')