Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
k = int(input())



sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd1 = fractions.gcd(i, j)
        for l in range(1,k+1):
            sum += fractions.gcd(gcd1,l)

print(sum)

Fixed submission:
import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
k = int(input())
h_list = []
 
 
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            h_list.append([i,j,l])
 
sum = 0
for i in range(len(h_list)):
    a = fractions.gcd(h_list[i][0], h_list[i][1])
    sum += fractions.gcd(a,h_list[i][2])
 
print(sum)

Fixed submission:
import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
k = int(input())
h_list = []


for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            h_list.append([i,j,l])

sum = 0
for i in range(len(h_list)):
    a = fractions.gcd(h_list[i][0], h_list[i][1])
    sum += fractions.gcd(a,h_list[i][2])

print(sum)

Fixed submission:
import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
k = int(input())
h_list = []



def gcd(numbers):
    return functools.reduce(fractions.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            h_list.append([i,j,l])

sum = 0
for i in range(len(h_list)):
    sum += gcd(h_list[i])

print(sum)

Fixed submission:
import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import math
import fractions
import functools
k = int(input())
h_list = []



def gcd(numbers):
    return functools.reduce(fractions.gcd, numbers)

for i in range(1,k+1):
    for j in range(1,k+1):
        for k in range(1,k+1):
            h_list.append([i,j,k])

sum = 0
for i in range(len(h_list)):
    sum += gcd(h_list[i])

print(sum)

Fixed submission:
import itertools
import math
import fractions
import functools

K = int(input())
 
res = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    gcd1 = math.gcd(i, j)
    for k in range(1, K+1):
      if gcd1 == 1:
        res += 1
      else:
        res += math.gcd(gcd1, k)
print(res)