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

Solution (Python):
n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
tmpt = 0
for i in range(n):
    v1,v2,v3 = map(int,input().split())
    t.append(v1)
    x.append(v2)
    y.append(v3)
for i in range(n):
    if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i] - tmpt and (abs(tmpx-x[i]) + abs(tmpy-y[i])) % 2 == (t[i] - tmpt) % 2:
        tmpx = x[i]
        tmpy = y[i]
        tmpt = t[i]
        continue
    else:
        ans = "No"
        break
print(ans)

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

ans = "Yes"
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) or ((dt - dist) % 2 == 1):
        ans = "No"

print(ans)

Solution (Python):
N = int(input())
txy = [[0]*3 for _ in range(N)]
for i in range(N):
  txy[i] = list(map(int, input().split()))
flag = True
for sh in txy:
  Sxy = sh[1] + sh[2]
  if (Sxy % 2 == 0) ^ (sh[0] % 2 == 0):
    flag = False
  if sh[0] < Sxy:
    flag = False
  if not(flag):
    break
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):

n = int(input()) + 1
data = [[0] * 3 for i in range(n)]

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

for i in range(1, n):
    dt = data[i][0] - data[i - 1][0]
    dx = data[i][1] - data[i - 1][1]
    dy = data[i][2] - data[i - 1][2]

    for j in range(dt//2 + 1):
        if dt - 2 *j == abs(dx) + abs(dy):
            if i == n - 1:
                print('Yes')
            break
    else:
        if i == n - 1:
            print('No')

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

cur = [0, 0, 0]

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

    dur = t - cur[0]
    dist = abs(x - cur[1]) + abs(y - cur[2])
    if not (dist <= dur and (dur - dist) % 2 == 0):
        ok = False
        print("No")
        break
    
    cur = [t, x, y]

if ok:
    print("Yes")

Solution (Python):

import sys, math, fractions, itertools

YES = "Yes"  
NO = "No"  

def solve(N: int, t: "List[int]", x: "List[int]", y: "List[int]"):
    flag = True
    p = (0, 0)
    ct = 0
    for i in range(N):
        d = abs(x[i] + y[i])
        dt = t[i] - ct
        if dt - d < 0 or (dt - d) % 2 != 0:
            flag = False
    if flag:
        print('Yes')
    else:
        print('No')
    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())
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(1, N + 1):
    dr = abs(X[i] - X[i-1]) + abs(Y[i] - Y[i-1])
    dt = T[i] - T[i-1]
    if dr > dt or (dr - dt) % 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
def solve():
    list_of_txy = read()
    result = think(list_of_txy)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_txy = [[0, 0, 0]]
    for _ in range(n):
        list_of_txy.append(read_int(3))
    return list_of_txy


def read_int(n):
    return list(map(int, read_line().split()[:n]))


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_txy):
    for i in range(len(list_of_txy) - 1):
        t, x, y = list_of_txy[i]
        nt, nx, ny = list_of_txy[i + 1]
        dx, dy, dt = abs(nx - x), abs(ny - y), abs(nt - t)
        if dx + dy > dt:
            return False
        if (dt - dx - dy) % 2 != 0:
            return False
    return True


def write(result):
    if result:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

N = int(sys.stdin.readline())
T, X, Y = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(N)]))

t, x, y = 0, 0, 0
ok = True
for i in range(N):
    dt = T[i] - t
    d = abs(x - X[i]) + abs(y - Y[i])
    if not (dt >= d and (dt - d) % 2 == 0):
        ok = False
    t = T[i]
    x = X[i]
    y = Y[i]
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
TS = sorted([[0,0,0]] + [list(map(int, input().split())) for k in range(N)])
result = True
for k in range(N):
    length = [abs(TS[k+1][i] - TS[k][i]) for i in range(3)]
    reminder = length[0] - length[1] - length[2]
    result = result and (reminder >= 0) and (reminder % 2 == 0)
print("Yes") if result else print("No")

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


def main():
    for i in range(1, N + 1):
        t[i], x[i], y[i] = map(int, input().split())
    print("Yes" if detect() else "No")


def detect():
    for i in range(1, N+1):
        t_diff = t[i] - t[i-1]
        d_diff = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1])
        if d_diff > t_diff or (t_diff - d_diff) % 2 != 0:
            return False
    return True


main()

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())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print('No')
        exit()
    t, x, y = next_t, next_x, next_y
print('Yes')

Solution (Python):
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
z=0
p=s[0][0]-abs(s[0][1])-abs(s[0][2])
if p>=0 and p%2==0:
        pass
else:
    print('No')
    exit()
    
for i in range(1,n):
    z=s[i][0]-s[i-1][0]-abs(s[i][1]-s[i-1][1])-abs(s[i][2]-s[i-1][2])
    if z>=0 and z%2==0:
        pass
    else:
        print('No')
        exit()
print('Yes')

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

for j in range(1,N+1):
    dt[j-1] = t[j] - t[j-1]
    dist[j-1] = abs(x[j] - x[j-1]) + abs(y[j] - y[j-1])

Flag = "OK"
for k in range(N):
    if dt[k] < dist[k]:
        Flag = "NG"
    else:
        if (dt[k]-dist[k]) % 2 != 0:
            Flag = "NG"

if Flag == "OK":
    print("Yes")
else:
    print("No")

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

for j in range(1,N+1):
    dt[j-1] = t[j] - t[j-1]
    dist[j-1] = abs(x[j] - x[j-1]) + abs(y[j] - y[j-1])

Flag = "OK"
for k in range(N):
    if dt[k] < dist[k]:
        Flag = "NG"
    else:
        if (dt[k]-dist[k]) % 2 != 0:
            Flag = "NG"

if Flag == "OK":
    print("Yes")
else:
    print("No")

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

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

print("Yes")

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

for i in li:
    cost = abs(i[1] - now[0]) + abs(i[2] - now[1]) 
    if (i[0] - t) < cost or (i[0] - t - cost) % 2 != 0:
        print("No")
        break
    t = i[0]
    now = [i[1], i[2]]
else:
    print("Yes")

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

x_before = 0
y_before = 0
t_before = 0
ans = 'Yes'

for i in range(N):
    t, x, y = map(int, input().split())
    
    
    distance = abs(x-x_before) + abs(y-y_before)
    
    
    time = t-t_before
    
    
    if time-distance<0:
        ans = 'No'
        break
    if time%2 != distance%2:
        ans = 'No'
        break
        
    
    x_before = x
    y_before = y
    t_before = t
    
print(ans)

Solution (Python):
N = int(input())
t_old, x_old, y_old = 0, 0, 0

for i in range(N):
  t, x, y = map(int, input().split())
  dt = t - t_old
  dx = x - x_old
  dy = y - y_old
  t_old = t
  x_old = x
  y_old = y
  if abs(dx) + abs(dy) <= dt and (dt - (abs(dx) + abs(dy))) % 2 == 0:
    if i == N - 1:
      print('Yes')
    pass
  else:
    print('No')
    break

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

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

print("Yes")

Solution (Python):
N_POINTS = int(input())
POINTS = [[0, 0, 0]]
for _ in range(N_POINTS):
    POINTS.append([int(value) for value in input().split(' ')])


def is_accessible_point(point1, point2):
    distance = abs(point1[1] - point2[1]) + abs(point1[2] - point2[2])
    time = point2[0] - point1[0]
    if distance > time or (time - distance) % 2 != 0:
        return False
    return True


def is_accessible_points(n_points, points):
    for i in range(n_points):
        if is_accessible_point(points[i], points[i + 1]):
            continue
        else:
            return False
    return True


if is_accessible_points(N_POINTS, POINTS):
    print('Yes')
else:
    print('No')

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

for i in range(n):
	temp=list(input().rstrip().split())
	temp2=[]
	for element in temp:
		temp2.append(int(element))
	timeline.append(temp2)


i=0
flag=True
output="Yes"

while i<n and flag:
	dif=[timeline[i+1][0]-timeline[i][0],timeline[i+1][1]-timeline[i][1],timeline[i+1][2]-timeline[i][2]]
	if dif[0]<abs(dif[1])+abs(dif[2]) or (dif[0]-abs(dif[1])-abs(dif[2]))%2 ==1 :
		flag=False
		output="No"
	i+=1

print(output)

Solution (Python):

def main():
    n = int(input()) 
    l = list()
    t = 0
    x , y = 0 , 0
    flag = True
    for i in range(n):
        c , a , b = map(int,input().split())
        if abs(a-x) + abs(b-y) > abs(c-t) :
            
            flag = False 
        elif (abs(c-t)-abs(a-x)-abs(b-y)) % 2 !=0:
            
            flag = False 
        else:
            x , y , t = a , b , c
    if flag:
        print('Yes')
    else:
        print('No')


        

main()

Solution (Python):
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(1,n+1):t[i],x[i],y[i]=map(int,input().split())
print('YNeos'[not all(t[i+1]-t[i]-abs(x[i]-x[i+1])-abs(y[i]-y[i+1])>=0 and (t[i+1]-t[i]-abs(x[i]-x[i+1])-abs(y[i]-y[i+1]))%2==0 for i in range(n))::2])

Solution (Python):
import numpy as np
n = int(input())
flag = 0

for i in range(n):
    a,b,c = [int(z) for z in input().split()]
    p = np.abs(b)+np.abs(c)
    if a < p or (a-p)%2 != 0:
        flag = 1
    
if flag:
    print("No")
else:
    print("Yes")

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

flag = 0
S = [0,0]
for i in range(N):
    t,x,y = [int(zz) for zz in input().split()]
    p = abs(S[0]-x)+abs(S[1]-y)
    if t < p or (t-p)%2 != 0:
        flag = 1

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

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

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

can = True

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

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

Solution (Python):
import sys

N = int(input())
T = [[0 for i in range(3)] for j in range(N)]
for i in range(3):
    T = [[0,0,0]]
for i in range(1,N+1):
    row = input().split()
    for j in range(len(row)):
        row[j] = int(row[j])
    T.append(row)

for i in range(N):
    dist = abs(T[i+1][1]-T[i][1]) + abs(T[i+1][2]-T[i][2])
    time = T[i+1][0]- T[i][0]

    if dist > time or (dist - time) % 2 == 1:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        t -= x + y
        if t < 0 or t % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):

import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
n = int(raw_input())
data = [map(int, raw_input().split()) for i in range(n)]
t = 0
x = 0
y = 0
for d in data:
  duration = d[0] - t
  distance = abs(x - d[1]) + abs(y - d[2])
  if (distance > duration) or ((duration - distance) % 2 == 1):
    print 'No'
    sys.exit()
  t = d[0]
  x = d[1]
  y = d[2]
print 'Yes'

Solution (Python):
def is_reachable(time, x, y):
  if time < x + y:
    return False
  if (time - x - y) % 2 == 0:
    return True
  else:
    return False
  
N=int(input())
X=[list(map(int, input().split())) for i in range(N)]
t = 0
x = 0
y = 0
for i in range(N):
  if is_reachable(X[i][0]-t, abs(X[i][1]-x), abs(X[i][2]-y)):
    t = X[i][0]
    x = X[i][1]
    y = X[i][2]
  else:
    print("No")
    break
else:
  print("Yes")

Solution (Python):


n = int(input())

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

Solution (Python):
N = int(input())
before_t = before_x = before_y = 0
for _ in range(N):
  t, x, y = map(int, input().split())
  distance = abs(x-before_x) + abs(y-before_y)
  diff_t = t-before_t
  if diff_t < distance or (diff_t-distance)%2 != 0:
    print('No')
    exit()
  before_t = t
  before_x = x
  before_y = y
print('Yes')

Solution (Python):
n=int(input())
a=[[0,0,0]]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in range(n):
  time=(a[i+1][0]-a[i][0])
  dis=abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])
  if time-dis>=0 and (time-dis)%2==0:
    continue
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    ans = ['Odd', 'Even']
    print(ans[(a*b)%2-1])
    return


def B():
    a, b = map(str,input().split())
    a = a + b
    if math.sqrt(int(a)).is_integer():
        print("Yes")
    else:
        print("No")
    return


def C():
    n = II()
    pre = (0, 0, 0)
    for _ in range(n):
        t,x,y = LI()
        dist = abs(pre[0] - x) + abs(pre[1] - y)
        if dist <= t - pre[2] and dist % 2 == (t - pre[2]) % 2:
            pre = (x, y, t)
            continue
        print("No")
        return
    print("Yes")
    return


def D():
    return


if __name__ == '__main__':
    C()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b = LI()
    ans = ['Odd', 'Even']
    print(ans[(a*b)%2-1])
    return


def B():
    a, b = map(str,input().split())
    a = a + b
    if math.sqrt(int(a)).is_integer():
        print("Yes")
    else:
        print("No")
    return


def C():
    n = II()
    pre = (0, 0, 0)
    for _ in range(n):
        t,x,y = LI()
        dist = abs(pre[0] - x) + abs(pre[1] - y)
        if dist <= t - pre[2] and dist % 2 == (t - pre[2]) % 2:
            continue
        print("No")
        return
    print("Yes")
    return


def D():
    return


if __name__ == '__main__':
    C()

Solution (Python):
import fractions
def main31():
    num = int(input())
    txy = []
    txy.append([0,0,0])
    for i in range(num):
        kari = []
        data = input().split()
        for j in range(3):
            kari.append(int(data[j]))
        txy.append(kari)
    for i in range(num):
        kyori = abs(txy[i][1]-txy[i+1][1]) + abs(txy[i][2]-txy[i+1][2])
        zikan = txy[i+1][0] - txy[i][0]
        if not(kyori <= zikan and (kyori - zikan) % 2 == 0):
            print("No")
            return
    print("Yes")

if __name__ == "__main__":
    main31()

Solution (Python):
N = int(input())
txy = [[0, 0, 0]]
for i in range(N):
    txy.append(list(map(int, input().split())))
flag = False
for i in range(N):
    t_tmp = txy[i+1][0] - txy[i][0]
    x_diff = txy[i+1][1] - txy[i][1]
    y_diff = txy[i+1][2] - txy[i][2]
    if t_tmp >= (x_diff + y_diff) and (t_tmp - (x_diff + y_diff)) % 2 == 0:
        flag = True
    else:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

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

travel.sort()

if travel[0][0]<(travel[0][1]+travel[0][2]) or travel[0][0]%2!=(travel[0][1]+travel[0][2])%2:
    ans=0
else:
    for k in range(n-1):
     a=travel[k+1][0]-travel[k][0]
     b=travel[k+1][1]-travel[k][1]
     c=travel[k+1][2]-travel[k][2]
     if a<abs(b)+abs(c) or a%2!=(b+c)%2:
         ans=0
         break

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

Solution (Python):

n = int(input())
A = [[int(el) for el in input().split(' ')] for i in range(n)]

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

for i in range(1,n+1):
    t = A[i][0] - A[i-1][0]
    d = abs(A[i][1] - A[i-1][1]) + abs(A[i][2] - A[i-1][2])
    if (d <= t) & (d % 2 == t % 2):
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
N = int(input())
et = 0
ex = 0
ey = 0
ans = 'Yes'
for i in range(N):
    t, x, y = map(int, input().split())
    T = t - et
    dist = x - ex + y - ey
    if T % 2 != dist % 2 or T < dist:
        ans = 'No'
        break
    et = t
    ex = x
    ey = y
print(ans)

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

pt, px, py = [0, 0, 0]
ans = 'Yes'
for t, x, y in XY:
    lim = t - pt
    need = abs(x-px) + abs(y-py)
    if lim < need or (lim-need)%2==1:
        ans = 'No'
        break
    pt, px, py = t, x, y

print(ans)

Solution (Python):
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]
t = [0]
x = [0]
y = [0]
for t_i, x_i, y_i in txy:
    t.append(t_i)
    x.append(x_i)
    y.append(y_i)
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
    elif dist % 2 != dt % 2:
        can = False
if can == True:
    print('Yes')
else:
    print('No')

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

Solution (Python):
N = int(input())
now = [0] * 2
prev_t = 0

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

print('Yes')

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

t, x, y = 0, 0, 0
for i in place:
  next_t, next_x, next_y = i
  rest = (next_t - t) % (abs(next_x - x) + abs(next_y - y))
  if rest % 2 != 0 or (next_t - t) < (abs(next_x - x) + abs(next_y - y)):
    print('No')
    exit()
    
  t, x, y = next_t, next_x, next_y

print('Yes')

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

pos_t=0
pos_x=0
pos_y=0

def judge(target_t,target_x,target_y,
          pos_t,pos_x,pos_y):

    
    

    t = abs(target_t-pos_t)
    x = abs(target_x-pos_x)
    y = abs(target_y-pos_y)

    

    if x+y == t:
        
        return 0
    elif x == 0 and y== 0 and t%2==0:
        
        return 0
    elif ((x+y)%2 == 1) and (t%2==1) \
        and (x+y < t):
        
        return 0
    elif ((x+y)%2 == 0) and (t%2==0) \
        and (x+y<t):
        
        return 0
    else:
        return -1

no = 0
for i in range(n):
    t, x, y = map(int,input().split())
    ret = judge(t,x,y,pos_t,pos_x,pos_y)
    pos_t=t
    pos_x=x
    pos_y=y
    if ret == -1:
        no = 1

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

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

f = False
for i in range(n):
    t, x, y = list(map(int, input().split()))
    if f:
        continue
    if t < x + y:
        print('No')
        f = True
    if t % 2 == 0 and (x + y) % 2 == 1:
        print('No')
        f = True
    if t % 2 == 1 and (x + y) % 2 == 0:
        print('No')
        f = True
if not f:
    print('Yes')

Solution (Python):



N = int(input())

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

ans = 'Yes'

for i in range(N):
    t = X[i][0] - X[i][1]- X[i][2]
    if t < 0 or X[i][0] % 2 != (X[i][1] + X[i][2]) % 2 :
        ans = 'No'

print(ans)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math





 
def main():
    N = int(input())
    txy = []
    for i in range(N):
        t,x,y = map(int, input().split())
        txy.append((t,x,y))
        
    xx = 0
    yy = 0
    for i, val in enumerate(txy):
        t,x,y = val
        tmp = abs(xx-x) + abs(yy-y)
        if tmp > t:
            print("No")
            sys.exit()
        tmptmp = (tmp - t) % 2
        if tmptmp == 1:
            print("No")
            sys.exit()
            
    print("Yes")
	
if __name__ == "__main__":
	main()

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

T = 0
X = Y = 0
Flag = 'Even'

for n in range(N):
    Ti,Xi,Yi = [int(x) for x in input().split()]
    if abs(Xi-X) + abs(Yi-Y) > (Ti-T):
        print('No')
        break
    else:
        if Flag == 'Even':
            if (Ti-T) % 2 == 0:
                if (Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
                else:
                    print('No')
                    break
            else:
                if (Xi + Yi) % 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Odd'
                    continue
        else:
            if (Ti - T) % 2 == 0: 
                if(Xi + Yi)% 2 == 0:
                    print('No')
                    break
                else:
                    X = Xi
                    Y = Yi
                    T = Ti
                    continue
            else: 
                if(Xi + Yi) % 2 == 0:
                    X = Xi
                    Y = Yi
                    T = Ti
                    Flag = 'Even'
                    continue
                else:
                    print('No')
                    break
else:
    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())
count = 0
for i in range(n):
    t,x,y = map(int,input().split())
    if (x + y <= t and t % 2 == (x + y) % 2):
        continue
    else:
        print("No")
        exit()
print("Yes")

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


N = ii()

pt = 0
px = 0
py = 0

for _ in range(N):
  t, x, y = mi()
  mnht = abs(x-px) + abs(y-py)
  if not (t-pt >= mnht and (t-pt)%2 == mnht % 2):
    print('No')
    exit()

print('Yes')

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

for i in range(N):
	t, x, y = map(int, input().split(" "))
	t = t - x - y
	if t % 2 != 0 or t < 0:
		print("No")
		sys.exit()

print("Yes")

Solution (Python):
import sys
n=int(input())
t_pre=0
x_pre=0
y_pre=0
for _ in range(n):
    t,x,y=map(int,input().split())
    if t-t_pre<abs(x-x_pre)+abs(y-y_pre):
        print("No")
        sys.exit(0)
    elif (t-t_pre)%2!=(abs(x-x_pre)+abs(y-y_pre))%2:
        print("No")
        sys.exit(0)
print("Yes")

Solution (Python):
import sys
ans = "Yes"; input()

for e in sys.stdin:
    t, x, y = map(int, e.split())
    t = t - x - y
    if t < 0 or t % 2 == 1:
        ans = "No"
        break
print(ans)

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

check = [False for i in range(N)]

for i in range(N):
        if i == 0:        
                t = TXY[0][0]
                x = TXY[0][1]
                y = TXY[0][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[0] = True
                else:
                        break
        else :
                t = TXY[i][0] - TXY[i-1][0]
                x = TXY[i][1] - TXY[i-1][1]
                y = TXY[i][2] - TXY[i-1][2]
                if t >= (x+y) and t%2 ==(x+y)%2 :
                        check[i] = True
                else:
                        break

ans = check.count(True)
if ans == N :
        print('Yes')
else:
        print('No')

Solution (Python):
N = int(input())
table = [[int(i) for i in input().split()] for n in range(N)]
can = True
for i in range(N):
    if(i != 0):
        dt = table[i][0] - table[i-1][0]
        dist = abs(table[i][1]-table[i-1][1]) +abs(table[i][2]-table[i-1][2])
    else:
        dt = table[i][0]
        dist = abs(table[0][1]) + abs(table[0][2])
    if(dist > dt):
        can = False
        break
    elif((dt-dist)%2 != 0):
        can = False
        break
if(can == True):
    print("Yes")
else:
    print("No")

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

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

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

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

    z = (t - t_prev) - (abs(x - x_prev) + abs(y - y_prev))
    if z < 0 or z % 2 == 1:
        possible = False

    t_prev, x_prev, y_prev = t, x, y

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

Solution (Python):



n = int(input())

nt,nx,ny = 0,0,0
f = 1
for _ in range(n):
    t,x,y = map(int,input().split())
    if t - nt < abs(nx - x) + abs(ny - y):
        f = 0
    s = abs(nx - x) + abs(ny - y) - (t - nt)
    if s % 2 == 1:
        f = 0
    nt,nx,ny = t,x,y
if f:
    print('Yes')
else:
    print('No')