peterverebics/CodeNet_Python_118 huggingface dataset:
def main():
    n, a, b = map(int, input().split())
    quo = n // (a+b)
    rem = n % (a+b)
    ans = quo * a
    if a >= rem:
        ans += rem
    else:
        ans += a
    print(ans)
    
if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())

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

m = a + b
n_set = n // m
n_mod = n % m

ans = a * n_set

if n_mod > a:
    ans += a
else:
    ans += n_mod
print(ans)
n,a,b=map(int,input().split())

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

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

print(ans)
n, a, b = [int(_) for _ in input().split()]
print((n // (a + b)) * a + min(n % (a + b), a))
import sys
input = sys.stdin.readline

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


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

c=(A+B)*(N//(A+B))
s=A*(N//(A+B))

if c+A<=N:
    print(s+A)
else:
    print(s+N-c)
N, A, B = map(int, input().split()) 
how_many = N // (A+B)
r = N % (A+B)
if r >= A:
    print(A*how_many + A)
else:
    print(A*how_many + r)
# ABC 158: B – Count Balls
N, A, B = [int(s) for s in input().split()]

blues = A * (N // (A + B))
remains = N % (A + B)

if remains < A:
    blues += remains
elif A <= remains < A + B:
    blues += A

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

count = N // (A + B)

blue = A * count
red = B * count

N -= blue + red

if N > A:
    blue += A
    red += (N - A)
else:
    blue += N

print (blue)
n, a, b = map(int, input().split())
div, rest =divmod(n, (a + b))
#div, rest
ans = a * div
if rest >= a:
    ans += a
else:
    ans += rest
print(ans)
def main():
    n,a,b=map(int,input().split())
    k=n//(a+b)
    print(a*k+min(n%(a+b),a))
main()
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)
N, A, B = list(map(int, input().split()))
C = N % (A+B)
D = N//(A+B)
if A >= C:
  print(A*D+C)
else:
  print(A*D+A)
n, a, b = map(int, input().split())
if a+b == 0:
  x = 0
else:
	s = n//(a+b)
	t = n%(a+b)
	if t <= a:
		x = s*a+t
	else:
		x = s*a+a
print(x)
n, a, b = list(map(int, input().split(' ')))

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

print(ans + alp)
n, a, b = map(int, input().split())
rest = n % (a + b)
block = (n // (a + b)) * a
if a <= rest:
    print(block + a)
else:
    print(block + rest)
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)
# coding: utf-8

def main():
    N, A, B = map(int, input().split())
    quo = N // (A + B)
    rem = N % (A + B)

    if (rem > A): rem = A
    ans = quo * A + rem

    print(ans)

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

cnt = int(n//(a+b))
res = int(n%(a+b))
if res <= a:
    print(cnt*a+res)
else:
    print((cnt+1)*a)
import numpy as np
N, A, B = list(map(int, input().split()))

count = A + B
hoge1 = N // count
hoge2 = N % count

ans1 = A * hoge1

if hoge2 < A:
    print(ans1 + hoge2)
else:
    print(ans1 + A)
n,a,b = map(int,input().split())
ans = 0
ans += (n//(a + b)) * a
m = n%(a + b)
if m >= a:
    ans += a
else:
    ans += m
print(ans)
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)
N,A,B=map(int,input().split())
t=N//(A+B)
if N%(A+B)==0:
  print(t*A)
else:
  if N%(A+B)<=A:
    print(t*A+N%(A+B))
  else:
    print(t*A+A)
n, a, b = map(int, input().split())

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

answer = a * q + min(a, r)
print(answer)
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	ans = int(N // (A + B)) * A + min(N % (A + B), A)
	print(ans)


if __name__ == '__main__':
	main()
N,A,B=[int(a) for a in input().split()]

div,mod=divmod(N,A+B)
ans=div*A + min(A,mod)
print(ans)
N, A, B = map(int,input().split())
patternNum = N // (A + B)
remains = N % (A + B)
if (remains > A):
	print(patternNum * A + A)
else:
	print(patternNum * A + remains)
n, a, b = map(int, input().split())

if n%(a+b) >a:
    print(int(n//(a+b))*a +a)
else:
    print(int(n//(a+b))*a +n%(a+b))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

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

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

# 整数除算
m = n // (a+b)

# あまり
amari = n % (a+b)

# まずはあまりを除いた青の数
blue_num = m * a

if a > amari:
    blue_num += amari
elif a <= amari:
    blue_num += a

print(blue_num)
N, A, B = map(int, input(). split())
amari = N%(A+B)
kaisu = N//(A+B)
kazu = kaisu*A + min(amari, A)
print(kazu)
N, A, B = list(map(int, input().split()))

shou = N // (A + B)
amari = N % (A + B)
print(shou * A + min(A, amari))
line = input().split()
N = int(line[0])
nB = int(line[1])
nR = int(line[2])

if nB == 0:
  print(0)
  quit()

nball = nB + nR
nGroup = N // nball
nAdditional = N % nball

if nAdditional > nB:
  nAdditional = nB

nBlueTotal = nB * nGroup + nAdditional
print(nBlueTotal)
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)
n, a, b = map(int, input().split())
print((n // (a + b)) * a + min(n % (a + b), a))
n, a, b = map(int, input().split())
c = n // (a+b)
d = n % (a+b)
if d > a:
    d = a
print(c*a+d)
N, A, B = map(int, input().split())
ans = 0

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

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

cluster = NAB[1] + NAB[2]
q, mod = divmod(NAB[0], cluster)

q *= NAB[1]
q += NAB[1] if (NAB[1] < mod) else mod

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

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

if amari > A:
    print(A*(loop+1))

else:
    print(A*loop+amari)
N, A, B = map(int, input().split())
M = N // (A + B)

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

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

print(ans)
N, A, B = map(int, input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
N, A, B = map(int, input().split())
r = N//(A+B)
print(r*A+min(A, N-r*(A+B)))
n,a,b=map(int,input().split())
print((n//(a+b))*a+min(n%(a+b),a))
# coding: utf-8

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

c = a + b
m = n % c
mn = n // c

if m > a:
    result = mn * a + a
else:
    result = mn * a + m
print(result)
d = input().split(" ")
n = int(d[0])
a = int(d[1])
b = int(d[2])
s = a + b
c = (n // s) * a
if n % s > a:
	c += a
else:
	c += n % s
print(c)
N, A, B = input().split()
N, A, B = int(N), int(A), int(B)

print(N//(A+B)*A + min([A, N%(A+B)]))
n, a, b = map(int, input().split())
ans = n // (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)
N, A, B = map(int, input().split())
print(A*(N//(A+B)) + min(A, N%(A+B)))
n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)
n, a, b = map(int, input().split())

ans = n // (a + b) * a
rem = n % (a + b)
ans += min(a, rem)  # ansとremを比較することでnの位置よって処理を変えられる

print(ans)
n, a, b = map(int, input().split())
ans = n // (a + b) * a
rest = n % (a + b)
ans += min(rest, a)
print(ans)
n,a,b=map(int,input().split())
c=n//(a+b)
d=n-(a+b)*c
if d>=a:
    print((c*a)+a)
else:
    print((c*a)+d)
n, a, b = [int(i) for i in input().split()]

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

if y > a:
  y = int(a)
  

print(int((x*a)+y))
n,a,b = map(int,input().split())
ans = 0
pair = n//(a+b)
ans += pair * a
ans += min(n - (a+b)*pair,a)
print(ans)
N, A, B = map(int, input().split())

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

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

ans = N // (blue + red) * blue
rem = N % (blue + red)
ans += min(rem, blue)
print(ans)
#!/usr/bin/env python3

n, a, b = map(int, input().split())
print(n//(a+b)*a + min(n-(n//(a+b)*(a+b)), a))
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A) if m > A else A*n + m)


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

cnt = A * (N//(A+B))
x =  N % (A+B)
if x > A:
    cnt += A
else:
    cnt += x
    
print(cnt)
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)
import math
S,A,B=map(int,input().split())

q=S//(A+B)
mod=S%(A+B)

if mod>=A:
    print(q*A+A)
else:
    print(q*A+mod)
N, A, B = map(int, input().split())
if N%(A+B) < A:
    print(N%(A+B) + N//(A+B) * A)
else:
    print(A + N//(A+B) * A)
N,A,B = map(int, input().split())
if N // (A + B) == 0:
    print(min(A, N))
else:
    print((N // (A + B)) * A + min((N % (A + B)), A))
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()
n,a,b=map(int,input().split())
# x=n//(a+b)
# y=n%(a+b)
# print(a*x+min(y,a))
if a==0:
    print(0)
else:
    x=n//(a+b)
    y=n%(a+b)
    print(a*x+min(y,a))
n,a,b=map(int,input().split())
if a==0:
  print(0)
  exit()
elif b==0:
  print(n)
  exit()
s=a+b
cnt=n//s
r=n%s
ans=cnt*a+min(a,r)
print(ans)
import math
N, A, B = map(int, input().split())

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

amari = N - times * (A + B)
if amari > A:
  amari_a = A
else:
  amari_a = amari 

print(times * A + amari_a)
N ,A ,B = map(int,input().split())

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

ans = (Q * A + min(r,A))
print(ans)
n,a,b=map(int,input().split())
m=n%(a+b)
s=n//(a+b)
if m<=a:
    print(a*s+m)
else:
    print(a*s+a)
Nf,Af,Bf = (input().split(' '))
N = int(Nf)
A = int(Af)
B = int(Bf)
a = N % (A + B)
b = N // (A + B)

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

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

if n > a:
    ans += a
else:
    ans += n

print(ans)
n, blue, red = map(int, input().split())

total= n//(blue+red)*blue

if n%(blue+red)>=blue:
  total+= blue
else:
  total+= n%(blue+red)

print(total)
N,A,B=map(int,input().split())
K=N//(A+B)
print(K*A+min(A,N%(A+B)))
N, A, B = map(int, input().split())
t = N // (A + B)
print(t * A + min(N - t * (A + B), 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())
ans = 0

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

ans = A*r

if s <= A:
    ans += s
elif s > A:
    ans += A


print(ans)
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

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


ab = a + b

d = int(n / ab)
m = n % ab

if ( a > m):
	sum = a * d + m
else:
	sum = a * d + a

print sum
sys.stdout.flush()
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)
n,a,b=map(int,input().split())
c=n//(a+b)
d=n%(a+b)
print(a*c+min(d, a))
n,a,b=map(int,input().split())
q,r = n//(a+b),n%(a+b)
print(q*a + min(r,a))
from sys import stdin
n,a,b = map(int,stdin.readline().rstrip().split())
c = n//(a+b)
d = n%(a+b)
if d > a:
    print(a*(c+1))
else:
    print(a*c+d)
N,A,B = map(int,input().split())
print(N//(A+B)*A + min(N%(A+B),A))
balls = input().split(" ")

n = int(balls[0])
b = int(balls[1])
r = int(balls[2])


if( b == 0 ):
  print( 0 )
else:
  
  step = b + r 
  cnt = n // step
  remain = n % step
  bcnt = cnt * b + min( remain, b)
  
  print( bcnt )
n, a, b = map(int, input().split())

s = a + b
n_s = n // s
l = n - s * n_s

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

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

if q >= 1:
    if q > A:
        ans += A
    else:
        ans += q

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

AB = A + B
ans = 0

ans += (N // AB) * A

if N % AB > A:
  ans += A
else:
  ans += N % AB

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

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

if N <= A:
    print(N)
    exit()

set_count = N // (A+B)
extra = N % (A+B)

if extra <= A:
    print(set_count*A + extra)
    exit()
else:
    print(set_count*A + A)
    exit()
N, A, B = map(int, input().split())
print (A * (N // (A+B)) + min(N % (A+B), A))
n, a, b = map(int,input().split())
add = 0
if ( n % (a + b) ) < a :
    add = ( n % (a + b) ) % a
else:
    add = a
print((n // (a + b)) * a + add)
import math

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

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

one_set = a + b
amari = n % one_set
ans = (n // one_set) * a

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

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

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

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

print(A * (N // (A + B)) + min(A, N % (A + B)))
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


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


def main():
    N,A,B = MI()
    oneset = A + B

    rep = N // oneset

    print(rep * A + min(N % oneset,A))


main()
N,A,B = map(int,input().split())
a = N//(A+B)
ans = a*A
ans2 = min(N-(A+B)*a,A)
print(ans+ans2)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

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

if __name__=='__main__':
  main()
N, A, B = map(int, input().split())
a = N//(A+B)
b = N % (A+B)

if A == 0:
    print(0)
elif b <= A:
    print(a*A+b)
else:
    print(a*A+A)
N, A, B = map(int, input().strip().split())

tmp = N // (A+B)
ans = tmp * A
remain = N - (tmp * (A+B))
if (remain >= A) :
    ans += A
    
else:
    ans += remain

print(ans)
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)
N, A, B = map(int, open(0).read().split())

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

print(ans)
N, A, B = map(lambda x: int(x), input().split(" "))

if A == 0:
    print(0)
else:
    count = N // (A+B)
    result = count*A
    if (N-(count*(A+B))) >= A:
        result += A
    else:
        result += (N-(count*(A+B)))

    print(result)
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)
N, A, B = map(int, input().split())
print(N // (A + B) * A + min(A, N % (A + B)))
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

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

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


if __name__ == '__main__':
    main()
n,a,b = map(int,input().split())
saaa = a+b
s1 = n//saaa
nokori = n%saaa
if nokori >= a:
    nokori = a
else:
    nokori = nokori
ans = s1*a + nokori
print(ans)
n, a, b = map(int, input().split())

print((n // (a + b) * a + min(n % (a + b), a)))
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = N//(A+B)*A + (A if N%(A+B)>A else N%(A+B))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)
n,a,b=map(int,input().split())
answer=0
if a==0:
    answer=0
elif b==0:
    answer=n
elif a==1 and b==1:
    answer=n//2
else:
    while n>a+b:
        answer+=n//(a+b)*a
        n-=n//(a+b)*(a+b)
    if n>a:
        answer+=a
    else:
        answer+=n
print(answer)
N, A, B = list(map(int, input().split()))
if N > A + B:
  set_n = N // (A+B)
  N0 = N % (A+B)
  print(A * set_n + min(N0, A))
else:
  print(min(N, A))
import math
N, A, B = [int(i) for i in input().split()]
if A == 0 and B == 0:
    print(0)
else:
    count = A + B
    setCount = math.floor(N / count)
    amari = N - setCount * count
    if amari > 0:
        if A > amari:
            result = setCount * A + amari
        else:
            result = setCount * A + A
    else:
        result = setCount * A
    print(result)
N, A, B = map(int, input().split())

period = N // (A + B)
number = N % (A + B)

if number >= A:
  print(A * period + A)
else:
  print(A * period + number)
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)
N, A, B = map(int, input().split())
period = A + B
times = N//period
k = N%period
N =  A if k >A else k
print(times*A + N)
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))
N,A,B = map(int,input().split())
ans = 0
ans += (N//(A+B)) * A
i = min((N % (A+B)),A)
if i >= 0:
    ans += i
print(ans)
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)
n, a, b = (int(i) for i in input().split());

res = a * (n // (a + b));

curr = n % (a + b);

res += min(a, curr);

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

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

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

print(ans)
n,a,b=map(int,input().split())
if n<a:
    print(n)
    exit()
katamari=max(n//(a+b),1)
if n>a+b:
    amari=min(n%(a+b),a)
else:
    amari=0
print(a*katamari+amari)
# ABC158 B - Count Balls

M,A,B = map(int,input().split())
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A

if N >= A:
    E+=A
else:
    E+=N
print(E)
#B - Count Balls
N, A,B= map(int, input().split())

a = N % (A+B)
b = N // (A+B)
if a <= A:
    print(b*A+a)
else:
    print(b*A+A)
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
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()
n, a, b = map(int, input().split())
line = n // (a + b)
remain = n % (a + b)

ans = line * a
ans += min(a, remain)

print(ans)
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    ans = N//(A+B)*A
    rem = N%(A+B)
    print(ans+min(rem, A))
if __name__ == '__main__':
    main()
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)
N, A, B = map(int, input().split())
sum_ = A * (N // (A+B))
mod = N % (A+B)
print(sum_ + (A if mod >= A else mod))
N, A, B = 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())

print(n // (a + b) * a + min(a, n % (a + b)))
N, A, B = map(int, input().split())
tmp = N%(A+B)
if tmp>A:
    tmp=A
ans = (N//(A+B))*A + tmp
print(ans)
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)
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

n, a, b = input_nums()

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

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

c = 0
if A == 0:
    print(0)
    exit()
if B == 0:
    print(N)
    exit()

x = N // (A+B)
y = N % (A+B)
c = x * A
if A <= y:
    c += A
else:
    c += y

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

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


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

kuri=n//(a+b)
ama=n%(a+b)
ans=kuri*a+min(a,ama)
print(ans)
f = [int(i) for i in input().split()]
n = f[0]
a = f[1]
b = f[2]

m = n // (a+b)
tmp = m * a
mod = n%(a+b)
print(tmp+min(mod,a))
n, a, b = map(int, input().split())
ans = n//(a+b)*a
tmp = min(n%(a+b), a)
print(ans + tmp)
N, A, B = [int(x) for x in input().split()]

mod = int(N % (A + B))
kake = int(N // (A + B))
if mod <= A:
    print(kake*A + mod)
else:
    print(kake*A + A)
n, a, b = map(int, input().split())
sho = n//(a+b)
amari = n % (a+b)
print(sho*a+min(a, amari))
N, A, B = map(int,input().split())
ans = (N // (A+B)) * A
N = N % (A+B)
ans += min(A,N)
print (ans)
n, a, b = map(int, input().split(' '))

if a == 0:
  print('0')
else:
  base = (n//(a+b))*a
  
  n = n%(a+b)
  
  base += min(n, a)
  
  print(base)
import sys

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

Count_Blue = 0
if 1<=N<=10**18 and A > 0 and B >= 0 and \
   0< A + B <= 10**18:
    Add_Blue = 1 * A
    Add_Both = Add_Blue + 1 * B

    q = N // Add_Both
    mod = N % Add_Both
    if mod < Add_Blue:
        Count_Blue = (q *Add_Blue) + mod
    else:
        Count_Blue = (q * Add_Blue) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)
N, A, B = map(int, input().split())
if A > (N % (A + B)):
    print((N // (A + B)) * A + N % (A + B))
else:
    print((N // (A + B)) * A + A)