Buggy python submission (verdict: Time Limit Exceeded):
import fractions


from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions


from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

from functools import reduce
K=int(input())

def gcd_list(a,b,c):
  return gcd(gcd(a,b),gcd(b,c))


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list(i,j,k)

print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Runtime Error):
import fractions

from functools import reduce
K=int(input())

def gcd_list(a,b,c):
  return gcd(gcd(a,b),gcd(b,c))


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list(i,j,k)

print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd(i,j,k)
print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd(i,j,k)
print(count)

Fixed submission:
import math

from functools import reduce
K=int(input())

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


count=0
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i==j and j==k and k==i:
        n=1
      elif i==j or j==k or k==i:
        n=3
      else:
        n=6
      count+=n*gcd_list([i,j,k])

print(count)