qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def check(x, y, new_x, new_y, dt):
  diff = abs(new_x - x) + abs(new_y - y)
  if dt%2 == diff%2 and diff <= dt:
    return True
  return False

n = int(input())
t, x, y, count = 0, 0, 0, 0
canReach = True
while(count < n):
  new_t, new_x, new_y = map(int, input().split())
  if not check(x, y, new_x, new_y, new_t-t):
    canReach = False
    break
  t, x, y = new_t, new_x, new_y
  count += 1
if canReach:
  print("YES")
else:
  print("NO")

Fixed code:
def check(x, y, new_x, new_y, dt):
  diff = abs(new_x - x) + abs(new_y - y)
  if dt%2 == diff%2 and diff <= dt:
    return True
  return False

n = int(input())
t, x, y, count = 0, 0, 0, 0
canReach = True
while(count < n):
  new_t, new_x, new_y = map(int, input().split())
  if not check(x, y, new_x, new_y, new_t-t):
    canReach = False
    break
  t, x, y = new_t, new_x, new_y
  count += 1
if canReach:
  print("Yes")
else:
  print("No")
Buggy code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    t,x,y=lst[num+1]
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')

Fixed code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  return (t-t0-minT)>=0 and (t-t0-minT)%2==0
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
num=0;bool=False
while num<=n-1:
  t,x,y=lst[num]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    num+=1
    bool=True
  else:
    bool=False
    break
if bool:
  print('Yes')
else:
  print('No')
Buggy code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  if (t-t0-minT)%2==0:
    return True
  else:
    return False
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
for i in range(n):
  t,x,y=lst[i]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    ans=True
  else:
    ans=False
    break
if ans:
  print('Yes')
else:
  print('No')

Fixed code:
def judge(t,x,y,t0,x0,y0):
  minT=abs(x-x0)+abs(y-y0)
  if (t-t0-minT)>=0 and (t-t0-minT)%2==0:
    return True
  else:
    return False
n=int(input())
lst=[tuple(int(i) for i in input().split()) for i in range(n)]
t0=0;x0=0;y0=0
for i in range(n):
  t,x,y=lst[i]
  if judge(t,x,y,t0,x0,y0):
    t0=t;x0=x;y0=y
    ans=True
  else:
    ans=False
    break
if ans:
  print('Yes')
else:
  print('No')
Buggy code:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y <= t or (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Fixed code:
n = int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if (x+y)>t or (x+y)%2 != t%2:
        print("No")
        exit()
print("Yes")
Buggy code:
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y) <= t and (x + y) % 2 != t % 2:
        print("No")
        exit()
print("Yes")

Fixed code:
n = int(input())
for i in range(n):
    t,x,y=map(int,input().split())
    if(not((x+y)<=t and (x+y)%2 == t%2)):
        print("No")
        exit()
print("Yes")
Buggy code:
N=int(input())
count=0
for i in range(N):
    t,x,y=map(int,input().split())
    if x+y<=t:
      count+=1
print("Yes" if count==N else "No")

Fixed code:
N=int(input())
count=0
for i in range(N):
    t,x,y=map(int,input().split())
    if x+y<=t and t%2==(x+y)%2:count+=1
print("Yes" if count==N else "No")
Buggy code:
N = int(input())
s = [[0,0,0]]*(N+1)
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
k = 0
for i in range(N):
  dt = t[i+1]-t[i]
  d = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1])
  if d <= dt and d%2 == dt%2:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')

Fixed code:
N = int(input())
s = [[0,0,0]]*(N+1)
t = [0]*(N+1)
x = [0]*(N+1)
y = [0]*(N+1)
for i in range(1,N+1):
  s[i] = input().split()
  t[i] = int(s[i][0])
  x[i] = int(s[i][1])
  y[i] = int(s[i][2])
k = 0
for i in range(N):
  dt = t[i+1]-t[i]
  d = abs(x[i]-x[i+1]) + abs(y[i]-y[i+1])
  if d <= dt and d%2 == dt%2:
    k = k + 1
  else:
    print('No')
    break
if k == N:
  print('Yes')
Buggy code:
n=int(input())
txylist=[[0,0,0,]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
if n==1:
    p=False
    t1,x1,y1=txylist[1]
    lengs=abs(x1)+abs(y1)-t
    if lengs>=0 and lengs%2==0:
        p=True
    else:
        print("No")
else:
    for i in range(n):
        p=False
        t0,x0,y0=txylist[i]
        t1,x1,y1=txylist[i+1]
        t=t1-t0
        x=x1-x0
        y=y1-y0
        longs=abs(x)+abs(y)
        lengs=longs-t
        if lengs>=0 and lengs%2==0:
            p=True
        else:
            print("No")
            break
if p==True:
    print("Yes")

Fixed code:
n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t=t1-t0
    x=x1-x0
    y=y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")
Buggy code:
n = int(input())

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

t = 0
x = 0
y = 0
flag = 0

for i in range(n):
    if i>0:
        t = list[i][0] - list[i-1][0]
        d = list[i][1] - list[i-1][1] + list[i][2] - list[i-1][2]
    else:
        t = list[i][0]
        d = list[i][1] + list[i][2]
    if (d-t) >= 0 and (d-t)%2 == 0:
        continue
    else:
        flag = 1
        print('No')
        break
if flag ==0:
    print('Yes')

Fixed code:
n = int(input())

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

t = 0
x = 0
y = 0
flag = 0

for i in range(n):
    if i>0:
        t = list[i][0] - list[i-1][0]
        d = abs(list[i][1] - list[i-1][1] + list[i][2] - list[i-1][2])
    else:
        t = list[i][0]
        d = abs(list[i][1] + list[i][2])
    if (t-d) >= 0 and (d-t)%2 == 0:
        continue
    else:
        flag = 1
        print('No')
        break
if flag ==0:
    print('Yes')
Buggy code:
N = int(input())
T = []
Z = []
time = []
T.append([0,0,0])
for i in range(N):
    t = list(map(int, input().split()))
    T.append(t)
goal = True

for l in range(len(T)-1):
    Z.append(abs(T[l+1][1]-T[l][1]) + abs(T[l+1][2]-T[l][2]))
    time.append(T[l+1][0] - T[l][0])

for j in range(len(T)-1):
    if Z[j] > time[j] or Z[j]%2 != time[j]%2:
        goal = False
        break

if goal == False:
    print('NO')
else:
    print('YES')

 

Fixed code:
N = int(input())
T = []
Z = []
time = []
T.append([0,0,0])
for i in range(N):
    t = list(map(int, input().split()))
    T.append(t)
goal = True

for l in range(len(T)-1):
    Z.append(abs(T[l+1][1]-T[l][1]) + abs(T[l+1][2]-T[l][2]))
    time.append(T[l+1][0] - T[l][0])

for j in range(len(T)-1):
    if Z[j] > time[j] or Z[j]%2 != time[j]%2:
        goal = False
        break

if goal == False:
    print('No')
else:
    print('Yes')
Buggy code:
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = abs(t0 - t)
    if abs(kyori - time) % 2 == 0 and kyori - time < 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')


Fixed code:
N = int(input())
t0, x0, y0 = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    kyori = abs(x - x0) + abs(y - y0)
    time = t - t0
    if (abs(kyori - time)) % 2 == 0 and time - kyori >= 0:
        t0, x0, y0 = t, x, y
    else:
        print('No')
        exit(0)
print('Yes')
Buggy code:
N = int(input())

t,x,y = 0,0,0
for _ in range(1, N+1):
    tn,xn,yn = map(int, input().split())
    step = abs(x-xn) + abs(y-yn)
    
    if  tn-t < step or (tn-t)%2 != step%2:
        print("No")
        break
    t,x,y = tn,xn,yn
    
print("Yes")

Fixed code:
N = int(input())

t,x,y = 0,0,0
for _ in range(1, N+1):
    tn,xn,yn = map(int, input().split())
    step = tn-t
    step_needed = abs(x-xn) + abs(y-yn)
    
    if step < step_needed or step%2 != step_needed%2:
        print("No")
        break
    t,x,y = tn,xn,yn
    
else:  
    print("Yes")
Buggy code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])
prev_dst = np.array([0] * 3)

for n in range(N):
    t,x,y = map(int, input().split(" "))
    a = (prev_dst[0] - t) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t,x,y]
    else:
        print("No")
        exit(0)

print("Yes")



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

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")
Buggy code:
N = int(input()) 
P = [list(map(int, input().split())) for i in range(N)] 
P.insert(0,[0,0,0])

ans = "YES"
for i in range(N):
	norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
	move = (P[i+1][0]-P[i][0]) - norm
	if ((move%2 != 0) or (move < 0)):
		ans = "NO"
		break
	
print(ans)
	

Fixed code:
N = int(input()) 
P = [list(map(int, input().split())) for i in range(N)] 
P.insert(0,[0,0,0])

ans = "Yes"
for i in range(N):
	norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
	move = (P[i+1][0]-P[i][0]) - norm
	if ((move%2 != 0) or (move < 0)):
		ans = "No"
		break
	
print(ans)
Buggy code:
n = int(input())

def check_distance(move_distance, move_time):
  buf_result = False

  if move_distance / move_time >= 1:
    buf_val = move_distance % move_time

    if buf_val % 2 == 0:
      buf_result = True

  return buf_result

current_posi = [0, 0]
next_posi = []

current_time = 0
next_time = 0

result = False

for i in range(n):
  input_i = list(map(int, input().split()))
  next_time = input_i[0]
  next_posi = [input_i[1], input_i[2]]

  move_distance = abs(current_posi[0] - next_posi[0]) + abs(current_posi[1] - next_posi[1])

  move_time = next_time - current_time

  result = check_distance(move_distance, move_time)

  if result == False:
    break


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

  

Fixed code:
n = int(input())

def check_distance(move_distance, move_time):
  buf_result = False

  if move_time >= move_distance:
    buf_val = move_time - move_distance

    if buf_val % 2 == 0:
      buf_result = True

  return buf_result

current_posi = [0, 0]
next_posi = []

current_time = 0
next_time = 0

result = False

for i in range(n):
  input_i = list(map(int, input().split()))
  next_time = input_i[0]
  next_posi = [input_i[1], input_i[2]]

  move_distance = abs(current_posi[0] - next_posi[0]) + abs(current_posi[1] - next_posi[1])

  move_time = next_time - current_time

  result = check_distance(move_distance, move_time)

  if result == False:
    break
  else:
    current_time = input_i[0]
    current_posi = [input_i[1], input_i[2]]


if result == False:
  print("No")
else:
  print("Yes")
Buggy code:
N = int(input())
t_0, x_0, y_0 = [int(txy) for txy in input().split()]

for n in range(N-1):
  t_1, x_1, y_1 = [int(txyz) for txyz in input().split()]
  d_01 = abs(x_1 - x_0) + abs(y_1 - y_0)
  dt = t_1 - t_0
  if dt < d_01:
    print("No")
    break
  else:
    t_d = dt - d_01
    if t_d % 2 == 0:
      t_0, x_0, y_0 = t_1, x_1, y_1
    else:
      print("No")
      break
else:
  print("Yes")

Fixed code:
N = int(input())
t_0, x_0, y_0 = 0, 0, 0

for n in range(N):
  t_1, x_1, y_1 = [int(txyz) for txyz in input().split()]
  d_01 = abs(x_1 - x_0) + abs(y_1 - y_0)
  dt = t_1 - t_0
  if dt < d_01:
    print("No")
    break
  else:
    t_d = dt - d_01
    if t_d % 2 == 0:
      t_0, x_0, y_0 = t_1, x_1, y_1
    else:
      print("No")
      break
else:
  print("Yes")
Buggy code:
def main():
  size = int(input())
  for i in range(size):
    array[i] = list(map(int, input().split())
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0]- pre_time
    distance = array[i][1]-pos[0] + array[i][2]-pos[1]
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = time
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()

Fixed code:
def main():
  size = int(input())
  array = []
  for i in range(size):
    array.append(list(map(int, input().split())))
                    
  flg = "Yes"           
  pre_time = 0
  pos = [0, 0] 
  for i in range (size):
    time = array[i][0] - pre_time
    distance = abs(array[i][1]-pos[0]) + abs(array[i][2]-pos[1])
    
    if time == distance or ((distance<time) and (time-distance)%2 == 0):
      pre_time = array[i][0]
      pos = array[i][1:]
    else:
      flg = "No"
                    
  print(flg)
                    
main()
Buggy code:
n=int(input())
if n==1:
  exit()
t0=x0=y0=0
f=0
for i in range(n):
  t,x,y=map(int,input().split())
  t-=t0
  x1=abs(x-x0)
  y1=abs(y-y0)
  if t<x1+y1 or t%2!=(x1+y1)%2:
    f=1
  t0=t
  x0=x
  y0=y
if f==1:
  print('No')
else:
  print('Yes')

Fixed code:
n=int(input())
t0=x0=y0=0
f=0
for i in range(n):
  t,x,y=map(int,input().split())
  t1=t-t0
  x1=abs(x-x0)
  y1=abs(y-y0)
  if t1<x1+y1 or t1%2!=(x1+y1)%2:
    f=1
  t0=t
  x0=x
  y0=y
if f==1:
  print('No')
else:
  print('Yes')
Buggy code:
N=int(input())
t=[]
x=[]
y=[]
#t.append(0)
#x.append(0)
#y.append(0)
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
  abs(x_gap)=x[i]-x_cur
  abs(y_gap)=y[i]-y_cur

  dist=x_gap+y_gap

#  print("trip=",t[i],x[i],y[i])
#  print("t_gap=",t_gap)
#  print("dist=",dist)
  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")


Fixed code:
N=int(input())
t=[]
x=[]
y=[]
#t.append(0)
#x.append(0)
#y.append(0)
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

#  print("trip=",t[i],x[i],y[i])
#  print("t_gap=",t_gap)
#  print("dist=",dist)
  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")
Buggy code:
N=int(input())
pre_t=0
pre_x=0
pre_y=0
flg=0
for i in range(N-1):
    t,x,y=map(int,input().split())
    t_tmp = t
    t=t-pre_t
    dist=abs(x-pre_x) + abs(y - pre_y)
    pre_t=t_tmp
    pre_x=x
    pre_y=y
    if(dist > t ):
        flg=1
        break
    if((dist)%2 != t%2):
        flg=1
        break
if(flg == 0):
    print("Yes")
else:
    print("No")    

Fixed code:
N=int(input())
pre_t=0
pre_x=0
pre_y=0
flg="Yes"
for i in range(N):
    t,x,y=map(int,input().split())
    dt=t-pre_t
    dist=abs(x-pre_x) + abs(y-pre_y)
    pre_t=t
    pre_x=x
    pre_y=y
    if(dist > dt ):
        flg="No"
        break
    if((dist)%2 != dt%2):
        flg="No"
        break
print(flg)
Buggy code:
def check_rote(a, b, t, x, y):
    cost_min = abs(a - x) + abs(b - y)
    if cost_min <= t and (t - cost_min) % 2 == 0:
        return True
    else:
        return False

n = int(input())
rotes = []

for i in range(n):
    rotes.append(tuple((int(x) for x in input().split())))

print(rotes)

copy_t = 0
copy_a = 0
copy_b = 0

for i in rotes:
    t, a, b = i
    if not check_rote(a, b, t - copy_t, copy_a, copy_b):
        print("No")
        break
    copy_t = t
    copy_a = a
    copy_b = b
else:
    print("Yes")


Fixed code:
def check_rote(a, b, t, x, y):
    cost_min = abs(a - x) + abs(b - y)
    if cost_min <= t and (t - cost_min) % 2 == 0:
        return True
    else:
        return False

n = int(input())
rotes = []

for i in range(n):
    rotes.append(tuple((int(x) for x in input().split())))

copy_t = 0
copy_a = 0
copy_b = 0

for i in rotes:
    t, a, b = i
    if not check_rote(a, b, t - copy_t, copy_a, copy_b):
        print("No")
        break
    copy_t = t
    copy_a = a
    copy_b = b
else:
    print("Yes")
Buggy code:
import sys
input = sys.stdin.readline
n=int(input())

t1,x1,y1=0,0,0
flg=True
for i in range(n):
    t2,x2,y2=map(int,input().split())
    l=abs(x2-x1)+abs(y2-y1)
    print(l,t2-t1)
    if l<=(t2-t1) and (t2-t1-l-1)%2==0:
        t1,x1,y1=t2,x2,y2
    else:
        flg=False
        break
print("Yes" if flg else "No")


Fixed code:
import sys
input = sys.stdin.readline
n=int(input())

t1,x1,y1=0,0,0
flg=True
for i in range(n):
    t2,x2,y2=map(int,input().split())
    l=abs(x2-x1)+abs(y2-y1)
    #print(l,t2-t1)
    if l<=(t2-t1) and (t2-t1-l)%2==0:
        t1,x1,y1=t2,x2,y2
    else:
        flg=False
        break
print("Yes" if flg else "No")
Buggy code:
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt or dt%2==(dist)%2:continue
	else:
		ans='No'
		break
print(ans)


Fixed code:
n=int(input())

ans='Yes'
dt=0
cur=0
cur_t=0
dist=0
for i in range(n):
	t,x,y=map(int,input().split())
	dist=abs(cur-(x+y))
	cur=x+y
	dt=t-cur_t
	cur_t=t
	
	if dist>dt:
		ans='No'
		break
	if dt%2==0 and (dist)%2==0 or dt%2==1 and (dist)%2==1:continue
	else:
		ans='No'
		break
print(ans)
Buggy code:
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 = xi, yi
  if dist<=t and dist%2==dt%2:
    continue
  else:
    flag=False
print("Yes") if flag else print("No")

Fixed code:
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")
Buggy code:
import sys

n = int(input())

for i in range(n):
    t,x,y = map(int,input().split())
    if (x + y) > t or (x + y + t) % 2:
        print("No")
        sys.exit()
    print("Yes")


Fixed code:
import sys
n = int(input())

for i in range(n):
    t,x,y = map(int,input().split())
    
    if (x+y) > t or (x+y+t) % 2 == 1:
        print("No")
        sys.exit()
        
print("Yes")
Buggy code:
N = int(input())

result = 1
bt=0
bx=0
by= 0

for i in range(N):
	t, x, y = map(int, input().split())
	distance = abs(x-bx) + abs(y-by)
	dur = t - bt
#	print(t,x,y,distance, dur)
	if dur - distance > 0 and (dur - distance) %2 == 0:
		(bt,bx,by) = (t,x,y)
		continue
	else:
		result = 0
		break

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



Fixed code:
N = int(input())

result = 1
bt=0
bx=0
by= 0

for i in range(N):
	t, x, y = map(int, input().split())
	distance = abs(x-bx) + abs(y-by)
	dur = t - bt
#	print(t,x,y,distance, dur)
	if dur - distance >= 0 and (dur - distance) %2 == 0:
		(bt,bx,by) = (t,x,y)
		continue
	else:
		result = 0
		break

if result:
	print("Yes")
else:
	print("No")
Buggy code:
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
ans = "YES"
tpre, xpre, ypre = 0, 0, 0
for _ in range(n):
    t, x, y = na()
    move = abs(x - xpre) + abs(y - ypre) 
    time = (t - tpre)
    if move <= time and move % 2 == time % 2:
        continue
    else:
        ans = "No"

    tpre, xpre, ypre = t, x, y
print(ans)

Fixed code:
import sys
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
ans = "Yes"
tpre, xpre, ypre = 0, 0, 0
for _ in range(n):
    t, x, y = na()
    move = abs(x - xpre) + abs(y - ypre) 
    time = (t - tpre)
    if move <= time and move % 2 == time % 2:
        continue
    else:
        ans = "No"

    tpre, xpre, ypre = t, x, y
print(ans)
Buggy code:
import sys

def dis(x0, y0, x1, y1):
    d = 0
    d += abs(x0 - x1)
    d += abs(y0 - y1)
    return d

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    lines = sys.stdin.readlines()

    ls = [[0, 0, 0]]
    for line in lines:
        ls.append([int(i) for i in line.split()])

    for i in range(1, len(ls)):
        d = dis(ls[i][1], ls[i][2], ls[i-1][1], ls[i-1][2])
        t = ls[i][0] - ls[i-1][0]
        print(ls[i], d, t)
        if d <= t and t % 2 == d %  2:
            continue
        else:
            print('NO')
            break
    else:
        print('YES')


Fixed code:
import sys

def dis(x0, y0, x1, y1):
    d = 0
    d += abs(x0 - x1)
    d += abs(y0 - y1)
    return d

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    lines = sys.stdin.readlines()

    ls = [[0, 0, 0]]
    for line in lines:
        ls.append([int(i) for i in line.split()])

    for i in range(1, len(ls)):
        d = dis(ls[i][1], ls[i][2], ls[i-1][1], ls[i-1][2])
        t = ls[i][0] - ls[i-1][0]
        # print(ls[i], d, t)
        if d <= t and t % 2 == d %  2:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')
Buggy code:
# -*- coding: utf-8 -*-

n = int(input())
t_bef = 0
x_bef = 0
y_bef = 0
flag = 0
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('YES')

Fixed code:
# -*- coding: utf-8 -*-

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    t, x, y = [int(x) for x in input().split()]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')
Buggy code:
# -*- coding: utf-8 -*-

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    travel.append([int(x) for x in input().split()])

for j in travel:
    t, x, y = j[0], j[1], j[2]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('YES')

Fixed code:
# -*- coding: utf-8 -*-

n = int(input())
t_bef, x_bef, y_bef, flag = 0, 0, 0, 0
travel = []
for i in range(n):
    travel.append([int(x) for x in input().split()])

for j in travel:
    t, x, y = j[0], j[1], j[2]
    check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y)
    t_bef, x_bef, y_bef = t, x, y
    if check < 0:
        print('No')
        flag = 1
        break
    if check % 2 != 0:
        print('No')
        flag = 1
        break
if flag == 0:
    print('Yes')
Buggy code:
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i];flag=0;break if a>0 or a%2
print("Yes" if flag else "No")  

Fixed code:
N=int(input());t=[0]*(N+1);x=[0]*(N+1);y=[0]*(N+1);flag=1
for i in range(N):t[i+1],x[i+1],y[i+1]=map(int,input().split())
for i in range(N):
    a=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])-t[i+1]+t[i]
    if a>0 or a%2:flag=0;break
print("Yes" if flag else "No")