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):
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())

    pt, px, py = 0, 0, 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        dt = t - pt
        dx = abs(x - px)
        dy = abs(y - py)
        dl = dx + dy

        if dt < dl or dl % 2 != dt % 2:
            print('No')
            return

        pt, px, py = t, x, y

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	if dist > d or dist % 2 != d % 2:
		print("No")
		exit()
else:
	print("Yes")

Solution (Python):
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	flag = False
	for t in range(d, -1, -2):
		if t == dist:
			flag = True
			break
	if flag == False:
		print("No")
		exit()
else:
	print("Yes")

Solution (Python):
n = int(input())
ans = "Yes"
now_x = 0
now_y = 0
now_t = 0

for i in range(n):
  t,x,y = map(int,input().split())
  
  if abs(now_x-x)+abs(now_y-y) > (t-now_t):
    ans = "No"
    break
    
  if (abs(now_x-x)+abs(now_y-y)-(t-now_t))%2 == 1:
    ans = "No"
    break
    
  now_x = x
  now_y = y
  now_t = t
    
print(ans)

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


data.insert(0, [0, 0, 0])
canTravel = True

for i in range(1, N+1):
    absT = abs(data[i][0] - data[i-1][0])
    absX = abs(data[i][1] - data[i-1][1])
    absY = abs(data[i][2] - data[i-1][2])

    distance = absX + absY
    if absT < distance or absT % 2 != distance % 2:
        canTravel = False
        break

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

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


data.insert(0, [0, 0, 0])
canTravel = True


def diff(nowData, oldData):
    absT = abs(nowData[0] - oldData[0])
    absX = abs(nowData[1] - oldData[1])
    absY = abs(nowData[2] - oldData[2])
    return [absT, absX, absY]


for index, d in enumerate(data):
    if index == 0:
        continue
    else:
        absT, absX, absY = diff(d, data[index - 1])
        distance = absX + absY
        if absT < distance or absT % 2 != distance % 2:
            canTravel = False
            break

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

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

def manhat_dis(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)

ans = "Yes"
t0, sx, sy = 0, 0, 0
for i in range(N):
    dis = manhat_dis(sx, sy, x[i], y[i])
    dt = t[i] - t0
    if dt < dis or (dis - dt) % 2:
        ans = "No"
        break
    t0, sx, sy = t[i], x[i], y[i]
print(ans)

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

flag = 0
for i in range(1,n+1):
    dt = t[i] - t[i-1]
    dx = x[i] - x[i-1]
    dy = y[i] - y[i-1]
    dist = abs(dx) + abs(dy)
    if dist > dt:
        flag = flag +1
    elif dist % 2 != dt % 2:
        flag = flag +1
else:
    print("Yes" if flag ==0 else "No")

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

for i in range(1,n+1):
    dt = t[i] - t[i-1]
    dx = x[i] - x[i-1]
    dy = y[i] - y[i-1]
    if abs(dx) + abs(dy) > dt or (dx+dy) % 2 != 0 and dt % 2 == 0 or (dx+dy) % 2 == 0 and dt % 2 != 0:
        break

else:
    print("Yes")
    exit()
print("No")

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

if N ==1:
  n = int(A[0][0])
  move = int(A[0][1]) + int(A[0][2]) 
  if move > n or move%2 != n%2:
    print("No")
  else:
    print("Yes")
  
for i in range(1,N):
  H = abs(int(A[i][1]) - int(A[i -1][1]))
  V = abs(int(A[i][2]) - int(A[i -1][2]))
  move = H + V
  n = int(A[i][0]) - int(A[i -1][0])
  if move > n or move%2 != n%2:
    print("No")
    break
  elif i == N -1:
    print("Yes")

Solution (Python):
before = 0, 0, 0
for _ in range(int(input())):
    tt, tx, ty = map(int, input().split())
    bt, bx, by = before
    distance = abs(tx - bx) + abs(ty - by)
    t = tt - bt
    if t < distance or t % 2 != distance % 2:
        break
    before = tt, tx, ty
else:
    print('Yes')
    exit()
print('No')

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

bt, bx, by = 0, 0, 0

for _ in range(N):
    t, x, y = map(int, input().split())
    dist = abs(x-bx)+abs(y-by)
    time = t-bt
    if time<dist or time%2!=dist%2:
        print('No')
        break
    bt, bx, by = t, x, y
else:
    print('Yes')

Solution (Python):
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Solution (Python):
N=int(input())
x=y=t=0
flag=True
for i in range(N):
  ti, xi, yi = map(int, input().split())
  dist = abs(xi-x)+abs(yi-y)
  dt = ti-t
  x, y, t = xi, yi, ti
  if dist<=dt and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Solution (Python):
import sys
from collections import Counter
from collections import deque
import math
import fractions
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[lmp() for i in range(n)]
if l[0][0]<l[0][1]+l[0][2] or l[0][0]%2!=(l[0][1]+l[0][2])%2:
    print("No")
    exit()
for i in range(n-1):
    t,x,y=l[i+1][0]-l[i][0],abs(l[i+1][1]-l[i][1]),abs(l[i+1][2]-l[i][2])
    if t<x+y or t%2!=(x+y)%2:
        print("No")
        exit()
print("Yes")

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

T=X=Y=0
ok = True
for t,x,y in txy:
  if abs(X-x)+abs(Y-y) <= t-T:
    if (t-T)%2 == 0:
      if (abs(X-x)+abs(Y-y))%2!=0:
        ok = False
        break
    else:
      if (abs(X-x)+abs(Y-y))%2==0:
        ok = False
        break
  else:
    ok = False
    break
  T,X,Y = t,x,y
print("Yes" if ok else "No")

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

  t = 0
  x = 0
  y = 0

  for p in plan:
    time = p[0] - t
    l = abs(x - p[1]) + abs(y - p[2])
    if l > time or l % 2 != time % 2:
      print('No')
      return
    t, x, y = p

  print('Yes')

  return

if __name__ == "__main__":
  resolve()

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

time = 0
now = [0, 0]
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x - now[0]) + abs(y - now[1])
    if d <= t - time and d % 2 == (t - time) % 2:
        time = t
        now = x, y
        continue
    else:
        print("No")
        exit()
else:
    print("Yes")

Solution (Python):
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N = int(input())
X = [list(map(int,input().split())) for _ in range(N)]
X.insert(0,[0,0,0])
flag = 0
for i in range(1,N+1):
    dx = dist(X[i][1:],X[i-1][1:])
    dt = X[i][0]-X[i-1][0]
    if dt>=dx and (dt-dx)%2==0:
        continue
    else:
        flag = 1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
T = 0
X = 0
Y = 0
ans = 'Yes'
for i in range(N):
  t, x, y = map(int, input().split())
  if abs(X-x)+abs(Y-y)>abs(T-t) or (((X-x)+(Y-y))-(T - t))%2==1:
    ans = 'No'
  else:
    T = t
    X = x
    Y = y
    
print(ans)

Solution (Python):
N = int(input())
ans = "Yes"
X = 0
Y = 0
T = 0
for _ in range(N):
    t,x,y = map(int, input().split())
    dt = t-T
    d = abs(X-x)+abs(Y-y)-dt
    if d > 0 or d%2 == 1:
        ans = "No"
    T = t
    X = x
    Y = y

print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    l.insert(0,[0,0,0])
    ans='Yes'
    for i in range(n):
        t=l[i+1][0]-l[i][0]
        x=abs(l[i+1][1]-l[i][1])
        y=abs(l[i+1][2]-l[i][2])
        if t<x+y or t%2!=(x+y)%2:
            ans='No'
            break
    print(ans)
resolve()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    XY = [list(map(int, input().split())) for _ in range(n)]
    px, py, pt = 0, 0, 0
    for i in range(n):
        t, x, y = XY[i]
        if abs(x - px) + abs(y - py) > abs(t - pt):
            print("No")
            break
        else:
            if (abs(x - px) + abs(y - py) - abs(t - pt)) % 2 != 0:
                print("No")
                break
            px, py, pt = x, y, t
    else:
        print("Yes")


if __name__ == '__main__':
    resolve()

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

    flag=True
    for i in range(n):
        if i==0:
            if t[i]==x[i]+y[i]:
                pass
            else:
                flag=False
                break
        else:
            a=t[i]-t[i-1]
            b=abs(x[i]-x[i-1])
            c=abs(y[i]-y[i-1])
            if a>=b+c and a%2==(b+c)%2:
                pass
            else:
                flag=False
                break

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

if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
txy = [list(map(int, input().split())) for _ in range(n)]
T=X=Y=0
ans = "Yes"

for t,x,y in txy:
  a = (t-T) - (abs(X-x) + abs(Y-y))
  if a % 2 == 0 and abs(X-x) + abs(Y-y) <= t - T:
    T,X,Y = t,x,y
  else:
    ans = "No"
    break
print(ans)

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

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

t = 0
x = 0
y = 0
for i in range(N):
  dt = L[i][0]-t
  nx = L[i][1]
  ny = L[i][2]
  dif = abs(x-nx)+abs(ny-y)
  
  if dif > dt or (dif-dt)%2 == 1:
    print("No")
    sys.exit()
  t += dt
  x = nx
  y = ny
print("Yes")

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

bt=0
bx=0
by=0
ans='Yes'
for i in range(n):
  t,x,y=map(int,input().split())
  dt=t-bt
  dx=abs(x-bx)
  dy=abs(y-by)

  if (dx+dy)>dt:
    ans='No'
  elif (dt-(dx+dy))%2==1:
    ans='No'

  bt=t
  bx=x
  by=y

print(ans)

Solution (Python):
n = int(input())
txy = []
for _ in range(n):
    t, x, y = map(int, input().split())
    txy.append((t, x, y))
px = py = pt = 0
for t, x, y in txy:
    m = abs(x-px)+abs(y-py)
    dt = t-pt
    if m>dt or (dt-m)%2==1:
        print('No')
        break
    px, py, pt = x, y, t
else:
    print('Yes')

Solution (Python):
def main():
    n = int(input())
    a = [list(map(int, input().split())) for i in range(n)]
    t, x, y = [0], [0], [0]
    t.extend([row[0] for row in a])
    x.extend([row[1] for row in a])
    y.extend([row[2] for row in a])
    flag = True
    for i in range(n):
        dt = t[i+1] - t[i]
        dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
        if dt < dist:
            print('No')
            flag = False
            break
        elif dt % 2 != dist % 2:
            print('No')
            flag = False
            break
    if flag == True:
        print('Yes')
if __name__ == '__main__':
    main()

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

t_list = [0]
x_list = [0]
y_list = [0]

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n+1):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    def check_possible_plan(query):
        prev_t, prev_x, prev_y = 0, 0, 0
        for t, x, y in query:
            diff_t = t - prev_t
            manhattan = abs(x - prev_x) + abs(y - prev_y)
            if diff_t < manhattan or (diff_t - manhattan) % 2 == 1:
                return False
            prev_t, prev_x, prev_y = t, x, y
        return True


    n = ii()
    query = [lmi() for _ in range(n)]
    print('Yes') if check_possible_plan(query) else print('No')



if __name__ == "__main__":
    main()

Solution (Python):
import sys
def main():
    n = int(input())
    txy = []
    for _ in range(n):
        txy.append(tuple(map(int, input().split())))

    t = x = y = 0
    for i1 in range(n):
        txye = txy[i1]
        t, dt = txye[0], txye[0] - t
        x, dx = txye[1], abs(txye[1] - x)
        y, dy = txye[2], abs(txye[2] - y)
        if dt < (dx + dy):
            print('No')
            sys.exit()
        elif dt > (dx + dy) and (dt - dx - dy) % 2 != 0:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
import sys
n=int(input())
px=0
py=0
pt=0
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(x-px)+abs(y-py)>t-pt or (abs(x-px)+abs(y-py))%2!=(t-pt)%2:
        print('No')
        sys.exit()
    else:
        px=x
        py=y
        pt=t
print('Yes')

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

x,y = 0,0
t = 0
for i in range(N):
    nx,ny = XY[i]
    nt = T[i]
    distance = abs(x-nx) + abs(y-ny)
    if distance <= nt - t and ((nt - t) - distance) %2 == 0:
        x,y = nx,ny
        t = nt
    else:
        print("No")
        exit()

print("Yes")

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

for _ in range(N):
    t, x, y = [int(i) for i in input().split()]
    T.append(t)
    X.append(x)
    Y.append(y)
for i in range(N):
    z = abs(X[i]-X[i+1])+abs(Y[i]-Y[i+1])
    if z & 1 == (T[i + 1] - T[i]) & 1 and z <= (T[i + 1] - T[i]):
        continue
    else:
        print("No")
        exit()
print("Yes")

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

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

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

Solution (Python):
n = int(input())
time = 0
point = [0,0]
for i in range(n):
    t,x,y = map(int,input().split())
    distance = abs(x-point[0]) + abs(y-point[1])
    dum_time = t-time
    if distance > dum_time:
        print("No")
        exit()
    elif distance%2 != dum_time%2:
        print("No")
        exit()
    time = t
    point[0] = x
    point[1] = y
print("Yes")

Solution (Python):
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A.insert(0,[0,0,0])
for i in range(len(A)-1):
    dt = A[i+1][0]-A[i][0]
    dist = abs(A[i+1][1]-A[i][1])+abs(A[i+1][2]-A[i][2])
    if dist>dt:
        print("No")
        quit()
    if dist%2!=dt%2:
        print("No")
        quit()
print("Yes")

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

count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
print("Yes" if count == N else "No")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        l=[list(map(int,input().split())) for i in range(n)]
        l.insert(0,[0,0,0])
        for j in range(n):
            t,x,y=l[j+1][0]-l[j][0],l[j+1][1]-l[j][1],l[j+1][2]-l[j][2]
            if t<(abs(x)+abs(y))or t%2!=(abs(x)+abs(y))%2:
                return 'No'
        return 'Yes'
    print(main())
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(input())
        l=[list(map(int,input().split())) for i in range(n)]
        l.insert(0,[0,0,0])
        for j in range(n):
            t,x,y=l[j+1][0]-l[j][0],l[j+1][1]-l[j][1],l[j+1][2]-l[j][2]
            if t<(abs(x)+abs(y)):
                return 'No'
            elif t%2!=(abs(x)+abs(y))%2:
                return 'No'
        return 'Yes'
    print(main())
resolve()

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

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")

Solution (Python):
N = int(input())
flag = 1
t1 = 0
x1 = 0
y1 = 0
for i in range(N):
  t2, x2, y2 = map(int, input().split())
  dt = t2-t1
  dx = abs(x2-x1)
  dy = abs(y2-y1)
  if dt<(dx+dy) or dt %2 != (dx+dy) % 2:
    flag = 0
    break
  t1 = t2
  x1 = x2
  y1 = y2
print("Yes" if flag else "No")

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

now = [0,0,0]
for i in range(n):
    s = list(map(int,input().split()))
    time = s[0] - now[0]
    dis = abs(s[1] - now[1]) + abs(s[2] - now[2])
    if time < dis or (time-dis)%2 == 1:
        print("No")
        exit()
    now = s

print("Yes")

Solution (Python):
N = int(input())
points = [tuple(map(int, input().split())) for _ in range(N)]
current_time = 0
current_x = 0
current_y = 0
for point in points:
    t, x, y = point
    diff_time = t - current_time
    diff_x = abs(x - current_x)
    diff_y = abs(y - current_y)
    if diff_x + diff_y > diff_time:
        print("No")
        break
    elif diff_x + diff_y < diff_time:
        remainder = diff_time - (diff_x + diff_y)
        if remainder % 2 == 1:
            print("No")
            break
    current_x = x
    current_y = y
    current_time = t
else:
    print("Yes")

Solution (Python):
n = int(input())
t=[0]
x=[0]
y=[0]
for i in range(n):
  t_inp,x_inp,y_inp=(int(x) for x in input().split())
  t.append(t_inp)
  x.append(x_inp)
  y.append(y_inp)
  
flag=True
for i in range(1,n+1):
  dt=t[i]-t[i-1]
  dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1])
  if dt<dist:
    flag=False
    break
  if dt%2 != dist%2:
    flag=False
    break
    
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([iarr() for i in range(n)])

txy = np.concatenate((np.zeros((1,3),int),txy))
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 1
for i in range(n):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

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

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n = iinput()
txy = np.array([iarr() for i in range(n)])
t,x,y = txy.T[0], txy.T[1], txy.T[2]

flag = 0 if t[0] < abs(x[0]) + abs(y[0]) else 1
for i in range(n-1):
    dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
    time = abs(t[i+1] - t[i])
    if time < dist: flag = 0; break
    if (time - dist)%2 == 1: flag = 0; break

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

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

for i in range(n):
  if txy[i+1][0] - txy[i][0] < abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]):
    print('No')
    exit()
  else:
    if (txy[i+1][0] - txy[i][0])%2 == 0 and (abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]))%2 != 0:
      print('No')
      exit()
    elif (txy[i+1][0] - txy[i][0])%2 != 0 and (abs(txy[i+1][1] - txy[i][1]) + abs(txy[i+1][2] - txy[i][2]))%2 == 0:
      print('No')
      exit()
      
print('Yes')

Solution (Python):
def solve(n, t_list):

    px = 0
    py = 0
    pt = 0
    ans = "Yes"
    for t, x, y in t_list:
        d = abs(x-px) + abs(y-py)
        dt = t - pt
        if (d %2  == dt % 2) and dt >= d:
            px = x
            py = y
            pt = t
        else:
            ans = "No"
            break

    return ans


if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n)]
    print(solve(n, t_list))

Solution (Python):
def solve(n, t_list):

    px = 0
    py = 0
    pt = 0
    ans = "Yes"
    for t, x, y in t_list:
        d = abs(x-px) + abs(y-py)
        dt = t - pt
        if ((d %2 == 0 and dt % 2 == 0) or (d % 2 == 1 and dt %2 == 1) )and dt >= d:
            px = x
            py = y
            pt = t
        else:
            ans = "No"
            break

    return ans


if __name__ == "__main__":
    n = int(input())
    t_list = [[int(j) for j in input().split()] for i in range(n)]
    print(solve(n, t_list))

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

pre = [0, 0, 0]
can = True
for i in range(N):
    dist = abs(plan[i][1] - pre[1]) + abs(plan[i][2] - pre[2])
    dt = plan[i][0] - pre[0]
    
    if dt < dist:
        can = False
    if dt % 2 != dist % 2:
        can = False
        break
    pre = plan[i]
        
if can:
    print("Yes")
else:
    print("No")

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

N = int(input())
x1,y1,t1 = 0,0,0
for _ in range(N):
    t2,x2,y2 = map(int, input().split())
    X, Y, T = abs(x2 - x1), abs(y2 - y1), t2 - t1
    if X + Y > T or (T - X - Y) % 2 == 1:
        print('No')
        exit()
    x1, y1, t1 = x2, y2, t2
print('Yes')

Solution (Python):

N = int(input())
T = []
for n in range(N):
    T.append([int(i) for i in input().split()])
now_t = 0
now_x = 0
now_y = 0
cnt=0
for t in T:
    if t[0]%2 !=(t[1]+t[2])%2:
        print('No')
        exit()
        
    if t[0] -now_t  >= abs(t[1]-now_x)+abs(t[2]-now_y):
        now_t = t[0]
        now_x = t[1]
        now_y = t[2]
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):

import sys
n = int(input())
t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

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

for i in range(n):
    length = abs((x[i+1]-x[i])+(y[i+1]-y[i]))
    move = t[i+1]-t[i]
    if move < length:
        print('No')
        sys.exit()
    if (move - length)%2==1:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
n = int(input())
bt, bx, by = 0, 0, 0
flag = True
for i in range(n):
    nt, nx, ny = map(int, input().split())
    dist = abs(nx - bx) + abs(ny - by)
    diff_t = nt - bt
    if diff_t < dist or (diff_t - dist) % 2:
        flag = False
    bt, bx, by = nt, nx, ny
print('Yes' if flag else 'No')

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    D = list(map(int, input().split()))
    dt = D[0] - t
    dx = D[1] - x
    dy = D[2] - y
    l = abs(dx) + abs(dy)
    if dt < l:
        print('No')
        exit()
    if dt % 2 != l % 2:
        print('No')
        exit()
    t, x, y = dt, dx, dy
print('Yes')

Solution (Python):









n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

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

    dist = abs(x-X) + abs(y-Y)
    dt = (t-T)

    
    if dist <= dt and dist%2 == dt%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")

Solution (Python):









n = int(input())

T = 0
X = 0
Y = 0

cnt = 0

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

    if abs(x-X) + abs(y-Y) <= (t-T) and (x+y)%2 == t%2:
        cnt += 1
    T,X,Y = t,x,y
print("Yes" if cnt == n else "No")

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

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



t_cur=0
x_cur=0
y_cur=0

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

for i in range(N):
  t_gap=t[i]-t_cur
  x_gap=abs(x[i]-x_cur)
  y_gap=abs(y[i]-y_cur)

  dist=x_gap+y_gap




  if (t_gap-dist)>=0 and (t_gap-dist)%2==0:
    t_cur=t[i]
    x_cur=x[i]
    y_cur=y[i]
  else:
    print("No")
    exit()
print("Yes")

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())
pt, px, py = 0, 0, 0

for i in range (N):
    t, x, y = map(int, input().split())
    dt = abs(t - pt)
    dxy = abs(x-px+y-py)
    if dxy > dt or (dxy - dt)%2:
        print("No")
        exit()
    pt, px, py = t, x, y
print("Yes")

Solution (Python):
n = int(input())
a,b,c=0,0,0
for i in range(n):
    t,x,y = map(int, input().split())
    sa = t-a
    if sa<abs(x-b)+abs(y-c):
        print("No")
        exit()
    else:
        tw = sa-abs(x-b)-abs(y-c)
        if tw%2!=0:
            print("No")
            exit()
    a,b,c=t,x,y
print("Yes")

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

Solution (Python):
N=int(input())
import sys
l=[list(map(int,input().split())) for i in range(N)]
if l[0][0] != l[0][1] + l[0][2]:
   print("No")
   exit()
for i in range(N-1):
   if abs(l[i][0]-l[i+1][0]) >= abs(l[i][1]-l[i+1][1])+abs(l[i][2]-l[i+1][2]):
      if (abs(l[i][0]-l[i+1][0])-abs(l[i][1]-l[i+1][1])-abs(l[i][2]-l[i+1][2]))%2==0:
         pass
      else:
         print("No")
         exit()
   else:
      print("No")
      exit()
print("Yes")