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 solve():
    N = int(input())

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

    p_t = 0
    p_x = 0
    p_y = 0
    for n in range(N):
        t, x, y = L[n]

        mt = t - p_t
        
        mp = abs(x-p_x) + abs(y-p_y)
        
        

        if mp <= mt and ((mp - mt)%2 == 0):
            p_t = t
            p_x = x
            p_y = y
        else:
            print('No')
            return

    print('Yes')


if __name__ == "__main__":
    solve()

Solution (Python):

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


x = 0
y = 0
t = 0
for i in range(N):
    dx = abs(x - X[i])
    dy = abs(y - Y[i])
    dt = abs(t - T[i])

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


print('Yes')

Solution (Python):

import sys

n = int(input())
tprev = 0
tdiff = 0
pos = [0, 0]
for i in range(n):
    t, x, y = list(map(int,input().split()))
    tdiff = t - tprev
    if(tdiff>=abs(x-pos[0])+abs(y-pos[1])):
        if((tdiff-(abs(x-pos[0])+abs(y-pos[1])))%2 == 0):
            tprev = t
            pos = [x, y]
        else:
            print('No')
            sys.exit()
    else:
        print('No')
        sys.exit()
else:
    print('Yes')

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

t.append(0)
x.append(0)
y.append(0)

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

def solve():
    for i in range(1, n+1):
        kx = x[i] - x[i-1]
        ky = y[i] - y[i-1]
        dt = (t[i] - t[i-1]) - (kx + ky)

        if dt >= 0 and dt % 2 == 0:
            pass
        else:
            print("No")
            return
    print("Yes")

solve()

Solution (Python):



n = int(raw_input())
before = [0,0,0]
status = 0
for i in range(n):
    line = map(int,raw_input().split())
    if status == 1:
        pass
    else:
        kyori = abs(line[1]-before[1])+abs(line[2]-before[2])
        time = line[0]-before[0]
        if kyori>time:
            status = 1
        elif (time - kyori)%2 == 1:
            status = 1
        before = line

if status == 0:
    ans = "Yes"
else:
    ans = "No"

print ans

Solution (Python):
n = int(input())
cur_x = 0
cur_y = 0 
cur_t = 0
for i in range(n):
    t, x, y = [int(i) for i in input().split()]
    d_x = abs(x - cur_x)
    d_y = abs(y - cur_y)
    d_t = t - cur_t
    if d_x + d_y > d_t or (d_t - (d_x + d_y)) % 2 == 1:
        print('No')
        break 
    cur_t = t
    cur_x = x
    cur_y = y
else:
    print('Yes')

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

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

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

t_now = 0
p = (0,0)
ans = True

for i,z in enumerate(t):
    td = t[i] - t_now
    d = abs(p[0]-x[i]) + abs(p[1]-y[i])
    tmp = td - d
    if tmp >= 0 and tmp % 2 == 0:
        p = (x[i],y[i])
        t_now = t[i]
        continue
    else:
        ans = False
        break

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

Solution (Python):
def solve1(t, x, y):
    ax = abs(x)
    ay = abs(y)
    if ax > t:
        return False
    t -= ax
    ax = 0
    if ay > t:
        return False
    t -= ay
    ay = 0
    if t % 2 != 0:
        return False
    return True

def solve(txy):
    t, x, y = 0, 0, 0
    for e in txy:
        if not solve1(e[0] - t, e[1] - x, e[2] - y):
            return False
        t, x, y = e
    return True

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

if solve(txy):
    print("Yes")
else:
    print("No")

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

pt = 0
px = 0
py = 0
ans = 'Yes'
for t in range(N):
    t, x, y = map(int, input().split())

    diff = abs(x - px) + abs(y - py)
    if diff > t - pt or ((t - pt) - diff) % 2 == 1:
        ans = 'No'

    pt, px, py = t, x, y

print(ans)

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

def solve():
    N = int(input())
    t, x, y = 0, 0, 0
    for _ in range(N):
        nt, nx, ny = map(int, input().split())
        
        dt = nt - t
        if abs(nx - x) + abs(ny - y) > dt or \
           (abs(nx - x) + abs(ny - y) - dt) % 2 == 1:
            return False
        else:
            t, x, y = nt, nx, ny
    return True


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

Solution (Python):



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

t__x__y = sorted(t__x__y)
ct, cx, cy = (0, 0, 0)
for i in range(n):
    nt, nx, ny = t__x__y[i]
    dist = abs(cx - nx) + abs(cy - ny)
    time = nt - ct
    if dist > time:
        print('No')
        quit()
    if dist % 2 != time % 2:
        print('No')
        quit()

print('Yes')

Solution (Python):

def inpl(): return tuple(map(int, input().split()))
N = int(input())

t = 0
x, y = 0, 0

for _ in range(N):
    nt, nx, ny = inpl()
    d = abs(nx - x) + abs(ny - y)
    if d <= (nt-t) and (nt - t)%2 == d%2:
        t, x, y = nt, nx, ny
    else:
        print("No")
        break

else:
    print("Yes")

Solution (Python):
import sys
N = int(raw_input())
T = [0]
X = [0]
Y = [0]
for n in xrange(N):
    t, x, y = [int(val) for val in raw_input().split(" ")]
    T.append(t)
    X.append(x)
    Y.append(y)
for i in xrange(N):
    dt = T[i+1] - T[i]
    dx = X[i+1] - X[i]
    dy = Y[i+1] - Y[i]
    target = dt - abs(dx) - abs(dy)
    if (target%2==1) or (target<0):
        print "No"
        sys.exit()
print "Yes"

Solution (Python):
N = int(input())
t, x, y = 0, 0, 0
ok = True
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t_diff = ti - t
    xy_diff = abs(xi - x) + abs(yi - y)
    if t_diff < xy_diff:
        ok = False
        break
    if t_diff == xy_diff:
        continue
    if (t_diff - xy_diff) % 2 == 1:
        ok = False
        break
    t, x, y = ti, xi, yi


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

Solution (Python):
import sys


def main():
    n = int(input())
    t0 = x0 = y0 = 0
    for line in sys.stdin:
        t1, x1, y1 = map(int, line.split())
        dx = abs(x1 - x0) + abs(y1 - y0)
        dt = t1 - t0
        if dx > dt or dx % 2 != dt % 2:
            print('No')
            return
        t0, x0, y0 = t1, x1, y1
    print('Yes')


if __name__ == '__main__':
    main()

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

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

Solution (Python):
def LI(): return list(map(int, input().split()))
def LS(): return input().split()
def I(): return int(input())
def S(): return input()

n = I()
a = []
a.append([0,0,0])
for i in range(n):
    a.append(LI())

flag = 0
for i in range(n):
    t = a[i + 1][0] - a[i][0]
    l = abs(a[i][1] - a[i+1][1]) + abs(a[i][2] - a[i+1][2])
    if t >= l and (t-l)%2 == 0:
        continue
    flag = 1

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

Solution (Python):
def check(cx, cy, t, x, y):
    dx = abs(x - cx)
    dy = abs(y - cy)
    if dx + dy > t:
        return False
    if ((dx + dy) & 1) != (t & 1):
        return False
    return True


n = int(input())
ct, cx, cy = 0, 0, 0
for _ in range(n):
    t, x, y = map(int, input().split())
    result = check(cx, cy, t - ct, x, y)
    if not result:
        print('No')
        break
    ct, cx, cy = t, x, y
else:
    print('Yes')

Solution (Python):



def solve():
    x, y, t = 0, 0, 0
    for i in range(int(input())):
        tt, tx, ty = map(int, input().split())
        m = abs(x - tx) + abs(y - ty)
        if m > (tt - t):
            print("No")
            return
        if (m - (tt - t)) % 2 == 1:
            print("No")
            return
        x, y, t = tx, ty, tt
    print("Yes")

if __name__=="__main__":
    solve()

Solution (Python):
import sys


def f(t, x, y):
    d = t - (x+y)
    return d >= 0 and d % 2 == 0

N = int(sys.stdin.readline())
last_T = 0
last_X = 0
last_Y = 0
for _ in range(N):
    T, X, Y = map(int, sys.stdin.readline().split())
    if not f(T-last_T, X-last_X, Y-last_Y):
        print('No')
        sys.exit()
    last_T, last_X, last_Y = T, X, Y
print('Yes')

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

t = x = y = 0
for t2,x2,y2 in src:
    dt = t2 - t
    d = abs(x-x2) + abs(y-y2)
    if dt < d or dt%2 != d%2:
        print('No')
        exit()
    t,x,y = t2,x2,y2
print('Yes')

Solution (Python):
t, x, y = 0, 0, 0
ans = "Yes"
n = int(input())
for _ in range(n):
    ti, xi, yi = map(int, input().split())
    d = ti - t - abs(xi - x) - abs(yi - y)
    if d < 0 or d % 2 == 1:
        ans = "No"
    t, x , y = ti, xi, yi
print(ans)

Solution (Python):
n = int(input())
txy = [tuple(map(int, input().split())) for _ in range(n)]
t, x, y = 0, 0, 0
for ti, xi, yi in txy:
    dt = ti - t
    dd = abs(xi - x) + abs(yi - y)
    if dd > dt or (dd - dt) % 2 == 1:
        print('No')
        raise SystemExit
print('Yes')

Solution (Python):
N = int(input())
lx = 0
ly = 0
lt = 0
good = True
for i in range(N):
    t,x,y = map(int,input().split())
    xd = abs(lx-x)
    yd = abs(ly-y)
    td = t-lt
    if td<(xd+yd) or td%2!=(xd+yd)%2:
        good = False
    lt,lx,ly = t,x,y
print({True:"Yes",False:"No"}[good])

Solution (Python):

import heapq
import math
import sys

N = int(input())
t, x, y = 0, 0, 0
flag = True
for n in range(N):
    tmp = input()
    nt, nx, ny = [int(a) for a in tmp.split()]
    dt, dx, dy = nt - t, nx - x, ny - y
    d = abs(dx) + abs(dy)
    if d <= dt and d % 2 == dt % 2:
        continue
    else:
        flag = False
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)


def solve(N, l):
    nt, nx, ny = 0, 0, 0
    for i in range(len(l)):
        t, x, y = l[i]
        a = abs(x - nx) + abs(y - ny)
        k = t - nt
        if (k >= a and k % 2 == a % 2):
            pass
        else:
            return False
    return True


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


if __name__ == '__main__':
    main()

Solution (Python):
N = input()
pt,px,py = 0,0,0
for _ in range(N):
  t,x,y = map(int, raw_input().split())
  if abs(px-x)+abs(py-y)<=t-pt and (abs(px-x)+abs(py-y))%2==abs(t-pt)%2:
    pass
  else:
    print "No"
    exit(0)
  pt,px,py = t,x,y
print "Yes"

Solution (Python):
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()

(T, X, Y) = (0, 0, 0)

for i in range(N):
  (t, x, y) = reads()
  d = abs(X-x) + abs(Y-y)
  if d <= t - T and (t - T - d)%2 == 0:
    (T, X, Y) = (t, x, y)
    continue
  else:
    print("No")
    exit()

print("Yes")

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

Solution (Python):
n = int(input())
t, x, y = 0, 0, 0
for _ in range(n):
    nt, nx, ny = map(int, input().split())
    dt = nt - t
    dx = nx - x
    dy = ny - y
    if abs(dx) + abs(dy) <= dt and (abs(dx) + abs(dy)) % 2 == dt % 2:
        t, x, y = nt, nx, ny
    else:
        print("No")
        quit(0)
print("Yes")

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

x, y, t = 0, 0, 0
for i in range(n):
  t2, x2, y2 = map(int, input().split())
  d = abs(x-x2) + abs(y-y2)
  dt = t2 - t
  if d > dt or (dt - d) % 2 == 1:
    print("No")
    exit(0)
  x, y, t = x2, y2, t2

print("Yes")

Solution (Python):
def ng():
  print "No"
  exit()

def ok():
  print "Yes"
  exit()

  
n = input()
t, x, y = 0, 0, 0
for i in range(n):
  nt, nx, ny = map(int, raw_input().split())
  dist = abs(nx - x) + abs(ny - y)
  dt = nt - t
  if dist > dt or (dist - dt) % 2 != 0:
    ng()
  t,x,y = nt, nx, ny

ok()