CodeEff/ECCO huggingface dataset:
# Original solution
memo = [[[-1] * 201 for j in range(201)] for i in range(201)]

def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(eval(input()))
numbers = []

for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

gcd_sum = 0
for number in numbers:
    dup = len(set(number))
    a, b, c = number
    if memo[a][b][c] == -1:
        if dup == 1:
            ans = gcd([gcd([a, b]), c])
        elif dup == 2:
            ans = gcd([gcd([a, b]), c]) * 3
        else:
            ans = gcd([gcd([a, b]), c]) * 6
        memo[a][b][c] = ans
    gcd_sum += memo[a][b][c]

print(gcd_sum)


# Optimized solution
def gcd(numbers):
    numbers.sort()
    a = numbers[1]
    b = numbers[0]
    ans = b
    while True:
        q, mod = divmod(a, b)
        if mod == 0:
            break
        a = b
        b = mod
        ans = mod
    return ans

K = int(eval(input()))
numbers = []

for i in range(K, 0, -1):
    for j in range(i, 0, -1):
        for k in range(j, 0, -1):
            numbers.append([i, j, k])

gcd_sum = 0
for number in numbers:
    dup = len(set(number))
    a, b, c = number
    if dup == 1:
        gcd_sum += gcd([gcd([a, b]), c])
    elif dup == 2:
        gcd_sum += gcd([gcd([a, b]), c]) * 3
    else:
        gcd_sum += gcd([gcd([a, b]), c]) * 6

print(gcd_sum)
# Original solution
import math

n = int(eval(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 += math.gcd(math.gcd(i,j),k)

print(sum)

# Optimized solution
import math

n = int(eval(input()))
sum = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    a = math.gcd(i,j)
    for k in range(1,n+1):
      sum += math.gcd(a,k)

print(sum)
# Original solution
import math
# from itertools import product
from functools import reduce

def main():
    def gcd(*numbers): return reduce(math.gcd, numbers)
    K = int(eval(input()))
    ans = 0
#     valiation = list(itertools.product(range(1, K+1), repeat=3))
#     for v in valiation:
#         ans += gcd(v)
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += gcd(i, j, k)
    print(ans)
        
    
if __name__ == '__main__':
    main()

# Optimized solution
import math
# from itertools import product
from functools import reduce

def main():
#     def gcd(*numbers): return reduce(math.gcd, numbers)
    K = int(eval(input()))
    ans = 0
#     valiation = list(itertools.product(range(1, K+1), repeat=3))
#     for v in valiation:
#         ans += gcd(v)
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += math.gcd(math.gcd(i, j), k)
    print(ans)
        
    
if __name__ == '__main__':
    main()
# Original solution
k = int(eval(input()))
from math import gcd

ans=0
for i in range(k):
    ans+=i+1
    for j in range(i+1, k):
        x=gcd(i+1,j+1)
        ans+=6*gcd(i+1,j+1)
        for l in range(j+1, k):
            ans+=6*gcd(x,l+1)
print(ans)


# Optimized solution
n=3
k=int(eval(input()))
INF=10**9+7
l=[0]*k
ans=0
for i in range(k-1,-1,-1):
    x=i+1
    temp=pow(k//x,n,INF)
    for j in range(2,k//x+1):
        temp=(temp-l[j*x-1])%INF
    l[i]=temp
    ans=(ans+x*temp)%INF
print(ans)
# Original solution
def gcd(x,y):
  while (y):
    x, y = y, x%y
  return x

def tgcd(x,y,z):
  return gcd(x,gcd(y,z))

a = int(eval(input()))
s = 0
for i in range(1,a+1):
  for j in range(1,a+1):
    for k in range(1,a+1):
      s+=tgcd(i,j,k)
print(s)


# Optimized solution
l=[1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692]
print((l[int(eval(input()))-1]))
# Original solution
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
k = int(eval(input()))
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

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

def main():
    ans = 0
    for i in range(1, k+1):
        for j in range(1, k+1):
            for l in range(1, k+1):
                ans += gcd(i, j, l)
    print(ans)

main()




    


# Optimized solution
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
k = int(eval(input()))
#n, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

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

def main():
    ans = 0
    for i in range(1, k+1):
        for j in range(1, k+1):
            if gcd(i, j) == 1:
                ans += k
                continue
            for l in range(1, k+1):
                ans += gcd(i, j, l)
    print(ans)

main()
# Original solution
from functools import reduce
from math import gcd

K = int(eval(input()))
l = [0 for i in range(K**3)]

ans = 0

for i in range(1,K+1):
    num = [0, 0, 0]
    num[0] = i
    for k in range(1,K+1):
        num[1] = k
        for m in range(1,K+1):
            num[2] = m
            ans += reduce(gcd, num)


print(ans)

# Optimized solution
from math import gcd

K = int(eval(input()))
ans = 0

for i in range(1,K+1):
    for k in range(1,K+1):
        b = gcd(i, k)
        for m in range(1,K+1):
            ans += gcd(b, m)

print(ans)
# Original solution
from functools import lru_cache

K = int(eval(input()))
sum = 0

@lru_cache()
def gcd(x,y):
  r = x % y
  while r> 0:
    x = y
    y = r
    r = x%y
  return y
  
for a in range(K):
  for b in range(K):
    for c in range(K):
      sum += gcd(gcd(a+1,b+1),c+1)
print(sum)

# Optimized solution
from functools import lru_cache
@lru_cache()
def gcd(x,y):
    r = x%y
    if r == 0:
        return y
    return gcd(y,r)

K = int(eval(input()))
Sum = 0

for i in range(1,K+1):
    Sum += i
    for j in range(i+1,K+1):
        Sum += 6*gcd(i,j)
        for k in range(j+1,K+1):
            Sum += 6*gcd(gcd(i,j),k)
print(Sum)
# Original solution
import math


def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)


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


K = int(eval(input()))
data = [k+1 for k in range(K)]
result = []
for i, d_i in enumerate(data):
    for j, d_j in enumerate(data[i:]):
        for d_k in data[i+j:]:
            result.append([d_i, d_j, d_k])

s = 0
for r in result:
    r0, r1, r2 = r
    g = gcd(r2, gcd(r0, r1))
    if r0 == r1 == r2:
        s += g
    elif r0 != r1 and r1 != r2:
        s += g * 6
    else:
        s += g * 3

print(s)


# Optimized solution
import itertools
import math


def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)


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


K = int(eval(input()))
data = [k+1 for k in range(K)]
result = list(itertools.combinations_with_replacement(data, 3))

s = 0

for r in result:
    r0, r1, r2 = r
    g0 = gcd(r0, r1)
    g = gcd(g0, r2)
    if r0 == r1 == r2:
        s += g
    elif r0 != r1 and r1 != r2:
        s += g * 6
    else:
        s += g * 3

print(s)
# Original solution
import math

K = int(eval(input()))
ans = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            gcd_0 = math.gcd(i+1,j+1)
            ans += math.gcd(gcd_0,k+1)

print(ans)

# Optimized solution
import math

K = int(eval(input()))
ans = 0
for i in range(K):
    for j in range(K):
        gcd_0 = math.gcd(i+1,j+1)
        if gcd_0 == 1:
            ans += gcd_0 * K
        else:
            for k in range(K):
                ans += math.gcd(gcd_0,k+1)

print(ans)
# Original solution
import itertools
import math

K = int(eval(input()))
nums = [i for i in range(1, K+1)]
product = itertools.product(nums, repeat=3)
ans = 0
for comb in product:
    m = min(comb)
    for i in range(3):
        m = math.gcd(m, comb[i])
    ans += m
print(ans)

# Optimized solution
import itertools
import math

K = int(eval(input()))
nums = [i for i in range(1, K+1)]
product = itertools.product(nums, repeat=3)
ans = 0
for comb in product:
    m = min(comb)
    if m == 1:
        ans += m
    else:
        for i in range(0, 3):
            m = math.gcd(m, comb[i])
        ans += m
print(ans)
# Original solution
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import math

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()

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)


# Optimized solution
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
import math

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

K = i_i()

res = sum([math.gcd(math.gcd(a, b), c) for a in range(1,K+1) for b in range(1,K+1) for c in range(1,K+1)])
print(res)
# Original solution
import math

k = int(eval(input()))
count = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            x = math.gcd(a,b)
            count += math.gcd(x,c)
print(count)

# Optimized solution
import math

k = int(eval(input()))
count = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        x = math.gcd(a,b)
        for c in range(1, k+1):
            count += math.gcd(x,c)
print(count)
# Original solution
n=int(eval(input()))
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd,numbers)
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            count+=gcd(a,b,c)
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

# Optimized solution
n=int(eval(input()))
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)
# Original solution
import math
K=int(eval(input()))
GCD=[[0]*(K+2) for _ in range(K+2)]

def divable(a,b):
    if a==b:
        return a
    if a<b:
        a,b=b,a
    if a%b>0:
        return 1
    return math.gcd(a,b)

def make_GCD(K):
    for a in range(1,K+1):
        for b in range(1,K+1):
            GCD[a][b]=math.gcd(a,b)            
def gcd3(a,b,c):
    if a<b:
        a,b=b,a
    a=GCD[a][b]
    return GCD[a][c]
make_GCD(K)
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd3(a,b,c)
            
print(ans)

# Optimized solution
K=int(eval(input()))
GCD=[[0]*(K+2) for _ in range(K+2)]
import math
def make_GCD(K):
    for a in range(1,K+1):
        for b in range(1,K+1):
            GCD[a][b]=math.gcd(a,b)            
make_GCD(K)

def gcd3(a,b,c):
    a=GCD[a][b]
    return GCD[a][c]
ans=0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans += gcd3(a,b,c)            
print(ans)
# Original solution
import math
 
k=int(eval(input()))
cnt=0
for a in range(k):
  a=a+1
  for b in range(k):
    b=b+1
    for c in range(k):
      c=c+1
      cnt=cnt+math.gcd(math.gcd(a,b),c)
print(cnt)
      

# Optimized solution
import math
 
k=int(eval(input()))
cnt=0
tmp=[]
for a in range(k):
  a=a+1
  for b in range(k):
    b=b+1
    tmp.append(math.gcd(a,b))
for i in tmp:
  if i==1:
    cnt=cnt+k
  else:
    for j in range(k):
      j=j+1
      cnt=cnt+math.gcd(i,j)
print(cnt)
# Original solution
import math
k = int(eval(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)


# Optimized solution
import math
k = int(eval(input()))
dp = [[1 for _ in range(k + 1)] for _ in range(k + 1)]
for i in range(1, k + 1):
    for j in range(1, k + 1):
        dp[i][j] = math.gcd(i, j)
ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += dp[a][dp[b][c]]
print(ans)
# Original solution
#coding:utf-8
import math
K=int(eval(input()))
result=0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			result+=math.gcd(math.gcd(i,j),k)

print(result)

# Optimized solution
#coding:utf-8
from math import*
K=int(eval(input()))
result=0
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			result+=gcd(gcd(i,j),k)

print(result)
# Original solution
import math
k = int(eval(input()))
ans = 0
for a in range(1, k + 1):
    for b in range(a, k + 1):
        x = math.gcd(a, b)
        for c in range(b, k + 1):
            y = math.gcd(x, c)
            if a == b and b == c:
                ans += y
            elif a == b or b == c:
                ans += y * 3
            else:
                ans += y * 6
print(ans)

# Optimized solution
import math
ans = 0
k = int(eval(input()))
for a in range(1, k + 1):
    for b in range(1, k + 1):
        x = math.gcd(a, b)
        for c in range(1, k + 1):
            y = math.gcd(x, c)
            ans += y
print(ans)
# Original solution
import math
k=int(eval(input()))
s=0
for a in range(k):
  for b in range(k):
    for c in range(k):
      s+=math.gcd(math.gcd(a+1,b+1),c+1)
print(s)

# Optimized solution
import math
k=int(eval(input()))
s=0
for a in range(k):
  for b in range(k):
    x=math.gcd(a+1,b+1)
    for c in range(k):
      s+=math.gcd(x,c+1)
print(s)
# Original solution
k = int(eval(input()))

import math 
from functools import reduce

sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += reduce(math.gcd, (a, b, c))

print(sum)

# Optimized solution
k = int(eval(input()))
 
import math
total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        gcd2 = math.gcd(a, b)
        for c in range(1, k+1):
            total += math.gcd(gcd2, c)
print(total)
# Original solution
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import math

    
def main():
	num = int(eval(input()))
	sum = 0
	for i in range(num):
		a = i+1
		for j in range(num):
			b = j+1
			for k in range(num):
				c = k+1
				if a == b:
					sum += math.gcd(a,c)
				elif b == c or a == c:
					sum += math.gcd(a,b)
				else:
					sum += math.gcd(math.gcd(a,b),c)
	print (sum)

if __name__ == '__main__':
	main()


# Optimized solution
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import math

    
def main():
	num = int(eval(input()))
	sum = 0
	for i in range(num):
		a = i+1
		for j in range(num):
			b = j+1
			for k in range(num):
				c = k+1
				sum += math.gcd(math.gcd(a,b),c)
	print (sum)

if __name__ == '__main__':
	main()
# Original solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 

K = INT()
 
many_gcd = lambda numbers: reduce(gcd, numbers)
 
ans = 0
for i in range(1, K+1):
	for j in range(1, K+1):
		for k in range(1, K+1):
			ans += many_gcd([i, j, k])
print(ans)

# Optimized solution
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(eval(input()))
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
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)
# Original solution
import math
 
K = int(eval(input()))
 
sum = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            sum += math.gcd(math.gcd(i+1, j+1), k+1)
            
print(sum)

# Optimized solution
import math
 
K = int(eval(input()))
 
sum = 0
for i in range(K):
    for j in range(K):
        r = math.gcd(i+1, j+1)
        for k in range(K):
            sum += math.gcd(r, k+1)
            
print(sum)
# Original solution
k = int(eval(input()))

def gcd(a, b, c):
    mini = a
    if a > b:
        mini = b
    if b > c:
        mini = c
    if (a % mini == 0) & (b % mini == 0) & (c % mini == 0):
        return mini
    for i in range((mini + 1)//2 + 1, 1, -1):
        if (a % i == 0) & (b % i == 0) & (c % i == 0):
            return i
    return 1

s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            a = gcd(i, j, l)
            s += int(a)

print(s)

# Optimized solution
k = int(eval(input()))

def gcd(a, b, c):
    mini = a
    if a > b:
        mini = b
    if b > c:
        mini = c
    if (a % mini == 0) & (b % mini == 0) & (c % mini == 0):
        return mini
    if mini % 2 == 0:
        h = mini / 2
        if (a % h == 0) & (b % h == 0) & (c % h == 0):
            return h
    for i in range((mini + 1)//3 + 1, 1, -1):
        if (a % i == 0) & (b % i == 0) & (c % i == 0):
            return i
    return 1

s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            if i <= j <= l:
                if i < j < l:
                    a = gcd(i, j, l) * 6
                    s += int(a)
                elif ((i == j) & (j != l)) | ((i != j) & (j == l)):
                    a = gcd(i, j, l) * 3
                    s += int(a)
                else:
                    a = gcd(i, j, l) 
                    s += int(a)
            else:
                continue

print(s)
# Original solution
class GCD:
    def __init__(self):
        self.numlist = dict()
        self.numlist2 = dict()
    def culc(self, K):
        ret = 0
        for i in range(1,K-1):
            for j in range(i+1, K):
                for k in range(j+1,K+1):
                    ret += self.gcd(i,j,k)*6
        
        for i in range(1,K+1):
            for j in range(1,K+1):
                if i != j:
                    ret += self.gcd(i,i,j) * 3
        for i in range(1, K+1):
            ret += self.gcd(i,i,i)

        return ret

    def gcd(self, a,b,c):
        l = [a,b,c]
        l.sort()
        l = tuple(l)
        if l in self.numlist:
            return self.numlist[l]
        else:
            temp_ = self.gcd_(l[0],l[1])
            temp_ = self.gcd_(temp_, l[2])
            self.numlist[l] = temp_
            return temp_

    def gcd_(self,a,b):
        l = (min(a,b), max(a,b))
        if l in self.numlist2:
            return self.numlist2[l]
        else:
            mod = max(a,b) % min(a,b)
            if mod == 0:
                ret = min(a,b)
                self.numlist2[l] = ret
                return ret
            else:
                ret = self.gcd_(min(a,b), mod)
                self.numlist2[l] = ret
                return ret

K = int(eval(input()))
gcd = GCD()
ret = gcd.culc(K)
print(ret)

# Optimized solution
class GCD:
    def __init__(self):
        self.numlist = dict()
    def culc(self, K):
        ret = 0
        
        for i in range(1,K):
            for j in range(i + 1,K+1):
                ret += self.gcd_(i,j) * 6

        for i in range(1,K-1):
            for j in range(i+1, K):
                for k in range(j+1,K+1):
                    ret += self.gcd(i,j,k)*6

        for i in range(1, K+1):
            ret += i

        return ret

    def gcd(self, a,b,c):
        #l = (a,b,c)
        #if l in self.numlist:
        #    return self.numlist[l]
        #else:
        temp_ = self.gcd_(a,b)
        temp_ = self.gcd_(temp_, c)
        
        return temp_

    def gcd_(self,a,b):
        l = (min(a,b), max(a,b))
        if l in self.numlist:
            return self.numlist[l]
        else:
            mod = max(a,b) % min(a,b)
            if mod == 0:
                ret = min(a,b)
                self.numlist[l] = ret
                return ret
            else:
                ret = self.gcd_(min(a,b), mod)
                self.numlist[l] = ret
                return ret

K = int(eval(input()))
gcd = GCD()
ret = gcd.culc(K)
print(ret)
# Original solution
import math
from functools import reduce

k = int(eval(input()))

ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            ans += reduce(math.gcd,[i,j,l])

print(ans)

# Optimized solution
import math
from functools import reduce

k = int(eval(input()))

ans = 0
for i in range(1,k+1):
    for j in range(i,k+1):
        for l in range(j,k+1):
            temp = reduce(math.gcd,[i,j,l])
            if len(set([i,j,l])) == 1:
                ans += temp
            elif len(set([i,j,l])) == 2:
                ans += temp * 3
            elif len(set([i,j,l])) == 3:
                ans += temp * 6
print(ans)
# Original solution
#200412C
K = int(eval(input()))
import math

ans = 0
for i in range(K):
    for k in range(K):
        for l in range (K):
            ans += math.gcd(math.gcd(i+1, k+1), l+1)
print((int(ans)))

# Optimized solution
#200412C
K = int(eval(input()))
import math

ans = 0
for i in range(K):
    for k in range(K):
        x = math.gcd(i+1,k+1)
        if x==1:
            ans +=K
        else:
            for l in range (K):
                ans += math.gcd(x, l+1)
            
print((int(ans)))