qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,a,b=map(int,input().split())
if n%(a+b)<=b:
  print(n//(a+b)*b+n%(a+b))
else:
  print(n//(a+b)*b+b)

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:
n,a,b = map(int,input().split())
ans = (n//(a+b))*a
ans += min((n-n%(a+b)),a)
print(ans)

Fixed code:
n,a,b=map(int,input().split())
l=n//(a+b)
ans=l*a
ans+=min(n-(a+b)*l,a)
print(ans)
Buggy code:
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n * a / (a+b)
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Fixed code:
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n // (a+b) * a
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)
Buggy code:
N,A,B = input().split()

if int(A) == 0:
    print('0')
else:
    k = (int(N)//(int(A)+int(B))) * int(A) + int(N)%int(A)
    print(str(A))

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

if int(A) == 0:
    print('0')
else:
    k = (int(N)//(int(A)+int(B))) * int(A) 
    if int(N)%(int(A) + int(B)) >= int(A):
        k = k + int(A)
    else:
        k = k + int(N)%(int(A) + int(B))
    print(str(k))
Buggy code:
N,A,B = map(int,input().split())
C = A+B
D = C//N
ans = 0
ans+=D*A
ans+=min(N-D*C,A)
print(ans)

Fixed code:
N,A,B = map(int,input().split())
C = A+B
D = N//C
ans = 0
ans+=D*A
ans+=min(N-D*C,A)
print(ans)
Buggy code:
N,A,B=map(int,input().split())
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, b, a = map(int, input().split())
print(n // (a + b) * b + min(n % (a + b), b)

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())
p=n%(a+b)
x=(n-p)//(a+b)
res=x*a
y=a if p>=a else p
res+=y
print(y)

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

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

print(ans)

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

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

print(ans)
Buggy code:
N,A,B = map(int,input().split())
t = N // (A + B)
s = N % (A + B)
ans = t * A
if s > A :
    ans += (s - A)
    print(ans)
else :
    print(ans)

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

if(A==0 & B==0):
  print("0")

else:
  r=N//(A+B)
  s=N-A*r
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)

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

if(A==0 & B==0):
  print("0")

else:
  r=N//(A+B)
  s=N%(A+B)
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)
Buggy code:
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = N % S if S != 0 and count % 2 == 0 else 0
print(A*count + mod)


Fixed code:
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = min(N % S, A) if S != 0 else 0
print(A*count + mod)
Buggy code:
n,a,b=map(int,input().split())
x=n/(a+b)-n%(a+b)
c=n-(a+b)*x
print(int(a*x+min(c,a)))

Fixed code:
n,a,b=map(int,input().split())
x=n//(a+b)
c=n-(a+b)*x
print(a*x+min(c,a))
Buggy code:
n, a ,b = list(map(int,(input().split())))
k = n//(a+b)
am = n%(a+b)

print(k+min(am,a))

Fixed code:
n, a ,b = list(map(int,(input().split())))
k = n//(a+b)
am = n%(a+b)

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

ans=n//(a+b)
ans=a*ans
hoge=n%(a+b)%1
if(hoge>a):
  ans+=hoge-a
else:
  ans+=hoge

print(int(ans))

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

ans=n//(a+b)
ans=a*ans
hoge=n%(a+b)
if(hoge>a):
  ans+=a
else:
  ans+=hoge

print(ans)
Buggy code:
n,a,b = map(int,input().split())
x = n//(a+b)
if n - x >= a:
    print(x + a)
else:
    print(x + n - x)

Fixed code:
n,a,b = map(int,input().split())
x = n//(a+b)
if n - x*(a+b) >= a:
    print(x*a + a)
else:
    print(x*a + n - x*(a+b))
Buggy code:
n, a, b = map(int, input().split())
ab = a + b
syou = ab // n
amari = ab % n
print(syou * a + min(amari, a))

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans)
Buggy code:
N, A, B = list(map(int, input().split()))
pair = N // (A + B)
rest = N % (A + B)
if rest >= A:
    ans = pair * (A + 1)
else:
    ans = pair * A + rest
print(ans)

Fixed code:
N, A, B = list(map(int, input().split()))
pair = N // (A + B)
rest = N % (A + B)
if rest >= A:
    ans = A * (pair + 1)
else:
    ans = pair * A + rest
print(ans)
Buggy code:
n,a,b=map(int,input().split())
import math
x=math.floor(n/(a+b))
print(x*a+max(a,n-x*(a+b)))

Fixed code:
n,a,b=map(int,input().split())
import math
x=math.floor(n/(a+b))
print(x*a+min(a,n-x*(a+b)))
Buggy code:
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
    if t <= a:
    	x = s*a+t
	else:
    	x = s*a+a
print(x)

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

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

if a==0:
  print(0)
else:
  s= n//(a)
  sn = n%(a)
  
  print (s+sn)



Fixed code:

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

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

ans = n//(a + b)*a
ans+=min(a,n%(a+b))
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 = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
answer *= a
print(answer + max(a, amari))

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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + rem
else:
	sum =c + rem

print(sum)

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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + A
else:
	sum =c * A + rem

print(sum)
Buggy code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = total//n
diff = n % total
if b < diff:
    print(diff + circle*b)
else:
    print(b + circle*b)


Fixed code:
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = n//total
diff = n % total
if b <= diff:
    print(b + circle*b)
else:
    print(diff + circle*b)
Buggy code:
n, a, b = map(int, input().split())
print(n//(a+b) * (a+1)) if n%(a+b)>=a else print(n//(a+b) * a + (n%(a+b)))

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

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

count = n // (a + b)
mod = n % (a + b)

res = count * b
if mod > a:
  res += (mod - a)
  
print(res)

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

count = n // (a + b)
mod = n % (a + b)

res = count * a
if mod > a:
  res += a
else:
  res += mod
 
print(res)
Buggy code:
N, A, B = map(int, input().split())

s = A + B
ans = (N // s)*B
if (N % s) < A: print(ans)
else: print(ans + (N%s-A))

Fixed code:
N, A, B = map(int, input().split())
 
s = A + B
ans = (N // s)*A
if (N % s) < A: print(ans + N % s)
else: print(ans + 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())
K = A+B
ans = (N//K)*A
ans += min(A,N%K)
print(ans)
Buggy code:
n,a,b = map(int,input().split())
ans = 0
q = n // (a+b)
ans += q*a
q = n - (a+b)*q
if q - a >= 0:
    ans += a

print(ans)

Fixed code:
n,a,b = map(int,input().split())
ans = 0
q = n // (a+b)

ans += q*a
q = n - (a+b)*q

if q - a >= 0:
    ans += a
if q - a < 0:
    ans = ans + a +(q-a)
print(ans)
Buggy code:
n,a,b=map(int,input().split())
x=n//(a+b)
if (a+b)*x<=a:
  t=n-x*(a+b)
else:
  t=a
print(a*x+t)


Fixed code:
n,a,b=map(int,input().split())
x=n//(a+b)
if n-(a+b)*x<=a:
  t=n-x*(a+b)
else:
  t=a
print(a*x+t)
Buggy code:
N, A, B = map(int, input().split())

pattern = N // (A + B)

ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)

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

pattern = N // (A + B)

ans = 0
ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)
Buggy code:
N , A , B = int(input().split())
a = N // ( A + B )
b = N % ( A + B )

if b >> A:
    print( a * A + A )
else:
    print( a * A + b ) 

Fixed code:
N , A , B = map(int, input().split())
AB = A + B
a = N // AB
b = N % AB



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

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

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

Fixed code:
N, A, B = map(int, input().split())
an = N // (A+B) * A
rem = N % (A+B)
an += min(rem,A)
print(an)
Buggy code:
n, a, b = (int(i) for i in input().split())
q, mod = divmod(ｎ, a+b)
print(b * q + min(mod, a))

Fixed code:
n, a, b = (int(i) for i in input().split())
q, mod = divmod(ｎ, a+b)
print(a * q + min(mod, a))
Buggy code:
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
m=n%(a+b)
l=(n-m)/(a+b)
if m>a:
  y=a
else:
  y=m
x=a*l+y
print(x)

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

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

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

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

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

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

set = N // (A + B)
rest = N - set * (A + B)


if rest < A:
    ans = A * set + rest

else:
    ans = (A+1) * set

print(ans)

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

set = N // (A + B)
rest = N - set * (A + B)


if rest <= A:
    ans = A * set + rest

else:
    ans = A * (set + 1)

print(ans)
Buggy code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B = read_int()

def solve():
    ans = (N / (A + B)) * A
    r = (N % (A + B))
    ans += r if r < A else A
    return ans

if __name__ == "__main__":
    print(solve())

Fixed code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B = read_int()

def solve():
    ans = (N // (A + B)) * A
    r = (N % (A + B))
    ans += r if r < A else A
    return ans

if __name__ == "__main__":
    print(solve())
Buggy code:
n, a, b = map(int, input().split())
ans = n // (a + b)
x = n % (a + b)
ans += min(a, x)
print(ans)

Fixed code:
n, a, b = map(int, input().split())
x = a + b
ans = n // x * a
ans += min(a, (n % x))
print(ans)
Buggy code:
n,a,b=map(int,input().split())
s=n//(a+b)
ans1=a*s
rem=n%(a+b)
if rem>=a:
  print(ans1+a)
else:
  print(ans1+a-rem)
  

Fixed code:
n,a,b=map(int,input().split())
s=n//(a+b)
ans1=a*s
rem=n%(a+b)
if rem>=a:
  print(ans1+a)
else:
  print(ans1+rem)
Buggy code:
N,A,B=map(int,input().split())
ana=N//(A+B)*A
rem=N%(A+B)
ana=ana+rem.count(A)
print(ana)

Fixed code:
N,A,B=map(int,input().split())
ana=N//(A+B)*A
rem=N%(A+B)
ana=ana+min(rem,A)
print(ana)
Buggy code:
N, A, B = map(int,input().split())
patternNum = N // (A + B)
remains = N % (A + B)
if (remains > A):
	print(patternNum * B + (remains - A))
else:
	print(patternNum * B)

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

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

q, mod = divmod(N, A+B)
print(q, mod)

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)


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

q, mod = divmod(N, A+B)

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)
Buggy code:
n,a,b = map(int,input().split())
x = n // (a+b)
y = m - (a+b)*x
if a == 0:
  print(0)
elif y < a + 1:
  print (x * a + y)
else:
  print (x*a + a)

Fixed code:
n,a,b = map(int,input().split())
x = n // (a+b)
y = n - (a+b)*x
if a == 0:
  print(0)
elif y < a + 1:
  print (x * a + y)
else:
  print (x*a + a)
Buggy code:
n,a,b=map(int,input().split())
if(n<=a):
    print(n)
elif(n<=a+b):
    print(a)
else:
    print(n//(a+b)+n%(a+b))

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:
N,A,B = map(int,input().split())

b = 0
r = 0

if A >= N:
    print(A)
elif A == 0 and B == 0:
    print(0)
else:
    C = A * (N // (A+B) )
    D = N % (A+B) 
    print(D)
    if D <= A:
        print(C+D)
    else:
        print(C+A)

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

b = 0
r = 0

if A >= N:
    print(N)
else:
    C = A * (N // (A+B) )
    D = N % (A+B) 
    if D <= A:
        print(C+D)
    else:
        print(C+A)
Buggy code:
N,A,B=map(int,input().split())
i=N//((A+B)*(10**100))*A
if N%((A+B)*(10**100))>A:
    i=i+A
else:
    i=i+(N%(A+B)*(10**100))
print(i)


Fixed code:
N,A,B=map(int,input().split())
i=(N//(A+B))*A
if N%(A+B)>A:
    i=i+A
else:
    i=i+(N%(A+B))
print(i)
Buggy code:
N,A,B = map(int, input().split())
roop = N//(A+B)
remainder = N % (A+B) 

if A==0:
  print(0)
elif A>=N:
  print(N)
elif N>A and N<A+B:
  print(A)
elif N>A and N>A+B and A>remainder:
  out = roop * A + remainder
  print(out)
elif N>A and N>A+B and A<remainder:
  out = roop * A + A
  print(out)
  

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

if A==0:
  print(0)
elif A>=N:
  print(N)
elif N>A and N<=A+B:
  print(A)
elif N>A and N>A+B and A>=remainder:
  out = roop * A + remainder
  print(out)
elif N>A and N>A+B and A<remainder:
  out = roop * A + A
  print(out)
Buggy code:
N=[int(e) for e in input().split()]
if N[1]==0:
    A=0
else:
    M=N[0]//(N[1]+N[2])
    if M==0:
        if N[0]>N[1]:
            A=N[1]
        else:
            A=N[0]
    else:
        A=M+N[0]%(N[1]+N[2])
print(A)




Fixed code:
N=[int(e) for e in input().split()]
A=N[0]//(N[1]+N[2])*N[1]
M=N[0]%(N[1]+N[2])
if N[1]>M:
    A+=M
else:
    A+=N[1]
print(A)
Buggy code:
N, A, B = map(int,input().split())

loop = N//(A+B)

remain = N - loop*(A+B)

if remain <= A:
    remain = remain
else:
    remain = A

print("loop=",loop)
print("remain=",remain)

print(loop*A+remain)

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

loop = N//(A+B)

remain = N - loop*(A+B)

if remain <= A:
    remain = remain
else:
    remain = A

print(loop*A+remain)
Buggy code:
N,A,B = map(int,input().split())
C = N//(A+B)
D = N%(A+B)
print(C*A+max(D,A))

Fixed code:
N,A,B = map(int,input().split())
C = N//(A+B)
D = N%(A+B)
print(C*A+min(D,A))
Buggy code:
N, A, B = 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:
a,b,c=map(int,input().split())
if a%(b+c)<=b:
  print(((a//b*c)*b)+a%(b+c))
elif b==0:
  print(0)
else:
  print(((a//b*c)*b)+a%(b+c))

Fixed code:
a,b,c=map(int,input().split())
if a%(b+c)<=b:
  print((a//(b+c))*b+a%(b+c))
else:
  print((a//(b+c))*b+b)
Buggy code:
n,a,b=map(int,input().split())
temp1=n//(a+b)
temp=n-temp1
ans=min(a,temp)
ans+=(temp1*a)
print(ans)


Fixed code:
n,a,b=map(int,input().split())
temp1=n//(a+b)
temp=n-(temp1*(a+b))
ans=min(a,temp)
ans+=(temp1*a)
print(ans)
Buggy code:
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

N, A, B = map(int, input().split())
C = A+B
x = N//C
print(x*A+max(N-x*C, A))


Fixed code:
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

N, A, B = map(int, input().split())
C = A+B
x = N//C
print(x*A+min(N-x*C, A))
Buggy code:
N, A, B = list(map(int, input().split()))

count = -(-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)
print(A * count)
print(amari)
print(sum_blue)

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

count = N // (A + B)
amari = N%(A+B)
sum_blue = A * count + min(A, amari)

print(sum_blue)
Buggy code:
n,a,b = list(map(int,input().split()))
cnt = 0
c = n//(a+b)
d = n%(a+b)
if d <= a:
  cnt = c+d
else:
  cnt = c+a
print(cnt)

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

r = 3*math.floor(n/7)
res = n%7
if res>3:
  r += 3
else:
  r += res

print(str(int(r)))

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


Fixed code:
N , A, B = map(int, input().split())
ans = 0
ans += N // (A + B) * A
ans += min(N % (A + B), A)
print(ans)
Buggy code:
N, A, B = map(int, input().split())
print(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= list(map(int,input().split()))


s = n//(a+b)
t = n% (a+b)

if t>=a:
    print(a*s+a)

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

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


s = n//(a+b)
t = n% (a+b)

if t>a:
    print(a*s+a)
if t<=a:
    print(a*s+t)
Buggy code:
N,A,B=[int(s) for s in input().split()]
C=A+B
Q=N//C
R=N%C
if R<=A:
  print(Q*A+C)
else:
  print((Q+1)*A)

Fixed code:
N,A,B=[int(s) for s in input().split()]
C=A+B
Q=N//C
R=N%C
if R<=A:
  print(Q*A+R)
else:
  print((Q+1)*A)
Buggy code:
N, A, B = map(int, input().split())
print(min((N//(A+B))A + N-(N//(A+B), (N//(A+B))A + A))

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


s=0

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

    # print(a)
    # print(b)
    if b>A:
    sum=A*a+A
    print(s)
    else:
    s=A*a+b
    print(s)

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


sum=0

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

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)
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 = list(map(int, input().split()))

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

print(ans)
Buggy code:
n,r,b = [int(i) for i in input().split()]
k = n * b// (r+b)
l = min(n % (r+b) - r,0)
print(k+l)

Fixed code:
n,b,r = [int(i) for i in input().split()]
k = n // (r+b) * b
l = min(n % (r+b), b)
print(k+l)
Buggy code:
N, A, B = map(int, input().split())
r = N // (A + B)
m = N % (A + B)
if A != 0:
    if A > N:
        print(N - A)
    elif A + B < N:
        print(A)
    else:
        print(A * r + (A if A <= m else m))
else:
    print(0)

Fixed code:
N, A, B = map(int, input().split())
if A != 0:
    if A + B <= N:
        r = N // (A + B)
        m = N % (A + B)
        print(A * r + (A if A <= m else m))
    elif A > N:
        print(N)
    else:
        print(A)
else:
    print(0)
Buggy code:
n,a,b=map(int, input().split())
if n%(a+b)>b:
    print(n//(a+b)*a+n%(a+b))
elif n%(a+b)==0:
    print(n//(a+b)*a)
else:
    print(n//(a+b)*a+a)

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

Fixed code:
N, A, B = map(int, input().split())
m = N // (A + B)
r = N % (A + B)
if r <= A:
  ans = m * A + r
else:
  ans = m * A + A
print(ans)
Buggy code:
N, A, B = map(int, input().split())
 
tmp1 = N // (A + B)
tmp2 = N % (A + B)
 
print(tmp1 * A + mim(tmp2, A))

Fixed code:
N, A, B = map(int, input().split())
 
tmp1 = N // (A + B)
tmp2 = N % (A + B)
 
print(tmp1 * A + min(tmp2, A))
Buggy code:
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

d,m = divmod(n,a+b)

print(d*a+m if m<a else d*a+m-b)

Fixed code:
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

d,m = divmod(n,a+b)

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

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

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

x = n // (a + b) * a
k = n % (a + b)
if k <= a:
    print(x + k)
else:
    print(x + a)
Buggy code:
N = list(map(int, input().split()))
print((N[0]//(N[1]+N[2])*N[1] + min([N[0]%(N[1]+N[2]), N[1]]))

Fixed code:
N = list(map(int, input().split()))
print((N[0]//(N[1]+N[2]))*N[1] + min([N[0]%(N[1]+N[2]), N[1]]))