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

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

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

t = n%(a+b)

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

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

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

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

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

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

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

times = n//(a+b)
remain = n%(a+b)

if remain < a:
    print(a*times+remain)
else:
    print(a*(times+1))

Solution (Python):

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


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

print(ans+min(a,n%total))

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))
elif N%(A+B)>A:
    print(N//(A+B)*A+A)

Solution (Python):
from sys import stdin, setrecursionlimit


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

    mod = n % (a + b)

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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

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))
elif N%(A+B)>A:
    print(N//(A+B)*A+A)

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

Solution (Python):
N,A,B = input().split()
N = int (N)
A = int(A)
B = int(B)
rep = (int)(N/(A+B))

numb = min(N%(A+B),A) + rep*A

print(numb)

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

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

Solution (Python):


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

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n,a,b=map(int,stdin.readline().split())
ans=0
ans+=a*(n//(a+b))
n=n%(a+b)
if(n<=a):
    ans+=n 
else:
    ans+=a
print(ans)

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

a = N % (B + R)
b = N // (B + R) * B
if a >= B:
    b += B
else:
    b += a
print(b)

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

nkome = n % (a+b)
kaisuu = n // (a+b)

if nkome > a:
    print(a*(kaisuu+1))
else:
    print(n-b*kaisuu)

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

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

print(ans)

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

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

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

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

C = A + B
N = min(N, C * 10 ** 100)
print(N // C * A + min(A, N % C))

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


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

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())
syou = n//(a+b)
kakutei = syou*a
nokori = n - syou*(a+b)

if nokori <= a:
  print(kakutei + nokori)
else:
  print(kakutei + a)

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

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

print(ans)

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



def main():
    nsum = (a+b)
    
    if(a==0):
        print(0)
        return

    if(n<=nsum):
        if(n<a):
            print(n)
        else:
            print(a)
        return
    else:
        div = n//nsum
        remain = n - div*nsum
        ans = div*a
        if(remain<=a):
            ans += remain
        else:
            ans += a
        print(ans)
        return
        
main()

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

Solution (Python):
N,A,B = map(int, input().split())
ans = 0
S = A+B
T = N//S
U = N%S


if(A == 0):
    ans = 0
else :
    if(0< U < A):
        ans = A*T+U
    elif(U == 0):
        ans = A*T
    elif(U >= A):
        ans = A*T+A
    
print(ans)

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

Solution (Python):
a = list(map(int,input().split()))
N = a[0]
blue = a[1]
red = a[2]
ans = 0
A = blue + red
X = N // A
Y = N % A
if Y <= blue:
    ans = blue * X + Y
else:
    ans = blue * X + blue
print(ans)

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

Q = N // (A + B)
r = N - Q * (A + B)

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

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

key=N//(A+B)
if N%(A+B)==0:
  print(A*key)
else:
  Key=N%(A+B)
  if Key>=A:
    print(A*(key+1))
  else:
    print(A*key+Key)

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

Solution (Python):
n,a,b = [int(i) for i in input().split()]
d=int(n/(a+b))
r=n%(a+b)
if r==0:
  print(d*a)
elif r>a:
  print(d*a+a)
else:
  print(d*a+r)

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

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

Solution (Python):
import itertools
import math
import fractions
import functools
n, a, b = map(int, input().split())
count = n // (a+b)*a
if n % (a+b) <= a:
    count += n % (a+b)
if n % (a+b) > a:
    count += a

print(count)

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 = 0

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

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

Solution (Python):

class abc_158:
    
    def __init__(self):
        pass
    
    def A(self):
        S=input()
        if "BA" in S or "AB" in S:print("Yes")
        else:print("No")
    
    def B(self):
        NAB=list(map(int,input().split()))
        
        if NAB[0]<=NAB[1]:ans=NAB[0]
        elif NAB[0]<=NAB[1]+NAB[2]:ans=NAB[1]
        else:
            tail = NAB[0]%(NAB[1]+NAB[2]) if NAB[0]%(NAB[1]+NAB[2])<NAB[1] else NAB[1]
            ans=(int(NAB[0]/(NAB[1]+NAB[2]))*NAB[1])+tail
            
        print(int(ans))
            
    def C(self):
        AB=list(map(int,input().split()))
        ans=-1
        
        
        for i in range(1,1001):
            if AB[0]==int(i*0.08) and AB[1]==int(i*0.1):
                ans=i
                break
            else:continue
        print(ans)
            
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_158()
    obj.B()

Solution (Python):
n,a,b=[int(x) for x in 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 + min(a, (n % (a+b)))
print(ans)

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

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

AB = A + B

div, mod = divmod(N, AB)

blue = A * div
blue += min(mod, A)

print(blue)

Solution (Python):

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

c = N//(A+B)

d = N%(A+B)

if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b)

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

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

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

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

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

print(x+y)

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


resolve()

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

cnt = n%(a+b)
cont = n//(a+b)
ans = 0

if cnt <= a:
    ans = a*cont + cnt
    print(ans)
else:
    ans = a*(cont+1)
    print(ans)

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

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

C=A+B

M=N%C
K=N//C

if A<M:
    print(K*A+A)
else:
    print(K*A+M)

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

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

C=A+B

M=N%C
K=N//C

if A<M:
    print(K*A+A)
else:
    print(K*A+M)

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

n_c = N // (A+B)
n = N - n_c*(A+B)

ans = n_c*A + min(n, 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 = (n//(a+b)) * a
rest = n % (a+b)
ans += min(rest, 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 = 0
 
if n % (a+b) == 0:
  ans += n//(a+b) *a
  
else:
  if n%(a+b)<a:
    ans += n//(a+b)*a + n%(a+b)
  else:
    ans += n//(a+b)*a + a
  
print(ans)

Solution (Python):
from statistics import median


from fractions import gcd
from itertools import combinations 
from collections import deque
from collections import defaultdict
import bisect










import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))

def main():
    n,a,b = readInts()
    print(a * (n // (a+b)) + min(a,n%(a+b)))

if __name__ == '__main__':
  main()

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

n, a, b = [int(x) for x in input().split()]

t = a + b

ans = 0

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

ans += 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) != 0: 
  if n % (a+b) < a: ans += n%(a+b)
  else: ans += a
print(ans)

Solution (Python):
from sys import exit

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

i = n%(a+b)
j = (n-i)//(a+b)

if i <=a:
    ans = j*a + i
else:
    ans = (j+1)*a

print(ans)

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

d, m = divmod(N, A + B)
ans = A * d + min(m, A)
print(ans)

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

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

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n,a,b = myinput()

x = a + b

ans = (n//x) * a

if n%x <= a:
    ans += n%x
else:
    ans += a

print(ans)

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):
n,a,b = tuple(map(int,input().split()))

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

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

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

sett = a+b
num = n // sett
amari = n % sett
print(num*a + min(a, amari))

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

Solution (Python):
n,a,b=map(int,input().split())
x=(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())
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())
su = 0
blue = 0

mo = n%(a+b)
mu = int(n/(a+b))

if mo > a:
    ma = mo-a
    blue = n-ma-b*mu
elif mo <= a:
    blue = n- b*mu

print(str(blue))

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

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

A*(N // (A+B)) + (N%(A+B))

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

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

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

cnt = 0

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

x = n % (a+b)

if x > a:
    cnt += a
else:
    cnt += x

print(cnt)

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

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)

Solution (Python):
N,A,B = [int(s) for s in 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())

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

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

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

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

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

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

r=n%(a+b)

if r<=a:
    ans+=r
else:
    ans+=a

print(ans)

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

x = n//(a+b)
y = n%(a+b)

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

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
q, r = divmod(N, (A+B))
answer = A * q + min(r, A)
print(answer)

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
time = N // (A+B)
remain = N - (A+B) * time
answer = A * time + min(A, remain)
print(answer)

Solution (Python):



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

amount_of_b = (n // total) * a
amount_of_b += a if n % total > a else n % total

print(amount_of_b)

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

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

Solution (Python):


from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

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


a = N // (A+B)
b = N % (A+B)
if b > A:
    b = A

print(int(a * A + b))

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

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

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

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

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

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

print(a*A + min(mod, A))

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

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

Solution (Python):
import math
x = input().split()
n = int(x[0])
a = int(x[1])
b = int(x[2])
z = 0
z = math.floor(n / (a+b)) * a
amari = math.floor(n % (a+b))
if amari == 0:
  pass
elif amari <= a:
  z += amari
else:
  z += a
print(z)

Solution (Python):

"""
Created on Thu May  7 01:35:43 2020

@author: shinba
"""

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

a = N // (A+B)

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

print(a*A+b)

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

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

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

if n<A:
    ans+=n 
else:
    ans+=A
print(ans)

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

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

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

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

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

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

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

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

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

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

Solution (Python):


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

print(i * A + j)

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

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

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

    if (mod > A):
        ans += A
    else:
        ans += mod

    print(ans)


resolve()

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

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

ab = a + b

repeat = n // ab
modular = n % ab

print(a * repeat + min(modular, a))

Solution (Python):
import sys

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

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

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

if (amari >= 0) and (amari <= a):
    print(a * ao_count + amari)
else:
    print(a * (ao_count + 1))

Solution (Python):
import math

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

ans = 0

ONE_BLOCK_NUM = A + B

if ONE_BLOCK_NUM != 0:
    ans += math.floor(N / ONE_BLOCK_NUM) * A 
    res = N % ONE_BLOCK_NUM                  
    if res >= A:
        ans += A
    else:
        ans += res

print(ans)

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

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

x = N//(A+B)*A
y = N%(A+B)

ans = x + min(y, A)
print(ans)

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

x = N//(A+B)*A
y = N%(A+B)

if y<=A:
    ans = x + y
else:
    ans = x + A
print(ans)

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, a, b = MI()

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


if __name__ == '__main__':
    solve()

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  
def Is(): return map(int, input().split())  
def LI(): return list(map(int, input().split()))  
def TI(): return tuple(map(int, input().split()))  
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  
def LS(): return list(input())  
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n, a, b = Is()
k = n // (a+b)
l = n % (a+b)
ans = k*a
if a < l:
    ans += a
else:
    ans += l
print(ans)

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

Kurikaeshi = N // (A + B) 
Amari = N % (A + B)
Aoi = 0 

if Amari >= A:
    Aoi = A
else:
    Aoi = Amari

result = Aoi + Kurikaeshi * A


print(result)

Solution (Python):



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





if a == 0:
  print(0)
elif n < (a + b):
  print(min(n, a))
else:
  nab = n // (a + b)
  ans = nab * a
  mod = n % (nab * (a + b))
  ans += min(mod, a)
  print(ans)

Solution (Python):
N, A, B = [int(_) for _ in input().split()]
temp = N % (A + B)
print((N // (A + B)) * A + min(A, temp))

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

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

print(syo * a + amari)

Solution (Python):
N,A,B = map(int,input().split())
Loop = N//(A+B)
Rest = N%(A+B)
if Rest >= A :
    Last = A 
else :
    Last = Rest

ans = Loop*A + Last

print (ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n,a,b = [int(i) for i in readline().split()]

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

t = n//(a+b)
c=0

if t == 0 and n < a:
    c += n
    print(c)
elif t == 0 and n >= a:
    c += a
    print(c)
elif t > 0:
    c += t * a
    r = n%(a+b)
    if r == 0:
        print(c)
    elif r < a:
        c += r 
        print(c)
    elif r > a:
        c += a
        print(c)

Solution (Python):
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n,a,b = readInts()
x = math.floor(n/(a+b))
y = n-(a+b)*x
ans=a*x+min(y,a)
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

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

Solution (Python):


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

print(i * A + j)

Solution (Python):

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

loop_count = n // (a + b)
amari = n % (a + b)
amari_a = a
if amari < a:
  amari_a = amari

print(a * loop_count + amari_a)

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