qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a = input()
aList = []
for i in range(1,int(a)+1):
    if i%3 == 0 and i%5 == 0:
        print('FizzBuzz')
    elif i%3 == 0:
        print('Fizz')
    elif i%5 == 0:
        print('Buzz')
    else:
        aList.append(i)
        print(i)
ans = 0
for _,b in enumerate(aList):
    ans = ans + b
print(ans)


Fixed code:
a = input()
aList = []
for i in range(1,int(a)+1):
    if i%3 == 0 and i%5 == 0:
        pass
        # print('FizzBuzz')
    elif i%3 == 0:
        pass
        # print('Fizz')
    elif i%5 == 0:
        pass
        # print('Buzz')
    else:
        aList.append(i)
        # print(i)
ans = 0
for _,b in enumerate(aList):
    ans = ans + b
print(ans)
Buggy code:
n = int(input())
for i in range(1, n+1):
    if 0 != i%3 and 0 != i%5:
        ans += i
print(ans)

Fixed code:
n = int(input())
s = 0
for i in range(1,n+1):
	if i%3 != 0 and i%5 != 0:
		s = s + i
print(s)
Buggy code:
# coding: utf-8
 
N  = int(input())
sum = 0
 
for i in range(N):
    if ( i % 3 != 0 or i % 5 != 0):
        sum += i
 
print(sum)

Fixed code:
#coding: utf-8
 
N  = int(input())
sum = 0
 
for i in range(N+1):
    if ( i % 3 != 0):
        if (i % 5 != 0):
           sum += i
 
print(sum)
Buggy code:
A = int(input())
total = 0L
for x in range(A+1):
  if x%5!=0 and x%3!=0:
    total += x
print(x)

Fixed code:
A = int(input())
total = 0
for x in range(A+1):
  if x%5!=0 and x%3!=0:
    total += x
print(total)
Buggy code:
n = int(input())

for i in range(1, n+1):
    if i%3==0 or i%5==0:
        sum += i
print(sum)

Fixed code:
n = int(input())

sum = 0
for i in range(1, n+1):
    if not(i%3==0 or i%5==0):
        sum += i
print(sum)
Buggy code:
n = int(input())

fb = long(0)
for i in range(n):
    if(i%5 != 0 and i%3 != 0):
        fb = fb + i

print(fb)

Fixed code:
n = int(input())

fb = 0
for i in range(n+1):
    if(i%5 != 0 and i%3 != 0):
        fb = fb + i

print(fb)
Buggy code:
N=int(input())
sum_ = 0
for i in range(1,N+1):
  if (i % 3 != 0) and (i % 5 != 0):
    sum_ += 1
print(sum_)

Fixed code:
N=int(input())
sum_ = 0
for i in range(1,N+1):
  if (i % 3 != 0) and (i % 5 != 0):
    sum_ += i
print(sum_)
Buggy code:
i = int(input())
fizz=[]
for x in range(1, i+1):
  if x % 3 ==0 and x%5==0:
    continue
  elif x % 3==0:
    continue
  elif x%5==0:
    continue 
  else:
    fizz.append(x)
print(fizz)
print(sum(fizz))

Fixed code:
i = int(input())
fizz=[]
for x in range(1, i+1):
  if x % 3 ==0 and x%5==0:
    continue
  elif x % 3==0:
    continue
  elif x%5==0:
    continue 
  else:
    fizz.append(x)
print(sum(fizz))
Buggy code:
print(sum([i for i in range(int(input()+1)) if (i % 3 != 0 and i % 5 != 0)]))


Fixed code:
print(sum([i for i in range(int(input())+1) if (i % 3 != 0 and i % 5 != 0)]))
Buggy code:
N = int(input())

total = 0
for i in range(N):
  if i % 3 != 0 and i % 5 != 0:
    total += i + 1
print(total)

Fixed code:
N = int(input())

total = 0
for i in range(1, N+1):
  if i % 3 != 0 and i % 5 != 0:
    total += i
print(total)
Buggy code:
N = int(input())
cnt += 0
for i in range(N):
  if i%5!=0 and i%3!=0:
    cnt += i
print(cnt)

Fixed code:
N = int(input())
cnt = 0
for i in range(N+1):
    if i%5!=0 and i%3!=0:
        cnt += i
print(cnt)
Buggy code:
N=int(input())
ans=0
for i in range (N+1):
  if i%3!=0 and i%5!=0:
    ans+=0
print(ans)

Fixed code:
N = int(input())

ans = 0

for i in range(1, N+1):
  if i % 15 != 0 and i % 3 != 0 and i % 5 != 0:
    ans = ans + i

print(ans)
Buggy code:
n=int(input())
ans = 0
for i in range(n+1):
	if a%3 != 0 and a%5 !=0:
  		ans += i
print(ans)
  
  


Fixed code:
n = int(input())

ans = 0
for i in range(1, n + 1):
    if (i % 3 != 0) and (i % 5 != 0):
        ans += i

print(ans)
Buggy code:
N = int(input())
FBSum = 0
for i in N:
    j = i+1
    if j % 3 != 0 and j % 5 != 0:
    FBSum +=j

print(FBSum)

Fixed code:
N = int(input())
FBSum = 0
for i in range(N):
    j = i+1
    if j % 3 != 0 and j % 5 != 0:
        FBSum +=j

print(FBSum)
Buggy code:
a=int(input())
ans = 0
for i in range(a+1)
if a%3 != 0 and a%5 !=0:
  ans += i
print(ans)
  
  


Fixed code:
N = int(input())
ans = 0
for i in range(N+1):
    if i % 3 != 0 and i % 5 != 0:
        ans += i 
print(ans)
Buggy code:
n = int(input())
sum = 0

for i in range(n):
  if i % 15 == 0:
    pass
  elif 1 % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    sum += i
  
print(sum)

Fixed code:
n = int(input())
sum = 0

for i in range(n+1):
  if i % 15 == 0:
    pass
  elif i % 3 == 0:
    pass
  elif i % 5 == 0:
    pass
  else:
    sum += i
  
print(sum)
Buggy code:
N = int(input())
A = 0
for i in range(1,N+1):
    if(i % 3 !=0) and (i % 5 !=0):
        A+=1
        
print(A)

Fixed code:
N=int(input())
a=0
for i in range(1,N+1):
    if i%3!=0 and i%5!=0:
        a+=i
print(a)
Buggy code:
n = int(input())
sum = 0
for i in range(n):
    if i%5!=0 and i%3=0:
        sum = sum + 1
print(sum)

Fixed code:
n = int(input())
sum = 0
for i in range(1,n+1):
    if i%5!=0 and i%3!=0:
        sum = sum + i
print(sum)
Buggy code:
N=int(input())
B=0
for i in range(N):
    if (i+1)%3!=0 and (i+1)%5==0:
        B=i+B
        print(B)
        
        
       
        

Fixed code:
N = int(input())

count = 0

for i in range(N + 1):
    if i % 3 != 0 and i % 5 != 0:
        count += i

print(count)
Buggy code:
N = int(input())

sumsum = 0
for i in range(N):
    
    val = i+1
    if val % 3 == 0 & val % 5 == 0:
        
        print('FizzBuzz')
    
    elif val % 3 == 0:
        
        print('Fizz')
    
    elif val % 5 == 0:
        
        print('Buzz')
        
    else:
        
        sumsum += val
        
print(sumsum)

Fixed code:
N = int(input())

sumsum = 0
for i in range(N):
    
    val = i+1
    if val % 3 == 0 & val % 5 == 0:
        
        pass
        #print('FizzBuzz')
    
    elif val % 3 == 0:
        
        pass
        #print('Fizz')
    
    elif val % 5 == 0:
        
        pass
        #print('Buzz')
        
    else:
        
        sumsum += val
        
print(sumsum)
Buggy code:
N = int(input())

import math
 
a = N // 3
b = N // 5
c = N // 15
 
d = 3*a*(a+1)/2
e = 3*b*(b+1)/2
f = 3*c*(c+1)/2
 
g = N*(N+1)/2
 
print(math.floor(g-d-e+f))

Fixed code:
N = int(input())

import math
 
a = N // 3
b = N // 5
c = N // 15
 
d = 3*a*(a+1)/2
e = 5*b*(b+1)/2
f = 15*c*(c+1)/2
 
g = N*(N+1)/2
 
print(math.floor(g-d-e+f))
Buggy code:
N = int(input())
a = 0
for i in range(N):
  x =i+1
  if x%3!=0 andx%5!=0:
    a+=x
print(x)

Fixed code:
N = int(input())
a = 0
for i in range(N):
  x =i+1
  if x%3!=0 and x%5!=0:
    a+=x
print(a)
Buggy code:
a=int(input())
b=((a//3)*(3+(3*(a//3))))*(1/2)
c=((a//5)*(5+(5*(a//5))))*(1/2)
d=((a//15)*(15+(15*(a//15))))*(1/2)
e=(a(1+a)*(1/2))-(b+c-d)
print(e)

Fixed code:
a=int(input())
b=((a//3)*(3+(3*(a//3))))*(1/2)
c=((a//5)*(5+(5*(a//5))))*(1/2)
d=((a//15)*(15+(15*(a//15))))*(1/2)
e=(a*(1+a)*(1/2))-(b+c-d)
print(int(e))
Buggy code:
N=int(input())
s=0
for i in range(1,N+1):
  print(i)
  if i%3!=0 and i%5!=0:
    s+=i
print(s)

Fixed code:
N = int(input())
summ = 0

for i in range(1, N + 1):
    if (i % 3 != 0 and i % 5 != 0):
        summ += i

print(summ)
Buggy code:
input = int(input())
a = []
while(i <= input):
  if i%3 == 0 or i%5 == 0:
    pass
  else:
    a.append(i)
  i += 1
sum = 0
for j in a:
    sum = sum + a[j]
print(sum)



Fixed code:
input = input()
a = []
i = 1
while(i <= int(input)):
    if i%3 == 0 or i%5 == 0:
        pass
    else:
        a.append(i)
    i += 1
res = 0
for j in a:
  res = res + j
print(res)
Buggy code:
N = input()
xx= 0
for i in range(1,N+1):
    if((i%3!=0)&(i%5!=0)):
        xx += i
print(xx)

Fixed code:
N = int(input())
xx= 0
for i in range(1,N+1):
    if((i%3!=0)&(i%5!=0)):
        xx += i
print(xx)
Buggy code:
n = int(input())
ans = 0
for i in range(n):
  if n % 3 != 0 and n % 5 != 0:
    ans += i
print(ans)

Fixed code:
n = int(input())
ans = 0
for i in range(n):
  if (i+1) % 3 != 0 and (i+1) % 5 != 0:
    ans += i+1
print(ans)
Buggy code:
N = int(input())
sum = 0
for i in range(N+1):
  if(i % 3 != 0 and i % 5 != 0):
    sum += i
  
  if(i > )

Fixed code:
N = int(input())
sum = 0
for i in range(N+1):
  if(i % 3 != 0 and i % 5 != 0):
    sum += i

print(sum)
Buggy code:
n = int(input())
sum = 0
for x in range(1,n+1):
  if x % 3 != 0 and x % 5 != 0:
    sum += n
print(sum)

Fixed code:
n = int(input())
sum = 0
for x in range(1,n+1):
  if x % 3 != 0 and x % 5 != 0:
    # print(x)
    sum += x
print(sum)
Buggy code:
n = int(input())
tmp = n // 15
tmp2 = n % 15
d = [(15*(tmp) + i) for i in [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14]]
for i in [0,3,5,6,9,10,12]:
    d[i] = 0
(tmp **2 * 60) + sum(d[:(tmp2+1)])

Fixed code:
n = int(input())
tmp = n // 15
tmp2 = n % 15
d = [(15*(tmp) + i) for i in [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14]]
for i in [0,3,5,6,9,10,12]:
    d[i] = 0
print((tmp **2 * 60) + sum(d[:(tmp2+1)]))
Buggy code:
N = int(input())

res = 0
for i in range(3, N+1):
  if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
    continue
  res += i

print(res)

Fixed code:
N = int(input())

res = 0
for i in range(1, N+1):
  if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
    continue
  res += i

print(res)
Buggy code:
n = int(input())
sum = 0
for i in range(n+1):
    if not (i % 3 == 0 and i % 5 ==0):
        sum += i
print(sum)


Fixed code:
n = int(input())
sum = 0
for i in range(n+1):
    if not (i % 3 == 0 or i % 5 ==0):
        sum += i
print(sum)
Buggy code:
S = int(input())

print(sum([i+1 for i in range(S) if not (i%3==0 or i%5==0 )]))

Fixed code:
S = int(input())


print(sum([i+1 for i in range(S) if not ((i+1)%3==0 or (i+1)%5==0 )]))
Buggy code:
N = int(input())

total = sum([i for i in range(1,N+1) if i%3!=0 and i%5!=0]
print(total)

Fixed code:
N = int(input())
 
total = sum([i for i in range(1,N+1) if i%3!=0 and i%5!=0])
print(total)
Buggy code:
N = int(input())
A = list(range(N+1))
S = sum(A)

n3 = N // 3
B = list(range(n3+1))
S3 = 3*sum(B)

n5 = N // 5
C = list(range(n5+1))
S5 = 5*sum(C)

n15 = N // 15
D = list(range(n15+1))
S15 = 15*sum(D)

print(S,S3,S5,S15)

print(S-S3-S5+S15)

Fixed code:
N = int(input())
A = list(range(N+1))
S = sum(A)

n3 = N // 3
B = list(range(n3+1))
S3 = 3*sum(B)

n5 = N // 5
C = list(range(n5+1))
S5 = 5*sum(C)

n15 = N // 15
D = list(range(n15+1))
S15 = 15*sum(D)

print(S-S3-S5+S15)
Buggy code:
N = int(input())
ans = 0

for i in range(1,N+1):
  if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
    ans += i

print(ans)


Fixed code:
N = int(input())
ans = 0

for i in range(1,N+1):
  if i % 15 == 0 or i % 3 == 0 or i % 5 == 0:
    continue
  ans += i

print(ans)
Buggy code:
n = int(input())
print(sum([i for i in range(1, n+1) if and i%5 != 0 and i%3 != 0]))

Fixed code:
n = int(input())
print(sum([i for i in range(1, n+1) if i%5 != 0 and i%3 != 0]))
Buggy code:
a=int(input("a"))
b=(sum(range(3,a+1,3)))
c=(sum(range(5,a+1,5)))
d=(sum(range(15,a+1,15)))
e=a*(a+1)/2
print(int(e-b-c+d))

Fixed code:
a=int(input())
b=(sum(range(3,a+1,3)))
c=(sum(range(5,a+1,5)))
d=(sum(range(15,a+1,15)))
e=a*(a+1)/2
print(int(e-b-c+d))
Buggy code:
N = int(input())
out = 0
for in in range(1,N+1):
  if i%3==0 and i%5==0 or i%3==0 or i%5==0
	continue
  out +=i
print(out) 

Fixed code:
N = int(input())
out = 0
for i in range(1,N+1):
    if i%3 == 0 and i%5 == 0 or i%3==0 or i%5==0:
       continue
    out += i
print(out)
Buggy code:
a = int(input())
  
set3 = set(range(0, a+1, 3))
set5 = set(range(0, a+1, 5))
seta = set(range(0, a+1))

print(set3, set5)

print(sum(seta-set3-set5))


Fixed code:
a = int(input())
  
set3 = set(range(0, a+1, 3))
set5 = set(range(0, a+1, 5))
seta = set(range(0, a+1))
 
print(sum(seta-set3-set5))
Buggy code:
N = int(input())
c=0
for i in range (1,N+1):
  if i%15==0:
    c += i//15
  elif i%3==0:
    c += i//3
  elif i%5==0:
    c += i//5
  else:
    c += i
    
print(c)
 
    
  

Fixed code:
N = int(input())
c=0
for i in range (1,N+1):
  if i%15==0:
    c += 0
  elif i%3==0:
    c += 0
  elif i%5==0:
    c += 0
  else:
    c += i
    
print(c)
Buggy code:
x=int(input())
t=0
for i in range(1,x+1):
  print(i)
  if i%3!=0 and i%5!=0:
    t+=i
print(t)


Fixed code:
x=int(input())
t=0
for i in range(1,x+1):
  if i%3!=0 and i%5!=0:
    t+=i
print(t)
Buggy code:
a=input()
total=0
for i in range(1, a):
  if i %5 != 0 and i %3 != 0:
    total += a
print(total)

Fixed code:
a = int(input())
total = 0
for i in range(1, a+1):
  if i % 5 != 0 and i % 3 != 0:
    total += i

print(total)
Buggy code:
total = []

N = int(input())

for i in range(1, N):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        total.append(i)

print(total)


Fixed code:
total = []

N = int(input())

for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        total.append(i)

print(sum(total))
Buggy code:
N = 1000000#int(input())
a = list(range(1,N+1))
N_3 = N//3
N_5 = N//5
for i in range(1,N_3+1):
    a[3*i-1] = 0
for i in range(1,N_5+1):
    a[5*i-1] = 0
print(sum(a))

Fixed code:
N = int(input())
a = list(range(1,N+1))
N_3 = N//3
N_5 = N//5
for i in range(1,N_3+1):
    a[3*i-1] = 0
for i in range(1,N_5+1):
    a[5*i-1] = 0
print(sum(a))
Buggy code:
N = eval(input())
k=0
for i in range(0,N):
  if i%3!=0 or i%5!=0:
   k = k+1
print (k)

Fixed code:
N = eval(input())
k = 0
for i in range(0, N+1):
    if i % 3 != 0 and i % 5 != 0:
        k = k+i
print(k)
Buggy code:
n = int(iniput())
sm = 0
for i in range(1,n+1,1):
  if i%3 and i%5:
    sm+=i
print(sm)

Fixed code:
n = int(input())
sm = 0
for i in range(1,n+1,1):
  if i%3 and i%5:
    sm+=i
print(sm)
Buggy code:
N = int(input())
A = list(range(1, N))
ans = 0
for a in A:
    if (a % 3 == 0 and a % 5 == 0) or (a % 3 == 0) or (a % 3 == 0):
        pass
    else:
        ans += A[a - 1]
print(ans)

Fixed code:
#B
N = int(input())
A = list(range(1, N + 1))
ans = 0
for a in A:
    if (a % 3 == 0) or (a % 5 == 0):
        pass
    else:
        ans += A[a - 1]
print(ans)
Buggy code:
def S(n):
  return n*(n-1)//2

N = int(input())
print(S(N)-S(N//3)*3-S(N//5)*5+S(N//15)*15)

Fixed code:
def S(n):
  return n*(n+1)//2

N = int(input())
print(S(N)-S(N//3)*3-S(N//5)*5+S(N//15)*15)
15
Buggy code:
N = int(input())

sum = 0
for i in range(N):
    j = i + 1
    if (j % 3 != 0) and (j % 5 != 0):
        print(j)
        sum += j

print(sum)


Fixed code:
N = int(input())

sum = 0
for i in range(1, N+1):
  if(i % 3 != 0 and i % 5 != 0):
    sum = sum + i

print(sum)
Buggy code:
n = int(input())

totalsum = []

for i in range(1, n + 1):
    if i % 15 == 0:
        print("FizzBuzz")
    elif i % 5 == 0:
        print("Buzz")
    elif i % 3 == 0:
        print("Fizz")
    else:
        totalsum.append(i)

print(sum(totalsum))

Fixed code:
n = int(input())

total = []

for i in range(1, n + 1):
    if i % 15 == 0:
        "FizzBuzz"
    elif i % 5 == 0:
        "Buzz"
    elif i % 3 == 0:
        "Fizz"
    else:
        total.append(i)

print(sum(total))
Buggy code:
import math

N = int(input())
sum = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            g = math.gcd(i,j)
            sum += math.gcd(g,k)

print(sum)

Fixed code:
import math

N = int(input())
sum = 0

for i in range(N):
    for j in range(N):
        g = math.gcd(i+1,j+1)
        for k in range(N):
            sum += math.gcd(g,k+1)

print(sum)
Buggy code:
K=int(sys.stdin.readline().rstrip())

def gcd(a,b):

    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

cnt1 = 0
cnt2 = 0
cnt3 = 0
for n1 in range(K):
    for n2 in range(K):
        temp = gcd(n1+1, n2+1)
        for n3 in range(K):
            cnt3 += gcd(temp, n3+1)
        

ans = cnt1 + cnt2 + cnt3
print(ans)

Fixed code:
import sys

K=int(sys.stdin.readline().rstrip())
 
def gcd(a,b):

    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

cnt1 = 0
cnt2 = 0
cnt3 = 0
for n1 in range(0,K):
    cnt1 += n1+1
    for n2 in range(n1+1, K):
        temp = gcd(n1+1, n2+1)
        cnt2 += temp*6
        for n3 in range(n2+1, K):
            cnt3 += gcd(temp, n3+1)*6
        

ans = cnt1 + cnt2 + cnt3
print(ans)
Buggy code:
import math

K = int(input())

sum = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            sum += math.gcd(math.gcd(i, j), k)
            
print(sum)

Fixed code:
import math
 
K = int(input())
 
sum = 0
for i in range(K):
    for j in range(K):
        r = math.gcd(i+1, j+1)
        for k in range(K):
            sum += math.gcd(r, k+1)
            
print(sum)
Buggy code:
import math
gcd = math.gcd()
ans = 0
k = int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans += gcd(i,gcd(j,l))
print(ans)


Fixed code:
k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        a=math.gcd(i,j)
        for l in range(1,k+1):
            ans+=math.gcd(a,l)
print(ans)
Buggy code:
import math

    k = int(input())
    ans = 0

    for h in range(1, k+1):
        for i in range(1, k+1):
            l = math.gcd(h, i)
            for j in range(1, k+1):
                ans += math.gcd(l, j)

    print(ans)

Fixed code:
from math import gcd

k = int(input())
ans = 0

for h in range(1, k+1):
    for i in range(1, k+1):
        l = gcd(h, i)
        for j in range(1, k+1):
            ans += gcd(l, j)

print(ans)
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = 200#int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)



Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)
Buggy code:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      eles:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)

Fixed code:
K = int(input())
total = 0

def gdc(x,y):
  if x%y==0:
    return y
  return gdc(y, x%y)

for a in range(K):
  for b in range(a,K):
    for c in range(b,K):
      if a==b and b==c:
        total += gdc(c+1, gdc(b+1, a+1))
      elif a==b or b==c or a==c:
        total += 3*gdc(c+1, gdc(b+1, a+1))
      else:
        total += 6*gdc(c+1, gdc(b+1, a+1))
print(total)
Buggy code:
import math
sum = 0
K = int(input())
for k in range(K):
  for j in range(K):
    for i in range(K):
      sum = sum + gcd(math.gcd(k+1,j+1),i+1)
print(sum)

Fixed code:
import math
k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)
Buggy code:
from math import gcd
k = int(input())
gcdl = [[0 for i in range(k + 1)]for i in range(k+1)]
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcdl[i][j] = gcd(i, j)
s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            s += gcdl[i][gcdl[j][k]]

print(s)


Fixed code:
from math import gcd
k = int(input())
gcdl = [[0 for i in range(k + 1)]for i in range(k+1)]
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcdl[i][j] = gcd(i, j)
s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            s += gcdl[i][gcdl[j][l]]

print(s)
Buggy code:
import sys
import numpy as np

N=int(input())
count = 0

for i in range(1,N+1):
    i_ins=[]
    for x in range(1,i+1):
        if i//x != 0 and i%x == 0:
            i_ins.append(x)
    for j in range(1,N+1):
        i_j_ins=[]
        for y in i_ins:
            if j//y != 0 and j%y == 0:
                i_j_ins.append(y)
        if i_j_ins[-1]==1:
            print(i,j,i_j_ins[-1])
            count = count + i_j_ins[-1]*N
        else:
            for k in range(1,N+1):
                i_j_k_ins=[]
                for z in reversed(i_j_ins):
                    if k//z != 0 and k%z == 0:
                        i_j_k_ins.append(z)
                        break
                print(i,j,k,i_j_k_ins[-1])
                count = count + i_j_k_ins[-1]

print(count)

Fixed code:
import sys
import numpy as np

N=int(input())
count = 0

for i in range(1,N+1):
    i_ins=[]
    for x in range(1,i+1):
        if i//x != 0 and i%x == 0:
            i_ins.append(x)
    for j in range(1,N+1):
        i_j_ins=[]
        for y in i_ins:
            if j//y != 0 and j%y == 0:
                i_j_ins.append(y)
        if i_j_ins[-1]==1:
            #            print(i,j,i_j_ins[-1])
            count = count + i_j_ins[-1]*N
        else:
            for k in range(1,N+1):
                i_j_k_ins=[]
                for z in reversed(i_j_ins):
                    if k//z != 0 and k%z == 0:
                        i_j_k_ins.append(z)
                        break
            #    print(i,j,k,i_j_k_ins[-1])
                count = count + i_j_k_ins[-1]

print(count)
Buggy code:
k = int(input())

count = [pow(k // max(i, 1), 3, mod) for i in range(k + 1)]

for i in range(k, 0, -1):
  for j in range(2 * i, k + 1, i):
    count[i] -= count[j]

sum_ = 0
for i in range(k + 1):
  sum_ += i * count[i]

print(sum_)

Fixed code:
k = int(input())

count = [pow(k // max(i, 1), 3) for i in range(k + 1)]

for i in range(k, 0, -1):
  for j in range(2 * i, k + 1, i):
    count[i] -= count[j]

sum_ = 0
for i in range(k + 1):
  sum_ += i * count[i]

print(sum_)
Buggy code:
def main():
    k = int(input())
    gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)]))
    j = 0
    s = list(set(gcds))
    m = k**2-1
    gcdss = [0]*len(s)
    for i, l in enumerate(s):
        while gcds[j] == l:
            j += 1
            gcdss[i] += 1
        if j == m:
            break
    ans = sum([gcd(i, j)*n for i in range(1, k+1) for j, n in zip(s, gcdss)])
    print(ans)
            
    
def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)


if __name__ == "__main__":
    main()

Fixed code:
def main():
    k = int(input())
    gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)]))
    j = 0
    s = list(sorted(list(set(gcds))))
    m = k**2-1
    gcdss = [0]*len(s)
    flag = False
    for i, l in enumerate(s):
        while gcds[j] == l:
            gcdss[i] += 1
            if j == m:
                flag = True
                break
            j += 1
        if flag:
            break
    ans = sum([gcd(i, p)*n for i in range(1, k+1) for p, n in zip(s, gcdss)])
    print(ans)
            
    
def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)


if __name__ == "__main__":
    main()
Buggy code:
def gcd(a,b):
    if a<b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r!=0:
      a = b
      b = r
      r = a % b
    return b
  
def main():
    K = int(input())
    list_ = []
    sum_ = 0
    for i in range(K):
        for j in range(K):
            a = gcd(i,j)
            list_.append(a)
    for i in list_:
        for j in range(K):
            a = gcd(i,j)
            sum_ += a
    print(sum_)

main()
  

Fixed code:
def gcd(a,b):
    if a<b:
        tmp = a
        a = b
        b = tmp
    r = a % b
    while r!=0:
      a = b
      b = r
      r = a % b
    return b
  
def main():
    K = int(input())
    list_ = []
    sum_ = 0
    for i in range(1,K+1):
        for j in range(1,K+1):
            a = gcd(i,j)
            list_.append(a)
    for i in list_:
        for j in range(1,K+1):
            a = gcd(i,j)
            sum_ += a
    print(sum_)

main()