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())
l=[[] for i in range(n+1)]
l[0]=[0,0,0]
for i in range(1,n+1):
    l[i]=list(map(int,input().split()))
for i in range(n):
    flag=False
    t=l[i+1][0]-l[i][0]
    x=l[i+1][1]-l[i][1]
    y=l[i+1][2]-l[i][2]
    for a in range(t+1):
        for b in range(t+1-a):
            c=a-x
            d=b-y
            if a+b+c+d==t:
                flag=True
                break
        if flag: break
    if not flag:
        print("No")
        break
if flag: 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())
now = 0
ans = 1
x0 = 0
y0 = 0
for i in range(n):
    if i == 0:
        if x[i]+y[i] > t[i]:
            ans = 0
            break
        elif (x[i]+y[i]-t[i])%2 == 1:
            ans = 0
            break
    else:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i]-t[i-1]:
            ans = 0
            break
        elif (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-t[i]+t[i-1])%2 == 1:
            ans = 0
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
t_pre, x_pre, y_pre = 0, 0, 0
flag = True
for i in range(N):
    t, x, y = map(int, input().split())
    delta_t = t - t_pre
    delta_x = abs(x - x_pre)
    delta_y = abs(y - y_pre)
    if t % 2 != (x + y) %2:
        flag = False
        break
    if delta_x + delta_y > delta_t:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = lambda: sys.stdin.readline().strip()

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

    pre_ti, pre_x, pre_y = 0,0,0
    for tx in tx_list:
        ti,x,y = tx[0],tx[1],tx[2]
        tmp_ti,tmp_x,tmp_y = ti-pre_ti,x-pre_x,y-pre_y
        pre_ti,pre_x,pre_y = ti,x,y
        for i in range(tmp_ti+1):
            if ((tmp_ti-i)-i) == (abs(tmp_x)+abs(tmp_y)):
                break
        else:
            print("No")
            exit()
    print("Yes")

main()

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

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
t1, x1, y1 = 0, 0, 0
p = False
for i in range(n):
	t, x, y = t1, x1, y1
	t1, x1, y1 = map(int, input().split())
	s = t1 - t
	d = x1 + y1 - x - y
	p = x >= 0 and y >= 0 and (abs(s) >= abs(d)) and ((s - d) % 2 == 0)
	
	if p == False:
		break
print("Yes" if p else "No")

Solution (Python):
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())

    t = 0
    x = 0
    y = 0

    ans = True

    for _ in range(n):
        next_t, next_x, next_y = map(int, input().split())

        dist = abs(next_x - x) + abs(next_y - y)

        if next_t - t == dist:
            t, x, y = next_t, next_x, next_y
        elif next_t - t > dist and ((next_t - t) - dist) % 2 == 0:
            t, x, y = next_t, next_x, next_y
        else:
            ans = False
            break

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




class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2
3 1 2
6 1 1"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
2 100 100"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """2
5 1 1
100 1 1"""
        output = """No"""
        self.assertIO(input, output)

if __name__ == "__main__":
    
    resolve()

Solution (Python):
ans = 'Yes'
n = int(input())
for _ in range(n):
    t, x, y = map(int, input().split())
    if t < x + y:
        ans = 'No'
        break
    if  t % 2 != 0 and (x - y) % 2 == 0:
        ans = 'No'
        break
    elif t % 2 == 0 and (x - y) % 2 != 0:
        ans = 'No'
        break

print(ans)

Solution (Python):
n = int(input())
x = 0
y = 0
t = 0
ans = 'Yes'

for _ in range(n):
    ti, xi, yi = map(int, input().split())
    elapsed_time = ti - t
    if abs(x - xi) + abs(y - yi) > elapsed_time:
        ans = 'No'
        break
    dist_odd_even = (abs(x - xi) + abs(y - yi)) % 2
    time_odd_even = elapsed_time % 2
    if dist_odd_even != time_odd_even:
        ans = 'No'
        break
    x = xi
    y = yi
    t = ti

print(ans)

Solution (Python):
def difference(two_lists):
    return [abs(two_lists[1][i] - two_lists[0][i]) for i in range(3)]


n = int(input())

txy = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
dtxy = list(map(difference, zip(txy, txy[1:])))

for i in range(n):
    dt, dx, dy = dtxy[i]
    if  dx + dy > dt or (dt - dx - dy) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if (x + y) > t or (x + y + t) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
t1 = 0
x1 = 0
y1 = 0
count = 0
for _ in range(n):
    t,x,y = map(int,input().split())
    t = abs(t - t1)
    x = abs(x - x1)
    y = abs(y - y1)
    if x + y <= t and (x+y) % 2 == t % 2:
        t1 = t
        x1 = x
        y1 = y
        count += 1
if count == n:
    print("Yes")
else:
    print("No")

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

for i in range(N):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dt < dist:
        print("No")
        exit(0)

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

print("Yes")

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
for i in txy:
    if i[0] % 2 != (i[1] + i[2]) % 2 or (i[1] + i[2]) > i[0]:
        print("No")
        exit()
print("Yes")

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

Solution (Python):
import sys


n=int(input())
t=0
x=0
y=0
s="Yes"
for i in range(n):
  t1,x1,y1=map(int,sys.stdin.readline().split())
  if abs(x1-x)+abs(y1-y) > (t1-t):
    s="No"
    break
  if ((x1 + y1) % 2) == (t1 % 2):
    x=x1
    y=y1
    t=t1
  else:
    s="No"
    break

print(s)

Solution (Python):
n = int(input())
pre_t, pre_x, pre_y = 0, 0, 0
for i in range(n):
    t , x, y = map(int, input().split())
    dt = t - pre_t
    dist = abs(x - pre_x) + abs(y -pre_y)
    if dist > dt or (dist+dt)%2 != 0:

        print("\nNo") 
        exit()
    pre_t, pre_x, pre_y = t, x, y
print("Yes")

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


t = []
xy = []
for i in range(n):
    a, b, c = map(int, input().split())
    t.append(a)
    xy.append([b, c])

point = xy[0][0]+xy[0][1]
if n == 1:
    if point == t[0]:
        print("Yes")
    elif point < t[0] and (t[0]-point) % 2 == 0:
        print("Yes")
    else:
        print("No")
else:

    if point > t[0] or (point < t[0] and (t[0]-point) % 2 == 1):
        print("No")
        exit()

    for i in range(1, n):
        point += abs(xy[i][0]-xy[i-1][0]) + abs(xy[i][1]-xy[i-1][1])
        if point > t[i] or (point < t[i] and (t[i]-point) % 2 == 1):
            print("No")
            exit()
    print("Yes")

Solution (Python):
n = int(input())
txy = []
for _ in range(n):
    t, x, y = map(int, input().split())
    txy.append((t, x, y))
pt = px = py = 0
for t, x, y in txy:
    l = abs(x-px)+abs(y-py)
    if l>t-pt or (t-pt-l)%2==1:
        print('No')
        break
    pt, px, py = t, x, y
else:
    print('Yes')

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

ans = 'Yes'
nt = 0; nx = 0; ny = 0

for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - nt; dx = abs(x - nx); dy = abs(y - ny)
    if dx + dy > dt or (dx + dy - dt)%2 == 1:
        ans = 'No'
        break
    nt = t; nx = x; ny = y

print(ans)

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

ok = True

for i in range(n):
    delta_t = t[i+1] - t[i]
    delta_x = x[i+1] - x[i]
    delta_y = y[i+1] - y[i]
    if delta_t < delta_x + delta_y:
        ok = False
    else:
        if abs(delta_x + delta_y - delta_t)%2 != 0:
            ok = False

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

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

prev_t, prev_x, prev_y = 0, 0, 0
flag = 'Yes'

for i in range(N):
  next_t, next_x, next_y = map(int, input().split())

  t = next_t - prev_t
  x = next_x - prev_x
  y = next_y - prev_y
  
  if x+y > t or (t-(x+y))%2 != 0:
    flag = 'No'
    break
  prev_t, prev_x, prev_y = next_t, next_x, next_y

print(flag)

Solution (Python):
N = int(input())
x = 0
y = 0
t = 0
for _ in range(N):
    ti, xi, yi = map(int, input().split())
    dist = abs(x-xi) + abs(y-yi)
    flag = False
    if dist % 2 == 0 and not t % 2 == ti % 2:
        flag = True
    elif not dist % 2 == 0 and t % 2 == ti % 2:
        flag = True
    if dist > ti - t or flag:
        print('No')
        exit()
    x = xi
    y = yi
    t = ti

print('Yes')

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def judge(s, g):
    t = g[0] - s[0]
    x = g[1] - s[1]
    y = g[2] - s[2]
    if (abs(x)+abs(y)) % 2 == t % 2 and (abs(x)+abs(y)) <= t:
        return True
    else:
        return False


def main():
    
    n = int(input().strip())
    txy = [(0, 0, 0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int, input().strip().split())
        txy.append((tmp1, tmp2, tmp3))
    txy.sort()
    n += 1

    
    for i in range(0, n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


















def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def judge(s,g):
    t=g[0] - s[0]
    x=g[1] - s[1]
    y=g[2] - s[2]
    eprint('x,y,t ',end=':\n')
    eprint(x,y,t)
    if (abs(x)+abs(y))%2 == t%2 and (abs(x)+abs(y))<=t:
        return True
    else:
        return False


def main():
    n = int(input().strip())
    txy=[(0,0,0)]
    for i in range(n):
        tmp1, tmp2, tmp3 = map(int,input().strip().split())
        txy.append((tmp1,tmp2,tmp3))
    txy.sort()
    n+=1

    for i in range(0,n-1):
        if judge(txy[i], txy[i+1]) != True:
            print("No")
            return
    print("Yes")

        




if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
pt, px, py = 0, 0, 0
for _ in range(N):
    ct, cx, cy = map(int, input().split())
    diff_t = ct - pt
    diff_x = cx - px
    diff_y = cy - py

    diff_xy = abs(diff_x+diff_y)
    if diff_xy > diff_t:
        print('No')
        exit()
    if (diff_xy + diff_t) % 2 != 0:
        print('No')
        exit()

    px = cx
    py = cy
    pt = ct

print('Yes')

Solution (Python):
n = int(input())
pt = 0
px = 0
py = 0
tmp = []
can = True

for i in range(n):
    tmp = list(map(int, input().split()))
    t = tmp[0]
    x = tmp[1]
    y = tmp[2]
    dist = abs(x-px) + abs(y-py)
    if dist > t-pt or (px+py+t-pt)%2 != (x+y)%2:
        can = False
        break

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

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

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

Solution (Python):

n, *a = map(int, open(0).read().split())
a = [0]*3 + a
for i in range(n):
    i *= 3
    t, x, y = map(lambda j:abs(a[i+3+j]-a[i+j]), [0,1,2])
    d = x+y
    if d>t or d%2-t%2: print("No"); exit()
print("Yes")

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(input())
    T = [0] * (N+1)
    XY = [[0,0] for _ in range(N+1)]
    ans = 'Yes'
    for i in range(1,N+1):
        T[i],XY[i][0],XY[i][1] = map(int, input().split())
    for i in range(N):
        t = T[i+1] - T[i]
        d = abs(XY[i+1][0]-XY[i][0]) + abs(XY[i+1][1]-XY[i][1])
        if t<d or (t-d)%2==1:
            ans = 'No'

    print(ans)



if __name__ == '__main__':
    main()

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

ans = 'Yes'
for t, x, y in P:
    if x + y > t:
        ans = 'No'
        break
    if (x + y) % 2 != t % 2:
        ans = 'No'
        break

print(ans)

Solution (Python):
n = int(input())
dia = [[0,0,0] for _ in range(n)]
for i in range(n):
    t, x, y = map(int, input().split())
    dia[i][0] = t
    dia[i][1] = x
    dia[i][2] = y
t = 0
x = 0
y = 0
ans = "Yes"
for i in range(n):
    r = abs(dia[i][1] - x) + abs(dia[i][2] - y)
    if (dia[i][0] - t < r) or (dia[i][0] - t >= r and (dia[i][0] - t - r) & 1) :
        ans = "No"
        break
    t = dia[i][0]
    x = dia[i][1]
    y = dia[i][2]
print(ans)

Solution (Python):

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

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

now = [0,0,0]
flg = True
for i in range(n):
    next = grid[i]
    time = next[0] - now[0]
    if time >= distance(now[1],now[2],next[1],next[2]) and (time - distance(now[1],now[2],next[1],next[2])) % 2 == 0:
        now = next
    else:
        flg = False
        break
        
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
def myAnswer(N:int, txy:list) -> str:
   time = 0
   now = [0,0]
   ans = "Yes"
   for t,x,y in txy:
      counter = t - time
      dx = abs(x - now[0])
      dy = abs(y - now[1])
      if(counter % (dx + dy) != 0):
         ans = "No"
         break
      else:
         time = t
         now =[x,y]
   return ans


def modelAnswer():
   return
def main():
   N = int(input())
   txy = []
   for _ in range(N):
      txy.append(list(map(int,input().split())))
   print(myAnswer(N,txy[:]))
if __name__ == '__main__':
   main()

Solution (Python):



N = int(input())

oldest_t = 0
oldest_x = 0
oldest_y = 0
for i in range(N):
    t, x, y = map(int, input().split())
    
    distans_t=t-oldest_t
    distans_x=abs(x - oldest_x)
    distans_y=abs(y - oldest_y)
    
    
    distans =  distans_t - distans_x - distans_y
    
    
    if distans >= 0 and distans % 2==0:
        oldest_x = x
        oldest_y = y
        oldest_t = t
        continue
    else:
        print("No")
        exit()





print("Yes")

Solution (Python):
import sys
N = int(input())
turn = 0
x, y = 0, 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0]%2 == 0 and (a[1]+a[2])%2 == 1:
        print("No")
        sys.exit()
    if a[0]%2 == 1 and (a[1]+a[2])%2 == 0:
        print("No")
        sys.exit()
    if (a[0] - turn) < abs(x - a[1]) + abs(y - a[2]):
        print("No")
        sys.exit()
print('Yes')

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

tprev = 0
xprev = 0
yprev = 0

result = 'Yes'

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

    xlen = abs(x - xprev)
    ylen = abs(y - yprev)
    
    time = t - tprev

    length = xlen + ylen

    if time%2 == length%2 and time >= length:
        tprev = t
        xprev = x
        yprev = y

    else:
        result = 'No'
        break
print(result)

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

ans = "Yes"
before = [0, 0, 0]
for plan in plans:
    
    dt = plan[0] - before[0]
    dx = abs(plan[1] - before[1])
    dy = abs(plan[2] - before[2])

    if dt >= (dx+dy) and ((dt % 2 == 0 and (dx+dy) % 2 == 0) or (dt % 2 == 1 and (dx+dy) % 2 == 1)):
        pass
    else:
        ans = "No"
        break
    before = plan[:]
    
print(ans)

Solution (Python):
import sys
n = int(input())
t1 , x1 , y1 = 0 , 0 , 0
for i in range(n):
    t2,x2,y2=map(int,input().split())
    if t2-t1<abs(x1-x2)+abs(y1-y2) or (t2-t1-abs(x1-x2)-abs(y1-y2))%2==1:
        print('No')
        sys.exit()
    t1,x1,y1=t2,x2,y2
print('Yes')

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

t = x = y = 0
for _ in range(n):
    t_, x_, y_ = map(int, input().split())
    dt, dx, dy = (t_ - t), abs(x_ - x), abs(y_ - y)

    if dx + dy > dt:
        print("No")
        exit()

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

    t, x, y = t_, x_, y_

print("Yes")

Solution (Python):
N = int(input())
t, x, y = 0, 0, 0
for i in range(N):
    t_1, x_1, y_1 = map(int, input().split())
    distance = abs(x - x_1) + abs(y - y_1)
    if distance > t_1 - t or (t_1 - t - distance) % 2 != 0:
        print("No")
        exit()
print("Yes")

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

Solution (Python):
from sys import exit

n = int(input())

ans = 0
for q in range(n):
    limit, x, y = map(int, input().split())
    if (limit < x + y) or (limit - x - y) % 2:
        print("No")
        exit(0)


print("Yes")

Solution (Python):


def main():
    
    n = int(input())
    
    plans = []
    for i in range(n):
        a, b, c = map(int, input().split())
        plans.append((a, b, c))

    
    for x in plans:
        if (x[0] + x[1] + x[2]) % 2 == 1:
            print("No")
            return

    
    pre_p = (0, 0, 0)
    for p in plans:
        time_diff = p[0] - pre_p[0]
        x_diff = abs(p[1] - pre_p[1])
        y_diff = abs(p[2] - pre_p[2])
        if time_diff < x_diff + y_diff:
            print("No")
            return
        pre_p = p

    print("Yes")


main()

Solution (Python):
n = int(input())
bx = 0
by = 0
bt = 0
def p(t,x,y):
  if abs(x)+abs(y) > t:
    return True
  elif (t-abs(x)-abs(y))%2 == 1:
    return True
  else:
    return False
for _ in range(n):
  at,ax,ay = map(int,input().split())
  if p(at-bt,bx-ax,by-ay):
    print("No")
    exit()
  bx = ax
  by = ay
  bt = at
print("Yes")

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

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

Solution (Python):
n = int(input())
TXY = [list(map(int,input().split())) for i in range(n)]
t = 0
x = 0
y = 0
ok = 0
            
for i in range(n):
    time = TXY[i][0]-t
    distance = abs(TXY[i][1]-x) + abs(TXY[i][2]-y)
    if time >= distance:
        if time%2 == distance%2:
            ok += 1
            
print("YNeos"[ok<n::2])

Solution (Python):
n = int(input())
t_list = [0]
x_list = [0]
y_list = [0]
for _ in range(n):
    data = input().split(' ')
    t_list.append(int(data[0]))
    x_list.append(int(data[1]))
    y_list.append(int(data[2]))
for i in range(n):
    t_diff = t_list[i + 1] - t_list[i]
    x_diff = abs(x_list[i + 1] - x_list[i])
    y_diff = abs(y_list[i + 1] - y_list[i])
    manhattan_dist = x_diff + y_diff
    if t_diff < manhattan_dist or (manhattan_dist - t_diff) % 2 == 1:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    chp = [[int(item) for item in input().split()] for _ in range(N)]

    def root_chk(a, b):

        delta_t = b[0] - a[0]
        shortest_path = abs(a[1] - b[1]) + abs(a[2] - b[2])

        if shortest_path > delta_t:
            return False

        elif (delta_t - shortest_path) % 2 == 1:
            return False
        else:
            return True
    


    for i in range(N):

        if i == 0:
            
            if root_chk([0,0,0], chp[0]):
                pass
            else:
                print('No')
                break
        else:
            
            if root_chk(chp[i-1], chp[i]):
                pass
            else:
                print('No')
                break
    else:
        print('Yes')


if __name__ == "__main__":
    resolve()

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

n = int(input())
LL = [list(map(int,input().split())) for _ in range(n)]
t0,x0,y0 = 0,0,0
ans = "Yes"
for l in LL:
    t,x,y = l[0],l[1],l[2]
    dist = func(x0,y0,x,y)
    time = t-t0
    if dist-time > 0 or (dist-time <= 0 and (dist-time)%2 == 1):
        ans = "No"
        break
print(ans)

Solution (Python):
def main():
    N = int(input())
    plan = [[int(a) for a in input().split()] for i in range(N)]
    possible = True

    for i in range(N):
        d = 0
        dt = 0

        if i == 0:
            d = abs(plan[i][1] - 0) + abs(plan[i][2] - 0)
            dt = plan[i][0] - 0
        else:
            d =  abs(plan[i][1] - plan[i-1][1]) + abs(plan[i][2] - plan[i-1][2])
            dt = plan[i][0] - plan[i-1][0]

        if d == dt or ( d < dt and d % 2 == dt % 2 ):
            pass
        else:
            possible = False
            break

    if possible:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

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())
    
yn=""
for i in range(n):
    ti=t[i+1]-t[i]
    d=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if d>ti or ti%2!=d%2:
        yn="No"
        break
    
if yn=="No":
    print("No")
else:
    print("Yes")

Solution (Python):
N = int(input())
plan = [[0]*3 for i in range(N+1)]
for i in range(1,N+1):
    plan[i][0],plan[i][1],plan[i][2] = map(int,input().split())

flag = 0

for i in range(N):
    dt = plan[i+1][0] - plan[i][0]
    dist =  abs(plan[i+1][1]-plan[i][1]) + abs(plan[i+1][2]-plan[i][2])
    if dt < dist or dt%2 != dist%2:
        print("No")
        flag = 0
        break
    else:
        flag = 1

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

Solution (Python):
n=int(input())
a=[[int(i) for i in input().split()] for l in range(n)]
nx=0
ny=0
day=0
for x in a:
    tx=abs(x[1]-nx)
    ty=abs(x[2]-ny)
    tday=x[0]-day
    if (tx+ty-tday)%2==0 and tx+ty<=tday:
        nx=x[1]
        ny=x[2]
        day=x[0]
    else:
        print("No")
        break
else:print("Yes")

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

for i in range(n):
    t_dif = txy_l[i+1][0] - txy_l[i][0]
    x_dif = txy_l[i+1][1] - txy_l[i][1]
    y_dif = txy_l[i+1][2] - txy_l[i][2]
    spare_time = t_dif - (abs(x_dif)+abs(y_dif))
    if spare_time < 0 or spare_time%2 != 0:
        judge = 'No'

print(judge)

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

flag = True
txy.insert(0,[0,0,0])
for i in range(n):
    t = txy[i+1][0] - txy[i][0]
    d = abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2]-txy[i][2])
    if t < d:
        flag = False
    elif t == d:
        continue
    elif (t-d) % 2 != 0:
        flag = False

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

Solution (Python):
class Traveling:
    def calculate(self, N: int, T: list) -> bool:
        for t in T:
            n = int(t[1]) + int(t[2])
            if n % 2 !=0:
                n_is = "odd"
            else: 
                n_is = "even"
            if int(t[0]) % 2 != 0:
                t0_is = "odd"
            else:
                t0_is = "even"
            
            if int(t[0]) < n or n_is != t0_is:
                return False
        return True

if __name__ == '__main__':
    N = int(input())
    T = [input().split() for i in range(N)]
    t = Traveling()
    res = t. calculate(N, T)
    if res:
        print("Yes")
    else:
        print("No")

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

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



for i in range(N):
  if abs(x[i][0]-x[i+1][0])<(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2])):
    flag=1
  if x[i][1]==x[i+1][1] and x[i][2]==x[i+1][2]:
    flag=1
  if abs(x[i][0]-x[i+1][0])%2!=(abs(x[i][1]-x[i+1][1])+abs(x[i][2]-x[i+1][2]))%2:
    flag=1

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

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

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

ans='Yes'
for i in range(1,N+1):
    if T[i][0]-T[i-1][0]<abs(T[i][1]-T[i-1][1])+abs(T[i][2]-T[i-1][2]):
        ans='No'
    
for j in range(1,N+1):
    if (T[j][1]+T[j][2])%2!=T[j][0]%2:
        ans='No'

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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

print('Yes')

Solution (Python):
n=int(input())
mt,mx,my=0,0,0
p=True
for i in range(n):
    t,x,y=map(int,input().split())
    
    if abs(mx-x)+abs(my-y)<=t-mt and (t-mt)%2==(abs(mx-x)+abs(my-y))%2:
        mt,mx,my=t,x,y
    else:
        p=False
        print('No')
        break
        
if p:
    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())
    t.append(ti)
    x.append(xi)
    y.append(yi)

can = True
for i in range(n):
    dt=t[i+1]-t[i]
    dist=(x[i+1]-x[i])+(y[i+1]-y[i])
    if(dt<dist):
        can=False
    if(dist%2 != dt%2):
        can=False
if(can):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
point_list = [{'t_0':0, 'x_0':0, 'y_0':0}]
cnt = 0

for i in range(1, N + 1):
    time, x, y = list(map(int, input().split()))
    point_dict = {}
    point_dict['t_{}'.format(i)] = time
    point_dict['x_{}'.format(i)] = x
    point_dict['y_{}'.format(i)] = y
    point_list.append(point_dict)

for i in range(N):
    time = point_list[i + 1]['t_{}'.format(i + 1)] - point_list[i]['t_{}'.format(i)]
    xdist = abs(point_list[i + 1]['x_{}'.format(i + 1)] - point_list[i]['x_{}'.format(i)])
    ydist = abs(point_list[i + 1]['y_{}'.format(i + 1)] - point_list[i]['y_{}'.format(i)])
    if time >= xdist + ydist and time % 2 == (xdist + ydist) % 2:
        continue
    else:
        print('No')
        cnt += 1
        break

if cnt == 0:
    print('Yes')

Solution (Python):
t = [0]
x = [0]
y = [0]
n = int(input())
for i in range(n):
  ti, xi, yi = map(int,input().split())
  t.append(ti)
  x.append(xi)
  y.append(yi)
  
flg = True 
for i in range(1,n+1):
  if (t[i]-t[i-1]) < (x[i]-x[i-1]+y[i]-y[i-1]):
    flg = False
  elif ((t[i]-t[i-1])%2) != ((x[i]-x[i-1]+y[i]-y[i-1])%2):
    flg = False
if(flg):
  print("Yes")
else:
  print("No")

Solution (Python):
t = [0]
x = [0]
y = [0]
n = int(input())
for i in range(n):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
    
flg=True
for i in range(1, n+1):
    if((x[i]-x[i-1])+(y[i]-y[i-1])>(t[i]-t[i-1])):
        flg=False
    elif(((x[i]-x[i-1])+(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2):
        flg=False
if(flg):
    print("Yes")
else:
    print("No")

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



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

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

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

aFlg = True 

for i,tm in enumerate(t):
  xm = 0
  ym = 0
  if i > 0:
    if x[i] > x[i-1]:
      xm = x[i] - x[i-1]
    else:
      xm = x[i-1] - x[i]

    if y[i] > y[i-1]:
      ym = y[i] - y[i-1]
    else:
      ym = y[i-1] - y[i]

    if xm + ym > (t[i] - t[i-1]):  
      aFlg = False
      break
    elif ((t[i] - t[i-1]) - (xm+ym))%2 == 1:  
      aFlg = False
      break

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

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

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

Solution (Python):
t = [0]
x = [0]
y = [0]
n = int(input())
for i in range(n):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)
    
flg=True
for i in range(1, n+1):
    if((x[i]-x[i-1])+(y[i]-y[i-1])>(t[i]-t[i-1])):
        flg=False
    elif(((x[i]-x[i-1])+(y[i]-y[i-1]))%2!=(t[i]-t[i-1])%2):
        flg=False
if(flg):
    print("Yes")
else:
    print("No")