qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N,A,B=map(int, input().split())

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
print(s*A+sA*A+sAG)

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

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
  sAG=0
print(s*A+sA*A+sAG)
Buggy code:
n, a, b = map(int, input().split(' '))
print(min(int(n%(a+b)),a)+int((n//(a+b)1)*a))

Fixed code:
n, a, b = map(int, input().split(' '))
print(min(int(n%(a+b)),a)+int((n//(a+b))*a))
Buggy code:
n, a, b = map(int, input().split(' '))
print(int(min(n-n//(a+b),a))+int((n//(a+b))*a))

Fixed code:
n, a, b = map(int, input().split(' '))
r = n//(a+b)
print(int(r*a+min((n-r*(a+b),a))))
Buggy code:
 N, A, B = map(int, input().split())
 ans = N // (A + B) * A
 rem = N % (A + B)
 ans += min(rem, A)
 print(ans)


Fixed code:
N, A, B = map(int, input().split()) 
ans=N//(A+B)*A
rem=N%(A+B)
ans += min(rem, A)
print(ans)
Buggy code:
n,a,b = map(int,input().split())
ans = n//(a+b)*a
rem = n%(a+b)
ans +=(rem,a)
print(ans)

Fixed code:
n,a,b = map(int,input().split())
ans = n // (a+b) * a
rem = n % (a+b)
ans += min(rem,a)
print(ans)
Buggy code:
N, A, B = map(int,input().split())

ans = (N//(A+B)) + min(N%(A+B),A)

print(ans)

Fixed code:
N, A, B = map(int,input().split())
ans = A*(N//(A+B)) + min(N%(A+B),A)
print(ans)
Buggy code:
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b
    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

Fixed code:
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b

    if n <= a:
        print(n)
        return

    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

if doTest==0:
    resolve()
    sys.exit()
Buggy code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = n % all_ball
print(count * all_ball + min(rest, blue_num))


Fixed code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // all_ball
rest = num % all_ball
print(count * blue_num + min(rest, blue_num))
Buggy code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    print(A)
    
if __name__ == '__main__':
    main()


Fixed code:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    ans = N//(A+B)*A
    rem = N%(A+B)
    print(ans+min(rem, A))
if __name__ == '__main__':
    main()
Buggy code:
n, a, b = map(int, input().split().rstrip())
k = n // (a + b)
r = n % (a + b)
print(k * a + min(r, a))


Fixed code:
n, a, b = map(int, input().rstrip().split())
k = n // (a + b)
r = n % (a + b)
print(k * a + min(r, a))
Buggy code:
n,a,b=map(int,input().split())
i=n%(a+b)
print(i)
if i>a:
    print(a*(n//(a+b))+a)
else:
    print(a*(n//(a+b))+i)

Fixed code:
n,a,b=map(int,input().split())
i=n%(a+b)
if i>a:
    print(a*(n//(a+b))+a)
else:
    print(a*(n//(a+b))+i)
Buggy code:
n,a,b=map(int,input().split())

kaisu = int(n // (a+b))
amari = int(n % (a + b))
ans = kaisu * b
if amari  > b:
    ans += b
else:
    ans += amari

print(ans)

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

kaisu = int(n // (a+b))
amari = int(n % (a + b))
ans = kaisu * a
if amari > a:
    ans += a
else:
    ans += amari

print(ans)
Buggy code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i == A
count = j * A + i


Fixed code:
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i
print(count)
Buggy code:
N, A, B = [int(i) for i in input().strip().split()]
if A < N:
  print(A)
else:
  q, r = divmod(N, A+B)
  print(A*q + r)


Fixed code:
N, A, B = [int(i) for i in input().strip().split()]
q, r = divmod(N, A+B)
if r <= A:
  print(A*q + r)
else:
  print(A*q + A)
Buggy code:
n, a, b = map(int,input().split())
p = n // (a+b)
ans = a*b + min(a,(n%(a + b)))
print(ans)

Fixed code:
n,a,b = map(int,input().split())
ans = n // (a+b)
n %= (a+b)
ans *= a
ans += min(a,n)
print(ans)
Buggy code:
n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*b + [b,q][q<b]) 

Fixed code:
n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*a + [a,q][q<a])
Buggy code:
n,a,b = map(int, input().split())
m1 = n // (a + b)
m2 = n % (a + b)
print(m1,m2)
if a ==0:
  print(0)
elif a + b > n:
  print(a)
elif a > n:
  print(n)
else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)

Fixed code:
n,a,b = map(int, input().split())
m1 = n // (a + b)
m2 = n % (a + b)

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print((m1 + 1) * a )
  else:
    print(m1 * a + m2)
Buggy code:
n,a,b=map(int,input().split())

print(n//(a+b)*a+mi,min(a,n%(a+b))
    


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

print(n//(a+b)*a+min(a,n%(a+b)))
Buggy code:
n, a, b = [int(i) for i in input().split]

if a + b == 0:
  print(0)
else:
  c, r = n // (a + b), n % (a + b)
  nblue = c * a + min(a, r)
  print(nblue)


Fixed code:
def main():
    n, a, b = [int(i) for i in input().split()]

    if a + b == 0:
        print(0)
    else:
        c, r = n // (a + b), n % (a + b)
        nblue = c * a + min(a, r)
        print(nblue)

main()
Buggy code:
# B
n, a, b = map(int, input().split())

if n <= a+b:
    if n >= a:
        print(a)
    elif n < a:
        print(n)
elif n > a+b:
    ans = (n//(a+b))*a
    if n-ans >= a:
        print(ans+a)
    elif n < a:
        print(ans+n)

Fixed code:
# B
n, a, b = map(int, input().split())

if n <= a+b:
    if n >= a:
        print(a)
    elif n < a:
        print(n)
elif n > a+b:
    taba = n//(a+b)
    if n-taba*(a+b) >= a:
        print(taba*a+a)
    elif n-taba*(a+b) < a:
        print(taba*a+n-taba*(a+b))
Buggy code:
n,a,b = map(int,input().split())
k = n//(a+b)
h = min(a,n%(a+b))
print(k+h)


Fixed code:
n,a,b = map(int,input().split())
k = n//(a+b)
h = min(a,n%(a+b))
print(a*k+h)
Buggy code:
n,a,b = map(int,input().split())
print(a*n//(a+b)+min(n%(a+b),a)

Fixed code:
n, a, b=map(int,input().split())
print((n//(a+b))*a + min(n%(a+b), a))
Buggy code:
n, a, b = map(int, input().split())

if a+b <= n:
  print(a)
elif n%(a+b) <= a:
  print((n//(a+b))*a + n%(a+b))
else:
  print((n//(a+b))*a + a)

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

if a >= n:
  print(n)
elif a+b >= n:
  print(a)
elif n%(a+b) <= a:
  print((n//(a+b))*a + n%(a+b))
else:
  print((n//(a+b))*a + a)
Buggy code:
N,a,b=map(int,input().split())
c=N//(a+b)
d=N%(a+b)
if d<=a:
  print(c*b+d)
else:
  print(c*b+a)


Fixed code:
N,a,b=map(int,input().split())
c=N//(a+b)
d=N%(a+b)
if d<=a:
  print(c*a+d)
else:
  print(c*a+a)
Buggy code:
n, a, b = map(int,input().split())
a_b = n//(a+b)*a
if n - n//(a+b)*(a*b) < a:
    print(a_b + (n - n//(a+b)*(a+b)))
else:
    print(a_b + b)

Fixed code:
n, a, b = map(int,input().split())
a_b = n//(a+b)*a
if n%(a+b) < a:
    print(a_b + n%(a+b))
else:
    print(a_b + a)
Buggy code:
N, A, B = map(int, input().split())
len_loop = A + B
n_comp_loop = N//len_loop
blue_res = max(A, N % len_loop)
print(n_comp_loop * A + blue_res)


Fixed code:
N, A, B = map(int, input().split())
len_loop = A + B
n_comp_loop = N//len_loop
blue_res = min(A, N % len_loop)
print(n_comp_loop * A + blue_res)
Buggy code:
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if (total%(red+blue)) >= blue:
        print(num*blue+(total%(red+blue)))
    else:
        print(num*blue+blue)

Fixed code:
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if (total%(red+blue)) <= blue:
        print(num*blue+(total%(red+blue)))
    else:
        print(num*blue+blue)
Buggy code:

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
print(c)
d = N%(A+B)
print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b) 


Fixed code:

N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
#print(c)
d = N%(A+B)
#print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b)
Buggy code:
N, A, B = map(int, input().split())
mul = N // (A + B)
mod = N % (A + B)
ret = mul * A * min(mod, A)
print(ret)

Fixed code:
N, A, B = map(int, input().split())
mul = N // (A + B)
mod = N % (A + B)
ret = mul * A + min(mod, A)
print(ret)
Buggy code:
n, a, b = map(int,input().split())

if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print(answer*a) + min(a, remainder)
else:
  print(0)

Fixed code:
n, a, b = map(int,input().split())
 
if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print((answer*a) + min(a, remainder))
else:
  print(0)
Buggy code:
n,b,r = map(int, input().split())

t = n % (b + r)

if t >= b: print(b)
else: print(t)
  


Fixed code:
n,b,r = map(int, input().split())

t = n % (b + r)

if t >= b: print(b * int(n//(b+r)) + b)
else: print(b * int(n//(b+r)) + t)
Buggy code:
n,a,b = (int(x) for x in input().split())

t = a+b
q = n%t
p = (n-q)//t

print(min(p+q,p+a))


Fixed code:
n,a,b = (int(x) for x in input().split())

t = a+b
q = n%t
p = (n-q)//t
print(min(a*p+q,a*p+a))
Buggy code:
n,b,r = map(int, input().split())		# 5 7 2

ans = (n//(b+r)) + min(n%(b+r),b)

print(ans)



Fixed code:
n,b,r = map(int, input().split())		# 5 7 2

ans = (n//(b+r))*b + min(n%(b+r),b)

print(ans)
Buggy code:
n,a,b=map(int, input().split())
count=n//a+b*a
n=n%(a+b)
count+=min(n,a)
print(count)


Fixed code:
n,a,b=map(int, input().split())
count=n//(a+b)*a
n=n%(a+b)
count+=min(n,a)
print(count)
Buggy code:
balls=map(int,input().split())
print((n//(a+b))*a+min(a,n%(a+b)))

Fixed code:
n,a,b=map(int,input().split())
print((n//(a+b))*a+min(a,n%(a+b)))
Buggy code:
N, A, B = map(int, input().split())
print(N, A, B)
x = N//(A+B)
r = N - (A+B)*x
if r >= A:
    add = A
else:
    add = r

print(x*A + add)

Fixed code:
N, A, B = map(int, input().split())
x = N//(A+B)
r = N - (A+B)*x
if r >= A:
    add = A
else:
    add = r

print(x*A + add)
Buggy code:
N, A, B = map(int, input().split())
k = N % (A+B)
n = N / (A+B)

if n < A:
  print(n+k*A)
else:
  print(A+k*A)

Fixed code:
N, A, B = map(int, input().split())
n = N % (A+B)
k = N // (A+B)

if n < A:
  print(n+k*A)
else:
  print(A+k*A)
Buggy code:
N, A, B = [int(i) for i in input().split()]

S = N//(A+B)*A

S = S+(N%S,A)
print(S)

Fixed code:
N, A, B = [int(i) for i in input().split()]
S = A+B
c = (N//S)*A
 
c += min(N%S,A)
print(c)
Buggy code:
n,b,r = map(int, input().split())
s = n // (b+r)
a = n % (b+r)
ans = s * b
ans += min(a, b)
print({}.format(ans))

Fixed code:
n,b,r = map(int, input().split())
s = n // (b+r)
a = n % (b+r)
ans = s * b
ans += min(a, b)
print("{}".format(ans))
Buggy code:
#N = str(input())
N,A,B = map(int,input().split())
#X=list(map(int,input().split()))

if A==0:
    print(0)
else:
    b=N//(A+B)
    x=N%(A+B)

if x>A:
    x=A

    print(b*A+x)


Fixed code:
#N = str(input())
N,A,B = map(int,input().split())
#X=list(map(int,input().split()))

if A==0:
    print(0)
    exit()
else:
    b=N//(A+B)
    x=N%(A+B)

    if x>A:
        print(b*A+A)
    else:
        print(b*A+x)
Buggy code:
n,a,b=map(int,input().split())
if n%(a+b)>=a:
  s=a
  
else:
  s=n%(a+b)
print(n//(a+b)+s)

Fixed code:
n,a,b=map(int,input().split())
if n%(a+b)>=a:
  s=a
  
else:
  s=n%(a+b)
print(n//(a+b)*a+s)
Buggy code:
n,a,b=map(int, input().split())
tmp = 0
if n%a+b>a:
    tmp = a
else:
    tmp = 0
print((n//(a+b))*a+tmp)

Fixed code:
n,a,b=map(int, input().split())
tmp = n%(a+b)
if tmp>a:
    tmp = a
print((n//(a+b))*a+tmp)
Buggy code:
N, A, B = map(int, input().split())
C = A + B
x = N // C
y = N % C
p = x * A
q = min(y, A)
p + q

Fixed code:
N, A, B = map(int, input().split())
C = A + B
x = N // C
y = N % C
p = x * A
q = min(y, A)
print(p + q)
Buggy code:
import math
def main():
  n, a, b = map(int, input().split())
  total = 0
  
  if n <= a + b:
    print(int(n - b))
  else:
    x = math.floor(n / (a+b))
    total = a * x
    y = n % (a+b)
    if y >= a:
      total += a
    else:
      total += y
      
      
  print(total)
  
  
main()

Fixed code:
import math
def main():
  n, a, b = map(int, input().split())
  total = 0
  
  # if n <= a + b:
  #   print(int(n - b))
  # else:
  x = math.floor(n / (a+b))
  total = a * x
  y = n % (a+b)
  if y >= a:
    total += a
  else:
    total += y
      
      
  print(total)
  
  
main()
Buggy code:
def resolve():
    N, A, B = map(int, input().split())  

    ao_count = 0

    count_num = N / (A + B)
    amari_num = N % (A + B)

    ao_count = count_num * A
    if amari_num <= A:
        ao_count += A


    print(ao_count)



if __name__ == "__main__":
    resolve()

Fixed code:
def resolve():
    N, A, B = map(int, input().split())  

    ao_count = 0

    count_num = N // (A + B)
    amari_num = N % (A + B)



    ao_count = count_num * A

    if A <= amari_num:
        ao_count += A
    else:
        ao_count += amari_num

    print(ao_count)



if __name__ == "__main__":
    resolve()
Buggy code:
n, a, b = map(int,input().split())
tot = a + b
bcnt = (n // tot) * b
n -= (n // tot) * tot
bcnt += min(n,b)
print(bcnt)


Fixed code:
n, a, b = map(int,input().split())
tot = a + b
bcnt = (n // tot) * a
n -= (n // tot) * tot
bcnt += min(n,a)
print(bcnt)
Buggy code:
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif a+b >= n:
    print(n)
else:
    ab = a + b
    ans = n // ab * a + n % ab
    print(ans)

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

if a == 0:
    print(0)
elif a+b >= n:
    print(a) if a <= n else print(n)
else:
    ab = a + b
    ans = n // ab * a
    ans += a if n % ab > a else n % ab 
    print(ans)
Buggy code:
n, a, b = map(int, input().split())

x = n // (a + b)
ans = a * a + min(a, n - (a + b)*x)
print(ans)


Fixed code:
n,a,b = map(int, input().split())
x = n // (a + b)
ans = a * x + min(a,n - (a + b) * x)
print(ans)
Buggy code:
# coding:utf-8


from math import ceil

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)


Fixed code:
# coding:utf-8


from math import floor

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)
Buggy code:
a,b,c=input().strip().split(" ")
a,b,c=[int(a),int(b),int(c)]
p=b+c
x=a//p
m=a%p
pp=min(b,m)
print(pp+x*a)

Fixed code:
a,b,c=input().strip().split(" ")
a,b,c=[int(a),int(b),int(c)]
p=b+c
x=a//p
m=a%p
pp=min(b,m)
print(pp+x*b)
Buggy code:
n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
print(ans, rem, a)
ans += min(rem, a)
print(ans)


Fixed code:
n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)
Buggy code:
N, A, B = map(int,input().split())

x = N // (A+B)

y = N % (A+B)

ans = x + min(A, y)

print(ans)

Fixed code:
N, A, B = map(int,input().split())
 
x = A * (N // (A+B))
 
y = N % (A+B)
 
ans = x + min(A, y)
 
print(ans)
Buggy code:
n,a,b=map(int,input().split())
ans=n/(a+b)
 if n%(a+b)>=a:
    ans+=a
 else:
    ans+=n%(a+b)
print(ans)

Fixed code:
n,a,b = map(int,input().split())
if n % (a + b) > a:
    print(n // (a + b) * a + a)
else:
    print(n // (a + b) * a + n % (a + b))
Buggy code:
s = input()
n, a, b = s.split(' ')
n = int(n)
a = int(a)
b = int(b)
na = n / (a+b) * a 
if n % (a+b) >= a :
  na += a
else:
  na += n % (a+b)
  
print(na)

Fixed code:
s = input()
n, a, b = s.split(' ')
n = int(n)
a = int(a)
b = int(b)

na = n // (a+b) * a
if n % (a+b) >= a:
  na += a
else:
  na += (n % (a + b))
  
print(na)
Buggy code:
b=map(int,input().split())
print((n//(a+b))*a+min([n%(a+b),a]))

Fixed code:
n,a,b=map(int,input().split())
print(((n//(a+b))*a)+min([n%(a+b),a]))
Buggy code:
n,a,b = list(map(int,input().split()))
if(a != 0):
    kurikaeshi = n // (a + b)
    mod = n % (a + b)
    ans = a*kurikaeshi
    if(mod - a > 0):
        ans += mod
if(a == 0):
    ans = 0
print(ans)

Fixed code:
n,a,b = list(map(int,input().split()))
if(a != 0):
    kurikaeshi = n // (a + b)
    mod = n % (a + b)
    ans = a*kurikaeshi
    if(mod - a > 0):
        ans += a
    else:
        ans += mod
if(a == 0):
    ans = 0
print(ans)
Buggy code:
n,a,b= map(int,input().split())
ans = (n//(a+b))*a
rem += (n%(a+b))
ans = min(rem,a)
print(ans)

Fixed code:
n,a,b=map(int,input().split())
x=n%(a+b)
ans=(n//(a+b))*a+min(x,a)
print(ans)
Buggy code:
n,a,b = map(int,input().split())
dars = n // (a+b)*a
amari = n % (a+b)
dars = min(amari,a)
print(dars)

Fixed code:
n,a,b = map(int,input().split())
dars = n // (a+b)*a
amari = n % (a+b)
dars += min(amari,a)
print(dars)
Buggy code:
n,a,b = map(int,input().split())
c = a + b
ans = n/(a+b) + min(n%c,b)

print(ans)


Fixed code:
n,a,b = map(int,input().split())
c = a + b
ans = n//c*a + min(n%c,a)

print(ans)
Buggy code:
def main():

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

    # blue = ['b']*A
    # red = ['r']*B
    # l = []
    # while len(l) <= N:
    #     l.extend(blue)
    #     l.extend(red)
    # print(l[:N].count('b'))

    c = 0
    len = 0
    while len <= N-A:
        len += A+B
        c += A
    c += N-len
    print(c)


if __name__ == '__main__':
    main()


Fixed code:
def main():

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

    # blue = ['b']*A
    # red = ['r']*B
    # l = []
    # while len(l) <= N:
    #     l.extend(blue)
    #     l.extend(red)
    # print(l[:N].count('b'))

    # c = 0
    # len = 0
    # while len <= N-A:
    #     len += A+B
    #     c += A
    # c += N-len
    # print(c)

    loops = N // (A+B)
    c = A*loops
    c += min(A, N % (A+B))
    print(c)


if __name__ == '__main__':
    main()
Buggy code:
n,a,b = map(int,input().split())
c = a + b
ans = n/(a+b)*b + min(n%c,b)

print(ans)


Fixed code:
n, a, b = map(int, input().split())
ans = n // (a + b) * a
rest = n % (a + b)
ans += min(rest, a)
print(ans)
Buggy code:
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)
print((x*b)+(y-a))

Fixed code:
n,a,b=map(int,input().split())
x=(n//(a+b))*a
y=min(a,n%(a+b))
print(x+y)
Buggy code:
# -*- coding: utf-8 -*-
i_str = input()
N,A,B = map(int,i_str.split())

import sys
AB = A+B
maxnum = pow(10,100)
if A == 0:
    print(0)
    sys.exit()
if N <= A:
    print(N)
    sys.exit()
waru,amari = divmod(B,AB)
#waru = (N // AB)
#amari = N % AB
if amari > A:
    amari = A
answer = waru * A + amari

print(answer)

Fixed code:
# -*- coding: utf-8 -*-
i_str = input()
N,A,B = map(int,i_str.split())

import sys
AB = A+B
maxnum = pow(10,100)
if A == 0:
    print(0)
    sys.exit()
if N <= A:
    print(N)
    sys.exit()
waru,amari = divmod(N,AB)
#waru = (N // AB)
#amari = N % AB
if amari > A:
    amari = A
answer = waru * A + amari
print(answer)
Buggy code:
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = a // (b + r)
bb = c * b
d = a % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)

Fixed code:
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = n // (b + r)
bb = c * b
d = n % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)
Buggy code:
import math
a = input().split(" ")
res = int(a[0])
div = int(a[1])+int(a[2])
mult = math.floor(res/div)
plus = res%div
answer = int(a[1])*mult + min([plus,int(a[1])])
answer

Fixed code:
import math
a = input().split(" ")
res = int(a[0])
div = int(a[1])+int(a[2])
mult = math.floor(res/div)
plus = res%div
answer = int(a[1])*mult + min([plus,int(a[1])])
print(answer)
Buggy code:
n, a, b = map(int, input().split())
if a < n%7 < b:
     print(n//7*a + a)
else:
     print(n//7*a + n%7)

Fixed code:
n, a, b = map(int, input().split())
if n%(a+b) < a:
    print(n//(a+b)*a+n%(a+b))
else:
    print(n//(a+b)*a+a)
Buggy code:
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

print(x)

if y >= A:
  print(A * x + A)
else:
  print(A * x + y)

Fixed code:
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

if y >= A:
  print(A * x + A)
else:
  print(A * x + y)
Buggy code:
N, A, B = map(int, input().split())
ans = N // (A+B) * A
rem = n % (A+B)
ans += min(rem, A)
print(ans)

Fixed code:
N, A, B = map(int, input().split())
ans = N // (A + B) * A
ans += min(A, N % (A + B))
print(ans)
Buggy code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else:
    res = ((n // sum)*a) + (n % sum)
    
    if n%sum > a: 
        print( ((n // sum)*a) + a

    else:
        print(res)


Fixed code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else: 
    if n%sum > a: 
        print (((n // sum)*a) + a)

    else:
        res = ((n // sum)*a) + (n % sum)
        print(res)
Buggy code:
N, A, B = map(int, input().split())
X = N // (A + B)
R = X * A
X += min(A, N % (A + B))
print(X)

Fixed code:
N, A, B = map(int, input().split())
X = N // (A + B)
R = X * A
R += min(A, N % (A + B))
print(R)
Buggy code:
N, A, B = map(int, input().split())

ans = int(N / (A + B))

r = N % (A + B)

ans = ans + min(r, A)

print(ans)

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

ans = N // (A + B) * A

r = N % (A + B)

ans = ans + min(r, A)

print(ans)
Buggy code:
n,a,b = map(int,input().split())
s = a+b
c = n % s
d = n // s

if s <= a:
  print( a*d + s )

else:
  print( a*d + a )
  

Fixed code:
n,a,b = map(int,input().split())
s = a+b
c = n % s
d = n // s

if c <= a:
  print( a*d + c )

else:
  print( a*d + a )
Buggy code:
n, a, b = map(int, input().split())

fulls = n // (a+b)
lefts = n % (a+b)

print(fulls*a + min(left, a))

Fixed code:
n, a, b = map(int, input().split())
 
fulls = n // (a+b)
lefts = n % (a+b)
 
print(fulls*a + min(lefts, a))
Buggy code:
N, A, B = map(int, input().split())
if A > (N % (A + B)):
    print(N // (A + B) + N % (A + B))
else:
    print(N // (A + B) + A)

Fixed code:
N, A, B = map(int, input().split())
ans = N//(A+B) * A
if N%(A+B) >= A:
  ans += A
else:
  ans += N%(A+B)
print(ans)
Buggy code:
 n,a, b = map(int, input().split())
    ans = n //(a+b) *a
    ans += min(n%(a+b),a)
    print(ans)

Fixed code:
n,a,b=map(int,input().split())
ans=n//(a+b)*a
rem=n%(a+b)
ans+=min(rem,a)
print(ans)
Buggy code:
N,A,B=map(int,input().split)
ans=N//(A+B)*A
rem=N%(A+B)
ans=ans+min(rem,A)
print(ans)

Fixed code:
N,A,B=map(int,input().split())
ans=(N//(A+B))*A
rem=N%(A+B)
ans=ans+min(rem,A)
print(ans)
Buggy code:
n,a,b=map(int,input().split())
ans=b*(n//(a+b))
ans+=min(b,n%(a+b))
print(ans)

Fixed code:
n,a,b=map(int,input().split())
ans=a*(n//(a+b))
ans+=min(a,n%(a+b))
print(ans)