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

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

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(1,k+1):
        for j in range(1,k+1):
            for l in range(1,k+1):
                #print(i,j,l)
                sum = sum + gcd(i,j,l)
    print(sum)

if __name__ == '__main__':
    main()

Fixed submission:
import math

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(k):
        for j in range(k):
            for l in range(k):
                sum = sum + math.gcd(math.gcd(i+1 ,j+1), l+1)
    print(sum)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, combinations,combinations_with_replacement,product
import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    for i in range(k):
        for j in range(k):
            for l in range(k):
                lists.append((i+1,j+1,l+1))
    
    #for v in combinations_with_replacement(lists,3):
    #    print(v)
    #lists = list(combinations_with_replacement(lists,3))
    #lists2 = set(lists)
    #print(lists)
    #lists2 = [i[0]*100+i[1]*10+i[2] for i in lists]
    #print(lists2)
    k = 0
    for i in lists:
        k = k + gcd(i[0],i[1],i[2])
    print(k)
    """
    koubai = 0
    for i in lists:
        if len(set(i))==1:
            koubai = koubai + gcd(i[0],i[1],i[2])
            #print(koubai)
        elif len(set(i))==2:
            koubai = koubai + 3*gcd(i[0],i[1],i[2])
        else:
            koubai = koubai + 6*gcd(i[0],i[1],i[2])
            #print(koubai)
    print(koubai)
    """



if __name__ == '__main__':
    main()

Fixed submission:
import math

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(k):
        for j in range(k):
            for l in range(k):
                sum = sum + math.gcd(math.gcd(i+1 ,j+1), l+1)
    print(sum)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#import fractions
from itertools import permutations, combinations,combinations_with_replacement,product
import math
from functools import reduce

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

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
    
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    #for i in range(k):
    #    for j in range(k):
    #        for l in range(k):
    #            lists.append((i+1,j+1,l+1))
    for i in range(k):
        lists.append(int(i+1))
        lists.append(int(i+1))
        lists.append(int(i+1))
    
    #for v in combinations_with_replacement(lists,3):
    #    print(v)
    lists = list(combinations_with_replacement(lists,3))
    lists = set(lists)
    #print(lists)
    #lists2 = [i[0]*100+i[1]*10+i[2] for i in lists]
    #print(lists2)
        
    koubai = 0
    for i in lists:
        if len(set(i))==1:
            koubai = koubai + gcd(i[0],i[1],i[2])
            #print(koubai)
        elif len(set(i))==2:
            koubai = koubai + 3*gcd(i[0],i[1],i[2])
        else:
            koubai = koubai + 6*gcd(i[0],i[1],i[2])
            #print(koubai)
    print(koubai)
    



if __name__ == '__main__':
    main()


"""
    grid.append(array)
#print(grid)

for i in grid:
    if len(i)==1:
        s = ''.join(list(reversed(s)))
    else:
        if i[1]=="1":
            s = i[2]+s
        else:
            s = s+i[2]
print(s)

a = array[0]
b = array[1]

min8 = a/0.08
max8 = (a+1)/0.08
min10 = b/0.1
max10 = (b+1)/0.1

def lists(a,b):
    if a%1==0:
        a2 = a
    else:
        a2 = int(a)+1
    if b%1==0:
        b2 = b-1
    else:
        b2 = int(b)
    return np.arange(a2,b2+1)

list8 = lists(min8,max8)
list10 = lists(min10,max10)
#print(list8,list10)
hosii = list(set(list8)&set(list10))
if len(hosii)>0:
    print(int(np.min(hosii)))
else:
    print(-1)


grid = np.array(grid)

N = int(input())
s = [int(input()) for i in range(N)]

for i in s:
    grid = np.where(grid==i,0,grid)
    
print(grid)
    
if grid[0][0]==0 and grid[0][1]==0 and grid[0][2]==0:
    han = "Yes"
elif grid[1][0]==0 and grid[1][1]==0 and grid[1][2]==0:
    han = "Yes"
elif grid[2][0]==0 and grid[2][1]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 and grid[1][0]==0 and grid[2][0]==0:
    han = "Yes"
elif grid[0][1]==0 and grid[1][1]==0 and grid[2][1]==0:
    han = "Yes"
elif grid[0][2]==0 and grid[1][2]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][0]==0 and grid[1][1]==0 and grid[2][2]==0:
    han = "Yes"
elif grid[0][2]==0 and grid[1][1]==0 and grid[2][0]==0:
    han = "Yes"
else:
    han = "No"
print(han)
"""


Fixed submission:
import math

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(k):
        for j in range(k):
            for l in range(k):
                sum = sum + math.gcd(math.gcd(i+1 ,j+1), l+1)
    print(sum)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations, combinations,combinations_with_replacement,product
import math
from functools import reduce

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

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

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []

    for i in range(k):
        lists.append(int(i+1))
        lists.append(int(i+1))
        lists.append(int(i+1))
    

    lists = list(combinations_with_replacement(lists,3))
    lists = sorted(set(lists))

        
    koubai = 0
    for i in lists:
        if len(set(i))==1:
            koubai = koubai + gcd(i[0],i[1],i[2])
            #print(koubai)
        elif len(set(i))==2:
            koubai = koubai + 3*gcd(i[0],i[1],i[2])
        else:
            koubai = koubai + 6*gcd(i[0],i[1],i[2])
            #print(koubai)
    print(koubai)
    
if __name__ == '__main__':
    main()

Fixed submission:
import math

def main():
    #n, k = map(int,input().split())
    k = int(input())
    lists = []
    sum = 0
    for i in range(k):
        for j in range(k):
            for l in range(k):
                sum = sum + math.gcd(math.gcd(i+1 ,j+1), l+1)
    print(sum)

if __name__ == '__main__':
    main()