peterverebics/CodeNet_Python_118 huggingface dataset:
N, num_of_blue, num_of_red = map(int, input().split())

num_of_repetition = (N // (num_of_blue + num_of_red))
remainder_s = N % (num_of_blue + num_of_red)

count_b = num_of_blue * num_of_repetition + min(num_of_blue, remainder_s)

print(count_b)
n, a, b = map(int, input().split())
good = n//(a+b)*a
resd = min(a, n%(a+b))
print(good+resd)
N, A, B = map(int, input().split())

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

print(answer)
N, A, B = map(int, input().split())
ab = A + B
cnt = N // ab
remain = N - (cnt * ab)
blue = 0
if remain > A:
    blue = A
else:
    blue = remain
ans = A * cnt + blue
print(ans)
N,A,B=map(int,input().split())
div=N//(A+B)
mod=N%(A+B)
print(div*A+min(mod,A))
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))
n,a,b = [int(x) for x in input().split()]
print((n//(a+b))*a + min(n % (a+b), a))
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)
n,a,b=map(int,input().split())
print(n//(a+b)*a+min(a,n%(a+b)))
n,a,b=map(int,input().split())
x=a+b
y=n//x
z=n%x
if z==0:
    print(a*y)
    exit()
else:
    if z>=a:
        print(y*a+a)
    else:
        print(y*a+z)
n, a, b = map(int, input().split())

result = 0
result += (n // (a+b))*a
result += min(a, n%(a+b))
print(result)
N, A, B = map(int, input().split())
print((N // (A+B)) * A + min(A, N % (A+B)))
N,A,B = map(int, input().split())
adds = A + B
times = N // adds
boalsLen = adds * times
count = A * times


while True:
    if boalsLen > N:
        break
    
    tmpBoalsLen = boalsLen + A
    if tmpBoalsLen > N:
        addBoals = N - boalsLen
        count += addBoals
        break
    
    boalsLen = tmpBoalsLen
    boalsLen += B
    count += A

print(count)
N,A,B=list(map(int,input().split()));print(A*(N//(A+B))+min([N%(A+B),A]))
import sys
 
readline = sys.stdin.buffer.readline
 
N,A,B = map(int, readline().split())
 
div,mod =divmod(N, A+B)
 
if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)
n, a, b = map(int, input().split())
ans1, ans2 = divmod(n, a+b)
print(ans1 * a + min(ans2, a))
# Q(A+B) gives QA blue balls, where Q = N/(A+B)
# then the left over is R = N - Q(A+B) < (A+B)
# from the left over, there are additional min(A, R) blue balls


def get_num_blue(n, a, b):
  if a == 0: return 0
  q, r = divmod(n, a+b)
  return q*a + min(a, r)


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

q = n//(a+b)
r = n%(a+b)

if r < a:
  ans = a*q + r
else:
  ans = a*q + a
  
print(ans)
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, A, B = map(int, input().split())
    full = N // (A+B)
    ans = full * A
    N -= full * (A+B)
    if N >= A:
        ans += A
    else:
        ans += N
    print(ans)

if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())

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

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

if amari > a:
    ans = set_num * a + a
else:
    ans = set_num * a + amari

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

n,r = divmod(N,(A+B))

ans = n * A
ans += min(r,A)
print(ans)
n, a, b = map(int, open(0).read().split())

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

print(d*a+min(m, a))
N, A, B = map(int, input().split())
print(N//(A+B)*A + min(N%(A+B), A))
N, A, B = map(int, input().split())
if A == 0:
    print('0')
elif B == 0:
    print(N)
else:
    tmp = N // (A + B)
    result = tmp * A
    N -= tmp * (A + B)
    if N > A:
        result += A
    else:
        result += N
    print(result)
n, a, b = map(int, input().split())

lep = int(n / (a+b))
per = n % (a+b)
if per > a:
    print (lep * a + a)
else:
    print (lep * a + per)
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
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)
n, a, b = list(map(int, input().split(' ')))
if a == 0:
    print(0)
elif n % (a+b) <= a:
    print(a*(n // (a+b))+ n % (a+b))
else:
    print( a*(n // (a+b))+a)
N, A, B = map(int, input().split(" "))

a = N // (A + B)
b = N % (A + B)
#print(a, b)
if b <= A:
    print(b + A * a)
else: # b > A
    print(A + A * a)
n, a, b = map(int, input().split())
shou = n // (a + b)
amari = n % (a + b)
if amari == 0:
  print(shou * a)
elif shou * (a+b) + a > n:
  print(a*shou + amari)
else:
  print(a*shou + a)
n,a,b = map(int,input().split())
c = a + b
rest = n % c
if rest <= a:
    print(a*(n//c) + rest)
else:
    print(a*(n//c)+a)
n,a,b  =map(int,input().split())
se = a+b
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n//se
    if cnt == 0:
        if n < a:
            print(n)
        else:
            print(a)
    else:
        res = a*cnt
        n -= se*cnt
        if n <= a:
            res += n
        else:
            res += a
        print(res)
N, A, B = map(int, input().split())
n, r = divmod(N, A+B)

ans = A * n  + min(A, r)
print(ans)
N, A, B = map(int, input().split())

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

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

ans = k*b+min(p,b)
print(ans)
import math

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

QUO = math.floor(N / (A + B))

if N - (A + B) * QUO < A:
  print(QUO * A + N - (A + B) * QUO)
  
else:
  print(QUO * A + A)
def main():
    N,A,B = map(int,input().split())
    a = N//(A+B)
    b = N - (a * (A+B))
    if b >= A:
        print(a*A+A)
    elif b < A:
        print(a*A+b)

if __name__ == "__main__":
    main()
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))
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)
N, A, B = map(int, input().split())
s = N // (A+B)
a = N % (A+B)
print(A*s + min(A, a))
N, A, B = map(int,input().split())
times = N // (A + B)
mod = N % (A + B)
print(times * A + min(A, mod))
n, a, b = list(map(int, input().split()))

ab = a+b

i = 0

r = n//ab
m = n%ab

if m>a:
  m=a

ans = a*r + m

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

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

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

print(ans * a + res)
import sys
from copy import copy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for test in range(int(input())):
'''
inf = 100000000000000000  # 1e17
mod = 998244353

n, a, b = map(int, input().split())
num = a + b
ans = n // num * a
n %= num
ans += min(n, a)
print(ans)
N,A,B = map(int,input().split())
#Aが青
#Bが赤
i = N // (A+B)
b = i*A
t = N % (A+B)
if t > A:
   t = A
print(b+t)
N,A,B = map(int,input().split())
X = A + B
ans = N // X * A
ans += min(N%X,A)
print(ans)
# A: blue, B: red
N, A, B = map(int, input().split())
# N, A, B = 8,0,4
#print(N)

q, mod = divmod(N, A+B)
if mod < A:
    extra = mod
else:
    extra = A
result = q * A + extra

print(result)
N, A, B = map(int, input().split())
C = N // (A + B) * A + N % (A + B)
D = N // (A + B) * A + A
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N % (A + B) > A:
    print(D)
else:
    print(C)
N,A,B = map(int, input().split())


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

if N >= AB:
    iters, div = divmod(N, AB)
    if div <= A:
        print((A*iters + div))
    else:
        print((A*(iters + 1)))
elif N >= A:
    print(A)
else:
    print(N)
n,a,b = map(int, input().split())
 
if n%(a+b)<=a: print(int(n/(a+b))*a+n%(a+b))
else: print(int(n/(a+b)+1)*a)
N, A, B = map(int, input().split())

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

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

if n == a + b:
    print(a)
    exit()

elif a == 0:
    print(0)
    exit()



c = n % (a +b)
if n % (a +b) < a:
    print((a * (n//(a+b))) + (n %(a+b)))
    exit()
else:
    print((a * (n//(a+b))) + a)
    exit()
N, A, B = map(int, input().split())
print(N//(A+B)*A + N%(A+B) if N%(A+B) <= A else N//(A+B)*A + A)
# -*- coding: utf-8 -*-
N, A, B = map(int, input().split())

# 出力
# 奇数を取得
i = 0
num_loop = int(N / (A+B))
tmp = num_loop * A

mod = N % ((A+B))

if mod > A:
    tmp2 = A
else:
    tmp2 = mod

print(tmp + tmp2)
N,A,B=map(int,input().split())
ser=N//(A+B)
mod=N%(A+B)
print(ser*A+min(mod,A))
import sys
input = sys.stdin.readline

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

if __name__ == '__main__':
    main()
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)
N,A,B = map(int,input().split())
count = 0
a = N//(A+B)
#print(a)
count += a*A
#print(count)
b = N%(A+B)
if b > A:
  count +=A
else:
  count +=b
print(count)
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)
N,A,B = list(map(int, input().split()))


groups = N // (A+B)

amari = N % (A+B)


if amari > A:
  print(groups*A + A)
else:
  print(groups*A + amari)
N,A,B = map(int,input().split())

b = 0
r = 0

if A >= N:
    print(N)
else:
    C = A * (N // (A+B) )
    D = N % (A+B) 
    if D <= A:
        print(C+D)
    else:
        print(C+A)
N, A, B = map(int, input().split())
roop = int(N / (A + B))
nokori = N - roop * (A + B)
if nokori == 0:
    ans = roop * A
elif nokori <= A:
    ans = roop * A + nokori
else:
    ans = roop * A + A
print(ans)
N, A, B = map(int, input().split())
print((N // (A + B) )*A + min(N % (A + B), A))
N, A, B = map(int, input().split())
len_loop = A + B
n_comp_loop = N//len_loop
blue_res = min(A, N % len_loop)
print(n_comp_loop * A + blue_res)
N, A, B = map(int, input().split())
g = A + B
ct = N // g
cr = N % g
ct = A * ct
if cr > A:
    print(ct + A)
    exit()
print(ct + cr)
N, A, B = map(int, input().split())

print((N // (A+B)) * A + min((N % (A+B)), A))
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(tmp+A) 
else:
  print(tmp+( N % (A+B)))
N,A,B = map(int, input().split())

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

print(A * x + min(y,A))
n, a, b = map(int, input().split())

k = int(n//(a+b))
s = n % (a+b)

if s>=a:
    print(a*k+a)
else:
    print(a*k+s)
import numpy as np

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

per = int(N//(A+B))

last = int(N%(A+B))

if last <=A:
    add_ = last
else:
    add_=A
    
ans =int(A*per+add_)
print(ans)
n, a, b = map(int, input().split())
print(n//(a+b)*a + min(a, n%(a+b)))
n, a, b = map(int,input().split())

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

ans += min(a, r)

print(ans)
n, a, b =(int(x) for x in input().split())

ans = 0
ab = a+b

if a == 0:
    print('0')
    exit()

ans = n // ab
ans = ans * a
if n % ab > a:
    ans += a
else:
    ans += n % ab

print(ans)
N, A, B = map(int, input().split())
print(N//(A+B)*A+min(A, N % (A+B)))
N, A, B = map(int, input().split())
ans = A*(N//(A+B)) + min(A, N%(A+B))
print(ans)
n,a,b=map(int,input().split())
if b==0:
    print(n)
else:
    x=n//(a+b)*a
    rem=n-n//(a+b)*(a+b)
    if rem>=a:
        print(x+a)
    else:
        print(x+rem)
n, a, b = map(int, input().split(' '))
q, r = divmod(n, a + b)

s = q * a

if r > a:
    s += a
else:
    s += r

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

quotient = N // (A+B)
remainder = N % (A+B)

if quotient == 0:
    ans = N if A >= N else A
elif remainder > A:
    ans = quotient*A + A
else:
    ans = quotient*A + remainder

print(ans)
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))

  print(int(num_a * a + min(a, num_b)))
  
if __name__ == '__main__':
  main()
n,a,b = map(int, input().split())
print((n//(a+b))*a+min(n%(a+b),a))
N, A, B = list(map(int, input().split()))
r = N%(A+B)
if r > A:
  r = A
print(N//(A+B)*A + r)
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
amari = N % (A+B)
if A >= amari: 
    countnum = N // (A+B) * A +amari
else:
    countnum = N // (A+B) * A +A
print(countnum)
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)
n, a, b = [int(i) for i in input().split()]
answer, amari = divmod(n, a+b)
answer *= a
print(answer + min(a, amari))
n, a, b = map(int,input().split())


ope1 = n//(a+b)
ope2 = n%(a+b)

if ope1 == 0:
    if n > a:
        print(a)
    else:
        print(n)
elif ope2 == 0:
    print(a*ope1)
elif ope2 < a:
    print(a*ope1 + ope2)
else:
    print(a*ope1 + a)
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(A, rem)
print(ans)
n, a, b = map(int, input().split())
 
fulls = n // (a+b)
lefts = n % (a+b)
 
print(fulls*a + min(lefts, a))
numbers=input().rstrip().split(" ")
N=int(numbers[0])
A=int(numbers[1])
B=int(numbers[2])
X=int(N/(A+B))
Y=N-X*(A+B)
if Y>=A:
    delta=A
elif Y<A:
    delta=Y
print(X*A+delta)
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,a,b = [int(i) for i in read().split()]

m = a+b

ans = n//m*a + min(a,n%m)
print(ans)
n,a,b=map(int, input().split())
t=a+b
s=n//t
p=n%t
g=0
if p<=a:
  g=p
else:
  g=a
print(s*a+g)
n,a,b=map(int,input().split())
p=n//(a+b)
n-=(a+b)*p
ans=a*p
ans+=min(a,n)
print(ans)
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)
n, a, b = list(map(int, input().split()))
ans = n // (a + b) * a
if n % (a + b) >= a :
    ans += a
else :
    ans += n % (a + b)
print(ans)
n, a, b = [int(i) for i in input().split()]
cnt = n // (a + b) * a
if n % (a + b) >= a:
  cnt += a
else:
  cnt += n % (a + b)
print(cnt)
n, a, b = map(int, input().split())

k = n // (a+b)
s = min(n % (a+b),a)
ans = k*a + s
print(ans)
n,a,b=map(int,input().split())
sum_=a+b
num=n//sum_
zan=n%sum_
ans=num*a
if zan<a:
    ans+=zan
else:
    ans+=a
print(ans)
n,a,b = map(int,input().split())
k = int(n/(a+b))
l = n%(a+b)
count = 0
count += k*a
if l>a:
    count +=a
else:
    count +=l

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

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

if amari >= a:
    tsuika = a
else:
    tsuika = amari

ans = syou * a + tsuika

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

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

else:
  r=N//(A+B)
  s=N%(A+B)
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)
n, a, b = map(int, input().split())
mod = a + b
ans = 0
ans += (n // mod) * a
n -= mod * (n // mod)
ans += min(a, n)
print(ans)
N, A, B = map(int, input().split())
print(N//(A+B)*A + min(A, N%(A+B)))
N,A,B=map(int,input().split())
print(N//(A+B)*A+(A if N%(A+B)>=A else N%(A+B)))
n,a,b=map(int,input().split())
s=n//(a+b)
w=n%(a+b)
if w<=a:
    print(s*a+w)
else:
    print(s*a+a)
n, b, r = map(int, input().split())

cnt_blk = n // (b+r)
res_b = cnt_blk*b
num = cnt_blk*(b+r) + b

if num > n:
  res_b += b - (num - n)
else:
  res_b += b
      
print(res_b)
n, a, b = (int(x) for x in input().split())

syou = n // (a + b)
sa = n % (a + b)

if sa > a:
  ans = syou * a + a
else:
  ans = syou * a + sa
print(ans)
n,a,b=map(int,input().split())
ans=n//(a+b)*a
n%=a+b
print(ans+min(n,a))
import sys
input = sys.stdin.readline

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

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

print(d * A + min(m, A))
n, a, b = map(int, input().split())
sum_num = a + b
if a == 0:
  print(0)
else:
  iter_num = int(n/sum_num)
  rest = n - iter_num * sum_num
  if rest >= a:
    print(a * iter_num + a)
  else:
    print(a * iter_num + rest)
n,a,b=map(int,input().split())
ans=(n//(a+b))*a

if n%(a+b)<=a:
    print(ans+(n%(a+b)))
else:
    print(ans+a)
S,A,B=map(int,input().split())
print((S//(A+B))*A+min(A,S%(A+B)))
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))
def main():
  n,a,b = list(map(int,input().split()))
  ans=0
  count=int(n/(a+b))
  ans+=count*a
  amari=n-count*(a+b)
  if amari <= a:
    ans+=amari
  else:
    ans+=a
  print(ans)
main()
n,b,r=map(int,input().split());c=b+r;print(n//c*b+min(n%c,b))
n,a,b=map(int,input().split())
print(a*(n//(a+b))+min(n%(a+b),a))
N,A,B = map(int, input().split())
num = A+B
Bolls = int(N/num)
perseBolls = int(N%num)
if perseBolls > int(A):
    print(Bolls*int(A)+int(A))
else:
    print(Bolls*int(A)+perseBolls)
N,A,B = map(int,input().split())

S = A+B

P = N//S

Ans = P*A + min((N-S*P),A)

print(Ans)
from math import floor

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

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)
N, A, B = map(int, input().split())
ans = A * (N // (A + B)) + min(N % (A + B), A)
print(ans)
N, A, B = map(int, input().split())

A_B = A + B
one_loop = min(N//A_B, 10**100)
ext = min(A, N%A_B)
SUM = one_loop*A + ext
print(SUM)
n,a,b=map(int,input().split())
l=n//(a+b)
ans=l*a
ans+=min(n-(a+b)*l,a)
print(ans)
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)
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)
n,a,b = map(int,input().split())

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

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

cnt = 0
cnt += syou * A

if (mod <= A):
    cnt += mod
else:
    cnt += A

print(cnt)
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))
N, A, B = map(int, input().split())
num = N // (A + B)
print(num * A + min(N - num * (A+B), A ))
n,a,b = map(int, input().split())
x = n // (a+b)
amari = n % (a+b)
if amari <= a:
    print(x*a+amari)
else:
    print(x*a+a)
N, A, B = map(int, input().split())

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

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

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


if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())

pair = N // (A + B)
remain = N % (A + B)

if remain > A:
    print(A * pair + A)
else:
    print(A * pair + remain)
#!/usr/bin/env 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()
N, A, B = map(int,input().split())
ans = A*(N//(A+B)) + min(N%(A+B),A)
print(ans)
N, A, B = map(int,input().split())

X = A + B
Y = N // X
Z = N % X

if Z >= A:
  print(A * Y + A)
else:
  print(A * Y + Z)
n,a,b=map(int,input().split())

if a+b ==0:
    print(0)
else:
    c = n//(a+b)
    d = n%(a+b)

    if d <= a:
        print(a*c+d)
    else:
        print(a*c+a)
N,A,B = map(int,input().split())
s = N // (A + B)
if N % (A+B) <= A:
    print(s*A + N % (A+B))
else:
    print((s+1)*A)
N, A, B = map(int, input().split())

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

if amari < A:
    count = shou * A + amari
else:
    count = shou * A + A
    
print(count)
n,a,b = map(int,input().split())
ab = a + b
m = n // ab
n %= ab
print(m*a+min(n,a))
N,A,B = map(int,input().split())

from math import ceil

x = N // (A+B)

ans = 0
if x > 0:
    N -= x * (A + B)
    ans += x * A

ans += min(N, A)

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

ans = N//(A+B) * A
ra = N % (A+B)
if ra <= A:
    ans += ra
elif ra > A:
    ans += A

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

c = N // (A + B)

print(c * A + min(A, N - c * (A + B)))
n, a, b = map(int, input().split())

k = n // (a+b)
l = n - (a+b) * k
l = a if l > a else l

ans = k * a + l
print(ans)
args = input()
nums = args.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
blue_calc = int(n / (a + b))
blue_mod = n % (a + b)
if blue_mod < a:
  print(a * blue_calc + blue_mod)
  exit()
print(a * blue_calc + a)
N, A, B = map(int, input().split()) 

mod = N // (A+B)
amari = N % (A+B)
if amari >= A:
	print(mod*A+A)
else:
	print(mod*A+amari)
# -*- coding: utf-8 -*-
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)
n, a, b = map(int, input().split())
count = 0
f = 0

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

if e >= a:
    f += a

else:
    f += e

count = a * d + f
print(count)
n, a, b = map(int, input().split())
q, r = divmod(n, a+b)
print(q*a + min(r, a))
n, a, b= map(int, input().split())
rem = n%(a+b)
prot = n//(a+b)
if rem > a:
  print((prot+1)*a)
else:
  print(prot*a+rem)
N, A, B = [int(x) for x in input().split()]

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

if from_head < A:
    print(n_groups * A + from_head)
else:
    print(n_groups * A + A)
N,A,B = map(int,input().split())

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: #nokoriが全てAの場合
	print((number_turn * A) + nokori)
else: #nokoriがAとBの両方の場合
	print((number_turn * A) + A)
n,a,b = map(int,input().split())
s = a+b
ans = (n//s)*a
if n%s <= a:
    ans = ans + n%s
else:
    ans = ans + a
print(ans)
N, A, B = map(int, input().split())
res = (N//(A+B))*A
res += min(N % (A+B), A)
print(res)
N,A,B=map(int,input().split())
C=N//(A+B)
D=N%(A+B)
ans=C*A+min(D,A)
print(ans)
import sys
import copy
import math
import itertools

a = [int(c) for c in input().split()]
N=a[0]
A=a[1]
B=a[2]

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

cnt += int(N/(A+B))*A
print(cnt)
N, A, B, =map(int, input().split())
ans=N//(A+B)*A
rem=N%(A+B)
ans+=min(rem,A)
print(ans)
#B - Count Balls
N,A,B = map(int,input().split())

balls = N - (A+B)*(N//(A+B))#最後の一回の操作で加えることのできるボールの個数
if balls <= A:
    ans = A * (N//(A+B)) + balls
else:
    ans = A * (N//(A+B)) + A
print(ans)
import math

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

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

print(math.floor(N / (A+B)) * A + temp)
n,a,b=map(int,input().split())
x=n%(a+b)
y=n//(a+b)
if x>a:
    print(a*(y+1))
else:
    print(a*y + x)
n, a, b = list(map(int, input().split()))

if n < a + b:
    print(min(a, n))
else:
    m = n % (a + b)
    d = n // (a + b)
    print(d * a + min(a, m))
N,A,B=map(int, raw_input().split())
x=N/(A+B)
y=N%(A+B)
print A*x+min(A,y)
N,A,B=map(int,input().split())
c=10**100
if N<c:
    if N%(A+B)<=A:
        print((N//(A+B))*A+(N%(A+B)))
    elif N%(A+B)>A:
        print((N//(A+B))*A+A)
elif N>=c:
    if c%(A+B)<=A:
        print((c//(A+B))*A+(c%(A+B)))
    elif c%(A+B)<=A:
        print((c//(A+B))*A+A)
N,A,B = [int(i) for i in input().split(" ")]


def check(N,A,B):
    if A == 0:
        return 0
    r  = N//(A+B)
    x = N-r*(A+B)
    if x > A:
        return r*A+A
    else:
        return r*A+x
print(check(N,A,B))
N, A, B = map(int, input().split())

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

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print(0)
  else:
    if a <= amari:
      print(trial_num*a + a)
    else:
      print(trial_num*a + amari)
N,A,B = [int(i) for i in input().split()] 

C = N // (A + B)#商
D = N % (A + B) #余

if D >= A:
  Blue = C * A + A
else:
  Blue = C * A + D
  
print(Blue)