Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
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+=math.gcd(math.gcd(a,b),c)
print(s)

Fixed submission:
from math import gcd
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+=gcd(gcd(a,b),c)
print(s)
Buggy python submission (verdict: Runtime Error):
n,k=int(input().split())
i=n//k
j=n-k*i
if j>=abs(j-k):
    print(abs(j-k))
else:
    print(j)

Fixed submission:
n,k=input().split()
n=int(n)
k=int(k)
i=n//k
j=n-k*i
if j>=abs(j-k):
    print(abs(j-k))
else:
    print(j)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.append(n)
d=[]
for i in range(len(a)):
    d.append([i,a[i+1]-a[i]])
l=sorted(d,key=lambda x:x[1])

o=l[-1][0]
g=a[o]+n-a[o+1]
print(g)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.append(n)
d=[]
for i in range(len(a)-1):
    d.append([i,a[i+1]-a[i]])
d[-1][1]+=a[0]
l=sorted(d,key=lambda x:x[1])

o=l[-1][0]
if o==len(a)-2:
    g=a[-2]-a[0]
else:
    g=a[o]+n-a[o+1]
print(g)
Buggy python submission (verdict: Runtime Error):
n=input()
s=len(n)
d=int((s-1)/2)
p=int(s+3)/2
m=n[::-1]
n1=n[0:d-1]
n2=n1[::-1]
n3=n[p-1:]
n4=n3[::-1]
if n==m and n1==n2 and n3==n4:
    print("Yes")
else:
    print("No")

Fixed submission:
n=input()
s=len(n)
d=int((s-1)/2)
p=int((s+3)/2)
m=n[::-1]
n1=n[0:d]
n2=n1[::-1]
n3=n[p-1:]
n4=n3[::-1]
if n==m and n1==n2 and n3==n4:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
import sys
a,b=map(int,input().spliit())
a2=math.ceil(a/0.08)
a3=math.floor((a+1)/0.08)
if a2>a3:
    print("-1")
    sys.exit()
b2=math.ceil(b/0.1)
b3=math.floor((b+1)/0.1)
if b2>b3:
    print("-1")
    sys.exit()
if b2<a2:
    if a2<(b+1)/0.1:
        print(a2)
    else:
        print("-1")
if a2<b2:
    if b2<(a+1)/0.08:
        print(b2)
    else:
        print("-1")
if a2==b2:
    print(a2)


Fixed submission:
import math
import sys
a,b=map(int,input().split())
a2=math.ceil(a/0.08)
a3=math.floor((a+1)/0.08)
if a2>a3:
    print("-1")
    sys.exit()
b2=math.ceil(b/0.1)
b3=math.floor((b+1)/0.1)
if b2>b3:
    print("-1")
    sys.exit()
if b2<a2:
    if a2<(b+1)/0.1:
        print(a2)
    else:
        print("-1")
if a2<b2:
    if b2<(a+1)/0.08:
        print(b2)
    else:
        print("-1")
if a2==b2:
    print(a2)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
c=0
m=0
for i in b:
    c+=i
d=c/len(b)
e=str(d)[2]
e=int(e)
if e>=5:
    f=int(str(d)[0])+1
else:
    f=int(str(d)[0])
for g in b:
    m+=(abs(g-f))**2
print(m)



Fixed submission:
a,b=input().split()
a=int(a)
b=int(b)
if a>=10:
    print(b)
else:
    c=b-100*a+1000
    print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=input().split()
q=input().split()
N=[i for i in range(1,n+1)]
def kaijou(x):
    if x==1:
        return 1
    if x==2:
        return 2
    if x==3:
        return 6
    if x==4:
        return 24
    if x==5:
        return 120
    if x==6:
        return 720
    if x==7:
        return 5040

s1=1
s2=1
j=1
for i in p:
    s1 += kaijou(n-j)*(i-1)
    j+=1
j=1
for i in q:
    s2 += kaijou(n-j)*(i-1)
    j+=1
k=s1-s2
if k<0:
    print(-k)
else:
    print(k)


Fixed submission:
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
N=[i for i in range(1,n+1)]
p1=[i for i in range(1,n+1)]
q1=[i for i in range(1,n+1)]
def kaijou(x):
    if x==0:
        return 0
    elif x==1:
        return 1
    elif x==2:
        return 2
    elif x==3:
        return 6
    elif x==4:
        return 24
    elif x==5:
        return 120
    elif x==6:
        return 720
    elif x==7:
        return 5040

s1=1
s2=1
j=1
for i in p:
    s1 += kaijou(n-j)*int(p1.index(i))
    j+=1
    p1.remove(i)
j=1
for i in q:
    s2 += kaijou(n-j)*int(q1.index(i))
    j+=1
    q1.remove(i)
k=s1-s2
if k<0:
    print(-k)
else:
    print(k)
Buggy python submission (verdict: Runtime Error):
s=input().split()
a=int(s[0])
b=int(s[1])
k=int(s[2])
if a>=k:
    print((a-k)+" "+b)
else:
    if a+b>=k:
        print("0 "+b+a-k)
    else:
        print("0 0")



Fixed submission:
s=input().split()
a=int(s[0])
b=int(s[1])
k=int(s[2])
if a>=k:
    print(str(a-k)+" "+str(b))
else:
    if a+b>=k:
        print("0 "+str(b+a-k))
    else:
        print("0 0")
Buggy python submission (verdict: Runtime Error):
a=input().split()
A=int(a[0])
B=int(a[1])
li=[2]
li2=[]
p=0
if B>A:
    c=A
    A=B
    B=A

for i in range(3,int(A**0.5)+1):
    for j in range(2,i+1):
        if j==i:
            li.append(i)
        if i%j==0:
            break
while p==0:
    for s in li:
        if A%s==0 and B%s==0:
            A/=s
            B/=s
            li2.append(s)
            break
        if A%s==0 and B%s!=0:
            A/=s
            li2.append(s)
            break
        if A%s!=0 and B%s==0:
            B/=s
            li2.append(s)
            break
        if s==li[-1]:
            p=1
n=1
for m in li2:
    n*=m
print(n)

Fixed submission:
a=int(input())
b=int(input())
if a+b==3:
  print("3")
elif a+b==4:
  print("2")
else:
  print("1")
Buggy python submission (verdict: Runtime Error):
import math
a=input().split()
A=int(a[0])
B=int(a[1])
print(math.gcd(A,B))

Fixed submission:
import fractions
a=input().split()
A=int(a[0])
B=int(a[1])
def lcm(x,y):
  return(x*y)//fractions.gcd(x,y)
print(lcm(A,B))

Buggy python submission (verdict: Time Limit Exceeded):
a=input().split()
A=int(a[0])
B=int(a[1])
li=[2]
li2=[]
p=0
if B>A:
    c=A
    A=B
    B=c
for i in range(3,A+1):
    for j in range(2,i+1):
        if j==i:
            li.append(i)
        if i%j==0:
            break
while p==0:
    for s in li:
        if A%s==0 and B%s==0:
            A/=s
            B/=s
            li2.append(s)
            break
        if A%s==0 and B%s!=0:
            A/=s
            li2.append(s)
            break
        if A%s!=0 and B%s==0:
            B/=s
            li2.append(s)
            break
        if s==li[-1]:
            p=1
n=1
for m in li2:
    n*=m
print(n)



Fixed submission:
import fractions
a=input().split()
A=int(a[0])
B=int(a[1])
def lcm(x,y):
  return(x*y)//fractions.gcd(x,y)
print(lcm(A,B))
Buggy python submission (verdict: Runtime Error):
a=input()
if len(a)%2==0:
    v=len(a)/2
else:
    v=(len(a)-1)/2
c=0
for i in range(v):
    if a[i]!=a[-i-1]:
        c+=1
print(c)

Fixed submission:
a=input()
if len(a)%2==0:
    v=int(len(a)/2)
else:
    v=int((len(a)-1)/2)
c=0
for i in range(v):
    if a[i]!=a[-i-1]:
        c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
s=int(input())
list1=[input() for _ in range(s)]
for i in range(len(list1)):
  list2=copy.copy(list1)
  list2.remove(list2[i])
  list2=sorted(list2,key=lambda x:-int(x))
  print(list2[0])


Fixed submission:
import copy
s=int(input())
list1=[input() for _ in range(s)]
list2=copy.copy(list1)
list2=sorted(list2,key=lambda x:-int(x))
for i in list1:
    if list2[0]==i:
      print(list2[1])
    else:
      print(list2[0])
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=a.split()
d=b.split()
e=0
k=1
u=int(c[1])
for i in range(len(d)):
        e+=int(d[i])
        k+=1
        if e>u:
                break
print(k)

Fixed submission:
a=input()
b=a.split()
if int(b[0])<int(b[1]):
  print(0)
else:
  print(10)

Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=a.split()
d=b.split()
e=0
k=0
u=int(c[1])
for i in range(len(d)):
        e+=int(d[i])
        k+=1
        if e>u:
                break
print(k)

Fixed submission:
a=input()
b=a.split()
if int(b[0])<int(b[1]):
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float("inf")]*n
cost[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,n-i):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[-1])


Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float("inf")]*n
cost[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[-1])

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[9999]*n
cost[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,n-i+1):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[-1])


Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
cost=[float("inf")]*n
cost[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        cost[i+j]=min(cost[i+j],cost[i]+abs(h[i+j]-h[i]))

print(cost[-1])
Buggy python submission (verdict: Runtime Error):
n,ww=map(int,input().split())
waight=[0]
value=[0]
for _ in range(n):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
dp=[[0]*(ww+1) for _ in range(n+1)]
for i in range(n):
    for w in range(ww+1):
        if w-waight[i+1]>=0:
            dp[i+1][w]=max(dp[i][w],dp[i][w-waight[i+1]]+value(i+1))
        else:
            dp[i+1][w]=dp[i][w]
print(dp[-1][-1])

Fixed submission:
n,ww=map(int,input().split())
waight=[0]
value=[0]
for _ in range(n):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
dp=[[0]*(ww+1) for _ in range(n+1)]
for i in range(n):
    for w in range(ww+1):
        if w-waight[i+1]>=0:
            dp[i+1][w]=max(dp[i][w],dp[i][w-waight[i+1]]+value[i+1])
        else:
            dp[i+1][w]=dp[i][w]
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
waight=[0]
value=[0]
for _ in range(N):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
SUM_v=sum(value)
dp=[[float("inf")]*(SUM_v+1) for _ in range(N+1)]
dp[0][0]=0
ans=0
for i in range(N):
    for sum_v in range(SUM_v+1):
        dp[i+1][sum_v]=min(dp[i][sum_v],dp[i][max(0,sum_v-value[i+1])]+waight[i+1])
        if dp[i+1][sum_v]<=W:
            ans=max(ans,sum_v)
print(ans)

Fixed submission:
N,W=map(int,input().split())
waight=[0]
value=[0]
for _ in range(N):
    a,b=map(int,input().split())
    waight.append(a)
    value.append(b)
SUM_v=sum(value)
dp=[[float("inf")]*(SUM_v+1) for _ in range(N+1)]
dp[0][0]=0
ans=0
for i in range(N):
    for sum_v in range(SUM_v+1):
        dp[i+1][sum_v]=min(dp[i][sum_v],dp[i][max(0,sum_v-value[i+1])]+waight[i+1])
        if dp[i+1][sum_v]<=W:
            ans=max(ans,sum_v)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
dp=[float("inf")]*n
dp[0]=0
for i in range(n-1):
    for j in range(1,7):
        j=6**j
        if i+j<n:
            cost[i+j]=min(dp[i+j],dp[i]+1)
    for j in range(1,6):
        j=9**j
        if i+j<n:
            cost[i+j]=min(dp[i+j],dp[i]+1)
    dp[i+1]=min(dp[i+1],dp[i]+1)
    

print(dp[-1])

Fixed submission:
n=int(input())
dp=[float("inf")]*(n+1)
dp[0]=0
for i in range(n):
    for j in range(1,7):
        j=6**j
        if i+j<n+1:
            dp[i+j]=min(dp[i+j],dp[i]+1)
    for j in range(1,6):
        j=9**j
        if i+j<n+1:
            dp[i+j]=min(dp[i+j],dp[i]+1)
    dp[i+1]=min(dp[i+1],dp[i]+1)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
a,b=map(int,(input().split()))
li=[]
for i in range(a):
    li.append(input())
li.sort
a=li[0]
for j in range(1,a):
    a+=li[j]
print(a)




Fixed submission:
a,b=map(int,(input().split()))
li=[]
for i in range(a):
    li.append(input())
li2=sorted(li)
c=li2[0]
for j in range(1,a):
    c+=li2[j]
print(c)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,(input().split()))
li=[]
for i in range(K):
    li.append(int(input()))
for j in range(N,10000):
    k=0
    for t in str(j):
        if int(t) in li:
            k=1
            break
    else:
        if k==0:
            print(j)

Fixed submission:
N,K=map(int,(input().split()))
li=[]
m=set(input())
for j in range(N,100000):
    if len(set(m & set(str(j))))==0:
        print(j)
        break
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    answer = "No"
    while K >= 1:
        if A>=B:
            B *= 2
            K -= 1
        elif B>=C:
            C *= 2
            K -= 1
    if A<B and B<C:
        answer = "Yes"
    print(answer)

if __name__ == "__main__":
    main()



Fixed submission:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    A, B, C = map(int, input().split())
    K = int(input())

    answer = "No"
    for i in range(K):
        if A>=B:
            B *= 2
        elif B>=C:
            C *= 2
    if A<B and B<C:
        answer = "Yes"
    print(answer)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import math

#def main(N):
def main():
    N = int(input())
    # Nが1のときは答えは0
    if N == 1:
        return 0
    else:
        N_remein = N
        # Nを素因数分解する。
        p_list = []
        p_factor_list = []
        p = 2
        while N_remein >= 2:
        #for p in range(2, math.ceil(math.sqrt(N))+1):
            if N_remein%p == 0:
                counter = 0
                #p_pow_counter = 1
                while True:
                    #p_pow_counter *= p
                    if N_remein%p == 0:
                        N_remein = N_remein//p
                        counter+=1
                    else:
                        p_list.append(p)
                        p_factor_list.append(counter)
                        break
            if p > math.ceil(math.sqrt(N)) and N_remein == N:
                break
            p += 1
        #print(p_list)
        #print(p_factor_list)
        # Nが素数の場合は、答えは1。
        if not p_factor_list:
            return 1
        else:
            answer = 0
            # 各素因数の指数に対して、、
            # 1,2,3,...と正整数を順番に引いていき、
            # 引けた回数を合計する。
            for factor in p_factor_list:
                counter = 1
                while (counter*(counter+1))//2 <= factor:
                    counter += 1
                answer += (counter-1) 
            #return answer, p_list, p_factor_list
            return answer

if __name__ == "__main__":
    print(main())
    #for i in range(1, 100):
    #    print(i, main(i))



Fixed submission:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import math

#def main(N):
def main():
    N = int(input())
    # Nが1のときは答えは0
    if N == 1:
        return 0
    else:
        N_remein = N
        # Nを素因数分解する。
        p_list = []
        p_factor_list = []
        #p = 2
        #while N_remein >= 2:
        for p in range(2, math.ceil(math.sqrt(N))+1):
            if N_remein%p == 0:
                counter = 0
                #p_pow_counter = 1
                while True:
                    #p_pow_counter *= p
                    if N_remein%p == 0:
                        N_remein = N_remein//p
                        counter+=1
                    else:
                        p_list.append(p)
                        p_factor_list.append(counter)
                        break
        if N_remein != 1:
            p_list.append(N_remein)
            p_factor_list.append(1)
        #print(p_list)
        #print(p_factor_list)
        # Nが素数の場合は、答えは1。
        if not p_factor_list:
            return 1
        else:
            answer = 0
            # 各素因数の指数に対して、、
            # 1,2,3,...と正整数を順番に引いていき、
            # 引けた回数を合計する。
            for factor in p_factor_list:
                counter = 1
                while (counter*(counter+1))//2 <= factor:
                    counter += 1
                answer += (counter-1) 
            #return answer, p_list, p_factor_list
            return answer

if __name__ == "__main__":
    print(main())
    #for i in range(1, 100):
    #    print(i, main(i))
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

import queue

def main():
    N, M = map(int, input().split())

    connedted_room_list = [ [] for i in range(M)]
    for i in range(M):
        A, B = map(int, input().split())
        connedted_room_list[A-1].append(B-1)
        connedted_room_list[B-1].append(A-1)

    answer_list = [ -1 for i in range(N)]
    answer_list[0] = 0

    next_rooms_queue = queue.Queue()
    next_rooms_queue.put(0)
    now_room = int()
    while not next_rooms_queue.empty():
        now_room = next_rooms_queue.get()
        for i in connedted_room_list[now_room]:
            if answer_list[i] == -1:
                answer_list[i] = now_room
                next_rooms_queue.put(i)

    is_escapable = True
    for i in range(1, N):
        if answer_list[i] == -1:
            is_escapable = False
            break
    
    if is_escapable:
        print("Yes")
        for i in range(1, N):
            print(answer_list[i]+1)
    else:
        print("No")

if __name__ == "__main__":
    main()




Fixed submission:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

import queue

def main():
    N, M = map(int, input().split())

    connedted_room_list = [ [] for i in range(N)] # ここでNとMを書き間違えていた。
    for i in range(M):
        A, B = map(int, input().split())
        connedted_room_list[A-1].append(B-1)
        connedted_room_list[B-1].append(A-1)

    answer_list = [ -1 for i in range(N)]
    answer_list[0] = 0

    next_rooms_queue = queue.Queue()
    next_rooms_queue.put(0)
    now_room = int()
    while not next_rooms_queue.empty():
        now_room = next_rooms_queue.get()
        for i in connedted_room_list[now_room]:
            if answer_list[i] == -1:
                answer_list[i] = now_room
                next_rooms_queue.put(i)

    
    is_escapable = True
    for i in range(1, N):
        if answer_list[i] == -1:
            is_escapable = False
            break

    if is_escapable:
        print("Yes")
        for i in range(1, N):
            print(answer_list[i]+1)
    else:
        print("No")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    N, M, Q = map(int, input().split())
    r_list = []
    for i in range(Q):
        r_list.append(list(map(int, input().split())))
    max_score = 0
    a1 = 1
    for a2 in range(a1, M+1):
        for a3 in range(a2, M+1):
            for a4 in range(a3, M+1):
                for a5 in range(a4, M+1):
                    for a6 in range(a5, M+1):
                        for a7 in range(a6, M+1):
                            for a8 in range(a7, M+1):
                                for a9 in range(a8, M+1):
                                    for a10 in range(a9, M+1):
                                        a_list = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                                        score = 0
                                        for r in r_list:
                                            if a_list[r[1]-1] - a_list[r[0]-1] == r[2]:
                                                score += r[3]
                                        max_score = max(score, max_score)
    print(max_score)

if __name__ == "__main__":
    main()




Fixed submission:
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
import math
A, B, N = map(int, input().split())

def f(x):
    return math.floor(A*x/B) - A * math.floor(x/B)

def main():
    print(f(min(N, B-1)))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:59 2020

@author: H_Hoshigi
"""

N = int(input())

FizzBuzz_sum_list = [0,1,3,3,7,7,7,14,22,22,22,33,33,46]
FizzBuzz_num_list = [0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]

answer = 60*pow(N//15, 2) + FizzBuzz_sum_list[N%15] + 15*(N//15)*FizzBuzz_num_list[N%15]

print(answer)



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:59 2020

@author: H_Hoshigi
"""

N = int(input())

FizzBuzz_sum_list = [0,1,3,3,7,7,7,14,22,22,22,33,33,46,60]
FizzBuzz_num_list = [0,1,2,2,3,3,3,4,5,5,5,6,6,7,8]

answer = 60*pow(N//15, 2) + FizzBuzz_sum_list[N%15] + 15*(N//15)*FizzBuzz_num_list[N%15]

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 21:45:38 2020
 
@author: H_Hoshigi
"""
 
import math
 
K = int(input())
 
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        for c in range(1, K+1):
            answer += math.gcd(math.gcd(a, b), c)
print(answer)
 

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 21:45:38 2020

@author: H_Hoshigi
"""

import math

K = 200#int(input())

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



Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 22:01:05 2020

@author: H_Hoshigi
"""

import math

K = int(input())
answer = 0
for a in range(1, K+1):
    for b in range(1, K+1):
        gcd_a_b = math.gcd(a, b)
        for c in range(1, K+1):
            answer += math.gcd(gcd_a_b, c)
print(answer)