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):
def main():
    N = int(input())
    t_lst = [0] * (N + 1)
    x_lst = [0] * (N + 1)
    y_lst = [0] * (N + 1)

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

    ans = "Yes"
    for i in range(N):
        dt = t_lst[i + 1] - t_lst[i]
        dist = abs(x_lst[i + 1] - x_lst[i]) + abs(y_lst[i + 1] - y_lst[i])
        if dt < dist:
            ans = "No"
            break
        elif dt % 2 != dist % 2:
            ans = "No"
            break

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):


from typing import Tuple
from typing import List


Coordinate = Tuple[int, int, int]


def main():
    N = int(input())
    codList: List[Coordinate] = [(0, 0, 0)]
    for i in range(0, N):
        args = list(map(lambda x: int(x), input().split()))
        codList.append((args[0], args[1], args[2]))

    for i in range(1, N + 1):
        start = codList[i - 1]
        end = codList[i]
        dis = distance(start, end)
        duration = end[0] - start[0]

        if (duration - dis >= 0) and ((duration - dis) % 2 == 0):
            continue
        else:
            print("No")
            return

    print("Yes")


def distance(cod1: Coordinate, cod2: Coordinate):
    return abs(cod1[1] - cod2[1]) + abs(cod1[2] - cod2[2])


if __name__ == "__main__":
    main()

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

a = 'Yes'
for i in range(N):
    if t[i+1] - t[i] < abs(x[i+1]-x[i]) + abs(y[i+1] - y[i]):
      a = 'No'
      break
    if (t[i+1] - t[i]) % 2 != (abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])) % 2:
      a = 'No'
      break
print(a)

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

Solution (Python):
N = int(input())
t = [list(map(int, input().split())) for _ in range(N)]
t.insert(0, [0, 0, 0])
x = [t[i][1] for i in range(N+1)]
y = [t[i][2] for i in range(N+1)]
t = [t[i][0] for i in range(N+1)]
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 (abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])) %2 != (t[i] - t[i-1]) % 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
def move_time(x1,y1,x2,y2):
    return abs(x1-x2)+abs(y1-y2)

n = int(input())
t1 = 0
x1 = 0
y1 = 0
isYes = True
for i in range(n):
    t2,x2,y2 = map(int,input().split())
    tm = move_time(x1,y1,x2,y2)
    
    if tm>(t2-t1):
        isYes = False
    elif ((t2-t1)-tm)%2==1:
        isYes = False
    t1 = t2
    x1 = x2
    y1 = y2

if isYes:
    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_)

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

Solution (Python):
n = int(input())
t_ = 0
xy_ = [0,0]
for _ in range(n):
    t, *xy = map(int, input().split())
    ta = t - t_
    xya = [abs(xy[0]-xy_[0]), abs(xy[1]-xy_[1])]
    if sum(xya) > ta or (ta - sum(xya))%2 != 0:
        print("No")
        break
    t_ = t
    xy_ = xy
else:
    print("Yes")

Solution (Python):
ans = "Yes"
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
  tmp = input().split(" ")
  t.append(int(tmp[0]))
  x.append(int(tmp[1]))
  y.append(int(tmp[2]))

for j in range(N):
  dt = t[j+1] - t[j]
  dx = abs(x[j+1] - x[j])
  dy = abs(y[j+1] - y[j])
  if dt >= dx + dy and dt % 2 == (dx + dy) % 2:
    continue
  else:
    ans = "No"
    break

print(ans)

Solution (Python):
n=int(input());t,x,y=[],[],[]
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  m,k=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (m>=k and m%2==k%2): print('No');break
else:
  print('Yes')

Solution (Python):
n=int(input());t,x,y=[],[],[]
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')

Solution (Python):
n=int(input());t,x,y,r1,r2=[],[],[],0,0
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')

Solution (Python):
n=int(input());t,x,y=[],[],[]
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  if i==0:
    r1,r2=t[i],x[i]+y[i]
  else:
    r1,r2=t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if not (r1>=r2 and r1%2==r2%2):
    print('No');break
else:
  print('Yes')

Solution (Python):
t,x,y=[],[],[];n=int(input())
for _ in range(n):
  a,b,c=map(int,input().split())
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  if i==0:
    r1=t[i]
    r2=x[i]+y[i]
  else:
    r1=t[i]-t[i-1]
    r2=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if not (r1>=r2 and r1%2==r2%2):
    print('No')
    break
else:
  print('Yes')

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

ans = True

for i in range(N):
    if i == 0:
        t = TXY[i][0]
        x = TXY[i][1]
        y = TXY[i][2]

    else:
        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 t == xy or (t > xy and (t - xy) % 2 == 0):
        pass
    else:
        ans = False
        break

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

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)

def helper():
  curt = 0
  curx = 0
  cury = 0
  for i in range(N):
    dt = t[i] - curt
    curt = t[i]

    dx = abs(x[i] - curx)
    curx = x[i]

    dy = abs(y[i] - cury)
    cury = y[i]

    if dt < (dx+dy) or dt%2 != (dx+dy)%2:
      return False
  return True

a = helper()  
print('Yes') if a else print('No')

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

def helper():
  for i in range(N):
    dt = t[i+1] -t[i] 
    dx = abs(x[i+1] - x[i])
    dy = abs(y[i+1] - y[i])

    if dt < (dx+dy) or dt%2 != (dx+dy)%2:

      return False
  return True

a = helper()  
print('Yes') if a else print('No')

Solution (Python):
N=int(input())
P=[(0,0,0)]*(N+1)

D=[0]*(N+1)

P[0]=(0,0,0)
D[0]=1
for i in range(1,N+1):
    t,x,y=map(int,input().split())
    dt=t-P[i-1][0]
    dx=abs(x-P[i-1][1])
    dy=abs(y-P[i-1][2])
    if dt < (dx+dy): 
        print('No')
        break
    if ((dx+dy)==0 and dt%2!=0): 
        print('No')
        break
    
    if (dt-(dx+dy))%2!=0:
        print('No')
        break
    
    P[i]=(t,x,y)
else:
    print('Yes')

Solution (Python):
def end():
    print('No')
    exit()

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

temp = abs(x[0]) + abs(y[0])
if t[0] % 2 == temp % 2:
    if t[0] < temp:
        end()
else:
    end()

for i in range(1, n):
    temp = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1])
    if (t[i]-t[i-1]) % 2 == temp % 2:
        if t[i]-t[i-1] < temp:
            end()
    else:
        end()

print('Yes')

Solution (Python):
import sys
readline=sys.stdin.readline
read=sys.stdin.read
n,*abc=map(int,read().split())

abc=[(t,x,y) for t,x,y in zip(*[iter(abc)]*3)]
abc=[(0,0,0)]+abc
diff=[abs(nxt[2]-cur[2])+abs(nxt[1]-cur[1])-nxt[0]+cur[0] for cur,nxt in zip(abc,abc[1:])]
for d in diff:
  if d>0 or d%2==1:
    print('No')
    break
else:
  print('Yes')

Solution (Python):

N = int(input())

t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)

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

boolian = True    
        
for i in range(N):
    delta_t = t[i+1] - t[i]
    delta_x = x[i+1] - x[i]
    delta_y = y[i+1] - y[i]
    
    delta_x = abs(delta_x)
    delta_y = abs(delta_y)
    
    delta_sum = delta_x + delta_y
    
    k = delta_sum % 2 
    j = delta_t % 2

    if -delta_t <= delta_sum and delta_sum <= delta_t:
        if k == 0 and j == 0:
            boolian = True
            continue
        if k == 1 and j == 1:
            boolian = True
            continue
        else:
            boolian = False
            print('No')
            break
    else:
        boolian = False
        print('No')
        break

if boolian == True:
    print('Yes')

Solution (Python):
N = int(input())
t_before = 0
x_before = 0
y_before = 0

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

def judge(t_plus, x_diff, y_diff):
    distance = abs(x_diff) + abs(y_diff)
    if (t_plus % 2) != (distance % 2):
        return False
    if distance > t_plus:
        return False 
    return True

is_found = False

for i in range(N):
    t, x, y = travel_list[i]
    result = judge(t_plus=t-t_before, x_diff=x-x_before, y_diff=y-y_before)
    if result:
        t_before = t
        x_before = x
        y_before = y
    else:
        break
else:
    is_found = True
if is_found:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
dx,dy,dt=0,0,0
count=0
for i in range(N):
    t,x,y=map(int,input().split())
    if (x+y+t)%2 == 0 and abs(x-dx) + abs(y-dy) <= abs(t-dt):
        count+=1
    dx,dy,dt=x,y,t

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

Solution (Python):
n=int(input())
plan=[[int(s) for s in input().split()] for j in range(n)]
now =[0 for j in range(3)]
plan.insert(0,now)
ans=0
for i in range(n):
    dt=abs(plan[i+1][0]-plan[i][0])
    dx=abs(plan[i+1][1]-plan[i][1])
    dy=abs(plan[i+1][2]-plan[i][2])
    if dt>=dx+dy:
        if dt%2 == (dx+dy)%2:
            ans+=1
print("Yes" if ans==n else "No")

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

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

t = 0
x = 0
y = 0
flag = 0

for i in range(n):
    if i>0:
        t = list[i][0] - list[i-1][0]
        d = abs(list[i][1] - list[i-1][1] + list[i][2] - list[i-1][2])
    else:
        t = list[i][0]
        d = abs(list[i][1] + list[i][2])
    if (t-d) >= 0 and (d-t)%2 == 0:
        continue
    else:
        flag = 1
        print('No')
        break
if flag ==0:
    print('Yes')

Solution (Python):
n=int(input())
sy,sx=[0,0]
t1=0
ch=0

for _ in range(n):
  t,x,y=map(int,input().split())
  if (abs(sy-y)+abs(sx-x)-abs(t-t1))%2!=0 or abs(sy-y)+abs(sx-x)>abs(t-t1):
    ch+=1
  t1=t
  sy,sx=[y,x]
  
if  ch==0:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

input = sys.stdin.readline
t, x, y = 0, 0, 0
for _ in range(int(input())):
    t1, x1, y1 = map(int, input().split())
    a = abs(x1 - x) + abs(y1 - y)
    b = t1 - t
    if a <= b and a % 2 == b % 2:
        t, x, y = t1, x1, y1
    else:
        print("No")
        break
else:
    print("Yes")

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

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

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

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) < 0 or (dt - (dx + dy))%2 == 1:
        print("No")
        exit()
    t,x,y = T,X,Y

print("Yes")

Solution (Python):
N = int(input())
TXY = [list(map(int, input().split())) for _ in range(N)]
 
pre_t, pre_x, pre_y = 0, 0, 0
for t, x, y in TXY:
  diff_t = t - pre_t
  diff_pos = abs(x-pre_x) + abs(y-pre_y)
  if diff_t < diff_pos or (diff_t-diff_pos) % 2 == 1:
    print('No')
    exit()
  else:
    pre_t, pre_x, pre_y = t, x, y
print('Yes')

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())
  
  lim_t=t[i+1]-t[i]
  lim_x=x[i+1]-x[i]
  lim_y=y[i+1]-y[i]
  
  if abs(lim_x)+abs(lim_y)>lim_t or (lim_t-lim_x-lim_y)%2==1:
    print('No')
    exit()
    
print('Yes')

Solution (Python):
N = int(input())
P = []

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

t_before = 0
x_before = 0
y_before = 0
f_enable = True
for p in P:
    t, x, y = p

    t_distance = abs(t_before - t)
    p_distance = abs(x_before - x) + abs(y_before - y)

    distance = t_distance - p_distance

    if distance < 0:
        f_enable = False
        break
    elif distance % 2 != 0:
        f_enable = False
        break

    t_before = t
    x_before = x
    y_before = y

if f_enable:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Solution (Python):
N = int(input())
now_x, now_y = 0, 0
time = 0
for i in range(N):
  t, x, y = map(int, input().split())
  board = abs(x - now_x) + abs(y - now_y)
  if board > t - time:
    print("No")
    quit()
  elif ((t - time) - board) % 2 == 1:
    print("No")
    quit()
  else:
    now_x, now_y, time = x, y, t
    
print("Yes")

Solution (Python):
def dist(s1,s2):
  return abs(s1[1]-s2[1]) + abs(s1[2]-s2[2])

N=int(input())
now = (0,0,0)
for i in range(N):
  next_ = list(map(int,input().split()))
  if dist(now,next_)<=next_[0]-now[0] and dist(now,next_) % 2 == (next_[0]-now[0])%2:
    now = next_
    continue
  else:
    print('No')
    exit()
print('Yes')

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

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

Solution (Python):
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Solution (Python):
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Solution (Python):



N=int(input())

T=0
X,Y=0,0

for i in range (N):
    t, x, y =map(int,input().split())
    time =t-T
    distance=abs((x+y)-(X+Y))
    if time >= distance and time%2==distance%2:
        T=t
        X,Y=x,y
    else :
        print("No")
        exit()

print("Yes")

Solution (Python):
class Coodinate (object):
    """Coodinate object
    This class contains infomation about the coodinates.
    Each instance can have up to 3-dimensional(x,y,z) space coodinates.
    
    params
    ------------------------------
    x : int or floot ,default 0
    y : int or floot ,default 0
    z : int or floot ,default 0


    This class have following methods.
    ------------------------------
    distance : Calculate the straight-line distance between 2 points in Euclidean space.
    midpoint : Calculate the midpoint(halfway) between 2 points.
    manhattan_distance : Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.
    """

    def __init__(self,x=0,y=0,z=0):
        self.x=x
        self.y=y
        self.z=z


    def __str__(self):
        if self.z==0:
            if self.y==0:
                return "( {} )".format(self.x)
            else :
                return "( {} , {} )".format(self.x,self.y)
        else:
            return "( {} , {} , {} )".format(self.x,self.y,self.z)    


    def distance(self,other):
        """Calculate the straight-line distance between 2 points in Euclidean space.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        distance : floot

        """
        x_diff_sq=(self.x-other.x)**2
        y_diff_sq=(self.y-other.y)**2
        z_diff_sq=(self.z-other.z)**2
        return (x_diff_sq + y_diff_sq +z_diff_sq)**0.5
    

    def midpoint(self,other):
        """Calculate the midpoint(halfway) between 2 points.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        midpoint : tupul
        
        """
        x_midpoint=(self.x+other.x)/2
        y_midpoint=(self.y+other.y)/2
        z_midpoint=(self.z+other.z)/2
        if self.z == other.z ==0 :
            if self.y == other.y==0:
                return(x_midpoint)
            else:
                return(x_midpoint,y_midpoint) 
        return(x_midpoint,y_midpoint,z_midpoint)

    def manhattan_distance(self,other):
        """Calculate the distance between 2 points that is sum of the absolute values their Cartesian coordinates.

        params
        ----------
        self : Coodinate object
        other : Coodinate object

        return
        ----------
        manhattan_distance : floot

        """

        x_diff_abs=abs(self.x - other.x)
        y_diff_abs=abs(self.y - other.y)
        z_diff_abs=abs(self.z - other.z)
        return(x_diff_abs + y_diff_abs + z_diff_abs)




N=int(input())

T=0
now=Coodinate()

for i in range (N):
    t, x, y =map(int,input().split())
    time =t-T
    location = Coodinate(x,y)
    destination = Coodinate.manhattan_distance(location,now)
    if time >= destination and time%2==destination%2:
        T=t
        now=location
    else :
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys
N=int(input())
 
t0=0
x0=0
y0=0
 
for i in range(N):
    t,x,y=map(int,input().split())
    l=(t-t0)-abs(x+y-x0-y0)
    t0=t
    x0=x
    y0=y
    if l%2==0 and l>=0:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    P = [0] * (N + 1)
    P[0] = (0, 0, 0)
    for i in range(1, N + 1):
        P[i] = tuple(map(int, readline().split()))

    ok = True
    for i in range(N):
        dt = P[i + 1][0] - P[i][0]
        dx = P[i + 1][1] - P[i][1]
        dy = P[i + 1][2] - P[i][2]
        if dt < abs(dx) + abs(dy) or (dt - abs(dx) - abs(dy)) % 2 == 1:
            ok = False
            break

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

    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import itertools

import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines



N = int(input())
px, py, pt = 0, 0, 0
ok = True
for i in range(N):
    t, x, y = map(int, input().split())
    diff = abs((x + y) - (px + py)) 
    if diff > t - pt:
        ok = False
    if diff % 2 != (t - pt) % 2:
        ok = False
    px = x
    py = y
    pt = t

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

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

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

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

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

status = True
t = x = y = 0

for i in range(n):
    ti, xi, yi = list(map(int, input().split()))
    dist = abs(xi-x)+abs(yi-y)
    time = ti-t
    if (dist > time):
        status = False
    elif (time - dist) % 2 == 1:
        status = False

    t, x, y = [ti, xi, yi]

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

Solution (Python):

import math
n = int(input())
t = 0
x = 0
y = 0




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

Solution (Python):

import math
n = int(input())
t = 0
x = 0
y = 0
txy = []
for i in range(n):
    ti, xi, yi = list(map(int, input().split()))
    txy.append((ti, xi, yi))

for ti, xi, yi in txy:
    if abs(xi - x) + abs(yi - y) > abs(ti - t):
        print("No")
        exit()
    elif (abs(xi - x) + abs(yi - y) - abs(ti - t)) % 2 != 0:
        print("No")
        exit()
    else:
        t = ti
        x = xi
        y = yi
print("Yes")

Solution (Python):
result = 'Yes'


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

for i in range(N):
	data.append(list(map(int, input().split())))


for move_index in range(N):
  start = data[move_index]
  end   = data[move_index + 1]
  
  
  move_count = end[0] - start[0]
  
  min_move = abs(end[1] - start[1]) + abs(end[2] - start[2])
  
  if min_move > move_count:     
    result = 'No'
    break
  elif min_move == move_count:	
    pass
  else:							
    exceed_count = move_count - min_move
    if exceed_count % 2 == 0:
      pass
    else:
      result = 'No'
      break
      

print(result)

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

flag=0
flag2=0
for i in range(N):
    flag=0
    time=t[i+1][0]-t[i][0]
    x=t[i+1][1]-t[i][1]
    y=t[i+1][2]-t[i][2]
    time=abs(time)
    x=abs(x)
    y=abs(y)
    
    if (time-(x+y))%2==0 and time>=(x+y):
        flag=1
    if flag!=1:
        flag2=1    

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

Solution (Python):

N = int(input())
txy = [map(int, input().split()) for _ in range(N)]
t, x, y = [list(i) for i in zip(*txy)]
t.insert(0, 0)
x.insert(0, 0)
y.insert(0, 0)
can = True
distX = [0]*(N)
distY = [0]*(N)
dist = [0]*(N)
time = [0]*(N)


for i in range(N):
	distX[i] = abs(x[i]-x[i+1])
	distY[i] = abs(y[i]-y[i+1])
	dist[i] = distX[i]+distY[i]
	time[i] = t[i+1]-t[i]
	if dist[i] > time[i]:
		can = False
		break


for i in range(N):
	if (dist[i]-time[i]) % 2 == 1:
		can = False
		break

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

Solution (Python):
n=int(input())
old=[0,0,0]
for i in range(n):
  t,x,y=map(int,input().split())
  tt=t-old[0]
  xx=x-old[1]
  yy=y-old[2]
  dist=abs(xx)+abs(yy)
  if tt%2 != (xx+yy)%2 or dist>tt:
    print("No")
    exit()
  old=[t,x,y]
  
print("Yes")

Solution (Python):
prev,pt = (0,0),0
b = True
def f(a,b): return abs(b[0]- a[0]) + abs(b[1] - a[1])
for _ in range(int(raw_input())):
	t,x,y  = map(int, raw_input().split())
	if (t - pt) < f((x,y), prev) :
		b = False
		break 

	if ((t - pt) - f((x,y), prev)) % 2:
		b = False
		break
	prev,pt = (x,y),t

print 'Yes' if b else 'No'

Solution (Python):
N = int(input().strip())
gridi = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    gridi.append(array)
f="Yes"
grid=[]
for i in range(N+1):
    grid.append([0,0,0])
for i in range(1,N+1):
    grid[i][0]=gridi[i-1][0]
    grid[i][1]=gridi[i-1][1]
    grid[i][2]=gridi[i-1][2]
for i in range(N):
    dt=int(grid[i+1][0])-int(grid[i][0])
    dist=abs(grid[i+1][1]-grid[i][1])+abs(grid[i+1][2]-grid[i][2])
    if dist>dt:
        f="No"
    elif dist%2!=dt%2:
        f="No"
print(f)

Solution (Python):
N = int(input())
PX = PY = PT = 0

for _ in range(N):
  T,X,Y = map(int,input().split())
  if abs(X-PX)+abs(Y-PY)>T-PT or (X+Y-PX-PY)%2 != (T-PT)%2:
    print("No")
    exit()
  else:
    PX = X
    PY = Y
    PT = T
    
print("Yes")

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


pt = 0
px = 0
py = 0

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

    time = abs(t - pt)
    
    dist = abs(x - px) + abs(y - py)

    if dist > time:
        print("No")
        exit()

    
    
    if time % 2 != dist % 2:
        print("No")
        exit()

    pt, px, py = t, x, y

print("Yes")

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

st_t = 0
st_x = 0
st_y = 0
li_in = list()
for i in range(n):
    li_in.append(list(map(int, input().split())))


for t, x, y in li_in:
    time = t - st_t
    diff_x = abs(x - st_x)
    diff_y = abs(y - st_y)

    if diff_x + diff_y > time:
        print('No')
        exit(0)
    elif diff_x + diff_y == time:
        st_t = t
        st_x = x
        st_y = y
        continue
    
    else:
        if (time - (diff_x + diff_y)) % 2 == 0:
            st_t = t
            st_x = x
            st_y = y
            continue
        else:
            print('No')
            exit(0)
else:
    print('Yes')

Solution (Python):
n = int(input())
t_l = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
t_t = [[abs(t_l[i][0]-t_l[i-1][0]), abs(t_l[i][1]-t_l[i-1][1]), abs(t_l[i][2]-t_l[i-1][2])] for i in range(1,n+1)]
ans = "Yes"

for j in t_t:
    t, x, y = j
    if t < x + y:
        ans = "No"
        break
    elif t % 2 != (x + y) % 2:
        ans = "No"
        break
print(ans)

Solution (Python):
import numpy as np
n=int(input())
x=[list(map(int, input().split())) for _ in range(n)]

now=0
nplace=[0,0]
noflag=False
for y in x:
    dis=sum(map(abs, (np.array(y[1:]) - np.array(nplace))))
    
    if not ((dis<=(y[0]-now)) & ((y[0]-now-dis)%2==0)):
        noflag=True

    now=y[0]
    nplace=y[1:]
print('Yes') if noflag==False 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())
    r=abs(X-x)+abs(Y-y)
    t=T-t
    if r%2!=t%2 or t<r:
        print('No')
        exit()
    t=T;x=X;y=Y
print('Yes')

Solution (Python):
N = int(input())
TB,XB,YB = 0,0,0
Flag = True
for Z in range(0,N):
    TA,XA,YA = (int(A) for A in input().split())
    RestT = (TA-TB)-(abs(XA-XB)+abs(YA-YB))
    if RestT<0 or RestT%2!=0:
        Flag = False
        break
    else:
        TB,XB,YB = TA,XA,YA
if Flag:
    print('Yes')
else:
    print('No')

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

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

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

for i in range(n):
    t = infos[i+1][0]-infos[i][0]
    abs_x = abs(infos[i][1]-infos[i+1][1])
    abs_y = abs(infos[i][2]-infos[i+1][2])
    d = abs_x + abs_y
    if t < d or t%2!=d%2:
        print("No")
        exit()

print("Yes")

Solution (Python):
N = int(input())
t, x, y = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    tn, xn, yn = map(int, input().split())
    d = abs(xn - x) + abs(yn - y)
    td = tn - t
    if d > td or (d - td)%2 != 0:
        ans = 'No'
    t, x, y = tn, xn, yn
print(ans)

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

ans = True
preT,preX,preY = 0,0,0
for i in range(N):
    t,x,y = map(int,input().split())

    if abs(x-preX)+abs(y-preY) > t - preT:
        ans=False
    if (-abs(x-preX)-abs(y-preY) + t - preT)%2==1:
        ans=False
    
    preX = x
    preY = y
    preT = t

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

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

flag = 0
for i in range(n):
  delta = a[i+1][0]-a[i][0]
  distance = abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2])
  if delta < distance or delta%2 != distance%2:
    flag = 1
    break
    
if flag == 1:
  print("No")
else:
  print("Yes")

Solution (Python):
n = int(input())
points = []
points.append([0, 0, 0])
can = True
for i in range(n):
    points.append([i for i in map(int, input().split())])
    move_n = points[i+1][0] - points[i][0]
    dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
    if move_n < dist or dist % 2 != move_n % 2:
        can = False 
        break









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

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

can = True
for i in range(len(points)-1):
    move_n = points[i+1][0] - points[i][0]
    dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
    if move_n < dist or dist % 2 != move_n % 2:
        can = False 
        break

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

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

can = True

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

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
        break
    if dt%2 == 0 and dist%2 == 0:
        continue
    elif dt%2 == 1 and dist%2 == 1:
        continue
    else:
        can = False
        break

if can == True:
    print('Yes')
elif can == False:
    print('No')