Problem:


Score : 300 points

Problem Statement

Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}.

Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.

Constraints

1 \leq K \leq 200

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print the value of \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}.

Sample Input 1

2

Sample Output 1

9

\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)
+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)
=1+1+1+1+1+1+1+2=9

Thus, the answer is 9.

Sample Input 2

200

Sample Output 2

10813692



Sample input:
2


Sample output:
9

Submission status: Runtime Error

Solution code:
K=int(input())
ans=0

def gcd2(a,b):
    if b==0:
        return a
    return gcd2(b,a%b)
def gcd3(a,b,c):
    return gcd2(gcd2(a,b),c)

for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(k,K+1):
            if i==j==k:
                ans+=gcd3(i,j,k)
            elif i==j or j==k:
                ans+=gcd3(i,j,k)*3
            else:
                ans+=gcd3(i,j,k)*6

print(ans)

Submission status: Runtime Error

Solution code:
import functions
from functools import reduce

K=int(input())

ans=K*(1+K)/2
for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans+=functions.gcd(i,j)*6
        for k in range(j+1,K+1):
            ans+=reduce(functions.gcd, [i,j,k])*6
print(str(int(ans)))

Submission status: Runtime Error

Solution code:
import numpy as np
K = int(input())
a = np.arange(a,K+1)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print(np.sum(b))

Submission status: Runtime Error

Solution code:
import numpy as np
K = int(input())
a = np.arrange(a,K+1)
b = np.gcd.outer(np.gcd.outer(a, a), a)
print(np.sum(b))

Submission status: Runtime Error

Solution code:
from numpy import gcd
N = int(input())
a = np.arange(1,N+1)
b = np.gcd.outer(np.gcd.outer(a,a), a)
print(b)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
 
def gcd(a,b,c):
  return reduce(math.gcd, (a,b,c))
 
K = int(input())
res = 0
for i in range(1:N+1):
  for j in range(1:N+1):
    for k in range(1:N+1):
      res += gcd(i,j,k)
print(res)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(array):
  return reduce(math.gcd, array)

K = int(input())
res = 0
for i in range(1:N+1):
  for j in range(1:N+1):
    for k in range(1:N+1):
      res += gcd(i,j,k)
print(res)

Submission status: Runtime Error

Solution code:
a=int(input())
import math
print(sum(gcd(gcd(i,j),k)for i in range(1,a+1) for j in range(1,a+1) for k in range(1,a+1)))

Submission status: Runtime Error

Solution code:
K = int(input())
gcd_sum = 0
for a in range(1,K+1):
  a_init = a
  for b in range(1, K+1):
	b_init = b
    for c in range(1, K+1):
      a = a_init
	  b = b_init						
	  m = min(a, b, c)
	  gcd = 1
	  for i in range(2, m+1):
	    if a%i == 0 and b%i == 0 and c%i == 0:
	      a /= i
          b /= i
          c /= i
		  gcd *= i
	  gcd_sum += gcd
print(gcd_sum)

Submission status: Runtime Error

Solution code:
K = int(input())
gcd_sum = 0
for a in range(1,K+1):
  a_init = a
  for b in range(1, K+1):
	b_init = b
    for c in range(1, K+1):
      a = a_init
	  b = b_init						
	  m = min(a, b, c)
	  gcd = 1
	  for i in range(2, m+1):
	    if a%i == 0 and b%i == 0 and c%i == 0:
	      a /= i
		  b /= i
		  c /= i
		  gcd *= i
	  gcd_sum += gcd
print(gcd_sum)

Submission status: Runtime Error

Solution code:
from fractions import gcd
K = int(input())

ans =  0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans = ans + gcd(i,j,k)

print(ans)

Submission status: Runtime Error

Solution code:
from math import *

K = int(input())

sum = 0
for i in range(K):
  for j in range(K):
    for k in range(K):
      sum += gcd(i,gcd(j,k))

print(sum)
return

Submission status: Runtime Error

Solution code:
import math

N=int(input())

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

A = 0
for i in N:
  for j in N:
    for k in N:
      l = gcd_list(i,j,k)
  A += l
print(A)

Submission status: Runtime Error

Solution code:
import math,itertools
N=int(input())

for i in range(1,N+1):
  for j in range(1,N+1):
    temp=math.gcd(i,j)
    for k in range(1,N+1):
      a=a+math.gcd(temp,c)
print(int(a))

Submission status: Runtime Error

Solution code:
import math,itertools
N=int(input())

for i in range(1,N+1):
  for j in range(1,N+1):
    temp=math.gcd(i,j)
    for k in range(1,N+1):
      a=a+math.gcd(temp,c)
print(int(temp))

Submission status: Runtime Error

Solution code:
from fractions import gcd

sum = 0
input_num = int(input())
for i in range(1, input_num+1):
    for j in range(1, input_num+1):
        for k in range(1, input_num+1):
            
print(sum)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
k=int(input())
r=0
l=[]

for i in range(k):
  for j in range(k):
    for l in range(k):
      if i<=j and j<=k:
        l.append([i+1,j+1,k+1])
for s in l:
  r+=gcd(s[0],s[1],s[2])
print(r)

Submission status: Runtime Error

Solution code:
def gcd(a, b):
    if a%b == 0:
        return b
    return gcd(b, a%b)

N = input()

sum = 0

for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(1, N+1):
            sum += gcd(gcd(i, j), k)

print(sum)

Submission status: Runtime Error

Solution code:
def gcd_(a,b):
    while b!=0:
        x = a%b
        a = b
        b = x
    return a
  
N = int(input())
result = [gcd(gcd(i,j),k) for i in range(1,N+1) for j in range(1,N+1) for k in range(1,N+1)]
print(sum(result))

Submission status: Runtime Error

Solution code:
def gcd(a, b,c):
    while b:
        a, b = b, a % b
    while c:
        b,c = c, b % c
    return b

""" 
l = []
for a in range(1,int(input())+1):
    for b in range(1, int(input())+1):
        for c in range(1,int(input())+1):
            l.append(gcd(a,b,c))
"""
l = (gcd(a,b,c) for a in range(1,int(input())+1) for b in range(1,int(input())+1) for c in range(1,int(input())+1))

print(sum(l))

Submission status: Runtime Error

Solution code:
import math

K = int(input())

sum = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        n = math.gcd(a, b)
        for c in range(1, K+1):
            sum += np.gcd(n, c)
print(sum)

Submission status: Runtime Error

Solution code:
import math
k=int(input())
r=0
for i in range(k):
  for j in range(k):
    for l in range(k):
      r+=math.gcd(i+1,j+1,l+1)
print(r)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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

n=int(input())
l1=range(1,n+1)
l2=range(1,n+1)
l3=range(1,n+1)

count=0

for i in l1:
    for j in l2:
        te=gcd(i,j)
        for k in l3:
            count+=(te,k)

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
count = 0

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

for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            m = gcd(i,j,k)
            count += m
print(count)

Submission status: Runtime Error

Solution code:
import nampy as np
k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    tmp = np.gcd(a,b)
    for c in range(1,k+1):
      ans += np.gcd(tmp,c)

print(ans)

Submission status: Runtime Error

Solution code:
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    c = 0
    for i in range(1,201):
        for j in range(1,201):
            for k in range(1,201):
                c = c + math.gcd(math.gcd(a,b),c)
    print(c)
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()

Submission status: Runtime Error

Solution code:
"""
    Author : thekushalghosh
    Team   : CodeDiggers
"""
import sys,math,cmath,time
start_time = time.time()
################# ---- USER DEFINED INPUT FUNCTIONS ---- #################
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().split()))
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    n = inp()
    c = 0
    for i in range(1,201):
        for j in range(1,201):
            for k in range(1,201):
                c = c + math.gcd(math.gcd(a,b),c)
    print(c)
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
ONLINE_JUDGE = __debug__
if not ONLINE_JUDGE:
    sys.stdin = open('input.txt','r')
    sys.stdout = open('output.txt','w')
else:
    input = sys.stdin.readline
t = 1
t = inp()
for tt in range(t):
    solve()
if not ONLINE_JUDGE:
    print("Time Elapsed:",time.time() - start_time,"seconds")
sys.stdout.close()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
k = int(input())
l = [a,b,c]
gcd = []
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
for l[0] in range(1,k+1):
    for l[1] in range(1,k+1):
        for l[2] in range(1,k+1):
            gcd.append(gcd_list(l))
print(sum(gcd))

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
d={}
if n==1:
    print(1)
for a in range(1,n+1):
    for b in range(1,n+1):
        p=math.gcd(a,b)
        if d.get(p)!=None:
            d[p]+=1
        else:
            d[p]=1
for c in range(1,n+1):
    for e in range(1,n+1):
        p=math.gcd(c,e)
        ans+=d[e]*p
print(ans)

Submission status: Runtime Error

Solution code:
import math
k = int(input())
sum =0
for a in range(1, k+1):
     for b in range(1, k+1):
         x = gcd(a, b)
         for c in range(1, k+1):
             sum += gcd(x, c)
print(sum)

Submission status: Runtime Error

Solution code:
import fractions

n = int(input())

answer = 0

for i in range(1,n+1):
  
  for j in range(1,n+1):
    
    for h in range(1,n+1):
      f = gractions.gcd(i,j,h)
    	answer += f

Submission status: Runtime Error

Solution code:
from itertools import combinations
import math
n = int(input()
ans = 0
for r in range(1,4): 
    if r>n:
        break
    for x  in combinations([x+1 for x in range(n)],r):
        if len(x)==1:
            ans += x[0]
        elif len(x)==2:
            ans += math.gcd(x[0],x[1])*6
        else:
            tmp = math.gcd(x[0],x[1])
            ans += math.gcd(x[2],tmp)*6
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import combinations
import math
n = int(input()
ans = 0
for r in range(1,4): 
    
    if r>n:
        break
    for x  in combinations([x+1 for x in range(n)],r):
        print(x)
        if len(x)==1:
            ans += x[0]
        elif len(x)==2:
            ans += math.gcd(x[0],x[1])*6
        else:
            tmp = math.gcd(x[0],x[1])
            ans += math.gcd(x[2],tmp)*6
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
K = int(input())

ans = 0
for a in range(1, K+1) for b in range(1, K+1) for c in range(1, K+1) ans += fractions.gcd(a, fractions.gcd(b,c))
print(ans)

Submission status: Runtime Error

Solution code:
import math
K = int(input())

ans = 0
for a in range(1, K+1) for b in range(1, K+1) for c in range(1, K+1) ans += math.gcd(a, math.gcd(b,c))
print(ans)

Submission status: Runtime Error

Solution code:
import math
K = int(input())

ans = 0
for a in range(1, K+1) for b in range(1, K+1) for c in range(1, K+1):
  ans += math.gcd(a, math.gcd(b,c))
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
K = int(input())

ans = 0
for a in range(1, K+1) for b in range(1, K+1) for c in range(1, K+1):
  ans += fractions.gcd(a, fractions.gcd(b,c))
print(ans)

Submission status: Runtime Error

Solution code:
import math
K = int(input())

# ans = 0
# for a in range(1, K+1):
#   for b in range(1, K+1):
#     for c in range(1, K+1):
#       ans += math.gcd(a, fractions.gcd(b,c))
# print(ans)

tmp = [0] * 800
ans = 0
k = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    tmp[k] = math.gcd(i, j)
    k += 1

for t in tmp:
  for i in range(1, K+1):
    if t == 0 :
      break
    ans += math.gcd(i, t)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
K = int(input())

# ans = 0
# for a in range(1, K+1):
#   for b in range(1, K+1):
#     for c in range(1, K+1):
#       ans += fractions.gcd(a, fractions.gcd(b,c))
# print(ans)

tmp = [0] * 800
ans = 0
k = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    tmp[k] = fractions.gcd(i, j)
    k += 1

for t in tmp:
  for i in range(1, K+1):
    if t == 0 :
      break
    ans += fractions.gcd(i, t)
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

def solv():
    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        for j in range(1, n + 1):
            a = gcd(i, j)
            for k in range(1, n + 1):
                ans += gcd(a, k)
    print(ans)

solve()

Submission status: Runtime Error

Solution code:
hogehoge

Submission status: Runtime Error

Solution code:
def gcd2(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def gcd3(a, b, c):
    z = gcd2(a, b)
    return(gcd2(c, z))

k = int(input())
t = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            t += gcd3(a, b, c)
print(t)

Submission status: Runtime Error

Solution code:
def gcd2(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def gcd3(a, b, c):
    z = gcd2(a, b)
    return(gcd2(c, z))

k = int(input())
t = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            t += gcd3(a, b, c)
print(t)

Submission status: Runtime Error

Solution code:
import math
K = int(input())

sum = 0
for i in range(1,K+1):
	for j in range(1,K+1):
		temp = math.gcd(i,j)
		for m in range(1,K+1):
			sum = sum + math.gcv(temp,m)

print(sum)

Submission status: Runtime Error

Solution code:
from math import  gcd

K = INT()
sum = 0
 
for n in range(K):
  for m in range(K):
    for l in range(K):
      sum += gcd(n+1, gcd(m+1, l+1))
 
print(sum)

Submission status: Runtime Error

Solution code:
print(sum(__import__('functools').reduce(__import__('math').gcd,[a,b,c]) for a,b,c in __import__('itertools').pro    duct(range(1,int(input())+1), repeat=3)))

Submission status: Runtime Error

Solution code:
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
k=0
for a in range(1,n+1):
    for b in range(1,n+1):
      k=gcd(a,b)
        for c in range(1,n+1):
            ans+=gcd(k,c)  
print(ans)

Submission status: Runtime Error

Solution code:
import math
K = int(input())
sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans+=math.gcd(math.gcd(a,b),c)
print(sum(list))

Submission status: Runtime Error

Solution code:
from math import gcd
K = int(iniput())
sum_gcd = [0]*201
ans = 0
 
for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += sum_gcd[i]*gcd(i,k)
 
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
K = int(iniput())
sum_gcd = [0]*201
ans = 0

for i in range(1,K+1):
  for j in range(1,K+1):
    sum_gcd[gcd(i,j)] += 1
for i in range(1,K+1):
  for k in range(1,K+1):
    ans += GCD[i]*gcd(i,k)

print(ans)

Submission status: Runtime Error

Solution code:
import math

k = int(imput())
n = 0

for i in range(1,k+1)
    for j in range(1,k+1)
        a=math.gcd(i,j)
        for l in range(1,k+1)
            b=math.gcd(a,l)
            n += b

print(n)

Submission status: Runtime Error

Solution code:
import math
K = int(input())

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      gcd = math.gcd(math.gcd(a, b), c) 
      sum_gcd += gcd

print(sum_gcd)

Submission status: Runtime Error

Solution code:
import math

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
sum = 0
for a in range(K):
  for b in range(K):
    for c in range(K):
      sum += int(gcd(a,b,c))
print(sum)

Submission status: Runtime Error

Solution code:
from math import gcd
k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        sub += gcd(i,j)
        for l in range(1,k+1):
            ans += gcd(sub,l)
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())

import math

l = list(range(1, K+1))

h_list = list(itertools.combinations_with_replacement(l, 3))

a = 0

for val in h_list:
  a += math.gcd(val)
  
print(a)

Submission status: Runtime Error

Solution code:
import math
sum_gcd = 0
K = int(input())

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      gcd = math.gcd(a, b, c) 
      sum_gcd += gcd

print(sum_gcd)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

K = input('')
la = lb = lc = list(range(1, K+1))
sum = 0

for a in range (len(la)):
  for b in range(len(lb)):
    for c in range(len(lc)):
      sum += gcd(la[a],lb[b],lc[c])

print(sum)

Submission status: Runtime Error

Solution code:
K = int(input())
 
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

def sumgcd(K):
for a in range (len(la)):
  for b in range(len(lb)):
    for c in range(len(lc)):
      sum += gcd(la[a],lb[b],lc[c])

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
 
K = int(float(read())
 
x = np.arange(1, K + 1)
nums = np.gcd.outer(np.gcd.outer(x, x), x)
print(nums.sum())

Submission status: Runtime Error

Solution code:
from colloctions import Counter
from scipy import gcd
 
def sum_of_gcd(N):
  temp = [gcd(i, k) for i in range(1, N+1) for k in range(1, N+1)]
  counts = Counter(temp)
  return sum([gcd(i, c)*counts[c] for i in range(1, N+1) for c in counts.keys()])
 
print(sum_of_gcd(int(input())))

Submission status: Runtime Error

Solution code:
from colloctions import Counter
import numpy as np

def sum_of_gcd(N):
  temp = [np.gcd(i, k) for i in range(1, N+1) for k in range(1, N+1)]
  counts = Counter(temp)
  return sum([np.gcd(i, c)*counts[c] for i in range(1, N+1) for c in counts.keys()])

print(sum_of_gcd(int(input())))

Submission status: Runtime Error

Solution code:
import math 

mysum = 0
K = int(input())
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			mysum += math.gcd(math.gcd(x,y),z)

print(mysum)

Submission status: Runtime Error

Solution code:
import math
k = int(input())+1
for i in range(1, k):
    for j in range(1, k):
        temp = math.gcd(i, j)
        for x in range(1, k):
            sum += math.gcd(temp, x)
print(sum)

Submission status: Runtime Error

Solution code:
K = int(input())

ans = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            ans += math.gcd(math.gcd(a,b),c)
print(ans)
exit()

Submission status: Runtime Error

Solution code:
import math
k = int(input())+1
for i in range(1, k):
    for j in range(1, k):
        temp = math.gcd(i, j)
        for x in range(1, k):
            sum += math.gcd(temp, x)


print(sum)

Submission status: Runtime Error

Solution code:
import math

k = int(input())+1

for i in range(1, k):
    for j in range(1, k):
        temp = math.gcd(i, j)
        for x in range(1,k):
            sum += math.gcd(temp,x)


print(sum)

Submission status: Runtime Error

Solution code:
import math
for i in range(1, k):
    for j in range(1, k):
        temp = math.gcd(i, j)
        for x in range(1,k):
            sum += math.gcd(temp,x)


print(sum)

Submission status: Runtime Error

Solution code:
import math

k = int(input())

gcd_sum_dict = collections.defaultdict(int)
for i in range(1, k+1):
    gcd_sum_dict[i] = 0
    for j in range(1, k+1):
        gcd_sum_dict[i] += gcd(i, j)

ans = 0
for i in range(1, k+1):
    for j in range(1, k+1):
        ans += gcd_sum_dict[gcd(i, j)]

print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      t=gcd(i,gcd(j,k))
      ans+=t
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans+=gcd(i,gcd(j,k))
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans+=gcd(i,gdc(j,k))
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import math

num = int(input())
a = 1
sum = 0

def gcd(a, b, c):
  num = np.array([a, b, c])
  return np.gcd(np.gcd.reduce(num))

def loopC(a, b, num):
  c = 1
  sum = 0
  while c <= num:
      ans = gcd(a, b, c)
      sum += ans
      c += 1
  return sum

def loopB(a, num):
  b = 1
  sum = 0
  while b <= num:
    ans = loopC(a, b, num)
    b += 1
    sum += ans
  return sum

while a <= num:
  ans = loopB(a, num)
  sum += ans
  a += 1

print(sum)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter

K = int(input())

memo = {frozenset((i, j)): math.gcd(i, j) 
        for i in range(1, K+1) for j in range(i, K+1)}

counter = Counter([memo[frozenset((i, j))] 
                   for i in range(1, K+1) for j in range(1, K+1)])

total = 0
for i in range(1, K+1):
  for value, count = counter.items():
    total += memo[frozenset((i, value))] * count
    
print(total)

Submission status: Runtime Error

Solution code:
k = int(input())
sum = 0
def gcd(p,q):
  if p%q == 0:
    return q
  retrun gcd(q,p%q)
for i in range(1,k+1):
   for j in range(1,k+1):
      for k in range(1,k+1):
        sum += gcd(gcd(i,j),k)

print(sum)

Submission status: Runtime Error

Solution code:
n=int(input())
from fractions import gcd
def gcds(a,b,c):
  d=gcd(a,b)
  e=gcd(d,c)
  return e
    
sum=0
for i in range(1,n+1):
  for j in range(i,n+1):
    for k in range(j,n+1):
      if i==j and j==k:
        sum=sum+gcds(i,j,k)
      else if i==j:
        sum=sum+2*gcds(i,j,k)
      else:
        sum=sum+6*gcds(i,j,k)
      
print(sum)

Submission status: Runtime Error

Solution code:
n=int(input())
from fractions import gcd
def gcds(a,b,c):
  d=gcd(a,b)
  e=gcd(e,c)
  return e
    
sum=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      sum=sum+gcds(i,j,k)
      
print(sum)

Submission status: Runtime Error

Solution code:
import math

K = int(input())

for a in range(K):
  for b in range(K):
    for c in range(K):
      gcd = math.gcd(a, b, c)
      
      sum_gcd += gcd

print(sum_gcd)

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools
 
if __name__ == "__main__":
    K = int(input())+1
    ret = 0
    for a, b, c in itertools.product(range(1,K), range(1,K), range(1,K)):
        ret += np.gcd.reduce(list({a,b,c}))
    print(ret)

Submission status: Runtime Error

Solution code:
def comomdiv(a, b, c):
  A = divs(a)
  B = divs(b)
  C = divs(c)
  comomdiv = 0.1
  for i in range(len(A)):
    for j in range(len(B)):
      for l in range(len(C)):
        if A[i] and B[j] == C[l]:
          x = c[l]
          if x > comomdiv or comomdiv == 0.1:
            comomdiv = x
  return comomdiv

def divs(n):
  divs = [None]*(n+1)
  for i=1 in range(n):
    if n%i == 0:
      divs[i] = i
  return divs

summ = 0
for i in range K:
  for j in range K:
    for l in range K:
      summ += comomdiv(i, j, l)
print(summ)

Submission status: Runtime Error

Solution code:
from Math import gcd

K = int(input())

result = 0
for a in range(1, K + 1):
  for b in range(1, K + 1):
    for c in range(1, K + 1):
      result += gcd(c, gcd(a, b))
      
print(result)

Submission status: Runtime Error

Solution code:
from math import gcd
k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        n = math.gcd(i,j)
        for m in range(1,k+1):
            a = math.gcd(n,m)
            ans += a
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
from math import gcd
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        n = math.gcd(i,j)
        for m in range(1,k+1):
            a = math.gcd(n,m)
            ans += a
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
from math import gcd
ans = 0
for i in range(k+1):
    for j in range(k+1):
        n = math.gcd(i,j)
        for m in range(k+1):
            a = math.gcd(n,m)
            ans += a
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
import math import gcd
ans = 0
for i in range(k+1):
    for j in range(k+1):
        n = math.gcd(i,j)
        for m in range(k+1):
            a = math.gcd(n,m)
            ans += a
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
import math import gcd
ans = 0
for i in range(k+1):
    for j in range(k+1):
        n = math.gcd(i,j)
        for m in range(k+1):
            a = math.gcd(n,m)
            list.append(int(a))

ans = sum(list)
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
list=[]
import math import gcd

for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            n = math.gcd(i,j)
            a = math.gcd(n,m)
            list.append(int(a))

ans = sum(list)
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
list=[]
import math import gcs

for i in range(k+1):
    for j in range(k+1):
        for m in range(k+1):
            n = math.gcd(i,j)
            a = math.gcd(n,m)
            list.append(int(a))

ans = sum(list)
print(ans)

Submission status: Runtime Error

Solution code:
def gcd1(p, q):
	if(p % q == 0):
      return q
    else:
	  return gcd1(q, p % q);

K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd1(gcd1(a,b),c)
print(s)

Submission status: Runtime Error

Solution code:
def gcd1(p, q):
	if(p % q == 0):
      return q
    else:
	  return gcd(q, p % q);

K = int(input())
s = 0
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      s+=gcd1(gcd1(a,b),c)
print(s)