Buggy python submission (verdict: Time Limit Exceeded):
import itertools 
import math
from functools import reduce

num = int(input())
a_list = [i for i in range(1,num+1)]
comb_list = list(itertools.product(a_list, repeat=3))

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

print(sum([gcd_list(x) for x in comb_list]))

Fixed submission:
import itertools 
import math
from functools import reduce


num = int(input())

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

if num<=2:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.product(a_list, repeat=3))
    print(sum([gcd_list(x) for x in comb_list]))

else:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.combinations_with_replacement(a_list, 3))
    test = sum([gcd_list(x) for x in comb_list])*3

    comb_list_dup = [[i, i, i] for i in a_list]
    duplica = sum([gcd_list(x) for x in comb_list_dup])*2

    comb_list_unique = list(itertools.combinations(a_list, 3))
    unique = sum([gcd_list(x) for x in comb_list_unique])*3
    print(test-duplica+unique)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools 
import copy
import math
from functools import reduce

num = int(input())
a_list = [i for i in range(1,num+1)]
comb_list = list(itertools.product(a_list, repeat=3))

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

print(sum([gcd_list(list(x)) for x in comb_list]))

Fixed submission:
import itertools 
import math
from functools import reduce


num = int(input())

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

if num<=2:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.product(a_list, repeat=3))
    print(sum([gcd_list(x) for x in comb_list]))

else:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.combinations_with_replacement(a_list, 3))
    test = sum([gcd_list(x) for x in comb_list])*3

    comb_list_dup = [[i, i, i] for i in a_list]
    duplica = sum([gcd_list(x) for x in comb_list_dup])*2

    comb_list_unique = list(itertools.combinations(a_list, 3))
    unique = sum([gcd_list(x) for x in comb_list_unique])*3
    print(test-duplica+unique)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools 
import copy
import math
from functools import reduce

num = int(input())
a_list = [i for i in range(1,num+1)]
b_list = a_list.copy()
c_list = a_list.copy()
comb_list = list(itertools.product(a_list,b_list,c_list))

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

sum_yaku = 0
for i in comb_list:
    num_list = list(i)
    sum_yaku += gcd_list(num_list)
print(sum_yaku)

Fixed submission:
import itertools 
import math
from functools import reduce


num = int(input())

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

if num<=2:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.product(a_list, repeat=3))
    print(sum([gcd_list(x) for x in comb_list]))

else:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.combinations_with_replacement(a_list, 3))
    test = sum([gcd_list(x) for x in comb_list])*3

    comb_list_dup = [[i, i, i] for i in a_list]
    duplica = sum([gcd_list(x) for x in comb_list_dup])*2

    comb_list_unique = list(itertools.combinations(a_list, 3))
    unique = sum([gcd_list(x) for x in comb_list_unique])*3
    print(test-duplica+unique)