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())
routes = []
for _ in range(n):
	time,x,y = map(int,input().split())
	routes.append((time,x,y))

now_x = 0
now_y = 0
time_now = 0
res = "Yes"
for time,x,y in routes :
	dist = abs(now_x - x) + (abs(now_y - y))
	t = time - time_now
	if t-dist < 0 or (t-dist)%2 != 0:
		res = "No"
		break
	now_x = x
	now_y = y
	time_now = time
print(res)

Solution (Python):
N=int(input())
t,x,y=0,0,0
f=True
for i in range(N):
    ti,xi,yi=map(int,input().split())
    if ti-t<abs(xi-x)+abs(yi-y) or (ti-t)%2!=((xi-x)+(yi-y))%2:
        f=False
        break
    else:
        t,x,y=ti,xi,yi
print('Yes' if f else 'No')

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

Solution (Python):
def odd_even_same(p):
  t,x,y=p[0],p[1],p[2]
  if (x+y)%2==t%2:
    return 1
  else:
    return 0
def dist_judge(p):
  t,x,y=p[0],p[1],p[2]
  if t >= x+y:
    return 1
  else:
    return 0
N=int(input())
p=[]
for i in range(N):
  p.append(list(map(int,input().split())))
for i in p:
  if odd_even_same(i)*dist_judge(i):
    pass
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):

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

flag = 'Yes'
elapsed = 0
now = (0, 0)
for p in plan:
    t, x, y = p[0], p[1], p[2]
    nx, ny = now[0], now[1]

    time = t - elapsed
    distance = abs(x - nx) + abs(y - ny)
    buff = time - distance
    if (buff>=0) and (buff%2 == 0):
        elapsed = t
        now = (x, y)
    else:
        flag = 'No'
        break
print(flag)

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
 
print(ans)

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break

print(ans)

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacements = (xi - x) + (yi - y)
  dist = abs(displacements)
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
  
  if ans == "No":
    break
 
print(ans)

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0 
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  dist = abs((xi - x) + (yi - y))
  dt = ti - t
  if dt >= dist and (dt - dist) % 2 == 0:
    t, x, y = ti, xi, yi  
  else:
    ans = "No"
    break
 
print(ans)

Solution (Python):
n = int(input())
t0, x0, y0 = 0, 0, 0
t, x, y = t0, x0, y0 
ans = "Yes"
for i in range(1, n+1):
  ti, xi, yi = map(int, input().split())
  displacement = (xi - x) + (yi - y)
  distance = abs(displacement)
  dt = ti - t
  
  
  if dt >= distance and (dt - distance) % 2 == 0:
    t, x, y = ti, xi, yi
  else:
    ans = "No"
    break
 
print(ans)

Solution (Python):
import sys
n = int(input())
T, X, Y = [], [], []

for i in range(n):
    v1, v2, v3 = map(int, input().split())
    T.append(v1)
    X.append(v2)
    Y.append(v3)

for i in range(n):
    t = T[i]
    x = X[i]
    y = Y[i]

    if x + y > t:
        print('No')
        sys.exit()
    if t % 2 != (x + y) % 2:
        print('No')
        sys.exit()

print('Yes')

Solution (Python):
def checkGo(x,y,t):
    if abs(x) + abs(y) > t or (t - (abs(x) + abs(y)) ) % 2 == 1:
        return False
    return True
count = int(input())
data = []
for i in range(count):
    data.append(list(map(int,input().split())))
passTime = 0
beforeX = 0
beforeY = 0
for i in data:
    time = i[0]
    x = i[1]
    y = i[2]
    if not checkGo(x - beforeX, y - beforeY, time - passTime):
        print("No")
        exit()
    passTime = i[0]
    beforeX = i[1]
    beforeY = i[2]
print("Yes")

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

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

Solution (Python):
def test():
    n = int(input())
    t = [0]*(n+1)
    x = [0]*(n+1)
    y = [0]*(n+1)
    ans = True
    for i in range(n):
        a = list(map(int,input().split()))
        t[i+1] = a[0]
        x[i+1] = a[1]
        y[i+1] = a[2]
    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 or dist%2 != dt%2:
            ans = False
    print("Yes" if ans else "No")


if __name__ == "__main__":
    test()

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())
t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)

flag = True
for i in range(N):
    if (t[i+1]-t[i])%2 != (x[i+1]-x[i]+y[i+1]-y[i])%2:
        flag = False
        break
    elif t[i+1]-t[i] < x[i+1]-x[i]+y[i+1]-y[i]:
        flag = False
        break

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    t.insert(0,0)
    x.insert(0,0)
    y.insert(0,0)
    for i in range(1,N+1):
        if t[i]%2 != (x[i]+y[i])%2:
            print("No")
            return 
        if t[i]<abs(x[i]-x[i-1])+abs(y[i]-y[i-1]):
            print("No")
            return 
    print("Yes")
    

    return



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

if __name__ == '__main__':
    main()

Solution (Python):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n = int(input())

    t_before, x_before, y_before = 0, 0, 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        diff_t = t - t_before
        diff_d = abs(x - x_before) + abs(y - y_before)
        if diff_t >= diff_d and (diff_t - diff_d) % 2 == 0:
            t_before, x_before, y_before = t, x, y
            pass
        else:
            print("No")
            break
    else:
        print("Yes")



if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
T,X,Y=[],[],[]
for i in range(N):
  TT,XX,YY=map(int,input().split())
  T.append(TT)
  X.append(XX)
  Y.append(YY)
ans=1
if(X[0]+Y[0]>T[0] or (T[0]-X[0]+Y[0])%2):
  ans=0
for i in range(N-1):
  Z=abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])
  if(Z>T[i+1]-T[i] or (T[i+1]-T[i]-Z)%2):
    ans=0
if(ans):
  print("Yes")
else:
  print("No")

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

t, x, y = 0, 0, 0
flag = True
for i in range(n):
    ti, xi, yi = map(int, input().split())
    dist = abs(xi-x) + abs(yi-y)
    dt = ti - t
    if dist <= dt and dist % 2 == dt % 2:
        flag = True
    else:
        flag = False
        break
    t, x, y = ti, xi, yi

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

Solution (Python):
N=int(input())
tb=0
xb=0
yb=0
c=0
for n in range(N):
  ta,xa,ya=map(int,input().split())
  td=ta-tb
  xd=abs(xa-xb)
  yd=abs(ya-yb)
  if td>=xd+yd and (td-xd-yd)%2==0:
    tb=ta
    xb=xa
    yb=ya
  else:
    c=1
    break

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

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

count = 0

for i in range(0,N):
	x = A[i+1][0] - A[i][0] + A[i+1][1] - A[i][1] + A[i+1][2] - A[i][2]
	y = A[i+1][0] - A[i][0]
	if x%2==0 and x <= 2*y:
		count += 1

if count == N:
	print('Yes')
else:
	print('No')

Solution (Python):
n=int(input())
l=[list(map(int, input().split())) for i in range(n)]
l=[[0,0,0]]+l
for i in range(n):
    if abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])>l[i+1][0]-l[i][0]:
        print('No')
        break
    elif abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])==0:
        if (l[i+1][0]-l[i][0])%2!=0:
            print('No')
            break
    elif (l[i+1][0]-l[i][0])%2!=(abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2]))%2:
        print('No')
        break
else:
    print('Yes')

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

l=[list(map(int, input().split())) for i in range(n)]
l=[[0,0,0]]+l

for i in range(n):
    if abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])>l[i+1][0]-l[i][0]:
        print('No')
        break
    elif abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])==0:
        if (l[i+1][0]-l[i][0])%2!=0:
            print('No')
            break
    elif (l[i+1][0]-l[i][0])%(abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2]))!=0:
        print('No')
        break
else:
    print('Yes')

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

L = [[0, 0, 0]] + L
ans = "Yes"
for i in range(N):
    t = L[i+1][0]-L[i][0]
    l = abs(L[i+1][1]-L[i][1]) + abs(L[i+1][2]-L[i][2])
    if t < l or (t-l)%2 == 1:
        ans = "No"
        break
        
print(ans)

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

for i in range(N):
  next_t,next_x,next_y = map(int,input().split())
  interval = next_t - t
  distant_x = int(next_x - x)
  distant_y = int(next_y - y)
  distant = distant_x + distant_y
  
  if(distant > interval):
    print('No')
    break
  elif( (interval - distant) % 2 == 1 ):
    print('No')
    break
  elif(i == N - 1):
    print('Yes')
    
    
  
  t , x , y = next_t , next_x , next_y

Solution (Python):


N=int(input())
l=[[0,0,0]]

for _ in range(N):
    l.append(list(map(int,input().split())))
   
for i in range(N):
    temp=[l[i+1][0]-l[i][0],l[i+1][1]-l[i][1],l[i+1][2]-l[i][2]]
    
    if temp[0]<temp[1]+temp[2] or temp[0]%2!=(temp[1]+temp[2])%2:
        print("No")
        exit()
    else:
        continue
    print(temp)

print("Yes")

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

x=y=0
flg = False
for t,dx,dy in T:
    if abs(x-dx) + abs(y-dy) <= t and (t-dx-dy)%2==0:
        x,y = dx,dy
    else:
        break
else:
    flg = True

print("NYoe s"[flg::2])

Solution (Python):
import os
import math

n = int(input())
t,x,y = 0,0,0
for i in range(n):
    ti,xi,yi = (int(x) for x in input().split())
    dt = ti-t
    dist = abs(xi-x) + abs(yi-y)
    if dist>dt:
        print("No")
        exit()
    if dist%2!=dt%2:
        print("No")
        exit()
    t,x,y = ti,xi,yi
print("Yes")

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

Solution (Python):
n = int(input())
l = []
for _ in range(n):
    l.append([int(x) for x in input().split()])
for j in range(n):
    if j == 0:
        i = l[0][1] + l[0][2]
        c = l[0][0]
    else:
        i = (l[j][1] - l[j-1][1]) + (l[j][2] - l[j-1][2])
        c = l[j][0] - l[j-1][0]
    if i > c:
        print("No")
        break
    elif i == c or (c - i) % 2 == 0:
        if j == n-1:
            print("Yes")
            break
        else: continue
    else:
        print("No")
        break

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

flag = True
i = 0
while(flag and i < n):
    if i == 0:
        dif = l[i][1] + l[i][2]
        t = 0
    else:
        dif = abs(l[i][1] - l[i-1][1]) + abs(l[i][2] - l[i-1][2])
        t = l[i-1][0]
    if l[i][0] - t < dif:
        flag = False
    elif (l[i][0] - t) % 2 != dif % 2:
        flag = False
    i += 1

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

Solution (Python):
N = int(input())
t_prev, x_prev, y_prev = 0,0,0

flag = True
for _ in range(N):
    t,x,y = map(int,input().split())
    k = abs(x-x_prev) + abs(y-y_prev)
    t_diff = t-t_prev
    
    if k > t_diff:
        flag = False
        break
    else:
        if (t_diff - k)%2 != 0:
            flag = False
            break
    t_prev, x_prev, y_prev = t,x,y

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

Solution (Python):
N = int(input())
ta = 0
xa = 0
ya = 0
for i in range(N):
  t,x,y = [int(x) for x in input().split()]
  tb = t-ta
  xb = abs(x-xa)
  yb = abs(y-ya)
  if tb-xb-yb<0 or (tb-xb-yb)%2!=0:
    print("No")
    exit()
print("Yes")

Solution (Python):
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0,0])
ind = 0
for i in range(1,N+1):
    t2,x2,y2 = A[i][0],A[i][1],A[i][2]
    t1,x1,y1 = A[i-1][0],A[i-1][1],A[i-1][2]
    d = dist((x2,y2),(x1,y1))
    if not(t2-t1>=d and (t2-t1-d)%2==0):
        ind = 1
        break
if ind==0:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    pre_t, pre_x, pre_y = [0] * 3
    for i in range(N):
        dt = t[i] - pre_t
        move = x[i] - pre_x + y[i] - pre_y
        if dt < move or dt % 2 != move % 2: 
            print(NO)
            return
        pre_t = t[i]
        pre_x = x[i]
        pre_y = y[i]

    print(YES)
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
t,x,y=0,0,0
for T,X,Y in a:
    if T-t<X-x+Y-y or (T+X+Y)%2==1:
        print("No")
        exit()
    t,x,y=T,X,Y    
print("Yes")

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

t =[i[0] for i in txy]
x =[i[1] for i in txy]
y =[i[2] for i in txy]

t.insert(0,0)
x.insert(0,0)
y.insert(0,0)

ans ="Yes"
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 and dt%2 ==dist%2:
        continue
    else :
        ans ="No"
        break

print(ans)

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

Solution (Python):

t0 = 0
x0 = 0
y0 = 0
n = int(input())
result = "Yes"

for i in range(n):
    t1, x1, y1 = list(map(int, input().split()))
    dt = t1 - t0
    dx = x1 - x0
    dy = y1 - y0
    if ((dx + dy)%2 == dt % 2) and (dx + dy) <= dt:
        t0 = t1
        x0 = x1
        y0 = y1
    else:
        result = "No"

print(result)

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

prev_x = 0
prev_y = 0
prev_t = 0
for i in range(N):

    x_i = abs(txy[i][1] - prev_x)
    y_i = abs(txy[i][2] - prev_y)
    t_i = (txy[i][0] - prev_t) - x_i - y_i

    if t_i == 0 or (t_i > 0 and t_i % 2 == 0):
        prev_t, prev_x, prev_y = txy[i][0], txy[i][1], txy[i][2]
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
N=int(input())
t1,x1,y1=[0,0,0]
for i in range(N):
  t2,x2,y2=[int(s) for s in input().split()]
  if t2-t1<abs(x2-x1)+abs(y2-y1) or (t2-t1)%2!=(x2+y2-x1-y1)%2:
    print("No")
    break
  else:
    t1,x1,y1==[t2,x2,y2]
else:
  print("Yes")

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    routes = list(map(string_to_int, inputs))
    current = [0, 0]
    t = 0
    for r in routes:
        diff_t = r[0] - t
        diff = abs(r[1] - current[0]) + abs(r[2] - current[1])

        if diff_t >= diff and (diff_t % 2) == (diff % 2):
            current = [r[1], r[2]]
            t = r[0]
        else:
            return 'No'
    return 'Yes'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

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

Solution (Python):
n = int(input())
t = 0
x = 0
y = 0
d = 0
ans = 'No'
for i in range(0, n):
    t_p = t
    x_p = x
    y_p = y
    t, x, y = [int(_) for _ in input().split()]
    d = abs(x-x_p) + abs(y-y_p)
    delta_t = t - t_p
    if delta_t < d:
        break;
    if delta_t >= d and (delta_t-d)%2 != 0:
        break;
    if i == n-1:
        ans = 'Yes'
print(ans)

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

Solution (Python):
n = int(input())
ary = [list(map(int,input().split())) for _ in range(n)]
nv = [0,0]
count = 0
for i in range(n):
    a,b = abs(nv[0]-ary[i][1]),abs(nv[1]-ary[i][2])
    c = ary[i][0] - count
    if c < a+b:print("No");exit()
    elif (c - (a+b)) % 2 == 1:print("No");exit()
    nv = [ary[i][1],ary[i][2]]
    count += c
else:print("Yes")

Solution (Python):
n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])

for k in range(n):
    o = int(t[k+1])-int(t[k])
    p = int(x[k+1])-int(x[k])
    q = int(y[k+1])-int(y[k])
    if (o >= p+q) and ((o - (p+q))%2 == 0):
        b += 1
    else:
        b = b

if b == n:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
TXY=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
  dift=abs(TXY[i][0]-TXY[i-1][0])
  difx=abs(TXY[i][1]-TXY[i-1][1])
  dify=abs(TXY[i][2]-TXY[i-1][2])
  if (dift-(difx-dify))%2!=0 or dift<(difx+dify):
    print('No')
    exit()
print('Yes')

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

for i in range(n):
    if plan[i + 1][0] - plan[i][0] < abs(plan[i + 1][1] - plan[i][1]) + abs(plan[i + 1][2] - plan[i][2]):
        print("No")
        exit()
    if (plan[i + 1][0] - plan[i][0]) % 2 != (abs(plan[i + 1][1] - plan[i][1]) + abs(plan[i + 1][2] - plan[i][2])) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n=int(input())
s=[input().split() for i in range(n)]
ans=0
for j in s:
    a=int(j[0])
    b=int(j[1])
    c=int(j[2])
    if a>=b+c:
        if a%2==0 and (b+c)%2==0 or a%2!=0 and (b+c)%2!=0:
            ans+=1
if ans==n:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
lis =list()
lis.append([0, 0, 0])
sys.stdin.readline()
for e in sys.stdin:
  lis.append(list(map(int, e.split())))
for i in range(len(lis) - 1):
  d_t = lis[i + 1][0] - lis[i][0]
  man_dis = abs(lis[i + 1][1] - lis[i][1]) + abs(lis[i + 1][2] - lis[i][2])
  if d_t < man_dis or d_t % 2 - man_dis % 2 != 0:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
def main():
    N = int(input())
    txy = [[0,0,0]] + [[int(i) for i in input().split()] for j in range(N)]
    for i in range(1,N+1):
        cur_distance = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
        t_diff = txy[i][0] - txy[i-1][0]
        if t_diff < cur_distance or t_diff%2 != cur_distance%2:
            print("No")
            break
    else:
        print("Yes")
if __name__ == '__main__':
    main()

Solution (Python):
def c_traveling():
    N = int(input())
    P = [[int(i) for i in input().split()] for j in range(N)]
    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 not (dt >= dd and (dt - dd) % 2 == 0):
            
            
            return 'No'
        t, x, y = t_next, x_next, y_next
    return 'Yes'

print(c_traveling())

Solution (Python):
n = int(input())
s = [input().split() for i in range(n)]
sum = 0

for locate in s:
    t = int(locate[0])
    x = int(locate[1])
    y = int(locate[2])
    if x+y <= t:
        if (x+y)%2==0 and t%2==0:
            sum += 1
        elif (x+y)%2!=0 and t%2!=0:
            sum += 1

if sum == n:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
pos=[0,0]
jt=0
arr=[]
for i in range(N):
    t,x,y=map(int,input().split())
    a=t-jt
    b=abs(pos[0]-x)+abs(pos[1]-y)
    arr.append(a%2==b%2 and a>=b)
    jt=t
    pos=[x,y]
print('Yes' if all(arr) else 'No')

Solution (Python):
N = int(input())
t = x = y = 0
for i in range(N):
  tn,xn,yn = map(int,input().split())
  dt = tn-t
  d = abs(xn-x)+abs(yn-y)
  if d <= dt and dt%2 == d%2:
    t,x,y = tn,xn,yn
    isValid = True
  else:
    isValid = False
    break
print("Yes" if isValid else "No")

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

    pos = [0, 0, 0]
    for i in range(0, n):
        t,x,y = txy[i][0:]
        dt = t - pos[0]
        dx = abs(pos[1] - x)
        dy = abs(pos[2] - y)
        dz = dx + dy

        if dz <= dt and dt%2 == dz%2:
            pos = [t, x, y]
        else:
            print('No')
            import sys
            sys.exit()

    print('Yes')

cc086()

Solution (Python):
import math
n = int(input())
a = [[0,0,0]]
for i in range(n):
    b = list(map(int, input().split()))
    a.append(b)
ansFlg = True
for i in range(1,len(a)):
    ti = a[i][0] - a[i-1][0]
    x = abs(a[i][1] - a[i-1][1])
    y = abs(a[i][2] - a[i-1][2])
    target = ti - x - y
    if (target < 0) or (target%2 != 0):
        ansFlg = False
if ansFlg:
    print("Yes")
else:
    print("No")

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

for i in range(n):
    t_diff = li[i+1][0] - li[i][0]
    xy_diff = sum(li[i+1][1:]) - sum(li[i][1:])

    if t_diff < xy_diff or t_diff % 2 != xy_diff % 2:
        print("No")
        exit()
print("Yes")

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

for i in range(n):
    t_diff = li[i+1][0] - li[i][0]
    xy_diff = sum(li[i+1][1:]) - sum(li[i][1:])

    if t_diff < xy_diff or t_diff % 2 != xy_diff % 2:
        print("No")
        exit()
print("Yes")

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

ctime = 0
cx = 0
cy = 0
ans = True

for i in range(N):
    nt,nx,ny = Data[i]
    dist = abs(nx-cx)+abs(ny-cy)
    dtime  = nt-ctime 

    if dist > dtime or (dtime-dist) % 2 == 1:
        ans = False
        break

    ctime = nt
    cx = nx
    cy = ny

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def dist(a, b):
    dist = 0
    dist += abs(a[0] - b[0])
    dist += abs(a[1] - b[1])
    return dist

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    txy = [[i, j, k] for i,j,k in zip(t, x, y)]
    txy = sorted(txy, key = lambda x: x[0])
    flag = 0
    coordinate_start = [0, 0]
    t_start = 0
    for t, x, y in txy:
        coordinate_goal = [x, y]
        time_to_travel = t - t_start
        distance = dist(coordinate_start, coordinate_goal)
        if distance > time_to_travel:
            flag = False
            break
        if distance <= time_to_travel:
            if (distance - time_to_travel) % 2 == 0:
                flag = True
            else:
                flag = False
                break
        t_start = t
        coordinate_start = [x, y]
    if flag == True:
        print(YES)
    else:
        print(NO)
    return



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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
t0 = 0
x0 = 0
y0 = 0
ans = True

for i in range(N):
    next = input().split()
    t = int(next[0])
    x = int(next[1])
    y = int(next[2])
    time = t - t0
    range = abs(x - x0) + abs(y - y0)

    if time < range:
        ans = False
        break

    if time % 2 == 0:
       if range % 2 != 0:
          ans = False
          break
    else:
       if range % 2 == 0 or range == 0:
          ans = False
          break

    t0 = t
    y0 = y
    x0 = x



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

Solution (Python):
_ = int(input())
bef_time = 0
bef_x = 0
bef_y = 0
ans = True

for i in range(_):
    next = input().split()
    next_time = int(next[0])
    next_x = int(next[1])
    next_y = int(next[2])
    time = next_time - bef_time
    range = abs(next_x - bef_x) + abs(next_y - bef_y)

    if (next_time - bef_time) < range:
        ans = False
        break

    if time % 2 == 0:
       if range % 2 != 0:
          ans = False
          break
    else:
       if range % 2 == 0 or range == 0:
          ans = False
          break

    bef_time = next_time
    bef_y = next_y
    bef_x = next_x



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

Solution (Python):
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
check = True
for i in range(len(l)):
    if not((l[i][0] >= l[i][1] + l[i][2]) and (l[i][0] % 2 == ((l[i][1] + l[i][2]) % 2))):
        check = False
if check:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])

for k in range(n):
    o = int(t[k+1])-int(t[k])
    p = int(x[k+1])-int(x[k])
    q = int(y[k+1])-int(y[k])
    if (o >= p+q) and ((o - (p+q))%2 == 0):
        b += 1
    else:
        b = b

if b == n:
    print('Yes')
else:
    print('No')

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

a = [input().split() for l in range(n)]
for i in range(n):
    t.append(a[i][0])
    x.append(a[i][1])
    y.append(a[i][2])

for i in range(1,n+1):
    time = int(t[i])-int(t[i-1])
    next2 = int(x[i])+int(y[i])
    if time >= next2-now and (time-(next2-now))%2 == 0:
       now = int(x[i])+int(y[i])
    else:
        print('No')
        exit()
    
print('Yes')

Solution (Python):
n = int(input())
now=0
t=[0 for i in range(n+1)]  
x=[0 for i in range(n+1)]
y=[0 for i in range(n+1)]

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

for i in range(1,n+1):
    time = int(t[i])-int(t[i-1])
    next2 = int(x[i])+int(y[i])
    if time >= next2-now and (time-(next2-now))%2 == 0:
       now = int(x[i])+int(y[i])
    else:
        print('No')
        exit()
    
print('Yes')

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

txy.insert(0,[0,0,0])


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

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

tarr = []
xarr = []
yarr = []

tarr.append(0)
xarr.append(0)
yarr.append(0)


for i in range(n):
    t, x, y = map(int, input().split())
    tarr.append(t)
    xarr.append(x)
    yarr.append(y)

for i in range(1, n+1):
    if (tarr[i] % 2 == 0 and (xarr[i] + yarr[i]) % 2 == 1) or (tarr[i] % 2 == 1 and (xarr[i] + yarr[i]) % 2 == 0):
        print('No')
        exit()

    if tarr[i] - tarr[i - 1] < xarr[i] + yarr[i] - xarr[i - 1] - yarr[i - 1]:
        print('No')
        exit()

print('Yes')

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

d = [(T[0][0],T[0][1]+T[0][2])]
for i in range(1,n):
    d += [(T[i][0]-T[i-1][0], abs(T[i][1]-T[i-1][1]) + abs(T[i][2]-T[i-1][2]))]

for i in range(n):
    if (d[i][0]+d[i][1])%2 != 0 or d[i][0] < d[i][1]:
        print('No')
        break
else:
    print('Yes')

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

now = [0,0]
now_t = 0

for target in targets:
    distance = abs(now[0] - target[1]) + abs(now[1] - target[2])
    limit = target[0] - now_t
    if distance > limit :
            print("No")
            exit()
    elif (distance - limit) %2 !=0:
            print("No")
            exit()
    else:
            now[0] = target[1]
            now[1] = target[2]
            now_t  = target[0]
print("Yes")

Solution (Python):
N=int(input())
List=[list(map(int,input().split())) for i in range(N)]
ans='Yes'
for j in List:
  if (j[1]+j[2]) > j[0]:
    ans='No'
  else:
    if j[0]%2 == 0:
      if (j[1]+j[2])%2 == 1:
        ans='No'
    else:
      if (j[1]+j[2])%2 == 0:
        ans='No'
print(ans)

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

can = 1

for i in range(1, n+1):
    tm = t[i] - t[i-1]
    xm = abs(x[i] - x[i-1])
    ym = abs(y[i] - y[i-1])
    if((tm < xm+ym) or ((tm-xm+ym)%2)):
        can = 0
        break;

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