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

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






def manhattan(p, q):
    return abs(p[0] - q[0]) + abs(p[1] - q[1])

N = int(input().strip())
ts = [None for _ in range(N+1)]
ps = [None for _ in range(N+1)]

ts[0] = 0
ps[0] = (0, 0)

for n in range(1, N+1):
    t, p, q = tuple(map(int, input().strip().split()))
    ts[n] = t
    ps[n] = (p, q)

for n in range(N):
    dt = ts[n+1] - ts[n]
    dist = manhattan(ps[n+1], ps[n])
    if (dist > dt) or (dt % 2) != (dist % 2):
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())


def main():
    N = ii()
    txy = [list(mi()) for i in range(N)]
    t, x, y = [list(i) for i in zip(*txy)]
    if t[0]-x[0]-y[0] < 0 or (t[0]-x[0]-y[0])%2:
        print('No')
        return
    for i in range(N-1):
        k = t[i+1]-t[i]-abs(x[i+1]-x[i])-abs(y[i+1]-y[i])
        if k < 0 or k%2:
            print('No')
            return
    print('Yes')
    


if __name__ == '__main__':
    main()

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

Solution (Python):
N = int(input())
T = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
normal = True
def judge(a, b):
  m = b[0]-a[0]-abs(b[1]-a[1])-abs(b[2]-a[2])
  if m>=0 and m%2==0:
    return True
  else:
    return False
for i in range(N):
  if judge(T[i], T[i+1]):
    pass
  else:
    normal = False
    break
print("Yes" if normal else "No")

Solution (Python):
from pprint import pprint
 


 
n = int(input())


t, x, y = [0], [0], [0]
d = [0]
dd = [0]
td = [0]
 
for i in range(1, n + 1):
    _t, _x, _y = map(int, input().split(' '))
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
    d.append(abs(x[i] - x[0]) + abs(y[i] - y[0]))
    dd.append(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
    td.append(t[i] - t[i-1])
 


movable = [False] * (n + 1)
 
for i in range(n + 1):
    if d[i] <= t[i] and (t[i] % 2 == d[i] % 2) and dd[i] <= td[i]:
        movable[i] = True
 
if all(movable):
    res = 'Yes'
else:
    res = 'No'
 


print(res)

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

prev_t = 0
prev_x = 0
prev_y = 0

for i in range(N):
    t,x,y = map(int,input().split())
    dist = abs(x-prev_x)+ abs(y-prev_y)
    if dist > (t-prev_t) or (dist+(t - prev_t))%2:
        print("No")
        exit()
    prev_t = t
    prev_x = x
    prev_y = y

print("Yes")

Solution (Python):
from pprint import pprint




n = int(input())


t, x, y = [0], [0], [0]
d = [0]
dd = [0]
td = [0]

for i in range(1, n + 1):
    _t, _x, _y = map(int, input().split(' '))
    t.append(_t)
    x.append(_x)
    y.append(_y)

    d.append(abs(x[i] - x[0]) + abs(y[i] - y[0]))
    dd.append(abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]))
    td.append(t[i] - t[i-1])



movable = [False] * (n + 1)

for i in range(n + 1):
    if d[i] <= t[i] and (t[i] % 2 == d[i] % 2) and dd[i] <= td[i]:
        movable[i] = True

if all(movable):
    res = 'Yes'
else:
    res = 'No'



print(res)

Solution (Python):
n=int(input())
x=0
y=0
t=0
fl=True
for i in range(n):
  nt,nx,ny=map(int,input().split())
  dist=abs(x-nx)+abs(y-ny)
  if (nt-t)%2!=dist%2 or (nt-t)<dist:
    print("No")
    break
  x,y=nx,ny
  t=nt
else:
  print("Yes")

Solution (Python):
import sys

N = int(input())
now = [0]*3
for i in range(N):
    a, b, c = map(int, input().split())
    val0 = a-now[0]
    val1 = abs(b-now[1]) + abs(c-now[2])
    
    while val1 < val0:
        val1 += 2
    if val1 != val0:
        print('No')
        sys.exit()
    now = [a, b, c]
print('Yes')

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

def main():
    n = int(input())
    pos = (0, 0)
    time_before = 0
    can = True

    for i in range(n):
        t, x, y = map(int, input().split())
        dist = abs(pos[0] - x) + abs(pos[1] - y)
        time = t - time_before
        
        if dist > time:
            can = False
            break
        if (dist % 2 == 0 and time % 2 != 0) or (dist % 2 != 0 and time % 2 == 0):
            can = False
            break
        time_before = t
        pos = (x, y)
    print('Yes' if can else 'No')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
now = [0, 0, 0]
def ng():
  print('No')
  exit()
for i in range(n):
  t, x, y = map(int, input().split())
  if t % 2 != (x + y) % 2:
    ng()
  if abs(x - now[1]) + abs(y - now[2]) > t - now[0]:
    ng()
  now = [t, x, y]
print('Yes')

Solution (Python):
n=int(input())
x=0
y=0
t=0
fl=True
for i in range(n):
  nt,nx,ny=map(int,input().split())
  dist=abs(x-nx)+abs(y-ny)
  if (nt-t)%2!=dist%2 or (nt-t)<dist:
    print("No")
    break
  x,y=nx,ny
  t=nt
else:
  print("Yes")

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

l = [[0, 0, 0]]
l.extend(L)

flag = True
for c in range(1, len(l)):
    dt = l[c][0] - l[c-1][0]
    dist = abs(l[c][1] - l[c-1][1]) + abs(l[c][2] - l[c-1][2])

    if dist > dt or (dist % 2) != (dt % 2):
        flag = False

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

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

Solution (Python):



n = int(input())
pre = [0, 0, 0]  
for i in range(n):
    t, x, y = map(int, input().split())
    t -= pre[0]
    x -= pre[1]
    y -= pre[2]
    if t < abs(x) + abs(y) or (abs(x) + abs(y)) % 2 != t % 2:
        print("No")
        exit()
    pre = [t, x, y]
print("Yes")

Solution (Python):
N = int(input())
tc, xc, yc = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t, x, y = map(int, input().split())
  if (t - tc - abs(x-xc) - abs(y-yc)) % 2 == 1 or t - tc - abs(x-xc) - abs(y-yc) < 0:
    ans = 'No'
    break
  tc, xc, yc = t, x, y
print(ans)

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n = int(input())
T = []
X = []
Y = []
for i in range(n):
    t,x,y = readInts()
    T.append(t)
    X.append(x)
    Y.append(y)
cx,cy,ct = 0,0,0
for i in range(n):
    dist_place = abs(X[i] - cx) + abs(Y[i] - cy)
    dist_time = abs(T[i] - ct)
    if dist_time >= dist_place and (dist_time - dist_place) % 2 == 0:
        cx = X[i]
        cy = Y[i]
        ct = T[i]

        pass
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
tc = 0
xc, yc = 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x-xc)+abs(y-yc)
    if d > t-tc:
        print('No')
        exit()
    else:
        if (t-tc-d)%2 != 0:
            print('No')
            exit()
    xc, yc, tc = x, y, t
else:
    print('Yes')

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

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

t_0 = 0
x_0 = 0
y_0 = 0
flag = True

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

    if not (abs(x-x_0) + abs(y-y_0) <= abs(t-t_0) and (abs(x-x_0)+abs(y-y_0))%2 == abs(t-t_0)%2):
        flag = False
    x_0 = x
    y_0 = y
    t_0 = t

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

Solution (Python):
n = int(input())
tp, xp, yp = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    td = t - tp
    xd = x - xp
    yd = y - yp
    if td < abs(xd) + abs(yd) or (td - abs(xd) - abs(yd)) % 2 == 1:
        print('No')
        break
    tp = t
    xp = x
    yp = y
else:
    print('Yes')

Solution (Python):
N=int(input())
T0,X0,Y0=0,0,0
for i in range(N):
  T,X,Y=map(int,input().split())
  tmp=T-T0
  if abs(X-X0)+abs(Y-Y0)>tmp:
    print('No')
    exit()
  else:
    Par=tmp%2
    if Par==1:
      if (abs(X-X0)+abs(Y-Y0))%2==0:
        print('No')
        exit()        
    else:
      if (abs(X-X0)+abs(Y-Y0))%2==1:
        print('No')
        exit()
  T0,X0,Y0=T,X,Y
print('Yes')

Solution (Python):
n = int(input())
now, nx, ny = [0, 0, 0]

f = True
for i in range(n):
    t, x, y = map(int, input().split())
    mdist = abs(nx-x) + abs(ny-y)
    if t - now < mdist:
        f = False
        break
    elif mdist%2 != (t-now)%2:
        f = False
        break
    else:
        now = t
        nx, ny = x, y
if f:
    print('Yes')
else:
    print('No')

Solution (Python):









import os
import sys




def main():
    n = int(input())
    current = [0, 0, 0]
    flag = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        if flag == 1:
            continue
        judge = int(abs(x-current[1]))+int(abs(y-current[2]))

        if t-current[0] < judge:
            flag = 1
        elif t-current[0] == judge:

            current[0] = t
            current[1] = x
            current[2] = y
        else:
            ama = t-current[0]
            if (ama-judge)%2 != 0:
                flag = 1
            else:
                current[0] = t
                current[1] = x
                current[2] = y

    if flag == 0:
        print("Yes")
    if flag == 1:
        print("No")



if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
T = [0 for _ in range(N)]
X = [0 for _ in range(N)]
Y = [0 for _ in range(N)]
count = 0
t = 0
x = 0
y = 0

for i in range(N):
    T[i], X[i], Y[i] = map(int, input().split())
    t = abs(T[i] -t)
    x = abs(X[i] -x)
    y = abs(Y[i] -y)
    if t>= x+y and (t-(x+y))%2 == 0:
        count +=1
    else:
        break
    
    
    
    
    
    

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

Solution (Python):
N = int(input())
txy = [tuple(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for i in range(N):
    nt,nx,ny = txy[i]
    t = nt-t
    x = nx-x
    y = ny-y
    d = abs(x)+abs(y)
    if t < d:
        print("No")
        exit(0)
    elif (t-d)%2 == 1:
        print("No")
        exit(0)
    t,x,y = txy[i]
print("Yes")

Solution (Python):
N=int(input())
flag='Yes'
p,q,r=0,0,0
for _ in range(N):
  t,x,y=map(int,input().split())
  a=abs(x-p)+abs(y-q)
  e=t-r
  if a<=e:
    if (e-a)%2!=0:
      flag='No'
      break
  else:
    flag='No'
    break
  p,q,r=x,y,t
print(flag)

Solution (Python):
N=int(input())
t_pre=0
x_pre=0
y_pre=0

for i in range(N):
    t,x,y = map(int,input().split())
    t_af=t-t_pre
    x_af=x-x_pre
    y_af=y-y_pre
    if (abs(x_af+y_af)<=t_af) & ((x_af+y_af+t_af)%2 == 0):
      t_pre=t
      x_pre=x
      y_pre=y
      continue
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
TP = [[0, 0, 0]]
for _ in range(n):
    TP.append(list(map(int, input().split())))
for i in range(1, n + 1):
    td = TP[i][0] - TP[i-1][0]
    pd = abs(TP[i][1] - TP[i-1][1]) + abs(TP[i][2] - TP[i-1][2])
    if td >= pd and td % 2 == pd % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
now_t, now_x, now_y = 0, 0, 0
for i in range(N):
    next_t, next_x, next_y = map(int, input().split())
    distance = abs(next_x - now_x) + abs(next_y - now_y)
    spent_time = next_t - now_t
    if spent_time < distance or distance % 2 != spent_time % 2:
        print('No')
        exit()
    now_t, now_x, now_y = next_t, next_x, next_y
print('Yes')

Solution (Python):
N = int(input())
xc, yc, tc = 0, 0, 0
ans = 'Yes'
for i in range(N):
  t, x, y = map(int, input().split())
  if (t - tc - abs(x-xc) - abs(y-yc)) % 2 == 0 and t - tc - abs(x-xc) - abs(y-yc) >= 0:
    xc, yc, tc = x, y, t
  else:
    ans = 'No'
    break
print(ans)

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

T=X=Y=0
ok = True
for t,x,y in txy:
  if abs(X-x)+abs(Y-y) <= t-T:
    if (t-T)%2 == 0:
      if (abs(X-x)+abs(Y-y))%2!=0:
        ok = False
        break
    else:
      if (abs(X-x)+abs(Y-y))%2==0:
        ok = False
        break
  else:
    ok = False
    break
  T,X,Y = t,x,y
print("Yes" if ok else "No")

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

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

x_dif = t_list[0][1]
y_dif = t_list[0][2]
t_dif = t_list[0][0]
if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
    pass
else:
    print('No')
    exit()
for i in range(n-1):
    x_dif = abs(t_list[i+1][1]-t_list[i][1])
    y_dif = abs(t_list[i+1][2]-t_list[i][2])
    t_dif = t_list[i+1][0]-t_list[i][0]
    
    if x_dif + y_dif <= t_dif and (x_dif+y_dif)%2 == t_dif%2:
        pass
    else:
        print('No')
        exit()
print('Yes')

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

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

t_0 = 0
x_0 = 0
y_0 = 0

for t,x,y in txy:
    dt = t - t_0
    dx = x - x_0
    dy = y - y_0
    if (abs(dx) + abs(dy))%2 == dt%2 and (abs(dx)+abs(dy)) <= dt:
        t_0 = t
        x_0 = x
        y_0 = y
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()


def solve():
    tc, xc, yc = 0, 0, 0
    for i in range(N):
        t, x, y = inm()
        d = abs(xc - x) + abs(yc - y)
        if d > (t - tc):
            return False
        if ((t - tc) - d) % 2 == 1:
            return False
        tc, xc, yc = t, x, y

    return True


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

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

Solution (Python):
import sys
n=int(input())
currtime=0
currx=0
curry=0
for i in range(n):
  t,x,y=map(int,input().split())
  if abs(y-curry)+abs(x-currx)<=t-currtime and (abs(y-curry)+abs(x-currx))%2==(t-currtime)%2:
    currx=x
    curry=y
    currtime=t
  else:
    print('No')
    sys.exit()
print('Yes')

Solution (Python):
n=int(input())
old_t = 0
old_x = 0
old_y = 0
for i in range(n):
  t, x, y = map(int, input().split())
  if (t - old_t) < abs(x-old_x)+abs(y-old_y) or (t - old_t)%2 != (abs(x-old_x)+abs(y-old_y))%2:
    print("No")
    break
  old_t, old_x, old_y = t, x, y
else:
  print("Yes")

Solution (Python):
N = int(input())
tpr, xpr, ypr = 0, 0, 0
count = 0
for i in range(N):
    t, x, y = map(int, input().split())
    d = abs(x-xpr) + abs(y-ypr)
    n = ((t-tpr) - d) / 2
    if n >= 0 and n % 1 == 0:
        count += 1
    tpr, xpr, ypr = t, x, y
if count == N:
    print("Yes")
else:
    print("No")

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

now_x, now_y = 0, 0
pre_t = 0

for t, x, y in txy:
    walk = abs(now_x - x) + abs(now_y - y)
    if t - pre_t < walk:
        print('No')
        exit()
    if (t-pre_t) % 2 != walk % 2:
        print('No')
        exit()
    now_x = x
    now_y = y
    pre_t = t

print('Yes')

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

Solution (Python):
n = int(input())
s = [list(map(int,input().split())) for _ in range(n)]
now = 0
now_t = 0
flag = 1
for i in range(n):
    t,x,y = s[i][0],s[i][1],s[i][2]
    next = x+y
    dist = abs(next - now)
    time = t - now_t
    if dist == 0 and time == 1:
        print('No')
        exit()
    if dist > time:
        print('No')
        exit()
    elif dist == time:
        now_t = t
        now = next
    else:
        if abs(dist - time) % 2 == 0:
            now_t = t
            now = next
        else:
            print('No')
            exit()
print('Yes')

Solution (Python):


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

dt = [-1 for _ in range(n)]
dx = [-1 for _ in range(n)]
dy = [-1 for _ in range(n)]
for i in range(n):
    if i == 0:
        dt[0] = t[0]
        dx[0] = x[0]
        dy[0] = y[0]
    else:
        dt[i] = t[i] - t[i-1]
        dx[i] = x[i] - x[i-1]
        dy[i] = y[i] - y[i-1]

ok = True
for i in range(n):
    tr = dt[i]%2
    pr = (dx[i]+dy[i])%2
    if (tr == pr) and (dt[i] >= abs(dx[i])+abs(dy[i])):
        pass
    else:
        ok = False

        break

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

Solution (Python):
from sys import stdin
data = stdin.readlines()

N = int(data[0])
l = [0, 0]
i = 1
while i <= N:
    l.append(int(data[i].split()[0]))
    l.append(int(data[i].split()[1])+int(data[i].split()[2]))
    i += 1

def check(x):
    diffrent_time = l[2*x] - l[2*x-2]
    diffrent_place = abs(l[2*x+1] - l[2*x-1])
    return diffrent_time % 2 == diffrent_place % 2 and diffrent_time >= diffrent_place

count = 0
i = 1
while i <= N:
    if check(i) == False:
        count = 1
    i += 1
if count == 0:
    print("Yes")
elif count == 1:
    print("No")

Solution (Python):
N=int(input())
pret=0
prex=0
prey=0
for i in range(N):
    t,x,y=map(int, input().split())
    d=abs(x-prex)+abs(y-prey)
    dt=t-pret
    if dt >= d and (dt-d)%2==0:
        prex=x
        prey=y
        pret=t
    else:
        
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]
stxy = sorted(txy, key=lambda x:(x[0]))

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

for i in range(1, N+1):
    if stxy[i][0] - stxy[i-1][0] < abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2]):
        print("No")
        exit()
    elif (stxy[i][0] - stxy[i-1][0] - (abs(stxy[i][1]-stxy[i-1][1]) + abs(stxy[i][2]-stxy[i-1][2])))%2 == 1:
        print("No")
        exit()

print("Yes")

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

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

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

flag = True
for i in range(1,n+1):

    if (t[i]-t[i-1])%2 != (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2 or (abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))>t[i]-t[i-1]:
        flag = False


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

Solution (Python):
n = int(input())
plcs = [list(map(int,input().split())) for _ in range(n)]
A = [0, 0, 0]
for i in range(n):
    A = [plcs[i][j] - A[j] for j in range(3)]
    if A[0] >= abs(A[1]) + abs(A[2]) and plcs[i][0] % 2 == (abs(plcs[i][1]) + abs(plcs[i][2])) % 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

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

Solution (Python):
n = int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):
    t[i],x[i],y[i]=map(int, input().split())
    
for i in range(1,n+1):
    time=t[i]-t[i-1]
    trip=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    if time<trip:
        print("No")
        exit()
    else:
        extra=time-trip
        if extra%2!=0:
            print("No")
            exit()

print("Yes")

Solution (Python):
N = int(input())
t, x, y = 0, 0, 0
for _ in range(N):
	_t, _x, _y = map(int, input().split())
	d_xy = abs(x - _x) + abs(y - _y)
	d_t = _t - t
	if d_xy <= d_t and d_xy%2 == d_t%2:
		pass
	else:
		print("No")
		exit()
	t, x, y = _t, _x, _y
print("Yes")

Solution (Python):
n=int(input())
l = [list(map(int, input().split())) for _ in range(n)]
l.insert(0,[0,0,0])
a,x,y = zip(*l)

for i in range(n):
  count=a[i+1]-a[i]
  x_len=abs(x[i+1]-x[i])
  y_len=abs(y[i+1]-y[i])
  
  if (x_len+y_len)>count:
    print('No')
    exit()
  elif (count-(x_len+y_len))%2!=0:
    print('No')
    exit()
  else:
    continue
else:
  print('Yes')

Solution (Python):
n = int(input())
now_t,now_x,now_y = 0,0,0
for i in range(n):
  t,x,y = map(int,input().split())
  time = t-now_t
  distance = abs(x-now_x)+abs(y-now_y)
  if distance <= time and (time-distance)%2 == 0:
    now_t,now_x,now_y = t,x,y
  else:
    print('No')
    exit()
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())

"""
t = [0, 3, 6]
x = [0, 1, 1]
y = [0, 2, 1]
"""

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 (dx + dy) > dt:
        print("No")
        exit()

    
    if (dt - (dx + dy)) % 2 != 0:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys


class Point(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __eq__(self, other):
        return self.x == other.x and self.y == other.y


def can_move(start, end, time):

    d_x = end.x - start.x
    d_y = end.y - start.y
    if abs(d_x) + abs(d_y) > time:
        return False
    elif abs(d_x) + abs(d_y) == time:
        return True
    else:
        if (abs(d_x) + abs(d_y) - time) % 2 == 0:
            return True
        else:
            return False


if __name__ == "__main__":
    N = int(input())
    prev_point = Point(0, 0)
    prev_time = 0
    for _ in range(N):
        t, x, y = [int(x) for x in input().split(" ")]
        if not can_move(prev_point, Point(x, y), t - prev_time):
            print("No")
            sys.exit(0)
        else:
            prev_time = t
            prev_point = Point(x, y)
    print("Yes")

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

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

Solution (Python):
def main():
    n=int(input())
    nowt, nowx, nowy = (0, 0, 0)
    is_ok = True
    for _ in range(n):
        t,x,y = map(int,input().split())
        if is_ok:
            dt = t - nowt
            d = abs(x-nowx) + abs(y-nowy)
            nowx, nowy, nowt = x, y, t
            if dt < d:
                is_ok = False
            elif (dt - d) % 2 != 0:
                is_ok = False
    if is_ok:
        print("Yes")
    else:
        print("No")
    
if __name__ == "__main__":
    main()

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

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


def solve():
    former = [0,0,0]
    for a in Z:
        distance = abs(a[1]-former[1])+abs(a[2]-former[2])
        if distance > a[0] - former[0]:
            print("No")
            return
        if (a[0]-former[0]) % 2 != distance % 2:
            print("No")
            return
        former = a
    print("Yes")

solve()

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

x,y=0,0
t=0
flag=True

for i in range(n):
    if abs(l[i][1]-x)+abs(l[i][2]-y)<=(l[i][0]-t) and ((l[i][0]-t)-abs(l[i][1]-x)+abs(l[i][2]-y))%2==0:
        x=l[i][1]
        y=l[i][2]
        t=l[i][0]
    else:
        flag=False
if flag:
    print("Yes")
else:
    print("No")

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

tx = 0
ty = 0
tt = 0

for i in range(n):
    dx = abs(ab[i][1] - tx)
    dy = abs(ab[i][2] - ty)
    dt = ab[i][0] -tt
    dd = dt- (dx+dy)
    if dd % 2 ==0 and dd>=0:
        tx = ab[i][1]
        ty = ab[i][2]
        tt = ab[i][0]

    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())
  if not(abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2):
    print("No")
    exit()
  t,x,y = nt,nx,ny
print("Yes")

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

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

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

flag = 0

for n in range(1,N+1):
  if txy[n][0] % 2 != (txy[n][1] + txy[n][2])%2 or \
  abs(txy[n][0] - txy[n-1][0]) < abs(txy[n][1] - txy[n-1][1]) + abs(txy[n][2] - txy[n-1][2]):
    flag = 1
    break

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

Solution (Python):
N = int(input())
ans = True
t1,x1,y1 = 0,0,0
for i in range(N):
    t2,x2,y2 = map(int, input().split())
    if t2-t1 >= abs(x2-x1)+abs(y2-y1) and ((t2-t1)-(abs(x2-x1)+abs(y2-y1)))%2 == 0:
        None
    else:
        ans = False
        break
    t1,x1,y1 = t2,x2,y2
    
print("Yes" if ans==True else "No")

Solution (Python):
N = int(input())
x = [list(map(int,input().split())) for i in range(N)]
x[0:0] =[[0,0,0]]
can = True
for i in range(N):
    max_dis = x[i+1][0]-x[i][0]
    dis = abs(x[i+1][1]-x[i][1])+abs(x[i+1][2]-x[i][2])
    if(dis>max_dis or dis%2 != max_dis%2):
        can = False
        break
print("Yes" if can == True else "No")

Solution (Python):
n=int(input())
sx,sy=0,0
f=True
t1=0
for i in range(n):
    t2,gx,gy=map(int,input().split())
    a=abs(sx-gx)+abs(sy-gy)
    t=t2-t1
    if a>t:
        f=False
    elif (a-t)%2==1:
        f=False
    sx,sy=gx,gy
    t1=t2
if f:
    print("Yes")
else:
    print("No")

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

x_old, y_old, t_old = 0, 0, 0

for _ in range(n):
    
    t, x, y = map(int, input().split())
    d = (t - t_old) - abs(x - x_old) - abs(y - y_old)
    if d >= 0 and d % 2 == 0:
        x_old, y_old, t_old = x, y, t
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
n = int(input())
t_pre = 0
x_pre = 0
y_pre = 0
ans = "Yes"

for _ in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - x_pre) + abs(y - y_pre)
    t_interval = t - t_pre
    if d <= t_interval and (t_interval - d) % 2 == 0:
        t_pre = t
        x_pre = x
        y_pre = y
    else:
        ans = "No"
        break

print(ans)

Solution (Python):
import copy
n = int(input())
X = 0
Y = 0
T = 0
ans = 'Yes'
for i in range(n):
    t, x, y = map(int, input().split())

    res = t - (T + abs(x -X) + abs(y - Y))
    if res >= 0 and res % 2 == 0:
        ans = 'Yes'
    else:
        ans = 'No'
        break
    X = copy.copy(x)
    Y = copy.copy(y)
    T = copy.copy(t)
print(ans)

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

now_t=0
now_x=0
now_y=0

for nt,nx,ny in l:
  d_dist=abs(nx-now_x)+abs(ny-now_y)
  d_t=nt-now_t
  if d_dist>d_t or (d_t-d_dist)%2==1:
    print('No')
    exit()
  now_t=nt
  now_x=nx
  now_y=ny

print('Yes')

Solution (Python):



import os
import sys





__author__ = 'acto_mini'
__date__ = "2020/06/08"


def main():
    n = int(input())
    t_prev = 0
    x_prev = 0
    y_prev = 0
    for i in range(n):
        t, x, y = map(int, input().split())
        dt = t - t_prev
        dist = abs(x - x_prev) + abs(y - y_prev)
        if dt < dist or ((dt % 2) != (dist % 2)):
            print("No")
            exit()
        t_prev, x_prev, y_prev = t, x, y

    print("Yes")
    return


if __name__ == '__main__':
    main()

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

x_now, y_now, t_now = 0, 0, 0

for i in range(n):
    t, x, y = map(int, input().split())
    distance = (t -t_now) - abs(x-x_now) - abs(y-y_now)
    if distance >= 0 and distance % 2 == 0:
        x_now,y_now,t_now = x,y,t
    else:
        print('No')
        exit()

print('Yes')

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

def enable_move(old_pos, new_pos):
    old_t, old_x, old_y = old_pos
    new_t, new_x, new_y = new_pos
    t = new_t - old_t
    d = abs(new_x - old_x) + abs(new_y - old_y)
    if t < d:
        return False
    return ((t - d) % 2 == 0)

ans = "Yes"
old_pos = [0, 0, 0]
for _ in range(n):
    new_pos = [int(s) for s in input().split()]
    if not enable_move(old_pos, new_pos):
        ans = "No"
        break
    old_pos = new_pos
print(ans)

Solution (Python):
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


N = I()
prev_t = 0
prev_x = 0
prev_y = 0
for i in range(N):
    t, x, y = LI()
    if abs(prev_x-x) + abs(prev_y-y) > (t - prev_t) or (abs(prev_x-x) + abs(prev_y-y) + (t - prev_t)) % 2:
        print('No')
        exit()
    prev_t = t
    prev_x = x
    prev_y = y
print('Yes')