Buggy python submission (verdict: Time Limit Exceeded):
memo = [[[-1] * 201 for j in range(201)] for i in range(201)]

def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(input())
numbers = []

for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

gcd_sum = 0
for number in numbers:
    dup = len(set(number))
    a, b, c = number
    if memo[a][b][c] == -1:
        if dup == 1:
            ans = gcd([gcd([a, b]), c])
        elif dup == 2:
            ans = gcd([gcd([a, b]), c]) * 3
        else:
            ans = gcd([gcd([a, b]), c]) * 6
        memo[a][b][c] = ans
    gcd_sum += memo[a][b][c]

print(gcd_sum)


Fixed submission:
memo = [[[-1] * 201 for j in range(201)] for i in range(201)]

def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(input())
numbers = []

for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

gcd_sum = 0
for number in numbers:
    dup = len(set(number))
    a, b, c = number
    if memo[a][b][c] == -1:
        if dup == 1:
            ans = gcd([gcd([a, b]), c])
        elif dup == 2:
            ans = gcd([gcd([a, b]), c]) * 3
        else:
            ans = gcd([gcd([a, b]), c]) * 6
        memo[a][b][c] = ans
    gcd_sum += memo[a][b][c]

print(gcd_sum)

Buggy python submission (verdict: Time Limit Exceeded):
memo = [
    [
        [ -1 ] * 201
    ] * 201
] * 201

def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(input())
numbers = []
for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

sum = 0
for number in numbers:
    dup = len(set(number))
    if dup == 1:
        sum += gcd([gcd([number[0], number[1]]), number[2]])
    elif dup == 2:
        sum += gcd([gcd([number[0], number[1]]), number[2]]) * 3
    else:
        sum += gcd([gcd([number[0], number[1]]), number[2]]) * 6

print(sum)


Fixed submission:
memo = [[[-1] * 201 for j in range(201)] for i in range(201)]

def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(input())
numbers = []

for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

gcd_sum = 0
for number in numbers:
    dup = len(set(number))
    a, b, c = number
    if memo[a][b][c] == -1:
        if dup == 1:
            ans = gcd([gcd([a, b]), c])
        elif dup == 2:
            ans = gcd([gcd([a, b]), c]) * 3
        else:
            ans = gcd([gcd([a, b]), c]) * 6
        memo[a][b][c] = ans
    gcd_sum += memo[a][b][c]

print(gcd_sum)