Problem:
 Score : 300 points    Problem Statement AtCoDeer the deer is going on a trip in a two-dimensional plane.
In his plan, he will depart from point (0, 0) at time 0 , then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i .  If AtCoDeer is at point (x, y) at time t , he can be at one of the following points at time t+1 : (x+1,y) , (x-1,y) , (x,y+1) and (x,y-1) .
Note that he cannot stay at his place .
Determine whether he can carry out his plan.      Constraints  1  ≤  N  ≤  10^5  0  ≤  x_i  ≤  10^5  0  ≤  y_i  ≤  10^5  1  ≤  t_i  ≤  10^5  t_i  <  t_{i+1} ( 1  ≤  i  ≤  N-1 )  All input values are integers.         Input Input is given from Standard Input in the following format:  N  t_1  x_1  y_1  t_2  x_2  y_2  :  t_N  x_N  y_N       Output If AtCoDeer can carry out his plan, print Yes ; if he cannot, print No .        Sample Input 1 2
3 1 2
6 1 1      Sample Output 1 Yes  For example, he can travel as follows: (0,0) , (0,1) , (1,1) , (1,2) , (1,1) , (1,0) , then (1,1) .       Sample Input 2 1
2 100 100      Sample Output 2 No  It is impossible to be at (100,100) two seconds after being at (0,0) .       Sample Input 3 2
5 1 1
100 1 1      Sample Output 3 No

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


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


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count





N = I()
nx = ny = 0
nt = 0
for _ in range(N):
  t,x,y = IL()
  if abs(nx-x)+abs(ny-y) > t-nt:
    NE()
  if (abs(nx-x)+abs(ny-y) )%2 != (t-nt)%2:
    NE()
  nx = x
  ny = y
  nt = t
Y()

Solution (Python):
import sys
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
a = 0
def sub(p,q):
    return p-q
for i in range(n):
    a = abs(ls[i][1]) + abs(ls[i][2])
    if ((a -ls[i][0]) % 2 != 0) or (a -ls[i][0] > 0):
        print("No")
        sys.exit()
    if i != n-1:
        ls[i+1] = list(map(sub,ls[i+1],ls[i]))
    else:
        pass
print("Yes")

Solution (Python):

import sys

import fractions
import copy
import bisect
import math
import numpy as np
import itertools
from itertools import combinations_with_replacement


from operator import itemgetter
from sys import stdin

from operator import mul
from functools import reduce
from collections import Counter





j=0
k=0
n=3
r=1
a=[0]






"1行1つの整数を入力を取得し、整数と取得する"




"12 21 332 とか入力する時に使う"
"1行に複数の整数の入力を取得し、整数として扱う"

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

for i in number_list:
    print(number_list[i-1])

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'''
x=[]
y=[]
for i in range(N):
    x1, y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)
print(x)
print(y)
"複数行に2数値を入力する形式 x座標とy座標を入力するイメージ"
'''

'''
mixlist=[]
for i in range(N):
    a,b=input().split()
    mixlist.append((int(a),b))
print(mixlist)
"複数行にintとstrを複合して入力するやつ，今回はリスト一つで処理している"
'''

'''



"正方行列にstr型の値を入力"
'''




'''
入力
1 2
4 5
7 8
出力結果
[[1, 2], [4, 5], [7, 8]]
'''
"列数に関して自由度の高いint型の値を入力するタイプの行列"


'''
table = [[int(i) for i in input().split()] for m in range(m)]

print(type(N))
print(N)
print(type(M))
print(M)

print(type(table))
print(table)
'''











'''
入力
1234
出力
1
[[1, 2, 3, 4]]
'''




'''
word_list= input().split(" ")
print(word_list[0])
"連続文字列の入力"
"qw er ty とかの入力に使う"
"入力すると空白で区切ったところでlistの番号が与えられる"
'''



'''
A, B, C=stdin.readline().rstrip().split()
print(A)
"リストではなく独立したstr型を入れるなら以下のやり方でOK"
'''




"aという変数に入っているものを大文字にして出力"

















'''
コンビネーションの組み合わせの中身を出力する形式
for i in itertools.combinations(brray, 2)
combinationsをpermutationsにすれば順列になる
今回なら(abc133B)
入力
1 2
5 5
-2 8
出力
[[1, 2], [5, 5], [-2, 8]]
もちろん一次元リストでも使えるし
何よりiもリストのように使えるので便利
'''


'''
def cmb(n,r):
    
    r= min(n-r,r)
    
    if r == 0: return 1
    over = reduce(mul, range(n, n-r, -1))
    
    
    

    under = reduce(mul, range(1, r+1))
    
    
    
    

    return over // under
    
    
    
    
a = cmb(n, r)

'''

'''
import itertools
from itertools import combinations_with_replacement

combinationについて
以下の違いを意識しよう
combinations() p, r 長さrのタプル列、ソートされた順で重複なし

combinations_with_replacement() p, r 長さrのタプル列、ソートされた順で重複あり


使用例 　　　　　　　　　　　                  出力　　
combinations('ABCD', 2)　　　　　　　　　　　　AB AC AD BC BD CD

combinations_with_replacement('ABCD', 2)　　 AA AB AC AD BB BC BD CC CD DD
'''



'''




for i in a.most_common(n):print(i)





 


'''









'''
bisect.bisect_left(a, x, lo=0, h=len(a))
引数
a: ソート済みリスト
x: 挿入したい値
lo: 探索範囲の下限
hi: 探索範囲の上限
(lo, hiはスライスと同様の指定方法)
bisect_leftはソートされたリストaに対して順序を保ったままxを挿入できる箇所を探索します。leftが示す通り、aにすでにxが存在している場合は、挿入箇所は既存のxよりも左側になります。また、lo, hiを指定することで探索範囲を絞り込むことも可能です。デフォルトはaの全体が探索対象です。
'''

'''
素数の判定
'''


def is_prime(n):
    if n == 1: return False

    for k in range(2, int(np.sqrt(n)) + 1):
        
        if n % k == 0:
            return False
            
    return True


'''
npのmaxとmaximumの違い
xs = np.array([1, -2, 3])
np.max(xs, 0)
この出力は3となります．[1, -2, 3]と0の4つの数字のうち，最も大きい値を出力します．

一方で，[max(1, 0), max(-2, 0), max(3, 0)]を出力したい時があります．
その時は，numpyのmaximum関数を用います．

xs = np.array([1, -2, 3])
np.maximum(xs, 0)  

'''

def factorial(x, mod=10**9+7):
    
    
    
    tmp = 1
    for i in range(1, x+1):
        tmp = (tmp * i) % mod
    return tmp
    '''
    Basically, when you do a**d % n, you actually have to calculate a**d, which could be quite large.
    But there are ways of computing a**d % n without having to compute a**d itself, and that is what pow does.
    '''











'''
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
hexdigits = '0123456789abcdefABCDEF'
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv...\xaf\xb0...
lowercase = 'abcdefghijklmnopqrstuvwxyz'
octdigits = '01234567'
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
punctuation = '!"
uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
whitespace = '\t\n\x0b\x0c\r '
'''
def main():
    n=3
    steps=0
    state=0
    w=1
    j=0
    k=0
    
    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):
        
        if (t[i+1]-t[i]) <(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])):
            print("No")
            sys.exit()
        if (t[i+1]-t[i]-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2!=0:
            print("No")
            sys.exit()
    print("Yes")
    
    
    
    
    
    
    
    

    l = ['aaa', 'bbb', 'ccc']
    x=l.index('aaa')
    
    
    
    

    
        
    
    

    
    
    
    
    DP = np.zeros(w+1, dtype=int)
    exdp=np.zeros((3,4)) 
    
    
    
        
        
    
    
        
        
    


    
    



    '''
    入力
    1234
    出力
    [1, 2, 3, 4]
    '''
    pin_l=["x" for i in range(10)]
    

    ls = ["a", "b", "c", "d", "e"]


    
    

    
    

    
    
    
    
    
    '''
    lsというリストの場合に、1つ飛びの値を取得したい場合には
    ls[::2]
    のようにします。こうすると、
    ["a", "c", "d"]と出力される
    '''

if __name__ == "__main__":
    main()

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

Solution (Python):
n=int(input())
ans='Yes'
pt, px, py=0, 0, 0
for i in range(n):
  t, x, y=map(int, input().split())
  if t-pt<abs(x-px)+abs(y-py):
    ans='No'
    break
  elif (abs(x-px)+abs(y-py)-(t-pt))%2==1:
    ans='No'
    break
  pt, px, py=t, x, y
print(ans)

Solution (Python):
N = int(input())
t = [0]*100001
x = [0]*100001
y = [0]*100001
for n in range(N):
    t[n+1], x[n+1], y[n+1] = map(int, input().split())
ans = True
for n in range(N):
    dt   = t[n+1] - t[n]
    dist = abs(x[n+1] - x[n]) + abs(y[n+1] - y[n])
    if dt < dist:
        ans = False
    if dt % 2 != dist % 2:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n = int(input())
    T = [0]
    X = [0]
    Y = [0]
    for _ in range(n):
        t,x,y = map(int,input().split())
        T.append(t)
        X.append(x)
        Y.append(y)
    for i in range(n):
        t_diff = T[i+1]-T[i]
        x_diff = abs(X[i+1]-X[i])
        y_diff = abs(Y[i+1]-Y[i])
        if abs(x_diff + y_diff - t_diff) % 2 == 1 or x_diff+y_diff-t_diff>0:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
TXY = [list(map(int,input().split())) for _ in range(N)]
t = 0
x = 0
y = 0
for txy in TXY:
    T = txy[0]
    X = txy[1]
    Y = txy[2]
    if (T-t) - abs(X-x) - abs(Y-y) >= 0 and ((T-t) - abs(X-x) - abs(Y-y)) % 2 == 0:
        t = T
        x = X
        y = Y
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
N = int(input())
plan = [[0,0,0]]
plan.extend(list(map(int, input().split())) for i in range(N))
f = True
for i in range(N):
    time = 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 dist>time or (dist%2 != time%2):
        f = False
print('Yes' if f else 'No')

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
prev_x = prev_y = prev_t = 0

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

    time = t - prev_t
    dist = abs(x - prev_x) + abs(y - prev_y)

    if dist > time or dist % 2 != time % 2:
        print("No")
        break

    prev_x, prev_y, prev_t = x, y, t

else:
    print('Yes')

Solution (Python):
n = int(input())
nowx = 0
nowy = 0
nowt = 0

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

for i in range(n):
    nextt, nextx, nexty = map(int,input().split())
    if (nextt - nowt) >= manhattan(nowx,nowy,nextx,nexty) and (nextt - nowt)%2 == manhattan(nowx,nowy,nextx,nexty)%2:
        nowx, nowy, nowt = nextx, nexty, nextt
    else:
        print('No')
        exit()
print('Yes')

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

    t = 0
    x = 0
    y = 0
    flag = True
    for i in range(n):
        if (A[i][0] % 2 == 0 and (A[i][1] + A[i][2]) % 2 != 0) or (A[i][0] % 2 == 1 and (A[i][1] + A[i][2]) % 2 != 1):
            flag = False
            break
        elif abs(A[i][1] - x) + abs(A[i][2] - y) > (A[i][0] - t):
            flag = False
            break
        else:
            t = A[i][0]
            x = A[i][1]
            y = A[i][2]

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


resolve()

Solution (Python):
N=int(input())
tn,xn,yn=0,0,0
judge=[]
for i in range(N):
    t1,x1,y1=map(int,input().split())
    td=abs(t1-tn)
    xd=abs(x1-xn)
    yd=abs(y1-yn)
    if t1%2==(x1+y1)%2 and td>=xd+yd:
        judge.append(True)
    else:
        judge.append(False)

    tn,xn,yn=t1,x1,y1
print('Yes' if all(judge) else 'No')

Solution (Python):
import sys
n = int(sys.stdin.readline().rstrip("\n"))
x,y = 0,0
t = 0
i = 0
while i < n:
    t_,x_,y_ = map(int, sys.stdin.readline().rstrip("\n").split())
    d = abs((x_+y_)-(x+y))
    t_d = t_-t
    if t_d >= d:
        if (t_d-d) % 2 == 0:
            x,y = x_,y_
            t = t_
            i += 1
        else:
            print('No')
            break
    else:
        print('No')
        break
else:
    print('Yes')

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

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

for i in range(1, n+1):
    if (abs(l[i][1]-l[i-1][1]) + abs(l[i][2]-l[i-1][2]) - (l[i][0]-l[i-1][0])) % 2 != 0 or abs(l[i][1]-l[i-1][1]) + abs(l[i][2]-l[i-1][2]) > (l[i][0]-l[i-1][0]):
        print("No")
        exit() 

print("Yes")

Solution (Python):
import sys

def main():
  N = int(input())
  t, x, y = 0, 0, 0
  for i in range(N):
    next_t, next_x, next_y = [int(i) for i in input().split()]
    distance = abs(next_x-x)+abs(next_y-y)
    delta_t = next_t - t
    if distance > delta_t:
      print('No')
      sys.exit()
    elif (distance -delta_t)%2 != 0:
      print('No')
      sys.exit()   
    t, x, y = next_t, next_x, next_y
  print('Yes')
  
if __name__ == '__main__':
  main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
txy = [LIST() for _ in range(N)]
txy.insert(0, [0, 0, 0])

for i in range(1, N+1):
	dt = txy[i][0] - txy[i-1][0]
	dx = abs(txy[i][1] - txy[i-1][1])
	dy = abs(txy[i][2] - txy[i-1][2])
	if dt%2 == (dx+dy)%2 and dt >= dx+dy:
		continue
	else:
		print("No")
		break
else:
	print("Yes")

Solution (Python):
t = []
 
N = input()
 
for i in range(int(N)):
    t.append(list(map(int, input().split())))
    
t.sort()
 
co, co_ = [0, 0, 0], [0, 0, 0]
flag = 1
 
for i in range(len(t)):
    co_[0] = t[i][0] - co[0]
    co_[1] = t[i][1] - co[1]
    co_[2] = t[i][2] - co[2]
    dis = abs(co_[1]) + abs(co_[2])
    if dis % 2 != (t[i][0]-co[0]) % 2:
        flag = 0
        break
    elif dis > co_[0]:
        flag = 0
        break
        
    co = t[i]
    
if flag == 0:
    print('No')
else:
    print('Yes')

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

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

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

Solution (Python):
N = int(input())
t,x,y = 0,0,0
f = True
for i in range(N):
    ti,xi,yi = map(int, input().split())
    p=ti-t
    d=abs(xi-x)+abs(yi-y)
    if p<d or p%2 != d%2:
        f = False
        break 
    t,x,y = ti,xi,yi
print('Yes' if f else 'No')

Solution (Python):
N = int(input())
time_coor = []
for n in range(N+1):
    if n==0:
        time_coor.append([0, 0, 0])
    else:
        time_coor.append(list(map(int, input().split())))

can = True
for n in range(N):
    dist = abs(time_coor[n+1][1]-time_coor[n][1]) + \
           abs(time_coor[n+1][2]-time_coor[n][2])
    time = time_coor[n+1][0]-time_coor[n][0]
    if dist>time:
        can = False
        break
    elif dist%2==time%2:
        continue
    else:
        can = False
        break
    

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

Solution (Python):
time = int(input())
jorney = [list(map(int,input().split())) for i in range(time)]
flg = True
x_before = 0
y_bfefore =0
t_before = 0

for point in jorney:
    t = point[0]
    x = point[1]
    y = point[2]
    distance = abs(x- x_before) + abs(y - y_bfefore)
    interval = t - t_before
    
    
    if t %2 == (x+y)%2 and interval >= distance:
        t_before=t
        x_before=x
        y_bfefore=y

        continue
    else:
        flg=False
        break
if flg:
    print("Yes")
else:
    print("No")

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

time = 0
visited = [0, 0]
result = []

for i in range(N):
    t, *xy = map(int, input().split())
    diff_time = t - time
    diff_dist = sum([abs(xy[i] - visited[i]) for i in range(2)])
    if (diff_dist <= diff_time) & (((diff_time - diff_dist) % 2)==0):
        result.append(True)
    else:
        result.append(False)
    time = t
    visited = xy

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

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


beforTime = 0
beforX = 0
beforY = 0
resultFrag = True
for travel in range(num):
    time, x, y = map(int, input().split())
    move = abs(beforX - x) + abs(beforY - y)
    canMoveTime = time - beforTime
    if move <= canMoveTime and (move + canMoveTime) % 2 == 0:
        beforTime = time
        beforX = x
        beforY =  y
        continue
    resultFrag = False
    break

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

Solution (Python):

num = int(input())
travels = []
for _ in range(num):
    travels.append(list(map(int, input().split())))


beforTime = 0
beforX = 0
beforY = 0
resultFrag = True
for travel in travels:
    move = abs(beforX - travel[1]) + abs(beforY - travel[2])
    canMoveTime = travel[0] - beforTime
    if move <= canMoveTime and (move + canMoveTime) % 2 == 0:
        beforTime = travel[0]
        beforX = travel[1]
        beforY =  travel[2]
        continue
    resultFrag = False
    break

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

Solution (Python):


n = int(input())
t, x, y = 0, 0, 0
flag = True

for i in range(n):
    _t,_x,_y = map(int, input().split())
    _d = abs(x - _x) + abs(y - _y)
    _dt = abs(t - _t)
    if _d > _dt or ((_d - _dt)%2) == 1:
        flag = False
    t,x,y = _t,_x,_y

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

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

Solution (Python):
N = int(input())
t,x,y = 0,0,0
cou = 0
t1,t2,x1,x2,y1,y2= 0,0,0,0,0,0

for i in range(N):
    t,x,y = map (int,input().split())
    if t>=(x+y) and (t+x+y)%2 == 0:
        t1,x1,y1 = t,x,y
        if abs(t1-t2) >= abs((x1-x2)+(y1-y2)):
            cou += 1
        else:
            print("No")
            break
        t2,x2,y2 = t1,x1,y1
    else:
        print("No")
        break

if cou == N:
    print("Yes")

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

x, y = 0, 0
t = 0
for i in range(N):
    t1 = T[i][0] - t
    x1 = T[i][1]
    y1 = T[i][2]
    if t1 < abs(x1 - x) + abs(y1 - y):
        print('No')
        sys.exit()
    t1 -= abs(x1 - x) + abs(y1 - y)
    if t1 % 2 != 0:
        print('No')
        sys.exit()
    t = T[i][0]
    x = x1
    y = y1
print('Yes')

Solution (Python):
import sys

N = int(input())

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

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

for i in range(N) : 
    T = t[i+1] - t[i]
    R = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]) 
    if T < R or (T + R) % 2 == 1 :
        print('No')
        sys.exit()

print('Yes')

Solution (Python):

n = int(input())
prev_t = 0
prev_x = 0
prev_y = 0
ans = True
for i in range(n):
    t,x,y = map(int,input().split())
    d_t = t - prev_t
    d_x = abs(x - prev_x)
    d_y = abs(y - prev_y)
    distance = d_x + d_y
    if d_t < distance or (d_t % 2) != (distance % 2):
        ans = False
    prev_t = t
    prev_x = x
    prev_y = y

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

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

Solution (Python):
n = int(input())
l = []
t = x = y = 0
for _ in range(n):
    a,b,c = map(int,input().split())
    t_delta = a - t
    x_delta = abs(b - x)
    y_delta = abs(c - y)

    if (x_delta+y_delta <= t_delta) and (t_delta%2 == (x_delta+y_delta)%2):
            pass
    else:
        print ("No")
        exit ()

    t = a
    x = b
    y = c

print ("Yes")

Solution (Python):
n=int(input())
data=[list(map(int,input().split())) for i in range(n)]
data.insert(0,[0,0,0])
def check(time,data):
    x0=data[time][1]
    y0=data[time][2]
    x1=data[time+1][1]
    y1=data[time+1][2]
    if abs(x0-x1)+abs(y0-y1)<=abs(data[time][0]-data[time+1][0]) and (abs(x0-x1)+abs(y0-y1))%2==abs(data[time][0]-data[time+1][0])%2:
        return(1)
    else:
        return(0)
ans=0    
for i in range(0,n):
    ans=ans+check(i,data)
if ans==n:
    print("Yes")
else:
    print("No")

Solution (Python):



import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[[0,0,0] for i in range(n+1)]
for i in range(n):
    lis[i+1]=LI()
for i in range(n):
    dt=lis[i+1][0]-lis[i][0]
    dx=abs(lis[i+1][1]-lis[i][1])
    dy=abs(lis[i+1][2]-lis[i][2])
    if dx+dy<=dt and (dx+dy-dt)%2==0:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

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

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

t.sort()
now = 0
ans = "Yes"
past = 0

for i in range(N):
  if t[i][0] - past >= abs(t[i][1] + t[i][2] - now) and abs(t[i][0] - past - abs(t[i][1] + t[i][2] - now))%2 == 0:
    now = t[i][1] + t[i][2]
    past = t[i][0]
  else:
    ans = "No"

print(ans)

Solution (Python):
n = int(input())
t = [0]
x = [0]
y = [0]
for _ in range(n):
    t_tmp, x_tmp, y_tmp = map(int, input().split(" "))
    t.append(t_tmp)
    x.append(x_tmp)
    y.append(y_tmp)

reachable = True
for j in range(1, n + 1):
    dt = t[j] - t[j - 1]
    dist = abs(x[j] - x[j - 1]) + abs(y[j] - y[j - 1])
    if dt < dist or dist % 2 != dt % 2:
        reachable = False

print("Yes" if reachable == True else "No")

Solution (Python):
n=int(input())
li=[input() for i in range(n)]
li2 = []
li2.append([0,0,0])
for i in range(n):
    li2.append( [int(x.strip()) for x in li[i].split()])
    
c=0


for i in range(n):
    t = li2[i+1][0] - li2[i][0]
    x = abs(li2[i+1][1] - li2[i][1])
    y = abs(li2[i+1][2] - li2[i][2])
    z = x+y
    if t < z:
        c=1
        break
    if (z - t)%2 == 1:
        c=1
        break
        
        

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

Solution (Python):
n = int(input())
txy = [[0, 0, 0]]

for i in range(n):
    txy.append(list(map(int, input().split())))

for j in range(1,n+1):
    t_diff = txy[j][0] - txy[j-1][0]
    x_diff = txy[j][1] - txy[j-1][1]
    y_diff = txy[j][2] - txy[j-1][2]
    if abs(x_diff) + abs(y_diff) <= t_diff and \
        (t_diff - abs(x_diff) - abs(y_diff))%2 == 0:
        continue
    else:
        print("No")
        exit()
print("Yes")

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

t_pre, x_pre, y_pre = 0, 0, 0
reachable = True
for point in points:
    t, x, y = map(int, point)
    diff_t = t - t_pre
    p = x + y
    p_pre = x_pre + y_pre
    move = 0
    for _ in range(diff_t):
        move += 1 if p > (p_pre + move) else -1

    if p - p_pre != move:
        reachable = False
        break

    t_pre, x_pre, y_pre = t, x, y

print("Yes" if reachable == True else "No")

Solution (Python):
N = int(input())
start = [0, 0]
start_t = 0
for i in range(N):
    t, x, y = map(int, input().split())
    now = [x, y]
    dt = t - start_t
    dist = abs(now[0]-start[0]) + abs(now[1]-start[1])
    if dist > dt or dt % 2 != dist % 2:
        print('No')
        break
    else:
        start = now
        start_t = t
else:
    print('Yes')

Solution (Python):
N = int(input())
x = 0
y = 0
t = 0
ans = 0
for i in range(N):
    tt,xx,yy = map(int,input().split())
    t1 = tt -t 
    x1 = abs(xx-x)
    y1 = abs(yy-y)
    if x1 + y1 > t1:
        ans = 1
        
    elif (t1 - (x1 + y1) ) % 2 == 1:
        ans = 1
        
    t = tt
    x = xx
    y = yy
if ans == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
t = [0]
x = []
y = []
for _ in [0]*n:
    _t, _x, _y = map(int, input().split())
    t += [_t]
    x += [_x]
    y += [_y]
nx = ny = 0
for i in range(n):
    nt = t[i+1] - t[i]
    d = abs(x[i]-nx) + abs(y[i]-ny)
    if not (nt%2 == d%2 and nt>=d):
        print('No')
        break
    nx = x[i]
    ny = y[i]
else:
    print('Yes')

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

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

can = True

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: 
        can = False
    if (dist % 2 != dt % 2):
        can = False

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

Solution (Python):
N = int(input())
li = []
pre_t = 0
pre_x = 0
pre_y = 0
ans = "Yes"
for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - pre_x) + abs(y - pre_y)
    d_t = abs(t - pre_t)
    if dist > d_t or (dist - d_t) % 2 == 1:
        ans = "No"

    pre_t, pre_x, pre_y = t, x, y

print(ans)

Solution (Python):
n = int(input())
t_list = [list(map(int,input().split())) 
          for nesya in range(n)]
dame = 0
ti = 0
tx = 0
ty = 0
for t in t_list:
  time = t[0]
  x_t = t[1]
  y_t = t[2]
  d = abs(y_t-ty)+abs(x_t-tx)
  h = time - ti
  if d > h or (h-d)%2 == 1:
    dame += 1
    print('No')
    break
  ti = time
  tx = x_t
  ty = y_t
if dame == 0:
  print('Yes')