CodeEff/ECCO huggingface dataset:
# Original solution
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    mem = defaultdict(lambda : None)
    def gcd(a,b):
        if mem[(a,b)] != None:
            return mem[(a,b)]
        if a == 0:
            mem[(a,b)] = mem[(b,a)] = b
            return b
        mem[(a,b)] = mem[(b,a)] = gcd(b%a,a)
        return mem[(a,b)]
    k = I()
    ans = 0
    for a in range(1,k+1):
        for b in range(1,k+1):
            g = gcd(a,b)
            for c in range(1,k+1):
                ans += gcd(g,c)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


# Optimized solution
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a, a)
    k = I()
    ans = 0
    for a in range(1,k+1):
        for b in range(1,k+1):
            g = gcd(a,b)
            for c in range(1,k+1):
                ans += gcd(g,c)
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()
# Original solution
import math
from functools import reduce

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

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

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

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

print(S)

# Optimized solution
from math import gcd 

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

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

print(S)
# Original solution
import math


def list_gcd(A):
    """N個の最大公約数
    Args:
        A (list[int])

    Returns:
        int: 最大公約数

    Examples:
        >>> list_gcd([1300, 34, 54, 60])
        2
    """
    ans = A[0]
    for i in range(1, len(A)):
        ans = math.gcd(ans, A[i])
    return ans


def resolve():
    K = int(eval(input()))

    ans = 0

    for kk in range(1, K+ 1):
        for jj in range(1, K+ 1):
            for ii in range(1, K+ 1):
                ans += list_gcd([kk, jj, ii])

    print(ans)


resolve()

# Optimized solution
from math import gcd


def resolve():
    n = int(eval(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)


resolve()
# Original solution
from math import gcd #or import math
K = int(eval(input()))#or K = int(input())+1
plus = 0

for i in range(1,K+1):# range(1,K)
    for a in range(1,K+1):# range(1,K)
        x = gcd(i,a) #or math.gcd(i,a)
        for j in range(1,K+1):# range(1,K)
            plus += gcd(x,j) #or math.gcd(x,j)
            
print(plus)

# Optimized solution
from math import gcd
K = int(eval(input()))
plus = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        temp = gcd(a, b)
        if temp != 1:
            for c in range(1, K+1):
                plus += gcd(temp, c)
        else:
            plus += K
print(plus)
# Original solution
import math
K=int(eval(input()))
tot=0
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp=math.gcd(i,j)
        for k in range(1,K+1):
            tot+=math.gcd(tmp,k)
print(tot)

# Optimized solution
# https://atcoder.jp/contests/abc162/tasks/abc162_c
import math
K=int(eval(input()))
# K=200
tot=0
# for i in range(1,K+1):
#     for j in range(1,K+1):
#         tmp=math.gcd(i,j)
#         for k in range(1,K+1):
#             tot+=math.gcd(tmp,k)
ls=[0]*202
for i in range(1,K+1):
    for j in range(1,K+1):
        tmp=math.gcd(i,j)
        ls[tmp+1]+=1
tot=0
for i in range(1,K+1):
    for j in range(1,201):
        tot+=ls[j+1]*math.gcd(j,i)

print(tot)
# Original solution
import math

k = int(eval(input())) + 1
ans = 0

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

print(ans)


# Optimized solution
import math

k = int(eval(input())) + 1
ans = 0

for a in range(1, k):
    for b in range(1, k):
        d = math.gcd(a, b)
        for c in range(1, k):
            ans += math.gcd(d, c)

print(ans)
# Original solution
def gcd(a, b, c):
    while b:
        a, b = b, a % b
    while c:
        a, c = c, a % c
    return a

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

# Optimized solution
def gccd(a, b, c):
    while b:
        a, b = b, a % b
    while c:
        a, c = c, a % c
    return a

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

n = int(eval(input()))
ans = n * (n+1) //2
for i in range(1,n+1):
    for j in range(i+1,n+1):
        ans += gcd(i,j) * 6
if n >2:
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                ans += gccd(i,j,k) * 6
print(ans)
# Original solution
def resolve():
    '''
    code here
    '''
    import sys
    from functools import lru_cache
    sys.setrecursionlimit(10**3)
    K = int(eval(input()))

    @lru_cache(maxsize=10**3)
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a%b)


    def gcd3(a, b, c):
        temp = gcd(a,b)
        return gcd(temp, c)
    
    res = 0
    for k in range(1,K+1):
        for j in range(1,K+1):
            for i in range(1, K+1):
                res += gcd3(k, j, i)

    print(res)


if __name__ == "__main__":
    resolve()


# Optimized solution
def resolve():
    '''
    code here
    '''

    K = int(eval(input()))

    import math
    
    temp_list = []
    for k in range(1,K+1):
        for j in range(1,K+1):
            temp_list.append(math.gcd(k,j))

    res = 0
    for item in temp_list:
        for i in range(1,K+1):
            res += math.gcd(item, i)

    print(res)


if __name__ == "__main__":
    resolve()
# Original solution
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

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

K = int(stdin.readline().rstrip())
ans = 0

for c in range(2,K+1):
    for b in range(2,K+1):
        for a in range(2,K+1):
            ans += gcd(a,b,c)
            
print((ans+(K**3-(K-1)**3)))

# Optimized solution
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

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

K = int(stdin.readline().rstrip())
ans = 0
for_c = []

for b in range(1,K+1):
    for a in range(1,K+1):
        if math.gcd(a,b) == 1:
            ans += K
        else:
            for_c.append(math.gcd(a,b))

for c in range(1,K+1):
    for ab in range(len(for_c)):
        ans += math.gcd(for_c[ab],c)

print(ans)
# Original solution
K = int(eval(input()))
import math
sumnation = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sumnation += math.gcd(math.gcd(a,b),c)
print(sumnation)

# Optimized solution
K = int(eval(input()))
import math
sumnation = 0
gcdlist = []
for A in range(1,K+1):
    for B in range(1,K+1):
        gcdlist.append(math.gcd(A,B))
for a in range(1,1+K):
    for b in range(1,1+K):
        gcd_a_b = gcdlist[(a-1)*K+b-1]
        for c in range(1,1+K):
            sumnation += gcdlist[(gcd_a_b-1)*K+c-1]
print(sumnation)
# Original solution
from functools import reduce

def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

def mgcd(*a):
    return reduce(gcd, a)

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 += mgcd(i, j, l)

print(ans)

# Optimized solution
from math import gcd

k=int(eval(input()))
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans += gcd(i, gcd(j,m))
print(ans)
# Original solution
import math

k = int(eval(input()))

ab = []
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        if a % b == 0:
            ab.append(b)
        elif b % a == 0:
            ab.append(a)
        else:
            ab.append(math.gcd(a, b))
for i in ab:
    for c in range(1,k+1):
        if i % c == 0:
            ans += c
        elif c % i == 0:
            ans += i
        else:
            ans += math.gcd(i, c)

print(ans)

# Optimized solution
import math

k = int(eval(input()))

ab = []
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        ab.append(math.gcd(a, b))
for i in ab:
    for c in range(1,k+1):
        ans += math.gcd(i, c)

print(ans)
# Original solution
def mapint_inp():
    return list(map(int, input().split()))

def intinp():
    return int(eval(input()))

import math
from functools import reduce
import itertools


K = intinp()

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

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, j, k)

print(ans)


# Optimized solution
def mapint_inp():
    return list(map(int, input().split()))
 
def intinp():
    return int(eval(input()))
 
import math
import itertools
  
K = intinp()
 
ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        ij = math.gcd(i, j)
        for k in range(1, K+1):
            ans += math.gcd(ij, k)
 
print(ans)
# Original solution
import math
num = int(eval(input()))
result = 0
for i in range(1, num+1):
  for j in range (1, num+1):
    for k in range (1, num +1):
      result += math.gcd(math.gcd(i,j), k)
    
print(result)

# Optimized solution
import math
num = int(eval(input()))
result = 0
for i in range(1, num+1):
  for j in range (1, num+1):
    s= math.gcd(i,j)
    for k in range (1, num +1):
      result += math.gcd(s, k)
    
print(result)
# Original solution
K = int(eval(input()))
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
sum = 0

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

print(sum)


# Optimized solution
K = int(eval(input()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
sum=0
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)
# print(gcd(2,6))
# Original solution
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
gcd_list=[]
i=int(eval(input()))
for x in range(1, i+1):
  for y in range(1, i+1):
    for z in range(1, i+1):
      gcd_list.append(gcd(x, y, z))
      
print((sum(gcd_list)))

# Optimized solution
from math import gcd
k=int(eval(input()))
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        ans_=gcd(i,j)
        for l in range(1,k+1):
            ans+=gcd(ans_,l)
print(ans)
# Original solution
import math
import itertools

w = 0
k = int(eval(input()))
for i in range(1, k+1):
    for j in range(1, k+1):
        for l in range(1, k+1):
            m = math.gcd(i, j)
            w += math.gcd(m, l)
print(w)

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

# Optimized solution
import math
 
w = 0
k = int(eval(input()))
for i in range(1, k+1):
    for j in range(1, k+1):
        m = math.gcd(i, j)
        for l in range(1, k+1):
            w += math.gcd(m, l)
print(w)
# Original solution
import itertools
import math
n = int(eval(input()))

lst = [_ for _ in range(1, n+1)]
lst2 = list(itertools.permutations(lst, 3))
lst3 = list(itertools.permutations(lst, 2))
l2 = sum([math.gcd(math.gcd(_[0],_[1]),_[2]) for _ in lst2])
l3 = sum([math.gcd(_[0], _[1]) for _ in lst3]) 
l4 = sum(lst)

ans = l2 + l3 * 3 + l4

print(ans)


# Optimized solution
import itertools
import math
n = int(eval(input()))

lst = [_ for _ in range(1, n+1)]
lst2 = list(itertools.product(lst, repeat=2))

lst3 = [math.gcd(_[0], _[1]) for _ in lst2]

lst4 = list(itertools.product(lst3, lst))

lst5 = [math.gcd(_[0], _[1]) for _ in lst4]

print((sum(lst5)))
# Original solution
import math
N = int(eval(input()))
def gcdtriple(a,b,c):
    return math.gcd(a, math.gcd(b,c))
ans = 0
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            ans += gcdtriple(a,b,c)
print(ans)

# Optimized solution
import math
N = int(eval(input()))
def gcdtriple(a,b,c):
    return math.gcd(a, math.gcd(b,c))
ans = 0
for a in range(1, N+1):
    for b in range(1, a+1):
        for c in range(1, b+1):
            if a == b and b == c:
                ans += gcdtriple(a,b,c)
            elif a == b or b == c or c == a:
                ans += gcdtriple(a,b,c) * 3
            else:
                ans += gcdtriple(a,b,c) * 6
print(ans)
# Original solution
import math

k = int(eval(input()))

x = 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(math.gcd(a, b), c)
            
print(x)

# Optimized solution
import math

k = int(eval(input()))

x = 0

for a in range(1, k+1):
    for b in range(1, k+1):
        t = math.gcd(a, b)
        for c in range(1, k+1):
            x += math.gcd(t, c)
            
print(x)
# Original solution
import math
from functools import reduce
from itertools import product

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

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

n = list(product([i for i in range(1,k+1)],repeat=3))

for a,b,c in n:
    ans += gcd(a,b,c)

print(ans)


# Optimized solution
from math import gcd

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

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)
# Original solution
k = int(eval(input()))

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

answer = 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)
            ans = gcd(ans, l)
            answer += ans
            
print(answer)

# Optimized solution
import itertools

k = int(eval(input()))

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

answer = 0
nums = list(range(1, k+1))
for balls in itertools.combinations_with_replacement(nums, 3):
    i, j, l = balls[0], balls[1], balls[2]
    ans = gcd(i, j)
    ans = gcd(ans, l)
    if len(set(balls)) == 1:
        answer += ans
    elif len(set(balls)) == 2:
        answer += ans*3
    elif len(set(balls)) == 3:
        answer += ans*6
            
print(answer)
# Original solution
import math
from functools import reduce

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

K = int(eval(input()))
S=0
for i in range(1,K+1):
	for h in range(1,K+1):
		for g in range(1,K+1):
			S+=gcd(g,h,i)

print(S)

# Optimized solution
import math
from functools import reduce

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

K = int(eval(input()))
S=0
for i in range(1,K+1):
	for h in range(i,K+1):
		for g in range(h,K+1):

			if i==h and h==g:
				S+=gcd(g,h,i)
			elif i==h or h==g or g==i:
				S+=3*gcd(g,h,i)
			else:
				S+=6*gcd(g,h,i)
			
print(S)
# Original solution
from functools import reduce
import math


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


K = int(eval(input()))
gcdsum = 0
for a in range(1, K + 1):
    for b in range(1, K + 1):
        for c in range(1, K + 1):
            #print(gcd(a, b, c))
            gcdsum += int(gcd(a, b, c))
print(gcdsum)


# Optimized solution
from functools import reduce
import math


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


K = int(eval(input()))
gcdsum = K*K*K
gcd_ab = []
ab_list = []
for a in range(1, K + 1):
    for b in range(1, K + 1):
        #print(str(gcd(a, b))+', a:'+str(a)+', b:'+str(b))
        if gcd(a, b) != 1:
            ab_list.append(a)
            ab_list.append(b)
            gcd_ab.append(ab_list)
            ab_list = []
for ab in gcd_ab:
    ab = gcd(ab[0], ab[1])
    for c in range(1, K+1):
        if gcd(ab, c) != 1:
            #print(gcd(ab, c))
            gcdsum += gcd(ab, c)-1

print(gcdsum)
# Original solution
K = int(eval(input()))

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

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

print(ans)


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

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

dec = {}
for a in range(1,K+1):
    for b in range(1, K+1):
        if gcd(a,b) not in dec:
            dec[gcd(a,b)] = 1
        else:
            dec[gcd(a,b)] += 1
ans = 0
for c in range(1, K+1):
    for key in list(dec.keys()):
        ans += gcd(c, key)*dec[key]

print(ans)
# Original solution
from math import gcd

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


# Optimized solution
from math import gcd

n = int(eval(input()))
ans = 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 == k:
                ans += gcd(gcd(i, j), k)
            elif i == j or i == k or j == k:
                ans += gcd(gcd(i, j), k) * 3
            else:
                ans += gcd(gcd(i, j), k) * 6
print(ans)
# Original solution
import math
k = int(eval(input()))
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum+=math.gcd(math.gcd(i,j),l)
print(sum)

# Optimized solution
k = int(eval(input()))
arr =  [0]*(k+1)
count = [0]*(k+1)
sum = 0
n = 3
for i in range(k,1,-1):
    x = k//i
    p = int(pow(x,n))
    arr[i]=i*p 
    count[i]=p
    for j in range(x-1):
        arr[i]-=i*count[i*(j+2)]
        count[i]-=count[i*(j+2)]
csum = 0
for i in range(2,k+1):
    sum+=arr[i]
    csum+=count[i]
sum+=(int(pow(k,n)) - csum)
print((int(sum%(1e9+7))))
# Original solution
k = int(eval(input()))
#k = 3

class GCD:
    def __init__(self):
        self.cache = {}
        self.cache3 = {}
    def gcd2(self, a, b):
        a, b = sorted([a, b], reverse=True)
        if (a in self.cache and b in self.cache[a]):
            return self.cache[a][b]
        if (a % b == 0):
            if (a not in self.cache):
                self.cache[a] = {}
            self.cache[a][b] = b
            return b
        return self.gcd2(b, a % b)
    def gcd3(self, a, b, c):
        a, b, c = sorted([a, b, c], reverse=True)
        if (a in self.cache3 and b in self.cache3[a] and c in self.cache3[a][b]):
            return self.cache3[a][b][c]
        if (a not in self.cache3):
            self.cache3[a] = {}
        if (b not in self.cache3[a]):
            self.cache3[a][b] = {}
        result = self.gcd2(self.gcd2(a, b), c)
        self.cache3[a][b][c] = result
        return result

a = 1
b = 1
c = 1
result = 0
client = GCD()
while (a <= k):
    b = 1
    while (b <= k):
        c = 1
        while (c <= k):
            result += client.gcd3(a, b, c)
            c += 1
        b += 1
    a += 1
print(result)


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

class GCD:
    def __init__(self):
        self.cache = {}
        self.cache3 = {}
    def gcd2(self, a, b):
        a, b = sorted([a, b], reverse=True)
        if (a in self.cache and b in self.cache[a]):
            return self.cache[a][b]
        if (a % b == 0):
            if (a not in self.cache):
                self.cache[a] = {}
            self.cache[a][b] = b
            return b
        return self.gcd2(b, a % b)
    def gcd3(self, a, b, c):
        a, b, c = sorted([a, b, c], reverse=True)
        if (a in self.cache3 and b in self.cache3[a] and c in self.cache3[a][b]):
            return self.cache3[a][b][c]
        if (a not in self.cache3):
            self.cache3[a] = {}
        if (b not in self.cache3[a]):
            self.cache3[a][b] = {}
        result = self.gcd2(self.gcd2(a, c), b)
        self.cache3[a][b][c] = result
        return result

a = 1
b = 1
c = 1
result = 0
client = GCD()
while (a <= k):
    b = a
    while (b <= k):
        interval = client.gcd2(a, b)
        c = b
        while (c <= k):
            if (a == b and b == c):
                result += client.gcd2(interval, c)
            elif(a != b and b != c and a != c):
                result += client.gcd2(interval, c) * 6
            else:
                result += client.gcd2(interval, c) * 3
            c += 1
        b += 1
    a += 1
print(result)
# Original solution
import math
K=int(eval(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 += math.gcd(math.gcd(i,j),k)
print(ans)

# Optimized solution
from math import gcd
K=int(eval(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 += gcd(gcd(i,j),k)
print(ans)
# Original solution
from math import gcd

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

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

print(ans)


# Optimized solution
from math import gcd

def main():
    k = int(eval(input()))
    ans = 0

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

    print(ans)

if __name__ == '__main__':
    main()
# Original solution
r=list(range(1,int(eval(input()))+1))
import math
from functools import reduce
def g(*n):return reduce(math.gcd, n)
print((sum(g(a,b,c) for a in r for b in r for c in r)))

# Optimized solution
r=list(range(1,int(eval(input()))+1))
from math import gcd 
print((sum(gcd(gcd(a,b),c) for a in r for b in r for c in r)))