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

Solution (Python):
import sys
n=int(input())
tmp_t=0
dist=0
for i in range(n):
    a,b,c=map(int,input().split())
    if i==0:
        if (b+c)%2==0 and a%2==0 and a>=(b+c) or (b+c)%2!=0 and a%2!=0 and a>=(b+c):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
    else:
        if abs((dist-(b+c)))%2==0 and (a-tmp_t)%2==0 and (a-tmp_t)>=(dist-(b+c)) or abs((dist-(b+c)))%2!=0 and (a-tmp_t)%2!=0 and (a-tmp_t)>=(dist-(b+c)):
            tmp_t=a
            dist=b+c
        else:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
a = int(input())
t = 0
x = 0
y = 0
count = 0
for i in range(a):
    l = list(map(int,input().split(" ")))
    if (l[0] - t) >= (abs(l[1]-x) + abs(l[2]-y)):
        if ((abs(l[1]-x)+abs(l[2]-y)) - (l[0] - t)) % 2 == 0:
            count += 1
    t = l[0]
    x = l[1]
    y = l[2]
if count == a:
    print("Yes")
else:
    print("No")

Solution (Python):


if __name__ == "__main__":
    n = int(input())

    flag = 0
    t, x, y = 0, 0, 0
    for i in range(n):
        newt, newx, newy = map(int, input().split())

        dift, difx, dify = newt - t, abs(newx - x), abs(newy - y)

        val = difx + dify
        if val > dift:
            flag = 1
            print("No")
            break
        if val % 2 != dift % 2:
            flag = 1
            print("No")
            break

        t, x, y = newt, newx, newy

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

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

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

for i in range(n):
    min_distance = abs(lattice_point[i][1]-lattice_point[i+1][1]) + abs(lattice_point[i][2]-lattice_point[i+1][2])
    time_limit = lattice_point[i+1][0] - lattice_point[i][0]
    if  time_limit < min_distance or time_limit%2 != min_distance%2:
        print('No')
        break
    else:
        count += 1

if count == n:
    print('Yes')

Solution (Python):
t=[0]
x=[0]
y=[0]
N=int(input())
for i in range(N):
    a,b,c=list(map(int,input().split()))
    t.append(a)
    x.append(b)
    y.append(c)
    
def cal(x_0,x_1,y_0,y_1,t_0,t_1):
    dis=abs(x_1-x_0)+abs(y_1-y_0)
    T=t_1-t_0
    if(T>=dis and abs(T-dis)%2==0):
        return 1
    return 0

for i in range(N):
    if(cal(x[i],x[i+1],y[i],y[i+1],t[i],t[i+1])==0):
        print("No")
        break
else:
    print("Yes")

Solution (Python):

import math, sys

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

ans = "No"
x = y = 0
t_prev = 0
for ti, xi, yi in txy:
    dist = math.fabs(x - xi) + math.fabs(y - yi)
    if ti - t_prev < dist: break
    elif (ti - t_prev) % 2 != dist % 2: break
    else:
        x = xi
        y = yi
        t_prev = ti
else:
    ans = "Yes"

print(ans)

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

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.insert(0,[0,0,0])
c=0
for j in range(n):
  if l[j+1][0]-l[j][0]<abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]) or (l[j+1][0]-l[j][0]+abs(l[j+1][1]-l[j][1])+abs(l[j+1][2]-l[j][2]))%2==1:
    c=1
    break
if c==0:print('Yes')
else:print('No')

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

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

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

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

for i in range(1, N + 1):
    dis = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
    time = txy[i][0] - txy[i-1][0]
    if time < dis or (time - dis) % 2 != 0:
        print('No')
        break
else:
    print('Yes')

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

if a[0][0] < (a[0][1] + a[0][2]):
    print("No")
    sys.exit()
if a[0][0]%2 != (a[0][1]+a[0][2])%2:
    print("No")
    sys.exit()
if n==1 and a[0][0]%2 == (a[0][1]+a[0][2])%2:
    print("Yes")
    sys.exit()


for i in range(1, n):
    if (a[i][0] - a[i-1][0]) < (abs(a[i][1]-a[i-1][1]) + abs(a[i][2]-a[i-1][2])):
        print("No")
        sys.exit()
    if (a[i][0] - a[i-1][0])%2 != (abs(a[i][1]-a[i-1][1]) + abs(a[i][2]-a[i-1][2]))%2:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):

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

flag = False

for i in range(N):
    c = path[i]
    n = path[i+1]

    time_delta = n[0] - c[0]
    abs_distance = abs(n[1] - c[1]) + abs(n[2] - c[2])
    if abs_distance > time_delta:
        flag = True
        break
    else:
        if abs_distance%2 == 0 and time_delta%2 == 0:
            pass
        elif abs_distance%2 == 1 and time_delta%2 == 1:
            pass
        else:
            flag = True
            break

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

Solution (Python):
N=int(input())
T=[[int(j) for j in input().split()] for i in range(N)]
m=0
T.reverse()
T.append([0,0,0])
T.reverse()
for i in range(N):
    l_i=T[i][1]+T[i][2]
    l_iadd=T[i+1][1]+T[i+1][2]
    t_iadd_i=T[i+1][0]-T[i][0]
    l=t_iadd_i-l_iadd+l_i
    mod=l%2
    if l>=0:
        if mod==0:
            m+=1
        else:
            break
    else:
        break
if m==N:
    print("Yes")
else:
    print("No")

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

cnt = 0

for _ in range(n):
    t, x, y = map(int, input().split())
    if t%2!=0 and (x+y)%2!=0 and x+y<=t:
        cnt += 1
    elif t%2==0 and (x+y)%2==0 and x+y<=t:
        cnt += 1
    else:
        break

if cnt == n:
    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:
    print("No")
    exit()

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 != 0: 
                                          
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
atime,ax,ay = 0,0,0
for i in range(N):
    btime,bx,by = map(int,input().split(" "))
    distance = abs(bx-ax)+abs(by-ay)
    time = btime-atime
    if (time >= distance)and((time-distance)%2 == 0):
        ax = bx
        ay = by
        atime = btime
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
def traveling():
    n = int(input())
    t, x, y = [0], [0], [0]

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

    can = True

    for i in range(n):
        dt = t[i+1] -t[i]
        distance = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])

        if dt < distance or distance % 2 != dt % 2:
            can = False

    return "Yes" if can else "No"


if __name__ == '__main__':
    print(traveling())

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

for i in range(n):
    if i == 0:
        if not(-s[i][1] - s[i][0] <= s[i][2] <= -s[i][1] + s[i][0] and s[i][1] - s[i][0] <= s[i][2] <= s[i][1] + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(-s[i][1] + s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= -s[i][1] + s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])\
            and s[i][1] - s[i - 1][1] + s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i][1] - s[i - 1][1] + s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

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

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

for i in range(n):
    if i == 0:
        if not(0 - s[i][0] <= s[i][1] <= 0 + s[i][0]) or not(0 - s[i][0] <= s[i][2] <= 0 + s[i][0]):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()
    else:
        if not(s[i - 1][1] - (s[i][0] - s[i - 1][0]) <= s[i][1] <= s[i - 1][1] + (s[i][0] - s[i - 1][0])) or not(s[i - 1][2] - (s[i][0] - s[i - 1][0]) <= s[i][2] <= s[i - 1][2] + (s[i][0] - s[i - 1][0])):
            print("No")
            exit()
        else:
            if (s[i][0] % 2 == 0 and (s[i][1] + s[i][2]) % 2 != 0) or (s[i][0] % 2 != 0 and (s[i][1] + s[i][2]) % 2 == 0):
                print("No")
                exit()

print("Yes")

Solution (Python):
n = int(input())
t, x, y, ok = 0, 0, 0, True
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    dt = t2 - t
    delta = abs(x - x2) + abs(y - y2)
    if delta > dt:
        ok = False
    elif (delta - dt) % 2:
        ok = False
    t, x, y = t2, x2, y2
print("Yes" if ok else "No")

Solution (Python):
import sys

n=int(input())

b_t=0
b_x=0
b_y=0
for _ in range(n):
    t,x,y=map(int,input().split())
    tmp= ( t - b_t) - abs(x - b_x) - abs( y - b_y )
    if( tmp % 2 != 0 or tmp <0):
        print( "No" )
        sys.exit()
    b_t,b_x,b_y=t,x,y

print("Yes")

Solution (Python):
import copy

n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
s=copy.deepcopy(l)
l.insert(0,[0,0,0])
for i in range(1,n+1):
    s[i-1][0]=l[i][0]-l[i-1][0]
    s[i-1][1]=l[i][1]-l[i-1][1]
    s[i-1][2]=l[i][2]-l[i-1][2]
    
    if s[i-1][0]<abs(s[i-1][1])+abs(s[i-1][2]) or (s[i-1][0])%2!=(abs(s[i-1][1])+abs(s[i-1][2]))%2:
        print('No')
        break
else:
    print('Yes')

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

flag = True
t0 = x0 = y0 = 0
for i in range(N):
    t1, x1, y1 = map(int, input().split())
    t = t1 - t0
    x = x1 - x0
    y = y1 - y0
    if (abs(x) + abs(y)) == 0:
        if t % 2 == 0: pass
    elif t % (abs(x) + abs(y)) != 0:
        flag = False
    t0 = t1
    x0 = x1
    y0 = y1

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

Solution (Python):

import sys

def 解():
    def isNotValid(dt,dx,dy):
        iD = dx+dy
        if dt % 2 : 
            if iD % 2 and iD <= dt:
                return False
            else:
                return True
        else: 
            if iD % 2 == 0 and iD <= dt:
                return False
            else:
                return True
    iN = int(input())
    bt,bx,by =0, 0,0
    for t,x,y in [[int(_) for _ in sLine.split()] for sLine in  sys.stdin.readlines()]:
        if isNotValid(t-bt,abs(x-bx),abs(y-by)):
            print("No")
            exit()
        bt,bx,by = t, x,y
    print("Yes")
解()

Solution (Python):
import sys

def isValid(dt,dx,dy):
    iD = dx+dy
    if dt % 2 : 
        if iD % 2 and iD <= dt:
            return True
        else:
            return False
    else: 
        if iD % 2 == 0 and iD <= dt:
            return True
        else:
            return False
def 解():
    iN = int(input())
    bt,bx,by =0, 0,0
    for t,x,y in [[int(_) for _ in sLine.split()] for sLine in  sys.stdin.readlines()]:
        if not isValid(t-bt,x-bx,y-by):
            print("No")
            exit()
        bt,bx,by = t, x,y
    print("Yes")
解()

Solution (Python):
n = int(input())
t_c,x_c,y_c = 0,0,0

for i in range(n):
    t,x,y = map(int,input().split())
    dt, dx, dy = t-t_c, abs(x-x_c), abs(y-y_c)
    dd = dx + dy
    if dd > dt or dd % 2 != dt % 2:
        print('No')
        exit()
    else:
        t_c,x_c,y_c = t,x,y

print('Yes')

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

T=0
X=0
Y=0

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

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

tmpx = 0
tmpy = 0
tmpt = 0
for _ in range(n):
    (t, x, y) = map(int, input().split())
    dist = abs(tmpx - x) + abs(tmpy - y)
    splt = t - tmpt
    if splt < dist:
        print('No')
        sys.exit(0)
    if (splt - dist) % 2 != 0:
        print('No')
        sys.exit(0)
    tmpx = x
    tmpy = y
    tmpt = t
print('Yes')

Solution (Python):
N = int(input())
tt = 0
xx = 0
yy = 0
z = [list(map(int, input().split())) for _ in range(N)]
for i in range(N):
    t, x, y = z[i]
    dt = t - tt
    dx = abs(x - xx)
    dy = abs(y - yy)
    if dt < dx + dy or (dt - (dx + dy)) % 2:
        print('No')
        exit()
    tt = t
    xx = x
    yy = y
print('Yes')

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

t, x, y = [0]*N, [0]*N, [0]*N
t[0], x[0], y[0] = map(int, input().split())
if t[0] == x[0]+y[0] or ((-x[0]-y[0] + t[0]) > 0 and  (-x[0]-y[0] + t[0]) % 2 == 0):
    check = True
else:
    check = False
for i in range(1, N):
    tt, xx, yy = map(int, input().split())
    t[i], x[i], y[i] = tt-t[i-1] ,abs(xx-x[i-1]) , abs(yy-y[i-1])
    judge = -x[i]-y[i]+t[i]
    if judge < 0 or ( judge % 2 !=0 and judge > 0) or (x[i]==y[i]==0 and t[i]%2 !=0) :
        if t[i] != x[i]+y[i]:
            check = False
            break

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

Solution (Python):
N = int(input())
T,X,Y = [],[],[]
for i in range(N):
  t,x,y = map(int,input().split())
  T.append(t)
  X.append(x)
  Y.append(y)
if N == 1:
  trans_count = X[0] + Y[0]
  time = T[0]
  if (time - trans_count) % 2 == 0 and time - trans_count >= 0:
    print("Yes")
  else:
    print("No")
  exit()
for i in range(N-1):
  trans_count = abs(X[i+1] - X[i]) + abs(Y[i+1] - Y[i])
  time = T[i+1] - T[i]
  if (time - trans_count) % 2 != 0 or time - trans_count < 0:
    print("No")
    break
  elif i == N-2:
    print("Yes")

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

current, time = (0, 0), 0
for i in range(N):
    dist = abs(current[0] - I[i][1]) + abs(current[1] - I[i][2])
    if dist > I[i][0] - time or (I[i][0]- time - dist) % 2 == 1:
        print("No")
        break
    current, time = (I[i][1], I[i][2]), I[i][0]
else:
    print("Yes")

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

for i in range(1,len(t)):
    tmp = abs(x[i] - x[i - 1])+abs(y[i] - y[i - 1])
    if (tmp <= (t[i] - t[i - 1])) and ((t[i] - t[i - 1] + tmp) % 2 == 0):
        z = z
    else:
        z = 0

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

Solution (Python):


N = int(input())
a = [[0,0,0]]+[list(map(int,input().split())) for n in range(N)]


def check(a1,a2):
    l = abs(a1[1]-a2[1])+abs(a1[2]-a2[2])
    t = abs(a1[0]-a2[0])
    if l <= t and l%2 == t%2:
        return True
    return False

flag = True
for i in range(N):
    r = check(a[i],a[i+1])
    if r==False:
        flag = False
        break

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

Solution (Python):
import collections


def solve(N, ts, ps):
    for i in range(N):
        dt = ts[i+1] - ts[i]
        d = abs(ps[i+1].x - ps[i].x) + abs(ps[i+1].y - ps[i].y)

        if d > dt or dt % 2 != d % 2:
            return "No"
    return "Yes"


N = int(input())
point = collections.namedtuple('point', ['x', 'y'])
ts = [0]
ps = [point(0, 0)]
for i in range(N):
    t, x, y = list(map(int, input().split()))
    ts.append(t)
    ps.append(point(x, y))

print(solve(N, ts, ps))

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

for i in range(N):

    if i == len(point):
        break

    Np = point[i][0]
    xp = point[i][1]
    yp = point[i][2]

    Nn = point[i+1][0]
    xn = point[i+1][1]
    yn = point[i+1][2]

    dist = abs(xn-xp) + abs(yn-yp)

    if dist != Nn - Np:
        if dist > Nn - Np:
            print('No')
            exit()
        else:
            if dist % 2 != (Nn - Np) % 2:
                print('No')
                exit()

print('Yes')

Solution (Python):
n = int(input())
for _ 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())
t = []
x = []
y =[]
for i in range(N):
    data = input().split()
    data = [int(n) for n in data]
    t.append(data[0])
    x.append(data[1])
    y.append(data[2])

t_now = 0
x_now = 0
y_now = 0

flag_able = True
for i in range(N):
    t_sub = t[i] - t_now
    x_sub = abs(x[i] - x_now)
    y_sub = abs(y[i] - y_now)
    step_needed = x_sub + y_sub
    if(step_needed > t_sub):
        flag_able = False
    else:
        if((t_sub - step_needed)%2 == 1):
            flag_able = False
        else:
            flag_able = True
    if(flag_able == False):
        break

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

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

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

judge = []
for i in range(N):
    diff_t = t[i+1] - t[i]
    diff_x = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if diff_t >= diff_x and (diff_t - diff_x ) % 2 == 0:
        judge.append(True)
    else:
        judge.append(False)

if all(judge):
    print('Yes')
else:
    print('No')

Solution (Python):
def solve():
    n = int(input())
    ary = []
    for i in range(n):
        t,x,y = map(int, input().split(' '))
        ary.append([t,x,y])

    f = True
    for a in ary:
        time = a[0]
        distance = a[1] + a[2]
        max_distance = time
        if ( (time % 2) != (distance % 2) or distance > max_distance):
            print("No")
            f = False
            break
    if (f):
        print("Yes")
solve()

Solution (Python):


import sys

n = int(input())
pos = [[int(_) for _ in input().split()] for _ in range(n)]

x = 0
y = 0
t = 0

for i in pos:
    ti, xi, yi = map(int,i)
    
    dl = abs(xi-x)+abs(yi-y)
    dt = ti-t
    if (dl > dt or (dl-dt)%2 == 1):
        print('No')
        sys.exit()
    else:
        x = xi
        y = yi
        t = ti

print('Yes')

Solution (Python):

N = int(input())

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

tb,xb,yb = 0,0,0

for t,x,y in txy:
    ts = t - tb
    xs = abs(x - xb)
    ys = abs(y - yb)
    tb = t
    xb = x
    yb = y

    if ts < xs + ys:
        print('No')
        exit()

    if (ts - (xs + ys)) % 2 == 1:
        print('No')
        exit()

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



def main():
    n = int(input())
    ts, xs, ys = [0], [0], [0]

    for i in range(n):
        ti, xi, yi = map(int, input().split())
        ts.append(ti)
        xs.append(xi)
        ys.append(yi)

    for j in range(n):
        dt = ts[j + 1] - ts[j]
        dxy = (xs[j + 1] - xs[j]) + (ys[j + 1] - ys[j])

        if (-dt <= dxy <= dt) and (dt % 2 == dxy % 2):
            pass
        else:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):


import math

n = int(input())
a = [input().split() for i in range(n)]






def travelCheck(alpha, beta):
    timeDiff = int(beta[0]) - int(alpha[0])
    positionDiff = abs(int(beta[1]) - int(alpha[1])) + abs(int(beta[2]) - int(alpha[2]))
    flag = False
    if timeDiff >= positionDiff and (timeDiff%2 == positionDiff%2):
        flag = True
    return flag

start = ['0', '0', '0']





for i in a:
    flag = travelCheck(start, i)
    start = i

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

Solution (Python):
import sys

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

TXY=[[0,0,0]]+TXY

n=0
nx=0
ny=0

for t,x,y in TXY:
    
    if abs(x-nx)+abs(y-ny)<=t-n and (abs(x-nx)+abs(y-ny))%2==(t-n)%2:
        n,nx,ny=t,x,y
    else:
        print("No")
        sys.exit()


print("Yes")

Solution (Python):
N = int(input())
t0 = 0
x0 = 0
y0 = 0
flag = 0
for i in range(N) :
    t1,x1,y1 = map(int,input().split())
    t = t1-t0
    x = abs(x1-x0)
    y = abs(y1-y0)
    if x+y <= t and (t-(x+y))%2 == 0 :
        t0 = t1
        x0 = x1
        y0 = y1
    else :
        flag = 1
if flag == 0 :
    print("Yes")
else :
    print("No")

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

t0 = 0
x0 = 0
y0 = 0

for t, x, y in plan:
    if not (abs(x-x0) + abs(y-y0) <= (t-t0) and (t-t0)%2 == (abs(x-x0) + abs(y-y0))%2):
        print("No")
        exit()
    t0 = t
    x0 = x
    y0 = y

print("Yes")

Solution (Python):
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

txy = [(0,0,0)]
for _ in range(n):
    txy.append(tuple(li()))
 
exist = True

for i in range(n):
    tp,xp,yp = txy[i]
    tn,xn,yn = txy[i+1]
    
    dt = tn-tp
    dx = xn-xp
    dy = yn-yp
    
    if abs(dx) + abs(dy) > dt:
        exist = False
        break
    
    if (dx+dy)%2 != dt%2:
        exist = False
        break
    
if exist:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
c = [0,0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    time = t-c[0]
    coor = abs(c[1]-x)+abs(c[2]-y)
    if not (time>=coor and coor%2==time%2):
        print('No')
        exit()
    c = [t,x,y]
print('Yes')

Solution (Python):
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

nt = nx = ny = 0
for t,x,y in src:
    dist = abs(x-nx) + abs(y-ny)
    if t - nt < dist or (t-nt)%2 != dist%2:
        print('No')
        exit()
    nt,nx,ny = t,x,y
print('Yes')

Solution (Python):
N = int(input())
x_list = [0]
y_list = [0]
t_list = [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)

ans = 'Yes'

for i in range(N):
	t_d = t_list[i+1] - t_list[i]
	x_d = abs(x_list[i+1] - x_list[i])
	y_d = abs(y_list[i+1] - y_list[i])
	xy_d = x_d + y_d
	if xy_d > t_d:
		ans = 'No'
		break
	else:
		if xy_d % 2 != t_d % 2:
			ans = 'No'
			break
print(ans)

Solution (Python):
def mdist(a, b):
    return abs(a[0]-b[0]) + abs(a[1]-b[1])

n = int(input())
data = [[0, 0, 0]] + [[int(d) for d in input().split(' ')] for _ in range(n)]

for d1, d2 in zip(data[:-1], data[1:]):
    dt = d2[0] - d1[0]
    dist = mdist(d1[1:], d2[1:])
    if not ((dt >= dist) and ((dt%2)==(dist%2))):
        print('No')
        break
else:
    print('Yes')

Solution (Python):
fr=[0]*3
ans="Yes"
for i in range(int(input())):
 dest=list(map(int,input().split()))
 if (dest[0]-fr[0])<(dest[1]+dest[2]-fr[1]-fr[2])or(dest[0]-fr[0]+dest[1]+dest[2]-fr[1]-fr[2])%2!=0:
  ans="No"
  break
 fr[0],fr[1],fr[2]=dest[0],dest[1],dest[2]
print(ans)

Solution (Python):
n = int(input())
txy = [[int(i) for i in input().split()] for i in range(n)] 
txy.append([0,0,0])
txy.sort(key=lambda x:x[0])
ispossible="Yes"
for i in range(0,n):
    k = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])
    if (k-txy[i+1][0]+txy[i][0])%2 or k>txy[i+1][0]-txy[i][0]:
        ispossible="No"
print(ispossible)

Solution (Python):



n = int(input())

now = [0,0]
time = 0

flag = True

for i in range(n):
    t,x,y = map(int,input().split())
    if t-time >= abs((now[0]-x)+(now[1]-y)) and (t-time)%2==((now[0]-x)+(now[1]-y))%2:
        now = [x,y]
        time = t
    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):
    line = input().split()
    t.append(int(line[0]))
    x.append(int(line[1]))
    y.append(int(line[2]))

flag = True
for j in range(1,N+1):
    c = abs(x[j]-x[j-1])+abs(y[j]-y[j-1])
    tm = t[j]-t[j-1]
    if tm-c < 0 or (tm-c) % 2 != 0:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

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

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

frag = 1
for i in range(0,N):
	if ((t[i + 1] - t[i]) % 2) != (abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) % 2:
		frag = 0
	if abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) > t[i + 1] - t[i]:
		frag = 0

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

Solution (Python):
def delta_t(t):
    return abs(t[1] - t[0])

def mh_distance(x, y):
    return abs(x[1] - x[0]) + abs(y[1] - y[0])

def yes_no():
    for i in range(N):
        d_t = delta_t(t[i:i+2])
        mh_d = mh_distance(x[i:i+2], y[i:i+2])
        if (d_t < mh_d or d_t % 2 != mh_d % 2):
            return "No"
    return "Yes"

N, = map(int, input().split())
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(yes_no())

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
flag = True
for nt, nx, ny in txy:
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if (dt < dx + dy) or ((dx + dy) % 2 != dt % 2):
        flag = False
        break
    t = nt
    x = nx
    y = ny
if flag:
    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!=0:
        print("No")
        exit()
print("Yes")

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

for i in range(n):
    if i == 0:
        ti, xi, yi = 0, 0, 0
    else:
        ti, xi, yi = txy[i-1]
    tf,xf,yf = txy[i]
    dt = tf - ti
    dx = abs(xi-xf)
    dy = abs(yi-yf)

    if dt < dx + dy or (dt-(dx+dy))%2 != 0:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
t1, x1, y1 = 0, 0, 0

for i in range(n):
    t2, x2, y2 = [int(j) for j in input().split()]
    if not ((t2 - t1) % 2 == (abs(x2 - x1) + abs(y2 - y1)) % 2
            and (t2 - t1) >= abs(x2 - x1) + abs(y2 - y1)):
        print('No')
        break
    else:
        t1, x1, y1 = t2, x2, y2
else:
    print('Yes')

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

can = True

for i in range(0, 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 dt % 2 != dist % 2:
        can = False

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

Solution (Python):
import sys

n=int(input())

a=0
b=0

for i in range(n):
    ti,x,y=map(int,input().split())
    s=abs(x+y-b)
    t=ti-a
    if t>=s and (s-t)%2==0:
        a=ti
        b=x+y
    else:
        print("No")
        sys.exit()
    
print("Yes")

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

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

	for i in range(len(plan)-1):
		delta_t = plan[i+1][0] - plan[i][0]
		delta_x = plan[i+1][1] - plan[i][1]
		delta_y = plan[i+1][2] - plan[i][2]

		if (delta_t < (delta_x + delta_y)) or ((delta_t - (delta_x + delta_y)) % 2 != 0):
			print("No")
			return

	print("Yes")
	return

if __name__ == '__main__':
	main()

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

list_tr = []
list_tr.append([list_txy[0][0],abs(list_txy[0][1]) + abs(list_txy[0][2])])

for i in range(1, n):
    list_tr.append([list_txy[i][0] - list_txy[i-1][0], \
    abs(list_txy[i][1] - list_txy[i-1][1]) + abs(list_txy[i][2] - list_txy[i-1][2])])

for i in range(0,n):
    if list_tr[i][0] < list_tr[i][1]:
        ans = "No"
    else:
        if (list_tr[i][0] - list_tr[i][1]) % 2 != 0:
            ans = "No"
        else:
            ans ="Yes"
print(ans)

Solution (Python):
n= int(input())
 
index=0
flag=0
list2=[0,0,0]
while index<n:
    list =input().split()
    t = abs(int(list[0])-list2[0])
    x = abs(int(list[1])-list2[1])
    y = abs(int(list[2])-list2[2])
    if x+y == t and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    elif x+y<t and (x+y)%2==t%2 and flag ==0:
        answer="Yes"
        list2=[t,x,y]
    else:
        answer="No"
        list2 =[t,x,y]
        flag=1
    index+=1
print(answer)

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