qyliang/CodeNanoFix huggingface dataset:
Buggy code:
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

c0 = c[0][0] + c[0][1] + c[0][2]
c1 = c[1][0] + c[1][1] + c[1][2]
c2 = c[2][0] + c[2][1] + c[2][2]

# a0 + b0 = c00
# a0 + b1 = c01
# a0 + b2 = c02
# 3*a2 + b0 + b1 + b2 = c20 + c21 + c22
# 3*a2 - 3*a0 = c20 + c21 + c22 - (c00 + c01 + c02)
print(str(c))
for a0 in range(101):
    b0 = c[0][0] - a0
    b1 = c[0][1] - a0
    b2 = c[0][2] - a0
    for a1 in range(101):
        a2 = (c2 - c0 + 3 * a0) / 3
        if (
            c[1][0] - a1 == b0
            and c[1][1] - a1 == b1
            and c[1][2] - a1 == b2
            and c[2][0] - a2 == b0
            and c[2][1] - a2 == b1
            and c[2][2] - a2 == b2
        ):
            print("Yes")
            exit(0)
print("No")


Fixed code:
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))

c0 = c[0][0] + c[0][1] + c[0][2]
c1 = c[1][0] + c[1][1] + c[1][2]
c2 = c[2][0] + c[2][1] + c[2][2]

# a0 + b0 = c00
# a0 + b1 = c01
# a0 + b2 = c02
# 3*a2 + b0 + b1 + b2 = c20 + c21 + c22
# 3*a2 - 3*a0 = c20 + c21 + c22 - (c00 + c01 + c02)
for a0 in range(101):
    b0 = c[0][0] - a0
    b1 = c[0][1] - a0
    b2 = c[0][2] - a0
    for a1 in range(101):
        a2 = (c2 - c0 + 3 * a0) / 3
        if (
            c[1][0] - a1 == b0
            and c[1][1] - a1 == b1
            and c[1][2] - a1 == b2
            and c[2][0] - a2 == b0
            and c[2][1] - a2 == b1
            and c[2][2] - a2 == b2
        ):
            print("Yes")
            exit(0)
print("No")
Buggy code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
A1=-1
A2=-1
A3=-1
B1=-1
B2=-2
B3=-1
flag=0
for i in range(a+1):
    A1=i
    B1=a-A1
    B2=b-A1
    B3=c-A1
    if d-B1==e-B2 and e-B2==f-B3 and g-B1==h-B2 and h-B2 and i-B3:
        flag=1
        break
print('Yes' if flag else 'No')

Fixed code:
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
A1=-1
A2=-1
A3=-1
B1=-1
B2=-2
B3=-1
flag=0
for j in range(a+1):
    A1=j
    B1=a-A1
    B2=b-A1
    B3=c-A1
    if B1<0 or B2<0 or B3 <0:
        continue
    A2=d-B1
    A3=g-B1
    if A2<0 or A3<0:
        continue
    if d-B1==e-B2 and e-B2==f-B3 and g-B1==h-B2 and h-B2 == i-B3:
        flag=1
        break
print('Yes' if flag else 'No')
Buggy code:
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([c[2] for line in c]) - sum([c[1] for line in c])) % 3 == 0
    assert (sum([c[1] for line in c]) - sum([c[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")


Fixed code:
c = [list(map(int, input().split())) for _ in range(3)]
try:
    assert (sum(c[2]) - sum(c[1])) % 3 == 0
    assert (sum(c[1]) - sum(c[0])) % 3 == 0
    assert (sum([line[2] for line in c]) - sum([line[1] for line in c])) % 3 == 0
    assert (sum([line[1] for line in c]) - sum([line[0] for line in c])) % 3 == 0
    print("Yes")
except AssertionError:
    print("No")
Buggy code:

li = [list(map(int, input().split())) for _ in range(3)]
sum1 = li[0][0] + li[1][1] + li[2][2]
sum2 = li[1][0] + li[2][1] + li[0][2]
sum3 = li[2][0] + li[3][1] + li[1][2]
if sum1 ==sum2 and sum2 == sum3:
    print("Yes")
else:
    print("No")

Fixed code:

li = [list(map(int, input().split())) for _ in range(3)]
sum1 = li[0][0] + li[1][1] + li[2][2]
sum2 = li[1][0] + li[2][1] + li[0][2]
sum3 = li[2][0] + li[0][1] + li[1][2]
if sum1 ==sum2 and sum2 == sum3:
    print("Yes")
else:
    print("No")
Buggy code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

C = [0] * 3

for i in range(3):
    C[i] = list(map(int, input().split()))

for i in range(1, 3):
    x = C[i][0] - C[i - 1][0]
    for j in range(1, 3):
        if C[i][j] - C[i - 1][j] != x:
            print("NO")
            exit()

for j in range(1, 3):
    x = C[0][j] - C[0][j - 1]
    for i in range(1, 3):
        if C[i][j] - C[i][j - 1] != x:
            print("NO")
            exit()
print("YES")




Fixed code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

C = [0] * 3

for i in range(3):
    C[i] = list(map(int, input().split()))

for i in range(1, 3):
    x = C[i][0] - C[i - 1][0]
    for j in range(1, 3):
        if C[i][j] - C[i - 1][j] != x:
            print("No")
            exit()

for j in range(1, 3):
    x = C[0][j] - C[0][j - 1]
    for i in range(1, 3):
        if C[i][j] - C[i][j - 1] != x:
            print("No")
            exit()
print("Yes")
Buggy code:
L=[]
for i in range(3):
  L.append(list(map(int,input().split())))
if all(S[i][0]-S[i+1][0]==S[i][1]-S[i+1][1]==S[i][2]-S[i+1][2] for i in range(2)) and all(S[0][i]-S[0][i+1]==S[1][i]-S[1][i+1]==S[2][i]-S[2][i+1] for i in range(2)):
  print("Yes")
else:
  print("No")

Fixed code:
L=[]
for i in range(3):
  L.append(list(map(int,input().split())))
if all(L[i][0]-L[i+1][0]==L[i][1]-L[i+1][1]==L[i][2]-L[i+1][2] for i in range(2)) and all(L[0][i]-L[0][i+1]==L[1][i]-L[1][i+1]==L[2][i]-L[2][i+1] for i in range(2)):
  print("Yes")
else:
  print("No")
Buggy code:
c = [[0] * 3 for i in range(3)]
for i in range(3):
    c[i][0], c[i][1], c[i][2] = map(int, input().split(' '))


a_list = [0] * 3
b_list = [0] * 3
for a0 in range(c[0][0] + 1):
    a_list[0] = a0
    b_list[0] = c[0][0] - a_list[0]
    a_list[1] = c[1][0] - b_list[0]
    a_list[2] = c[2][0] - b_list[0]
    b_list[1] = c[0][1] - a_list[0]
    b_list[2] = c[0][2] - a_list[0]
    
    tmp = [[0] * 3 for i in range(3)]
    for i in range(3):
        for j in range(3):
            tmp[i][j] = a_list[i] + b_list[j]

    for n, m in zip(c, tmp):
        if not n == m:
            print('No')        
            break
    else:
        print('Yes')
        exit()
else:
    print('No')


Fixed code:
c = [[0] * 3 for i in range(3)]
for i in range(3):
    c[i][0], c[i][1], c[i][2] = map(int, input().split(' '))


a_list = [0] * 3
b_list = [0] * 3
for a0 in range(c[0][0] + 1):
    a_list[0] = a0
    b_list[0] = c[0][0] - a_list[0]
    a_list[1] = c[1][0] - b_list[0]
    a_list[2] = c[2][0] - b_list[0]
    b_list[1] = c[0][1] - a_list[0]
    b_list[2] = c[0][2] - a_list[0]
    if not all([tmp >= 0 for tmp in a_list]):
        continue
    if not all([tmp >= 0 for tmp in b_list]):
        continue
    
    tmp = [[0] * 3 for i in range(3)]
    for i in range(3):
        for j in range(3):
            tmp[i][j] = a_list[i] + b_list[j]

    for n, m in zip(c, tmp):
        if not n == m:
            break
    else:
        print('Yes')
        exit()
else:
    print('No')
Buggy code:
grid = [list(map(int,input().split())) for i in range(3)]


if (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2]):
    print('Yes')

else:
    print('No')

Fixed code:
grid = [list(map(int,input().split())) for i in range(3)]


if (grid[0][0] - grid[1][0]) == (grid[0][1] - grid[1][1]) == (grid[0][2] - grid[1][2]) and (grid[0][0]-grid[0][1]) == (grid[1][0]-grid[1][1]) == (grid[2][0] - grid[2][1]) and(grid[0][0] - grid[2][0]) == (grid[0][1] - grid[2][1]) == (grid[0][2] - grid[2][2]) and  (grid[0][0]-grid[0][2]) == (grid[1][0]-grid[1][2]) == (grid[2][0] - grid[2][2]):

    print('Yes')

else:
    print('No')
Buggy code:
import sys
c=[[int(i) for i in l.stlip()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')

Fixed code:
import sys
c=[[int(i) for i in l.split()] for l in sys.stdin]
for i in range(2):
  stack=c[i][0]-c[i+1][0]
  for j in range(3):
    if stack!=c[i][j]-c[i+1][j]:
      print('No')
      exit()
for i in range(2):
  stack=c[0][i]-c[0][i+1]
  for j in range(3):
    if stack!=c[j][i]-c[j][i+1]:
      print('No')
      exit()
print('Yes')
Buggy code:
import numpy as np
nlis = []
for i in range(3):
    nlis.append(list(map(int, input().split())))

nlis = np.array(nlis)
for i in [nlis[2] - nlis[1],nlis[1] - nlis[0],nlis.T[2] - nlis.T[1],nlis.T[1] - nlis.T[0]]:
    if not i[0] == i[1] and i[1] == i[2]:
        print('No')    
print('Yes')


Fixed code:
import numpy as np
nlis = []
for i in range(3):
    nlis.append(list(map(int, input().split())))

nlis = np.array(nlis)
for i in [nlis[2] - nlis[1],nlis[1] - nlis[0],nlis.T[2] - nlis.T[1],nlis.T[1] - nlis.T[0]]:
    if not (i[0] == i[1] and i[1] == i[2]):
        print('No')
        exit()
print('Yes')
Buggy code:
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if Flag else "No")

Fixed code:
c = []
for _ in [0]*3:
  c += [list(map(int, input().split()))]

flag = True
for i in [0,1]:
  for j in [0,1]:
    if c[i][j] + c[i+1][j+1] != c[i+1][j] + c[i][j+1]:
      flag = False
print("Yes" if flag else "No")
Buggy code:
C = []
C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(2)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(2)]

for idx in range(2):
	if D_h[0][idx] != D_h[1][idx]:
		print("No")
	elif D_h[0][idx] != D_h[2][idx]:
		print("No")

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")

Fixed code:
C = []
for i in range(3):
	C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(3)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(3)]

for idx in range(2):
	if D_h[idx][0] != D_h[idx][1]:
		print("No")
		exit(0)
	elif D_h[idx][0] != D_h[idx][2]:
		print("No")
		exit(0)

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
		exit(0)
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
		exit(0)

print("Yes")
Buggy code:
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(3):
  if (lst[i][1]-lst[i][0])!=(lst[i][2]-lst[i][1]) or (lst[1][i]-lst[0][i])!=(lst[2][i]-lst[1][i]):
    print('No')
    sys.exit()
print('Yes')

Fixed code:
import sys
lst=[]
for i in range(3):
  a,b,c=map(int,input().split())
  lst.append([a,b,c])
for i in range(2):
  for j in range(2):
    if (lst[i][j+1]-lst[i][j])!=(lst[i+1][j+1]-lst[i+1][j]) or (lst[j+1][i]-lst[j][i])!=(lst[j+1][i+1]-lst[j][i+1]):
      print('No')
      sys.exit()
print('Yes')
Buggy code:
import sys

m = [map(int, input().split()) for _ in range(3)]

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')


Fixed code:
import sys

m = [list(map(int, input().split())) for _ in range(3)]

for a in range(-1000, 1001):
    b_1 = m[0][0] - a
    b_2 = m[0][1] - a
    b_3 = m[0][2] - a
    if (m[1][0] - b_1 ==
        m[1][1] - b_2 ==
        m[1][2] - b_3) and \
        (m[2][0] - b_1 ==
         m[2][1] - b_2 ==
         m[2][2] - b_3):
        print('Yes')
        sys.exit()
print('No')
Buggy code:
c = []
for i in range(3):
  c.append(list(map(int, input().split())))

d = []
for i in range(3):
  sum = 0
  d.append([])
  for j in range(3):
    sum += c[i][j]
  for j in range(3):
    d[i].append(c[i][j] - sum/3)
    
for i in range(3):
  if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')


Fixed code:
c = []
for i in range(3):
  c.append(list(map(int, input().split())))

d = []
for i in range(3):
  sum = 0
  d.append([])
  for j in range(3):
    sum += c[i][j]
  for j in range(3):
    d[i].append(3*c[i][j] - sum)
    
for i in range(3):
  if d[0][i]==d[1][i] and d[0][i]==d[2][i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')
Buggy code:
c = []
for i in range(3):
    c.append(list(int(x) for x in input().split()))
c[1][0] -= c[0][0]
c[2][0] -= c[0][0]
if c[1][1] == c[0][1] + c[1][0] and c[1][2] == c[0][2] + c[1][0] and c[2][1] == c[0][1] + c[2][0] and c[2][2] == c[0][2] + c[2][0]:
    print(‘Yes’)
else:
    print(‘No’)

Fixed code:
c = []
for i in range(3):
    c.append(list(int(x) for x in input().split()))
c[1][0] -= c[0][0]
c[2][0] -= c[0][0]
if c[1][1] == c[0][1] + c[1][0] and c[1][2] == c[0][2] + c[1][0] and c[2][1] == c[0][1] + c[2][0] and c[2][2] == c[0][2] + c[2][0]:
    print('Yes')
else:
    print('No')
Buggy code:
def Infomation():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c33 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True

c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

flag = Infomation()

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

Fixed code:
def solve():
    if not (c11 - c21 == c12 - c22 == c13 - c23):
        return False
    if not (c11 - c31 == c12 - c32 == c13 - c33):
        return False
    if not (c11 - c12 == c21 - c22 == c31 - c32):
        return False
    if not (c11 - c13 == c21 - c23 == c31 - c33):
        return False
    return True


c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

print('Yes' if solve() else 'No')
Buggy code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans='No'
if a[1]-a[0]==b[1]-b[0]==c[1]-c[0] and a[2]-a[1]==b[2]-b[1]==c[2]-c[1]:
  b[0]-a[0]==b[1]-a[1]==b[2]-b[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
    ans='Yes'
print(ans)

Fixed code:
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans='No'
if a[1]-a[0]==b[1]-b[0]==c[1]-c[0] and a[2]-a[1]==b[2]-b[1]==c[2]-c[1]:
  if b[0]-a[0]==b[1]-a[1]==b[2]-a[2] and c[0]-b[0]==c[1]-b[1]==c[2]-b[2]:
    ans='Yes'
print(ans)
Buggy code:
A=input().split(" ")
A = list(map(int, A))
B=input().split(" ")
B = list(map(int, B))
C=input().split(" ")
C = list(map(int, C))


if (A[0]-B[0] == A[1]-B[1] and A[1]-B[1] == A[2]-B[2]):
	if(A[0]-C[0] == A[1]-C[1] and A[1]-C[1] == A[2]-C[2]):
		if(C[0]-B[0] == C[1]-B[1] and C[1]-B[1] == C[2]-B[2]):
			print("Yes")
else:
	print("No")

Fixed code:
A=input().split(" ")
A = list(map(int, A))
B=input().split(" ")
B = list(map(int, B))
C=input().split(" ")
C = list(map(int, C))


if (A[0]-B[0] == A[1]-B[1] and A[1]-B[1] == A[2]-B[2]) and (A[0]-C[0] == A[1]-C[1] and A[1]-C[1] == A[2]-C[2]) and (C[0]-B[0] == C[1]-B[1] and C[1]-B[1] == C[2]-B[2]):
			print("Yes")
else:
	print("No")
Buggy code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=num4//2
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if sum(cnt1)<=num5 and sum(cnt2)<=num5 and (sum(cnt2)-sum(cnt1))%2==0:
    print("Yes")
else:
    print("No")


Fixed code:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt1=[0]*n
cnt2=[0]*n
for i in range(n):
    if a[i]>b[i]:
        cnt2[i]=a[i]-b[i]
    else:
        num4=b[i]-a[i]
        cnt1[i]=-(num4//-2)
        cnt2[i]=num4%2
num5=abs(sum(a)-sum(b))
if max(sum(cnt1),sum(cnt2))+abs(sum(cnt1)-sum(cnt2))<=num5:
    print("Yes")
else:
    print("No")
Buggy code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=b[i]-a[i]
    if resa+resb/2>=cnt:
        print("No")
    else:
        print("Yes")

Fixed code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sa=sum(a)
sb=sum(b)
if sb<sa:
    print("No")
else:
    cnt=sb-sa
    resa=0
    resb=0
    for i in range(n):
        if b[i]<a[i]:
            resa+=a[i]-b[i]
        else:
            resb+=math.ceil((b[i]-a[i])/2)
    if resa>cnt or resb>cnt:
        print("No")
    else:
        print("Yes")
Buggy code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]//2
    else:
        a_sum += c[i]

if a_sum < abs(b_sum):
    print("No")
else:
    print("Yes")


Fixed code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a_sum = 0
b_sum = 0
for i in range(n):
    c.append(b[i]-a[i])
    if c[i] < 0:
        b_sum += c[i]
    else:
        a_sum += c[i]//2

if a_sum < abs(b_sum):
    print("No")
else:
    print("Yes")
Buggy code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb <= aa:
    print('Yes')
else:
    print('No')


Fixed code:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = 0
cb = 0
for aa, bb in zip(a, b):
    if aa < bb:
        cb += (bb - aa)//2
    if bb < aa:
        ca += aa - bb
# print(ca, cb)
if cb >= ca:
    print('Yes')
else:
    print('No')
Buggy code:
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("NO" if [s >= 0 == s%2 ::2] else "Yes")

Fixed code:
n, *p = map(int, open(0).read().split())
s = sum(j - i - max(0, i - j) - max(0, j - i)%2 for i, j in zip(p, p[n:]))
print("Yes" if s >= 0 == s%2 else "No")
Buggy code:
n=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

a.sort()
b.sort()

if a==b:
    print("Yes")
    exit()

suma=sum(a)
sumb=sum(b)

if suma>=sumb:
    print("No")
    exit()

#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=(-1)*((a[i]-b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")

Fixed code:
n=int(input())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

#a.sort()
#b.sort()

if a==b:
    print("Yes")
    exit()

suma=sum(a)
sumb=sum(b)


#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=sumb-suma
#
#1 1 1 6
#2 2 2 3

cnta=0
cntb=0
for i in range(n):
    if a[i]>b[i]:
        cntb+=a[i]-b[i]
    elif a[i]<b[i]:
        cnta+=(-1)*((a[i]-b[i])//2)
#print(k,cntb,cnta)
if cntb<=k and cnta<=k:
    print("Yes")
else:
    print("No")
Buggy code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ba = 0
    bb = 0
    for i in range(N):
        if a[i] > b[i]:
            ba += a[i] - b[i]
        if b[i] > a[i]:
            bb += (b[i] - a[i]) // 2

    if bb = ba:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Fixed code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ba = 0
    bb = 0
    for i in range(N):
        if a[i] > b[i]:
            ba += a[i] - b[i]
        if b[i] > a[i]:
            bb += (b[i] - a[i]) // 2

    if bb >= ba:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
Buggy code:
N = int(input())
a = list(map(int, input.split()))
b = list(map(int, input.split()))

ba = 0, bb = 0
for i in range(N):
    if a[i] > b[i]:
        ba += a[i] - b[i]
    if b[i] > a[i]:
        bb += (b[i] - a[i])//2

if bb >= ba:
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ba = 0
bb = 0
for i in range(N):
    if a[i] > b[i]:
        ba += a[i] - b[i]
    if b[i] > a[i]:
        bb += (b[i] - a[i])//2

if bb >= ba:
    print("Yes")
else:
    print("No")
Buggy code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= sm:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Fixed code:
def main():
    import sys

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

    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    s = 0
    sm = 0
    for x, y in zip(a,b):
        tmp = y-x
        sm += tmp
        if tmp > 0:
            tmp //= 2
        s += tmp
    if s >= 0 and sm >= 0:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()
Buggy code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0

    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B >= _diff_A:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Fixed code:
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    A = [int(i) for i in input().strip().split()]
    B = [int(i) for i in input().strip().split()]

    _diff_A, _diff_B = 0, 0
    m = sum(B) - sum(A)
    for i in range(n):
        if A[i] > B[i]:
            _diff_A += A[i] - B[i]
        elif B[i] > A[i]:
            _diff_B += (B[i] - A[i] + 1) // 2

    if _diff_B <= m and _diff_A <= m:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy code:
n,*a=map(int,open(0).read().split())
u=d=z=r=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=(j-i)//2*2;r+=(j-i)%2
    elif j-i==0:z+=1
    else:d+=[j-i]
print("Yes" if u+2*d>=0 else "No")

Fixed code:
n,*a=map(int,open(0).read().split())
u=d=z=r=0
for i,j in zip(a[:n],a[n:]):
    if j-i>0:u+=(j-i)//2*2;r+=(j-i)%2
    elif j-i==0:z+=1
    else:d+=j-i
print("Yes" if u+2*d>=0 else "No")