Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

S = input()
work=list(S)
i=0
cout=0
while(True):
    if(i==len(work)-1):
        break
    if(work[i]==work[i+1]):
        i+=1
    else:
        cout+=2
        del work[i]
        del work[i]
        i=0

    

print(len(S)-len(work))

Fixed submission:

S = input()
work=list(S)
i=0
o_cout=0
z_cout=0
for x in work:
    if(x=='1'):
        o_cout+=1
    else:
        z_cout+=1
    
if(o_cout>z_cout):
    cout=z_cout
else:
    cout=o_cout
    

print(cout*2)

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
work=S
while(len(work)>=0):
    if('01' in work):
        work = re.sub('01','',work)
    elif('10' in work):
        work = re.sub('10','',work)
    else:#01 or 10 の羅列も見つけることができなかった
        break

print(len(S)-len(work))

Fixed submission:

S = input()
work=list(S)
i=0
o_cout=0
z_cout=0
for x in work:
    if(x=='1'):
        o_cout+=1
    else:
        z_cout+=1
    
if(o_cout>z_cout):
    cout=z_cout
else:
    cout=o_cout
    

print(cout*2)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A>0 & B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if(A>0 && B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A,B = map(int,input().split())
if(A>0 && B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A B = map(int(),input().split())
if(A>0 && B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)

Buggy python submission (verdict: Runtime Error):
A B = map(int(),input().split())
if(B%A==0):
  print(B+A)
else:
  print(B-A)
  

Fixed submission:
A,B=map(int,input().split())
if(A>0 and B%A==0):
  print(B+A)
else:
  print(B-A)
Buggy python submission (verdict: Runtime Error):
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    ilist = list(map(int,input().split()))
    ilist.pop(0)
    member[i]=set(ilist)

if(N==1):
    print(member(1))
    sys.exit(0)

match_set=member[1]
for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(len(match_set))
        


Fixed submission:
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    ilist = list(map(int,input().split()))
    ilist.pop(0)
    member[i]=set(ilist)

match_set=member[1]

for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(len(match_set))

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

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    j=int(input())
    member[i] = set(int(input()) for _ in range(j))
if(N==1):
    print(member(1))
    sys.exit(0)

match_set=member[1]
for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(match_set.length)
        


Fixed submission:
import sys

N,M = map(int,input().split())
member = dict()
for i in range(1,N+1,1):
    ilist = list(map(int,input().split()))
    ilist.pop(0)
    member[i]=set(ilist)

match_set=member[1]

for i in range(2,N+1,1):#memberに対し、1人ずつ検査していく
    match_set = match_set & member[i]

print(len(match_set))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
base_point = 1
new_point = 1
time = N-K
for i in range(K):
    base_point *= A[K-1-i]
for i in range(time):
    new_point = A[K+i] * base_point//A[i]
    if(new_point>base_point):
        print('Yes')
    else:
        print('No')

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-K):
    if(A[K+i]>A[i]):
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print(A*B)

Fixed submission:
A, B = map(int, input().split())
print(A*B)

Buggy python submission (verdict: Runtime Error):
def main():
    A = int(input())
    B = int(input())
    ans = a(A, B)
    print(ans)

def a(A, B):
    return (A * B)

main()

Fixed submission:
A, B = map(int, input().split())
print(A*B)

Buggy python submission (verdict: Runtime Error):
def a(A B)
	return A * B

Fixed submission:
A, B = map(int, input().split())
print(A*B)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    return
B = 1
for i in A:
    B = B * i
    if B >= 10 ** 18:
        print(-1)
        return
print(B)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)

Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))
B = 1
for i in A:
    B = B * i
    if B >= 10 ** 18
        print(-1)
        sys.exit()
print(B)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)

Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
A = list(map(int, input().split()))
for i in A:
    B = 1
    B = B * A[i]
    if B >= 10 ** 18
        print(-1)
        sys.exit()
print(B)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
for i in A:
    B = B * A[i]
    if B >= 1000000000000000000
        return print(-1)
print(B)

Fixed submission:
import sys
N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    sys.exit()
B = 1
for i in A:
    B = B * i
    if B > 10 ** 18:
        print(-1)
        sys.exit()
print(B)
Buggy python submission (verdict: Runtime Error):
A, B = input().split()
a = int(A)
b = round(float(B)*100)

print((A*B)//100)

Fixed submission:
A, B = input().split()
a = int(A)
b = round(float(B)*100)

print((a*b)//100)

Buggy python submission (verdict: Runtime Error):
A, B = input().split()
a = int(A)
b = float(B)*100

print((A*B)//100)


Fixed submission:
A, B = input().split()
a = int(A)
b = round(float(B)*100)

print((a*b)//100)
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))

import numpy as np

Base = np.prod(A[:K])
for n in range(N-K):
  Tgt_i = np.prod(A[n:K+n])
  Tgt_i1 = np.prod(A[n+1:K+n+1])
  if Tgt_i < Tgt_i1:
    print('Yes')
  else:
    print('No')

Fixed submission:
N = int(input().strip())

if N<=599:print(8)
elif N<=799:print(7)
elif N<=999:print(6)
elif N<=1199:print(5)
elif N<=1399:print(4)
elif N<=1599:print(3)
elif N<=1799:print(2)
else: print(1)
Buggy python submission (verdict: Runtime Error):
N, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))

for n in range(N-K):
  Tgt1 = A[n]
  Tgt2 = A[K+n+1]
  if Tgt1 < Tgt2:
    print('Yes')
  else:
    print('No')

Fixed submission:
N, K = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))

if N == K:
  print('No')
else:
  for n in range(N-K):
    Tgt1 = A[n]
    Tgt2 = A[K+n]
    if Tgt1 < Tgt2:
      print('Yes')
    else:
      print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input().strip())
A = list(map(int, input().strip().split()))
 
count = 0
 
for n in range(N):
  flg = True
  if A.count(A[n]) == 1:
    tmp = [a for a in A if a != A[n]]
    for m in tmp:
      if A[n]%m == 0: flg = False
  else: flg = False
  
  if flg == True: count += 1
    
print(count)

Fixed submission:
l = list(map(int, input().strip().split()))

idx = None
for i in range(len(l)):
  if l[i] == 0:
    idx = i+1
print(idx)
Buggy python submission (verdict: Runtime Error):
a, b = list(map(int, input().strip().split()))
c = a*b
if c%2 = 0:
  print('Even')
else:
  print('Odd')

Fixed submission:
a, b = map(int, input().split())
c = (a * b) % 2
if c == 0:
	print('Even')
else:
	print('Odd')
Buggy python submission (verdict: Runtime Error):
N = int(input())
 
l = [int(input()) for _ in range(N)]
 
count = 0

while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1
print(count)

Fixed submission:
N = int(input())
 
l = list(map(int, input().strip().split()))
 
count = 0
 
while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1
    
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input().strip())

l = [_ for _ in int(input().strip())]

count = 0

while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1

print(count)

Fixed submission:
N = int(input())
 
l = list(map(int, input().strip().split()))
 
count = 0
 
while all([a == 0 for a in list(map(lambda x: x%2, l))]):
    l = list(map(lambda x: x/2, l))
    count += 1
    
print(count)
Buggy python submission (verdict: Runtime Error):
X = int(input())
ls = [2, 2, 2, 3, 3, 5]
a = []
for l in ls:
  if X % l == 0:
    a.append(l)
    X /= l
num = 1
if len(a) != 0:
  for b in a:
    num *= b
print(360 / b)

Fixed submission:
X = int(input())
ls = [2, 2, 2, 3, 3, 5]
a = []
for l in ls:
  if X % l == 0:
    a.append(l)
    X /= l
num = 1
if len(a) != 0:
  for b in a:
    num *= b
print(int(360 / num))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
print(min(n%k,abs(k-n%k)))

Fixed submission:
#ab,ac
a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
print(min(n%k,k-n%k))

Fixed submission:
#ab,ac
a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
x = n//k
if(n<k):
    x = k//n
    print(min(abs(k*x-n),abs(k*(x+1)-n)))
else:
    print(min(abs(k*x-n),abs(k*(x+1)-n)))

Fixed submission:
#ab,ac
a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print(a,b,c)

Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
x = math.ceil(n/k)
if(n<k):
    x = math.ceil(n/k)
    print(min(n,abs(k*x-n)))
else:
    print(abs(k*x-n))

Fixed submission:
#ab,ac
a,b,c = map(int,input().split())
a,b = b,a
a,c = c,a
print(a,b,c)
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
x = n//k
if(n<k):
    x = k//n
    print(min(abs(k*x-n),abs(k*(x+1)-n)))
else:
    print(min(abs(k*x-n),abs(k*(x+1)-n)))


Fixed submission:
n,k = map(int,input().split())
print(min(n%k,abs(k-n%k)))

Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
x = n//k
if(n<k):
    x = k//n
    print(min(abs(k*x-n),abs(k*(x+1)-n)))
else:
    print(min(abs(k*x-n),abs(k*(x+1)-n)))


Fixed submission:
n,k = map(int,input().split())
print(min(n%k,abs(k-n%k)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(map(int,input().split()))
for i in range(len(s)-1,0,-1):
    if(s[i]>s[i-1]):
        continue
    else:
        s[i-1] = s[i]
print(sum(s)+s[0])
        

Fixed submission:
n = int(input())
print(n**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n):
    if(i<(n-1) and d[i]==(d[i+1]-1)):
        ans+=c[i-2]
print(ans)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n):
    if(i<(n-1) and d[i]==(d[i+1]-1)):
        ans+=c[d[i]-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools 
n,x = list(map(int,input().split()))
l = list(map(int,input().split()))
k = list(itertools.accumulate(l))
k.sort()
s = 0
ii = 0

for i in k:
    if(i<=x):
        continue
    else:
        s = ii
        ii+=1
        break
if(s==0):
    print(n)
else:
    print(max(1,s+1))

Fixed submission:
x,a = list(map(int,input().split()))
if(x<a):
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
m = []
for _ in range(3):
    m.append(sorted(list(map(int, input().split())), reverse=True))
 
def sorted_sum(list_a, list_b):
    s = []
    for x in list_a:
        for y in list_b:
            s.append(x + y)
    return sorted(s, reverse=True)
 
ans = sorted_sum(sorted_sum(m[0], m[1])[0:k], m[2])
for i in range(0, k):
    print(ans[i])

Fixed submission:
def check(pos):
    for a in pos:
        for b in pos:
            if abs(a - b) > k:
                return False
    return True

pos = [None] * 5
for i in range(0, 5):
    pos[i] = int(input())
k = int(input())

print("Yay!" if check(pos) else ":(")

Buggy python submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
m = []
for _ in range(3):
    m.append(sorted(list(map(int, input().split())), reverse=True))
 
def sorted_sum(list_a, list_b):
    s = []
    for x in list_a:
        for y in list_b:
            s.append(x + y)
    return sorted(s, reverse=True)
 
ans = sorted_sum(sorted_sum(m[0], m[1])[0:k], m[2])[0:k]
for i in range(0, k):
    print(ans[i])

Fixed submission:
def check(pos):
    for a in pos:
        for b in pos:
            if abs(a - b) > k:
                return False
    return True

pos = [None] * 5
for i in range(0, 5):
    pos[i] = int(input())
k = int(input())

print("Yay!" if check(pos) else ":(")
Buggy python submission (verdict: Runtime Error):
#!/usr/local/bin/python3
# coding: utf-8

ha = input()
kita = ha.split(" ")
x = int(kita[0])
y = int(kita[1])
ifAshi = False

for i in range(x):
    if(x = 1):
        if(y == 2 or y == 4):
            ifAshi = True
    if((y - 2*i)%4 == 0):
        if((x-i) == ((y - 2*i)/4)):
            ifAshi = True

if(ifAshi):
    print("Yes")
else:
    print("No")

Fixed submission:
#!/usr/local/bin/python3
# coding: utf-8

ha = input()
kita = ha.split(" ")
x = int(kita[0])
y = int(kita[1])
ifAshi = False

if(x == 1):
    if(y == 2 or y == 4):
        ifAshi = True
if(x*2 == y):
    ifAshi = True
for i in range(x):
        
    if((y - 2*i)%4 == 0):
        if((x-i) == ((y - 2*i)/4)):
            ifAshi = True

if(ifAshi):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
#!/usr/local/bin/python3
# coding: utf-8
n = input()
hairu = input()
kita = hairu.split(" ")
seki = 1

try:
    for c in kita:
        if seki > 10**18:
            print("-1")
            break
        else:
            seki = seki * int(c)
            if seki > 10**18:
                print("-1")
            else:
                print(seki)
except:
    print("-1")




Fixed submission:
#!/usr/local/bin/python3
# coding: utf-8
hairu = input()
kita = hairu.split(" ")
a = int(kita[0])
b = int(kita[1])

print(a*b)
Buggy python submission (verdict: Runtime Error):
#!/usr/local/bin/python3
# coding: utf-8


hairu = input()
sockets = 0
plugs = 1
ab = hairu.split()

while True:
    sockets += 1
    plugs -= 1
    plugs += int(ab[0])
    if int(ab[1]) < plugs:
        print(sockets)
        exit(1)

    

Fixed submission:
#!/usr/local/bin/python3
# coding: utf-8


hairu = input()
sockets = 0
plugs = 1
ab = hairu.split()

while True:
    if int(ab[1]) == 1:
        print(0)
        break

    sockets += 1
    plugs -= 1
    plugs += int(ab[0])
    if int(ab[1]) <= plugs:
        print(sockets)
        break
Buggy python submission (verdict: Runtime Error):
    #! /usr/bin/env python3
     
    from fractions import gcd
    from collections import Counter, deque, defaultdict
    from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
    from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
    from itertools import accumulate, product, permutations, combinations
     
    from fractions import gcd
    from collections import Counter, deque, defaultdict
    from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
    from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
    from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
     
    N, M, Q = [int(_) for _ in input().split()]
    abcd = [[int(_) for _ in input().split()] for i in range(Q)]
     
    com = combinations_with_replacement(range(1, M+1), N)
     
    ma = 0
    scores = []
    for i in com:
        score = 0
        for j in abcd:
            if i[j[1]-1] - i[j[0]-1] == j[2]:
                score += j[3]
        if score > ma:
            ma = score
    print(ma)

Fixed submission:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

N, M, Q = [int(_) for _ in input().split()]
abcd = [[int(_) for _ in input().split()] for i in range(Q)]

com = combinations_with_replacement(range(1, M+1), N)

ma = 0
scores = []
for i in com:
    score = 0
    for j in abcd:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            score += j[3]
    if score > ma:
        ma = score
print(ma)
Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

def floor(t):
    return t // 1

ma = 0
x = 0
a_b = A/B

while True:
    if x > N: break
    a = floor(a_b*x) - A * floor(x/B)
    x += 1
    if a > ma:
        ma = a

print(int(ma))   

Fixed submission:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

x = min(B-1, N) # 0 <= x < B and 0 <= x <= N
a = (A * x) // B - A * (x // B)

print(int(a))

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

def floor(t):
    return t // 1

ma = 0
x = 0
while True:
    if x > N: break
    a = floor(A*x/B) - A * floor(x/B)
    x += 1
    if a > ma:
        ma = a

print(int(ma))   

Fixed submission:
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

A, B, N = [int(_) for _ in input().split()]

x = min(B-1, N) # 0 <= x < B and 0 <= x <= N
a = (A * x) // B - A * (x // B)

print(int(a))
Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)

Fixed submission:
from math import gcd
K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)

Fixed submission:
from math import gcd
K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)

Fixed submission:
from math import gcd
K = int(input())

ret = 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):
            ret += gcd(n, c)
print(ret)