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 re
import math
from collections import defaultdict
from collections import deque
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache

readline=sys.stdin.readline
sys.setrecursionlimit(2000000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
    return ret
def seifu(x):
    return x//abs(x)

def main():
    N=int(input())
    f=True
    p=0
    px=0
    py=0
    A=[[] for a in range(N)]
    for a in range(N):
        A[a]=list(map(int,input().split()))
    A.sort()
    for a in range(N):
        t,x,y=A[a][0],A[a][1],A[a][2]
        d=abs(x-px)+abs(y-py)
        if d>t-p:
            f=False
        elif ((t-p)-d)%2==1:
            f=False
        p=t
        px=x
        py=y
    Yn(f)
main()

Solution (Python):
import math
import queue
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=qb
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def dq():
	return queue.deque()
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1

n = readInt()
be = [0,0]
b_time = 0
for i in range(n):
	data = readInts()
	delta = abs(be[0]-data[1])+abs(be[1]-data[2])
	time = data[0]-b_time
	if delta<=time and delta%2==time%2:
		be = data[1:]
		b_time = data[0]
	else:
		print("No")
		exit()

print("Yes")

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

def check(t, x, y):
    return (t - (abs(x) + abs(y))) >= 0 and (t - (abs(x) + abs(y))) % 2 == 0
t0, x0, y0 = 0, 0, 0
for l in [list(map(int, input().split())) for i in range(n)]:
    if not check(l[0] - t0, l[1] - x0, l[2] - y0):
        print('No')
        exit()
    t0, x0, y0 = l[0], l[1], l[2]
print('Yes')

Solution (Python):
N=int(input())
t0=0
x0=0
y0=0
for i in range(N):
  t,x,y = map(int, input().split())
  l = abs(x-x0) + abs(y-y0)
  if (l > (t-t0)) or (l%2 != (t-t0)%2):
    print("No")
    break
  else:
    x0 = x
    y0 = y
    t0 = t
else:
  print("Yes")

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

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

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

t0, x0, y0 = map(int, input().split())
if t0 < x0 + y0 or t0 % 2 != (x0 + y0) % 2:
    print("No")
    exit()

for i in range(1, N):
    t1, x1, y1 = map(int, input().split())
    dist_t, dist_x, dist_y = abs(t1-t0), abs(x1-x0), abs(y1-y0)
    
    if dist_t < dist_x + dist_y or dist_t % 2 != (dist_x + dist_y) % 2:
        print("No")
        exit()
    t0, x0, y0 = t1, x1, y1
print("Yes")

Solution (Python):
N = int(input())
ans = "Yes"
t_before = 0
x_before, y_before = 0, 0

for _ in range(N):
    ti, xi, yi = map(int, input().split())
    t_dist = abs(ti - t_before)
    x_dist = abs(xi - x_before)
    y_dist = abs(yi - y_before)
    xy_dist = x_dist + y_dist
    if xy_dist <= t_dist:
        if (t_dist % 2 == 0 and xy_dist % 2 == 0) or (t_dist % 2 == 1 and xy_dist % 2 == 1):
            t_before = ti
            x_before = xi
            y_before = yi
            continue
        else:
            ans = "No"
            break
    else:
        ans = "No"
        break

print(ans)

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

pre_t = 0
pre_x = 0
pre_y = 0

for t, x, y in records:
    turn = t - pre_t
    dx = abs(x - pre_x)
    dy = abs(y - pre_y)

    if turn < (dx + dy):
        print('No')
        break

    if turn % 2 != (dx + dy) % 2:
        print('No')
        break

    pre_t = t
    pre_x = x
    pre_y = y
else:
    print('Yes')

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

if n==1:
    dt=m[0][0]
    dx=m[0][1]
    dy=m[0][2]
    if dt<dx+dy:
        print("No")
    else:
        if dt%2!=(dx+dy)%2:
            print("No")
        print("Yes")

else:
    for i in range(n-1):
        dt=m[i+1][0]-m[i][0]
        dx=abs(m[i+1][1]-m[i][1])
        dy=abs(m[i+1][2]-m[i][2])

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

    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())
res = 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:
        res = False
    if dt % 2 != dist % 2:
        res = False
if res:
    print('Yes')
else:
    print('No')

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

c_x = 0
c_y = 0
c_t = 0
for i in range(n):
  t, x, y = map(int, input().split())
  d_x = abs(c_x - x)
  d_y = abs(c_y - y)
  d = d_x + d_y
  d_t = t - c_t
  if d_t < d or (d_t - d) % 2 != 0:
    print('No')
    sys.exit(0)
  c_x = x
  c_y = y
  c_t = t
print('Yes')

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

can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
T = [0]*100000
X= [0]*100000
Y= [0]*100000
x = 0
y = 0

for n in range(N):
        T[n],X[n],Y[n] = (map(int, input().split()))

flag = 1
for n in range(N):
    
    if flag == 0:
        continue


    if n == 0:
        count = T[n]
    else:
        count = T[n] - T[n-1]
        x = X[n-1]
        y = Y[n-1]
    c = 0
    end = 0
    while True:
        if end == 1:
            break
        s_x = X[n] - x
        s_y = Y[n] - y
    

        if ((s_x != 0 or s_y !=0) )and (c!=count):
            if s_x >0:
                x +=1
                c += 1
            elif s_x < 0:
                x -= 1
                c+=1
            elif s_y > 0:
                y +=1
                c += 1
            elif s_y < 0:
                y -= 1
                c+=1
        elif  ((s_x == 0 and s_y == 0) )and (c!=count):
                x +=1
                c +=1
        elif c==count:
            if (x == X[n] and y ==Y[n]):
                flag = 1
                end=1
            else:
                flag=0
                end =1



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

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

start=[0,0,0]

ans=0

for i in range(n):
    
    cont=list(map(int,input().split()))
    
    x=abs(start[0]-cont[0])
    
    y=abs(start[1]-cont[1])+abs(start[2]-cont[2])
    
    
    if x<y:
        ans=1
        
    else:
        if x%2==0:
            if y%2!=0:
                ans=1
                
        else:
            if y%2!=1:
                ans=1
                

        
    start=cont
        
if ans==0:
    print('Yes')
    
else:
    print('No')

Solution (Python):
import math
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())

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

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

Solution (Python):






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






import numpy as np





data = np.array(data)
diff = data[1:] - data[:-1]
diff = diff.tolist()
diff.insert(0, data[0].tolist())






flag = True
for idx,item in enumerate(diff):

    dist = abs(item[1]) + abs(item[2])
    if dist > item[0]:
        flag = False 
    else:
        if (item[0] - dist)%2 != 0:
            flag = False 

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

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

ans = 'Yes'

tt, tx, ty = 0, 0, 0,
for _ in range(N):
    t, x, y = map(int, input().split())
    ct = t-tt
    cx = abs(x-tx)
    cy = abs(y-ty)
    if ct < (cx+cy):
        ans = 'No'
        break
    if cx+cy == 0:
        ans = 'No'
        break
    if ct%2 != (cx+cy)%2:
        ans = 'No'
        break
    tt, tx, ty = t, x, y

print(ans)

Solution (Python):


def main():
    n = int(input())
    
    res = 'Yes'

    for i in range(n):
        t, x, y = map(int, input().split())
        
        if i != 0:
            t, x, y = t - t_prev, x - x_prev, y - y_prev

        if abs(x) + abs(y) > t:
            res = 'No'
            break
        elif (not t%2 and (x+y)%2) or (t%2 and not ((x+y)%2)):
            res = 'No'
            break
        
        t_prev, x_prev, y_prev = t, x, y
    
    print(res)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
places = [[0, 0, 0]] + [list(map(int, input().split())) for _ in range(n)]
can_move = True
for i in range(1, n + 1):
  _t = places[i][0] - places[i - 1][0]
  _x = abs(places[i][1] - places[i - 1][1])
  _y = abs(places[i][2] - places[i - 1][2])

  if not _t >= _x + _y or not _t % 2 == (_x + _y) % 2:
    can_move = False
    break

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

Solution (Python):
import sys










stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = int(stdin.readline().rstrip())


numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]



nx = 0
ny = 0
nt = 0
for number in numbers:
    t=number[0]
    x = number[1]
    y = number[2]
    sa = abs(x-nx) + abs(y-ny)
    if sa%2 == (t-nt)%2 and sa <= (t-nt):
        nx = x
        ny = y
        nt = t
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
def can_not_realize(N, t_list, x_list, y_list) -> bool:
    
    for i in range(N):
        diff_t = t_list[i + 1] - t_list[i]
        diff_x = abs(x_list[i + 1] - x_list[i])
        diff_y = abs(y_list[i + 1] - y_list[i])

        sum_of_moving = diff_x + diff_y

        
        if diff_t < sum_of_moving:
            return True

        
        if not (diff_t % 2 == sum_of_moving % 2):
            return True

    return False

def actual(N, t_list, x_list, y_list):
    
    t_list = [0] + t_list
    x_list = [0] + x_list
    y_list = [0] + y_list

    if can_not_realize(N, t_list, x_list, y_list):
        return 'No'

    return 'Yes'

N = int(input())

t_list, x_list, y_list = [], [], []

for _ in range(N):
  t, x, y = list(map(int, input().split()))
  t_list.append(t)
  x_list.append(x)
  y_list.append(y)
  
print(actual(N, t_list, x_list, y_list))

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

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

ct = cx = cy = 0
for t,x,y in tmp:
    dst = abs(cx - x) + abs(cy - y)
    if dst > t-ct or dst%2 != (t-ct)%2:
        print('No')
        exit()
    ct,cx,cy = t,x,y
print('Yes')

Solution (Python):
import unittest


def is_ある時刻での判定(t, d):
    
    if t < d:
        return True

    
    if not (t % 2 == d % 2):
        return True

    return False


def can_not_realize(N, t_list, x_list, y_list) -> bool:
    
    for t, x, y in zip(t_list, x_list, y_list):
        d = x + y

        if is_ある時刻での判定(t, d):
            return True

    
    for i in range(N):
        if i + 1 >= N:
            break

        t = t_list[i + 1] - t_list[i]
        diff_x = abs(x_list[i + 1] - x_list[i])
        diff_y = abs(y_list[i + 1] - y_list[i])

        d = diff_x + diff_y

        if is_ある時刻での判定(t, d):
            return True

    return False


def actual(N, t_list, x_list, y_list):
    if can_not_realize(N, t_list, x_list, y_list):
        return 'No'

    return 'Yes'

N = int(input())

t_list, x_list, y_list = [], [], []
for _ in range(N):
  t, x, y = list(map(int, input().split()))
  t_list.append(t)
  x_list.append(x)
  y_list.append(y)
  
print(actual(N, t_list, x_list, y_list))

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

flag = True
for i in range(1, n + 1):
    t = txy[i][0] - txy[i - 1][0]
    x = abs(txy[i][1] - txy[i - 1][1])
    y = abs(txy[i][2] - txy[i - 1][2])

    if not t >= x + y or not t % 2 == (x + y) % 2:
        flag = False
        break

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

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

def main():
    n = int(input())
    t = 0
    x = 0
    y = 0

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

    for t1, x1, y1 in l:
        if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1:
            print("No")
            exit()
        if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
            print("No")
            exit()
        x = x1
        y = y1
        t = t1

    print("Yes")
main()

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

n = int(input())
t = 0
x = 0
y = 0

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1:
        print("No")
        exit()
    if (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

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

for t1, x1, y1 in l:
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        print("No")
        exit()
    x = x1
    y = y1
    t = t1

print("Yes")

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

n = int(input())
t = 0
x = 0
y = 0
judge = True

for i in range(n):
    t1, x1, y1 = map(int, input().split())
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        judge = False
    x = x1
    y = y1
    t = t1

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

Solution (Python):
n = int(input())
t = 0
x = 0
y = 0
judge = True

for i in range(n):
    t1, x1, y1 = map(int, input().split())
    if (abs(x1 - x) + abs(y1 - y))/(t1 - t) > 1 or (abs(x1 - x) + abs(y1 - y))%2 != (t1 - t)%2:
        judge = False
    x = x1
    y = y1
    t = t1

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

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

def main():
    N = int(readline())
    res = 'Yes'
    pre_x, pre_y = 0, 0
    pre = 0
    for _ in range(N):
        t, x, y = map(int, readline().rstrip().split())
        cost = abs(x - pre_x) + abs(y - pre_y)
        if (t - pre) - cost >= 0 and ((t - pre) - cost) % 2 == 0:
            pre, pre_x, pre_y = t, x, y
        else:
            res = 'No'
            break

    print(res)

if __name__ == '__main__':
    main()

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

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

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

T = []
X = []
Y = []
T.append(0)
X.append(0)
Y.append(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(1, N+1, 1):
    dt = T[i]-T[i-1]
    dl = abs((X[i]+Y[i])-(X[i-1]+Y[i-1]))
    if dt<dl:
        print("No")
        exit()
    if dt%2!=dl%2:
        print("No")
        exit()
print("Yes")

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


def read():
    N =int(input().strip())
    TXY = []
    for i in range(N):
        t, x, y = map(int, input().strip().split())
        TXY.append((t, x, y))
    return N, TXY


def solve(N, TXY):
    t0 = 0
    x0, y0 = 0, 0
    for t1, x1, y1 in TXY:
        dt = t1 - t0
        du = abs(x1-x0) + abs(y1-y0)
        if du > dt:
            return "No"
        elif (du - dt) % 2 == 1:
            return "No"
        t0, x0, y0 = t1, x1, y1
    return "Yes"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
N = int(input())
A = [[int(x) for x in input().split()]for i in range(N)]
T = 0            
place = (0,0)    
for i in range(N):
  if ((A[i][0]-T) + abs(A[i][1]-place[0]) + abs(A[i][2]-place[1]))%2 == 1 or (A[i][0]-T) < abs(A[i][1]-place[0]) + abs(A[i][2]-place[1]):
    print("No")
    exit()
  else:
    T = A[i][0]
    place = (A[i][1], A[i][2])
print("Yes")

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

ans=1
for i in range(n):
    t,x,y = map(int,input_line[i])
    dist = abs(point[0]-x)+abs(point[1]-y)
    limit = t-time
    if dist>limit:
        ans=0
        break
    if (limit-dist)%2!=0:
        ans=0
        break
    time=t
    point=[x,y]
print('Yes' if ans==1 else 'No')

Solution (Python):
n = int(input())
prev_t, prev_x, prev_y = 0, 0, 0
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if abs(prev_x - x) + abs(prev_y - y) > abs(prev_t - t) or (
            abs(prev_x - x) + abs(prev_y - y) + abs(prev_t - t)) % 2:
        print('No')
        exit()
    prev_t, prev_x, prev_y = t, x, y
print('Yes')

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 = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

j = True

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


for d in range(0, n+1) :
    if t[d] % 2 == 1 and (x[d] + y[d]) %2 != 1 :
        j = False
    if t[d] % 2 == 0 and (x[d] + y[d]) %2 != 0 :
        j = False

for k in range(0, n) :
    a = t[k+1] - t[k]
    b = abs(x[k+1] - x[k]) + abs(y[k+1] - y[k])
    if a < b :
        j = False

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

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

x = 0
y = 0
t = 0
for i in range(n):
    sub = abs(txy[i][1] - x) + abs(txy[i][2] - y)
    if txy[i][0] - t < sub:
        print("No")
        exit()
    if txy[i][0] - t != sub:
        if (txy[i][0] - t) % 2 == 0:
            if sub % 2 != 0:
                print("No")
                exit()
        else:
            if sub % 2 != 1:
                print("No")
                exit()

    t = txy[i][0]
    x = txy[i][1]
    y = txy[i][2]

print("Yes")

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

tp = 0
xp = 0
yp = 0
flag = [0]*n
for i in range(n):
  t, x, y = map(int,input().split())
  dt = t-tp
  dx = abs(xp-x)
  dy = abs(yp-y)
  if dt==dx+dy:
    flag[i]=1
  elif dt>dx+dy and dt%2==0 and dx%2==0 and dy%2==0:
    flag[i]=1
  elif dt>dx+dy and dt%2==0 and dx%2==1 and dy%2==1:
    flag[i]=1
  elif dt>dx+dy and dt%2==1 and dx%2==0 and dy%2==1:
    flag[i]=1
  elif dt>dx+dy and dt%2==1 and dx%2==1 and dy%2==0:
    flag[i]=1
  tp=t
  xp=x
  yp=y

f=1
for i in range(n):
  f *= flag[i]
  
if f==1:
  print("Yes")
else:
  print("No")

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

now = (0,0)
now_t = 0
ok = True
for t,x,y in TXY:
  d = abs(x-now[0]) + abs(y-now[1])
  if d <= (t-now_t) and ((t - now_t) - d) % 2 == 0:
    now = (x,y)
    now_t = t
    continue
  ok = False
  break
  
if ok:
  print('Yes')
else:
  print('No')

Solution (Python):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  
    t_x_y_arr = [[0,0,0]]
    for i in range(N):
        _ = list(map(int,_in[i+1].split(' ')))  
        t_x_y_arr.append(_)
    
    TF = 'Yes'
    for i in range(N):
        dt = t_x_y_arr[i+1][0]-t_x_y_arr[i][0]
        dist = abs(t_x_y_arr[i+1][1]-t_x_y_arr[i][1]) + abs(t_x_y_arr[i+1][2]-t_x_y_arr[i][2])
        if dt<dist or dist%2!=dt%2:
            TF = 'No'
            break
    
    print(TF)

Solution (Python):
def main():
    n, *t = map(int, open(0).read().split())
    l = [(0, 0, 0)] + list(zip(*[iter(t)] * 3))
    for x, y in zip(l, l[1:]):
        dt = y[0] - x[0]
        dd = abs(y[1] - x[1]) + abs(y[2] - x[2])
        f = dd <= dt
        g = dt % dd == 0 or dt % dd == 2
        h = f and g
        if not h:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()

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

pt, px, py = [0, 0, 0]
for _ in range(N):
    t, x, y = map(int, input().split())
    ts = abs(t - pt)
    xys = abs(x - px) + abs(y - py)
    if ts < xys:
        print('No')
        break

    if ts % 2 != xys % 2:
        print('No')
        break
    
    pt, px, py = t, x, y
else:
    print('Yes')

Solution (Python):
N = int(input())
now = [0, 0]

for i in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - now[0]) + abs(y - now[1])
    if t < dist or (t % 2 != dist %2):
        print('No')
        quit()
 
print('Yes')

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

now = [0, 0]
for i in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x - now[0]) + abs(y - now[1])
    if dist <= t and (t - dist) % 2 == 0:
        continue
    print('No')
    quit()
 
print('Yes')

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

now = [0, 0]
for i in range(N):
  t, x, y = map(int, input().split())
  time = abs(x - now[0]) + abs(y - now[1])
  if t >= time and (t - time)%2==0:
    continue
  print('No')
  quit()

print('Yes')

Solution (Python):
def solve(N):
    x, y = 0, 0
    for _ in range(N):
        ti, xi, yi = [int(n) for n in input().split()]
        diff_x = abs(xi - x)
        diff_y = abs(yi - y)
        distance = diff_x + diff_y
        left = abs(ti - distance)

        if ti >= distance and left % 2 == 0:
            continue
        else:
            return False
    return True


N = int(input())
if solve(N):
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    N = int(input())
    t, x, y = [], [], []

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

    px = 0
    py = 0
    pt = 0
    for T, X, Y in zip(t, x, y):
        if (T-pt) % 2 == 0:
            if T-pt < X-px + Y-py or (X-px + Y-py) % 2 != 0:
                print('No')
                return
        else:
            if T-pt < X-px + Y-py or (X-px + Y-py) % 2 == 0:
                print('No')
                return
        pt = T
        px = X
        py = Y
    print('Yes')
    
main()

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    N=int(readline())
    t=[0]*N
    x=[0]*N
    y=[0]*N
    for i in range(N):
        t[i],x[i],y[i]=map(int,readline().split())

    nt=[]
    nx=[]
    ny=[]
    for i in range(N):
        if i==0:
            nt.append(t[0])
            nx.append(x[0])
            ny.append(y[0])
        else:
            nt.append(t[i]-t[i-1])
            nx.append(x[i]-x[i-1])
            ny.append(y[i]-y[i-1])

    for i in range(N):
        if nt[i]<abs(nx[i])+abs(ny[i]):
            print("No")
            break
        elif nt[i]%2!=(abs(nx[i])+abs(ny[i]))%2:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

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

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

def canmove(current, next):
    (t0,x0,y0) = current
    (t1,x1,y1) = next
    dist = abs(x1-x0) + abs(y1-y0)
    tdiff = t1-t0
    if(dist > tdiff):
        return False
    if( tdiff%2 != dist%2 ):
        return False
    return True

def main(n,txy):
    current = (0,0,0)
    for i in range(n):
        next = txy[i]
        ans = canmove(current, next )
        if (ans == False):
            return False
        current = next
    return True

if __name__=='__main__':
    n,txy = readinput()
    ans = main(n,txy)
    if (ans == True):
        print('Yes')
    else:
        print('No')

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

flag = 0
for _ in range(n):
  t, x, y = map(int, input().split())
  if t%2 == (x+y)%2 and t >= (x+y):
    continue
  else:
    flag = 1
    
print('Yes') if not flag else print('No')

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