CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
lst = [int(i) for i in input().split()]
for i in range(n):
    s1=0
    for j in range(i):
        s1+=lst[j]
    s2=sum(lst)-s1
    if i==0:
        ans=abs(s1-s2)
    elif abs(s1-s2)<ans:
        ans=abs(s1-s2)
print(ans)

# Optimized solution
n = int(eval(input()))
lst = list(map(int,input().split()))
ans = 10**9
for i in range(n-1):
    ans = min(ans,abs(sum(lst[:i+1])-sum(lst[i+1:])))
print(ans)
# Original solution
# coding: utf-8
# Your code here!
N = int(eval(input()))
W = list(map(int,input().split()))
S = sum(W)
ans = float('inf')
for i in range(1,N):
    l = sum(W[:i+1])
    r = S - l
    ans = min(ans, abs(l-r))

print(ans)

# Optimized solution
# coding: utf-8
# Your code here!
N = int(eval(input()))
W = list(map(int,input().split()))
S = sum(W)
ans = float('inf')
for i in range(N):
    l = sum(W[:i+1])
    r = S - l
    ans = min(ans, abs(l-r))

print(ans)
# Original solution
# -*- coding: utf-8 -*-
n=int(eval(input()))
W=list(map(int,input().split()))
t=0
while sum(W[:t])<sum(W[t:]) and t<n:
  t=t+1
print((min(abs(sum(W[:t])-sum(W[t:])),abs(sum(W[:t-1])-sum(W[t-1:])))))

# Optimized solution
# -*- coding: utf-8 -*-
n=int(eval(input()))
W=list(map(int,input().split()))
for i in range(n):
    if sum(W[:i])>sum(W[i:]) or i==n-1:
        print((min(sum(W[i-1:])-sum(W[:i-1]),sum(W[:i])-sum(W[i:]))))
        break
# Original solution
from itertools import accumulate

N = int(eval(input()))
W = list(accumulate([int(x) for x in input().split()]))

ans = 10**9
for i in range(N - 1):
    ans = min(ans, abs(W[N - 1] - W[i]*2))
print(ans)

# Optimized solution
N = int(eval(input()))
W = [int(x) for x in input().split()]
s1 = 0
s2 = sum(W)

ans = 10**9
for w in W:
    s1 += w
    s2 -= w
    ans = min(ans, abs(s1 -s2))

print(ans)
# Original solution
from collections import deque

n = int(eval(input()))
w = list(map(int,input().split()))

d = deque(w)

s1 = d.popleft()
s2 = d.pop()

for _ in range(n-2):
	if s1 < s2:
		s1 += d.popleft()
	else:
		s2 += d.pop()

print((abs(s1 - s2)))


# Optimized solution
n = int(eval(input()))
w = list(map(int,input().split()))

ans = []
for i in range(1,n):
    ans.append(abs(sum(w[:i])-sum(w[i:])))

print((min(ans)))
# Original solution
N = int(eval(input()))
W = list(map(int, input().split()))
ans = float('inf')

for T in range(1, N):
    ans = min(ans, abs(sum(W[T:])-sum(W[:T])))
print(ans)

# Optimized solution
n = int(eval(input()))
W = list(map(int, input().split()))
ans = float('inf')
for T in range(1, n):
    ans = min(ans, abs(sum(W[:T])-sum(W[T:])))
print(ans)
# Original solution
n = int(eval(input()))
w = list(map(int, input().split()))
 
min_diff = 1000
for i in range(n):
	diff = abs(sum(w[0:i]) - sum(w[i:]))
	if diff < min_diff:
		min_diff = diff
print(min_diff)

# Optimized solution
N = int(eval(input()))
W = list(map(int, input().split()))
 
ans = 1000
for i in range(N):
    mi = abs(sum(W[0:i]) - sum(W[i:]))
    if mi < ans:
        ans = mi
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int, list(input().split())))

s = sum(l)
temp = 0
if n == 2:
    print((abs(l[-1] - l[0])))
    exit(0)

for i in range(n):
    if temp >= s - temp:
        print((
            min(abs(2*temp-s), abs(2*(temp-l[i-1])-s))
        ))
        exit(0)
    temp += l[i]

print((abs(2*l[-1]-s)))


# Optimized solution
l=int(eval(input()))
b=[int(i) for i in input().split()]
print((sorted(abs(sum(b[i:])-sum(b[:i])) for i in range(0,l))[0]))
# Original solution
n = int(eval(input()))
x = list(map(int, input().split()))
left = 0
right = 0
for i in x:
    right += i
reco = []
i = 0
while right > left:
    left += x[i]
    right -= x[i]
    i += 1
    reco.append(right - left)
reco[-1] = 0-reco[-1]
print((min(reco)))


# Optimized solution
n = int(eval(input()))
x = list(map(int, input().split()))
left = 0
right = 0
for i in x:
    right += i
reco = 0
i = 0
while right > left:
    left += x[i]
    right -= x[i]
    i += 1
    if right <= left:
        print((min(reco, 0-(right - left))))
        break
    else:
        reco = right - left
# Original solution
N = int(eval(input()))
W = list(map(int, input().split()))

ttl = sum(W)
s = []
min = ttl

for i in range(len(W)):
    s.append(W[i])
    s2 = ttl - sum(s)
    if abs(sum(s) - s2) < min:
        min = abs(sum(s) - s2)
        
print(min)

# Optimized solution
N = int(eval(input()))
W = list(map(int, input().split()))

ttl = sum(W)

for i in range(len(W)):
    ttl = min(ttl, abs(sum(W[:i]) - sum(W[i:])))

print(ttl)
# Original solution
n=int(eval(input()))
a=[int(x) for x in input().split()]

b=10000
for i in range(n):
  c=(sum(a[:i+1])-sum(a[i+1:]))**2
  if c<b:
    b=c
print((int(b**0.5)))

# Optimized solution
n=int(eval(input()))
a=[int(x) for x in input().split()]

b=100
for i in range(1,n):
  c=abs(sum(a[:i])-sum(a[i:]))
  if c<b:
    b=c
print(b)
# Original solution
from itertools import accumulate
n = int(eval(input()))
w_lst = list(map(int,input().split()))
wa = [0] + list(accumulate(w_lst))
ans = wa[-1]

for i in range(len(wa)-1):
    sa = abs((wa[-1] - wa[i]) - wa[i])
    if sa < ans:
        ans = sa

print(ans)

# Optimized solution
n = int(eval(input()))
w_lst = list(map(int,input().split()))

ans = float("inf")

for i in range(len(w_lst)):
    if abs(sum(w_lst[0:i]) - sum(w_lst[i:])) < ans:
        ans = abs(sum(w_lst[0:i]) - sum(w_lst[i:])) 

print(ans)
# Original solution
N = int(eval(input()))
W = [int(i) for i in input().split()]

A = sum(W)
ans = float('inf')
for i in range(N):
    tmp = abs(sum(W[: i]) - (A - sum(W[: i])))
    ans = min(ans, tmp)
    
print(ans)

# Optimized solution
n = int(eval(input()))
W = list(map(int, input().split()))

diff = float('inf')
for i in range(1, n):
    x = abs(sum(W[: i]) - sum(W[i :]))
    if x < diff:
        diff = x
        
print(diff)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]

ret = 1000
for i in range(1, n):
    s = abs(sum(a[:i]) - sum(a[i:]))
    if s < ret:
        ret = s
print(ret)

# Optimized solution
from sys import stdin
n = int(eval(input()))
a = [int(i) for i in stdin.readline().rstrip().split()]

ret = 1000
for i in range(1, n):
    s = abs(sum(a[:i]) - sum(a[i:]))
    if s < ret:
        ret = s
print(ret)
# Original solution
n = int(eval(input()))
w = list(map(int, input().split()))

s1 = 0
s2 = 0
ref = sum(w)

for i in range(n - 1):
    s1 = sum(w[0: i + 1])
    s2 = sum(w[i + 1: n])
    diff = abs(s1 - s2)
    if diff <=  ref:
        ref = diff

print(ref)

# Optimized solution
n = int(eval(input()))
w = list(map(int, input().split()))

s1 = w[0]
s2 = w[n - 1]
c1 = 1
c2 = 1

ref = sum(w)

for i in range(n - 2):
    if abs(s1 + w[c1] - s2) >= abs(s1 - (s2 + w[n - 1 - c2])):
        s2 = s2 + w[n - 1 - c2]
        c2 = c2 + 1
    else:
        s1 = s1 + w[c1]
        c1 = c1 + 1

print((abs(s1 - s2)))
# Original solution
n = int(eval(input()))
t0, x0, y0 = 0, 0, 0

for i in range(n):
  ti, xi, yi = list(map(int, input().split()))
  test = (ti - t0) - (xi + yi - x0 - y0)
  
  if test >= 0 and test % 2 == 0:
    t0, x0, y0 = ti, xi, yi
    if i == n-1:
      print("Yes")
  else:
    print("No")
    break

# Optimized solution
#高速化
import sys
input_ = sys.stdin.readline

n = int(input_())
t0, x0, y0 = 0, 0, 0

for i in range(n):
  ti, xi, yi = list(map(int, input_().split()))
  test = (ti - t0) - (xi + yi - x0 - y0)
  
  if test >= 0 and test % 2 == 0:
    t0, x0, y0 = ti, xi, yi
    if i == n-1:
      print("Yes")
  else:
    print("No")
    break
# Original solution
n=int(eval(input()));t,x,y,r1,r2=[],[],[],0,0
for _ in range(n):
  a,b,c=list(map(int,input().split()))
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')

# Optimized solution
n=int(eval(input()));t,x,y=[],[],[]
for _ in range(n):
  a,b,c=list(map(int,input().split()))
  t.append(a);x.append(b),y.append(c)
for i in range(n):
  r1,r2=[[t[0],x[0]+y[0]],[t[i]-t[i-1],abs(x[i]-x[i-1])+abs(y[i]-y[i-1])]][i!=0]
  if not (r1>=r2 and r1%2==r2%2): print('No');break
else:
  print('Yes')
# Original solution
N = int(eval(input()))

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

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

good = True
for i in range(N):

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

    # Distance
    if dist > time:
        good = False

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


# Optimized solution
n = int(input())

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

pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = list(map(int, input().split()))
  if (((t-pre_t) - (abs(x-pre_x) + abs(y-pre_y))) < 0
      or ((t-pre_t) - (abs(x-pre_x) + abs(y-pre_y))) % 2 != 0):
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")

# Optimized solution
n = int(eval(input()))
pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = list(map(int, input().split()))
  if (((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) < 0
      or ((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) % 2 != 0):
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")
# Original solution
n = int(eval(input()))
pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = list(map(int, input().split()))
  if (((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) < 0
      or ((t-pre_t) - abs(x-pre_x) - abs(y-pre_y)) % 2 != 0):
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")

# Optimized solution
n = int(eval(input()))
pre_t, pre_x, pre_y = [0, 0, 0]
ok = True
for i in range(n):
  t, x, y = list(map(int, input().split()))
  d = (t-pre_t) - abs(x-pre_x) - abs(y-pre_y)
  if d < 0 or d % 2 != 0:
    ok = False
    break
  pre_t, pre_x, pre_y = [t, x, y]
  
if ok:
  print("Yes")
else:
  print("No")
# Original solution
n=int(eval(input()))
A=[]
for i in range(n):
  a,b,c=list(map(int,input().split()))
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append([a,b,c])
if n==1:
  print("Yes")
  exit()
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")


# Optimized solution
n=int(eval(input()))
A=[]
for i in range(n):
  a,b,c=list(map(int,input().split()))
  if a<b+c or (b+c)%2!=a%2:
    print("No")
    exit()
  A.append([a,b,c])
for i in range(n-1):
  if not A[i+1][0]-A[i][0]>=A[i+1][2]+A[i+1][1]-A[i][1]-A[i][2]:
    print("No")
    exit()
print("Yes")
# Original solution
N = int(eval(input()))
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = list(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
if count==N:
    print('Yes')
else:
    print('No')

# Optimized solution
N = int(eval(input()))
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        quit()
print("Yes")
# Original solution
N = int(eval(input()))
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        quit()
print("Yes")

# Optimized solution
N = int(eval(input()))
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        exit()
print("Yes")
# Original solution
n=int(eval(input()))
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=list(map(int,input().split()))
    if abs(x-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print(('{}'.format(a)))

# Optimized solution
N = int(eval(input()))
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x + y > t or (t + x + y)%2 != 0:
        print("No")
        exit()
print("Yes")
# Original solution
import sys
N = int(eval(input()))

for i in range(N):
	t, x, y = list(map(int, input().split(" ")))
	if x > 0 and t >= x:
		t = t - x
		x = 0
		for j in range(t):
			if y >= 0:
				y -=1               
			else:
				y +=1
	elif x < 0 and t >= x * (-1):
		t = t -(-1 * x)
		x = 0      
		for j in range(t):
			if y >= 0:
				y -=1               
			else:
				y +=1
	else:
		for j in range(t):
			if y >= 0:
				y -=1               
			else:
				y +=1
	if x != 0 or y !=0:
		print("No")
		sys.exit()
print("Yes")

# Optimized solution
import sys
N = int(eval(input()))

for i in range(N):
	t, x, y = list(map(int, input().split(" ")))
	t = t - x - y
	if t % 2 != 0 or t < 0:
		print("No")
		sys.exit()

print("Yes")
# Original solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = list(map(int, input().split()))
    for a in range(t - pre_t + 1):
        for b in range(t - pre_t + 1 - a):
            if pre_x + a - b == x:
                for c in range(t - pre_t + 1  - a - b):
                    d = t - pre_t - a - b - c
                    if pre_y + c - d == y:
                        count += 1
                        flag = True
                        break
            if flag:
                break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

# Optimized solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = list(map(int, input().split()))
    for a in range(t - pre_t + 1):
        b = pre_x - x + a
        if b >= 0:
            for c in range(t - pre_t + 1  - a - b):
                d = t - pre_t - a - b - c
                if pre_y + c - d == y:
                    count += 1
                    flag = True
                    break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")
# Original solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    flag = False
    t, x, y = list(map(int, input().split()))
    for a in range(t - pre_t + 1):
        b = pre_x - x + a
        if b >= 0:
            for c in range(t - pre_t + 1  - a - b):
                d = t - pre_t - a - b - c
                if pre_y + c - d == y:
                    count += 1
                    flag = True
                    break
        if flag:
            break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")

# Optimized solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")
# Original solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    else:
      print("No")
      break
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")

# Optimized solution
N = int(eval(input()))
pre_t = 0
pre_x = 0
pre_y = 0
count = 0
for _ in range(N):
    t, x, y = list(map(int, input().split()))
    if x > pre_x:
        a = x - pre_x
        b = 0
    else:
        b = pre_x - x
        a = 0
    if y > pre_y:
        c = y - pre_y
        d = 0
    else:
        d = pre_y - y
        c = 0
    total = a+b+c+d
    if t - pre_t >= total and (t - pre_t - total) % 2 == 0:
        count += 1
    pre_t = t
    pre_x = x
    pre_y = y
if count == N:
    print("Yes")
else:
    print("No")
# Original solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        n=int(eval(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()

# Optimized solution
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(eval(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()
# Original solution
n = int(eval(input()))
t = 0
res = True
x, y = 0, 0
for i in range(n):
    t2, x2, y2 = list(map(int, input().split()))
    dt = t2 - t
    #print("cur {0} {1} {2}".format(t, x, y))
    #print("d {0} {1} {2}".format(dt, x2, y2))
    #print("ju {0} {1} {2} {3}".format(abs(x-x2) + abs(y-y2), dt, (abs(x-x2) + abs(y-y2) - dt) % 2, 1))

    if abs(x-x2) + abs(y-y2) > dt or (abs(x-x2) + abs(y-y2) - dt) % 2 == 1:
        res = False
    t, x, y = t2, x2, y2
print(("Yes" if res else "No"))

# Optimized solution
n = int(eval(input()))
pt = 0
px, py = 0, 0
f = True
for i in range(n):
    t, x, y = list(map(int, input().split()))
    dis = abs(px-x) + abs(py-y)
    dt = t - pt
    #print("dis{0} dt = {1}".format(dis, dt))
    if dt >= dis and abs(dis - dt) % 2 == 0:
        pass
    else:
        f = False
    pt, px, py = t, x, y
print(("Yes" if f else "No"))
# Original solution
n = int(eval(input()))
pt = 0
px, py = 0, 0
f = True
for i in range(n):
    t, x, y = list(map(int, input().split()))
    dis = abs(px-x) + abs(py-y)
    dt = t - pt
    #print("dis{0} dt = {1}".format(dis, dt))
    if dt >= dis and abs(dis - dt) % 2 == 0:
        pass
    else:
        f = False
    pt, px, py = t, x, y
print(("Yes" if f else "No"))


# Optimized solution
n = int(eval(input()))
can = True
time = 0
x = 0
y = 0
for _ in range(n):
    t, xx, yy = list(map(int,input().split()))
    distance = abs(x-xx) + abs(y - yy)
    difft = t - time
    if difft < distance:
        can = False
        break
    if (distance - difft) % 2 == 1:
        can = False
        break


    x = xx
    y = yy
    time = t
print(("Yes" if can else "No"))
# Original solution
N = int(eval(input()))
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
from itertools import zip_longest
print(('Yes' if all(travelable(p,q) for p,q in zip_longest(P[:N],P[1:])) else 'No'))

# Optimized solution
N = int(eval(input()))
P = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]

def travelable(p,q):
    time = q[0] - p[0]
    dist = abs(q[1]-p[1]) + abs(q[2]-p[2])
    if dist <= time and time%2 == dist%2:
        return True
    else:
        return False
        
print(('Yes' if all(travelable(p,q) for p,q in zip(P[:N],P[1:])) else 'No'))
# Original solution
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

# Optimized solution
# ABC086C - Traveling (ARC089C)
import sys
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    A = tuple(tuple(map(int, input().split())) for _ in range(n))
    for t, x, y in A:
        if x + y > t or (t + x + y) % 2 != 0:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()
# Original solution
#!/usr/bin/python
# -*- coding: utf-8 -*-
N = int(eval(input()))
txy = []
for _ in range(N):
    t, x, y = list(map(int, input().strip().split()))
    txy.append((t, x, y))
can_travel = False
prev_t, prev_x, prev_y = 0,0,0
for t, x, y in txy:
    if abs(x-prev_x) + (y-prev_y) > t - prev_t:
        can_travel = False
        break
    elif (abs(x-prev_x) + abs(y-prev_y)) % 2 != (t-prev_t) % 2:
        can_travel = False
        break
    else:
        prev_t, prev_x, prev_y = t, x, y
        can_travel = True
        continue
if can_travel:
    print("Yes")
else:
    print("No")

# Optimized solution
N = int(input().strip())

prevt, prevx, prevy = 0, 0, 0
t = True
for n in range(N):
  t, x, y = list(map(int, input().strip().split()))
  if t - prevt >= abs(x-prevx) + abs(y-prevy) and (t-prevt) % 2 == (abs(x-prevx) + abs(y-prevy)) % 2:
    prevt, prevx, prevy = t, x, y
  else:
    t = False
    break

if t:
  print("Yes")
else:
  print("No")
# Original solution
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]=list(map(int,readline().split()))

    nt=[]
    nx=[]
    ny=[]
    for i in range(N):
        if i==0:
            nt.append(t[0])
            nx.append(x[0])
            ny.append(y[0])
        else:
            nt.append(t[i]-t[i-1])
            nx.append(x[i]-x[i-1])
            ny.append(y[i]-y[i-1])

    for i in range(N):
        if nt[i]<abs(nx[i])+abs(ny[i]):
            print("No")
            break
        elif nt[i]%2!=(abs(nx[i])+abs(ny[i]))%2:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

# Optimized solution
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]=list(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()
# Original solution
N = int(eval(input()))
t = x = y = [0]
for i in range(N):
  tn,xn,yn = list(map(int,input().split()))
  t = t+[tn]
  x = x+[xn]
  y = y+[yn]
  dt = t[i+1]-t[i]
  d = abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
  if d <= dt and dt%2 == d%2:
    isValid = True
  else:
    isValid = False
    break
print(("Yes" if isValid else "No"))

# Optimized solution
N = int(eval(input()))
t = x = y = 0
for i in range(N):
  tn,xn,yn = list(map(int,input().split()))
  dt = tn-t
  d = abs(xn-x)+abs(yn-y)
  if d <= dt and dt%2 == d%2:
    t,x,y = tn,xn,yn
    isValid = True
  else:
    isValid = False
    break
print(("Yes" if isValid else "No"))