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 numpy as np
N = input()
t, x, y = [0], [0], [0]
for _ in range(N):
    _t, _x, _y = map(float, raw_input().split())
    t.append(_t)
    x.append(_x)
    y.append(_y)
 
txy = np.array([[_t, _x, _y] for _t, _x, _y in zip(t, x, y)], dtype=np.int64)

dm = np.diff(txy, axis=0)

ret = 'Yes'
for d in dm:
    total = np.abs(d[1]) + np.abs(d[2])
    if d[0] < total or (d[0] - total) % 2 != 0:
        ret = 'No'

print ret

Solution (Python):



import sys

n = int(sys.stdin.readline().strip())

txy = [tuple(map(int, l.strip().split(" "))) for l in sys.stdin.readlines()]
check_txy = [abs(_x) + abs(_y) <= _t and (_t + _x + _y) % 2 == 0 for (_t, _x, _y) in txy]
if all(check_txy):
    print("Yes")
else:
    print("No")

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

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

pos = [0, 0, 0]
out = 'Yes'

for t_to, x_to, y_to in moves:
    move_to = abs(x_to - pos[1]) + abs(y_to - pos[2])
    time_to = t_to - pos[0]
    
    if move_to == time_to or (((time_to - move_to) > 0) and (time_to - move_to) % 2 == 0):
        pos = [t_to, x_to, y_to]
    else:
        out = 'No'
        break

print(out)

Solution (Python):

import sys

def yn(s,x,y):
 r=abs(x)+abs(y)
 if s>=r and (s-r)%2==0:
  return True
 else:
  return False

n=int(raw_input())
s0,x0,y0=map(int,raw_input().split())
if yn(s0,x0,y0)==False:
 print 'No'
 sys.exit()
for i in xrange(n-1):
 s,x,y=map(int,raw_input().split())
 if yn(s-s0,x-x0,y-y0)==False:
  print 'No'
  sys.exit()
 s0,x0,y0=s,x,y
print 'Yes'

Solution (Python):
N = int(input())
x = y = 0
for i in range(N):
	t, nx, ny = map(int, input().split())
	d = abs(nx - x) + abs(ny - y)
	if t < d or (t - d) % 2 == 1:
		print("No")
		break
else:
	print("Yes")

Solution (Python):


if __name__ == '__main__':
    N = int(input())
    a=[[0,0,0]]
    for i in range(N):
        a.append(list(map(int,input().split())))
    flag=0
    for i in range(N):
        if (((a[i+1][0]-a[i][0]) < abs(a[i][1]-a[i+1][1]) + abs(a[i][2]-a[i+1][2])) or ((a[i+1][0]-a[i][0]) % 2 != (abs(a[i][1]-a[i+1][1]) + abs(a[i][2]-a[i+1][2])) % 2)):
            flag = 1
            break
    if flag == 0:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
'''input
2
3 1 2
6 1 1
'''



n, data = input(), []
for N in xrange(n):
	t, x, y = map(int, raw_input().strip().split())
	data.append([t, x, y])
xp, yp, tp, ans = 0, 0, 0, True
for i in xrange(n):
	t, x, y = data[i]
	d = abs(x - xp) + abs(y - yp)
	tc = t - tp
	if not (d <= tc and tc % 2 == d % 2):
		ans = False
		break
	xp, yp, tp = x, y, t
print 'Yes' if ans else 'No'

Solution (Python):


judge = 'Yes'

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:
        judge = 'No'

print(judge)

Solution (Python):
from collections import defaultdict

d = defaultdict(int)
n = int(input())

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

s = sorted(d)

curent = 0

for ss in s:
    k1, k2 = d[ss]
    k3 = k1 + k2
    if k3 - curent > ss:
        print('No')
        exit(0)
    if ((k3 & 1) == 1 and (ss & 1) == 1) or ((k3 & 1) == 0 and (ss & 1) == 0):
        curent = k3
    else:
        print('No')
        exit(0)
print('Yes')

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

Solution (Python):
import math
import numpy as np
from operator import mul



















N = int(input())
dest = [[0,0,0]]
dest1 = [list(map(int, input().split())) for i in range(N)] 
dest = dest + dest1
yn = 0

for i in range(N):
    t_int = dest[i+1][0] - dest[i][0]
    t_min = abs(dest[i+1][1] - dest[i][1]) + abs(dest[i+1][2] - dest[i][2])
    if t_int >= t_min and (t_int - t_min)%2 == 0:
        continue
    else:
        yn += 1

if yn > 0:
    print('No')
else:
    print('Yes')

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


def get_taxicab_metric(x1, y1, x2, y2):
    a = abs(x1 - x2)
    b = abs(y1 - y2)
    return a + b


t_prev, x_prev, y_prev = 0, 0, 0
is_failed = False

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

    distance = get_taxicab_metric(x, y, x_prev, y_prev)
    time_distance = t - t_prev

    if distance > time_distance:
        is_failed = True
        break

    if distance % 2 != time_distance % 2:
        is_failed = True
        break

    t_prev, x_prev, y_prev = t, x, y

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

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

for i in range(N):
    dist = abs(ls[i+1][1] - ls[i][1]) + abs(ls[i+1][2] - ls[i][2])
    time = ls[i+1][0] - ls[i][0]
    if dist > time or (time - dist) % 2 != 0:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
N = input()
ct, cx, cy = 0, 0, 0
enabled = True
for i in range(N):
    nt, nx, ny = map(int, raw_input().split())
    d = abs(nx-cx) + abs(ny-cy)
    dt = nt - ct
    enabled &= (dt >= d) and (dt % 2 == d % 2)
print "Yes" if enabled else "No"

Solution (Python):
import numpy as np

input_line_count = input()
line_count = int(input_line_count)

line = np.zeros([line_count, 3])
line_check = np.zeros(line_count)
for num in range(line_count):
  input_line = input()
  line[num] = input_line.split()
  if(line[num][0] % 2 == 0):
    if((line[num][1] + line[num][2]) % 2 == 0 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
  elif(line[num][0] % 2 == 1):
    if((line[num][1] + line[num][2]) % 2 == 1 and (line[num][1] + line[num][2]) <= line[num][0]):
      line_check[num] = 1
for num1 in range(line_count):
  if(line_check[num1] == 0):
    answer = "No"
    break
  else:
    answer = "Yes"

print(answer)

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

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

ct,cx,cy = 0,0,0
for i in range(N):
    hdist = abs(data[i][1] - cx) + abs(data[i][2] - cy)
    if hdist > abs(data[i][0] - ct) or abs(hdist - abs(data[i][0] - ct)) % 2 != 0:
        print("No")
        break
    ct,cx,cy = data[i][0],data[i][1],data[i][2]
else:
    print("Yes")

Solution (Python):
N = int(input())
t0, x0, y0 = 0, 0, 0
for _ in range(N):
    t, x, y = map(int, input().split())
    dt = t - t0
    dx = x - x0
    dy = y - y0
    if dt < dx + dy:
        print("No")
        exit()
    if (dx + dy - dt) % 2 != 0:
        print("No")
        exit()
    t0, x0, y0 = t, x, y
print("Yes")

Solution (Python):
abs = lambda x:x if x > 0 else -x

N = int(input())
txt = "Yes"

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

for nanachi in range(N):
  T,X,Y = map(int,input().split())
  d = abs(X-x) + abs(Y-y)
  if not((T - t >= d) and (d - T + t)%2 == 0):
    txt = "No"
    break
  t,x,y = [T,X,Y]
print(txt)

Solution (Python):


def solve():
    N = int(raw_input())
    t_now, x_now, y_now = 0, 0, 0
    for _ in xrange(N):
        t_next, x_next, y_next = map(int, raw_input().split())
        distance = abs(x_now - x_next) + abs(y_now - y_next)

        if distance > t_next - t_now or distance % 2 != (t_next - t_now) % 2:
            print "No"
            return
        t_now, x_now, y_now = t_next, x_next, y_next

    print "Yes"
    return


solve()

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

def f(n):
  t_n, x_n, y_n = 0, 0, 0
  for i in range(n):
    t, x, y = map(int, input().split())
    t_d = abs(t_n - t)
    x_d = abs(x_n - x)
    y_d = abs(y_n - y)
    if not x_d+y_d <= t_d or (x_d+y_d)%2 == 0 and not t_d%2 == 0 or not (x_d+y_d)%2 == 0 and t_d%2 == 0:
      return "No"
    t_n, x_n, y_n = t, x, y
  
  return "Yes"

print(f(n))

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

counter=0
posnow=[0,0,0]
for i in range(N):
    dt=sche[i][0]-posnow[0]
    dx=sche[i][1]-posnow[1]
    dy=sche[i][2]-posnow[2]
    if (dt-dx-dy)<0 or (dt-dx-dy)%2:
        break
    else:
        posnow=sche[i]
        counter=counter+1
if counter==N:
    print("Yes")
else:
    print("No")

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

x, y = 0, 0
t = 0
ans = "Yes"

for i in data:
    add = abs(int(i[2])-y) + abs(int(i[1])-x)
    tt = int(i[0])-t

    if tt % add == 0 :
        t = int(i[0])
        x,y = int(i[1]), int(i[2])

    else:
        ans = 'No'
        break

print(ans)

Solution (Python):
t_before = 0
x_before = 0
y_before = 0
result = 'Yes'

N = int(input())
for i in range(N) :
  t, x, y = map(int, input().split())
  t_diff = abs(t - t_before)
  x_diff = abs(x - x_before)
  y_diff = abs(y - y_before)
  if (x_diff <= t_diff) and (y_diff <= t_diff) and ((t_diff - (x_diff + y_diff)) % 2 == 0) :
    t_before = t
    x_before = x
    y_before = y
  else :
    result = 'No'
    break
print(result)

Solution (Python):
import sys
def check_ans(t,x,y,nt,nx,ny):
    if (x+y) > (nx+ny+t):
        print("No")
        sys.exit()    
    if (x >= nx):
        nt += (x-nx)
    elif(x <= nx):
        nt += (nx-x)
    if (y >= ny):
        nt += (y-ny)
    elif(y <= ny):
        nt += (ny-y)
    if (t-nt)%2 != 0:
        print("No")
        sys.exit()

N = int(input())
nt = 0
nx = 0
ny = 0
t = []
x = []
y = []

for i in range(N):
    temp = input().split(" ")
    t.append(temp[0])
    x.append(temp[1])
    y.append(temp[2])
for i in range(N):
    if i == 0:
        check_ans(int(t[i]), int(x[i]), int(y[i]), nt, nx, ny)
    else:
        nt = int(t[i-1])
        nx = int(x[i-1])
        ny = int(y[i-1])
    check_ans(int(t[i]), int(x[i]), int(y[i]), nt, nx, ny)
print("Yes")

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

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




for x in range(n):
    p = nums[x+1][0] - nums[x][0]
    px = nums[x+1][1] - nums[x][1]
    py = nums[x+1][2] - nums[x][2]
    ps = px + py
    

    for w in range(p+1):
        pp = w
        mp = p - pp
        
        if pp-mp==ps:
            ans.append(1)
        else:
            ans.append(0)

    
sum = 0 
for num in ans:
    sum = sum + num


if sum==n:
    print('Yes')
else:
    print('No')

Solution (Python):

n = int(input())
tmpt = 0
tmpx, tmpy = 0, 0
c = 0

def check(t, x, y):
    if t>=x+y and ( (t%2==0 and (x+y)%2==0) or (t%2==1 and (x+y)%2==1) ):
        return True
    else:
        return False

for i in range(n):
    t, x, y = map(int, input().split())
    if x==tmpx and y==tmpy:
        break   

    target = t-tmpt
    tmpt = t
    t_x, t_y = abs(x-tmpx), abs(y-tmpy)
    tmpx = x
    tmpy = y
    if check(target, t_x, t_y):
        c+=1
    else:
        break

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

Solution (Python):



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

def check(li):
    before = [0, 0, 0]
    for i in li:
        n, x, y = map(int, i)
        move = abs(n - before[0])
        pos = abs(x - before[1]) + abs(y - before[2])
        if not (pos <= move and pos % 2 == move % 2):
            return "No"
        before = [n, x, y]
    return "Yes"


print(check(li))

Solution (Python):
a = int(raw_input())
curr_x = 0
curr_y = 0
old_t = 0
for i in range(a):
    t, x, y = map(int, raw_input().split())
    diff_x = abs(x - curr_x)
    diff_y = abs(y - curr_y)
    diff_xy = diff_x + diff_y
    result = 0
    t2 = t - old_t
    

    if diff_xy > t2:
        result += 1
        break
    elif diff_xy == t2:
        
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    elif (t2 - diff_xy) % 2 == 0:
        
        result += 0
        curr_x = x
        curr_y = y
        old_t = t
    else:
        result += 1
        break

if result == 0:
    print "Yes"
else:
    print "No"

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

sum = 0
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 time < dist:
        print("No")
        break
    else:
        if dist%2 == time%2:
            sum += 1
            continue
        else:
            print("No")
            break

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

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

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

f = 0
for i in range(N):
    abs_list = []
    a = t[i + 1] - t[i]
    while a >= 0:
        abs_list.append(a)
        a += -2
    if abs(x[i] - x[i + 1] + y[i] - y[i + 1]) not in abs_list:
        f += 1
if f >= 1:
    print("No")
else:
    print("Yes")

Solution (Python):
N = input()
N = int(N)
t_list = [0]
x_list = [0]
y_list = [0]
for i in range(N):
    txy = input()
    t, x, y = txy.split()
    t = int(t)
    x = int(x)
    y = int(y)
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)



for i in range(1, N+1):
    t = t_list[i] - t_list[i-1]
    x = abs(x_list[i] - x_list[i-1])
    y = abs(y_list[i] - y_list[i-1])
    xy = x+y
    if t%2 == xy%2:
        res = 'Yes'
    elif not t%2 == xy%2:
        res = 'No'
    if t < xy:
        res = 'No'

print(res)

Solution (Python):
N = int(input())
points_list = [list(map(int,input().split())) for _ in range(N)]
flag = True
for i in range(N):
    if i == 0:
        dis = points_list[i][1] + points_list[i][2]
        if points_list[i][0] % dis == 0:
            p = dis
        else:
            flag = False
            break
    else:
        dis = (points_list[i][1] + points_list[i][2]) - p
        if dis == 0:
            if (points_list[i][0] - points_list[i-1][0]) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
            else:
                flag = False
                break
        elif points_list[i][0] - points_list[i-1][0] >= dis:
            if (points_list[i][0] - points_list[i-1][0]) % dis == 0 or (points_list[i][0] - points_list[i-1][0] - dis) % 2 == 0:
                p = points_list[i][1] + points_list[i][2]
                continue
                if abs(points_list[i][1] - points_list[i-1][1]) <= (points_list[i][0] - points_list[i-1][0]) and abs(points_list[i][2] - points_list[i-1][2]) <= (points_list[i][0] - points_list[i-1][0]):
                    continue
                else:
                    flag = False
                    break
            else:
                flag = False
                break
        else:
            flag = False
            break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
arr=[]
for _ in range(int(raw_input())):
	arr.append(map(int,raw_input().split(' ')))
temp1,temp2,temp3,ans=0,0,0,True
for temp,x,y in arr:
	x_d = abs(x-temp1);y_d = abs(y-temp2);t_d=temp-temp3;
	if t_d >= x_d + y_d:
		if t_d%2 == ((x_d+y_d)%2):
			flag = True
		else:
			flag = False
			print "No"
			sys.exit()
	else:
		flag = False
		print "No"
		sys.exit()
print "Yes"

Solution (Python):
def seinokazu(num):
    if num >= 0:
        return num
    else:
        num = -1 * num
        return num


n = input()
n = int(n)
clear = False

nexs = []

now = 0
x = 0
y = 0

for z in range(n):
    nexs.append(input())

for i in range(n):
    aa = nexs[i].split(" ")
    nex = int(aa[0])
    xx = int(aa[1])
    yy = int(aa[2])

    xsa = xx - x
    xsa = seinokazu(xsa)
    ysa = yy - y
    ysa = seinokazu(ysa)
    xysa = xsa + ysa
    nsa = nex - now
    if xysa > nsa:
        clear = False
        break
    else:
        sa = xysa - nsa
        sa = seinokazu(sa)
        if sa % 2!=0:
            clear = False
            break
        else:
            clear = True
    now = nex
    x = xx
    y = yy

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

Solution (Python):
N = int(input())
t, x, y = [0], [0], [0]
isPossible = True
for i in range(N):
    a, b, c = [int(j) for j in input().split()]
    t.append(a)
    x.append(b)
    y.append(c)

for i in range(N):
    dt = t[i+1] - t[i]
    dx = abs(x[i+1] - x[i])
    dy = abs(y[i+1] - y[i])
    
    if dt <  dx + dy or dt % 2 != (dx + dy) % 2:
        isPossible = False

print(("No", "Yes")[isPossible])

Solution (Python):
N = int(input())
point = [0, 0]
current = 0
flag = False
for _ in range(N):
    t, x, y = map(int, input().split())
    tmp = abs(point[0]-x)+abs(point[1]-y)
    dif_time = t - current
    dif = dif_time - tmp
    if tmp > dif_time:
        flag = True
    elif tmp == dif_time:
        flag = False
    elif tmp % 2 == 0 and dif_time % 2:
        flag = True
    else:
        flag = False
    if flag:
        print("No")
        break
    point = [x, y]
    current = t
else:
    print("Yes")

Solution (Python):
N = int(input()) 
flag = True
def isTravel(ti, xi, yi):
    a_min = [0, xi, (xi+yi-ti)//2, (xi-yi-ti)//2]
    a_max = [ti, xi+ti, (xi+yi+ti)//2, (xi-yi+ti)//2]
    a = max(a_min)
    if max(a_min)<=min(a_max) and (xi+yi+ti)%2==0:
        return True
    else:
        return False

for _ in range(N):
    ti, xi, yi = map(int, input().split())
    if flag:
        if isTravel(ti, xi, yi):
            pass
        else:
            flag = False
        
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
import math

N = int(input())
X = 0
Y = 0
T = 0
flag = True
for i in range(N):
    t,x,y = [int(i) for i in input().split()]
    dt = t-T
    dx = abs(x-X)
    dy = abs(y-Y)
    if dx + dy <= dt and (dt - dx - dy) % 2 == 0:
        flag = True
    else:
        flag = False

    if flag == False:
        break

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

Solution (Python):
import sys
N=int(input())
placeT=[0]*(N+1);placeX=[0]*(N+1);placeY=[0]*(N+1);
for i in range(N):
    placeT[i+1],placeX[i+1],placeY[i+1]=map(int,input().split())
for i in range(1,N+1):
    t0=placeT[i-1];x0=placeX[i-1];y0=placeY[i-1];
    t=placeT[i];x=placeX[i];y=placeY[i];
    if abs(x-x0)+abs(y-y0)>t-t0:
        print("No");sys.exit();
    else:
        if (abs(x-x0)+abs(y-y0)-(t-t0))%2!=0:
            print("No");sys.exit();
print("Yes")

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

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

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

ans = "Yes"
for i in range(N):
    if x[i] + y[i] > t[i]:
        ans = "No"
        break
    if t[i] % 2 == 0 and (x[i] + y[i]) % 2 == 1:
        ans = "No"
        break
    elif t[i] % 2 == 1 and (x[i] + y[i]) % 2 == 0:
        ans = "No"
        break

print(ans)

Solution (Python):

def main():
    N = int(input())
    t1, x1, y1 = 0, 0, 0

    for i in range(N):
        t2, x2, y2 = map(int, input().split())
        dt = t2 - t1
        ds = abs(x1 - x2) + abs(y1 - y2)
        if dt - ds >= 0 and (dt - ds) % 2 == 0:
            pass
        else:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
import math

N = int(input())

prev_t, x, y = 0, 0, 0
for _ in range(N):
    t, t_x, t_y = map(int, input().split())

    m_t, m_x, m_y = t - prev_t, math.fabs(t_x - x), math.fabs(t_y - y)
    if m_x > m_t or m_y > m_t or math.fabs(m_t - (m_x + m_y)) % 2 == 1:
        print("No")
        exit()

    prev_t, x, y = t, t_x, t_y

print("Yes")

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

for i in range(n):
    tb, xb, yb = t, x, y
    t, x, y = map(int, input().split())
    tn = t - tb
    xn = x - xb
    yn = y - yb
    move = abs(xn) + abs(yn)

    if tn < move or (tn - move) % 2 == 1:
        ans = 'No'
        break

else:
    ans = 'Yes'

print(ans)

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

list = [(0,0,0)]
for i in range(N):
	data = input().split()
	list.append((int(data[0]), int(data[1]), int(data[2])))

for i in range(1, len(list)):
	t = list[i][0] - list[i-1][0]
	if(list[i][1] != list[i-1][1]):
		x = abs(list[i][1] - list[i-1][1])
		t -= x
		if(t < 0):
			print("No")
			exit()
	if(list[i][2] != list[i-1][2]):
		y = abs(list[i][2] - list[i-1][2])
		t -= y
		if(t < 0):
			print("No")
			exit()
	if(t % 2 != 0):
		print("No")
		exit()

print("Yes")

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

tn = 0
xn = 0
yn = 0

while n > 0:
    n -= 1
    c = "f"
    I = input()
    N = I.split()
    t = int(N[0])
    x = int(N[1])
    y = int(N[2])

    ts = t - tn
    xs = x - xn
    ys = y - yn
    s = ts - ( xs + ys )

    if s == 0:
        c = "t" 
    elif s > 0:
        if s % 2 ==0:
            c = "t"
    if c == "f":
        break

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

Solution (Python):
def main():
    N=int(input())
    t,x,y=[0]*(N+1),[0]*(N+1),[0]*(N+1)
    for i in range(1,N+1):
        t[i],x[i],y[i]=map(int,input().split())
        dif=((t[i]-t[i-1])-(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])))
        
        if dif < 0 or dif % 2 != 0:
            print("No")
            return
    print("Yes")
    
if __name__=="__main__":
    main()

Solution (Python):
flag = False

def traverable(st,sx,sy,gt,gx,gy):
    if ((gx+gy)-(sx+sy)) % 2 != (gt-st) %2:
        return False
    elif (gx+gy)-(sx+sy) > gt-st:
        return False
    else:
        return True

N = int(input())
t = [0];x = [0];y = [0]
for i in range(N):
    tt,xx,yy = [int(i) for i in input().split()]
    t.append(tt);x.append(xx);y.append(yy)

for i in range(N):
    if not(traverable(t[i],x[i],y[i],t[i+1],x[i+1],y[i+1])):
        flag = True

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

Solution (Python):
no_flag = False
N = int(input())
old_t, old_x, old_y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if not no_flag:
        judge = (t - old_t) - (x - old_x) - (y - old_y)
        if (judge < 0) or (judge % 2):
            no_flag = True
if not no_flag: print('Yes')
else:   print('No')

Solution (Python):
c = [0, 0]
f = True
for _ in range(int(input())):
    t, x, y = map(int, input().split())
    if sum(c) + t < abs(x) + abs(y):
        f = False
    if t % 2 != abs(c[1] - y + c[0] - x) % 2:
        f = False
print(f and 'Yes' or 'No')

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

for i in range(n):
    t,x,y = map(int,input().split())
    l = abs(x-cp[0])+abs(y-cp[1])
    s = t - t1 - l
    if s < 0 or s % 2 == 1:
        print('No')
        break
    cp = [x,y]
    t1 = t
else:
    print('Yes')

Solution (Python):
M = int(raw_input())

t0,x0,y0=0,0,0
OK=1

for i in range(M):
    t,x,y = map(int, raw_input().split())
    dl=abs(x-x0)+abs(y-y0)
    dt=t-t0
    if(dl>dt):
        OK=0
        break
    elif ((dt-dl)%2==1):
        OK=0
        break
    else:
        t0,x0,y0=t,x,y

if OK==1 :
    print "Yes"
else:
    print "No"

Solution (Python):


def canDeerGo(strinp):
    t, n1, n2 = map(int, strinp.split())
    var1 = t + n1 + n2
    var2 = n1 + n2
    ans = True
    if var1 % 2 != 0 or var2 > t:
        ans = False
    return ans

def diffData(s,ss):
    t, n1, n2 = map(int, s.split())
    t2,n12,n22 = map(int, ss.split())
    l = [t2-t,n12-n1,n22-n2]
    canDeerGo(' '.join((list(map(str,l)))))

num = int(input())
ss =''
for i in range(num):
    s = input()
    if ss != '':
        diffData(s,ss)
    ans = canDeerGo(s)
    if ans == False:
        ans = 'No'
        break
    elif i == num-1:
        ans = 'Yes'
    ss = s
print(ans)

Solution (Python):

n = int(input())
ot, ox, oy = 0, 0, 0
flg = True

for i in range(n):
    t, x, y = map(int, (input().split()))
    dt, dxy = t - ot, abs(x - ox) + abs(y - oy)

    if dt < dxy or (dt + dxy) % 2 != 0:
        flg = False

    ot, ox, oy = t, x, y

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

Solution (Python):
n = int(input())
t0 = int(0)
x0 = int(0)
y0 = int(0)

def solve(n):
    global t0, x0, y0
    for i in range(n):
        t, x, y = map(int, input().split())
        if t - t0 < abs(x - x0) + abs(y - y0):
            return "No"
        if ((t - t0) - (abs(x - x0) + abs(y - y0))) % 2 == 1:
            return "No"
        x0 = x
        y0 = y
        t0 = t        
    return "Yes"    

print(solve(n))

Solution (Python):
n = int(input())
me = [0,0]
arr = []
tmp = 0
flg = True
for i in range(n):
    arr += [list(map(int,input().split()))]

for t in arr:
    for _ in range(t[0]-tmp):
        if me[0] < t[1]:
            me[0] += 1
        elif me[0] > t[1]:
            me[0] -= 1
        elif me[1] < t[2]:
            me[1] += 1
        elif me[1] > t[2]:
            me[1] -= 1
        else:
            me[0] += 1
        tmp = t[0]
    if me != t[1:]:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
t = []
x = []
y = []
for i in range(N):
  t1, x1, y1 = map(int, input().split())
  t.append(t1)
  x.append(x1)
  y.append(y1)

flg = 1
for i in range(N):
        if x[i]+y[i] > t[i]:
            flg = 0
        elif (x[i]+y[i])%2 != t[i]%2:
            flg = 0
print("Yes" if flg == 1 else "No")

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

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

for i in range(n):
   ttmp, xtmp, ytmp = map(int, input().split())
   t.append(ttmp)
   x.append(xtmp)
   y.append(ytmp)

for i in range(n):
   if i == 0:
      if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2:
         cnt += 1
      else:
         print("No")
         break
   else:
         if t[i] >= x[i]+y[i] and (t[i])%2 == (x[i]+y[i])%2 and x[i]+y[i]-x[i-1]-y[i-1] <= t[i]-t[i-1] :
            cnt += 1
         else:
            print("No")
            break

if cnt == n:
   print("Yes")

Solution (Python):
'''
奇数距離の場合、偶数回の移動は不可能
偶数距離の場合、奇数回の移動は不可能
'''
N = int(input())
L =[]
for i in range(N):
	t,x,y = input().split(' ')
	L.append([int(t),int(x),int(y)])

now = [0,0,0]
for i in range(N):
	time = L[i][0] - now[0]
	sub_x = abs(now[1] - L[i][1])
	sub_y = abs(now[2] - L[i][2])
	dist = sub_x + sub_y
	if dist%2 == 0:
		if time < dist or time%2 == 1:
			print('No')
			quit()
		else:
			now = L[i]
	else:
		if time < dist or time%2 == 0:
			print('No')
			quit()
		else:
			now = L[i]


print('Yes')

Solution (Python):
num = int(input())
n_now = 0
x_now = 0
y_now = 0
Flag = True

for i in range(num):
    n_next, x_next, y_next = [int(i) for i in input().split()]
    time = n_next - n_now
    move = abs(x_next - x_now) + abs(y_next - y_now)
    if time < move:
        Flag = False
        break
    elif (time - move) % 2 != 0:
        Flag = False
        break
    else:
        x_now = x_next
        y_now = y_next
        n_now = n_next

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

Solution (Python):
import numpy as np
N =int(input())
data =np.array( [[ int(i) for i in input().split(" ")] for i in range(N)])
t_past = 0
x_past = 0
y_past = 0
flag = 0
for i in range(N):
    t_diff = data[i,0] - t_past
    x_diff = data[i,1] - x_past
    y_diff = data[i,2] - y_past
    if not( t_diff -abs(x_diff) -abs(y_diff) >=0 and (t_diff-abs(x_diff)-abs(y_diff))%2 ==0):
        flag = 1
        break
    t_past = data[i,0]
    x_past = data[i,1]
    y_past = data[i,2]
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):


N = int(input())
txy = []
for _ in range(N):
    t, x, y = map(int, input().strip().split())
    txy.append((t, x, y))
can_travel = False
prev_t, prev_x, prev_y = 0,0,0
for t, x, y in txy:
    if abs(x-prev_x) + (y-prev_y) > t - prev_t:
        can_travel = False
        break
    elif (abs(x-prev_x) + abs(y-prev_y)) % 2 != (t-prev_t) % 2:
        can_travel = False
        break
    else:
        prev_t, prev_x, prev_y = t, x, y
        can_travel = True
        continue
if can_travel:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
t=0
x=0
y=0
ans=True
for i in range(N):
  ta,xa,ya=map(int,input().split())
  res1=abs(xa-x)
  res2=abs(ya-y)
  if res1+res2>(ta-t):
    ans=False
    break
  else:
    if ((ta-t)-(res1+res2))%2==1:
      ans=False
      break
  t=ta
  x=xa
  y=ya
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
n=input()
n=int(n)
now = 0
nowx=0
nowy=0
for i in range(n):
    temp=input().split(" ")
    
    t=int(temp[0])
    
    x=int(temp[1])
    y=int(temp[2])
    
    
    if abs(nowx-x)+abs(nowy-y)>t-now  or ((abs(nowx-x)+abs(nowy-y))%2==1 and  (t-now)%2==0) or ((abs(nowx-x)+abs(nowy-y))%2==0 and  (t-now)%2==1):
        print("No")
        exit()
        
    else:
        now=t
        nowx=x
        nowy=y
        


print("Yes")

Solution (Python):
def main():
    N = int(input())
    ans = ''
    for a in range(N):
        t, x, y = map(int, input().split())
        if ans != 'No':
            if t-(x+y) == 0:
                ans = 'Yes'
            elif t-(x+y) > 0:
                if (t%2==0 and (x+y)%2==0) or (t%2==1 and (x+y)%2==1):
                    ans = 'Yes'
                else:
                    ans = 'No'
            else:
                ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

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

flag = 0
for i in range(N):
   T_min = (x[i+1]-x[i]) + (y[i+1]-y[i])
   if (t[i+1]-t[i]) < T_min:
      flag = 1
      break
   elif (t[i+1]-t[i]-T_min)%2 != 0:
      flag = 1
      break

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

else:
   print("Yes")

Solution (Python):

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

canBePlanned = 'Yes'
xprev = 0
yprev = 0
tprev = 0
for i in range(N):
    xdiff = abs(x[i] - xprev)
    ydiff = abs(y[i] - yprev)
    tdiff = t[i] - tprev
    if (t[i] - (x[i] + y[i])) % 2 != 0 or (tdiff - (xdiff + ydiff)) % 2 != 0 or tdiff < xdiff + ydiff:
        canBePlanned = 'No'
        break
    xprev, yprev, tprev = x[i], y[i], t[i]

print(canBePlanned)