Problem:
 Score : 200 points    Problem Statement Takahashi has many red balls and blue balls. Now, he will place them in a row.  Initially, there is no ball placed.  Takahashi, who is very patient, will do the following operation 10^{100} times:   Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.   How many blue balls will be there among the first N balls in the row of balls made this way?      Constraints  1 \leq N \leq 10^{18}  A, B \geq 0  0 < A + B \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  A  B       Output Print the number of blue balls that will be there among the first N balls in the row of balls.        Sample Input 1 8 3 4      Sample Output 1 4  Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb , among which there are four blue balls.       Sample Input 2 8 0 4      Sample Output 2 0  He placed only red balls from the beginning.       Sample Input 3 6 2 4      Sample Output 3 2  Among bbrrrr , there are two blue balls.

Solution (Python):
n, a, b = list(map(int, input().split()))
d = n // (a + b)
e = n % (a + b)
ans = d * a
if e > a:
    ans += a
else:
    ans += e
print(ans)

Solution (Python):
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)

Solution (Python):
N,A,B = list(map(int, input().split()))

sets = int(N/(A+B))
flow = N - sets*(A+B)
if flow > A:
    flow = A
print(sets*A+flow)

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

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

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

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

print(ans)

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
elif n_mod_ab // a > 0:
    res = a
else:
    res = n_mod_ab

print(n_div_ab * a + res)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
cnt = a * (n // (a + b))
cnt2 = min(n % (a + b), a)
print(cnt+ cnt2)

Solution (Python):
n,a,b =map(int,input().split())
roop = a + b
amari = n % roop

if amari <= a:
  print(n//roop * a + amari)
else:
  print(n//roop * a + a)

Solution (Python):
N,A,B=map(int,input().split())
c=A+B
blue=N//c*A
value=N%c
if value<A:
    blue+=value
else:
    blue+=A

print(blue)

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

r = a+b

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
out = (n // (a + b)) * a
t = n % (a + b)
out += min(t, a)
print(out)

Solution (Python):
def solve(string):
    n, a, b = map(int, string.split())
    return str(n // (a + b) * a + min(n % (a + b), a))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))

Solution (Python):
n, a, b = map(int, input().split())
result = n//(a+b)*a
if n%(a+b) < a:
    result += n%(a+b)
else:
    result += a
print(result)

Solution (Python):
N, A, B = map(int, input().split()) 
ans=N//(A+B)*A
rem=N%(A+B)
ans += min(rem, A)
print(ans)

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

t = N // (A+B) 

ans = t * A

temp = N - t*(A+B)
if temp >= A:
    ans += A
else:
    ans += temp
print(ans)

Solution (Python):

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

ans = (N // AB) * A
rem = N % AB
ans += min(A, rem)
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
AB = A + B

if N >= AB:
    iters, div = divmod(N, AB)
    if div <= A:
        print((A*iters + div))
    else:
        print((A*(iters + 1)))
elif N >= A:
    print(A)
else:
    print(N)

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

x = n//(a+b)
y = n%(a+b)
if y-a < 0:
  z = y
else:
  z = a

ans = x*a + z


print(ans)

Solution (Python):
s=input().split()
n=int(s[0])
a=int(s[1])
b=int(s[2])
p=n//(a+b)
q=n%(a+b)
print(a*p+q if q<a else a*(p+1))

Solution (Python):
import sys

def main():
    N, A, B = list(map(int, sys.stdin.readline().rstrip().split()))
    count = int(N / (A + B))
    mod = N % (A + B)
    if mod > A:
        print((count * A) + A)
    else:
        print((count * A) + mod)

if __name__ == '__main__':
    main()

Solution (Python):
N, A, B = map(int, input().split())
res = N // (A+B) * A
if N % (A+B) > A:
    res += A
else:
    res += N % (A+B)
print(res)

Solution (Python):
N, A, B = map(int, input().split())
 
if N < A:
  print(N)
 
elif A <= N <= A + B:
  print(A)
  
else:
  count = N // (A+B)
  amari = N % (A + B)
  if amari < A:
    print(A*count + amari)
  else:
    print(A*count + A)

Solution (Python):
l = list(map(int, input().split()))

ans = 0

mm = l[0]//(l[1]+l[2])
nn = l[0]%(l[1]+l[2])

ans += mm*l[1]

if nn >= l[1]:
  ans += l[1]
else:
  ans += nn

print(ans)

Solution (Python):
n, b, r = map(int, input().split())
baseTextCount = b + r 
i = n // baseTextCount
mod = n % baseTextCount
if mod < b:
    print(i * b + mod)
else:
    print(i * b + b)

Solution (Python):
n, b, r = map(int, input().split())





if b == 0:
    print(b)
else:
    
    baseTextCount = b + r 
    i = n // baseTextCount
    mod = n % baseTextCount
    
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)

Solution (Python):
inputText1 = input()

inputText1List = inputText1.split()
n = int(inputText1List[0])
b = int(inputText1List[1])
r = int(inputText1List[2])
count = 10 **100
if b == 0:
    print(b)
else:
    
    baseTextCount = b + r 
    i = n // baseTextCount
    mod = n % baseTextCount
    
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)

Solution (Python):
n_a_b = list(map(int, input().split()))

n = n_a_b[0]
a = n_a_b[1]
b = n_a_b[2]

division = n // (a+b)
remainder = n % (a+b)

answer = division * a

if remainder <= a:
  answer += remainder
else:
  answer += a

print(answer)

Solution (Python):
import sys
input = sys.stdin.readline
n,a,b=map(int,input().split())
x=n//(a+b)*a
y=n%(a+b)
y=min(y,a)
print(x+y)

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

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

Solution (Python):
n, a, b = map(int, input().split())
l, m = divmod(n, a+b)
print(l*a+min(a, m))

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

a = N // (A + B) * A
b = N % (A + B) if N % (A + B) < A else A

print(a + b)

Solution (Python):
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)

Solution (Python):
total,blue,red=map(int,input().split())
a=blue+red
if total<blue:
    ans=total

else:
    ans=(total//a)*blue
    temp=total%a
    if temp>blue:
        ans+=blue
    else:
        ans+=temp

print(ans)

Solution (Python):
total,blue,red=map(int,input().split())
a=blue+red
if total<blue:
    ans=total
elif total<a:
    ans=blue
else:
    ans=(total//a)*blue
    temp=total%a
    if temp>blue:
        ans+=blue
    else:
        ans+=temp

print(ans)

Solution (Python):
inp = list(map(int,input().split()))
n=inp[0]
a=inp[1]
b=inp[2]
if(a==0 and b==0):
    print (0)
else:
    k=n//(a+b)
    z=n-(a+b)*k
    if(z<=a):
        print (k*a+z)
    else:
        print ((k+1)*a)

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

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

Solution (Python):
a = list(map(int, input().split()))
if (a[1] == 0):
    print(0)
else:
    if a[0] - int(a[0] / (a[1] + a[2])) * (a[1] + a[2]) > a[1]:
        print(int(a[0] / (a[1] + a[2])) * a[1] + a[1])
    else:
        print(int(a[0]/(a[1]+a[2]))*a[1]+a[0] -
              int(a[0] / (a[1] + a[2])) * (a[1] + a[2]))

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

if A != 0 and N%(A+B) <= A :
  print((N//(A+B))*A + N%(A+B))

elif A != 0 and N%(A+B) > A :
  print((N//(A+B))*A + A)

else :
  print("0")

Solution (Python):
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)

Solution (Python):
n,a,b=map(int,input().split())
x=int(n/(a+b))
if(n%(a+b)>a):
  print((x+1)*a)
  
else:
  print(x*a+(n%(a+b)))

Solution (Python):
n,a,b = map(int,input().split())
roup = n//(a+b)
ama = n%(a+b)
plus = ama if ama<a else a
print(roup*a+plus)

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

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

Solution (Python):
n, a, b = map(int,input().split())
tot = a + b
bcnt = (n // tot) * a
n -= (n // tot) * tot
bcnt += min(n,a)
print(bcnt)

Solution (Python):
N,A,B = map(int,input().split())
s = int(N/(A+B))
a = N-(A+B)*s
print(int(A*s+a if A>a else A*(s+1)))

Solution (Python):
N, A, B = [int(i) for i in input().rstrip().split(' ')]
r = A + B
tmp = int(N / r) * A

print(tmp + A) if N % r >= A else print(tmp + N % r)

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

amari = n % (a+b) if n % (a+b)<=a else a

print(n//(a+b)*a+amari)

Solution (Python):
n,a,b = map(int, input().split())
c,d = divmod(n,a+b)
ans = c * a + min(d,a)
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
print((n//(a+b))*a + min(a, n%(a+b)))

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
print(answer*a + min(a, amari))

Solution (Python):
n, a, b = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
answer *= a
print(answer + min(a, amari))

Solution (Python):
n, a, b = map(int,input().split())
 
x = int(n/(a+b)) 
y = n%(a+b) 

if y > a:
    ans = (x+1) * a
else:
    ans = x * a + y

print(ans)

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

result = n // (a + b) * a + min (n % (a + b), a)

print(result)

Solution (Python):
n, a, b = map(int, input().split())
mul, res = n // (a + b) * a, n % (a + b)
if res <= a:
    mul += res
else:
    mul += a
print(mul)

Solution (Python):
n, a, b = list(map(int, input().split()))
print(int((n//(a+b))*a + min(n-(n//(a+b)*(a+b)), a)))

Solution (Python):
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)

Solution (Python):
N,A,B=(int(x) for x in input().split())
a=N//(A+B)*A
r=N%(A+B)
a+=min(r,A)
print(a)

Solution (Python):
N,A,B = map(int, input().split())
M = N/(A+B)
P = N%(A+B)
K = 0
if P != 0:
    if P > A:
        K = A
    else :
        K = P

print(A*int(M)+K)

Solution (Python):
num = input().split(' ')
data = [int(num[i]) for i in range(3)]

result = data[0] // (data[1] + data[2]) * data[1]
if(data[0] % (data[1] + data[2]) >= data[1]):
    key = data[1]
else:
    key =  data[0] % (data[1] + data[2])
result += key

print(result)

Solution (Python):
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)

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num

ans = times * a
if amari <= a:
    ans += amari
else :
    ans += a

print(ans)

Solution (Python):
n, a, b = [int(c) for c in input().split()]
num = n // (a+b)
amari = n % (a+b)
out = num * a + min(amari, a)
print(out)

Solution (Python):
N, A, B = map(int, input().split())
cnt = N // (A + B)
if N % (A + B) == 0:
    print(cnt * A)
else:
    num = min(A, N % (A + B))
    print(cnt * A + num)

Solution (Python):
N, A, B = map(int, input().split(" "))
k = N // (A + B)
N -= k * (A + B)
print(k * A + min(N, A))

Solution (Python):
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[1]+L[1])
elif L[1]==0:
    print(0)
else:
    print(q*L[1]+mod%L[1])

Solution (Python):
N, A, B = map(int, input().split())
tmp = N%(A+B)
if tmp>A:
    tmp=A
ans = (N//(A+B))*A + tmp
print(ans)

Solution (Python):
n, a, b = map(int, input().split(' '))
print(min(int(n%(a+b)),a)+int((n//(a+b))*a))

Solution (Python):

N,A,B = map(int,input().split())
cnt = N//(A+B)
rest = N%(A+B)
if rest <= A :
    print(cnt*A+rest)
else:
    print(cnt*A+A)

Solution (Python):
N,A,B = map(int, input().split())
num = A+B
Bolls = int(N/num)
perseBolls = int(N%num)
if perseBolls > int(A):
    print(Bolls*int(A)+int(A))
else:
    print(Bolls*int(A)+perseBolls)

Solution (Python):
n, a, b = map(int, input().split(' '))
r = n//(a+b)
print(int(r*a+min((n-r*(a+b),a))))

Solution (Python):
N, A, B = (int(x) for x in input().split())
r = N // (A + B)
ans = A * r + min((N - (A + B) * r), A)
print(ans)

Solution (Python):
x, b, r = [int(x) for x in input().split(' ')]

print((x // (b+r) * b) + min(x % (b+r),b))

Solution (Python):
N,A,B=map(int,input().split())
if (A+B)==0:
  print(0)
  exit()

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

if N%(A+B)<=A:
  ans+=N%(A+B)
else:
  ans+=A

print(ans)

Solution (Python):
n,a,b = map(int,input().split())
ans = a*(n//(a+b))
if n % (a+b) < a:
    ans += n % (a+b)
else:
    ans += a
print(ans)

Solution (Python):
N,A,B = map(int,input().split())
block = A+B
print((N//block)*A+min(N%block,A))

Solution (Python):



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

div, mod = divmod(n, a + b)




count = 0
count = a * div



if mod >= a:
    count += a
else:
    count += mod
    
print(count)

Solution (Python):
n,a,b=map(int,input().split())
num=n//(a+b)
amari=n-num*(a+b)
print(a*num+a if (amari>=a) else a*num+amari)

Solution (Python):
n,a,b = map(int,input().split())
cnt = n//(a+b)
if n%(a+b) - a >=0:
  cnt2 = a
else:
  cnt2 = n%(a+b)
print(a*cnt+cnt2)

Solution (Python):

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

syou = N // (A+B)
amari = N % (A+B)

ans = syou * A 
if amari >= A:
    ans += A
else:
    ans += amari
    
print(ans)

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

Solution (Python):
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)

Solution (Python):
n, a, b=map(int, input().split())
blue=n//(a+b)*a+min(a, n%(a+b))
print(blue)

Solution (Python):
n, b, r  = map(int, input().split())

b_set = b + r

re = n % b_set

if re <= b:
    print(b * (int(n/b_set)) + re)
else:
    print(b*(int(n /b_set)+1))

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

c = n // (a+b)
d = n % (a+b)

ans = a * c

if d <= a:
    ans += d
else:
    ans += a
    
print(ans)

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

S=A*int(N/(A+B))
if N%(A+B)-A>0:
    S+=A
else:
    S+=N%(A+B)
print(S)

Solution (Python):
N, A, B = map(int, input().split())
cy = N // (A + B)
cynum = N % (A + B)
tmpans = cy * A





if 0 <= cynum and cynum < A:
    ans = cynum + tmpans
else:
    ans = tmpans + A
print(ans)

Solution (Python):
import math

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

a = math.floor(N/(A+B)) 
b = N%(A+B)

if b <= A:
    print(A*a+b)
elif b>A:
    print(A*a+A)

Solution (Python):
n, a, b = map(int, input().strip().split())
q, r = divmod(n, a+b)
blue = a*q
if r < a:
    blue += r
else:
    blue += a
print(blue)

Solution (Python):
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
if Ans2>A:
    Ans3=A
else:
    Ans3=Ans2

Ans=A*Ans1+Ans3

print(int(Ans))

Solution (Python):
N,A,B=map(int,input().split())
n=0
x=N//(A+B)
y=N%(A+B)-A
if y>0:
    print((x+1)*A)
else:
    print((x+1)*A+y)

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

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

Solution (Python):
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)

Solution (Python):
n,a,b = list(map(int, input().split()))
q,mod = divmod( n,(a+b) )
if mod <= a:
    print(q*a+mod)
else:
    print((q+1)*a)

Solution (Python):
n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    print(a * x - (temp - n))
else:
    print(a * x)

Solution (Python):



n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    endsWithA = True
else:
    endsWithA = False
if endsWithA:
    print(a * x - (temp - n))
else:
    print(a * x)

Solution (Python):
import math

N, A, B = (int(x) for x in input().split())

temp = A if N % (A+B) >= A else N % (A+B)

print(math.floor(N / (A+B)) * A + temp)

Solution (Python):
n, a, b = map(int, input().split())
shou = n // (a + b)
amari = n % (a + b)
if amari == 0:
  print(shou * a)
elif shou * (a+b) + a > n:
  print(a*shou + amari)
else:
  print(a*shou + a)

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

c=n//(a+b)
d=n%(a+b)
e=c*a
f=c*d

if n<=a:
  print(n)
elif a<n<a+b:
  print(a)
elif a+b<=n and d<=a:
  print(e+d)
elif a+b<=n and a<=d:
  print(e+a)

Solution (Python):
n,a,b = map(int, input().split())
count = 0
if a != 0:
    roop = int(n / (a + b))
    remainder = n % (a + b)
    if roop > 0:
        count += roop * a
    
    if remainder > 0:
        if remainder <= a:
            count += remainder
        else:
            count += a
print(count)

Solution (Python):
N,A,B=map(int,input().split())
a=int(N//(A+B))
b=N%(A+B)
if b>A:
  b=A
print(A*a+b)

Solution (Python):

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)

Solution (Python):
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)

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

Solution (Python):
n, a, b = map(int, input().split())
k = n//(a+b)
r = n%(a+ b)
print(k*a+min(r,a))

Solution (Python):
N, A, B = [int(x) for x in input().split()]

n_groups = N // (A + B)
from_head = N % (A + B)

if from_head < A:
    print(n_groups * A + from_head)
else:
    print(n_groups * A + A)

Solution (Python):
N, A, B = map(int, input().split(" "))
ans = N // (A + B) * A
amari = N % (A + B)
ans += min(amari, A)
print(ans)

Solution (Python):
N,A,B=map(int,input().split())
x=N//(A+B)
y=N%(A+B)
if y<=A:
  print(A*x+y)
else:
  print(A*(x+1))

Solution (Python):
"""
    Author: _YL_
"""

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

if b == 0:
    print("0")
elif r == 0:
    print(n)
else:
    remainder = n % (b+r)
    if remainder > b:
        remainder = b

    print(n//(b+r)*b+remainder)

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

m=int(n/(a+b))
r=n%(a+b)

if r>=a:
  print(a+a*m)
else:
  print(r+a*m)

Solution (Python):
from sys import stdin

def main():
  N, A, B = map(int,input().split())
  k = int(N/(A+B))
  val = k*A+ min(A, N-k*(A+B))
  print(int(val))

if __name__ == "__main__":
  main()

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

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

Solution (Python):
N, A, B = list(map(int, input().split()))
print(N//(A+B)*A+min(N%(A+B),A))

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

X=int(N/(A+B))
ans1=int(A*X)

Y=int(N%(A+B))
ans2=0
if Y>A:
  ans2=A
elif Y==A:
  ans2=A
elif Y<A:
  ans2=Y

print(int(ans1+ans2))

Solution (Python):
import math
N,A,B = list(map(int,input().split()))
ans = A*(N//(A+B))
if N%(A+B)>=A:
    ans+=A
else: ans+=N%(A+B)
print(ans)

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

c=A+B

b=0

if int(N/c)>0:
  b=(int(N/c)*A)
  if N%c>A:
    b+=A
  else:
    b+=N%c
else:
  if N<A:
    b=N
  else:
    b=A

print(b)

Solution (Python):
n, a, b = list(map(int, input().split()))
print(n // (a + b) * a + min(n % (a+b), a))

Solution (Python):
n,a,b=map(int,input().split())
r,p=divmod(n,a+b)
print(r*a+min([p,a]))

Solution (Python):
n,a,b=map(int,input().split())
count = n//(a+b)*a
add = min(n%(a+b),a)
sum = count + add
print(sum)

Solution (Python):
n, a, b = map(int, input().split())
div = n // (a + b)
mod = n % (a + b)
if mod > a:
    ans = div * (a) + a
else:
    ans = div * (a) + mod

print(ans)

Solution (Python):
N,A,B = map(int,input().split())
quo = N//(A+B)
res = N%(A+B)
if res > A:
    print(quo*A+A)
elif res <= A:
    print(quo*A+res)

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

ans = 0
sho = N/(A+B)
ans += int(sho)*A
ans += min(N-(A+B)*int(sho),A)

print(ans)

Solution (Python):
def main():
    n,a,b=map(int,input().split())
    print((n//(a+b))*a+min(n%(a+b),a))
main()

Solution (Python):
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))

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

ao1=a*(n//(a+b))
ao2=min(n%(a+b),a)

print(ao1+ao2)

Solution (Python):
N, A, B = map(int, input().split())
if A == 0:
  print(0)
elif A > N or B == 0:
  print(N)
else:
  M = N // (A + B)
  if N - M * (A + B) > A:
    print(A * M + A)
  else:
    print(N - M * B)

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

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

print(blue)

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

kakeru = n // (a+b)
amari = n % (a+b)

blue = a * kakeru + min(amari, a)

print(blue)

Solution (Python):
N, A, B = map(int, input().split())
a, b = divmod(N, A+B)
print(a * A + min(b, A))

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

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

print(ans)

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

if a == 0:
    print("0")
elif b == 0:
    print(n)
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > a:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))

Solution (Python):
N, A, B = map(int, input().split())
S = A + B

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

print(ans)

Solution (Python):
def main():
    N,A,B = map(int,input().split())
    bl = (N // (A + B)) * A
    rl = (N % (A + B))
    if rl <= A:
        print(bl + rl)
    else:
        print(bl + A)
main()

Solution (Python):
n,x,y = map(int,input().split())
s = n // (x+y)
Sum = x*s
left =  n - (x+y) * s
if left > x:
    Sum += x
    
else:
    Sum += left
print(int(Sum))

Solution (Python):
N, A, B = map(int, input().split())
a = N//(A+B)
b = N%(A+B)

if b< A:
  print(a*A+b)
if b>=A:
  print(a*A+A)

Solution (Python):
N, A, B = map(int, input().split())
repeat = N // (A+B)
mod = N % (A+B)
print(A*repeat + min(A, mod))

Solution (Python):
l = input().split()

[n,a,b] = [int(x) for x in l]

if a==b and a==0:
    print(0)
else:
    x = a+b
    y = n//x

    if a == 0:
        print(0)
    else:
        if b == 0:
            print(n)
        else:
            t = n - y*x
            if t > a:
                print(y*a+a)
            else:
                print(y*a+t)

Solution (Python):
n,a,b = list(map(int, input().split()))
print(n//(a+b) * a + n%(a+b) if n%(a+b) < a else n//(a+b) * a + a)

Solution (Python):
n,a,b = map(int,input().split())
c = n//(a+b)
d = n % (a+b)
if d > a:
    ans = a * (c+1)
else:
    ans = c * a + d
print(ans)

Solution (Python):
N, A, B = map(int, input().split())
bnum = int(N // (A + B)) * A
bnum += min(N % (A + B), A)
print(bnum)

Solution (Python):





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


q = (N // (A+B)) * A
m = min((N % (A+B)),A)
print(q+m)

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

Solution (Python):
def main():
    n,a,b = map(int,input().split())
    x = (n // (a + b) ) * a 
    y = n % (a + b)
    ans = x + min(y,a)
    print(ans)
main()

Solution (Python):
n ,a ,b = map(int,input().split())
x = n // (a + b)
y = n % (a + b)

if y < a:
    print(x * a + y)
else:
    print(x * a + a)

Solution (Python):
a = [list(map(int, s.split())) for s in open(0)] [0]
n, r = a[0] // (a[1] + a[2]), a[0] % (a[1] + a[2])

if a[0] <= a[1] + a[2]:
    if a[0] >= a[1]:
        print(a[1])
    else:
        print(a[0])
else:
    if a[1] == 0:
        print(0)
    else:
        if r <= a[1]:
            print(n * a[1] + r)
        else:
            print(n * a[1] + a[1])

Solution (Python):
N,A,B = map(int,input().split())
R = N%(A+B)
res = (N//(A+B))*A
if R == 0:
  print(res)
else:
  if R<A:
    print(res+R)
  else:
    print(res+A)

Solution (Python):
N, A, B = map(int, input().split())
AB = A + B
c = N//AB
print(c*A + min(A, N%AB))

Solution (Python):
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if a >= mod:
        ans += mod
    else:
        ans += a
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N, A, B = input().rstrip().split(' ')
N = int(N)
A = int(A)
B = int(B)

n = int(N / (A+B)) * A
m = N % (A+B)

if m > A:
    m = A
print(n + m)

Solution (Python):
n,a,b=map(int,input().split())
x= n //(a+b) * a
r= n % (a+b)
x+=min(r,a)
print(x)

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

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

ans += min(rem, A)
print(ans)

Solution (Python):
def main():
    import numpy as numpy
    import sys
    n,a,b=list(map(int,sys.stdin.readline().split()))
 
    print(a*(n//(a+b))+min(a,n%(a+b)))
 
 
 
main()

Solution (Python):
from math import floor

inp = input()
N, A, B = [int(x) for x in inp.split(" ")]

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)

Solution (Python):

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


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


saigo = min(N%(A+B),A)
print(kanz + saigo)

Solution (Python):


import sys


def prob_b(n, a, b):
    x = int(n / (a + b)) * a
    y = min(n % (a + b), a)
    print(x+y)


if __name__ == '__main__':
    
    
    
    
    n, a, b = map(int, input().split())
    prob_b(n,a,b)

Solution (Python):
N,A,B=map(int,input().split())
x=N//(A+B)
y=N%(A+B)
if y<A:
    print(x*A+y)
else:
    print(x*A+A)

Solution (Python):
n, a, b = map(int, input().split())
ans = a * (n // (a + b))
m = n % (a + b)
if m <= a:
    ans += m
else:
    ans += a
print(ans)

Solution (Python):
N,A,B=map(int,input().split())
if A==0 or A+B==0:
    print(0)
    exit()
ans=A*(N//(A+B))
if N%(A+B)>A:
    ans+=A
else:
    ans+=N%(A+B)
print(ans)

Solution (Python):
total_balls, blue, red = [int(i) for i in input().split()]

balls_per_loop = red + blue
loops = total_balls // balls_per_loop
ex = total_balls % balls_per_loop

ex_blue = blue if ex >= blue else ex
total_blue = blue * loops + ex_blue
print(total_blue)

Solution (Python):
n,a,b=map(int,input().split())
x=n//(a+b)
y=n%(a+b)
if y<a:
  print(x*a+y)
else:
  print(x*a+a)

Solution (Python):
n,a,b = map(int, input().split())
ans = n//(a+b)*a
rem = n % (a+b)

ans = ans + min(rem,a)
print(ans)

Solution (Python):
n,a,b = map(int,input().split(" "))
count = 0
c = a + b
count += a * (n // c)
d = n % c
count += min(a,d)
print(count)

Solution (Python):
N, A, B = map(int, input().split())
ab = A + B
x = N // ab
y = N % ab

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

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

tmp1,tmp2=divmod(n,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
else:
  blue=blue+tmp2
  
print(blue)

Solution (Python):
N, A, B = map(int, input().split())
ans = 0

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

ans += q*A
ans += min(m, A)

print(ans)

Solution (Python):
def count_balls(n, a, b):
    if(a==0): return 0
    if(n<a): return n
    end = n % (a+b)
    if(end > a):
        return a*(n//(a+b))+a
    else:
        return a*(n//(a+b))+end
n,a,b=map(int, input().strip().split())
print(count_balls(n,a,b))

Solution (Python):
inputs = input().split(' ')
n = int(inputs[0])
a = int(inputs[1])
b = int(inputs[2])
sum = a + b

if n <= a:
    print(n)
elif n <= sum:
    print(a)
else:
    loop = n // sum
    num = n - loop * sum
    if num <= a:
        print(loop * a + num)
    else:
        print(loop * a + a)

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

q = int(N / (A+B))
r = N%(A+B)

print(q*A + min(A, r))

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

q = int(N / (A+B))
r = N%(A+B)
print((q+1)*A if r>A else q*A+r)

Solution (Python):
N,A,B=map(int,input().split())
num=N//(A+B)
res=N-num*(A+B)
count=0
if res<=A:
  count=num*A+res
else:
  count=num*A+A
print(count)

Solution (Python):
n,a,b=map(int,input().split())
print(a*(n//(a+b))+min(n%(a+b),a))

Solution (Python):
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)

Solution (Python):
a = input().split()
a = list(map(int,a))
(n,m,k)=a
answer = n // (m + k) * m + min(n % (m + k), m)
print(answer)

Solution (Python):
n,a,b=map(int,input().split())
answer=n//(a+b)*a+min(n%(a+b),a)
print(answer)

Solution (Python):
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)

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

perid = n//(a+b)
rest = n%(a+b)

print(a*perid + (rest if rest < a else a))

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

ans = n // (a + b)
res = min(a, n % (a + b))

print(ans * a + res)

Solution (Python):
N, A, B = map(int, input().split())
a = N // (A + B) * A
b = N % (A + B)
print(a + min(A, b))

Solution (Python):
data = input().split()
n = int(data[0])
a = int(data[1])
b = int(data[2])

div = n // (a + b)
amari = n % (a + b)
if amari > a:
  amari = a

res = div * a + amari

print(res)

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

repeats = N//(A+B)
amari = N%(A+B)
if amari >= A:
    amari = A
else: 
    amari = amari
print(repeats*A + amari)

Solution (Python):
n,a,b=map(int,input().split())
import math
x=math.floor(n/(a+b))
print(x*a+min(a,n-x*(a+b)))

Solution (Python):
N, A, B = map(int, input().split())
print(N//(A+B)*A + min(N%(A+B), A))

Solution (Python):
n, b, r = map(int, input().split())
if n - (b+r)*(n //(b+r)) <= b:
    print((n //(b+r))*b + n - (b+r)*(n //(b+r)))
else:
    print((n //(b+r))*b + b)

Solution (Python):
n, a, b = map(int, input().split())
t = a + b
count = t if t > 0 else 0
r = 0
if count == 0:
	r = 0
else:
	d = int(n/t)
	if d*t == n:
		r = d * a
	else:
		r = d * a
		e = n - d*t
		if e <= a:
			r = r + e
		else:
			r = r + a
print(r)

Solution (Python):

i = list(map(int, input().split()))
kazoeru = i[0]
ao = i[1]
aka= i[2]
kaisuu = i[0]/(i[1]+i[2])

answer = divmod(kazoeru, (i[1]+i[2]))

if ao == 0:
    print(0)
    exit()


aa = ao * answer[0]


if answer[1] == 0:
    print(aa)
    exit()



if answer[1] >= ao:
    aa += ao

else:
    aa += answer[1]
print(aa)

Solution (Python):
n, a, b = map(int,input().split())
blocks = n // (a + b)
fragment = n % (a + b)
ans = blocks * a
ans += a if fragment >= a else fragment
print(ans)

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

T = N//(A+B)
U = N%(A+B)

print(T*A + min(U,A))

Solution (Python):
n,a,b = map(int, input().split())
if a == 0:
	print(0)
elif n % (a + b) <= a:
	print((n // (a + b)) * a + (n % (a + b))) 
else:
	print((n // (a + b)) * a + a)

Solution (Python):
N,A,B = (int(x) for x in input().split())
c = N // (A+B)
d = N % (A+B)
if d >= A:
    print((c+1)*A)
else:
    print(c*A+d)

Solution (Python):
def cal(N,A,B):
    C=int(N/(A+B))
    W=N%(A+B)
    if W > A:
        return C*A+A
    else:
        return C*A+W

    

if __name__ == "__main__":
    N,A,B = input().split()
    N=int(N)
    A=int(A)
    B=int(B)
    cal(N,A,B)
    print(cal(N,A,B))

Solution (Python):
N, A, B = list(map(int, input().split()))
x = N // (A + B)
y = N % (A + B)

if y < A:
    print(x * A + y)
else:
    print(x * A + A)

Solution (Python):
n,a,b = map(int, input().split())
c = n//(a + b)
rem = min(n%(a + b), a)
print(c*a + rem)