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):
z = int(input())
x = 0
y = 0
t = 0
for i in range(z):
    s,a,b = map(int,input().split(" "))
    if s - t < abs(a-x) + abs(b-y):
        print("No")
        exit()
    elif (s - t) % 2 == 1 and (abs(a-x) + abs(b-y)) % 2 == 0:
        print("No")
        exit()
    elif (s - t) % 2 == 0 and (abs(a-x) + abs(b-y)) % 2 == 1:
        print("No")
        exit()
    else:
        x = a
        y = b
        t = s
print("Yes")

Solution (Python):
import sys
N = input()
p_t, p_x, p_y = 0, 0, 0
for _ in range(N):
    c_t, c_x, c_y = map(int, raw_input().split())
    if not c_t - p_t >= abs(c_x - p_x) + abs(c_y - p_y) or \
        not (c_t - p_t) % 2 == (abs(c_x - p_x) + abs(c_y - p_y)) % 2:
        print "No"
        sys.exit()
    p_t, p_x, p_y = c_t, c_x, c_y
print "Yes"

Solution (Python):
N = int(input())
txy = [input() for i in range(N)]
now_pos = [0, 0]
now_time = 0
fail_flag = False
for i in range(N):
    t, x, y = map(int, txy[i].split(' '))
    if (x+y) % 2 != t % 2:
        fail_flag = True
    distance = (abs(now_pos[0]-x) + abs(now_pos[1]-y))
    if distance > t-now_time:
        fail_flag = True
    if fail_flag:
        print('No')
        exit()
    now_pos = [x,y]
    now_time = t
print('Yes')

Solution (Python):
N = int(input())
txy = [input() for i in range(N)]
now_pos = [0, 0]
now_time = 0
fail_flag = False
for i in range(N):
    t, x, y = map(int, txy[i].split(' '))
    if (x+y) % 2 != t % 2:
        fail_flag = True
    distance = (abs(now_pos[0]-x) + abs(now_pos[1]-y))
    if distance > t:
        fail_flag = True
    if fail_flag:
        print('No')
        exit()
print('Yes')

Solution (Python):
def mhd(sx, sy, tx, ty):
    return(abs(sx-tx)+abs(sy-ty))
def inpl(): return [int(i) for i in input().split()]

N = int(input())
Sx, Sy, St = 0, 0, 0
ans = 'Yes'
for _ in range(N):
    Tt, Tx, Ty = inpl()
    if mhd(Sx, Sy, Tx, Ty) > Tt-St or (mhd(Sx, Sy, Tx, Ty) - Tt + St) % 2:
        ans = 'No'
print(ans)

Solution (Python):
N=int(input().strip())
t=[]
x=[]
y=[]
for i in range(N):
    tm, xm, ym=map(int,input().strip().split(' '))
    t.append(tm)
    x.append(xm)
    y.append(ym)
tn=0
xn=0
yn=0
fl=True
for i in range(N):
    tn=t[i]-tn
    xn=x[i]-xn
    yn=y[i]-yn
    
    if tn<abs(xn)+abs(yn) or tn%2!=(xn+yn)%2:
        fl=False
        break
if fl:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
  s,a,b = t,x,y
print("Yes" if f else "No")

Solution (Python):
n = int(input())
s,a,b = 0,0,0
f = True
for _ in [0]*n:
  t,x,y = map(int,input().split())
  p = t-s-(abs(x-a)+abs(y-b))
  if p%2 == 1 or p<0:
    f = False
print("Yes" if f else "No")

Solution (Python):
import sys

def chk1(t, x, y):
    return t % 2 == (x + y) % 2
def chk2(t, x, y):
    return t >= abs(x) + abs(y)
def chk(t, x, y):
    return chk1(t, x, y) and chk2(t, x, y)

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):
    dt, dx, dy = T[i] - T[i - 1], X[i] - X[i - 1], Y[i] - Y[i - 1]
    if not chk(dt, dx, dy):
        print('No')
        sys.exit(0)
print('Yes')

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

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


def isReachable(t1, x1, y1, t2, x2, y2):
    if (t2 - t1) < abs(x1 - x2) + abs(y1 - y2):
        return False
    if ((t2 - t1) - (abs(x1 - x2) + abs(y1 - y2))) % 2 == 0:
        return True
    else:
        return False


ret = True
for i in range(0, N):
    t1, x1, y1 = list[i]
    t2, x2, y2 = list[i + 1]
    b = isReachable(t1, x1, y1, t2, x2, y2)
    if b == False:
        ret = False
        break

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

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

t0, x0, y0 = 0, 0, 0
judge = "Yes"

for i in range(N):
	t, x, y = list(map(int, input().split()))
	if abs(x - x0) + abs(y - y0) <= t - t0 and (abs(x - x0) + abs(y - y0) - (t - t0)) % 2 == 0:
		x0 = x
		y0 = y
		t0 = t
	else:
		judge = "No"
		break

print(judge)

Solution (Python):
N = int(input())
st, sx, sy = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - st
    dr = abs(x - sx) + abs(y - sy)
    if not (dt >= dr and (dt - dr) % 2 == 0):
        print('No')
        break
else:
    print('Yes')

Solution (Python):
N = int(input())
t0,x0,y0 = 0,0,0
for _ in range(N):
    t1,x1,y1 = list(map(int, input().split()))
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    dis = abs(x)+abs(y)
    if dis<=t and (dis-t)%2 == 0:
        t0, x0, y0 = t1,x1,y1
    else:
        print('No')
        exit()
print('Yes')

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

t0 = 0
x0 = 0
y0 = 0

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

    d = abs(x - x0) + abs(y - y0)
    if t - t0 < d or ((t - t0) - d) % 2:
        print('No')
        exit()

    t0 = t
    x0 = x
    y0 = y

print('Yes')

Solution (Python):


def md(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

MI = lambda: map(int, input().split())

def main():
    N = int(input())
    t, x, y = 0, 0, 0
    for i in range(N):
        tn, xn, yn = MI()
        tr = tn - t - md(x, y, xn, yn)
        if tr < 0 or tr % 2:
            return "No"
    return "Yes"


if __name__ == "__main__":
    print(main())

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

Solution (Python):
import sys
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(1,N+1):
    t=L[i][0]-L[i-1][0]
    x=abs(L[i][1]-L[i-1][1])
    y=abs(L[i][2]-L[i-1][2])
    
    if x+y >t:
        print('No')
        sys.exit()
    if (x+y)%2!=t%2:
        print('No')
        sys.exit()
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)]
for i in range(N):
    t[i + 1], x[i + 1], y[i + 1] = map(int, input().split())
flag = 1
for i in range(N):
    dl = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if dl > dt or (dl - dt) % 2 == 1:
        flag = 0
        break
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
def manhattanDist(p1, p2):
    (x1, y1) = p1
    (x2, y2) = p2
    return abs(x1-x2) + abs(y1-y2)

N = int(input())
ans = "Yes"
now = 0
(nx, ny) = (0, 0)
for _ in range(N):
    t, x, y = map(int, input().split())
    d = manhattanDist((nx, ny), (x, y))
    sa = t - now
    if d <= sa and (sa-d) % 2 == 0:
        ()
    else:
        ans = "No"
        break

    now = t
    nx = x
    ny = y

    
print(ans)

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

t_org = 0
x_org = 0
y_org = 0
i = 0

for row in range(N):
    INPUT = input()
    t = int(INPUT.split( )[0])
    x = int(INPUT.split( )[1])
    y = int(INPUT.split( )[2])
    
    if t - t_org >= (x - x_org) + (y - y_org) and (t - t_org - (x - x_org) - (y - y_org)) % 2 == 0:
        t_org = t
        x_org = x
        y_org = y
        i += 1
    else:
        break

if i == N:
    print("Yes")
else:
    print('No')

Solution (Python):
ans = 'Yes'
m = []
t_last = x_last = y_last = 0
N = int(input())
for i in range(0, N):
  m.append(list(map(int, input().split())))

for l in m:
  t = abs(l[0] - t_last)
  mv = abs(l[1] - x_last) + abs(l[2] - y_last)
  if mv > t or (t - mv) % 2 != 0 :
    ans = 'No'
    break
  t_last=l[0]
  x_last=l[1]
  y_last=l[2]


print(ans)

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

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

print("Yes")

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

ans = 'Yes'
if a[0][0] < abs(a[0][1])+abs(a[0][2]) or (a[0][0]-abs(a[0][1])-abs(a[0][2]))%2 == 1:
    ans = 'No'
for i in range(n-1):
    if (a[i+1][0]-a[i][0]) < (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])):
        ans = 'No'
    if (a[i+1][0]-a[i][0]-abs(a[i+1][1]-a[i][1])-abs(a[i+1][2]-a[i][2]))%2!=0:
        ans = 'No'

print(ans)

Solution (Python):
n = int(input())
lx = 0
ly = 0
lt = 0
for _ in range(n):
    t, x, y = map(int, input().split())
    dt = t - lt
    dx = abs(x - lx)
    dy = abs(y - ly)
    dxy = dx + dy
    if dxy > dt:
        print('No')
        exit()
    elif (dt - dxy) % 2 == 1:
        print('No')
        exit()
    lx = x
    ly = y
    lt = t
print('Yes')

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

isok = True
x_now = 0
y_now = 0
t_now = 0
for i in range(N):
    t,x,y = map(int,input().split())
    c = t-t_now
    l = abs(x-x_now)+abs(y-y_now)
    if c%2!=l%2 or c<l:
        isok=False
    x_now = x
    y_now = y
    t_now = t
    
if isok:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
T, X, Y = [0], [0], [0]
for i in range(N):
    ti, xi, yi = map(int, input().split())
    T.append(ti)
    X.append(xi)
    Y.append(yi)

for i in range(1, N+1):
    if abs(X[i]-X[i-1]) + abs(Y[i]-Y[i-1]) > T[i]-T[i-1] or (-(abs(X[i]-X[i-1]) + abs(Y[i]-Y[i-1])) - T[i]-T[i-1]) % 2 == 1:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
from collections import deque

num = int(input())

to_num = lambda x : [int(i) for i in input().split(' ')]

masume = {}
for i in range(num):
    line = to_num(1)
    for l in range(len(line)):
        masume[line[0]] = (line[1], line[2])

masume_deque = deque(list(masume.keys()))
pre_pos = (0, 0)
pre_times = 0
for index in range(num):
    cur_times = masume_deque[index]
    cur_pos = masume[cur_times]
    distance = sum([abs(cur_pos[i]-pre_pos[i]) for i in [0, 1]])
    times = abs(cur_times - pre_times)
    if distance % 2 != times % 2 or distance > times:
        ans = False
        break
    else:
        ans = True
    pre_pos = cur_pos
    pre_times = cur_times
    
if ans:
    print('Yes')
else:
    print('No')

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

Solution (Python):
def dist(a,b,c,d):
    return abs(a-c)+abs(b-d)

n=int(input())
nx,ny=0,0
now=0
for i in range(n):
    t,x,y=map(int,input().split())
    if t-now>=dist(nx,ny,x,y) and (dist(nx,ny,x,y)-(t-now))%2==0:
        nx,ny=x,y
        now=t
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
N = int(input())
ans = True
tprev = 0
xprev = 0
yprev = 0
for _ in range(N):
    tnow,xnow,ynow = list(map(int,input().split()))
    time = abs(xnow-xprev) + abs(ynow-yprev)
    if time > tnow-tprev or (tnow-tprev-time)%2 == 1:
        ans = False
        break
    tprev = tnow
    xprev = xnow
    yprev = ynow
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
def travel(xs,ys,xf,yf,t):
    d=abs(xf-xs)+abs(yf-ys)
    if d>t:
        return False
    else:
        if d%2==t%2:
            return True
        else:
            return False

N=int(input())
txy=[[0,0,0]]
for i in range(N):
    txy.append([int(j) for j in input().split(" ")])

for i in range(N):
    if travel(txy[i][1],txy[i][2],txy[i+1][1],txy[i+1][2],txy[i+1][0]-txy[i][0])==False:
        print("No")
        sys.exit()
print("Yes")

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

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

step = 0
start = (0, 0)
for g in goals:
    s = g[0] - step
    d = abs(g[1] - start[0]) + abs(g[2] - start[1])

    if s < d or s % 2 != d % 2:
        print('No')
        break

    step = g[0]
    start = (g[1], g[2])
else:
    print('Yes')

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

Solution (Python):
def solve(plan, N):
    """

    :param plan: [time, x, y]
    :param N: number of plan
    :return: 'Yes' or 'No'
    """
    time = 0
    posi = [0,0]
    for i in range(N):
        next = plan[i][1:]
        dist = abs(next[0]-posi[0])+abs(next[1]-posi[1])
        if dist > plan[i][0] - time:
            return 'No'
        elif (plan[i][0] - time - dist) % 2 == 1 :
            return 'No'
        posi=next[:]
        time=plan[i][0]

    return 'Yes'

if __name__ == '__main__':
    N = int(input())

    plan = []
    for i in range(N):
        plan.append(list(map(int, input().split(' '))))

    plan.sort(key=lambda x: x[0])
    print(solve(plan, N))

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

time = 0;_x = 0;_y = 0

for i in range(N):
    t, x, y = map(int, input().split())
    time = t - time
    dis = abs(_x - x) + abs(_y - y)
    if dis == time:
        time, _x, _y = t, x, y
    elif dis < time and (time - dis) % 2 == 0:
        time, _x, _y = t, x, y
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
n = input()
tt, xx, yy = 0, 0, 0
for i in range(n):
	t, x, y = map(int, raw_input().split())
	d = abs(x - xx) + abs(y - yy)
	if d > t - tt or (d + t - tt) % 2 > 0:
		print 'No'
		exit()
	tt, xx, yy = t, x, y
print 'Yes'

Solution (Python):
import math

n = int(input())
t = 0
x = 0
y = 0
ans = "Yes"

for i in range(n):
    t1 = t
    x1 = x
    y1 = y
    t, x, y = map(int,input().split(' '))



    td = abs(t - t1)
    xd = abs(x - x1)
    yd = abs(y - y1)



    if xd + yd > td:
        ans = "No"
        break
    
    if ( xd + yd ) % 2 != td %2:
        ans = "No"
        break

print(ans)

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

def HammingDist(p1,p2):
  xd = abs(p1[0]-p2[0])
  yd = abs(p1[1]-p2[1])
  return xd+yd
def check(time,dist):
  if (dist > time):
    return False
  elif ((time - dist) % 2 == 0):
    return True
  else:
    return False

flag = 0
length = len(l)

for i in range(length-1):
  if not check(l[i+1][0] - l[i][0], HammingDist(l[i][1],l[i+1][1])):
    flag = 1

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

Solution (Python):

import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'

Solution (Python):
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque








def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)


def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))





def main():
	cx = 0; cy = 0
	prev_t = 0

	for i in range(I()):
		t, dist_x, dist_y = LI()

		diff = abs(dist_x - cx) + abs(dist_y - cy)		
		spend_time = t - prev_t


		if spend_time >= diff and (spend_time - diff)%2 == 0:
			f = True
		else:
			f = False
			break

		prev_t = t
		cx = dist_x
		cy = dist_y
	
	if f:
		print("Yes")
	else:
		print("No")

if __name__ == '__main__':
	main()

Solution (Python):
def main():
    N = int(input())
    b_t = 0
    b_x = 0
    b_y = 0
    flg = True
    for _ in range(N):
        a_t, a_x, a_y = map(int, input().split())
        spend_time = a_t - b_t
        distance = abs(a_x - b_x) + abs(a_y - b_y)
        if spend_time >= distance and (distance - spend_time) % 2 == 0:
            continue
        else:
            flg = False
            break

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


if __name__ == '__main__':
    main()

Solution (Python):
N = input()
ipts = [map(int,raw_input().split(" ")) for i in range(N)]

def solve():
    x,y = 0,0
    pt = 0
    for i in range(N):
        t,nx,ny = ipts[i]
        mv = abs(nx-x) + abs(ny-y)
        mt = t - pt
        
        if mv > mt:
            print "No"
            return
        if (mv - mt)%2:
            print "No"
            return
        x,y = nx,ny
        pt = t

    print "Yes"
            
        

solve()

Solution (Python):
def test(n,t,x,y):
	for i in range(n-1):
		t1=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
		t2=t[i+1]-t[i]
		if (t1>t2 or (t2-t1)%2): return 0
	return 1
def main():
	n=int(input())
	n+=1
	t=[0]*n
	x=[0]*n
	y=[0]*n
	for i in range(1,n):
		t[i],x[i],y[i]=map(int,input().split())
	if (test(n,t,x,y)): print("Yes")
	else: print("No")
main()

Solution (Python):
def test(n,t,x,y):
	for i in range(n-1):
		t1=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
		t2=t[i+1]-t[i]
		if (t1>t2 or (t2-t1)%2): return 0
	return 1
def main():
	n=int(input())
	n+=1
	t=[0]*n
	x=[0]*n
	y=[0]*n
	for i in range(1,n):
		t[i],x[i],y[i]=map(int,input().split())
	if (test(n,t,x,y)): print("Yes")
	else: print("No")
main()

Solution (Python):
def check(dt, dl):
    if dt < dl:
        return False
    left = dt - dl
    return left % 2 == 0

N = int(input())
t, x, y = 0, 0, 0
for n in range(N):
    ti, xi, yi = map(int, input().split())
    dt = ti - t
    dx = xi - x
    dy = yi - y

    if not check(dt, abs(dx) + abs(dy)):
        print('No')
        exit(0)

    t, x, y = ti, xi, yi
print('Yes')

Solution (Python):

def pred(t, x, y):
    return x + y <= t and (x + y - t) % 2 == 0
result = True
t, x, y = 0, 0, 0
for _ in range(int(input())):
    nt, nx, ny = map(int, input().split())
    if not pred(nt - t, abs(nx - x), abs(ny - y)):
        result = False
        break
    t, x, y = nt, nx, ny
print(['No', 'Yes'][result])

Solution (Python):



def f(poss):
    lastPos = (0, 0, 0)

    for pos in poss:
        t = pos[0] - lastPos[0]
        d = abs(pos[1] - lastPos[1]) + abs(pos[2] - lastPos[2])
        lastPos = pos

        if t < d or (t-d)%2 != 0:
            return False

    return True



def main():
    n = int(input())
    poss = [tuple(map(int, input().split())) for i in range(n)]

    print('Yes' if f(poss) else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
n = input()
x0, y0, t0 = 0, 0, 0
result = True
for i in range(n):
    t, x, y = map(int, raw_input().split())
    left = t - t0 - abs(x - x0) - abs(y - y0)
    if left < 0 or left % 2 != 0:
        result = False

if result:
    print "Yes"
else:
    print "No"

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [[0,0,0]] + sorted([LI() for _ in range(n)])
    for i in range(n):
        t1,x1,y1 = a[i]
        t2,x2,y2 = a[i+1]
        sa = abs(x1-x2) + abs(y1-y2)
        ts = t2 - t1
        if ts < sa or (ts+sa) % 2 == 1:
            return 'No'

    return 'Yes'

print(main())

Solution (Python):



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




for i in range(N):
    dist = abs(a4[i+1][1] - a4[i][1]) + abs(a4[i+1][2] - a4[i][2])
    tdist = a4[i+1][0] - a4[i][0]
 
    if dist > tdist or  (dist - tdist)%2 == 1:
        flag = -1


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

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

t_now = 0
p = (0,0)
ans = True

for _ in range(n):
    t,x,y = map(int,input().split())
    td = t - t_now
    d = abs(p[0]-x) + abs(p[1]-y)
    tmp = td - d
    if tmp >= 0 and tmp % 2 == 0:
        t_now = t
        p = (x,y)
        continue
    else:
        ans = False
        break

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

Solution (Python):


n = int(raw_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] = map(int, raw_input().split())

flag = True

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

	if dt < dx + dy:
		flag = False
		break
	else:
		if (dt - (dx + dy)) % 2 == 1:
			flag = False
			break

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

Solution (Python):
import sys


N = int(input())


t = []
x = []
y = []
flag = 0

for i in range(0,N):
    line = input().split()
    t0 = int(line[0])
    x0 = int(line[1])
    y0 = int(line[2])
    if len(t)>0:
        if ((t0-t[i-1])-(x0-x[i-1])-(y0-y[i-1])) % 2 != 0:
        
            flag = 1
        if (abs(t0-t[i-1])-abs(x0-x[i-1])-abs(y0-y[i-1])) < 0:
            flag = 1
    else:
        if t0 - x0 -y0 <0:
            flag = 1

    t.append(t0)
    x.append(x0)
    y.append(y0)
    



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

Solution (Python):
import sys                        
import copy                       
from collections import deque     
                                  
def get_read_func(fileobject):    
    if fileobject == None :       
        return raw_input          
    else:                         
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    now_t = 0
    now_x = 0
    now_y = 0
    is_ok_plan = True
    for i in range(N):
        input_raw = read_func().strip().split()
        [t, x, y] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        dist = abs(x - now_x) + abs(y - now_y)
        T = t - now_t
        if (dist <= T and dist % 2 == T % 2) == False:
            is_ok_plan = False
        now_t = t
        now_x = x
        now_y = y


    if is_ok_plan:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
check = [list(map(int, input().split())) for _ in range(n)]
prev = [0,0,0]
feasible = True

for point in check:
    time = point[0] - prev[0]
    dist = abs(point[1] - prev[1]) + abs(point[2] - prev[2])
    if time - dist < 0 or (time - dist) % 2:
        feasible = False
        break
    else:
        prev = point

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

Solution (Python):
N = int(input())
T,X,Y = 0,0,0
for n in range(N):
    t,x,y = map(int,input().split())
    if (x-X)+(y-Y) <= t-T and ((t-T)-(x-X)-(y-Y))%2 == 0:
        X = x
        Y = y
        T = t
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys

if __name__ == "__main__":
    N = int(input())
    plan = [list(map(int, input().split(' '))) for i in range(N)]
    for i in range(N):
        time = plan[i][0]
        if abs(plan[i][1]) > time or abs(plan[i][2]) > time:
            print('No')
            sys.exit()
        if abs(plan[i][1]) + abs(plan[i][2]) > time:
            print('No')
            sys.exit()
        if ((abs(plan[i][1]) + abs(plan[i][2])) % 2) != (time % 2):
            print('No')
            sys.exit()
    print('Yes')

Solution (Python):
import sys
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    tmp_t, tmp_x, tmp_y = map(int, input().split())
    t.append(tmp_t)
    x.append(tmp_x)
    y.append(tmp_y)

    
def go(t, d):
    if t == d:
        return True
    elif t > d:
        if (t - d) % 2 == 0:
            return True
        else:
            return False
    else:
        return False
        


for i in range(N):
    delta_t = t[i+1] - t[i]
    distance = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if go(delta_t, distance):
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    t1, x1, y1 = [int(j) for j in input().split()]
    if t1 - t >= abs(x1 - x) + abs(y1 - y):
        if (t1 - t - abs(x1 - x) - abs(y1 - y)) % 2 == 1:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t, x, y = t1, x1, y1
print("Yes")

Solution (Python):
N = int(input())
t = []
pos = []
pos.append((0, 0))
t.append(0)
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    t.append(t_i)
    pos.append((x_i, y_i))

def isReachable(cur, dst, t):
    dist = abs(cur[0] - dst[0]) + abs(cur[1] - dst[1])
    if dist > t:
        return False
    if dist % 2 != t % 2:
        return False
    return True

reachable = True
for i in range(1, N + 1):
    cur = (pos[i - 1][0], pos[i - 1][1])
    dst = (pos[i][0], pos[i][1])
    t_i = t[i] - t[i - 1]
    if not isReachable(cur, dst, t_i):
        reachable = False
        break

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

Solution (Python):
def main():
     N = int(input())
     dic = {}
     for i in range(N):
         try:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
         except Exception:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
     f = False
     index = 0
     coordinate = [0,0]
     for j in dic.items():
             distance = abs(j[1][0]-coordinate[0])+abs(j[1][1]-coordinate[1])
             if j[0]-index>=distance and (j[0]-index)%2==distance%2:
                 continue
             else:
                 print('No')
                 exit()
     print('Yes')


if __name__=="__main__":
    main()

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

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

  dt = ti-t
  d = abs(xi-x)+abs(yi-y)
  if d > dt or (d-dt) % 2 != 0:
    print('No')
    exit()
print('Yes')

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

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

prev = [0, 0, 0]
is_possible = "Yes"

for line in lines:
    pt, px, py = prev
    t, x, y = line
    dt = t - pt
    dx = x - px
    dy = y - py
    if dt < dx + dy:
        is_possible = "No"
        break

    if not dt & 1 == (dx + dy) & 1:
        is_possible = "No"
        break

    prev = line

print(is_possible)

Solution (Python):

N = int(input())

t, x, y = 0, 0, 0

def judge(t0, x0, y0, t1, x1, y1):
    t = t1- t0
    x = abs(x1- x0)
    y = abs(y1- y0)

    if t < x+y:
        return False
    if t%2 == (x+y)%2:
        return True
    else:
        return False


result = True
for i in range(N):
    t1, x1, y1 = list(map(int, input().split(" ")))
    result = result and judge(t, x, y, t1, x1 ,y1)
    t, x, y = t1, x1, y1

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

Solution (Python):


def checker(dx, dy, t):
	
	if dx + dy <= t and abs(dx + dy - t) % 2 == 0:
		return True
	else:
		return False

def main():
	n = int(input())
	plans = [list(map(int, input().split())) for _ in range(n)]

	
	x, y, old_t = [0, 0, 0]
	for i in range(n):
		t, new_x, new_y = plans[i]
		if checker(abs(x - new_x), abs(y - new_y), t - old_t):
			x = new_x
			y = new_y
			old_t = t
		else:
			print("No")
			break
	else:
		print("Yes")


if __name__ == '__main__':
	main()

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

flag = True
position = [0, 0]
tc = 0
for n in range(N):
    pdiff = sum([x[n] - position[0], y[n] - position[1]])
    tdiff = t[n] - tc
    if tdiff < pdiff:
        flag = False
        break
    elif tdiff == pdiff:
        pass
    elif (pdiff - tdiff) % 2 != 0:
        flag = False
        break

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

Solution (Python):
N=int(input())
t_lst, x_lst, y_lst = [], [], []
for _ in range(N):
    buf = [int(_) for _ in input().split()]
    t_lst.append(buf[0])
    x_lst.append(buf[1])
    y_lst.append(buf[2])

t, x, y =0,  0, 0
isValid=True
for i in range(N):
    move = abs(x_lst[i] - x) + abs(y_lst[i] - y)
    step = t_lst[i] - t
    if move <= step and (step - move)%2 ==0:
            x = x_lst[i]
            y = y_lst[i]
            t = t_lst[i]
    else:
        isValid=False
        break
if isValid:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
cx,cy,ct = 0,0,0
for i in range(n):
    t,x,y = Is()
    dt,dd =  t-ct, abs(x-cx)+abs(y-cy)
    if dt < dd or (dt-dd)%2 != 0:
        print("No")
        exit()
    cx,cy,ct = x,y,t
print("Yes")