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):
if __name__ == '__main__':
    N = int(input()) + 1
    P = [list(map(int, input().split())) for x in range(N-1)]
    P.insert(0, [0,0,0])
    
    for i in range(1, N):
        t = abs(P[i-1][0] - P[i][0])
        
        if t%2 == 0:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 0:
                pass
            else:
                break
        
        else:
            if (abs( sum(P[i-1][1:]) - sum(P[i][1:]) ) <= t) and (abs( sum(P[i-1][1:]) - sum(P[i][1:]))) % 2 == 1:
                pass
            else:
                break
    else:
        print('Yes')
        exit()
    print('No')

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

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

print("Yes")

Solution (Python):
N = int(input())
x = []
y = []
t = []
distance = []
x.append(0)
y.append(0)
t.append(0)

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

dis = 0
flag = True
for i in range(1,N+1):
    time = t[i] - t[i-1]
    dis = abs(x[i] -x[i-1])+abs(y[i] - y[i-1])
    
    
    if time != dis :
        if time < dis:
            
            flag = False
        elif time - dis > 0 and (time-dis) %2 == 1:
            
            flag = False

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

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

TXY = []
for i in range(N):
    txy = [int(x) for x in input().split()]
    TXY.append(txy)


def solve(TXY):
    px, py, pt = 0, 0, 0
    for t, x, y in TXY:
        dt = abs(x - px) + abs(y - py) - (t - pt)
        if dt > 0 or dt % 2 == 1:
            return "No"
        px, py, pt = x - px, y - py, t - pt
    return "Yes"

print(solve(TXY))

Solution (Python):
from collections import namedtuple

Point = namedtuple('Point', 't x y')

def canMove(p1, p2):
  dt = p2.t - p1.t
  dx = p2.x - p1.x
  dy = p2.y - p1.y
  if dx + dy > dt:
    return False
  if (dt - (dx + dy)) % 2 == 0:
    return True
  return False

N = int(input())
prev = Point(0, 0, 0)
for _ in range(N):
  t, x, y = map(int, input().split())
  next = Point(t, x, y)
  if not canMove(prev, next):
    print('No')
    break
  prev = next
else:
  print('Yes')

Solution (Python):
N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N
for i in range(N):
    t, x, y = map(int, input().split())
    if ((x+y)%2) != (t%2):
        print('No')
        exit()
    if t < x+y:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
t = 0
x = 0
y = 0
for _ in range(n):
    tt, xt, yt = map(int, input().split())
    tt -= t
    m = abs(xt - x) + abs(yt - y)
    if m > tt:
        print('No')
        exit()
    elif m < tt:
        if m%2 != tt%2:
            print('No')
            exit()
    t += tt
    x = xt
    y = yt
print('Yes')

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

T = 0 
X = 0 
Y = 0 
flag = True
for _ in range(N):
    t, x, y = map(int, input().split())
    a = abs(X-x) + abs(Y-y) 
    if a <= t-T and ((t-T)-a)%2 == 0:
        T = t
        X = x
        Y = y
    else:
        flag = False

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

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

t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = P[i]
    dt, dx, dy = (t - t0), (x - x0), (y - y0)
    dd = abs(dx) + abs(dy)
    if not (dd <= dt and dd % 2 == dt % 2):
        print('No')
        break
    t0, x0, y0 = t, x, y
else:
    print('Yes')

Solution (Python):

import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if ((x + y) % 2) != (t % 2):
        print('No')
        sys.exit()
    if t < x + y:
        print('No')
        sys.exit()
print('Yes')

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

for i in range(1,N+1):
    t[i],x[i],y[i] = map(int, input().split())
    a = t[i] - t[i-1]
    b = abs(x[i] - x[i-1])
    c = abs(y[i] - y[i-1])
    if a % 2 == 0:
        if b + c <= a and (b + c) % 2 == 0:
            continue
        else:
            print('No')
            exit()
    else:
        if b + c <= a and (b + c) % 2 == 1:
            continue
        else:
            print('No')
            exit()

print('Yes')

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()

  t=x=y=f=0
  for _ in range(n):
    _t,_x,_y=LI()
    
    _t-=t
    _t-=abs(x-_x)
    _t-=abs(y-_y)

    if _t<0:
      f=1
    elif _t%2!=0:
      f=1

  if f==1:
    return 'No'
  else:
    return 'Yes'

print(main())

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input())
    t = []
    x = []
    y = []
    for i in range(N):
        s1,s2,s3 = (int(_) for _ in input().split())
        t.append(s1)
        x.append(s2)
        y.append(s3)

    if x[0] + y[0] > t[0]:
        print('No')
        return
    
    for i in range(1,N):
        d = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
        if  d > t[i] - t[i-1]:
            print('No')
            return
        if (t[i] - t[i-1])%2 != d %2:
            print('No')
            return
        
    print('Yes')
    
if __name__ == '__main__':
    main()

Solution (Python):



import os
import sys





__author__ = 'acto_mini'
__date__ = "2019/06/02"


def main():
    
    os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))

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

    
    num = int(input())

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

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

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

    return


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
t_list = [0]*(n+1)
x_list = [0]*(n+1)
y_list = [0]*(n+1)
for i in range(n):
    t_list[i+1], x_list[i+1], y_list[i+1] = map(int,input().split())
for i in range(n):
    d = abs(x_list[i+1] - x_list[i]) + abs(y_list[i+1] - y_list[i])
    t = t_list[i+1] - t_list[i]
    if  t<d or t%2 != d%2:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
a = [[0, 0, 0]]
for i in range(N):
    a.append([int(x) for x in input().split()])

for i in range(N):
    dist = abs(a[i+1][1] - a[i][1]) + abs(a[i+1][2] - a[i][2])
    time = a[i+1][0] - a[i][0]
    if time < dist or (time - dist) % 2 != 0:
        print('No')
        exit()

print('Yes')

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    txy_list = [[0,0,0]] + [list(map(int, input().split())) for i in range(N)]

    answer = "Yes"
    for i in range(1, len(txy_list)):
        before_t = txy_list[i-1][0]
        t = txy_list[i][0]
        before_x = txy_list[i-1][1]
        x = txy_list[i][1]
        before_y = txy_list[i-1][2]
        y = txy_list[i][2]

        if t - before_t < (x - before_x) + (y - before_y):
            answer = 'No'
            break
        elif ((t - before_t) - ((x - before_x) + (y - before_y)))%2 != 0:
            answer = 'No'
            break

    print(answer)

Solution (Python):
n = int(input())
pos = [[int(i) for i in input().split()] for i in range(n)] 

x = 0
y = 0
cur = 0
ans = "Yes"
for i in pos:
  maximum = abs((i[1] - x) + (i[2] - y))
  if maximum > i[0] - cur:
    ans = "No"
    break
  elif maximum % 2 != (i[0] - cur) % 2:
    ans = "No"
    break
  x = i[1]
  y = i[2]
  cur = i[0]
print(ans)

Solution (Python):
N = int(input())
TXY = [[int(x) for x in input().split()] for _ in range(N)]

pt,px,py = 0,0,0

bl = True
for t,x,y in TXY:
  dt = abs(t-pt)
  dx = abs(x-px)
  dy = abs(y-py)
  px = x
  py = y
  pt = t
  if dt < dx+dy:
    bl = False
    break
  if (dt-(dx+dy))&1:
    bl = False
    break

print('Yes' if bl else 'No')

Solution (Python):
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    prev = (0, 0, 0)
    for _ in range(N):
        T, X, Y = prev
        t, x, y = MI()
        if abs(x - X) + abs(y - Y) <= abs(T - t):
            if (abs(x - X) + abs(y - Y) - (T - t)) % 2 != 0:
                print("No")
                exit()
        else:
            print("No")
            exit()
        prev = (t, x, y)
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    ret = YES
    t = [0] + t
    x = [0] + x
    y = [0] + y
    for i in range(1, N + 1):
        
        dis = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
        time = t[i] - t[i - 1]
        if dis > time or dis % 2 != time % 2:
            
            ret = NO
            break
    print(ret)
    return


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))
    solve(N, t, x, y)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
txy = [[0, 0, 0]] + txy
for i in range(1, len(txy)):
  dt = txy[i][0] - txy[i-1][0]
  dist = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
  if dt < dist or dt%2 != dist%2:
    print('No')
    exit()
print('Yes')

Solution (Python):
N = int(input())
count = 0
x = 0
y = 0
t = 0

for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    way = abs(x_i - x) + abs(y_i - y)
    time = t_i - t

    if way <= time:
        if way % 2 == time % 2:
            count += 1
    x = x_i
    y = y_i
    t = t_i

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

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())
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())
info = [list(map(int, input().split())) for i in range(n)]

info.insert(0, [0, 0, 0])
x_diff, y_diff = 0, 0

for i in range(n):
    dt = info[i+1][0] - info[i][0]
    x_diff = abs(info[i+1][1] - info[i][1])
    y_diff = abs(info[i+1][2] - info[i][2])
    if dt < x_diff + y_diff:
        print('No')
        exit()
    if dt%2 != (x_diff + y_diff)%2:
        print('No')
        exit()

print('Yes')

Solution (Python):
N =int(input())
L = [(list(map(int, input().split()))) for _ in range(N)]
ans = ('Yes')
L.insert(0, [0, 0, 0])
for i in range(N):
	if L[i+1][0]-L[i][0] < L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2] or ((L[i+1][1]+L[i+1][2]-L[i][1]-L[i][2])+(L[i+1][0]-L[i][0]))%2==1:
		ans = ('No')
		break
print(ans)

Solution (Python):



def main():
    num = int(input())
    start = [0, 0, 0]
    flg = 1
    for i in range(num):
        data = list(map(int, input().split()))
        time_data = data[0] - start[0]
        kyori = abs(data[1] - start[1]) + abs(data[2] - start[2])
        
        if time_data == kyori:
            start = data
        elif time_data < kyori:
            flg = 0
            break
        elif (time_data - kyori) % 2 == 0:
            start = data
        else:
            flg = 0
            break

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




if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
txy=list(list(map(int,input().split())) for _ in range(N))
for i in range(N):
    if i!=0 and not((txy[i][0]-txy[i-1][0]>=(txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))\
            and ((txy[i][0]-txy[i-1][0])%2==((txy[i][1]+txy[i][2])-(txy[i-1][1]+txy[i-1][2]))%2)):
        print('No')
        exit()
    elif i==0 and not((txy[i][0]>=(txy[i][1]+txy[i][2]))\
            and ((txy[i][0])%2==(txy[i][1]+txy[i][2])%2)):
        print('No')
        exit()
print('Yes')

Solution (Python):
n=int(input())
t,x,y=0,0,0
for i in range(n):
     t_,x_,y_=map(int,input().split())
     l=abs(x-x_)+abs(y-y_)
     if l<=t_-t and (t_-t-l)%2==0:
          t,x,y=t_,x_,y_
     else:
          print('No')
          break
else:
     print('Yes')

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

current = [0, 0]
time  = 0
is_valid = True

for _ in range(N):
    t, x, y = map(int, input().split())
    distance = t - time - (abs(current[0] - x) + abs(current[1] - y))
    if distance < 0 or distance % 2 != 0:
        is_valid = False
        break
    else:
        current = [x, y]
        time = t

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

Solution (Python):
n = int(input())
x = 0
y = 0
t = 0
a = 0
def trav(a,b,c,d,e,f):
    if abs(a-b) + abs(c-d) <= e - f and ((a-b) % 2 + (c-d) % 2)%2 == (e-f) % 2:
        return 0
    else:
        return 1
for i in range(n):
    tn,xn,yn = map(int,input().split())
    if trav(xn,x,yn,y,tn,t) == 0:
        x = xn
        y = yn
        t = tn
    else:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import math
import fractions
import copy

def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


n = ip()                                     











pt,px,py = 0,0,0
for i in range(n):
    t,x,y = (int(i) for i in input().split())
    time = t - pt
    dist = abs(x-px)+abs(y-py)
    if dist>time:j(0)
    if (time-dist)%2:j(0)
j(1)

Solution (Python):
n = int(input())
x = 0
y = 0
t = 0
a = 0
def trav(a,b,c,d,e,f):
    if abs(a-b) + abs(c-d) <= e - f and ((a-b) % 2 + (c-d) % 2)%2 == (e-f) % 2:
        return 0
    else:
        return 1
for i in range(n):
    tn,xn,yn = map(int,input().split())
    if trav(xn,x,yn,y,tn,t) == 0:
        x = xn
        y = yn
        t = tn
    else:
        a = 1
if a == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
x = [0]
y = [0]
t = [0]
fl = True
def judge(a,b,c,d,e,f):
    if abs(b-a)+abs(d-c) <= f-e and abs(b+d-a-c)%2 == abs(f-e)%2:
        return False
    return True
for i in range(n):
    tt,xx,yy = map(int,input().split())
    x.append(xx)
    y.append(yy)
    t.append(tt)
    if judge(x[i],x[i+1],y[i],y[i+1],t[i],t[i+1]):
        fl = False
if(fl):
    print("Yes")
else:
    print("No")

Solution (Python):
n,*t=map(int,open(0).read().split())
s=i=j=0
for t,x,y in zip(t[::3],t[1::3],t[2::3]):
  d=abs(y-i)+abs(x-j)
  if t-s<d or d%2!=(t-s)%2:
    print('No')
    exit()
  s,i,j=t,y,x
print('Yes')

Solution (Python):
n,*t=map(int,open(0).read().split())
s=i=j=0
for t,x,y in zip(t[::3],t[1::3],t[2::3]):
  d=abs(y-i)+abs(x-j)
  if t-s<d or d%2!=(t-s)%2:
    print('No')
    exit()
  s,i,j=t,y,x
print('Yes')

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


def solve():
    for i in range(1, len(txy)):
        if (
            txy[i][0] - txy[i - 1][0]
            < (abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2]))
        ) or (
            (txy[i][0] - txy[i - 1][0]) % 2
            != (abs(txy[i][1] - txy[i - 1][1]) + abs(txy[i][2] - txy[i - 1][2])) % 2
        ):
            print("No")
            return 0
    print("Yes")
    return 0


solve()

Solution (Python):
def get_distance(from_x, from_y, to_x, to_y) :
    distance_x = abs(from_x - to_x)
    distance_y = abs(from_y - to_y)
    return distance_x + distance_y

def main() :
    N = int(input())
    action_list = []
    for i in range(N) :
        action_list.append([int(i) for i in input().split()])
    
    from_x = 0
    from_y = 0
    now_t = 0

    for action in action_list :
        t = action[0]
        to_x = action[1]
        to_y = action[2]

        d = get_distance(from_x, from_y, to_x, to_y)
        if (d > (t - now_t) or (t-now_t) % 2 != d%2) :
            print("No")
            return
        
        from_x = to_x
        from_y = to_y
        now_t = t
    
    print("Yes")
    return


main()

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
f=1
for i in range(n):
  ti=l[i+1][0]-l[i][0]
  dist=abs(l[i+1][1]-l[i][1])+abs(l[i+1][2]-l[i][2])
  if dist>ti:
    f=0
    break
  elif ti%2==0 and dist%2>0:
    f=0
    break
  elif ti%2>0 and dist%2==0:
    f=0
    break
if f==1:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
p=(0,0)
now=0
for _ in range(n):
    t,x,y=map(int,input().split())
    mov=abs(x-p[0])+abs(y-p[1])
    if t-now<mov or (t-now-mov)%2==1:
        print("No")
        break
    p=(x,y)
    now=t
else:print("Yes")

Solution (Python):
def main():
    N = int(input())
    t, x, y, = [0], [0], [0]
    for i in range(N):
        ti, xi, yi = [int(_) for _ in input().split(" ")]
        t.append(ti)
        x.append(xi)
        y.append(yi)

    flag = "Yes"
    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 or dt%2 != dist%2:
            flag = "No"

    print(flag)
main()

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

Solution (Python):
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(tme >= cor and tme % 2 == cor % 2)
print('Yes' if all(ans) else 'No')

Solution (Python):
N = int(input())
X = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(N)]
ans = []
for i in range(N):
  tme = X[i + 1][0] - X[i][0]
  cor = abs(X[i + 1][1] - X[i][1]) + abs(X[i + 1][2] - X[i][2])
  ans.append(max(tme - cor, -1) % 2 == 0)
print('Yes' if all(ans) else 'No')

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

Solution (Python):
N = int(input())
prev = (0, 0, 0)
b = True
for n in range(N):
    next=[int(i) for i in input().split()]
    diff = abs(next[1] - prev[1]) + abs(next[2] - prev[2])
    c = next[0] - prev[0]
    if c - diff < 0 or (c - diff) % 2 != 0:
        print('No')
        b=False
        break
    prev = next
if b:
    print('Yes')

Solution (Python):
t, x, y = 0, 0, 0

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

Solution (Python):


import sys

t,x,y = 0,0,0

N = int(input())


for _ in range(N):
    t1,x1,y1=[int(__) for __ in input().split()]
    delta_t = abs(t1-t)
    delta_x = abs(x1-x)
    delta_y = abs(y1-y)

    if delta_x + delta_y > delta_t:
        print("No")
        sys.exit()

    if (delta_x + delta_y - delta_t) % 2 != 0:
        print("No")
        sys.exit()

    t,x,y = t1,x1,y1

print("Yes")

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

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

c = 0

for i in range(n):
    if l[i][0] < sum(l[i][1:]):
        print('No')
        break
    
    if (l[i][0] % 2) == sum(l[i][1:]) % 2:
        c += 1
    
    else:
        print('No')
        break

if c == n:
    print('Yes')

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

ans=0
for i in range(len(txy)-1):
    time=txy[i+1][0]-txy[i][0]
    dis=txy[i+1][1]-txy[i][1]+txy[i+1][2]-txy[i][2]
    if time>=dis and time%2==dis%2:
        ans+=0
    else:
        ans+=1

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

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

now = 0
p = [0, 0]

for line in (map(int, input().split()) for _ in range(N)):
  t, x, y = line
  d = abs(p[0] - x) + abs(p[1] - y)
  now += d
  if now < t:
    now += math.ceil((t - now)/2)*2
  if now != t:
    print("No")
    break
  p = x, y
else:
  print("Yes")

Solution (Python):
import sys
sys.setrecursionlimit(700000)

n = int(input())
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

def travel(t, x, y, k):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    time_dist = t1-t
    
    if dist <= time_dist and dist%2 == time_dist%2:
        if k+1 == n:
            return "Yes"
        else:
            return travel(t1, x1, y1, k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))

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


time = [0]
x = [0]
y = [0]
for txy in Txy:
    time.append(txy[0])
    x.append(txy[1])
    y.append(txy[2])

def isPossible(N, time, x, y):
    for i in range(N):
        dt = (time[i + 1] - time[i]) ** 2 
        dx = (x[i + 1] - x[i]) ** 2
        dy = (y[i + 1] - y[i]) ** 2

        if dt >= (dx + dy) and (dt%2 == (dx+dy)%2):
            pass
        else:
            return False
    return True

if(isPossible(N, time, x, y)):
    print("Yes")
else :
    print("No")

Solution (Python):
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key=lambda x: x[0])
s = [0] * 3

for i in range(N):
    sa = (X[i][0] - s[0]) - ((X[i][1] - s[1]) + (X[i][2] - s[2]))
    if sa >= 0 and sa % 2 == 0:
        start = X[i]
    else:
        print("No")
        quit()
print("Yes")

Solution (Python):
from sys import stdin
N=int(stdin.readline().rstrip())

data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])

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

for j in data:
    dist = abs(x-j[1]) + abs(y-j[2])
    if dist > j[0] - t:
        flag = False
    if dist == 0:
        flag = False
    if dist % 2 != (j[0] - t) % 2:
        flag = False
        
    t = j[0]
    x = j[1]
    y = j[2]
    
if flag == True:
    print("Yes")
else:
    print("No")

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

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

for l in lst:
  if l[0] % 2 != (abs(l[1]) + abs(l[2])) % 2 or (abs(l[1]) + abs(l[2])) > l[0]:
    print("No")
    exit()

print("Yes")

Solution (Python):
n = int(input())
t,x,y = map(int , input().split())
if x+y>t or (x+y+t)%2 !=0:
	print('No')
	exit()
for i in range(n-1):
	t_i,x_i,y_i = map(int , input().split())
	e=abs(x-x_i)+abs(y-y_i)-t_i-t
	if e>0  or e%2 !=0:
		print('No')
		exit()
	x=x_i
	y=y_i
	t=t_i
print('Yes')

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



def can_reach(p1, p2):
    t = p2[0] - p1[0]
    dist =  abs(p2[1]-p1[1]) + abs(p2[2]-p1[2])
    if dist > t:
        return False
    elif dist == t:
            return True
    elif dist % 2 != t % 2:
            return False 
    elif can_reach(p1, [p2[0]-1, p2[1]+1, p2[2]]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1]-1, p2[2]]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1], p2[2]+1]):
        return True
    elif can_reach(p1, [p2[0]-1, p2[1], p2[2]-1]):
        return True
    else:
        return False

can = True
for i in range(n):
    if not can_reach(place[i], place[i+1]):
        can = False
        break

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

Solution (Python):
def main():
    N = int(input())
    ll = [list(map(int, list(input().split()))) for i in range(N)]
    
    for l in ll:
        t = l[0]
        x = l[1]
        y = l[2]
        if t < x + y:
            print('No')
            return
        if (t % 2) != ((x + y) % 2):
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
 
input = stdin.readline
lines = stdin.readlines
 
N = int(input())
 
txy = ((map(int, line.split())) for line in lines())
t,x,y =(0, 0, 0)
for nt, nx, ny in txy:
    dis=abs(nx-x)+abs(ny-y)
    tim = nt - t
    if tim >= dis and (tim - dis) % 2 ==0:
        t,x,y=nt, nx, ny
    else:
        print('No')
        break
else:
    print('Yes')

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

Solution (Python):
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    else:
      print("No")
      break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")

Solution (Python):
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    else:
      print("No")
      break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")

Solution (Python):
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = map(int, input().split())
    for a in range(t - pre_t + 1):
        b = pre_x - x + a
        if b >= 0:
            for c in range(t - pre_t + 1  - a - b):
                d = t - pre_t - a - b - c
                if pre_y + c - d == y:
                    count += 1
                    flag = True
                    break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
plan = [tuple(map(int, input().split())) for i in range(N)]
plan.insert(0, (0, 0, 0))

for i in range(1, N+1):
     t = plan[i][0] - plan[i-1][0]
     x = abs(plan[i][1] - plan[i-1][1])
     y = abs(plan[i][2] - plan[i-1][2])
     
     if t < x+y or (t - (x+y)) % 2 != 0:
         print('No')
         break
else:
    print('Yes')

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

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

Solution (Python):
N=int(input())
now=(0,0,0)
flag=True
for i in range(N):
    t,x,y=map(int,input().split())
    move=abs(x-now[1])+abs(y-now[2])
    if t-now[0]>=move and (move-t+now[0])%2==0:
        continue
    else:
        flag=False
        break
if flag:
    print('Yes')
else:
    print('No')