Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())


def gcd(a, b, c):
    mi = min(a, b, c)
    for k in range(mi, 0, -1):
        if a % k == 0 and b % k == 0 and c % k == 0:
            return k


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(a, b, c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import math
K = int(input())


def gcd(a, b, c):
    mi = min(a, b, c)
    for k in range(mi, 0, -1):
        if a % k == 0 and b % k == 0 and c % k == 0:
            return k


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(a, b, c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import math
K = int(input())


def gcd(a, b, c):
    for k in range(K, 0, -1):
        if a % k == 0 and b % k == 0 and c % k == 0:
            return k


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(a, b, c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
import math
K = int(input())


def gcd(*numbers):
    return reduce(math.gcd, numbers)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(a, b, c)

print(ans)


Fixed submission:
from fractions import gcd
K = int(input())


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


ans = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            ans += gcd(gcd(a, b), c)

print(ans)