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 unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(8, 3, 4), 4)

    def test_2(self):
        self.assertEqual(think(8, 0, 4), 0)

    def test_3(self):
        self.assertEqual(think(6, 2, 4), 2)


def solve():
    n, a, b = read()
    result = think(n, a, b)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, a, b):
    mode = a + b
    if n % mode == 0:
        return a * (n // mode)
    else:
        blue = a * (n // mode)
        remain = n - (n // mode) * mode
        if a <= remain:
            return blue + a
        else:
            return blue + remain


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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

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):
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq

from collections import defaultdict as dd  
from collections import deque  
from collections import Counter as c  
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect



mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


n, a, b = sp()
answer = min(a, n % (a+b))
temp = n - (n % (a+b))
answer += a * (n // (a+b))
out(str(answer))

Solution (Python):
i = input()
j = i.split(' ')
c,b,r = int(j[0]),int(j[1]),int(j[2])
if b == 0:
    print(0)
elif b <= c%(b+r):
    rsl = b*(c//(b+r))+b
    print(rsl)
else:
    rsl = b*(c//(b+r))+(c%(b+r))
    print(rsl)

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

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

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

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

sum = a * (n // c) + min(a, mod)
print(sum)

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

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

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

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

Solution (Python):
N, A, B = list(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())
c=n//(a+b)
d=0
if a==0:
	print(0)
else:
	if n>=(a+b):
		if n-c*(a+b)<=a:
			d=a*c+n-c*(a+b)
			print(d)
		else:
			d=a*(c+1)
			print(d)
	else:
		if n>=a:
			print(a)
		else:
			print(n)

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

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

Solution (Python):
import sys
import itertools

INF = 1001001001

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

if __name__ == "__main__":
    resolve()

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase


input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

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().rstrip().split())

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

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

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

set_num = N // (A + B)
mod_num = N % (A + B)
if mod_num >= A :
    mod_num = A

ans = set_num * A + mod_num
print(ans)

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

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

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

print(ans)

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

q = int(n/(a+b))
c = n-q*(a+b)

if c<=a:
    ans = a*q+c
else:
    ans = a*(q+1)

print(ans)

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


S = A+B
div = N//S
dd = N % S

ans = div * A + min(dd,A)

print(ans)

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

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

res = 0

res += (N // (A+B)) * A
res += min([N % (A+B), A])

print(res)

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

Solution (Python):
line = [int(x) for x in input().split()]

total = line[0]
b = line[1]
r = line[2]

ini = (total//(b+r))*b
ini = ini + min([b, total - ((b+r)*(total//(b+r)))])

print(ini)

Solution (Python):
N,blue,red = map(int,input().split())
count = N // (blue + red)
amari = N % (blue + red)
if N%(blue+red) >= blue:
    print(blue*(count + 1))
else:
    print(blue * count + amari)

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

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

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

num_A=int(N/(A+B))
sur=int(N-(A+B)*num_A)

if A==0:
    print(0)
elif A!=0 and N>(A+B) and sur>=A:
    print(num_A*A+A)
elif A!=0 and N>(A+B) and sur<A:
    print(num_A*A+sur)
elif A!=0 and N<=(A+B) and N>=A:
    print(A)
elif A!=0 and N<=(A+B) and N<A:
    print(N)

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

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

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

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

print(c)

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

ans = (N // (A+B)) * A
if A > N % (A+B):
  ans += N % (A+B)
else:
  ans += A

print(ans)

Solution (Python):


t = input().split()
n = int(t[0])
a = int(t[1])
b = int(t[2])

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

print("{}".format(a*x + min(a,y)))

Solution (Python):
num = input().split(" ")
ball = int(num[0])
blue = int(num[1])
red = int(num[2])

a = ball // (blue + red)
b = ball - a * (blue + red)
if(b > blue):
    b = blue
print(a*blue + b)

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

Solution (Python):
N,A,B = [int(i) for i in input().rstrip().split()]
s = N // (A+B)
a = min( N % (A+B), A )
print(s*A + 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 = list(map(int,input().split()))
def problem2(N, A, B):
  if A <= N % (A+B):
    answer = (N // (A+B)) * A + A
  else:
    answer = (N // (A+B)) * A + N % (A+B)
  return answer
print(problem2(N, A, B))

Solution (Python):
N, A ,B = list(map(int,input().split()))
def problem2(N, A, B):
  if A <= N % (A+B):
    answer = (N // (A+B)) * A + A
  else:
    answer = (N // (A+B)) * A + N % (A+B)
  return answer
print(problem2(N, A, B))

Solution (Python):
N, A ,B = list(map(int,input().split()))
def problem2(N, A, B):
  if A <= N % (A+B):
    answer = (N // (A+B)) * A + A
  else:
    answer = (N // (A+B)) * A + N % (A+B)
  return answer
print(problem2(N, A, B))

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

n = int(n)
a = int(a)
b = int(b)

q = n // (a + b)
rest = n - q * (a + b)

if rest >= a:
    blue_ball = a * q + a
    print(blue_ball)
else:
    blue_ball = a * q + rest
    print(blue_ball)

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

Solution (Python):


N, A, B = map(int, input().split())
q, mod = divmod(N,(A+B))
blue = (q*A)
blue += min(mod, A)

print(blue)

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

r = N % (A + B)
Q = N // (A + B)

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

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

c = b + r

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

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

AB = A + B
x1 = N // AB
x2 = N % AB

if x2 < A:
    ao = A * x1 + x2

else:
    ao = A * x1 + A
print(ao)

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
sumab = a + b
lost = n % sumab

if lost >= a:
    lost = a

print(a * (n // sumab) + lost)

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

print(ans)

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

if A!=0:
    ans = N//(A+B)*A
    mod = N%(A+B)
    plus = min(mod, A)
    c = ans + plus 
else:
    c = 0
print(c)

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

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

print(ans)

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

c = a+b

ans = n//c *a
remainder = n%c

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

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

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

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

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

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

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

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

Solution (Python):
n, blue_num, red_num = map(int, input().split())

count = n // (blue_num + red_num)
rest = n % (blue_num + red_num)

if rest > blue_num:
    print(count * blue_num + blue_num)
else:
    print(count * blue_num + rest)

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

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

Solution (Python):
inp=list(map(int,input().split()))
s=inp[0]
b=inp[1]
r=inp[2]
print(s//(b+r)*b+min(s%(b+r),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(' '))
r = a * int(n / (a + b)) + (a if a < n % (a + b) else n % (a + b))
print(r)

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

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

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

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

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

else:
    rem=min(N%(A+B),A)
    print(N//(A+B)*A+rem)

Solution (Python):
S = input()
N = int(S.split(' ')[0])
A = int(S.split(' ')[1])
B = int(S.split(' ')[2])
 
b_count = (N // (A+B)) * A
rem = N % (A+B)
b_count = b_count + min(rem, A)
print(b_count)

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

m = a + b

t, r = divmod(n, m)

ans = t*a

if r > 0:
    ans += min(a, r)

print(ans)

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

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

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

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

Solution (Python):
info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info[0] // group
b = info[0] % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)

Solution (Python):
n,a,b=(int(x) for x in input().split())




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

c=q*a+min(a,mod)

print (c)

Solution (Python):
N,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
elif (b ==0):
  print(0)
else :
  sets = N//(b+r)
  surplus = N%(b+r)
  if(surplus - b > 0):
    residue = b
  elif(surplus - b < 0):
    residue = surplus  
  Number_of_Blue = sets * b + residue
  print(Number_of_Blue)

Solution (Python):
NAB = input()
n_a_b = NAB.split(" ")
N = int(n_a_b[0])
A = int(n_a_b[1])
B = int(n_a_b[2])
numOfAB = N//(A+B)
n = N - numOfAB*(A+B)
if (n - A) >= 0:
    print(numOfAB*A + A)
else:
    print(numOfAB*A + n)

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):
s = input().split(" ")
N = int(s[0])
A = int(s[1])
B = int(s[2])

q = N // (A+B)
m = N % (A+B)

if m <= A:
    print(q*A+m)
else:
    print(q*A+A)

Solution (Python):

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

unit = a + b

if n >= unit:
  
  
  c = n // unit
  d = n % unit
  num = c * a
  if d >= a:
    num += a
  else:
    num += d
else:
  d = n % unit
  if d >= a:
    num = a
  else:
    num = d
    
print(num)

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

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

if n%(a+b)<a:
  c+=n%(a+b)
else:
  c+=a
print(c)

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

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

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

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 = map(int, input().split())
C = A + B
ans = 0
D = N // C

if D >= 1:
    ans = A * D
    if N % C <= A:
        ans = ans + N%C
    elif N % C > A:
        ans = ans + A

elif D < 1:
    if N >= A:
        ans = A
    else:
        ans = N
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):
N,A,B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)

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

print(ans)

Solution (Python):
a = list(map(int,input().split()))
b=a[0]
c=a[1]
d=a[2]
e=0
f=0
e = (b//(c+d))*c
f= b % (c+d)
if c<=f:
  e=e+c
else:
  e=e+f

print(e)

Solution (Python):
S = input().split()
N = int(S[0])
A = int(S[1])
B = int(S[2])
AB = A + B
DIV = int(N / AB)
MOD = N % AB
X = 0
if MOD <= A:
  X = MOD
else:
  X = A
print(A * DIV + X)

Solution (Python):
list = input().split(" ")
N = int(list[0])
A = int(list[1])
B = int(list[2])

num1 = N // (A + B)
num2 = N % (A + B)
if num2 <= A:
    print(num1 * A + num2)
else:
    print(num1 * A + 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 = input().split()
N = int(n)
A = int(a)
B = int(b)
L = N // (A+B)
M = N % (A+B)
if A <= M:
    print(A*L+A)
else:
    print(A*L+M)

Solution (Python):
S,a,b=(int(x) for x in input().split())
ans = S//(a+b) * a
rem = S % (a+b )
ans +=min(rem,a)
print(ans)

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

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

Solution (Python):
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    d, m = divmod(n, (a + b))
    print(d * a + min(m, a))


if __name__ == '__main__':
    solve()

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

Solution (Python):
N,A,B=[int(x) for x in input().split()]
a,b = divmod(N,A+B)
print((a+1)*A if b>A else a*A+b)

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

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

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


answer = 0
c = N//(A+B)

answer += c * A

if N - c*(A+B) < A:
    answer += N - c* (A+B)
else:
    answer += A
print(answer)

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

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

Solution (Python):
import math


N, A, B = map(int, input().split())
leftOver = N % (A + B)
divTime = N / (A + B)



if divTime == 1:
  print(A)
elif divTime != 1:
  if leftOver > A:
    print(math.floor(divTime) * A + A)
  elif leftOver <= A:
    print(math.floor(divTime) * A + leftOver)

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

Solution (Python):
def solve(n, a, b):
    return (n // (a+b)) * a + min(a, n % (a+b))

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

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


from sys import stdin, stderr

def main():
   N, A, B = map(int, stdin.readline().split())
   T = N / (A+B)
   res = A*T
   R = N % (A+B)
   res += min(R, A)
   print(res)

   return 0

if __name__ == '__main__': main()

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

c = a+b

q = n//c
r = n%c

if r<=a:
    R = r
else:
    R = a

ans = q*a + R 

print(ans)

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

t1 = N//(A+B)
t2 = min(N%(A+B), A)

print(A*t1+t2)

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

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

Solution (Python):
N, A , B = list(map(int,input().split()))
BR_set, r_ball  = divmod(N, A+B)
blue_num1 = BR_set * A
if r_ball > A:
    blue_num2 = A
else:
    blue_num2 = r_ball
blue_num = blue_num1 + blue_num2
print(blue_num)

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

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

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

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

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

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

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

Solution (Python):
import sys

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

a = 0
a = N/(A+B)*A

b = 0
if A > 0:
    b = min(A,N%(A+B))
print(a+b)

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

p,q = divmod(N, A+B)
ans = p*A + min(A,q)

print(ans)

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

Solution (Python):


n, a, b = list(map(int, input().split()))
c = a + b
x = n // c
y = n % c

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

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

C = A+B
D = int(N/C)
E = A*D
F = N%C

if F>A:
    print(E+A)
else:
    print(E+F)

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

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

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

Solution (Python):
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
    sys.exit()


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

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

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

X = N // (A + B)
Y = N - X * (A + B)

ans = A * X + min(Y, A)
print(ans)

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

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

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

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

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):
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

N, a, b = map(int, inp().split())
ans = N//(a+b) * a
rest = N%(a+b)
ans += min(a, rest)
print(ans)

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())
m = N // (A + B)
r = N % (A + B)
if r <= A:
  ans = m * A + r
else:
  ans = m * A + A
print(ans)

Solution (Python):
import math
import numpy as np

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

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


AB_set = N // (A+B)


rest = N % (A+B)
if rest > A:
    print(A * AB_set + A)
else:
    print(A * AB_set + rest)

Solution (Python):
import sys
import math

str = input() 



ary = str.split(' ')
N = int(ary[0])
B = int(ary[1])
R = int(ary[2])

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

a = N % (B+R)
ret = math.floor(N / (B+R))*B + (a if a < B else B)
print(ret)

Solution (Python):
N, A, B = map(int, input().split())
q, mod = divmod(N, A+B)
if mod >= A:
	print(q*A+A)
else: 
	print(q*A+mod)

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

Solution (Python):
N,A,B=map(int,input().split())
group = int(N / (A+B))
amari = N % (A+B)
if amari <= A:
    amari_ao = amari
else:
    amari_ao = A
aoi = group * A + amari_ao
print(str(aoi) + '\n')

Solution (Python):


import math

[n, a, b] = map(int, input().split())
total = math.floor(n / (a + b)) * a
total += min(a, (n % (a + b)))
print(total)

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

Solution (Python):
import math
import itertools
import statistics

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

Solution (Python):

from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,a,b = mi()

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






main()

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

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

Solution (Python):
S,A,B = map(int,input().split())
W = int(S // (A + B))
R = (S % (A + B))
if R < A:
    X = R
else:
    X = A


print (W * A + X)

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

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

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

sumAB = A + B
c = N // sumAB
k = N % sumAB
if k < A:
    ans = A * c + k
else:
    ans = A * c + A

print(ans)