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_before=0
x_before=0
y_before=0
import sys

for i in range (N):
    t, x, y =map(int,input().split())
    t_diff=t-t_before
    distance=abs(x-x_before)+abs(y-y_before)
    if (t_diff-distance)%2!=0 or distance>t_diff:
        print("No")
        sys.exit()
    else:
        t_before=t
        x_before=x
        y_before=y
    
        

print ("Yes")

Solution (Python):
N = int(input())
coords_list = tuple([(0, 0, 0)] + [tuple([int(elem) for elem in input().split(' ')]) for _ in range(N)])

for i in range(N):
    dt = coords_list[i + 1][0] - coords_list[i][0]
    diff = [abs(coords_list[i + 1][1] - coords_list[i][1]), 
            abs(coords_list[i + 1][2] - coords_list[i][2])]

    if sum(diff) > dt:
        print("No")
        exit(0)
    elif (diff[0] + diff[1]) % 2 == dt % 2:
        continue
    else: 
        print("No")
        exit(0)
else:
    print("Yes")

Solution (Python):
N = int(input())
coords_list = tuple([(0, 0, 0)] + [tuple([int(elem) for elem in input().split(' ')]) for _ in range(N)])

for i in range(N):
    dt = coords_list[i + 1][0] - coords_list[i][0]
    diff = [abs(coords_list[i + 1][1] - coords_list[i][1]), 
            abs(coords_list[i + 1][2] - coords_list[i][2])]

    if sum(diff) > dt:
        print("No")
        exit(0)
    elif (diff[0] + diff[1]) % 2 == dt % 2:
        continue
    else: 
        print("No")
        exit(0)
else:
    print("Yes")

Solution (Python):
class Point:
	def __init__(self, x, y):
		self.x = x
		self.y = y

def ham_dist(p1, p2):
	dx = abs(p1.x - p2.x)
	dy = abs(p1.y - p2.y)

	return dx+dy

n = int(input())
possible = True

pos = Point(0, 0)
t = 0

for i in range(n):
	_t, x, y = map(int, input().split())
	
	dest = Point(x, y)
	dt = _t - t
	dist = ham_dist(pos, dest)

	if dt < dist or (dt - dist) % 2 != 0:
		possible = False
		
	t = _t
	pos = dest

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

Solution (Python):
import sys

m = int(input())
t = []
x = []
y = []

i = 0
while(i < m):
  a = input().split()
  t.append(int(a[0]))
  x.append(int(a[1]))
  y.append(int(a[2]))
  i += 1

cx = 0
cy = 0
ct = 0

i = 0
while(i < m):
  dx = abs(x[i] - cx)
  dy = abs(y[i] - cy)
  dt = (t[i] - ct) - (dx + dy)
  if(dt < 0 or dt > 0 and dt % 2 == 1):
    print('No')
    sys.exit()
  cx = x[i]
  cy = y[i]
  ct = t[i]
  i += 1
print('Yes')

Solution (Python):

r = 1
t = 0
m = 0
N = int(input())
txy = []

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


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if t < m:
        print("No")
        break
    elif (t - m) % 2 != 0:
        print("No")
        break
    
    
    
    if r == N and t >= m:
        print("Yes")
        
    r += 1

Solution (Python):
N = int(input())
X = []
flag = True
dt=0
dx=0
dy=0

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

for i in X:
     dt = abs(i[0] - dt)
     dx = abs(i[1] - dx)
     dy = abs(i[2] - dy)
     if dx + dy > dt:
         flag = False
     elif (dt - dx - dy) % 2 == 1:
         flag = False

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

Solution (Python):

r = 1
t = 0
m = 0
N = int(input())
txy = []

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


for i in txy:
    t = i[0] - t
    m = abs((i[1] + i[2]) - m)
    
    if i[0] % 2 == 0:
        if (i[1] + i[2]) % 2 != 0:
            print("No")
            break
        elif t < m:
            print("No")
            break
            
    else:
        if (i[1] + i[2]) % 2 != 1:
            print("No")
            break
        elif t < m:
            print("No")
            break
    
   
    if r == N and t >= m:
        print("Yes")
        
    r += 1

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

t = 0
x = 0
y = 0

able = True
for point in points:
    dt = point[0] - t
    dl = abs(point[1] - x)+abs(point[2]-y)
    if dt-dl>=0 and (dt-dl)%2 == 0:
        pass
    else:
        able = False
    t = point[0]
    x = point[1]
    y = point[2]
print("Yes" if able else "No")

Solution (Python):
n = int(input())
t = [0 for i in range(n)]
x = [0 for i in range(n)]
y = [0 for i in range(n)]
for i in range(n):
    t[i],x[i],y[i] = map(int, input().split(" "))

for i in range(n):
    if i == 0:
        sum = abs(x[i]) + abs(y[i])
        time = t[i]
    else:
        sum = abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
        time = t[i]-t[i-1]
    if sum > time:
        print("No")
        quit()
    if sum%2 != time%2:
        print("No")
        quit()
print("Yes")

Solution (Python):
def can_travel(ts, xs, ys):
    t_prev, x_prev, y_prev = 0, 0, 0
    for t, x, y in zip(ts, xs, ys):
        t_diff = t - t_prev
        d = abs(x - x_prev) + abs(y - y_prev)

        if t_diff < d:
            return False

        if t_diff % 2 != d % 2:
            return False

    return True


if __name__ == '__main__':
    N = int(input())
    values = [list(map(int, input().split())) for _ in range(N)]
    ts, xs, ys = zip(*values)

    if can_travel(ts, xs, ys):
        print("Yes")
    else:
        print("No")

Solution (Python):

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

judge = True 
for i in range(N):
    distance = t_list[i + 1] - t_list[i]
    distance_abs = abs(x_list[i + 1] - x_list[i]) + abs(y_list[i + 1] - y_list[i])

    if (distance < distance_abs):
        judge = False
    if (distance % 2 != distance_abs % 2):
        judge = False

if judge is True:
    print('Yes')
if judge is False:
    print('No')

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if judge!=0:
        break
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for i in range(n)]
loc_x=0
loc_y=0
judge=0
for i in range(n):
    if txy[i][0]%2==0:
        if (txy[i][1]+txy[i][2])%2!=0:
            judge+=1
    elif (txy[i][1]+txy[i][2])%2==0:
        judge+=1
    temp = abs(loc_x-txy[i][1])+abs(loc_y-txy[i][2])
    if i == 0:
        if temp > txy[0][0]:
            judge+=1
    else:
        if temp > txy[i][0]-txy[i-1][0]:
            judge+=1
    loc_x = txy[i][1]
    loc_y = txy[i][2]
print('No') if judge else print('Yes')

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

for j in range(0,N):
    t,x,y = map(int,input().split())
    plan.append(t)
    plan.append(x)
    plan.append(y)

if (plan[0] < plan[1] + plan[2]) or ((plan[0] % 2) != ((plan[1] + plan[2]) % 2)):
    print("No")
    exit()

for i in range(0,N-1):
    time_dis = plan[i*3 +3] - plan[i*3]
    x_dis = abs(plan[i*3+1] - plan[i*3+1 +3])
    y_dis = abs(plan[i*3+2] - plan[i*3+2 +3])
    
    if (time_dis < x_dis + y_dis) or ((time_dis % 2) != ((x_dis + y_dis) % 2)):
        print("No")
        exit()
        
print("Yes")

Solution (Python):
n = int(input())
t,x,y=[0],[0],[0]
for _ in range(n):
    T,X,Y = map(int, input().split())
    t.append(T)
    x.append(X)
    y.append(Y)

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

Solution (Python):
n = int(input())
t1, x1, y1 = 0, 0, 0
feasible = True
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    movements = abs(x2 - x1) + abs(y2 - y1)
    if movements > (t2 - t1) or movements % 2 != (t2 - t1) % 2:
        feasible = False
    t1, x1, y1 = t2, x2, y2
print('Yes') if feasible else print('No')

Solution (Python):
n=int(input())
info=[[int(i)for i in input().split()]for i in range(n)]
info.insert(0,[0,0,0])
for i in range(n):
    t=info[i+1][0]-info[i][0]
    d=abs(info[i+1][1]-info[i][1])+abs(info[i+1][2]-info[i][2])
    if d<=t:
        if d%2==0 and t%2==0:
            pass
        elif d%2==1 and t%2==1:
            pass
        else:
            print("No")
            exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Solution (Python):
def validate(plan):
    pre_time = 0
    pre_x, pre_y = 0, 0
    available = True
    for t, x, y in plan:
        elapsed = t - pre_time
        dist = abs(x-pre_x) + abs(y-pre_y) 
        if elapsed < dist or elapsed%2 != dist%2:
            available = False
            break
    return available

def solve():
    N = int(input())
    plan = []
    for i in range(N):
        plan.append(map(int, input().split()))
    available = validate(plan)
    if available:
        print('Yes')
    else:
        print('No')

solve()

Solution (Python):


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

current_position = [0, 0]
t = 0
flag = True
for i in range(N):
    diff_x = abs(a[i][1] - current_position[0])
    diff_y = abs(a[i][2] - current_position[1])
    p = (a[i][0] - t) - (diff_x + diff_y)
    if p >= 0 and p % 2 == 0:
        pass
    else:
        flag = False
        break
    t = a[i][0]
    current_position[0] = a[i][1]
    current_position[1] = a[i][2]
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
old_t = 0
old_x, old_y = 0, 0
ok = True
for i in range(n):
    t, x, y = map(int, input().split())
    if ok:
        dt = t - old_t
        dx = abs(x - old_x)
        dy = abs(y - old_y)
        if dt < dx+dy:
            ok = False
            break
        else:
            if dt % 2 == 0:
                if (dx + dy) % 2 != 0:
                    ok = False
                    break
            else:
                if (dx + dy) % 2 == 0:
                    ok = False
                    break
        old_t = t
        old_x = x
        old_y = y
if ok:
    print('Yes')
else:
    print('No')

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

for i in range(n):
    t, x, y = map(int, input().split())
    if (x + y <= t) & ((x + y + t) % 2 == 0):
        is_yes = True
    else:
        print("No")
        quit()

if is_yes:
    print("Yes")

Solution (Python):
import sys

n = int(input())
prev_t = 0
prev_x = 0
prev_y = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    d_t = abs(prev_t - t)
    d_x = abs(prev_x - x)
    d_y = abs(prev_y - y)
    if d_t % 2 != ((d_x + d_y) % 2) or d_t < d_x + d_y:
        print('No')
        sys.exit()
    prev_t = t
    prev_x = x
    prev_y = y
print('Yes')

Solution (Python):
N = int(input())
S = "Yes"
A = [(0,0,0)]
for i in range(N):
    t,x,y = map(int,input().split())
    A.append((t,x,y))
A = sorted(A)
for i in range(N):
    t1,x1,y1 = A[i]
    t2,x2,y2 = A[i+1]
    if abs(x2-x1)+abs(y2-y1) > t2-t1  or   (abs(x2-x1)+abs(y2-y1))%2 != (t2-t1)%2:
        S = "No"
        break
print(S)

Solution (Python):
N = int(input())
L = [list(map(int, input().split())) for k in range(N)]
L = [[0,0,0]] + L
for k in range(1,N+1):
    if (L[k][0]-L[k-1][0])%2 != (abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]))%2 or L[k][0]-L[k-1][0] < abs(L[k][1]-L[k-1][1])+abs(L[k][2]-L[k-1][2]):
        print("No")
        exit(0)
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 ==1:
        print('No')
        exit()
print('Yes')

Solution (Python):

def can_Travel(visits):
    current_loc = (0, 0)
    current_time = 0
    for visit in visits:
        next_loc = (visit[1], visit[2])
        distance =  abs(next_loc[0] - current_loc[0]) + abs(next_loc[1] - current_loc[1])

        if distance > visit[0] - current_time:
            return False
        elif (visit[0] - current_time - distance)%2 != 0:
            return False

    return True


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

print("Yes" if can_Travel(visits) else "No")

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())
for i in range(N):
    dt = t[i+1] - t[i] 
    dx = x[i+1] - x[i]
    dy = y[i+1] - y[i]
    if dx+dy > dt or (dt-dx-dy)%2!=0:
        print('No')
        break
    if i == N-1:
        print('Yes')

Solution (Python):
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    if result==0:
        print('No')
        break
if result:
  print('Yes')

Solution (Python):
def a(t,x,y):
    n=abs(x)+abs(y)
    if (t-n)%2==0 and t-n>=0 :
        return 1
    else :
        return 0
N=int(input())
result=1
tn,xn,yn=0,0,0
for i in range(N):
    t,x,y=map(int,input().split())
    tn=t-tn
    xn=x-xn
    yn=y-yn
    result*=a(tn,xn,yn)
    
if result==1:
    print ('Yes')
else:
    print ('No')

Solution (Python):
N = int(input())
next_plan = [0, 0, 0]
for i in range(N):
    now_plan = next_plan
    next_plan = [int(i) for i in input().split()]
    time = next_plan[0] - now_plan[0]
    x = abs(next_plan[1] - now_plan[1])
    y = abs(next_plan[2] - now_plan[2])
    distance = x + y
    if not (distance <= time and (time - distance) % 2 == 0):
        print("No")
        break
else:
    print("Yes")

Solution (Python):
def solve():
  N = int(input())
  t = [0]
  x = [0]
  y = [0]
  for i in range(N):
    a, b, c = map(int, input().split())
    t.append(a)
    x.append(b)
    y.append(c)
  for i in range(N):
    l = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    dt = t[i + 1] - t[i]
    if l > dt or l % 2 != dt % 2:
      return "No"
  return "Yes"

print(solve())

Solution (Python):
N=int(input())
ans=True
for i in range(N):
    a,b,c=map(int,input().split())
    n=(a)-abs(b)-abs(c)
    if n<0 or n%2==1:
        ans=False
if ans==True:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
x,y,z=0,0,0
ans=True
for i in range(N):
    a,b,c=map(int,input().split())
    n=(a-x)-abs(b-y)-abs(c-z)
    x,y,z=a,b,c
    if n<0 or n%2==1:
        ans=False
if ans==True:
    print("Yes")
else:
    print("No")

Solution (Python):


n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')

Solution (Python):


n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    travel.append([int(x) for x in input().split()])

for j in travel:
    t, x, y = j[0], j[1], j[2]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')

Solution (Python):
import sys


def dist(a, b):
    return abs(a[0] - b[0]) + abs(a[1] - b[1])


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

tmp = (0, 0, 0)
for query in q:
    if (query[0] - tmp[0] < dist(tmp[1:], query[1:]) or (query[1] - tmp[1] + query[2] - tmp[2]) % 2 != (query[0] - tmp[0]) % 2):
        print('No')
        sys.exit()
else:
    print('Yes')

Solution (Python):

def movable(prev_loc, loc):
  dt = loc[0] - prev_loc[0]
  dx = abs(loc[1] - prev_loc[1])
  dy = abs(loc[2] - prev_loc[2])
  
  if dx + dy > dt:
    return False
  if (dx + dy) % 2 == dt % 2:
    return True
  else:
    return False


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


ans = True
prev_loc = [0, 0, 0]
for loc in loc_list:
  
  if not movable(prev_loc, loc):
    ans = False
    break
  prev_loc = loc

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

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

Solution (Python):
def BlCannotGo(dt, dx, dy): 
    dist = dx + dy
    if (dt % 2) != (dist % 2) or dist > dt:
        return True
    else:
        return False

def abs(x):
    if x>=0:
        return x
    else:
        return -x

if __name__ == '__main__':
    n = int(input())
    t = list(False for _  in range(n+1))
    x = list(False for _  in range(n+1))
    y = list(False for _  in range(n+1))
    t[0], x[0], y[0] = 0, 0, 0
    for i in range(n):
        t[i+1], x[i+1], y[i+1] = map(int, input().split())

    for i in range(1,n+1):
        dt = t[i] -  t[i-1]
        dx = abs(x[i] -  x[i-1])
        dy = abs(y[i] -  y[i-1])
        if BlCannotGo(dt, dx, dy):
            print('No')    
            exit()

    print('Yes')

Solution (Python):
def BlCannotGo(dt, dx, dy): 
    if (dt % 2) != ((dx + dy) % 2) or (dx + dy) > dt:
        return True
    else:
        return False

if __name__ == '__main__':
    n = int(input())
    l = list(list(map(int, input().split())) for _ in range(n))

    dt = l[0][0]
    dx = l[0][1]
    dy = l[0][2]
    if BlCannotGo(dt, dx, dy):
        print('No')    
        exit()
        
    for i in range(1,n):
        dt = l[i][0] -  l[i-1][0] 
        dx = l[i][1] -  l[i-1][1]
        dy = l[i][2] -  l[i-1][2]
        if BlCannotGo(dt, dx, dy):
            print('No')    
            exit()

    print('Yes')

Solution (Python):
import time
n = int(input())
t = [[i for i in map(int, input().split())] for _ in range(n)]

now = [0, 0, 0]
flag = True

for target in t:
    t_t, t_x, t_y = target
    n_t, n_x, n_y = now

    distance = abs(t_x-n_x) + abs(t_y - n_y)
    require_time = t_t - n_t

    if distance <= require_time and (distance-require_time) % 2 == 0:
        now = target
        continue
    else:
        flag = False
        break

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

Solution (Python):
N=int(input())
t=0
x=0
y=0
for i in range(N):
    T=t
    X=x
    Y=y
    t,x,y=map(int,input().split())
    if abs(X-x)+abs(Y-y)>t-T:
        print("No")
        exit()
    elif (X+Y+T+x+y+t)%2!=0:
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
start = [0, 0, 0]
for _ in range(N):
    goal = list(map(int, input().split()))
    dif = abs(goal[1] - start[1]) + abs(goal[2] - start[2])
    time = goal[0] - start[0]
    if dif > time or (dif - time ) % 2 != 0:
        print("No")
        exit()

print("Yes")

Solution (Python):
n = int(input())
st, sx, sy = 0, 0, 0

is_reach = True

for i in range(0, n):
    gt, gx, gy = list(map(int, input().split()))
    t = gt - sy
    dist = abs(gx - sx) + abs(gy - sy)

    if not(t >= dist and (t - dist) % 2 == 0):
        is_reach = False
        break


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

Solution (Python):


def can_reach(a):
    c = 0
    n = [0, 0]
    for point in a:
        c = point[0] - c
        dis = abs(point[1] - n[0]) + abs(point[2] - n[1])
        if (dis > c) or ((c - dis) % 2 != 0):
            return False
        c = point[0]
        n[0] = point[1]
        n[1] = point[2]
    return True

def main():
    n = int(input())
    a = [ list(map(int, input().split())) for _ in range(n)]

    print('Yes' if can_reach(a) else 'No')

if __name__ == '__main__':
    main()

Solution (Python):


def can_reach(a):
    c = 0
    n = [0, 0]
    for point in a:
        c = point[0] - c
        dis = (point[1] - n[0]) + (point[2] - n[1])
        if (dis > c) or ((c - dis) % 2 != 0):
            return False
        c = point[0]
        n[0] = point[1]
        n[1] = point[2]
    return True

def main():
    n = int(input())
    a = [ list(map(int, input().split())) for _ in range(n)]

    print('Yes' if can_reach(a) else 'No')

if __name__ == '__main__':
    main()

Solution (Python):


def can_move(t0, x0, y0, t1, x1, y1):
    assert t1 > t0
    dist = abs(x0 - x1) + abs(y0 - y1)
    dt = t1 - t0
    if dist > dt:
        return False
    if (dist + dt) % 2 == 1:
        return False
    return True

n = int(input())
ts = [0]
xs = [0]
ys = [0]
for i in range(n):
    t, x, y = map(int, input().split())
    ts.append(t)
    xs.append(x)
    ys.append(y)

flag = True
for i in range(n):
    if not can_move(ts[i], xs[i], ys[i], ts[i + 1], xs[i + 1], ys[i + 1]):
        flag = False

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

Solution (Python):
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        quit()
print("Yes")

Solution (Python):
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        quit()
print("Yes")

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

for i in range(N):
    t1, x1, y1 = txys[i]
    t2, x2, y2 = txys[i+1]
    dt = t2 - t1
    dist = abs(x1 - x2) + abs(y1 - y2)
    if dt % 2 != dist % 2 or dist > dt:
        print("No")
        exit()
print("Yes")

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

for i in range(N):
    t1, x1, y1 = txys[i]
    t2, x2, y2 = txys[i+1]
    dt = t2 - t1
    tIsEven = dt % 2 == 0
    dist = abs(x1 - x2) + abs(y1 - y2)
    xyIsEven = dist % 2 == 0
    if tIsEven != xyIsEven or dist > dt:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    if x + y > t or (x + y + t) % 2 == 1: 
        print('No')
        exit()
print('Yes')

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

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

step = 0
start = (0, 0)
for g in goals:
    s = g[0] - step
    d = abs(g[1] - start[0]) + abs(g[2] - start[1])

    if s < d or s % 2 != d % 2:
        print('No')
        break

    step = g[0]
    start = (g[1], g[2])
else:
    print('Yes')

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(N):
    diff = abs(X[i + 1] - X[i]) + abs(Y[i + 1] - Y[i])
    if T[i + 1] - T[i] < diff:
        print("No")
        exit()

    if (diff - (T[i + 1] - T[i])) % 2 != 0:
        print("No")
        exit()

print("Yes")

Solution (Python):
def can_move(coord1, coord2):
    distance = abs(coord2[1] - coord1[1]) + abs(coord2[2] - coord1[2])
    time = coord2[0] - coord1[0]
    if distance > time:
        return False
    quotient, remainder = divmod(distance - time, 2)
    if remainder == 1:
        return False
    return True

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

flag = True
for i in range(N):
    flag = flag and can_move(coord[i], coord[i+1])

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

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

for i in range(N):
    a,b,c = map(int, input().split())
    t.append(a)
    x.append(b)
    y.append(c)
i = 0
flag = True
while i < N:
    time = t[i+1]-t[i]
    dis = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if time<dis:
        flag = False
        break
    elif (time%2 + dis%2) == 1:
            flag = False
            break
    i += 1

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

Solution (Python):
n = int(input())
x = [[int(i) for i in input().split()] for i in range(n)]
y = [x[0]]
for j in range(1,n):
	y.append([x[j][0]-x[j-1][0],abs(x[j][1]-x[j-1][1]),abs(x[j][2]-x[j-1][2])])
if all(k[0]>=k[1]+k[2] and k[0]%2==(k[1]+k[2])%2 for k in y): print("Yes")
else: print("No")

Solution (Python):
n = int(input(""))
data = [0]*n
t = [0]*n
x = [0]*n
y = [0]*n
flag = 0

for i in range(n):
    data[i] = input("")
    t[i] = int(data[i].split(" ")[0])
    x[i] = int(data[i].split(" ")[1])
    y[i] = int(data[i].split(" ")[2])

for i in range(n):
    if i == 0:
        if x[i]+y[i] > t[i] or (x[i]+y[i]-t[i])%2 != 0:
            print("No")
            flag = 1
            break
    else:
        if abs(x[i]-x[i-1])+abs(y[i]-y[i-1]) > t[i] or (x[i]+y[i]-t[i])%2 != 0:
            print("No")
            flag = 1
            break
if flag == 0:print("Yes")

Solution (Python):
n=int(input())
place=[0,0]
bf_t=0
flag=0
for _ in range(n):
    t,x,y=map(int, input().split(" "))
    if (abs(place[0]-x) + abs(place[1] - y)) > (t-bf_t):
        
        flag=1
        break
    elif (t-bf_t)%2 != ((place[0]+place[1]) - (x + y))%2:
        
        flag=1
        break
    place[0]=x
    place[1]=y
    bf_t=t

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

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

num=0
for i in range(N):
    t=a[i][0]
    x=a[i][1]
    y=a[i][2]
    if  x+y<=t and (x+y)%2==t%2:
        num+=0
    else:
        num+=1


if num==0:
    print('Yes')
else:
    print('No')

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

for i in range(n):
 tn, xn, yn = list(map(int, input().split()))
 if tn%2 != (xn+yn)%2: break
 if abs(x-xn)+abs(y-yn)>tn-t: break
 t, x, y = tn, xn, yn
 if i==n-1: ans="Yes"

print(ans)

Solution (Python):
n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
arr = [ [0, 0, 0] ] + arr
ans = "No"

for i in range(n):
 if arr[i][0]%2 != (arr[i][1]+arr[i][2])%2: break
 if abs(arr[i][1]-arr[i+1][1])+abs(arr[i][2]-arr[i+1][2])>arr[i+1][0]-arr[i][0]: break
 if i==n-1: ans="Yes"

print(ans)

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):
n = int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if(not((x+y)<=t and (x+y)%2 == t%2)):
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
t = [na() for _ in range(n)]
zahyo = [0,0]
pre = 0
flag = 1
for i in range(n):
    time = t[i][0] - pre
    dis = (t[i][1]+t[i][2]) - sum(zahyo)
    dis = abs(dis)
    if time >= dis and time%2 == dis%2:
        zahyo = [t[i][1], t[i][2]]
        pre = t[i][0]
    else:
        flag = 0
        break
if flag:
    print("Yes")
else:
    print("No")

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

t=x=y=0
judge=True
for i in range(N):
    in_t,in_x,in_y=map(int,input().split())
    dt=in_t-t
    dxy=abs(in_x-x)+abs(in_y-y)
    if dxy>dt or (dxy-dt)%2!=0: judge=False
    t=in_t
    x=in_x
    y=in_y

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

Solution (Python):
import sys
batch = 0
lines = 0
ans = []
for line in sys.stdin:
    if line == None or line == '\n':
        break
        
    cur = line.split(" ")
    if len(cur) == 1:
        lines = int(cur[0])
        batch = 0
        continue
    
    else:
        batch += 1
        if int(cur[0]) < int(cur[1]) + int(cur[2]):
            ans.append(0)
        elif (int(cur[0]) - int(cur[1]) - int(cur[2])) % 2 == 0:
            ans.append(1)
        else:
            ans.append(0)
        
        if batch == lines:
            prod = 1
            for n in ans:
                prod *= n
            if prod == 0:
                print("No")
            else:
                print("Yes")

Solution (Python):

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


def matchdist(x,y):
    dt = abs(x[0]-y[0])
    ds = abs(x[1]-y[1]) + abs(x[2]-y[2])
    if ds%2 == dt%2 and ds<=dt:
        return True
    else:
        return False
flag = False
for i in range(N):
    if matchdist(txy[i],txy[i+1]):
        continue
    else:
        print("No")
        flag = True
        break
if not flag:
    print("Yes")

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

x = 0
y = 0
t = 0
do = True
for i in range(0, n):
 z = raw_input().split(" ")
 nt = int(z[0])
 nx = int(z[1])
 ny = int(z[2])
 dt = nt - t
 dx = nx - x
 dy = ny - y
 t = nt
 x = nx
 y = ny
 
 if (abs(dx)+abs(dy))%2 != (dt)%2:
  do = False
  break
 if abs(dx)+abs(dy) > abs(dt):
  do = False
  break
if do:
 print "Yes"
else:
 print "No"

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

ts = [0]
xs = [0]
ys = [0]

for _ in range(N):
    t,x,y = [ int(a) for a in input().split() ]
    ts.append(t)
    xs.append(x)
    ys.append(y)

good = True
for i in range(N):

    dist = abs(xs[i]-xs[i+1])+abs(ys[i]-ys[i+1]) 
    time = ts[i+1]-ts[i]
    
    if dist%2 != time%2:
        good = False

    
    if dist > time:
        good = False

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

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

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

Solution (Python):
N = int(input())
t = x = y = 0
judge = True
for i in range(N):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dxy = abs(nx - x) + abs(ny - y)
    if dxy > dt or (dxy - dt) % 2 == 1: judge = False
    t = nt
    x = nx
    y = ny
print("Yes" if judge else "No")