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

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left, bisect_right 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for txyi, txyip in zip([[0, 0, 0]] + txy[:-1], txy):
    ti, xi, yi = txyi
    tip, xip, yip = txyip
    dift = tip - ti
    difd = abs(xip-xi) + abs(yip-yi)
    if difd%2 != dift%2:
        print('No')
        exit()
    if dift < difd:
        print('No')
        exit()
print('Yes')

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

n = int(input())

bt, bx, by = 0, 0, 0
cond = True
for i in range(n):
    t, x, y = [int(w) for w in input().split()]
    dt = t-bt
    dist = abs(bx-x)+abs(by-y)
    if dt >= dist and (dt-dist) % 2 == 0:
        bt, bx, by = t, x, y
        continue
    cond = False


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

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

t=x=y=0

for _ in range(N):
    ti,xi,yi = map(int,input().split())
    T = ti-t
    X = xi-x
    Y = yi-y
    if ((T%2==0 and (X+Y)%2==0) or (T%2==1 and (X+Y)%2==1)) and T >= abs(X+Y):
        t=ti
        x=xi
        y=yi
    else:
        print('No')
        break
else:print('Yes')

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

now = [0,0]
time = 0

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

Solution (Python):

import math

lastT, lastX, lastY = 0, 0, 0
flag = "Yes"

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

    

    if ( t - lastT < math.fabs(x - lastX) + math.fabs(y - lastY)
        or ( (t - lastT) - math.fabs(x - lastX) - math.fabs(y - lastY) ) % 2 == 1 ):
        flag = "No"

    lastT = t
    lastX = x
    lastY = y

print(flag)

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

Solution (Python):
from sys import stdin
import sys

n = int(stdin.readline().rstrip())

A = [0, 0, 0]
for i in range(n):
    B = [int(j) for j in stdin.readline().rstrip().split()]

    t = B[0]-A[0]
    x = abs(B[1]-A[1])
    y = abs(B[2]-A[2])

    z = x+y

    if t % 2 == 1:
        if not(z % 2 == 1 and z <= t):
            print("No")
            sys.exit()

    else:
        if not(z % 2 == 0 and z <= t):
            print("No")
            sys.exit()

    A = B

print ("Yes")

Solution (Python):
def main(points):
    points.insert(0, [0, 0, 0])
    for i in range(len(points) - 1):
        p1 = points[i]
        p2 = points[i + 1]
        t = p2[0] - p1[0]
        if not can_reach(p1[1:], p2[1:], t):
            print('No')
            return
    print('Yes')


def can_reach(p1, p2, t):
    length = abs(p1[0] - p2[0]) + abs(p1[1] - p2[1])
    return length <= t and (length - t) % 2 == 0


if __name__ == "__main__":
    points = []
    n = int(input())
    for i in range(n):
        points.append([int(x) for x in input().split(' ')])
    main(points)

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

now_time = 0
now_x = 0
now_y = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    xy_diff = abs(x - now_x) + abs(y - now_y)

    if t - now_time < xy_diff:
        print("No")
        exit()
    if (t - now_time) % 2 == 0:
        if xy_diff % 2 != 0:
            print("No")
            exit()
        else:
            now_time = t
            now_x = x
            now_y = y
    else:
        if xy_diff % 2 != 1:
            print("No")
            exit()
        else:
            now_time = t
            now_x = x
            now_y = y

print("Yes")

Solution (Python):
N = int(input())
P = [[0,0,0]]+[list(map(int,input().split())) for n in range(N)]
ans = "Yes"

for n in range(N):
  dt = P[n+1][0]-P[n][0]
  dx = abs(P[n+1][1]-P[n][1])
  dy = abs(P[n+1][2]-P[n][2]) 
  if dt<dx+dy or dt%2!=(dx+dy)%2:
    ans = "No"

print(ans)

Solution (Python):
from collections import deque
n = int(input())

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

tn, xn, yn = 0, 0, 0
while txy:
    t, x, y = txy.popleft()
    if (abs(xn-x)+abs(yn-y)<=(t-tn)) and (abs(xn-x)+abs(yn-y))%2==(t-tn)%2:
        tn, xn, yn = t, x, y
    else:
        print('No')
        exit()
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, ), *p = [[*map(int, i.split())] for i in open(0)]
t, x, y = 0, 0, 0
for a, b, c in p:
    d = abs(x - b) + abs(y - c) - a + t
    if d <= 0 and d % 2 < 1:
        t, x, y = a, b, c
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
t,x,y = [list(i) for i in zip(*l)]
p = 0
q = 0

for i in range(n):
    z = abs(p - (x[i] + y[i]))
    if ((t[i] - q) - z) % 2 == 0 and (t[i] - q) - z >= 0:
        p = x[i] + y[i]
        q = t[i]
    else:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    pre_t = 0
    pre_x = 0
    pre_y = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        d_dis = abs(x - pre_x) + abs(y - pre_y)
        d_t = abs(t - pre_t)
        if d_dis > d_t:
            print('No')
            sys.exit()
        elif (d_t - d_dis) % 2 == 1:
            print('No')
            sys.exit()
        else:
            pre_t = t
            pre_x = x
            pre_y = y
    print('Yes')

if __name__ == '__main__':
    main()

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

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


now = [0,0]
now_time = 0
for i in range(N):
  left_time = T[i][0] - now_time
  target = [T[i][1],T[i][2]]
  distance = abs(T[i][1]-now[0]) + abs(T[i][2]-now[1])
  if distance <= left_time and distance % 2 == left_time % 2:
    now_time = T[i][0]
    now = target
    
  else:
    print("No")
    sys.exit()

print("Yes")

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

pt = px = py = 0
for i in range(I):
    t, x, y = map(int, input().split())

    costtime = abs(t - pt)
    distance = abs(x - px) + abs(y - py)

    if costtime%2 != distance%2:
        print("No")
        exit()

    if costtime < distance:
        print("No")
        exit()

    pt,px,py = t,x,y

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(" "))
    t.append(tt)
    x.append(xx)
    y.append(yy)

ans = "Yes"
for i in range(n):
    dt = t[i+1] - t[i]
    ddis = abs(x[i + 1] + y[i + 1] - (x[i] + y[i]))
    if not (ddis <= dt and ((dt % 2 == 0 and ddis % 2 == 0) or (dt % 2 == 1 and ddis % 2 == 1))):
        ans = "No"
        break

print(ans)

Solution (Python):
import sys
from math import sqrt
def input(): return sys.stdin.readline().strip()


def main():
    n = int(input())
    possible = True
    pre_t, pre_x, pre_y = 0, 0, 0
    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 and (time - dist) % 2 == 0:
            pre_t, pre_x, pre_y = t, x, y
        else:
            possible = False
            break
    if possible:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
kot="Yes"
at,a1,a2=0,0,0
for i in range(n):
  a=list(map(int,input().split()))
  a[0]=a[0]-at
  a[1]=a[1]-a1
  a[2]=a[2]-a2
  gou=max(a[1]+a[2],(-1*a[1])+a[2],a[1]+(-1*a[2]),(-1*a[1])+(-1*a[2]))
  if a[0]%2!=(gou)%2:
    kot="No"
    break
  if a[0] < gou:
    kot="No"
    break
  at,a1,a2=a
print(kot)

Solution (Python):
N = int(input())
now_t, now_x, now_y = 0, 0, 0

for _ in range(N):
  t, x, y = list(map(int, input().split()))
  distance = abs(now_x - x) + abs(now_y - y)
  has_time = t - now_t
  if (distance - has_time) > 0 or (distance - has_time) % 2:
    print("No")
    break
  now_t, now_x, now_y = t, x, y
else:
  print("Yes")

Solution (Python):

n = int(input())
t_now = 0
pos = [0,0]
l = [list(map(int, input().split())) for _ in range(n)]

for t, x, y in l:
    t_d = t - t_now
    range_move = list(range(-t_d, t_d+1, 2))

    pos_d = (x-pos[0]) + (y-pos[1])

    if pos_d in range_move:
        t_now = t
        pos = [x, y]
    else:
        print('No')
        exit()

print('Yes')

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

t,x,y=0,0,0
F=True
for _ in range(N):
    s,a,b=t,x,y
    t,x,y=map(int,input().split())

    m=abs(x-a)+abs(y-b)
    if not(m<=t-s and (t-s-m)%2==0):
        F=False

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

Solution (Python):
N = int(input())
_t, _x, _y = 0, 0, 0
flg = True
for i in range(N):
    t, x, y = list(map(int, input().split()))
    dt = t - _t
    dd = abs(x - _x) + abs(y - _y)
    if not (dd <= dt and dt % 2 == dd % 2):
        flg = False
    _t, _x, _y = t, x, y
if flg:
    print('Yes')
else:
    print('No')

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

x_defo = 0
y_defo = 0
t_defo = 0
result = 0

for i in range(n):
    dt = t[i] - t_defo
    it = abs(x[i]-x_defo) + abs(y[i]-y_defo)
    if it > dt:
        result = 1
        break
    if it %2 != dt %2:
        result = 1
        break
    else:
        x_defo = x[i]
        y_defo = y[i]
        t_defo = t[i]

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

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

f = True
for i in range(N):
    dt = t[i+1] - t[i]
    dictlist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    
    if dt < dictlist:
        f = False
    if dictlist % 2 != dt % 2:
        f = False

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

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
ct,cx,cy=0,0,0
for t,x,y in l:
    dt=t-ct
    d=abs(cx-x)+abs(cy-y)
    if dt-d<0 or (dt-d)%2==1:
        print('No')
        exit()
    ct,cx,cy=t,x,y
print('Yes')

Solution (Python):
N = int(input())
pt, px, py = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(px - x) + abs(py - y)
    dt = t - pt
    if d <= dt and dt % 2 == d % 2:
        pt, px, py = t, x, y
        continue
    flag = False
    break

if flag:
    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)

flag = True
for i in range(N):
    time = T[i+1]-T[i]
    dist = abs(X[i+1]-X[i])+abs(Y[i+1]-Y[i])
    if time < dist or (dist%2!=time%2):
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

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

for i in range(n):
    dt=t[i+1]-t[i]
    dx=x[i+1]-x[i]
    dy=y[i+1]-y[i]
    dl=abs(dx)+abs(dy)
    if dl<=dt and dt%2==dl%2:
        continue
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):

import math
n = int(input())
txy = [map(int, input().split()) for _ in range(n)]
t, x, y = [list(i) for i in zip(*txy)]

gt = 0
gx = 0
gy = 0

for i in range(n):
    wt = t[i] -gt
    ww = abs(x[i] - gx) + abs(y[i] - gy)
    if (wt < ww) or ((wt - ww) % 2 == 1):
        print("No")
        break

    gt = t[i]
    gx = x[i]
    gy = y[i]

else:
    print("Yes")

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

tn = 0
xn = 0
yn = 0
j = True
for i in range(n):
    td, xd, yd = map(int, input().split())
    t = td - tn
    x = abs(xd - xn)
    y = abs(yd - yn)
    xn = xd
    yn = yd
    tn = td
    if t%2 == (x + y)%2 and (x + y) <= t:
        continue
    j = False
if j:
    print("Yes")
else:
    print("No")

Solution (Python):

import math
n = int(input())
txy = [map(int, input().split()) for _ in range(n)]
t, x, y = [list(i) for i in zip(*txy)]

gt = 0
gx = 0
gy = 0

for i in range(n):
    wt = t[i] -gt
    ww = abs(x[i] - gx) + abs(y[i] - gy)
    if (wt < ww) or ((wt - ww) % 2 == 1):
        print("No")
        break

    gt = t[i]
    gx = x[i]
    gy = y[i]

else:
    print("Yes")

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

t_,x_,y_=(0,0,0)

ans = 'Yes'
for n in range(N):
    t,x,y = list(map(int,input().split()))
    T = t-t_
    manhattan_dist = abs(x-x_)+abs(y-y_)

    if T >= manhattan_dist and manhattan_dist%2 == T%2:
        pass
    else:
        ans='No'
        
    t_,x_,y_ = t,x,y

print(ans)

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

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

Solution (Python):
n = int(input())
l = [[0,0,0]]
for i in range(n):
    t,x,y = map(int,input().split())
    l.append([t,x,y])
for i in range(n):
    t,x,y = l[i][0],l[i][1],l[i][2]
    t_,x_,y_ = l[i+1][0],l[i+1][1],l[i+1][2]
    if t_ - t < (abs(x-x_)+abs(y-y_)) or (t_-t-(abs(x-x_)+abs(y-y_)))%2 != 0:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
l = []
for i in range(n):
    t,x,y = map(int,input().split())
    l.append([t,x,y])
for i in range(n):
    t,x,y = l[i][0],l[i][1],l[i][2]
    if x+y > t or (t-(x+y))%2 != 0:
          print('No')
          exit()
l.sort()
for i in range(n-1):
    t,x,y = l[i][0],l[i][1],l[i][2]
    t_,x_,y_ = l[i+1][0],l[i+1][1],l[i+1][2]
    if t_ - t < (abs(x-x_)+abs(y-y_)):
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
t = [list(map(int,input().split())) for _ in range(n)]
t.insert(0,[0,0,0])
for i in range(1,n+1):
    d_sec = t[i][0] - t[i-1][0]
    d_x = abs(t[i][1]- t[i-1][1])
    d_y = abs(t[i][2]- t[i-1][2])
    d_xy = d_x + d_y
    if (d_sec < d_xy) | (d_sec%2 != d_xy%2):
        print("No")
        break
else:
    print("Yes")

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

t_0 = 0
x_0 = 0
y_0 = 0

can = True

dt = t[0] - t_0
dx = x[0] - x_0
dy = y[0] - y_0
dist = abs(dx) + abs(dy)

if dt >= dist and dt % 2 == dist % 2:
    can = True
else:
    can = False

for i in range(1, n):
    dt = t[i] - t[i - 1]
    dx = x[i] - x[i - 1]
    dy = y[i] - y[i - 1]
    dist = abs(dx) + abs(dy)
    if dt >= dist and dt % 2 == dist % 2:
        can = True
    else:
        can = False
        break

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

pass

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

N=int(input())

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

dtxy = []
for i in range(N):
    dt=txy[i+1][0]-txy[i][0]
    dx=txy[i+1][1]-txy[i][1]
    dy=txy[i+1][2]-txy[i][2]
    ds = dt-abs(dx)-abs(dy)
    if ds<0 or ds%2 !=0:
        print('No')
        exit()
print('Yes')

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

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

flg = True
for i in range(1, n+1):
    dt = txy[i][0] - txy[i-1][0] 
    dx = abs(txy[i][1] - txy[i-1][1])
    dy = abs(txy[i][2] - txy[i-1][2])
    dxdy = dx + dy
    if dt % 2 != dxdy % 2 or dt < dxdy:
        flg = False
        break
print('Yes') if flg else print('No')

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



t_bef=0
x_bef=0
y_bef=0
flag='Yes'

for i in range(1,n+1):
    t,x,y=map(int,input().split())
    dt=t-t_bef
    dist=abs(x-x_bef)+abs(y-y_bef)
    if (dt%2 != dist%2) or dist>dt:
        flag='No'
        break
    t_bef,x_bef,y_bef=t,x,y

print(flag)

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



t_bef=0
x_bef=0
y_bef=0
flag='Yes'

for i in range(1,n+1):
    t,x,y=map(int,input().split())
    dt=t-t_bef
    dist=abs(x-x_bef)+abs(y-y_bef)
    if (dt%2 != dist%2) or dist>dt:
        flag='No'
        
    t_bef,x_bef,y_bef=t,x,y

print(flag)

Solution (Python):
n=int(input())
a=[]
for _ in range(n):
  a.append([int(i) for i in input().split()])
b=[0,0,0]
for i in range(n):
  minC=abs(a[i][1]-b[1])+abs(a[i][2]-b[2])
  if a[i][0]-b[0]<minC or (a[i][0]-b[0]-minC)%2==1:
    print("No")
    break
  b=a[i]
else:
  print("Yes")

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

pos_x=0
pos_y=0
t_now=0
flg = True
for i in range(N):
    t,x,y = map(int,input().split())
    t_del = t-t_now
    res = (t_del-abs(pos_x-x)-abs(pos_y-y))
    if (res>=0) & (res%2==0):
        t_now = t
        pos_x = x
        pos_y=y
        pass
    else:
        flg = False
        break

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

Solution (Python):
def main():
    n = int(input())
    txys = [list(map(int, input().split())) for _ in range(n)]
    txys.insert(0, [0, 0, 0])
    ans = 'Yes'
    for i in range(n):
        time_diff = txys[i+1][0] - txys[i][0]
        manhattan_dis = abs(txys[i][1] - txys[i+1][1]) + abs(txys[i][2] - txys[i+1][2])
        if time_diff < manhattan_dis:
            ans = 'No'
            break
        elif time_diff == manhattan_dis:
            continue
        else:
            if (time_diff - manhattan_dis) % 2 == 0:
                continue
            else:
                ans = 'No'
                break
    print(ans)


if __name__ == "__main__":
    main()

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

now_t = 0
now_xy = 0
for i in range(n):
    t, x, y = map(int, input().split())
    baf = 0
    if not abs((x+y) - now_xy) == t - baf*2 - now_t:
        while t-baf*2-now_t >= 2:
            baf += 1
            if abs((x+y) - now_xy) == t - baf*2 - now_t:
                break
        else:
            print("No")
            exit()
    now_t = t
    now_xy = x + y
print("Yes")

Solution (Python):
N = int(input())
t = 0
x = 0
y = 0
for ti, xi, yi in [map(int, input().split(' ')) for n in range(N)]:
    if not (abs(xi-x)+abs(yi-y) <= ti-t and ti%2 == (xi+yi)%2):
        print('No')
        exit()
    else:
        t = ti
        x = xi
        y = yi
print('Yes')

Solution (Python):
N = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
ans = "Yes"
for _ in range(N):
    t, x, y = map(int, input().split())
    if t - prev_t < abs(prev_x - x) + abs(prev_y - y):
        ans = "No"
    if (abs(prev_x - x) + abs(prev_y - y)) % 2 != (t - prev_t) % 2:
        ans = "No"
    prev_t, prev_x, prev_y = t, x, y
print(ans)

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
st, stx, sty = 0, 0, 0
ans = "Yes"
for t, x, y in txy:
    ta, xa, ya = abs(t - st), abs(x - stx), abs(y - sty)
    if ta >= xa + ya and (
        (ta % 2 == 1 and (xa + ya) % 2 == 1) or (ta % 2 == 0 and (xa + ya) % 2 == 0)
    ):
        st, stx, sty = t, x, y
    else:
        ans = "No"
        break
print(ans)

Solution (Python):


N = int(input())
now_t = 0 
now_x = 0 
now_y = 0 
flag = 0 
for i in range(N):
    t,x,y = map(int,input().split())
    
    
    if abs(x-now_x)+abs(y-now_y)<= abs(t-now_t) and (abs(x-now_x)+abs(y-now_y))%2 == abs(t-now_t)%2:
        now_t = t
        now_x = x
        now_y = y
    else:
        flag += 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
can = True
time = 0
x = 0
y = 0
for _ in range(n):
    t, xx, yy = map(int,input().split())
    distance = abs(x-xx) + abs(y - yy)
    difft = t - time
    if difft < distance:
        can = False
        break
    if (distance - difft) % 2 == 1:
        can = False
        break


    x = xx
    y = yy
    time = t
print("Yes" if can else "No")

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

Solution (Python):
N = int(input())
now_t = 0
now_x = 0
now_y = 0
flag = 0
for i in range(N):
    t,x,y = map(int,input().split())
    if abs(x-now_x)+abs(y-now_y)<= abs(t-now_t) and (abs(x-now_x)+abs(y-now_y))%2 == abs(t-now_t)%2:
        now_t = t
        now_x = x
        now_y = y
    else:
        flag += 1
        break
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

def f(x1,y1,x2,y2,t):
    l = abs(x1-x2)+abs(y1-y2)
    if l <= t:
        if l%2 == t%2:
            return True
    return False

if __name__ == "__main__":
    n = I()
    t = [0]
    x = [0]
    y = [0]
    for i in range(n):
        a,b,c = I2()
        t.append(a)
        x.append(b)
        y.append(c)
    for i in range(n):
        
        if not f(x[i],y[i],x[i+1],y[i+1],t[i+1]-t[i]):
            print("No")
            exit()
    print("Yes")

Solution (Python):
N = int (input ())
t2 = 0
x2 = 0
y2 = 0
ans = 'Yes'
for i in range (N):
    t,x,y = map(int, input().split())
    if abs(x+y-x2-y2) <= t-t2:
        if ((abs(x2+y2-x-y))-(t-t2)) % 2 == 1:
            ans = 'No'
            break
    else:
        ans = 'No'
        break
    t2 = t
    x2 = x
    y2 = y
print (ans)

Solution (Python):
n = int(input())
curt, curx, cury = 0, 0, 0
ans = 'Yes'
for _ in range(n):
   t, x, y = map(int, input().split())
   d = abs(x - curx) + abs(y - cury)
   if d > (t - curt) or (t - curt) % 2 != d % 2:
      ans = 'No'
      break
   curt, curx, cury = t, x, y

print(ans)

Solution (Python):
n = int(input())
t = []
p = [0, 0, 0]
while(n):
    a, b, c = input().split(' ')
    t.append([int(a), int(b), int(c)])
    n-=1
for i in t:
    while(p[0] < i[0]):
        p[0]+=1
        if i[1] > p[1]:
            p[1]+=1
        elif i[2] > p[2]:
            p[2]+=1
        elif i[1] < p[1]:
            p[1]-=1
        elif i[2] < p[2]:
            p[2]-=1
        else:
            p[1]-=1
    if p != i:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
 
ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

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

ti,xi,yi = 0,0,0
found = True
for _ in range(n):
    t, x, y = map(int, input().split())
    root = abs(x-xi)+abs(y-yi)
    if root > (t-ti) or (t-ti-root)&1:
        found = False
    ti,xi,yi = t,x,y  
    
print("Yes" if found else "No")

Solution (Python):
n = int(input())
found = True
ti,xi,yi = 0,0,0
for _ in range(n):
  t,x,y = map(int,input().split())
  rt = abs(x-xi)+abs(y-yi)
  if rt > (t-ti) or (t-ti-rt)&1:
    found = False
  ti,xi,yi = t,x,y
print("Yes" if found else "No")

Solution (Python):
n = int(input())
 
s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")

Solution (Python):
from sys import exit

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

l.insert(0, [0, 0, 0])
for i in range(n):
    t1, x1, y1 = l[i]
    t2, x2, y2 = l[i+1]
    d = abs(x2 - x1) + abs(y2 - y1)
    t = t2 - t1
    if d > t or (d + t) % 2 == 1:
        print('No')
        exit()

print('Yes')

Solution (Python):
N=int(input())
t0=0
x0=0
y0=0
 
for i in range(N):
  t1,x1,y1=map(int,input().split())
  AbsT=t1-t0
  AbsX=abs(x1-x0)
  AbsY=abs(y1-y0)
  if AbsX+AbsY>AbsT or (AbsX+AbsY-AbsT)%2!=0:
    print("No")
    break
  else:
      x0=x1
      y0=y1
      t0=t1

else:
  print("Yes")

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

for i in range(1, n+1):
    dt = l[i][0] - l[i-1][0]
    dx = abs(l[i][1] - l[i-1][1])
    dy = abs(l[i][2] - l[i-1][2])
    
    tmp = dt - dx - dy
    if tmp < 0 or tmp % 2 == 1:
        print('No')
        break
else:
    print('Yes')

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

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

for i in range(n):
    if i>0:
        distance = abs(data[i][1]-data[i-1][1])+abs(data[i][2]-data[i-1][2])
        time = abs(data[i][0]-data[i-1][0])
    else:
        distance = abs(data[i][1])+abs(data[i][2])
        time = abs(data[i][0])
    
    if distance <= time:
        if (data[i][0] + data[i][1] + data[i][2])% 2 == 0:
            continue
        else:
            break
    else:
        break
else:
    print("Yes")
    sys.exit()

print("No")

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

for i in range(n):
    if i>0:
        distance = abs(data[i][1]-data[i-1][1])+abs(data[i][2]-data[i-1][2])
        time = abs(data[i][0]-data[i-1][0])
    else:
        distance = abs(data[i][1])+abs(data[i][2])
        time = abs(data[i][0])
    
    if distance <= time:
        if (data[i][0] + data[i][1] + data[i][2])% 2 == 0:
            continue
        else:
            break
    else:
        break
else:
    print("Yes")
    sys.exit()

print("No")

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

s = 0
p = 0
for _ in range(n):
  t,x,y = map(int, input().split())
  s = t - s
  p = abs((x+y)-p)
  if s < p:
    print("No")
    exit()
  elif s%2 != p%2:
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())
nt, nx, ny = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    now = t-nt
    location = abs(nx-x) + abs(ny-y)
    if location <= now and (now-location)%2 == 0:
        nt, nx, ny = t, x, y
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
nt, nx, ny = 0, 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    now = t-nt
    location = abs(nx-x) + abs(ny-y)
    if location <= now and (now-location)%2 == 0:
        nt, nx, ny = t, x, y
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
txy = [0]*n

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

t_ = 0
x_ = 0
y_ = 0

for i in range(n):
  dx = 0
  dy = 0
  t = txy[i][0]
  x = txy[i][1]
  y = txy[i][2]
  dx = abs(x-x_)
  dy = abs(y-y_)
  d = dx + dy
  if d == abs(t - t_):
    t_ = t
    x_ = x
    y_ = y
  elif d > abs(t - t_):
    print("No")
    exit()
  else:
    if (abs(t - t_)-d)%2 == 0:
      t_ = t
      x_ = x
      y_ = y      
    else:
      print("No")
      exit()
      
print("Yes")

Solution (Python):
N = int(input())
t, x, y = [0]*3
for _ in range(N):
  t_, x_, y_ = map(int, input().split())
  dis = abs(x_ - x) + abs(y_ - y)
  dt = t_ - t
  if dis > dt:
    print("No")
    exit()
  if dis%2 == dt%2:
    t, x, y = t_, x_, y_
  else:
    print("No")
    exit()
print("Yes")

Solution (Python):
n = int(input())
tb, xb, yb = 0, 0, 0
for _ in range(n):
    ta, xa, ya = list(map(int, input().split()))
    tdiff = abs(ta - tb)
    mdiff = abs(xa - xb) + abs(ya - yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
        
    tb, xb, yb = ta, xa, ya
print('Yes')

Solution (Python):
n = int(input())
tb,xb,yb = 0,0,0
for _ in range(n):
    ta,xa,ya = list(map(int, input().split()))
    tdiff = abs(ta-tb)
    mdiff = abs(xa-xb) + abs(ya-yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
    
    tb,xb,yb = ta,xa,ya

print('Yes')

Solution (Python):
n = int(input())
tb,xb,yb = 0,0,0
for _ in range(n):
    ta,xa,ya = list(map(int, input().split()))
    tdiff = abs(ta-tb)
    mdiff = abs(xa-xb) + abs(ya-yb)
    if tdiff < mdiff or (tdiff + mdiff) & 1:
        print('No')
        exit()
    
    tb,xb,yb = ta,xa,ya

print('Yes')

Solution (Python):
n = int(input());
told,xold,yold = 0,0,0; 
ans = 'Yes';
for i in range(n) :
    tnew,xnew,ynew = [int(x) for x in input().split()];
    dis = abs(xnew-xold) + abs(ynew-yold);
    diff = tnew - told;
    if (diff - dis)%2 == 1 or diff < dis :
        ans = 'No';
        break;
    else :
        told,xold,yold = tnew,xnew,ynew;

print(ans);

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

t = [0]*1001001
x = [0]*1001001
y = [0]*1001001


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

flag = 1    
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:
        flag = 0
    if dist % 2 != dt % 2:
        flag = 0

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