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



Sample input:
2
3 1 2
6 1 1


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys                        
import copy                       
from collections import deque     
                                  
def get_read_func(fileobject):    
    if fileobject == None :       
        return raw_input          
    else:                         
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    now_t = 0
    now_x = 0
    now_y = 0
    is_ok_plan = True
    for i in range(N):
        input_raw = read_func().strip().split()
        [t, x, y] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        dist = abs(x - now_x) + abs(y - now_y)
        T = t - now_t
        if (dist <= T and dist % 2 == T % 2) == False:
            is_ok_plan = False
        now_t = t
        now_x = x
        now_y = y


    if is_ok_plan:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
check = [list(map(int, input().split())) for _ in range(n)]
prev = [0,0,0]
feasible = True

for point in check:
    time = point[0] - prev[0]
    dist = abs(point[1] - prev[1]) + abs(point[2] - prev[2])
    if time - dist < 0 or (time - dist) % 2:
        feasible = False
        break
    else:
        prev = point

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

Submission status: Accepted

Solution code:
N = int(input())
T,X,Y = 0,0,0
for n in range(N):
    t,x,y = map(int,input().split())
    if (x-X)+(y-Y) <= t-T and ((t-T)-(x-X)-(y-Y))%2 == 0:
        X = x
        Y = y
        T = t
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys

if __name__ == "__main__":
    N = int(input())
    plan = [list(map(int, input().split(' '))) for i in range(N)]
    for i in range(N):
        time = plan[i][0]
        if abs(plan[i][1]) > time or abs(plan[i][2]) > time:
            print('No')
            sys.exit()
        if abs(plan[i][1]) + abs(plan[i][2]) > time:
            print('No')
            sys.exit()
        if ((abs(plan[i][1]) + abs(plan[i][2])) % 2) != (time % 2):
            print('No')
            sys.exit()
    print('Yes')

Submission status: Accepted

Solution code:
import sys
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    tmp_t, tmp_x, tmp_y = map(int, input().split())
    t.append(tmp_t)
    x.append(tmp_x)
    y.append(tmp_y)

    
def go(t, d):
    if t == d:
        return True
    elif t > d:
        if (t - d) % 2 == 0:
            return True
        else:
            return False
    else:
        return False
        


for i in range(N):
    delta_t = t[i+1] - t[i]
    distance = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if go(delta_t, distance):
        continue
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
n = int(input())
t, x, y = 0, 0, 0
for i in range(n):
    t1, x1, y1 = [int(j) for j in input().split()]
    if t1 - t >= abs(x1 - x) + abs(y1 - y):
        if (t1 - t - abs(x1 - x) - abs(y1 - y)) % 2 == 1:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t, x, y = t1, x1, y1
print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
t = []
pos = []
pos.append((0, 0))
t.append(0)
for i in range(N):
    t_i, x_i, y_i = map(int, input().split())
    t.append(t_i)
    pos.append((x_i, y_i))

def isReachable(cur, dst, t):
    dist = abs(cur[0] - dst[0]) + abs(cur[1] - dst[1])
    if dist > t:
        return False
    if dist % 2 != t % 2:
        return False
    return True

reachable = True
for i in range(1, N + 1):
    cur = (pos[i - 1][0], pos[i - 1][1])
    dst = (pos[i][0], pos[i][1])
    t_i = t[i] - t[i - 1]
    if not isReachable(cur, dst, t_i):
        reachable = False
        break

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

Submission status: Accepted

Solution code:
def main():
     N = int(input())
     dic = {}
     for i in range(N):
         try:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
         except Exception:
             entry = list(map(int,input().split(" ")))
             dic[entry[0]] = [entry[1],entry[2]]
     f = False
     index = 0
     coordinate = [0,0]
     for j in dic.items():
             distance = abs(j[1][0]-coordinate[0])+abs(j[1][1]-coordinate[1])
             if j[0]-index>=distance and (j[0]-index)%2==distance%2:
                 continue
             else:
                 print('No')
                 exit()
     print('Yes')


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

t,x,y = 0,0,0
for _ in range(N):
  ti,xi,yi = map(int,input().split())

  dt = ti-t
  d = abs(xi-x)+abs(yi-y)
  if d > dt or (d-dt) % 2 != 0:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
txy = []
txy.append([0, 0, 0])
for i in range(N):
    txy.append(list(map(int, input().split())))
for i in range(N):
    if abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2]) > txy[i + 1][0] - txy[i][0]:
        print("No")
        break
    else:
        if (txy[i + 1][0] - txy[i][0] - abs(txy[i + 1][1] - txy[i][1]) + abs(txy[i + 1][2] - txy[i][2])) % 2 != 0:
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

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

prev = [0, 0, 0]
is_possible = "Yes"

for line in lines:
    pt, px, py = prev
    t, x, y = line
    dt = t - pt
    dx = x - px
    dy = y - py
    if dt < dx + dy:
        is_possible = "No"
        break

    if not dt & 1 == (dx + dy) & 1:
        is_possible = "No"
        break

    prev = line

print(is_possible)

Submission status: Accepted

Solution code:

N = int(input())

t, x, y = 0, 0, 0

def judge(t0, x0, y0, t1, x1, y1):
    t = t1- t0
    x = abs(x1- x0)
    y = abs(y1- y0)

    if t < x+y:
        return False
    if t%2 == (x+y)%2:
        return True
    else:
        return False


result = True
for i in range(N):
    t1, x1, y1 = list(map(int, input().split(" ")))
    result = result and judge(t, x, y, t1, x1 ,y1)
    t, x, y = t1, x1, y1

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

Submission status: Accepted

Solution code:
# encoding:utf-8

def checker(dx, dy, t):
	#print([dx, dy, t])
	if dx + dy <= t and abs(dx + dy - t) % 2 == 0:
		return True
	else:
		return False

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

	#print(checker(0, 1, 3))
	x, y, old_t = [0, 0, 0]
	for i in range(n):
		t, new_x, new_y = plans[i]
		if checker(abs(x - new_x), abs(y - new_y), t - old_t):
			x = new_x
			y = new_y
			old_t = t
		else:
			print("No")
			break
	else:
		print("Yes")


if __name__ == '__main__':
	main()

Submission status: Accepted

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

flag = True
position = [0, 0]
tc = 0
for n in range(N):
    pdiff = sum([x[n] - position[0], y[n] - position[1]])
    tdiff = t[n] - tc
    if tdiff < pdiff:
        flag = False
        break
    elif tdiff == pdiff:
        pass
    elif (pdiff - tdiff) % 2 != 0:
        flag = False
        break

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

Submission status: Accepted

Solution code:
N=int(input())
t_lst, x_lst, y_lst = [], [], []
for _ in range(N):
    buf = [int(_) for _ in input().split()]
    t_lst.append(buf[0])
    x_lst.append(buf[1])
    y_lst.append(buf[2])

t, x, y =0,  0, 0
isValid=True
for i in range(N):
    move = abs(x_lst[i] - x) + abs(y_lst[i] - y)
    step = t_lst[i] - t
    if move <= step and (step - move)%2 ==0:
            x = x_lst[i]
            y = y_lst[i]
            t = t_lst[i]
    else:
        isValid=False
        break
if isValid:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
cx,cy,ct = 0,0,0
for i in range(n):
    t,x,y = Is()
    dt,dd =  t-ct, abs(x-cx)+abs(y-cy)
    if dt < dd or (dt-dd)%2 != 0:
        print("No")
        exit()
    cx,cy,ct = x,y,t
print("Yes")

Submission status: Accepted

Solution code:
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)
        # print('mp',mp)
        # print('mt',mt)

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

Submission status: Accepted

Solution code:
#
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-      
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')

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
#!usr/bim/python
#! -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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())
        # print("{} {} {} -> {} {} {}".format(t, x, y, nt, nx, ny))
        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")

Submission status: Accepted

Solution code:
#python3
# utf-8

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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")

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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())
# 距離 + 2nが可能
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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')

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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"

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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()

Submission status: Runtime Error

Solution code:
N=input()
for i in range(int(input(N))):
  t, x, y = map(int, input().split())
  if (x + y + t) % 2 or (x + y) > t:
    print('No')
    exit(0)
print('Yes')

Submission status: Runtime Error

Solution code:
n = int(input())
ti = [0] * (n-1)
xi = [0] * (n-1)
yi = [0] * (n-1)

P = 'Yes'


for i in range(n):
    tii, xii, yii = map(int, input().split())
    ti.append(tii)
    xi.append(xii)
    yi.append(yii)
    tc = ti[i-1] - ti[i]
    #dest = abs(xi[i]-xi[i-1]) - abs(yi[i]-yi[i-1])
    #if tc == abs(dest): pass
    if (ti[i]-ti[i-1]) > (abs(xi[i]-xi[i-1]+abs(yi[i]-yi[i-1])) or (xi[i]+yi[i]+ti[i]-ti[i-1])%2: P = 'No'

print(P)

Submission status: Runtime Error

Solution code:
n = int(input())
ti = [0] * (n-1)
xi = [0] * (n-1)
yi = [0] * (n-1)

P = 'Yes'


for i in range(n):
    tii, xii, yii = map(int, input().split())
    ti.append(tii)
    xi.append(xii)
    yi.append(yii)
    tc = ti[i-1] - ti[i]
    #dest = abs(xi[i]-xi[i-1]) - abs(yi[i]-yi[i-1])
    #if tc == abs(dest): pass
    if (ti[i]-ti[i-1]) < (abs(xi[i]-xi[i-1]+abs(yi[i]-yi[i-1])) or (xi[i]+yi[i]+ti[i]-ti[i-1])%2: P = 'No'

print(P)

Submission status: Runtime Error

Solution code:
n = int(input())
ti = [0] * (n-1)
xi = [0] * (n-1)
yi = [0] * (n-1)

P = 'Yes'


for i in range(n):
    tii, xii, yii = map(int, input().split())
    ti.append(tii)
    xi.append(xii)
    yi.append(yii)
    tc = ti[i-1] - ti[i]
    #dest = abs(xi[i]-xi[i-1]) - abs(yi[i]-yi[i-1])
    #if tc == abs(dest): pass
    if ti[i] != (xi[i]+yi[i]) or (x[i]+yi[i]+ti[i]-ti[i-1])%2: P = 'No'

print(P)

Submission status: Runtime Error

Solution code:
n = int(input())
ti = [0] * (n-1)
xi = [0] * (n-1)
yi = [0] * (n-1)

P = 'Yes'


for i in range(n):
    tii, xii, yii = map(int, input().split())
    ti.append(tii)
    xi.append(xii)
    yi.append(yii)
    tc = ti[i-1] - ti[i]
    #dest = abs(xi[i]-xi[i-1]) - abs(yi[i]-yi[i-1])
    #if tc == abs(dest): pass
    if ti[i] == (xi[i]+yi[i]) or (x[i]+yi[i]+ti[i]-ti[i-1]): P = 'No'

print(P)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    sys.stdin = open("sample.txt")
    N = Scanner.int()
    T = Scanner.int_list_list(N)
    x, y, t = 0, 0, 0
    for i in T:
        len = abs(i[1] - x) + abs(i[2] - y)
        time = i[0] - t
        if len <= time and len % 2 == time % 2:
            t, x, y = i
        else:
            print("No")
            return
    print("Yes")
    return


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N = int(input())
t0, x0, y0 = map(int, input().split())
flag = True
if (x0+y0)%2 != t0%2 or x0+y0 > t0:
    flag = False
else:
    for _ in range(N-1):
        t1, x1, y1 = map(int, input().split())
        if (x1+y1-x0-y0)%2 != (t1-t0)%2 or (x1+y1-x0-y0) > t1-t0:
            flag = False
            brake
        else:
            t0, x0, y0 = t1, x1, y1
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N, K = map(int, input().split())
counts = [[0] * 2*K for _ in range(2*K)]

for _ in range(N):
  x, y, t = input().split()
  if t == 'B':
    x = int(x) + K
  counts[int(x)%(2*K)][int(y)%(2*K)] += 1
max_c = 0
for i in range(K):
  sum_c = 0
  for idx, row in enumerate(counts):
    if idx < i:
      sum_c += sum(row[K:])
    elif idx < i + K:
      sum_c += sum(row[:K])
    else:
      sum_c += sum(row[K:])
  max_c = max(max_c, sum_c)
  for j in range(K):
    minus = plus = 0
    for idx, row in enumerate(counts):
      if idx < i:
        minus += row[j+K]
        plus += row[j]
      elif idx < i + K:
        minus += row[j]
        plus += row[j+K]
      else:
        minus += row[j+K]
        plus += row[j]
    sum_c = sum_c-minus+plus
    max_c = max(max_c, sum_c)
print(max_c)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; cin >> N;
  
  vector<int> t(N+1, 0), x(N+1, 0), y(N+1, 0);
  for (int i = 1; i < N+1; i++) cin >> t[i] >> x[i] >> y[i];
  
  bool can = true;
  for (int i = 0; i < N; i++) {
    int dt = t[i+1]-t[i];
    int dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }
  
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Submission status: Runtime Error

Solution code:
import sys
n = int(input())
pt, px, py = 0, 0, 0
for _ in range(n):
    t, x, y = map(int,input().split())
    dt = abs(t-pt)
    dx = abs(x-px)
    dy = abs(y-py)
    if dt<dx+dy or dt%2!=(dx+dy)%2:
        print('No')
        sys.exit()    
    pt,px,py = t,x,y
print('Yes'

Submission status: Runtime Error

Solution code:
def get_arounds(target):
    return [(target[0] + x, target[1] + y) for x, y in ((1, 0), (0, 1), (-1, 0), (0, -1))]

def search_path(step, start, end, limit):
    if step == limit:
        return start == end

    return any([search_path(step + 1, a, end, limit) for a in get_arounds(start)])


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

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

    step = 0
    start = (0, 0)
    for p in path:
        goal = (p[1], p[2])
        if not search_path(step, start, goal, p[0]):
            print('No')
            break
        step = p[0]
        start = goal
    else:
        print('Yes')

Submission status: Runtime Error

Solution code:
N = int(input())
nx, ny = 0, 0
for i in range(N):
  t, x, y = list(map(int(input().split(" ")))
  if abs(nx - x) + abs(ny - y) != t:
  	print("No")
    return
  else:
  	nx, ny = x, y
print("Yes")