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):

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

c = a + b
d = n % c
e = n // c

if d <= a:
    print(e * a + d)
else:
    print((e + 1) * a)

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())

d = a+b
c = n%d
e = n//d

if c <= a:
    print(e*a+c)
if c > a:
    print((e+1)*a)

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())
ans = A * (N//(A+B)) + min(A, N%(A+B))
print(ans)

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

Solution (Python):
from sys import stdin

n,a,b = [int(x) for x in stdin.readline().strip().split()]
print(int(n/(a+b))*a+min(n%(a+b), a))

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




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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, A, B = map(int, readline().split())

    q, r = N // (A + B), N % (A + B)
    ans = A * q + min(A, r)
    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

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

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):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

t = n // (a + b)
u = n - (a + b) * t
if a < u:
    u = a
print(t * a + u)

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

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

quot=n//(a+b)
ans = a*quot + rem if rem < a else a*quot + a
print(ans)

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

if r > a:
    print(q * a + a)
else:
    print(q * a + r)

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

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 = list(map(int, input().split()))
p = N // (A + B)
q = N % (A + B)
print(p * A + min(A, q))

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

S = A+B

x = N//S
y = N%S

print(x*A+min(y,A))

Solution (Python):
N, A, B = (int(x) for x in input().split())
div=int(N/(A+B))
amari=N%(A+B)

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

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

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

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

print(ans)

Solution (Python):
N, A, B = [int(_) for _ in input().split()]
q, r = divmod(N, A + B)
print(A * q + min(r, A))

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

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

if x == 0:
    print(min(a, n))
else:
    print(a * x + min(mod, a))

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

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

loop = N//(A+B)

remain = min(N - loop*(A+B),A)

print(loop*A+remain)

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

Solution (Python):
n,a,b = map(int,input().split())
c = a + b
z = n // c

if n % c != 0:
    m = n % c
    if a <= m:
        print(z * a + a)
    else:
        print(z * a + m)
else:
    print(z * a)

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

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

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())
 
if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print((answer*a) + min(a, remainder))
else:
  print(0)

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

c = A+B
size = N//c
rest = N%c
ans = (size*A) + min(A, rest)
print(ans)

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    time = N // (A + B)
    rest = N % (A + B)
    restCalc = 0
    if rest >= A:
        restCalc = A
    else:
        restCalc = rest
    print((time*A)+restCalc)
main()

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

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

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

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

print(result)

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

count=0
m=n//(a+b)
l=n%(a+b)

if l==0:
    print(m*a)
elif l>a:
    print(m*a+a)
else:
    print(m*a+l%a)

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

ans=0
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())
num=a+b
ans,plus=divmod(n,num)
ans*=a
ans+=min(plus,a)
print(ans)

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())

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

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

sho=int(n/(a+b))
ama=n%(a+b)

if ama > a:
  ao=sho*a+a
else:
  ao=sho*a+ama
print(ao)

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

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):
n, a, b = map(int, open(0).read().split())

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

print(d*a+min(m, a))

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

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

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

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

ans += (n//(a+b))*a

if amari<=a:
    ans+=amari

elif amari>a:
    ans+=a

print(ans)

Solution (Python):
N, A, B = map(int, input().split())
m = int(N/(A+B))
n = N - m*(A+B)
if n > A:
  n = A
num = m * A + n
print(num)

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

if A == 0:
    print(0)
elif A+B >= N:
    print(min(A,N))
else:
    cnt = A * (N // (A+B))
    N -= (A+B) * (N // (A+B))
    cnt += min(A,N)
    print(cnt)

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

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

count = int(N / (A + B))
blue_balls = count * A

if N % (A + B) != 0:
    if N % (A + B) > A:
        blue_balls += A
    else:
        blue_balls += N % (A + B)

print(blue_balls)

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

x = n//(b+r)
x1 = n%(b+r)

if b >= x1:
  b_count = x1
else:
  b_count = b

print(x*b + b_count)

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

x = n//(b+r)
x1 = n%(b+r)

if b >= x1:
  b_count = x1
else:
  b_count = b

print(x*b + b_count)

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

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

def ans():
  if b<=A:
    return a+b
  else:
    return a+A

print(ans())

Solution (Python):
N, A, B = [int(i) for i in input().split()]
d, m = divmod(N, (A + B))
print(d * A + min(m, A))

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

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

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


if r<= a:
    print(r+s*a)
else:
    print((s+1)*a)

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

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

q, mod = divmod(n, a + b)
ans = a * q
if mod > a:
    ans += a
else:
    ans += mod

print(ans)

Solution (Python):









import sys
input = sys.stdin.readline

N, A, B = 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())

div, mod = divmod(N, (A + B))
res = A * div + min(A, mod)
print(res)

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    
    if N<=A:
        print(N)
    else:
        print(A*(N//(A+B))+min(N%(A+B),A))
    
    
if __name__=="__main__":
    main()

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

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

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

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

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

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

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

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())
div = N//(A+B)
mod = N % (A+B)
print(div*A+min(mod, A))

Solution (Python):


N,A,B = map(int,input().split())
sumab = A + B
quot,mod = divmod(N, sumab)
if A > mod:
    ans = (A * quot) + mod
else:
    ans = (A * quot) + A
    
print(ans)

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

print(ans)

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

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

cnt_blue = 0
total_tmp = 0

try:
    pre_cnt = N // (A+B)
    total_tmp = pre_cnt * (A+B)
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  (pre_cnt * B)
    else:
        cnt_blue = (pre_cnt * A) + A
    print(cnt_blue)
except Exception as e:
    print(0)

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

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

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

print(ans)

Solution (Python):
import math
def main():
  n, a, b = map(int, input().split())
  total = 0
  
  
  
  
  x = math.floor(n / (a+b))
  total = a * x
  y = n % (a+b)
  if y >= a:
    total += a
  else:
    total += y
      
      
  print(total)
  
  
main()

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

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

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

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

rest = N % pair

ans += min(A, rest)

print(ans)

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

Solution (Python):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations

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

ADD=A+B


C=N//ADD
ans = C*A
tmp = C*ADD
if N - tmp >= A:
    print(ans + A)
else:
    print(ans + (N-tmp))

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):
import sys

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

if a == 0:
  print(0)
  sys.exit()

set_n = n // (a + b)
amari_n = n % (a + b)

ans = set_n * a + min(amari_n, a)

print(ans)

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

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

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())
c = a + b
if n % c == 0:
    ans = a * (n // c)
elif n % c <= a:
    ans = a * (n // c) + n % c
else:
    ans = a * (n // c +1)

print(ans)

Solution (Python):

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

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

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

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

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

print(ans)

Solution (Python):
n,a,b = map(int,input().split())
rest = n%(a+b)
n -= rest
ans = n//(a+b)*a
if rest >= a:
  ans += a
elif rest < a:
  ans += rest

print(ans)

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

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

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

t = N//(b+r)
s = N%(b+r)

if s>=b:
    print((t+1)*b)
else:
    print(t*b + s)

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

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

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

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

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

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

SUM=0
a = N % (A + B)
if a > A:
    SUM = A
else:
    SUM = a 

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

print(SUM)

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

ans1 = N//C*A
if N%C > A:
    ans2 = A
else:
    ans2 = N%C

print(ans1+ans2)

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):

import sys
import numpy as np




N,A,B = [int(x) for x in sys.stdin.readline().split()]

num = int(np.floor(N/(A+B)))*A
if (N%(A+B)) >= A:
    num = num + A
else:
    num = num + N%(A+B)

print(int(num))

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

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

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

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

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

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

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

x = n // (a + b)
num += (x * a)

y = n % (a + b)

if y <= a:
    num += y
else:
    num += a

print(num)

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

Solution (Python):
N,A,B = map(int,input().split())
C1 = N//(A+B)
C2 = N - C1*(A+B)
if C2 >= A:
    C2 =A
print(A*C1+C2)

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

cycle = n//(a+b)
plus = n%(a+b)

ans = a*cycle + min(a, plus)

print(ans)

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

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

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())

ans = n // (a + b) * a

rem = n % (a + b)

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Solution (Python):
import numpy as np
def cumsum(x):
    return list(np.cumsum(x))

def cumsum_number(N,K,x):
    ans=[0]*(N-K+1)
    number_cumsum = cumsum(x)
    number_cumsum.insert(0,0)
    for i in range(N-K+1):
        ans[i]=number_cumsum[i+K]-number_cumsum[i]
    return ans
"""
int 
float 


for name in fruits: 
    print(name)


list0 = [] 
list0 = [1,2,3,4] 
list0 = [0]*10 
list1= [i for i in range(10)] 
list1 = list(map(int, input().split()))　
number=[int(input()) for i in range(int(input()))] 
list1 = list1 + [6, 7, 8] 
list2.append(34) 
list.insert(3,10) 
len(list4) 
max(sa) 
list5.count(2) 
list1.sort() 
list1.sort(reverse=True)  
set(list1) 
sum([2,3,   ,3]) 

abs(a) 
max(a,b) min(a,b) 
text1 = text1.replace("34","test") 

exit(0) 

cumsum(リスト) 
cumsum_number(N,K,x) 
"""
N,A,B=map(int,input().split())
S=N//(A+B) 
M=N-S*(A+B) 
if A<=M:
    print(A+S*A)
else:
    print(M+S*A)

Solution (Python):
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, A, B = map(int, input().split())
q = N // (A+B)
s = N % (A+B)
print(q*A+min(s,A))

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

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

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

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

s = N // (A + B)
t = N % (A + B)

if t >= A:
    x = A
else:
    x = t

ans = A*s + x

print(ans)

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

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

print(count)

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

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())
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())
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())

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

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

if __name__ == "__main__":
    main()

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

a = N//(A + B)
b = N%(A + B)

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

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())
ans=(N//(A+B))*A
nokori=N%(A+B)
ans+=min(nokori,A)
print(ans)

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


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

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

ans = block*a + min(a,rest)
print(ans)

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

a = N // (A+B)
b = N % (A+B)

ans = a * A + min(b,A)
print(ans)

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

kiri = n // (a+b);
blue = kiri * a;
amari = n % (a+b);

if amari >= a:
    blue += a
else:
    blue += amari

print(blue);

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

if Y > A:
    blue = X*A + A
else:
    blue = X*A + Y

print(blue)

Solution (Python):






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

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

b = int(n/(a+b))
b = b * a

print(b+amari)

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

a = N // (A + B) 
b = N %  (A + B) 

if b <= A:
    num = a * A + b
else:
    num = a * A + A

print(num)

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

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

Solution (Python):


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

X = N // (A + B) * A
Y = N % (A + B)
if Y <= A:
    Z = Y
else:
    Z = A

print(X + Z)

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

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

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

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 + a)

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

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())
s = a + b
ans = 0

if a == 0:
    print(ans)
    exit()
elif b == 0:
    print(n)
    exit()

if n <= s and n <= a:
    ans = n
elif n <= s:
    ans = a
else:
    d = n % s
    if d == 0:
        ans += n // s * a
    elif d >= a:
        ans += (n // s * a) + a
    else:
        ans += (n // s * a) + d

print(ans)

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

num1 = n // (a + b) * a
num2 = n % (a + b)

if num2 >= a:
    print(num1 + a)
else:
    print(num1 + num2)

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

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

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


a=(N//(A+B))
b=min(A,N%(A+B))

print(a*A+b)

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

bl1 = N // (A+B)
remain = (N - bl1*(A+B))

if remain >= A:
    remain = A

print(bl1*A+remain)

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

print(Q*A+min(A,R))

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

Solution (Python):

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

n = N // (A+B)
p = N % (A+B)

if(p>=A):
    ans  = A*n+A
else:
    ans = A*n+p

print(ans)

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())
print((n//(a+b))*a + min(a,n%(a+b)))

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

Solution (Python):
N,A,B = (int(x) for x in input().split())
Blue  = A*(N//(A+B))
Red   = B*(N//(A+B))
Rest  = N-(Blue+Red)
if Rest==0:
    print(Blue)
elif 0<Rest<=A:
    print(Blue+Rest)
elif A<Rest<=(A+B):
    print(Blue+A)

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())
Q = N//(A+B)
print(A*Q + min(N%(A+B), A))

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

count_a = N//(A+B)*A
div = N%(A+B)

if div <= A:
    print(count_a + div)
else:
    print(count_a + A)

Solution (Python):

N,A,B = map(int,input().split())
AB = N//(A+B)
rest = N - (A+B)*AB

if rest > A:
    rest = A
print(AB*A+rest)

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

total += N//(A+B)

blue = total * A

if N%(A+B) >= A:
  blue += A
else:
  blue += N%(A+B)
print(blue)

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

ans = 0
d = n // (a+b)

ans += a * d

m = n % (a+b)
if m > a:
  ans += a
else:
  ans += m
print(ans)

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

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

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

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

print(m*a + min(d,a))

Solution (Python):

n,a,b=map(int,input().split())
cnb=n//(a+b)
ans=a*cnb
add=n-(a+b)*cnb

if add-a>0:
    ans+=a
else:
    ans+=add
print(ans)

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

x = math.floor(n/(a+b)) * a

y = n%(a+b)
if y >= a:
    print(x+a)
else:
    print(x+y)

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

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    N,A,B=map(int,input().split())
    if N%(A+B)<=A:
        print(A*(N//(A+B))+N%(A+B))
    else:
        print(A*(N//(A+B))+A)
    
    
    
if __name__=="__main__":
    main()

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

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

v = N//(A+B)
z = N %(A+B)

if z < A:
    print(A*v + z)
else:
    print(A*v + A)

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

Solution (Python):

n, b, r = map(int, input().split())
a = 0
a += n//(r+b) * b
if n - n//(r+b) * (r+b)> b:
    a += b
else:
    a += n - n//(r+b) * (r+b)
print(a)

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

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

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

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

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

print(k + l)

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

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

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

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

if __name__ == '__main__':
    solve()

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

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

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

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

ans=0

times=N//(A+B)
rest=N%(A+B)

ans=times*A
if rest>A:
  a=A
else:
  a=rest

print(ans+a)

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

nu = n // (a + b)

print(min(nu * a + n % (a + b), (nu + 1) * a))

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

a = N // (A+B)
b = N % (A+B)
total = a * A
if A >= b:
    total += b
elif A < b:
    total += A
print(total)

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

Solution (Python):
n,a,b=map(int,input().split())
if a==0:
  print("0")
  exit()
tmp1 = n // (a+b)
tmp2 = n-(tmp1*(a+b))
if tmp2 >= a:
  print((tmp1*a)+a)
else:
  print((tmp1*a)+tmp2)

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

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

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

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

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

    print(ans)

    return


resolve()

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

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