Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
S = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            S += math.gcd(math.gcd(a,b),c)
print(S)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
S = 0
for a in range(K):
    for b in range(K):
        for c in range(K):
            S += math.gcd(math.gcd(a+1,b+1),c+1)
print(S)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from math import gcd
K = int(input())
A=[]
B=[]
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        A.append(gcd(a,b))
for x in range(len(A)):
    for c in range(1,K+1):
        B.append(gcd(A[x],c))
for i in range(len(B)):
    sum +=B[i]
print(sum)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from math import gcd
K = int(input())
A=[]
B=[]
for a in range(1,K+1):
    for b in range(1,K+1):
        A.append(gcd(a,b))
for x in range(len(A)):
    for c in range(1,K+1):
        B.append(gcd(A[x],c))
for i in range(len(B)):
    sum +=B[i]
print(sum)


Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from math import gcd
K = int(input())
A=[]
B=[]
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        A.append(gcd(a,b))
for c in range(1,K+1):
    for d in range(1,K+1):
        B.append(gcd(A[c],d))
        sum+=B[c]
print(sum)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
from math import gcd
K = int(input())
A=[]
B=[]
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        A.append(gcd(a,b))
for c in range(1,K+1):
    for d in range(1,K+1):
        B.append(gcd(A[c],d)
        sum+=B[c]
print(sum)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from math import gcd
K = int(input())
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            items = [a,b,c]
            d=reduce(gcd,items)
            sum+=d
print(sum)

Fixed submission:
import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)