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

N = int(input())

t1, x1, y1 = 0, 0, 0

for i in range(N):
    t, x, y = map(int, input().split())
    dx = abs(x - x1)
    dy = abs(y - y1)
    dt = t - t1
    d = dx + dy
    

    if (d <= dt) & (dt % 2 == d % 2):
        pass
    else:
        print("No")
        exit()

    t1, x1, y1 = t, x, y

print("Yes")

Solution (Python):
N = int(input())
now,nowx,nowy=0,0,0
out = "Yes"
for i in range(N):
    t,x,y = list(map(int,input().split()))
    D = abs(x-nowx)+abs(y-nowy)
    T = t-now
    if D<=T and T%2==D%2:
        now,nowx,nowy = t,x,y
        continue
    else:
        now,nowx,nowy = t,x,y
        out="No"
print(out)

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

n = map(int,readline().split())
data = list(map(int,read().split()))

t,x,y = 0,0,0
it = iter(data)
for ti,xi,yi in zip(it,it,it):
    dif = abs(x-xi) + abs(y-yi)
    if(ti-t < dif)|(dif%2 != (ti-t)%2):
        print('No')
        exit()
    t,x,y = ti,xi,yi
print('Yes')

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

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))
 
n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    if (abs(x - prevx) + abs(y - prevy)) > (t - prevt) or (t - prevt) % 2 != (abs(x - prevx) + abs(y - prevy)) % 2:
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n = ini()
ans = True
prevt = 0
prevx = 0
prevy = 0
for _ in range(n):
    t, x, y = inm()
    totalt = t - prevt
    totald = abs(x - prevx) + abs(y - prevy)
    if totald > totalt or (totald % 2) != (totalt % 2):
        ans = False
        break
    prevt = t
    prevx = x
    prevy = y
print("Yes" if ans else "No")

Solution (Python):
N = int(input())
x_pred = 0
y_pred = 0
t_pred = 0
ans = 'Yes'
for i in range(N):
    t,x,y = map(int,input().split())
    check = ((t-t_pred)-(abs(x-x_pred)+abs(y-y_pred)))
    if((check<0) or (check%2!=0)):
        ans = 'No'
    else:
        t_pred = t
        x_pred = x
        y_pred = y
print(ans)

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

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

T = [0]
XY = [[0,0]]
for i in range(N):
    t, *xy = map(int, input().split())
    T.append(t)
    XY.append(xy)

for i in range(1,N+1):
    tmp_t = T[i] - T[i-1]
    tmp_cnt = abs(XY[i][0] - XY[i-1][0]) + abs(XY[i][1] - XY[i-1][1])
    if tmp_t < tmp_cnt:
        print('No')
        exit()
    else:
        if (tmp_t - tmp_cnt)%2 != 0:
            print('No')
            exit()

print('Yes')

Solution (Python):

def calc_min_path(current_c, next_c):
    x = abs(current_c[1]-next_c[1])
    y = abs(current_c[2]-next_c[2])
    return x+y


def is_movable(current_c, next_c):
    move_count = next_c[0] - current_c[0]
    min_path = calc_min_path(current_c, next_c)
    if move_count == min_path:
        return True
    if move_count < min_path:
        return False
    if move_count > min_path:
        must_move_count = move_count-min_path
        if must_move_count % 2 == 0:
            return True
        else:
            return False


def main():
    N = int(input())
    coordinate = [[int(x) for x in input().split(" ")] for _ in range(N)]
    coordinate.insert(0, [0, 0, 0])

    for i in range(N):
        if not is_movable(coordinate[i], coordinate[i+1]):
            print("No")
            exit()
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
arr_t = [0]
arr_x = [0]
arr_y = [0]
flag = 0

for i in range(N):
  t, x, y = list(map(int, input().split()))
  arr_t.append(t)
  arr_x.append(x)
  arr_y.append(y)

for i in range(N):
  if arr_t[i+1]-arr_t[i] < abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]):
    flag = 1
  elif ((arr_t[i+1]-arr_t[i])-abs(arr_x[i+1]-arr_x[i])+abs(arr_y[i+1]-arr_y[i]))%2 == 0:
    flag = 0
  else:
    flag = 1

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

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

pre = [0, 0, 0]
jdg = True
for t, x, y in txy:
    d = abs(x - pre[1]) + abs(y - pre[2])
    tt = t - pre[0]
    if tt - d >= 0 and (tt - d) % 2 == 0:
        jdg = True
        pre = [t, x, y]
    else:
        jdg = False
        break
        
print('Yes' if jdg else 'No')

Solution (Python):
n, *lst = map(int, open(0).read().split())
start = [0, 0, 0]
for i in range(n):
  tmplst = lst[3 * i : 3 * i + 3]
  tmp =  (tmplst[0] - start[0]) - (abs(tmplst[1] - start[1]) + abs(tmplst[2] - start[2]))
  if tmp < 0 or tmp % 2:
    print('No')
    quit()
  start = tmplst
else:
  print('Yes')

Solution (Python):
n=int(input())
txy=[input().split() for i in range(n)]
if n!=1:
  for i in range(n-1):
    subX=abs(int(txy[i+1][1])-int(txy[i][1]))
    subY=abs(int(txy[i+1][2])-int(txy[i][2]))
    subT=int(txy[i+1][0])-int(txy[i][0])
    t=[]
    p=subT-subX-subY
    t.append(p)
  for i in range(len(t)):
      if t[i]<0 or t[i]%2==1:
        print('No')
      else:
        print('Yes')
else:
  subby=int(txy[0][0])-int(txy[0][1])-int(txy[0][2])
  if subby>=0 and subby%2==0:
    print('Yes')
  else:
    print('No')

Solution (Python):
N=int(input())
result='Yes'

plan=[[0,0,0]]

for _ in range(N):
    plan.append(list(map(int,input().split())))

for i in range(1,N+1):
    t_sp=plan[i][0]-plan[i-1][0]
    dis=abs(plan[i][1]-plan[i-1][1])+abs(plan[i][2]-plan[i-1][2])

    if dis>t_sp or (dis-t_sp)%2==1:
        result='No'
        break

print(result)

Solution (Python):
import sys

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

Solution (Python):
import sys

a,b,tt = 0,0,0
for i in range(int(input())):
    t,x,y = map(int,input().split())
    dif = abs(x - a) + abs(y - b)
    if (t - tt) % dif != 0:
        print("No")
        sys.exit()
    a,b,tt = x,y,t
print("Yes")

Solution (Python):



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


def judge(p1, p2):
    t = p2[0] - p1[0]
    d = abs(p1[1] - p2[1]) + abs(p1[2] - p2[2])
    if t < d:
        return False
    if (t - d) % 2 == 0:
        return True
    else:
        return False


def main():
    txy.sort()
    p1 = (0, 0, 0)
    for p2 in txy:
        if judge(p1, p2):
            continue
        else:
            print("No")
            return
    print("Yes")
    

if __name__ == "__main__":
    main()

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

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())
    
for i in range(N):
    if(x[i]+y[i] > t[i]):
        print("No")
        break
    if((x[i]+y[i])%2 == 0):
        if(t[i]%2 != 0):
            print("No")
            break
    else:
        if(t[i]%2 == 0):
            print("No")
            break
else:
    print("Yes")

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
txy = nan(n)

ct = 0
cx, cy = 0, 0
flag = True
for i in range(n):
    t, x, y = txy[i]
    nx, ny = abs(cx - x), abs(cy - y)
    p = abs(nx - ny)
    if ct + t < nx + ny:
        flag = False
    if t > nx + ny and (ct + t) % 2 != p % 2:
        flag = False
    cx, cy = x, y
    ct = t

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

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

Solution (Python):

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


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

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

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

ans = "Yes"
for i in range(1,N+1):
    dl = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
    dt = t[i]-t[i-1]
    if (dt < dl)or((dt-dl) % 2 != 0):
        ans = "No"
        break

print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
maex=0
maey=0
maet=0
flag=0
for i in range(n):
    t,x,y=map(int,input().split())
    kyori=abs(x-maex)+abs(y-maey)
    jikan=t-maet
    if jikan>=kyori and (jikan-kyori)%2==0:
        flag+=0
    else:
        flag=1
    maex=x
    maey=y
    maet=t
print('Yes' if flag==0 else 'No')

Solution (Python):
N, = map(int, input().split())
tt, aa, bb = 0, 0, 0
for _ in range(N):
    t, a, b = map(int, input().split())
    d = abs(aa-a) + abs(bb-b)
    if d <= t - tt and (t-tt-d) % 2 == 0:
        pass
    else:
        print("No")
        break
    aa, bb, tt = a, b, t
else:
    print("Yes")

Solution (Python):
def manh(coord_x, coord_y):
    return abs(coord_x + coord_y)

def main():
    N = int(input())
    nt, nx, ny = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        d = manh(x - nx, y - ny)
        T = t - nt

        if d > T or (d - T) & 1:
            print("No")
            return
        
        nt, nx, ny = t, x, y
    
    print("Yes")
        

if __name__ == "__main__":
    main()

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

for i in range(n):
  sa=li[i+1][0]-li[i][0]
  kyori=abs(li[i+1][1]-li[i][1])+abs(li[i][2]-li[i+1][2])
  if kyori==0 or sa<kyori or sa%2!=kyori%2:
    print("No")
    exit()
  else:
    continue
print("Yes")

Solution (Python):
N = int(input())
 
T = [0]
X = [0]
Y = [0]

for i in range(0,N):
	ti, xi, yi = map(int, input().split())
	T.append(ti)
	X.append(xi)
	Y.append(yi)
 
message = "Yes"
 
for i in range(1,N + 1):
	time_dis = T[i] - T[i-1]
	x_dis = abs(X[i] - X[i-1])
	y_dis = abs(Y[i] - Y[i-1])
	total_dis = x_dis + y_dis

	if time_dis >= total_dis and (time_dis - total_dis) % 2 == 0:
		continue
		
	else:
		message = "No"
		break
		
print(message)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

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

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    
    N = Scanner.int()
    T = Scanner.int_list_list(N)
    x, y, t = 0, 0, 0
    for i in T:
        len = abs(i[1] - x) + abs(i[2] - y)
        time = i[0] - t
        if len <= time and len % 2 == time % 2:
            t, x, y = i
        else:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
t1=0
x1=0
y1=0
for _ in range(n):
    t2,x2,y2=map(int,input().split())
    t=t2-t1
    d=abs(x1-x2)+abs(y1-y2)
    if d>t or t%2!=d%2:
        print('No')
        break
    t1,x1,y1=t2,x2,y2
else:
    print('Yes')

Solution (Python):
N = int(input())
pos = [0, 0]
time = 0
p = "Yes"
for i in range(N):
  A = list(map(int, input().split()))
  dt = A[0] - time
  dx = A[1] - pos[0]
  dy = A[2] - pos[1]
  if dt < dx + dy or dt % 2 != (dx + dy) % 2:
    p = "No"
  pos[:] = [A[1], A[2]]
  time = A[0]
print(p)

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

N = int(input())
prev = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    if abs(x - prev[1]) + abs(y - prev[2]) > t - prev[0]:
        print('No')
        exit()
    elif (x-prev[1] + y - prev[2]) % 2 != (t-prev[0])%2:
        print('No')
        exit()
    else:
        prev = [t, x, y]
print('Yes')

Solution (Python):
N=int(input())
px,py,ct=0,0,0
for i in range(N):
  t,x,y=map(int,input().split())
  dis=abs(px-x)+abs(py-y)
  mt=t-ct
  if dis>mt or (mt-dis)%2==1:
    print("No")
    exit(0)
  px,py,ct=x,y,t
print("Yes")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, t, x, y):
    ct = 0
    cx = 0
    cy = 0
    for i in range(N):
        r = t[i] - ct - abs(cx - x[i]) - abs(cy - y[i])
        if r < 0 or r & 1:
            return NO
        ct = t[i]
        cx = x[i]
        cy = y[i]
    return YES


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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
for _ in range(N-1):
    t1, x1, y1 = map(int, input().split())
    if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
        flag = False
    t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

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

main()

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

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

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

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

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
def Manhattan(a,b):
    l_1=abs(a[1]-b[1])+abs(a[2]-b[2])
    return l_1
ok=0
if a[0][0]>=a[0][1]+a[0][2] and((a[0][0]%2==0 and (a[0][1]+a[0][2])%2==0) or (a[0][0]%2==1 and (a[0][1]+a[0][2])%2==1)):
    ok+=0
else:
	ok+=1

for i in range(n-1):
    if Manhattan(a[i],a[i+1])>a[i+1][0]-a[i][0]:
        ok+=1
    elif (Manhattan(a[i],a[i+1])%2==0 and (a[i+1][0]-a[i][0])%2==0) or (Manhattan(a[i],a[i+1])%2==1 and (a[i+1][0]-a[i][0])%2==1):
        ok+=0
    else:
        ok+=1

if ok!=0:
    print("No")
else:
    print("Yes")

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    tn = xn = yn = 0
    for i in range(n):
        t, x, y = list(map(int, input().rstrip('\n').split()))
        d = abs(xn - x) + abs(yn - y)
        td = t - tn
        if d - td > 0:
            print("No")
            exit()
        elif (d - td) % 2 != 0:
            print("No")
            exit()
        xn = x
        yn = y
        tn = t
    print("Yes")


if __name__ == '__main__':
    slove()

Solution (Python):
def solve():
  n = int(input())
  time = 0
  x,y = 0,0
  travel = True
  for i in range(n):
    t,nx,ny = (int(i) for i in input().split())
    timediff = t-time
    xdif = abs(nx-x)
    ydif = abs(ny-y)
    
    movement = xdif + ydif
    if movement > timediff:
      travel = False
    elif movement == time:
      pass
    else:
      if movement%2 == timediff%2:
        pass
      else:
        travel = False
    x,y = nx,ny
    time = t
  print("Yes") if travel else print("No")
    
solve()

Solution (Python):
def main(N, moves):
    pre_t = 0
    pre_x = 0
    pre_y = 0 
    for move in moves: 
        new_t, new_x, new_y = move[0], move[1], move[2]
        delta_t = new_t - pre_t 
        delta_x = abs(new_x - pre_x)
        delta_y = abs(new_y - pre_y)
        delta_sum = delta_x + delta_y 
        remain_time = delta_t - delta_sum 
        if remain_time == 0: 
            pre_t, pre_x, pre_y = new_t, new_x, new_y 
        elif remain_time > 0: 
            if remain_time % 2 == 0: 
                pre_t, pre_x, pre_y = new_t, new_x, new_y 
            else: 
                return "No" 
        else:
            return "No" 
    return "Yes"

N = int(input())
moves = [] 
for i in range(N):
    moves.append([int(j) for j in input().split()]) 
print(main(N, moves))

Solution (Python):
N = int(input())
flag = True
t_0,x_0,y_0 = 0,0,0

for i in range(N):
    t_1,x_1,y_1 = map(int,(input().split()))
    dt = t_1 - t_0
    dx = abs(x_1 - x_0)
    dy = abs(y_1 - y_0)
    if dx+dy<=dt and (dx+dy+dt)%2==0:
        t_0,x_0,y_0 = t_1,x_1,y_1
    else:
        flag = False
        break

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

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

currentT = 0;
currentX = 0;
currentY = 0;
flag = True;

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

    timeDiff = t - currentT;
    xDiff = abs(x - currentX);
    yDiff = abs(y - currentY);

    currentT = t;
    currentX = x;
    currentY = y;

    leftMoveCount = timeDiff - (xDiff + yDiff);

    if leftMoveCount < 0:
        flag = False;
        break;
    elif leftMoveCount % 2 == 0:
        continue;
    else:
        flag = False;
        break;

if flag:
    print('Yes');
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())
    dxy = abs(X - x) + abs(Y - y)
    dt = t - T
    if dxy > dt or dxy % 2 != dt % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):


import sys
import math

n=int(input())

pt=0
px=0
py=0

for i in range(0,n):
	tmp = input().split()
	t,x,y = list(map(lambda a: int(a), tmp))

	if((t-pt)%2!=(abs(x-px)+abs(y-py))%2):
		print("No")
		sys.exit()
	if(t-pt<(abs(x-px)+abs(y-py))):
		print("No")
		sys.exit()
	pt=t
	px=x
	py=y

print("Yes")

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

def valid_move(t1, x1, y1, t2, x2, y2):
    d = abs(x1 - x2) + abs(y1 - y2)
    return (t2 - t1) >= d and (t2 - t1) % 2 == d % 2

for i in range(1, N + 1):
    t[i], x[i], y[i] = map(int, input().split())
    
yes = True
for i in range(N):
    if not valid_move(t[i], x[i], y[i], t[i + 1], x[i + 1], y[i + 1]):
        yes = False
        break
        
if yes:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
t=[0]
x=[0]
y=[0]
flag=True
for i in range(n):
  a,b,c=map(int,input().split())
  t.append(a)
  x.append(b)
  y.append(c)
  if(abs(x[i+1]+y[i+1]-x[i]-y[i])>t[i+1]-t[i] or (x[i+1]+y[i+1]+t[i+1]-x[i]-y[i]-t[i])%2!=0):
    flag=False
    break
if(flag):
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for _ in range(N):
    t, x, y = map(int,input().split())
    tn = t - t0
    xn = x - x0
    yn = y - y0
    if abs(xn) + abs(yn) <= tn and (abs(xn) + abs(yn)) % 2 == (tn % 2):
        t0 = t
        x0 = x
        y0 = y
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys

def manhattan(px, py, x, y):
    return abs(px-x) + abs(py-y)

N = int(input())
pt = 0
px = 0
py = 0
for i in range(N):
    t, x, y = map(int,input().split())
    dist = manhattan(px, py, x, y)
    time = t - pt
    if (time % 2 != dist % 2) or time < dist:
        print("No")
        sys.exit()
    else:
        pt = t
        px = x
        py = y
print("Yes")

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

for i in range(n):
    t = a[i+1][0]-a[i][0]
    z = a[i+1][1]-a[i][1]+a[i+1][2]-a[i][2]
    if t>=z and (t-z)%2==0:
        continue
    print('No')
    exit()

print('Yes')

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

t = txy[0][0]
d = abs(txy[0][1] + abs(txy[0][2]))
if t < d or t % 2 != d % 2:
    print('No')
    exit()

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

print('Yes')

Solution (Python):

def main():
    n = int(input())
    for _ in range(n):
        t, x, y = list(map(int, input().split()))
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
last_t = 0
last_x = 0
last_y = 0
for i in range(n):
    t, x, y = map(int, input().split())
    if abs(last_x - x) + abs(last_y - y) > t - last_t:
        print("No")
        exit()
    else:
        if (t % 2 == 1 and (x + y) % 2 == 0) or (t % 2 == 0 and (x + y) % 2 == 1):
            print("No")
            exit()
    last_t = t
    last_x = x
    last_y = y
print("Yes")

Solution (Python):
import sys

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

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
import sys
import math
from itertools import accumulate as acc
input=sys.stdin.readline
N=int(input())
a=[[0,0,0]]+[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
import sys
import math
from itertools import accumulate as acc
input=sys.stdin.readline
N=int(input())
a=[[0,0,0]]+[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0: print("No"),sys.exit()
print("Yes")

Solution (Python):

n = int(input())
for _ in range(n):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y) % 2 != 0:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
n=int(input())
t,x,y=0,0,0
ans='Yes'
for i in range(n):
    s,a,b=map(int,input().split())
    if abs(x-a)+abs(y-b)<=s-t and (a-x+y-b-s+t)%2==0:
        0
    else:
        ans='No'
        break
    t,x,y=s,a,b

print(ans)

Solution (Python):
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
bt,bx,by = 0,0,0
for i in range(N):
    t,x,y = inpl()
    dt = t-bt
    dx,dy = abs(x-bx),abs(y-by)
    if dx+dy > dt:
        print('No')
        exit()
    else:
        if (dt - (dx+dy)) %2 != 0:
            print('No')
            exit()
    bt,bx,by = t,x,y

print('Yes')

Solution (Python):
N = int(input())
li=[[int(it) for it in input().split()] for i in range(N)]

to,ao,bo=0,0,0
flag = "Yes"
for tn,an,bn in li:
  dt = tn-to
  dr = abs(an-ao)+abs(bn-bo)
  if (dt<dr):
    flag = "No"
  if (dr%2!=dt%2):
    flag = "No"
  to,ao,bo=tn,an,bn
print (flag)

Solution (Python):
N = int(input())
tnow = 0
xnow = 0
ynow = 0
flag = 1
for i in range(N):
  t, x, y = map(int, input().split())
  cost = abs(x-xnow)+abs(y-ynow)
  if cost <= t - tnow and (t-tnow-cost)%2==0:
    tnow = t
    xnow = x
    ynow = y
    continue
  else:
    flag = 0
    break
if flag == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
N=int(input())
travel=[[0,0,0]]+[ list(map(int,input().split(' '))) for i in range(N) ]
ans='Yes'
for i in range(N):
  dt = travel[i+1][0]-travel[i][0]
  dx = abs(travel[i+1][1]-travel[i][1])
  dy = abs(travel[i+1][2]-travel[i][2])
  if dx+dy<=dt and (dx+dy)%2==dt%2:
    continue
  else:
    ans='No'
    break
print(ans)

Solution (Python):
import sys

N = int(input())

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

prev = [0, 0, 0]
for step in steps:
    t, x, y = step
    diff = abs(x - prev[1]) + abs(y - prev[2])
    time = t - prev[0]
    if diff > time or (time - diff) % 2 > 0:
        print('No')
        sys.exit()
    prev = [t, x, y]

print('Yes')

Solution (Python):
N = int(input())
last = [0,0,0]
for i in range(N):
    ti,xi,yi = map(int,input().split())
    a = ti-last[2] - (abs(xi-last[0])+abs(yi-last[1]))
    if a >= 0  and a % 2 == 0:
        flag = True
    else:
        flag = False
        break
    last = [xi,yi,ti]
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
tmp = [[int(i) for i in input().split()] for i in range(N)]
tmp.insert(0, [0, 0, 0])
ans = 'Yes'

for i in range(N):
    t = tmp[i+1][0] - tmp[i][0]
    dx = abs(tmp[i+1][1] - tmp[i][1])
    dy = abs(tmp[i+1][2] - tmp[i][2])
    d = dx + dy
    if t < d \
    or t % 2 != d % 2:
        ans = 'No'
print(ans)

Solution (Python):
def main():
    N = int(input())
    T, X, Y = 0, 0, 0
    for _ in range(N):
        t, x, y = list(map(int, input().split()))
        dx = abs(x - X)
        dy = abs(y - Y)
        dt = t - T
        if (dx + dy) % 2 != dt % 2:
            print('No')
            return
        if dx + dy > dt:
            print('No')
            return
        T, X, Y = t, x, y
    print('Yes')

main()

Solution (Python):
n=int(input())
x=[[0,0,0]]+[list(map(int,input().split()))for i in range(n)]
y=[]
for i in range(n):
    s,t,r=x[i+1]
    q,p,w=x[i]
    temp=s-q
    abso=abs(t-p)+abs(r-w)
    if temp<abso or (temp%2!=abso%2):
        print("No")
        exit()
print("Yes")

Solution (Python):
import math
n = int(raw_input())

xy = [[0, 0, 0]]
for _ in xrange(n):
	xy.append([int(x) for x in raw_input().split()])

flag = True
for i  in xrange(0, n):
	t1, x1, y1 = xy[i]
	t2, x2, y2 = xy[i+1]
	xx = (t2-t1) - math.fabs(x2-x1) - math.fabs(y2-y1)
	if xx  < 0:
		flag = False
		break
	if xx % 2 != 0:
		flag = False
		break
if flag:
	print 'Yes'
else:
	print 'No'

Solution (Python):
n=int(input())
now=(0,0,0)
result=True
for i in range(n):
    t,a,b=[int(i) for i in input().split()]
    time=t-now[0]
    x=abs(a-now[1])
    y=abs(b-now[2])
    if (x+y-time)%2!=0 or (x+y)>time:
        result=False
    else:
        now=(t,a,b)
if result:
    print("Yes")
else:
    print("No")

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

ans="Yes"
for i in range(N):
        n=abs(t[i][1][0]-t[i+1][1][0])+abs(t[i][1][1]-t[i+1][1][1])
        if(n%2!=(t[i+1][0]-t[i][0])%2 or n>(t[i+1][0]-t[i][0])):
                ans="No"

print(ans)

Solution (Python):
n=int(input())
s=[list(map(int,input().split()))for i in range(n)]
s.insert(0,[0,0,0])
p=0
for i in range(n):
    c=s[i+1][0]-s[i][0]
    d=abs(s[i+1][1]-s[i][1])+abs(s[i+1][2]-s[i][2])
    if c<d or (c-d)%2==1:
        p=1
        break
print("No" if p==1 else "Yes")