CodeEff/ECCO huggingface dataset:
# Original solution
n, a, b = list(map(int, input().split()))

ans = 0
test = 0
while n > test:
    test += a + b
    if n >= test:
        ans += a
    else:
        x = test - n
        if x > b:
            ans += a - (x - b)
        else:
            ans += a

print(ans)

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

q = n // (a + b)

x = a * q

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

ans = x + y

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))
ball = []
import sys
cnt = 0
while 1:
    for i in range(A):
        ball += [0]
        cnt += 1
        if len(ball)==N:
            print(cnt)
            sys.exit()
    for j in range(B):
        ball += [1]
        if len(ball)==N:
            print(cnt)
            sys.exit()

# Optimized solution
N, A, B = list(map(int, input().split()))
kaisu = N//(A+B)

n = N-((A+B)*kaisu)
if n >= A:
    print((A*(kaisu+1)))
else:
    print((A*kaisu+n))
# Original solution
n,a,b = list(map(int, input().split()))

x = ''
y = ''
z = ''
zz =''
for i in range(a):
  x = x + '0'

for i in range(b):
  y = y + '1'

zz = x + y

for i in range(int(n/len(zz))+1):
  z = z + x + y

print((z[:n].count('0'))) 

# Optimized solution
n,a,b = list(map(int, input().split()))
 
x = n//(a+b)
y = n%(a+b)
z = 0
if y <= a :
  z = y
else :
  z = a
  
print((x*a+z))
# Original solution
n, a, b = list(map(int, input().split()))

ans = 0
while n > 0:
    if n >= a:
        ans += a
        n -= a
    else:
        ans += n
        break
    n -= b

print(ans)

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

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

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

print(ans)
# Original solution
N, A, B = list(map(int, input().split()))

c = 0
bc = 0

while True:
    if c > N:
        ans = bc
        break
    c += A
    bc += A
    if c > N:
        ans = bc - (c - N)
        break
    c += B

print(ans)

# Optimized solution
N, A, B = list(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)
# Original solution
n,b,r=list(map(int,input().split()))
blue=True
c=0
while n>0:
    if blue:
        x=b if n>b else n
        c+=x
        n-=x
    else:
        n-=r if n>r else n
    blue=(not blue)
print(c)

# Optimized solution
n,b,r=list(map(int,input().split()))
x=n%(b+r)
c=b*(n//(b+r))
c+=b if x>b else x
print(c)
# Original solution
n, a, b = list(map(int, input().split()))

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

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

print(ans)

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

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

print(ans)
# Original solution
n,a,b=list(map(int,input().split()))
x=n//(a+b)
x*=a
if a!=0:
    for i in range(n%(a+b)):
        x+=1
        a-=1
        if a==0:
            break
print(x)    

# Optimized solution
n,a,b=list(map(int,input().split()))
x=n//(a+b)
x*=a
if a!=0:
    if n%(a+b)<a:
        x=x+(n%(a+b))
    else:
        x+=a
print(x)
# Original solution
N, A, B = [int(x) for x in input().split()]

ans = 0
flag = True
list = ''
if A + B == N:
    ans = A
elif A == 0:
    ans = 0
else:
    while flag == True:
        for a in range(A):
            ans = ans + 1
            list += 'b'
            if len(list) == N:
                flag = False
                break
        for b in range(B):
            list += 'r'
            if len(list) == N:
                flag = False
                break
print(ans)

# Optimized solution
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))
# Original solution
import collections
N, A, B = list(map(int, input().split()))

cnt = []
for n in range(10 ** 100):
    if len(cnt) == N:
        break
    for i in range(A):
        if len(cnt) == N:
            break
        cnt.append("b")
    for j in range(B):
        if len(cnt) == N:
            break
        cnt.append("r")
ans = collections.Counter(cnt)
print((ans["b"]))

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

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

print(cnt)
# Original solution
n, a, b = [int(x) for x in input().split()]

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - ((a + b) * x)) >= a:
            print((a * x + a))
        else:
            print((a * x + (n - (a + b) * x)))


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

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - ((a + b) * x)) >= a:
            print((a * x + a))
        else:
            print((n - b * x))
# Original solution
n,a,b=list(map(int,input().split()))
c=0
ans=0

while c<n:
  c=c+a+b
  ans+=a
  
if c==n:
  print(ans)
else:
  if c-n<=b:
    print(ans)
  else:
    print((ans-c+n+b))

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

q=n//(a+b)
r=n-q*(a+b)
if r>=a:
  print((a*(q+1)))
else:
  print((a*q+r))
# Original solution
import math
from collections import deque
def main():
    n,a,b = tuple([int(t)for t in input().split()])

    if b == 0:
        print(n)
    else:
        t = a+b
        res = (n // t)*a+min(n%t,a) 
        print(res)
if __name__ == "__main__":
    main()

# Optimized solution
n,a,b = tuple(map(int,input().split()))

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

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

print(ans)
# Original solution
n, a, b = list(map(int, input().split()))

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

if y <= a:
  print(((x * a) + y))
else:
  print(((x * a) + a))

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

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

print(((x * a) + min(y, a)))
# Original solution
N, A, B = list(map(int, input().split()))
a = 0
b = 0
C = 0
while N > 0:
    C = N
    N = N - A
    if N > 0:
        a = a + A
    else:
        a = a + C
    N = N - B
print(a)

# Optimized solution
N, A, B = list(map(int, input().split()))
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
# Original solution
n, a, b = list(map(int, input().split()))
blue = 0
total = 0

for i in range(10**100):
  blue += a
  total += a
  if total == n:
    print(blue)
    exit(0)
  elif total > n:
    print((blue - (total - n)))
    exit(0)
    
  total += b
  if total >= n:
    print(blue)
    exit(0)

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

num = n//(a+b)
if (a+b)*num == n:
  print((a*num))
elif (a+b)*num + a <= n:
  print((a*(num+1)))
else:
  print((a*num + n - (a+b)*num))
# Original solution
n,a,b=list(map(int,input().split()))
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n 
else:
    while True:
        if n-a>=0:
            n-=a
            ans+=a
        else:
            ans+=n
            break
        n-=b
        if n<=0:
            break
print(ans)

# Optimized solution
n,a,b=list(map(int,input().split()))
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n
else:
    ans=a*(int(n/(a+b)))
    n=n%(a+b)
    while True:
        if n==0:
            break
        if n-a<0:
            ans+=n
            break
        else:
            ans+=a
            break

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

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


sum = 0
while(n > a):
    n = n-a-b
    sum += a
if n < 0:
    print(sum)
else:    
    print((sum+n))


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

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

print(sum)
# Original solution
n, a, b = list(map(int, input().split()))
extra = n % (a +b)
roop = n // (a +b)
result = a*roop
cycle = [1 for _ in range(a)] +  [0 for _ in range(b)]
if extra != 0:
  for i in range(extra):
    result += cycle[i]
print(result)

# Optimized solution
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  if extra >= a:
    result += a
  else:
    result += extra
print(result)
# Original solution
n, b, r = list(map(int, input().split()))
x = []
bool = True
while bool:
    for i in range(b):
        if len(x) == n:
            bool = False
        else:
            x.append("b")
    for j in range(r):
        if len(x) == n:
            bool = False
        else:
            x.append("r")

print((x.count("b")))


# Optimized solution
n, b, r = list(map(int, input().split()))
b1 = n//(b+r)
b2 = n % (b+r)
if b == 0:
    print((0))
elif r == 0:
    print(n)
elif b2 != 0 and b2 <= b:
    b1 = b1*b + b2
    print(b1)
elif b2 != 0 and b2 > b:
    b1 = b1*b + b
    print(b1)
elif n % (b+r) == 0:
    print((b1*b))
# Original solution
N,A,B = list(map(int, input().split()))
adds = A + B
times = (N-1) // (adds + 1)
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)
    
    


# Optimized solution
N,A,B = list(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)
# Original solution
n,a,b = (int(x) for x in input().split())
c = 0
b_flg = True
while True:
  if n <= 0:
    break
  if b_flg:
    n -= a
    c += a
    if n <= 0:
      c += n
    b_flg = False
  else:
    n -= b
    b_flg = True
print(c)



# Optimized solution
n,a,b = (int(x) for x in input().split())

count = (int(n/(a+b)))*a
count += min(n%(a+b),a)
print(count)
# Original solution
N,A,B=list(map(int, input().split()))
arr=[]

for i in range(N):
  if A != 0:
    for _ in range(A):
      arr.append('b')
  if B != 0:
    for _ in range(B):
      arr.append('r')
print((arr[0:N].count('b')))

# Optimized solution
N,A,B=list(map(int, input().split()))
len=A+B
print(((N // len)* A + min(A, N % len)))
# Original solution
N,A,B = list(map(int,input().split()))
a = N//(A+B)
ans = a*A + min((N-a*(A+B)),A)
print(ans)


# Optimized solution
N,A,B = list(map(int,input().split()))
print((N//(A+B)*A + min((N-N//(A+B)*(A+B)),A)))
# Original solution
N, A, B = list(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))

# Optimized solution
n,a,b=list(map(int,input().split()))
p=n//(a+b)
ans=a*p+min(a,(n % (a + b)))
print(ans)
# Original solution
n, a, b = list(map(int, input().split()))
ans = []
c = 0

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

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


while True:
    

    for i in range(a):
        
        if len(ans) == n:
            print((ans.count("b")))
            exit()
        ans.append("b")
        

    for j in range(b):
        if len(ans) == n:
            print((ans.count("b")))
            exit()
        ans.append("r")



# Optimized solution
n, a, b = list(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()
# Original solution
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()


# Optimized solution
import sys


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


if __name__ == '__main__':
    solve()
# Original solution
import sys

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

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

ans = 0
while n > 0:
    if n - a <= 0:
        for i in range(a):
            ans += 1
            n -= 1
            if n <= 0: break
    else:
        ans += a
        n -= a
    n -= b
    
print(ans)

# Optimized solution
import sys

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

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

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

if amari <= a:
    print((syou*a + amari))
else:
    print((syou*a + a))
# Original solution
N_A_B = list(map(int, input().split()))
N = N_A_B[0]
A = N_A_B[1]
B = N_A_B[2]

count = 0
retu = []
while count < 10 ** 100 and count < N:
    count += 1
    for index in range(A):
        retu.append(1)
    for index in range(B):
        retu.append(0)
retu = retu[0:N]
print((sum(retu)))


# Optimized solution
N_A_B = list(map(int, input().split()))
N = N_A_B[0]
A = N_A_B[1]
B = N_A_B[2]

"""
count = 0
retu = []
while count < 10 ** 100 and count < N:
    count += 1
    for index in range(A):
        retu.append(1)
    for index in range(B):
        retu.append(0)
retu = retu[0:N]
print(sum(retu))
"""

if N % (A + B) == 0:
    print((N // (A + B) * A))
elif N % (A + B) > A:
    print((N // (A + B) * A + A))
else:
    print((N // (A + B) * A + N % (A + B)))
# Original solution
N,A,B=list(map(int,input().split()))
ans=0
count=0
Flag=False
waru=N//(A+B)
amari=N%(A+B)
for i in range (10**18):
    if amari==0:
        break
    for j in range(A):
        ans+=1
        count+=1
        if count==amari:
            Flag=True
            break
    for k in range(B):
        if Flag:
            break
        count+=1
        if count==amari:
            Flag=True
            break
    if Flag:
        break
print((ans+waru*A))

# Optimized solution
N,A,B=list(map(int,input().split()))
ans=0
count=0
Flag=False
waru=N//(A+B)
amari=N%(A+B)
if amari>A:
    print((waru*A+A))
else:
    print((waru*A+amari))
# Original solution
N, A, B = list(map(int, input().split()))
str = ''

if A == 0:
  print((0))
  exit()
  
for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += 'b'
  for j in range(B):
    if len(str) < N:
      str += 'r'

print((str.count('b')))

# Optimized solution
N, A, B = list(map(int, input().split()))
print(((N // (A + B) * A) + min(A, N % (A + B))))
# Original solution
n, a ,b = list(map(int, input().split()))
ans = 0
length = 0
while length <= n:
  length += a + b
  ans += a
over = length - n
if (over == 0):
  print(ans)
else:
  if (over <= b):
    print(ans)
  else:
    over -= b
    ans -= over
    print(ans)

# Optimized solution
n, a, b = list(map(int, input().split()))
q = n // (a+b)
mod = n % (a+b)
ans = q * a
if (mod > a):
  ans += a
else:
  ans += mod
print(ans)
# Original solution
n,a,b=list(map(int,input().split()))
K=n//(a+b)
J=n%(a+b)
if J<=a:
    print((K*a+J))
else:
    print((K*a+a))

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

print((a*(n//(a+b))+min(a,n%(a+b))))
# Original solution
[N, A, B] = [int(i) for i in input().split()]

Ac = 0
Bc = 0

times = 0
length = 0

while length < N:
    if times % 2 == 0:
        length += A
        Ac += 1
    else:
        length += B
        Bc += 1
    
    times += 1

if times % 2 == 0:
    print((A*Ac))
else:
    print((A*Ac - (length - N)))

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

div = N // (A+B)

ans = A*div

diff = N - ((A+B)*div)

if A < diff:
    ans += A
else:
    ans += diff

print(ans)
# Original solution
N,A,B = list(map(int,input().split()))
cnt = 0
num = 0
flg = 'A'

for i in range(N):
    if flg == 'A' and num < A:
        cnt += 1
        num += 1
        if num == A:
            num = 0
            flg = 'B'
    elif flg == 'B' and num < B:
        num += 1
        if num == B:
            num = 0
            flg = 'A'
print(cnt)


# Optimized solution
N, A, B = list(map(int, input().split()))
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
# Original solution
n, a, b = list(map(int, input().split(' ')))

count = 0
ret = 0
while(count < n):
    if count + a >= n:
        ret += n - count
        break
    if count + a + b >= n:
        ret += a
        break
    count += a + b
    ret += a
print(ret)

# Optimized solution
n, a, b = list(map(int, input().split(' ')))

ret = n // (a + b) * a
ret += a if (n % (a + b) >= a) else n % (a + b)
print(ret)
# Original solution
N, A, B  = [int(x) for x in input().split(" ")]

lst = []
b = 0
r = 0

while b + r <= N:
  for i in range(0,A):
    lst.append("b")
    b += 1
  for i in range(0,B):
    lst.append("r")
    r += 1
    
print((lst[:N].count("b")))

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

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

ball_n = [0, 0]

while sum(ball_n) != n:
    for _ in range(a):
        ball_n[0] += 1
        if sum(ball_n) == n:
            break
    
    if sum(ball_n) == n:
        break
    
    for _ in range(b):
        ball_n[1] += 1
        if sum(ball_n) == n:
            break

print((ball_n[0]))

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

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

ans += min(a, r)

print(ans)
# Original solution
N,A,B=list(map(int,input().split()))
l=[]
for i in range(N):
    for j in range(A):
        l.append('r')
        if len(l) >= N:
            print((l.count(('r'))))
            exit()
    for k in range(B):
        l.append('b')
        if len(l) >= N:
            print((l.count(('r'))))
            exit()

print((l.count(('r'))))



# Optimized solution
N,A,B=list(map(int,input().split()))
a=N//(A+B)
b=N%(A+B)
if A == 0:
    print((0))
    exit()

if b > A:
    print((a*A+A))
    exit()

print((a*A+b))
# Original solution
n, a, b = list(map(int, input().split()))
c = a + b
if n % c == 0:
    ans = a * (n // c)
elif n % c <= a:
    ans = a * (n // c) + n % c
else:
    ans = a * (n // c +1)

print(ans)


# Optimized solution
n,a,b=list(map(int,input().split()))
t=a+b
if n%t<=a:
    diff=n%t
else:
    diff=a
print((a*(n//t)+diff))
# Original solution
N,A,B=list(map(int,input().split()))
k=0
while (A+B)*k<N:
  k+=1


if (A+B)*k==N:
  print((A*k))
else:
  if N-(k-1)*(A+B)>A:
    print(((k-1)*A+A))
  else:
    print(((k-1)*A+N-(k-1)*(A+B)))

# Optimized solution
N,A,B=list(map(int,input().split()))
k=N//(A+B)

if (A+B)*k==N:
  print((A*k))
else:
  if N-k*(A+B)>A:
    print((k*A+A))
  else:
    print((k*A+N-k*(A+B)))
# Original solution
n,a,b=list(map(int,input().split()))
s=0
if n>=(a+b):

    while True:

        n=n-(a+b)

        s+=1

        if n-(a+b)<=0:

            break
        else:pass

    if n>=a:

        print((a*(s+1)))
    else:
        print((a*s+n))

else:

    if n>=a:

        print(a)

    else:
        print(n)
        


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

if n>=(a+b):

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

    l=int(n%(a+b))

    if l>=a:

        print((a*k+a))

    else:
        print((a*k+l))

else:

    if n>=a:

        print(a)

    else:
        print(n)
# Original solution
n, a, b = list(map(int, input().split()))

c = 0
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)

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

x = n // (a+b)
c = a * x
n -= (a+b)*x
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)
# Original solution
import math
## test

n,a,b=list(map(int, input().split()))
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)
    
    


# Optimized solution
import math
n,a,b=list(map(int, input().split()))
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
cnt = anc_a + min([n_b,a])
print(cnt)
# Original solution
N,A,B = list(map(int,input().split()))
count = 0
flag = True
while flag:
    if N >= A:
        N = N - A
        count += A
    else:
        count += N
        N = 0
        flag = False
    if N >= B:
        N = N - B
    else:
        N = 0
        flag = False
print(count)

# Optimized solution
N,A,B = list(map(int,input().split()))
C = A + B
 
shou = N // C
amari = N % C
if amari >= A:
    print((A * shou + A))
else:
    print((A * shou + amari))
# Original solution
# N, A, B
num, greenNum, redNum = [int(x) for x in input().split(' ')]

# output
totalGreen = 0
while (num > 0):
  if (num <= greenNum):
    totalGreen += num
    num = 0
  else:
    totalGreen += greenNum
    num -= (greenNum + redNum)
    
print(totalGreen)


# Optimized solution
# N, A, B
num, greenNum, redNum = [int(x) for x in input().split(' ')]

numSet = num // (greenNum+redNum)
remain = num % (greenNum+redNum)
numRest = remain if (remain < greenNum) else greenNum

totalGreen = numSet * greenNum + numRest

print(totalGreen)
# Original solution
n, a, b = list(map(int, input().split()))
l = []
i = 0
res = 0

while i < n:
    save = i
    i += a
    if i < n:
        res += a
        i += b
    elif i > n:
        res += n - save

print(res)

# Optimized solution
n, a, b = list(map(int, input().split()))
k = a + b
i = 0
res = 0

y = n // k  
res += y * a

x = k * y

if x + a <= n:
    res += a
elif x + a > n:
    res += n - x
    
print(res)
# Original solution
N, A, B = list(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)


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

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

print(ans)
# Original solution
n,b,r=list(map(int,input().split()))

flag = True
count = 0
counts = 0
while flag == True:
  for i in range(b):
    count += 1
    counts += 1
    if counts == n:
      flag = False
      break
  for i in range(r):
    counts += 1
    if counts == n:
      flag = False
      break

print(count)

# Optimized solution
n,b,r=list(map(int,input().split()))


count = n // (b+r)
counts = n % (b+r)

countss=b*count
if counts<= b:
  coun=counts
else:
  coun=b

print((countss+coun))
# Original solution
N,A,B = list(map(int, input().split()))

moji = ''

while len(moji) < N:
    for i in range(A):
        moji += 'b'
    for j in range(B):
        moji += 'r'

moji = moji[:N]

print((moji.count('b')))

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

nn = N // (A+B)

amari = N % (A+B)

if amari < A:
    print((A*nn + amari))
else:
    print((A*nn + A))
# Original solution
N,A,B=list(map(int,input().split()))

cnt_blue = 0
# cnt_red = 0
total = 0

while(True):
    cnt_blue += A
    total += A
    if N <= total:
        cnt_blue = cnt_blue - (total - N)
        break 
#     cnt_red += B
    total += B
    if N <= total:
#         cnt_red = cnt_red - (total - N)
        break
print(cnt_blue)

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

cnt_blue = 0
total_tmp = 0

try:
    pre_cnt = N // (A+B)
    total_tmp = pre_cnt * (A+B)
    total_tmp += A
    if N <= total_tmp:
        cnt_blue = N -  (pre_cnt * B)
    else:
        cnt_blue = (pre_cnt * A) + A
    print(cnt_blue)
except Exception as e:
    print((0))
# Original solution
n, a, b = list(map(int, input().split()))
ans = 0
count = 0
while(count < n):
  if count%(a+b) < a:
    ans+=1
  count+=1
print(ans)

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

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