Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            tmp = [i,j,k]
            res += reduce(gcd,tmp)
print(res)


Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Runtime Error):
from fractions import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            tmp = [i,j,k]
            res += reduce(gcd,tmp)
print(res)

Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            res += gcd(gcd(i,j),k)
print(res)

Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
 
K = int(input())
 
res = 0
tmp = 0
d = []
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if i == j and j == k:
                res += i
            elif i == j:
                res += gcd(i,k)
            elif i == k:
                res += gcd(j,k)
            elif j == k:
                res += gcd(i,j)
            else:
                res += gcd(gcd(i,j),k)
print(res)

Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

K = int(input())

res = 0
tmp = 0
d = []
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            if i == j and j == k:
                res += i
            elif i == j:
                res += gcd(i,k)
            elif i == k:
                res += gcd(j,k)
            elif j == k:
                res += gcd(i,j)
            else:
                res += gcd(gcd(i,j),k)
print(res)

Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            res += gcd(gcd(i,j),k)
print(res)


Fixed submission:
from math import gcd

K = int(input())

res = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp = gcd(i,j)
        for k in range(1,K+1):
            res += gcd(tmp,k)
print(res)