qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
x, y = map(int, input().split())
x -= 1
y -= 1
if a[x] == a[y]:
    print("No")
else:
    print("Yes")


Fixed code:
a = [0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
x, y = map(int, input().split())
x -= 1
y -= 1
if a[x] == a[y]:
    print("Yes")
else:
    print("No")
Buggy code:
x , y = map(iint,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
if x in A and y in A:
  print("Yes")
elif  x in B and y in B:
  print("Yes")
else:
  print("No")

Fixed code:
x , y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
if x in A and y in A:
  print("Yes")
elif  x in B and y in B:
  print("Yes")  
else:
  print("No")
Buggy code:
A = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int, input().split())
flg = 0
for a in A:
    if x in a and y in a:
        flg = 1

if flg = 1:
    print("Yes")
else:
    print("No")

Fixed code:
A = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int, input().split())
flg = 0
for a in A:
    if x in a and y in a:
        flg = 1

if flg == 1:
    print("Yes")
else:
    print("No")
Buggy code:
group = [[1,3,5,7,8,10,12],[4,6,9,11]]

x, y = map(int, raw_input().split())
for i in range(0,1):
    if(group[i].count(x) > 0 and group[i].count(y) > 0):
        print("Yes")
        exit()
print("No")


Fixed code:
group = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]

x, y = map(int, input().split())
for i in range(0,2):
    if(group[i].count(x) > 0 and group[i].count(y) > 0):
        print("Yes")
        exit()
print("No")
Buggy code:
x, y = [int(_) for _ in input().split()]
c1 = [1,3,5,7,8,10,12]
c2 = [4,6,9,11]
c3 = [2]
for t in [c1, c2, c3]:
    if (x in t) and (y in t):
        print("Yes")
print("No")

Fixed code:
x, y = [int(_) for _ in input().split()]
c1 = [1,3,5,7,8,10,12]
c2 = [4,6,9,11]
c3 = [2]
cnt = 0
for t in [c1, c2, c3]:
    if (x in t) and (y in t):
        cnt = 1
if cnt == 1:
    print("Yes")
else:       
    print("No")
Buggy code:
a = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = input().split()
for i in range(3):
	if (x and y) in a[i]:
    	print('Yes')
        exit()
print('No')

Fixed code:
a = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y = map(int, input().split())
for i in range(3):
    if (x in a[i]) and (y in a[i]):
        print('Yes')
        exit()
print('No')
Buggy code:
a, b = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
if g1 in a and g1 in b:
  print("Yes")
elif g2 in a and g2 in b:
  print("Yes")
elif g3 in a and g3 in b:
  print("Yes")
else:
  print("No")
  

Fixed code:
a, b = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 = [4, 6, 9, 11]
g3 = [2]
if a in g1  and b in g1:
  print("Yes")
elif a in g2  and b in g2:
  print("Yes")
elif a in g3  and b in g3:
  print("Yes")
else:
  print("No")
Buggy code:
x,y = map(int, input().split())
ans='No'
if x,y in [2]:
  if y in [2]:
    ans='Yes'
if x in [4,6,9,11]:
  if y in [4,6,9,11]:
    ans='Yes'
if x in [1,3,5,7,8,10,12]:
  if y in [1,3,5,7,8,10,12]:
    ans='Yes'
print(ans)

Fixed code:
x,y = map(int, input().split())
ans='No'
if x in [2]:
  if y in [2]:
    ans='Yes'
if x in [4,6,9,11]:
  if y in [4,6,9,11]:
    ans='Yes'
if x in [1,3,5,7,8,10,12]:
  if y in [1,3,5,7,8,10,12]:
    ans='Yes'
print(ans)
Buggy code:
x, y = map(int, input().split())

a, b, c = (4, 6, 9, 11), (1, 3, 5, 7, 8, 10, 12), (2)

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x in c and y in c:
    print("Yes")
else:
    print("No")

Fixed code:
x, y = map(int, input().split())

a, b, c = (4, 6, 9, 11), (1, 3, 5, 7, 8, 10, 12), (2)

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == 2 and y == 2:
    print("Yes")
else:
    print("No")
Buggy code:
A = [4,6,9,1]
x,y = map(int,input().split())
if x in A:
  x = 1
elif x != 2:
  x = 3
if y in A:
  y = 1
elif y != 2:
  y = 3
if x == y:
  print('Yes')
else:
  print('No')

Fixed code:
A = [4,6,9,11]
x,y = map(int,input().split())
if x in A:
  x = 4
elif x != 2:
  x = 3
if y in A:
  y = 4
elif y != 2:
  y = 3
if x == y:
  print('Yes')
else:
  print('No')
Buggy code:
n,m=map(int,input().split())
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
c=(2)
flag=False
if n in a and m in a:
  flag=True
  print("Yes")
elif n in b and m in b:
  flag=True
  print("Yes")
elif n in c and m in c:
  flag=True
  print("Yes")
else:
  print("No")

Fixed code:
n,m=map(int,input().split())
a=(1,3,5,7,8,10,12)
b=(4,6,9,11)
c=(2,)
if n in a and m in a:
  print("Yes")
elif n in b and m in b:
  print("Yes")
elif n in c and m in c:
  print("Yes")
else:
  print("No")
Buggy code:
x, y = (int(i) for i in input().split())

if x == 2 or y == 2:
  print('No')
if x == 4 or  x == 6 or x == 9 or x == 11:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('Yes')
  else:
    print('No')
else:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('No')
  else:
    print('Yes')

Fixed code:
x, y = (int(i) for i in input().split())

if x == 2 or y == 2:
  print('No')
  exit()
if x == 4 or  x == 6 or x == 9 or x == 11:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('Yes')
  else:
    print('No')
else:
  if y == 4 or y == 6 or y == 9 or y == 11:
    print('No')
  else:
    print('Yes')
Buggy code:
x, y = map(int, input().split())
l1 = [1, 3, 5, 7, 8, 10, 12]
l2 = [4, 6, 9, 11]
l3 = [2]
ans = 'N0'
if (x in l1 and y in l1) or (x in l2 and y in l2) or (x in l3 and y in l3):
  ans = 'Yes'
print(ans)

Fixed code:
x, y = map(int, input().split())
l1 = [1, 3, 5, 7, 8, 10, 12]
l2 = [4, 6, 9, 11]
l3 = [2]
ans = 'No'
if (x in l1 and y in l1) or (x in l2 and y in l2) or (x in l3 and y in l3):
  ans = 'Yes'
print(ans)
Buggy code:
x,y = map(int,input().split())
a = [4,6,9,11]
b = [1,3,5,7,8,10,12]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes"
else:
    print("No")



Fixed code:
x, y = map(int, input().split())
if x in [1, 3, 5, 7, 8, 10, 12] and y in [1, 3, 5, 7, 8, 10, 12]:
	print('Yes')
elif x in [4, 6, 9, 11] and y in [4, 6, 9, 11]:
	print('Yes')
else:
	print('No')
Buggy code:
x, y = map(int, input().split())
g1 = [1, 3, 5, 7, 8, 10, 12]
g2 =[4, 6, 9, 11]
if x and y in g1:
    print("Yes")
elif x and y in g2:
    print("Yes")
elif x and y in [2]:
    print("Yes")
else:
    print("No")

Fixed code:
x,y=map(int,input().split())
if x==2 or y==2:
    print("No")
elif x in [4,6,9,11] and y in [4,6,9,11]:
    print("Yes")
elif x in [1,3,5,7,8,10,12] and y in [1,3,5,7,8,10,12]:
    print("Yes")
else:
    print("No")
Buggy code:
import sys
a=list(map(int,input().split()))
flg=0
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
for i in range(len(A)):
    if A[i]==a[0]:
        for j in range(len(A)):
            if A[j]==a[1]:
                flg=1
for i in range(len(B)):
    if B[i]==a[0]:
        for j in range(len(B)):
            if B[j]==a[1]:
                flg=1
if flg==1:
    print("YES")
else:
    print("NO")

Fixed code:
import sys
a=list(map(int,input().split()))
flg=0
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
for i in range(len(A)):
    if A[i]==a[0]:
        for j in range(len(A)):
            if A[j]==a[1]:
                flg=1
for i in range(len(B)):
    if B[i]==a[0]:
        for j in range(len(B)):
            if B[j]==a[1]:
                flg=1
if flg==1:
    print("Yes")
else:
    print("No")
Buggy code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

d=input().strip().split(" ")
e=[int(i) for i in d]

if e[0] and e[1] in a:
    print("Yes")

elif e[0] and e[1] in b:
    print("Yes")

elif e[0] and e[1] in c:
    print("Yes")

else:
    print("No")


Fixed code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

d=input().strip().split(" ")
e=[int(i) for i in d]

if (e[0] in a and e[1] in a):
    print("Yes")

elif e[0] in b and e[1] in b:
    print("Yes")

elif e[0] in c and e[1] in c:
    print("Yes")

else:
    print("No")
Buggy code:
x,y=int(map,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
print("Yes" if x in a and y in a or x in b and y in b or x==2 and y==2 else "No)

Fixed code:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
print("Yes" if x in a and y in a or x in b and y in b or x==2 and y==2 else "No")
Buggy code:
a,b=map(int,input().split())

if a==b==2:
    print("Yes")
elif a==1or 3 or 5 or 7 or 8 or 10 or 12 and b==1or 3 or 5 or 7 or 8 or 10 or 12:
    print("Yes")
elif a==4 or 6 or 9 or 11 and  b==4 or 6 or 9 or 11:
    print("Yes")
else:
    print("No")
    

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


if (a==1or a==3 or a==5 or a==7 or a==8 or a==10 or a==12) and (b==1or b==3 or b==5 or b==7 or b==8 or b==10 or b==12):
    print("Yes")
elif (a==4 or a==6 or a==9 or a==11) and (b==4 or b==6 or b==9 or b==11):
    print("Yes")
else:
    print("No")
Buggy code:
data = input().split()
x = int(data[0])
y = int(data[1])

L1 = [1,3,5,7,8,10,12]
L2 = [4,6,9,11]
L3 = [2]

print(L1)
print(L2)
print(L3)

if((x in L1 and y in L1) or (x in L2 and y in L2) or (x in L3 and y in L3)):
	print("Yes")
else:
	print("No")


Fixed code:
data = input().split()
x = int(data[0])
y = int(data[1])

L1 = [1,3,5,7,8,10,12]
L2 = [4,6,9,11]
L3 = [2]

if((x in L1 and y in L1) or (x in L2 and y in L2) or (x in L3 and y in L3)):
	print("Yes")
else:
	print("No")
Buggy code:
x,y=map(int,input().split())
G=121313113131
print(["No","Yes"][G[x-1]==G[y-1]])

Fixed code:
x,y=map(int,input().split())
G="121313113131"
print(["No","Yes"][G[x-1]==G[y-1]])
Buggy code:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
if a.count(x)==a.count(y):
    print("Yes")
elif b.count(x)==b.count(y):
    print("Yes")
else:
    print("No")


Fixed code:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
if a.count(x)==1 and a.count(y)==1:
    print("Yes")
elif b.count(x)==1 and b.count(y)==1:
    print("Yes")
else:
    print("No")
Buggy code:
a,b=map(int,input().split())
if a==2:
 A==2
elif a==4 or a==6 or a==9 or a==11:
 A==1
else:
 A==3
if b==2:
 B==2
elif B==4 or B==6 or B==9 or B==11:
 B==1
else:
 B==3
if A==b:
 print("Yes")
else:
 print("No")

Fixed code:
a,b=map(int,input().split())
if a==2:
 A=2
elif a==4 or a==6 or a==9 or a==11:
 A=1
else:
 A=3
if b==2:
 B=2
elif b==4 or b==6 or b==9 or b==11:
 B=1
else:
 B=3
if A==B:
 print("Yes")
else:
 print("No")
Buggy code:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]
if ((x and y) in a) or ((x and y) in b) or ((x and y) in c):
  print("Yes")
else:
  print("No")

Fixed code:
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")
Buggy code:
X, Y = map(int, input().split())
A = [2]
B = [4, 6, 9, 11]
C = [1, 3, 5, 7, 8, 10, 12]
print(["No", "Yes"][(X in A and Y in A)or(X in B and Y in B)or(X in C and Y in B)])


Fixed code:
X, Y = map(int, input().split())
A = [2]
B = [4, 6, 9, 11]
C = [1, 3, 5, 7, 8, 10, 12]
print(["No", "Yes"][(X in A and Y in A)or(X in B and Y in B)or(X in C and Y in C)])
Buggy code:
import sys

def solve():
    x, y = map(int, input().split())

    if x in [1,3,5,7,8,10,12] and y in [1,3,5,7,8,10,12]:
        print("Yes")
    elif x in [4,6,9,11] and y in [4,6,9,11]:
        print("Yes")
    elif x in [2] and y in [2]:
        print("Yes")
    else:
        print("no")

if __name__ == '__main__':
    solve()

Fixed code:
import sys

def solve():
    x, y = map(int, input().split())

    if x in [1,3,5,7,8,10,12] and y in [1,3,5,7,8,10,12]:
        print("Yes")
    elif x in [4,6,9,11] and y in [4,6,9,11]:
        print("Yes")
    elif x in [2] and y in [2]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    solve()
Buggy code:
x,y = map(int,input().split())

group1 = list(1,3,5,7,8,10,12)
group2 = list(4,6,9,11)

if x in group1 and y in group1:
  print('Yes')
elif x in group2 and y in group2:
  print('Yes')
elif x == y == 2:
  print('Yes')
else:
  print('No')

Fixed code:
x,y = map(int,input().split())

group1 = [1,3,5,7,8,10,12]
group2 = [4,6,9,11]

if x in group1 and y in group1:
  print('Yes')
elif x in group2 and y in group2:
  print('Yes')
elif x == y == 2:
  print('Yes')
else:
  print('No')
Buggy code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

x,y=map(int,input().split())

def jj(n):
        if n in a:
            return 1
        if n in b:
            return 2
        if n in c:
            return 3

if jj(x)==jj(y):
    print("yes")
else:
    print("no")

Fixed code:
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

x,y=map(int,input().split())

def jj(n):
        if n in a:
            return 1
        if n in b:
            return 2
        if n in c:
            return 3

if jj(x)==jj(y):
    print("Yes")
else:
    print("No")
Buggy code:
x, y = map(int,input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]

if x in a and y in b:
  print("Yes")
elif x in b and y in b:
  print("Yes")
else:
  print("No")

Fixed code:
x,y = map(int,input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
else:
    print("No")
Buggy code:
x, y = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()
#x, y = input().split()

ls = [4,6,9,11]

if (ls.count(x) == 1 and ls.count(y) == 1) or (x == 2 and y == 2):
  print("Yes")
else:
  print("No")

Fixed code:
x, y = map(int,input().split())
#ls = list(map(int,input().split()))
#r = int(input())
#s = input()
#x, y = input().split()

ls = [4,6,9,11]

if (ls.count(x) == 1 and ls.count(y) == 1) or (x == 2 and y == 2) or (ls.count(x) != 1 and x != 2 and y != 2 and ls.count(y) != 1):
  print("Yes")
else:
  print("No")
Buggy code:
x, y = (int(x) for x in input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x, y in a) or (x, y in b) or (x, y in c):
    print('Yes')
else:
    print('No')


Fixed code:
x, y = (int(x) for x in input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if ((x in a) and (y in a)) or ((x in b) and (y in b)) or ((x in c) and(y in c)):
    print('Yes')
else:
    print('No')
Buggy code:
x,y = map(int,input().split())

li =[[1,3,5,7,8,10,12],[4,6,9,11],[2]]

for i in li:
    if x and y in i:
        print("Yes")
        sys.exit()
print("No")

Fixed code:

x,y = map(int,input().split())
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
    if x  in i and y in i:
        print("Yes")
        exit()
print("No")
Buggy code:
x,y = map(int,input().split())
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
    if x and y in i:
        print("Yes")
        exit()
print("No")

Fixed code:
# coding: utf-8
x,y = map(int,input().split())
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
    if x  in i and y in i:
        print("Yes")
        exit()
print("No")
Buggy code:
# coding: utf-8
x,y = map(int,input().split())
li = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
for i in li:
    if x and y in i:
        print("Yes")
        exit()
print("No")

Fixed code:
# coding: utf-8
gl=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x,y=map(int,input().split())
for g in gl:
    if x in g and y in g:
        print('Yes')
        exit()
print('No')
Buggy code:
h,w = map(int,input().split())
ans = h*w
for i in range(1,h-1):
    A = w*i
    if w%2 == 0 or h-1%2 == 0:
        B = (h-i)*w//2
        C = (h-i)*w//2
    else:
        if h-1 < w:
            B = (h-i)*((w//2)+1)
            C = (h-i)*(w//2)
        else:
            B = ((h-i)//2 + 1) * w
            C = (h-i)//2 * w
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))

for i in range(1,w-1):
    A = h*i
    if w%2 == 0 or h-1%2 == 0:
        B = (w-i)*h//2
        C = (w-i)*h//2
    else:
        if w-1 < h:
            B = (w-i)*((h//2)+1)
            C = (w-i)*(h//2)
        else:
            B = ((w-i)//2 + 1) * h
            C = (w-i)//2 * h
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))
print(ans)

Fixed code:
h,w = map(int,input().split())
ans = h*w
for i in range(1,h):
    A = w*i
    if w%2 == 0 or (h-i)%2 == 0:
        B = ((h-i)*w)//2
        C = ((h-i)*w)//2
    else:
        if h-i <= w:
            B = (h-i)*((w//2)+1)
            C = (h-i)*(w//2)
        else:
            B = ((h-i)//2 + 1) * w
            C = ((h-i)//2) * w
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))

for i in range(1,w):
    A = h*i
    if (w-i)%2 == 0 or h%2 == 0:
        B = ((w-i)*h)//2
        C = ((w-i)*h)//2
    else:
        if w-i <= h:
            B = (w-i)*((h//2)+1)
            C = (w-i)*(h//2)
        else:
            B = ((w-i)//2 + 1) * h
            C = ((w-i)//2) * h
    ans = min(ans,max(A,max(B,C)) - min(A,min(B,C)))
print(ans)
Buggy code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def core(h, H, W):
    if W % 2 == 0:
        return abs(h * W - (H - h) * (W // 2))
    else:
        a, b, c = h * W, (H - h) * (W // 2), (H - h) * (W // 2 + 1)
        return max(abs(a - b), abs(b - c), abs(c - a))


def solve(H, W):
    ans = abs((H // 3) * W - ((H + 2) // 3) * W)
    ans = min(ans, core(H // 3, H, W))

    return ans


def main():
    H, W = map(int, readline().split())

    ans = min(solve(H, W), solve(W, H))

    print(ans)
    return


if __name__ == '__main__':
    main()


Fixed code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def core(h, H, W):
    if W % 2 == 0:
        return abs(h * W - (H - h) * (W // 2))
    else:
        a, b, c = h * W, (H - h) * (W // 2), (H - h) * (W // 2 + 1)
        return max(abs(a - b), abs(b - c), abs(c - a))


def solve(H, W):
    ans = abs((H // 3) * W - ((H + 2) // 3) * W)

    if H % 3 == 0:
        ans = min(ans, core(H // 3, H, W))
    else:
        ans = min(ans, core(H // 3, H, W), core(H // 3 + 1, H, W))

    return ans


def main():
    H, W = map(int, readline().split())

    ans = min(solve(H, W), solve(W, H))

    print(ans)
    return


if __name__ == '__main__':
    main()
Buggy code:
def answer(H,W,ans):
    for x in range(1,W):
        y1 = H // 2
        Sa1 = H * x
        Sb1 = (W - x) * y1
        Sc1 = (W - x) * (H - y1)
        M = max(Sa1,Sb1,Sc1)
        m = min(Sa1,Sb1,Sc1)

        y2 = (W - x) // 2
        Sa2 = H * x
        Sb2 = H * y2
        Sc2 = H * (W - x - y2)
        M2 = max(Sa2,Sb2,Sc2)
        m2 = min(Sa2,Sb2,Sc2)

        if ans > min(M-m,M2-m2):
            ans = min(M-m,M2-m2)

        return ans

if __name__ == '__main__':
    H,W = [int(i) for i in input().split()]
    ans = H * W
    ans = answer(H,W)
    
    H,W = W,H

    if answer(H,W) < ans:
        ans = answer(H,W)

    print(ans)


Fixed code:
def answer(H,W,ans_kari):

    for x in range(1,W):
        y1 = H // 2
        Sa1 = H * x
        Sb1 = (W - x) * y1
        Sc1 = (W - x) * (H - y1)
        M = max(Sa1,Sb1,Sc1)
        m = min(Sa1,Sb1,Sc1)

        y2 = (W - x) // 2
        Sa2 = H * x
        Sb2 = H * y2
        Sc2 = H * (W - x - y2)
        M2 = max(Sa2,Sb2,Sc2)
        m2 = min(Sa2,Sb2,Sc2)

        if ans_kari > min(M-m,M2-m2):
            ans_kari = min(M-m,M2-m2)

    return ans_kari

if __name__ == '__main__':
    H,W = [int(i) for i in input().split()]
    ans = H * W
    ans = answer(H,W,ans)
    
    H,W = W,H

    if answer(H,W,ans) < ans:
        ans = answer(H,W,ans)

    print(ans)
Buggy code:
H,W = [int(i) for i in input().split()]
ans = 0

for x in range(1,W):
    y = H // 2
    Sa1 = H * x
    Sb1 = (W - x) * y
    Sc1 = (W - x) * (H - y)
    M = max(Sa1,Sb1,Sc1)
    m = min(Sa1,Sb1,Sc1)

    Sa2 = H * x
    Sb2 = H * y
    Sb2 = H * (W - x - y)
    M2 = max(Sa2,Sb2,Sc2)
    m2 = min(Sa2,Sb2,Sc2)

    if ans > min(M-m,M2-m2):
        ans = min(M-m,M2-m2)

print(ans)


Fixed code:
H,W = [int(i) for i in input().split()]
ans = H * W

for x in range(1,W):
    y1 = H // 2
    Sa1 = H * x
    Sb1 = (W - x) * y1
    Sc1 = (W - x) * (H - y1)
    M = max(Sa1,Sb1,Sc1)
    m = min(Sa1,Sb1,Sc1)

    y2 = (W - x) // 2
    Sa2 = H * x
    Sb2 = H * y2
    Sc2 = H * (W - x - y2)
    M2 = max(Sa2,Sb2,Sc2)
    m2 = min(Sa2,Sb2,Sc2)

    if ans > min(M-m,M2-m2):
        ans = min(M-m,M2-m2)

H,W = W,H
for x in range(1,W):
    y = H // 2
    Sa1 = H * x
    Sb1 = (W - x) * y
    Sc1 = (W - x) * (H - y)
    M = max(Sa1,Sb1,Sc1)
    m = min(Sa1,Sb1,Sc1)

    y2 = (W - x) // 2
    Sa2 = H * x
    Sb2 = H * y2
    Sc2 = H * (W - x - y2)
    M2 = max(Sa2,Sb2,Sc2)
    m2 = min(Sa2,Sb2,Sc2)

    if ans > min(M-m,M2-m2):
        ans = min(M-m,M2-m2)

print(ans)
Buggy code:
h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    if h > w:
        h, w = w, h
    ans = h
    if h % 2 == 0:
        h1 = h // 2
        for w1 in range(w//2+1):
            s2 = h1 * w1
            s3 = h1 * (w-w1)
            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    else:
        for w1 in range(w//3, w//2 + 1):
            s1 = w1 * h
            w2 = w-w1
            for h1 in range(h//2 + 1):
                s2 = w2 * h1
                s3 = w2 * (h-h1)
                ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    print(ans)

Fixed code:
h, w = map(int, input().split())
if h % 3 == 0 or w % 3 == 0:
    print(0)
else:
    if h > w:
        h, w = w, h
    ans = h
    for w1 in range(w//3-2, w//3+3):
        s1 = w1 * h
        w2 = w-w1
        for h1 in range(h//2 + 1):
            s2 = w2 * h1
            s3 = w2 * (h-h1)
            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    h, w = w, h
    for w1 in range(w//3-2, w//3+3):
        s1 = w1 * h
        w2 = w-w1
        for h1 in range(h//2 + 1):
            s2 = w2 * h1
            s3 = w2 * (h-h1)
            ans = min(ans, max(s1, s2, s3) - min(s1, s2, s3))
    print(ans)
Buggy code:
h, w = map(int, input().split())
min_diff = float('inf')
for i in range(1, h + 1):
    sa = i * w
    sb = (h - i) * (w // 2)
    sc = (h - i) * (w - (w // 2))
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
h, w = w, h
for i in range(1, h + 1):
    sa = i * w
    sb = (h - i) * (w // 2)
    sc = (h - i) * (w - (w // 2))
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
print(min_diff)

Fixed code:
h, w = map(int, input().split())
min_diff = float('inf')
for i in range(1, h + 1):
    sa = i * w
    sb = (h - i) * (w // 2)
    sc = (h - i) * (w - (w // 2))
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
    sb = (h - i) // 2 * w
    sc = (h - i - (h - i) // 2) * w
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
h, w = w, h
for i in range(1, h + 1):
    sa = i * w
    sb = (h - i) * (w // 2)
    sc = (h - i) * (w - (w // 2))
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
    sb = (h - i) // 2 * w
    sc = (h - i - (h - i) // 2) * w
    min_diff = min(min_diff, max(sa, sb, sc) - min(sa, sb, sc))
print(min_diff)
Buggy code:
h,w=map(int,input().split())
if h%3==0 or w%3==0:
    print(0)
elif h%2==0:
    mini=h*w
    for i in range(1,w):
        if max(i*h//2,(w-i)*h) - min(i*h//2,(w-i)*h) < mini:
            mini = max(i*h//2,(w-i)*h) - min(i*h//2,(w-i)*h)
    print(mini)
elif w%2==0:
    mini=h*w
    for i in range(1,h):
        if max(i*w//2,(h-i)*w) - min(i*w//2,(h-i)*w) < mini:
            mini = max(i*w//2,(h-i)*w) - min(i*w//2,(h-i)*w)
    print(mini)
else:
    mini=h*w
    for i in range(1,w):
        if max(i*(h+1)//2,h*(w-i)) - min(i*(h-1)//2,h*(w-i)) < mini:
            mini = max(i*(h+1)//2,h*(w-i)) - min(i*(h-1)//2,h*(w-i))
    for i in range(1,h):
        if max(i*(w+1)//2,w*(h-i)) - min(i*(w-1)//2,w*(h-i)) < mini:
            mini = max(i*(w+1)//2,w*(h-i)) - min(i*(w-1)//2,w*(h-i))        
    print(mini)

Fixed code:
h,w=map(int,input().split())
mini=h*w
for i in range(1,h):
    if mini > max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i):
        mini = max(w*(h-i),(w//2+w%2)*i) - min(w*(h-i),(w//2)*i)

for i in range(1,w):
    if mini > max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i):
        mini = max(h*(w-i),(h//2+h%2)*i) - min(h*(w-i),(h//2)*i)

if h%3 == 0 or w%3 == 0:
    mini=0
else:
    if mini > h:
        mini = h
    elif mini > w:
        mini = w
    else:
        pass
print(mini)