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())

ts,xs,ys = 0,0,0

for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x-xs) + abs(y-ys) > t-ts:
        print("No")
        break
    else:
        if (x-xs + y-ys - t-ts) % 2 != 0:
            print("No")
            break
        else:
            ts,xs,ys = t,x,y
    
if ts == t:
    print("Yes")

Solution (Python):
import sys

hoge = int(input())
cite = [list(map(int, input().split())) for i in range(hoge)]
cite.insert(0, [0, 0, 0])

for j in range(1, hoge+1):
    x_dif = abs(cite[j][1]-cite[j-1][1])
    y_dif = abs(cite[j][2]-cite[j-1][2])
    t_dif = cite[j][0] - cite[j-1][0]
    
    if x_dif + y_dif > t_dif or (x_dif + y_dif) % 2 != t_dif % 2:
        print("No")
        sys.exit()

print('Yes')

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

def main():
    n = int(input())
    t = [[0,0,0]]
    for _ in range(n):
        t.append(list(map(int,input().split())))
    for i in range(n):
        time = t[i+1][0] - t[i][0]
        distance = abs(t[i+1][1] - t[i][1]) + abs(t[i+1][2] - t[i][2])
        if time < distance or (time-distance) % 2 == 1:
            print('No')
            return
    print('Yes')

if __name__ == '__main__':
    main()

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

Solution (Python):
N=int(input())
t_list=[0]
x_list=[0]
y_list=[0]
ans="Yes"
for i in range(N):
    t,x,y=map(int,input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)
for i in range(N):
    T=t_list[i+1]-t_list[i]
    X=x_list[i+1]-x_list[i]
    Y=y_list[i+1]-y_list[i]
    X=abs(X)
    Y=abs(Y)
    if T<X+Y or T%2!=(X+Y)%2:
        ans="No"
print(ans)

Solution (Python):
N = int(input())
currentTime = 0
current = [0, 0]
for i in range(N):
    timeStamp = list(map(int, input().split()))
    reqLen = abs(timeStamp[1] - current[0]) + abs(timeStamp[2] - current[1])
    timeLen = timeStamp[0] - currentTime
    if reqLen > timeLen:
        print("No")
        exit()
    if reqLen % 2 != timeLen % 2:
        print("No")
        exit()
    currentTime = timeStamp[0]
    current = timeStamp[1:]
print("Yes")

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

ct, cx, cy = (0, 0, 0)

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

    d = abs(cx - x) + abs(cy - y)
    dt = t - ct

    if d > dt or (d - dt) % 2 == 1:
        ok = False
    ct, cx, cy = t, x, y

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

Solution (Python):
N=int(input())
pre_t,pre_x,pre_y=0,0,0
reachable=True
for _ in range(N):
  t,x,y=map(int,input().split())
  dist=abs(x-pre_x)+abs(y-pre_y)
  time=t-pre_t
  if dist<=time:
    if dist%2==time%2:
      pre_t,pre_x,pre_y=t,x,y
    else:
      reachable=False
      break
  else:
    reachable=False
    break
  pass
if reachable:print('Yes')
else: print('No')

Solution (Python):
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
can = True

for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - prev_t
    dist = abs(x - prev_x) + abs(y - prev_y)
    if dt < dist or dist % 2 != dt % 2:
        can = False
    prev_t = t
    prev_x = x
    prev_y = y

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

Solution (Python):
N = int(input())
plan = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]
f = True
for i in range(N):
    time = plan[i+1][0]-plan[i][0]
    dist = abs(plan[i+1][1]-plan[i][1])+abs(plan[i+1][2]-plan[i][2])
    if dist>time or dist%2 != time%2:
        f = False    
print('Yes' if f else 'No')

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

s = 0
t = 0
d = 0
p = [0, 0]
ans = ''
for e in l:
  if ans == '':
    s = e[0] - t
    t = e[0]
    d = abs(p[0] - e[1]) + abs(p[1] - e[2])
    p = [e[1], e[2]]
    if s < d:
      ans = 'No'
    else:
      if (s - d) % 2 == 1:
        ans = 'No'
      else:
        next
if ans == '':
  ans = 'Yes'
print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

t = txy[0][0]
d = abs(txy[0][1]) + abs(txy[0][2])

if t < d:
    print('No')
    exit()
for i in range(n-1):
    t = txy[i+1][0] - txy[i][0]
    d = abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])
    if t < d:
        print('No')
        exit()
    if t % 2 == 0 and d % 2 != 0:
        print('No')
        exit()
    if t % 2 != 0 and d % 2 == 0:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
st = 0
sx = 0
sy = 0
flg = False
for _ in range(N):
    t,x,y = map(int,input().split())

    if abs((x+y)-(sx+sy)) > (t-st) or (t-st) % 2 != abs((x+y)-(sx+sy)) % 2:
        flg = True
        break
    else:
        st = t
        sx = x
        sy = y
print('No' if flg else 'Yes')

Solution (Python):
n = int(input())
st = 0
sx, sy = 0, 0
ng = False
for _ in range(n):
    t, x, y = map(int, input().split())
    dt = (t - st)
    dx = abs(sx - x)
    dy = abs(sy - y)

    if dt%2 == (dx+dy)%2 and dx+dy <= dt:
        st = t
        sx = x
        sy = y
    else:
        ng = True
        break
print('No' if ng else 'Yes')

Solution (Python):
n = int(input())
t0 = 0
x0 = 0
y0 = 0
flag = True

for _ in range(n):
    t, x, y = map(int, input().split())
    t -= t0
    x -= x0
    y -= y0
    diff = abs(x) + abs(y)
    t0 = t
    x0 = x
    y0 = y
    if diff > t:
        flag = False
        break
    if t % 2:
        if diff % 2:
            pass
        else:
            flag = False
            break
    else:
        if diff % 2:
            flag = False
            break
        else:
            pass
print('Yes') if flag else print('No')

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

ans='Yes'
now=[0,0,0]
for t,x,y in txy:
    distance=abs(x-now[1])+abs(y-now[2])
    if distance>t-now[0] or (distance+(t-now[0]))%2>0:
        ans='No'
        break
    else:
        now=[t,x,y]

print(ans)

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

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

Solution (Python):
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
for i in range(N):
    if i == 0:
        cnt = x[i][0]
        sum = x[i][1] + x[i][2]
    else:
        cnt = x[i][0] - x[i-1][0]
        sum = abs(x[i][1]-x[i-1][1]) + abs(x[i][2]-x[i-1][2])
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
cnt = 0
sum = 0
flag = 0
T = X = Y = 0
for i in range(N):
    cnt = x[i][0] - T
    sum = abs(x[i][1]- X) + abs(x[i][2]- Y)
    T = x[i][0]
    X = x[i][1]
    Y = x[i][2]
    if cnt < sum or cnt % 2 != sum % 2:
        flag = 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
lt = 0
lx = 0
ly = 0
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    dt = abs(lt-t)
    dx = abs(lx-x)
    dy = abs(ly-y)
    if not(dt >= dx + dy and dt % 2 == (dx + dy) % 2):
        print("No")
        exit()
    lt = t
    lx = x
    ly = y
print("Yes")

Solution (Python):
import sys

input = sys.stdin.readline

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] = map(int, input().split())


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

Solution (Python):
n = int(input())
a = [[0, 0, 0]] + [[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    d = a[i + 1][0] - a[i][0]
    x = abs(a[i + 1][1] - a[i][1])
    y = abs(a[i + 1][2] - a[i][2])
    if x + y > d:
        print("No")
        break
    elif (d - (x + y)) % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
n = int(input())
l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    t1, x1, y1 = l[i]
    t2, x2, y2 = l[i + 1]
    if (abs(x1 - x2) + abs(y1 - y2)) % 2 != (t2 - t1) % 2 or t2 - t1 < abs(x1 - x2) + abs(y1 - y2):
        print('No')
        break
else:
    print('Yes')

Solution (Python):
__DEUBG__ = 0

import math

N = int(input())
t_prev = x_prev = y_prev = 0

def get_dist(x_old, y_old, x_new, y_new):
    return abs(x_old - x_new) + abs(y_old - y_new)

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = get_dist(x_prev, y_prev, x, y)
    delta_t = t - t_prev
    if __DEUBG__:
        print()
        print(dist, delta_t)
    if dist > delta_t:
        print('No')
        exit(0)
    elif delta_t %2 != dist % 2:
        print('No')
        exit(0)
    t_prev, x_prev, y_prev = t, x, y
print('Yes')

Solution (Python):
n = int(input())
start = [0, 0]
curtime = 0
flag = True
for i in range(n):
    t, x, y = map(int, input().split())
    dist = abs(x-start[0]) + abs(y-start[1])
    time = t-curtime
    if dist <= time and dist % 2 == time % 2:
        start = [x, y]
        curtime = t
        continue
    print('No')
    flag = False
    break
if flag:
    print('Yes')

Solution (Python):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(readline().rstrip())
pos = (0, 0)
used_time = 0
for _ in range(N):
    t, x, y = map(int, readline().split())
    cost = abs(pos[0] - x) + abs(pos[1] - y)
    available = t - used_time
    
    
    if cost > available or ((cost - available) % 2 != 0):
        print('No')
        quit()
    used_time = t
    pos = (x, y)
print('Yes')

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


t = x = y = 0

flag = 0
for l in coord:
    dt, dx, dy = abs(l[0] - t), abs(l[1] - x), abs(l[2] - y)
    
    if dt < dx + dy:
        flag = 1
        break
    else:
        
        
        if dt % 2 != (dx + dy) % 2:
            flag = 1
            break
        else:
            t, x, y = l[0], l[1], l[2]
            continue

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

Solution (Python):
import sys
import math


def main():
    t = 0
    pos = 0, 0

    N = int(input())
    for i in range(N):
        ti, xi, yi = [int(v) for v in input().split()]

        dx = xi - pos[0]
        dy = yi - pos[1]

        td = ti - t
        dd = abs(dx + dy)

        if dd > td:
            print("No")
            sys.exit()

        if td % 2 != dd % 2:
            print("No")
            sys.exit()

        t = ti
        pos = xi, yi

    print("Yes")


if __name__ == "__main__":
    main()

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


for i in range(1, N):
    L[i] = [L[i][0]-L[i-1][0], L[i][1]-L[i-1][1], L[i][2]-L[i-1][2]]


def judge(t, x, y):
    distance = abs(x) + abs(y)
    global answer
    if distance > t:
        answer = 'No'
        return
    else:
        if t % 2 == distance % 2:
            return
        else:
            answer = 'No'
            return


for l in L:
    judge(l[0], l[1], l[2])
    if answer == 'No':
        break

print(answer)

Solution (Python):
N = int(input())
t = [0 for _ in range(N + 10)]
x = [0 for _ in range(N + 10)]
y = [0 for _ in range(N + 10)]
res = 'Yes'
for i in range(N):
  t[i], x[i], y[i] = map(int, input().split(' '))
for i in range(N):
  if abs(x[i]) + abs(y[i]) <= t[i] and (abs(x[i]) + abs(y[i])) % 2 == t[i] % 2:
    x[i + 1] -= x[i]
    y[i + 1] -= y[i]
    t[i + 1] -= t[i]
  else:
    res = 'No'
    break
print(res)

Solution (Python):
N = int(input())
nowt = 0
nowx = 0
nowy = 0
for i in range(N):
  t, x, y = map(int, input().split())
  ti = t - nowt
  xi = x - nowx
  yi = y - nowy
  if ti < abs(xi) + abs(yi):
    print('No')
    exit()
  if ti%2 != (xi+yi)%2:
    print('No')
    exit()
  nowt = t
  nowx = x
  nowy = y
    
print('Yes')

Solution (Python):
n=int(input())
t0=0
x0=0
y0=0
def num_abs(num):
    return abs(num)
ans=0
for i in range(n):
    t,x,y=map(int,input().split())
    numx=num_abs(x-x0)
    numy=num_abs(y-y0)
    numt=t-t0
    if numx+numy>numt or (numt-(numx+numy))%2==1:
        ans=1
        break
    t0=t
    x0=x
    y0=y
if ans==1:
    print("No")
else:
    print("Yes")

Solution (Python):
def main():
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]
    
    pre_x, pre_y, pre_t = 0, 0, 0
    for t, x, y in txy:
        d = abs(pre_x - x) + abs(pre_y - y)
        if not(t - pre_t >= d and (t - pre_t) % 2 == d % 2):
            print('No')
            break
        pre_x,  pre_y, pre_t = x, y, t
    else:
        print('Yes')
        
        
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n = int(input())
    txy = [list(map(int, input().split())) for _ in range(n)]
    
    pre_x, pre_y, pre_t = 0, 0, 0
    for t, x, y in txy:
        d = abs(pre_x - x) + abs(pre_y - y)
        if t - pre_t >= d and (t - pre_t) % 2 == d % 2:
            pre_x,  pre_y, pre_t = x, y, t
        else:
            print('No')
            break
        pre_x,  pre_y, pre_t = x, y, t
    else:
        print('Yes')
        
        
if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
now = 0
nowx = 0
nowy = 0
for i in range(N):
    t,x,y = map(int,input().split())
    d = (abs(x-nowx)+abs(y-nowy))
    if d > t-now:
        print('No')
        exit()
    if (t-now)%2 == 0:
        if d%2 == 0:
            now = t
            nowx = x
            nowy = y
        else:
            print('No')
            exit()
    else:
        if d%2 == 1:
            now = t
            nowx = x
            nowy = y
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):
N=int(input())
x=0
y=0
t=0
for i in range(N):
    tt,xx,yy=map(int,input().split())
    if abs(xx-x)+abs(yy-y)<=tt-t:
        if (abs(xx-x)+abs(yy-y))%2!=(tt-t)%2:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t,x,y=tt,xx,yy
print("Yes")

Solution (Python):
n=int(input())
nowx, nowy, nowt = 0, 0, 0
for i in range(n):
	t,x,y = map(int,input().split())
	k = t-nowt-abs(nowx-x)-abs(nowy-y)
	if k >= 0 and k % 2 == 0:
		nowx, nowy, nowt = x, y, t
	else:
		print("No")
		exit()
print("Yes")

Solution (Python):
n=int(input())
S = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    if i==0:
        if S[i][1]+S[i][2]>S[i][0]:
            print("No")
            exit()
        else:
            if S[i][0]%2==0:
                if (S[i][1]+S[i][2])%2==1:
                    print("No")
                    exit()
            else:
                if (S[i][1]+S[i][2])%2==0:
                    print("No")
                    exit()
    else:
        if abs(S[i][1]-S[i-1][1])+abs(S[i][2]-S[i-1][2])>S[i][0]-S[i-1][0]:
            print("No")
            exit()
        else:
            if S[i][0]%2==0:
                if (S[i][1]+S[i][2])%2==1:
                    print("No")
                    exit()
            else:
                if (S[i][1]+S[i][2])%2==0:
                    print("No")
                    exit()
print("Yes")

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

placeSequence = list()
for pivot in range(timeNum):
  placeSequence.append(list(map(int, input().split(' '))))

def compatibleCoordinate(time, x, y):
  if time % 2 == (abs(x) +  abs(y)) % 2 and time >= abs(x) + abs(y):
    return True
  else:
    return False

time = x = y = 0

for place in placeSequence:
  objectTime, objectX, objectY = place
  flag = compatibleCoordinate(objectTime-time, objectX-x, objectY-y)
  if flag:
    time = objectTime
    x = objectX
    y = objectY
    continue
  else:
    print('No')
    break

else:
  print('Yes')

Solution (Python):

n = int(input())
travel = [[0, 0, 0]]

for i in range(n):
    array = list(map(int, input().strip().split()))
    travel.append(array)


def func(num, query):
    for j in range(num):
        time_temp = query[j+1][0] - query[j][0]
        x_temp = abs(query[j+1][1] - query[j][1])
        y_temp = abs(query[j+1][2] - query[j][2])

        if not (x_temp + y_temp) % 2 == time_temp % 2:
            print('No')
            return
        if x_temp + y_temp > time_temp:
            print('No')
            return

    print('Yes')


func(num=n, query=travel)

Solution (Python):
n = int(input())
s = [0, 0, 0]
ans = 'Yes'
for i in range(n):
  l = list(map(int, input().split()))
  diff_t = l[0] - s[0]
  diff_x = abs(s[1] - l[1])
  diff_y = abs(s[2] - l[2])
  s = [l[0], l[1], l[2]]
  if diff_x + diff_y > diff_t or (diff_t - diff_x - diff_y) % 2 != 0:
    ans = 'No'
print(ans)

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

tp = xp = yp = 0
for t, x, y in txy:
  ti = t - tp
  d = abs(x - xp) + abs(y - yp)
  tp = t
  xp = x
  yp = y
  if ti < d:
    print('No')
    exit()
  else:
    if ti % 2 != d % 2:
      print('No')
      exit()
    else:
      continue
    
print('Yes')

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


data_list = [(0, 0, 0)]
for _ in range(n):
  temp = list(map(int, input().strip().split()))
  data_list.append((temp[0], temp[1], temp[2]))


for i in range(n):
  time_diff = data_list[i + 1][0] - data_list[i][0]
  x_diff = abs(data_list[i + 1][1] - data_list[i][1])
  y_diff = abs(data_list[i + 1][2] - data_list[i][2])
  
  if ((x_diff + y_diff) % 2) != (time_diff % 2):
    print('No')
    exit()
  if x_diff + y_diff > time_diff:
    print('No')
    exit()

print('Yes')

Solution (Python):
def solve():
    N = int(input())
    t_p = 0
    x_p = 0
    y_p = 0
    for i in range(1, N+1):
        t, x, y = map(int, input().split())
        
        if (t - t_p) < abs(x - x_p) + abs(y - y_p):
            print('No')
            exit()
        
        if (t%2==0 and (x+y)%2==1) or (t%2==1 and (x+y)%2==0):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y
    print('Yes')


if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    N = int(input())
    t_p = 0
    x_p = 0
    y_p = 0
    for i in range(1, N+1):
        t, x, y = map(int, input().split())
        
        if (t%2==0 and (x+y)%2==1) or (t%2==1 and (x+y)%2==0):
            print('No')
            exit()
        
        if (t - t_p) < abs(x - x_p) + abs(y - y_p):
            print('No')
            exit()
        t_p, x_p, y_p = t, x, y
    print('Yes')


if __name__ == '__main__':
    solve()

Solution (Python):
def solve():
    N = int(input())
    t = [0] * (N+1)
    x = [0] * (N+1)
    y = [0] * (N+1)
    t[0] = 0
    x[0] = 0
    y[0] = 0
    for i in range(1, N+1):
        t[i], x[i], y[i] = map(int, input().split())
        
        if (t[i]%2==0 and (x[i]+y[i])%2==1) or (t[i]%2==1 and (x[i]+y[i])%2==0):
            print('No')
            exit()
        
        if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

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

    for i in range(1,N+1):
        
        if (t[i]%2==0 and (x[i]+y[i])%2==1) or (t[i]%2==1 and (x[i]+y[i])%2==0):
            print('No')
            exit()
        
        if (t[i] - t[i-1]) < abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

Solution (Python):
n = int(input())
flag = True
dx, dy, dt = 0, 0, 0

for _ in range(n):
    t, x, y = map(int, input().split())
    dist = abs(dx - x) + abs(dy - y)
    if t - dt < dist or (t - dt - dist) % 2:
        flag = False
    dt, dx, dy = t, x, y

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

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

p = [[ 0 for i in range(3)] for j in range(N+1)]

for i in range(1,N+1):
    p[i][0], p[i][1], p[i][2] = map(int,input().split())

cant = True

if p[1][0] % 2 == (p[1][1] + p[1][2]) % 2 and p[1][0] >= p[1][1] + p[1][2]:
    cant = False

if cant:
    print('No')
    exit()

if N > 1:
    for i in range(1, N+1):
        ts = p[i][0] - p[i-1][0]
        ps = p[i][1] - p[i-1][1] + p[i][2] - p[i-1][2]
        if ts%2 == ps%2 and ts*ts >= ps*ps:
            cant = False
        else:
            print('No')
            exit()

print('Yes')

Solution (Python):
N = int(input())
answer = ""
for i in range(N):
    t, x, y = map(int,input().split())
    if i == 0:
        if t == (abs(x) + abs(y)):
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break
    
    else:
        if (t - pre_t) >= (abs(x - pre_x) + abs(y - pre_y)) and (t - pre_t) % 2 == (abs(x - pre_x) + abs(y - pre_y)) % 2:
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break

print(answer)

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

for num in range(n):
    dif_t = t[num+1] - t[num]
    dif_x = abs(x[num+1] - x[num])
    dif_y = abs(y[num+1] - y[num])
    i = dif_t - (dif_x + dif_y)
    if i%2 == 1 or i <= -1:
        print('No')
        exit()

print('Yes')

Solution (Python):




import sys
from fractions import gcd
import math
from math import ceil,floor
import collections











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



t = 0
x = 0
y = 0

for i in range(0,N):
    mt = abs(list[i][0] - t)
    mx = abs(list[i][1] - x)
    my = abs(list[i][2] - y)
    if (mx + my == mt) or ( (mx+my<mt) & ((mt - mx - my)%2 == 0)):
        t = list[i][0]
        x = list[i][1]
        y = list[i][2]
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
N = int(input())
cs = []
t1, x1, y1 = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  d = abs(x1-x2) + abs(y1-y2)
  if d == 0 or d > (t2 - t1) or d % 2 != (t2 - t1) % 2:
    ans = 'No'
    break
  t1, x1, y1 = t2, x2, y2
print(ans)

Solution (Python):
N=int(input())
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2,x2,y2=map(int,input().split())
  d = abs(x1 - x2) + abs(y1 - y2)
  dt = t2 - t1
  if d > dt:
    print('No')
    exit()
  if dt%2!=0 and d%2==0:
    print('No')
    exit()
  if dt%2==0 and d%2!=0:
    print('No')
    exit()
  t1,x1,y1=t2,x2,y2
print('Yes')

Solution (Python):
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = [0]
x = [0]
y = [0]
for _ in range(n):
    tmp = LI()
    t.append(tmp.pop(0))
    x.append(tmp.pop(0))
    y.append(tmp.pop(0))

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

print('Yes')

Solution (Python):
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LI(): return list(map(int,stdin.readline().rstrip().split()))

n = I()
t = [0]
x = [0]
y = [0]
for _ in range(n):
    tmp = LI()
    t.append(tmp.pop(0))
    x.append(tmp.pop(0))
    y.append(tmp.pop(0))

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

print('Yes')

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__  == "__main__":
    n = int(input())
    nowX = 0
    nowY = 0
    nowT = 0
    for i in range(n):
        t,x,y = map(int,input().split())
        dt = t - nowT
        dx = abs(x - nowX)
        dy = abs(y - nowY)
        if dt%2 == 1:
            if (dx + dy)%2 == 1 and (dx + dy)<=dt:
                flag = 1
            else:
                print("No")
                sys.exit()
        else:
            if (dx + dy)%2 == 0 and (dx + dy)<=dt:
                flag = 1
            else:
                print("No")
                sys.exit()
        nowT = t
        nowX = x
        nowY = y
    print("Yes")

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

tmp = [0, 0, 0]
for t, x, y in txy:
    tmp1 = t - tmp[0]
    tmp2 = abs(x - tmp[1]) + abs(y - tmp[2])
    if tmp1 >= tmp2 and (tmp1 + tmp2) % 2 == 0:
        tmp = [t, x, y]
    else:
        print("No")
        exit()
print("Yes")

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

t = []
cordinate = []


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


time = 0
x,y = 0,0


for i in range(len(t)):
    
    
    time = abs(time - t[i])
    
    
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    

    
    
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()

    x,y = objx,objy
    time = t[i]

print("Yes")

Solution (Python):
import sys 
N = int(input())
 
t = []
cordinate = []
 

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

time = 0
x,y = 0,0
 
 
for i in range(len(t)):
    
    
    time = abs(time - t[i])
    
    
    objx = cordinate[i][0]
    objy = cordinate[i][1]
    
 
    
    
    if time < abs((objx - x) + (objy - y)):
        print("No")
        sys.exit()
    
    
    if (abs((objx - x) + (objy - y)))%2 != time % 2:
        print("No")
        sys.exit()
 
    x,y = objx,objy
    time = t[i]
 
print("Yes")

Solution (Python):
N, *T = map(int, open(0).read().split())
d_t, d_x, d_y = 0, 0, 0
for t, x, y in zip(T[::3], T[1::3], T[2::3]):
    dist = abs(d_x - x) + abs(d_y - y)
    if t - d_t - dist < 0 or (t - d_t - dist) % 2:
        print("No")
        break
    d_t, d_x, d_y = t, x, y
else:
    print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    lis = []
    lis.append((0, 0, 0))
    for _ in range(N):
        t, x, y = map(int, input().split())
        lis.append((t, x, y))
    ans = "Yes"
    for i in range(1, N+1):
        t_diff = lis[i][0] - lis[i-1][0]
        d_diff = abs(lis[i][1] - lis[i-1][1]) + abs(lis[i][2] - lis[i-1][2])
        if t_diff % 2 != d_diff % 2 or t_diff < d_diff:
            ans = "No"
            break
    print(ans)
if __name__ == "__main__":
    main()

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

ans="Yes"
for i in range(N):
  t_now=tra[i][0]
  x_now=tra[i][1]
  y_now=tra[i][2]
  
  t_next=tra[i+1][0]
  x_next=tra[i+1][1]
  y_next=tra[i+1][2]
  
  mind=abs(x_now-x_next)+abs(y_now-y_next)
  tdis=t_next-t_now
  
  
  if mind>tdis or (mind+tdis)%2==1:
    ans="No"
    break

print(ans)

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

start = (0, 0, 0)
goal = True

for r in route:
    t = r[0] - start[0]
    d = abs(r[1]-start[1]) + abs(r[2]-start[2])
    if d % 2 == t % 2 and t >= d: 
        pass
    else:
        goal = False
        break
    start = r

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

Solution (Python):
N=int(input())
listA=[[0,0,0]] 
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;        
        
def main():
  for i in range(N): 
    
    
    Manhattan_distance=abs(listA[i+1][1]-listA[i][1])+abs(listA[i+1][2]-listA[i][2])
    
    
    if listA[i+1][0]%2!=(listA[i+1][1]+listA[i+1][2])%2:
      return "No"
    
    
    
    if (listA[i+1][0]-listA[i][0])%2!=Manhattan_distance%2: 
      return "No"
    
    
    if (listA[i+1][0]-listA[i][0])<Manhattan_distance:
      return "No"
  
  return "Yes"


print(main())

Solution (Python):
N=int(input())
listA=[[0,0,0]] 
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;        
        
def main():
  for i in range(N):
    Manhattan_distance=abs(listA[i+1][1]-listA[i][1])+abs(listA[i+1][2]-listA[i][2])
    
    
    
    
    if listA[i+1][0]%2!=(listA[i+1][1]+listA[i+1][2])%2:
      
      
      return "No"
    
    if (listA[i+1][0]-listA[i][0])%2!=Manhattan_distance%2: 
      
      
      return "No"
    
    
    if (listA[i+1][0]-listA[i][0])<Manhattan_distance:
      return "No"
  
  return "Yes"



print(main())