Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)

Fixed submission:
n,a,b=list(map(int,input().split()))

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=list(map(int,input().split()))
from math import factorial as f
ans=1
ans2=1
for i in range(n-a):
    ans*=(n-i)
for i in range(n-b):
    ans2*=(n-i)
print(int(2**n-ans/f(n-a)-ans2/f(n-b)-1))

Fixed submission:
n,a,b=list(map(int,input().split()))

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=list(map(int,input().split()))
from math import factorial as f
print(int(2**n-f(n)/(f(n-a)*f(a))-f(n)/(f(n-b)*f(b)))-1)

Fixed submission:
n,a,b=list(map(int,input().split()))

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=list(map(int,input().split()))
from math import factorial as f
A=[i for i in range(1,n+1) if i!=a and i!=b]
ans=0
for i in A:
    ans+=f(n)/(f(n-i)*f(i))
print(int(ans))

Fixed submission:
n,a,b=list(map(int,input().split()))

p=10**9+7
ans1=1
ans2=1

for i in range(n-a+1,n+1):
    ans1*=i
    ans1%=p

for i in range(1,a+1):
    ans1*=pow(i,p-2,p)
    ans1%=p
    
for i in range(n-b+1,n+1):
    ans2*=i
    ans2%=p

for i in range(1,b+1):
    ans2*=pow(i,p-2,p)
    ans2%=p

print((pow(2,n,p)-ans1-ans2-1)%p)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[input() for i in range(N)]
D=dict()
C=[]
for i in set(A):
    D[i]=0
for i in A:
    D[i]+=1
ans=0
for i in D.keys():
    if D[i]==max(D.values()):
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

Fixed submission:
N=int(input())
A=[input() for i in range(N)]

from collections import Counter
counter=Counter(A)
m=max(counter.values())
C=[]
for i,value in counter.items():
    if value==m:
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
D=dict()
C=[]
for i in set(A):
    D[i]=0
for i in A:
    D[i]+=1
ans=0
for i in D.keys():
    if D[i]==max(D.values()):
        C.append(i)
C=sorted(C)
print(*C,sep='\n')

Fixed submission:
N=int(input())
A=[input() for i in range(N)]

from collections import Counter
counter=Counter(A)
m=max(counter.values())
C=[]
for i,value in counter.items():
    if value==m:
        C.append(i)
C=sorted(C)
print(*C,sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
counter=0
ans=0
for i in range(len(p)-K+1):
    count=0
    for j in range(K):
        count+=p[i+j]
    if counter<=count:
        counter=count
        ans=i
p2=[]
for i in range(K):
    p2.append(p[ans+i])
p3=[]
for i in p2:
    p3.append((sum(range(1,i+1))/i))
print(sum(p3))

Fixed submission:
from itertools import accumulate
from collections import deque
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p2=list(accumulate(p))
p2=deque(p2)
p2.appendleft(0)
p3=[]
ans=0
counter=0
ans2=0
for i in range(N-K+1):
    if counter<p2[i+K]-p2[i]:
        counter=p2[i+K]-p2[i]
        ans=i
for i in range(K):
    ans2+=sum(list(range(1,p[ans+i]+1)))/p[ans+i]
    
print(ans2)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
counter=0
ans=0
for i in range(len(p)-K+1):
    count=0
    for j in range(K):
        count+=p[i+j]
    if counter<=count:
        counter=count
        ans=i
p2=[]
for i in range(K):
    p2.append(p[ans+i])
p3=[]
from itertools import accumulate
for i in p2:
    p3.append((sum(range(1,i+1))/i))
print(sum(p3))

Fixed submission:
from itertools import accumulate
from collections import deque
N,K=list(map(int,input().split()))
p=list(map(int,input().split()))
p2=list(accumulate(p))
p2=deque(p2)
p2.appendleft(0)
p3=[]
ans=0
counter=0
ans2=0
for i in range(N-K+1):
    if counter<p2[i+K]-p2[i]:
        counter=p2[i+K]-p2[i]
        ans=i
for i in range(K):
    ans2+=sum(list(range(1,p[ans+i]+1)))/p[ans+i]
    
print(ans2)
Buggy python submission (verdict: Time Limit Exceeded):
H=int(input())
from collections import deque
stack=deque([H])
ans=0
while stack:
    ans+=1
    x=stack.pop()
    if x>1:
        stack.append(x//2)
        stack.append(x//2)
    else:
        continue
print(ans)

Fixed submission:
H=int(input())
counter=0
while H>1:
    H=H//2
    counter+=1
ans=0
for i in range(counter+1):
    ans+=2**i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
A=[]
ans=0
for i in P:
    A.append(i)
    if min(A)==i:
        ans+=1
print(ans)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
A=10**100
ans=0
for i in P:
    A=min(A,i)
    if A==i:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A,B=list(map(int,input().split()))
print(lcm_list([A,B]))

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A,B=list(map(int,input().split()))
print(lcm_list([A,B]))

Buggy python submission (verdict: Runtime Error):

import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
A,B=list(map(int,input().split()))
print(lcm(A,B))

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A,B=list(map(int,input().split()))
print(lcm_list([A,B]))

Buggy python submission (verdict: Runtime Error):

import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
A,B=list(map(int,input().split()))
print(lcm(A,B))

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

A,B=list(map(int,input().split()))
print(lcm_list([A,B]))
Buggy python submission (verdict: Runtime Error):

import itertools as it
import math
from statistics import mean
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
A=[]
for i in list(it.permutations(X,N)):
    B=[]
    for j in range(N-1):
        B.append(math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2))
    A.append(sum(B))
print(mean(A))

Fixed submission:
import itertools as it
import math
from statistics import mean
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
A=[]
for i in list(it.permutations(X,N)):
    B=[]
    for j in range(N-1):
        B.append(math.sqrt((i[j][0]-i[j+1][0])**2+(i[j][1]-i[j+1][1])**2))
    A.append(sum(B))
print(mean(A))
Buggy python submission (verdict: Time Limit Exceeded):
count=0
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k)==S:
                count+=1
print(count)

Fixed submission:
count=0
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        if S-i-j>=0 and S-i-j<=K:
            count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k)==S:
                count+=1
print(count)

Fixed submission:
count=0
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        if S-i-j>=0 and S-i-j<=K:
            count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        for k in range(K+1):
            if (i+j+k)==S:
                count+=1
print(count)

Fixed submission:
count=0
K,S=map(int,input().split())
for i in range(K+1):
    for j in range(K+1):
        if S-i-j>=0 and S-i-j<=K:
            count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
b=a[0]+a[1]+a[2]
print(b)

Fixed submission:
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
b=a[0]+a[1]+a[2]
print(b)

Fixed submission:
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(a[0]+a[1]+a[2])

Fixed submission:
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(a[0]+a[1]+a[2])

Fixed submission:
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')
Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * 100
for p in P: lis[p-1] -= 1

for i in range(100):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()


Fixed submission:
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * 100
for p in P: lis[p-1] -= 1

for i in range(50):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()



Fixed submission:
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * 100
print(lis)
for p in P: lis[p-1] -= 1
print(lis)

for i in range(50):
    up = X+i
    down = X-i
    if lis[down-1] == 1:
        print(down)
        exit()
    elif lis[up-1] == 1:
        print(up)
        exit()


Fixed submission:
X, N = map(int, input().split())
P = list(map(int, input().split()))

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
INF = 1000000000000000000

for a in A:
    ans *= a
    
if ans > INF:
    print(-1)
else:
    print(ans)


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

ans = 1
INF = 1000000000000000000

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > INF:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
INF = 1000000000000000000

# for a in A:
#     ans *= a

import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)
ans = prod(A)

if ans > INF:
    print(-1)
else:
    print(ans)


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

ans = 1
INF = 1000000000000000000

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > INF:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

ans = 1
INF = 1000000000000000000

for a in A:
    ans *= a

if ans > INF:
    print(-1)
else:
    print(ans)


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

ans = 1
INF = 1000000000000000000

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > INF:
        print(-1)
        exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = map(int, input().split())

ans = 1
INF = 1000000000000000000

for a in A:
    ans *= a

if ans > INF:
    print(-1)
else:
    print(ans)


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

ans = 1
INF = 1000000000000000000

if 0 in A:
    print(0)
    exit()

for a in A:
    ans *= a
    if ans > INF:
        print(-1)
        exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int,input().split())
# a = list(map(int, input().split()))

D = 60
MAX_N = 200005
to[D][MAX_N]

for i in range(n):
    to[0][i] = int(input())
    to[0][i] -= 1

for i in range(i, D-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]

v = 0
for i in range(D-1,0):
    l = 1<<i
    if (l <= k):
        v = to[i][v]
        k -= l

print(v+1)


Fixed submission:
n, k = map(int,input().split())
a = list(map(int, input().split()))

s = []
ord = [-1]*(n+1)
c = 1
l = 0


v = 1
while (ord[v] == -1):
    ord[v] = len(s)
    s.append(v)
    v = a[v-1]
    
c = len(s) - ord[v]
l = ord[v]


if (k < l): print(s[k])
else:
    k -= l
    k %= c
    print(s[l+k])
Buggy python submission (verdict: Runtime Error):
S=input()
if S=='ABC':
    print('ARC')
else S:
    print('ABC')


Fixed submission:
S=input()
if S=='ABC':
    print('ARC')
else :
    print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
H=list(map(int, input().split()))
A, B = [0]*M, [0]*M

ans = [True]*N
tmp = []

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if not a in tmp: tmp.append(a)
    if not b in tmp: tmp.append(b)
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

ctr = 0
for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)


Fixed submission:
N,M=map(int, input().split())
H=list(map(int, input().split()))

ans = [True]*N
ctr = 0

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)

Buggy python submission (verdict: Runtime Error):
X=int(input())

for i in range(0, 1000):
    for j in range(-1000,0):
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
N,M=map(int, input().split())
H=list(map(int, input().split()))

ans = [True]*N
ctr = 0

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)

Buggy python submission (verdict: Runtime Error):
X=int(input())

for i in range(0, 1000):
    for j in range(-1000,0):
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
N,M=map(int, input().split())
H=list(map(int, input().split()))

ans = [True]*N
ctr = 0

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] >= H[b]: ans[b] = False
    if H[a] <= H[b]: ans[a] = False

for i in range(N):
    if ans[i]:
        ctr += 1

print(ctr)
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(31622):
    for j in range(31622):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
X=int(input())

for i in range(-200,200):
    for j in range(-200,200):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(31633000):
    for j in range(31622000):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
X=int(input())

for i in range(-200,200):
    for j in range(-200,200):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(1000):
    for j in range(10000):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
X=int(input())

for i in range(-200,200):
    for j in range(-200,200):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())

for i in range(10000):
    for j in range(10000):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()


Fixed submission:
X=int(input())

for i in range(-200,200):
    for j in range(-200,200):
        j *= -1
        if X == (i**5-j**5):
            print(i, j)
            exit()
Buggy python submission (verdict: Runtime Error):
import math
import itertools

N,M,Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int, input().split())

maximum = 0
lis = list(range(1, M+1, 1))
for pair in itertools.combinations(lis, N):
    sum = 0
    pair = list(pair)
    for i in range(N):
        if pair[b[i]-1]-pair[a[i]-1] == c[i]:
            sum += d[i]
            
    if maximum < sum:
        maximum = sum

print(maximum)


Fixed submission:
from itertools import combinations_with_replacement as combr

N,M,Q = map(int, input().split())
a, b, c, d = [0]*Q, [0]*Q, [0]*Q, [0]*Q
for i in range(Q):
    a[i],b[i],c[i],d[i] = map(int, input().split())

ans = 0
# lis = list(range(1, M+1))
for pair in combr(range(1,M+1), N):
    tmp = 0
    pair = list(pair)
    for i in range(Q):
        if (pair[b[i]-1]-pair[a[i]-1]) == c[i]:
            tmp += d[i]
            
    ans=max(ans, tmp)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

A, B, N = map(int, input().split())

ans = 0

for i in range(N+1):
    ans=max(ans, math.floor(A*i/B)-A*math.floor(i/B))

print(ans)


Fixed submission:
import math
A, B, N = map(int, input().split())

x = N

if (N >= B-1): x = B-1
ans = A*(x%B)//B

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for _ in range(N)]

S.sort()
items = 0
i = 0

while i < N:
    items += 1
    for j in range(i+1, N):
        if S[i] == S[j]:
            i += 1
    i += 1

print(items)
       

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

print(len(set(S)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [input() for _ in range(n)]

items = []

for i in range(n):
    new = True
    for j in range(len(items)):
        if s[i] == items[j]:
            new = False
    if new:
        items.append(s[i])
    
print(len(items))


Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

print(len(set(S)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
N = N+1
sum = 0

import math

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

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

print( sum )


Fixed submission:
N = int(input())
N = N+1
sum = 0

from math import gcd

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

print( sum )

Buggy python submission (verdict: Runtime Error):
N = int(input())
N = N+1
sum = 0

import math

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

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

print( sum )


Fixed submission:
N = int(input())
N = N+1
sum = 0

from math import gcd

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

print( sum )

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
N = N+1
sum = 0

import math
from functools import reduce

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

for i in range(1, N):

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

print( sum )


Fixed submission:
N = int(input())
N = N+1
sum = 0

from math import gcd

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

print( sum )
Buggy python submission (verdict: Runtime Error):
from math

N, K = map(int, input().split())

if N==1 or K==1:
    print(0)
else:
    print(math.gcd(N, K))


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

ans = N

tmp = N%K

if tmp > abs(tmp-K):
    print(abs(tmp-K))
else:
    print(tmp)

Buggy python submission (verdict: Runtime Error):
from math import gcd

N, K = map(int, input().split())

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))


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

ans = N

tmp = N%K

if tmp > abs(tmp-K):
    print(abs(tmp-K))
else:
    print(tmp)

Buggy python submission (verdict: Runtime Error):
from math import gcd

N, K = map(int, input().split())

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))


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

ans = N

tmp = N%K

if tmp > abs(tmp-K):
    print(abs(tmp-K))
else:
    print(tmp)

Buggy python submission (verdict: Runtime Error):
from math import gcd

N, K = map(int, input().split())

if N==1 or K==1:
    print(0)
else:
    print(gcd(N, K))


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

ans = N

tmp = N%K

if tmp > abs(tmp-K):
    print(abs(tmp-K))
else:
    print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

ans = 0

while N > 0:
    red = min(N, A)
    ans += red
    N -= red
    blue = min(N, B)
    N -= blue
print(ans)


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

rep = N//(A+B)
ans = A*rep
diff = N - (A+B)*rep
ans += min(diff, A)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())

ans = 0

while N > 0:
    red = min(N, A)
    ans += red
    N -= red
    blue = min(N, B)
    N -= blue
print(ans)


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

rep = N//(A+B)
ans = A*rep
diff = N - (A+B)*rep
ans += min(diff, A)
print(ans)