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 sys
input = sys.stdin.buffer.readline

def inn(func=int):
    return list(map(func,input().split()))

def ins():
    return input().split()

n,a,b = inn()
mon = int(n/(a+b))
las = n%(a+b)
print(mon*a+min(las,a))

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

full_a = n // (a+b)
n_r = n % (a+b)
rest_a = min(n_r,a)

print(full_a*a+rest_a)

Solution (Python):

n,a,b = map(int, input().split())
x = n//(a+b)
y=n-(a+b)*x

if y <=a:
    z=y
else:
    z=a

print(x*a+z)

Solution (Python):
import math

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

X = math.floor(N/(A+B))
Y = N%(A+B)

if(Y>A):
  print(X*A+A)
else:
  print(X*A+Y)

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

print(head + tail)

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

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

Solution (Python):
if __name__ == '__main__':
    n,a, b = map(int, input().split())
    sum = 0
    if (a+b)*10 ** 100 > n:
        mod = n %(a+b)
        ans = n // (a+b)
        sum = ans * a
        if mod > a:
            sum =sum + a
        else:
            sum = sum + mod
    else:
        sum = b * (10 ** 100)
    print(sum)

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

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

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

print(ans)

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

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

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

Solution (Python):
P = [int(p) for p in input().split()]
N = P[0]
A = P[1]
B = P[2]

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

amari = N%(A+B)
if(amari < A ):
    Blue += amari
else:
    Blue += A

print(Blue)

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

X = int(N / (A+B))
Y = int(N % (A+B))

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

print(ans)

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

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

if __name__ == "__main__":
    main()

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

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

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

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

print(ans)

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

unit_num = A + B

unit_b = (N // unit_num) * A

temp_num = min(A, N % unit_num)

print(unit_b + temp_num)

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

n = (N // (A + B)*A)
m = (N % (A + B))
if m > A:
    print(A + n)
else:
    print(m + n)

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

c = a+b

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

print(ans)

Solution (Python):


def main():
    n, a, b = map(int, input().split())
    c = n // (a + b)
    n -= (a + b) * c

    count = a * c

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

    print(count)

if __name__ == '__main__':
    main()

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

Solution (Python):


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)

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

Solution (Python):


import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        
        
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    (n, a, b) = [int(e) for e in lines[0].split(" ")]

    return (n, a, b)


def solve(n, a, b):

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

    d = min([r, a])
    
    result = c*a + d

    return result
    


def main():
    
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

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

    print(sum_blue)

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

waku = n//(a+b)
amari = n % (a+b)
kisu = waku * a

if amari >= a:
    print(kisu + a)
elif amari < a:
    print(kisu + amari)

Solution (Python):
info = [int(i) for i in input().split()]
print(int(info[0]/(info[1]+info[2]))*info[1] + min(info[1], info[0]%(info[1]+info[2])))

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

times, m = divmod(N, A + B)

print(A * times + min(m, A))

Solution (Python):



I = list(map(int, input().split())) 
N=I[0]
A=I[1]
B=I[2]
K=N%(A+B)
L=N//(A+B)
ans=A*L+min(A,K)
print(ans)

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

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

Solution (Python):
def main():
    n, a, b = [int(e) for e in input().split()]

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

if __name__ == "__main__":
    main()

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

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

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

AB = A+B

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

Solution (Python):
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random


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


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


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


def S(): return list(sys.stdin.readline())[:-1]


def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l

def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l





N, blue, red = LI()

blue_red_count = N // (blue + red)
blue_balls = blue_red_count * blue

remaining = N - blue_red_count * (blue + red)
blue_balls += min(remaining, blue)
print(blue_balls)

Solution (Python):

n, a, b = map(int, input().split())
r1 = n // (a+b)
r2 = min(n % (a+b), a)

print(a * r1 + r2)

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

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

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

print(count)

Solution (Python):
N, A, B = map(int, input().split())
a, r = divmod(N, A+B)
ans = a * A

if r > A:
    ans += A
else:
    ans += r
print(ans)

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

c = 0
c = n//(a+b)
mod = n%(a+b)

ans = c*a
if mod > a :
  print(ans + a)
else :
  print(ans + mod)

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

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

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

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

print(ans)

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

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

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

Solution (Python):
import sys
import math
N, A, B = map(int, input().split())
sum = 0
sum += (N//(A+B))*A
sum += min(A, N%(A+B))

print(sum)

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

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

print(ans)

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

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

Solution (Python):
def main():
    n, a, b = map(int, input().split(" "))
    if a == 0:
        print("0")
        return
    count = (n // (a + b))
    ans = count * a
    if count * (a + b) != n:
        remain = n - (count * (a + b))
        if remain < a:
            ans += remain
        else:
            ans += a
    print(ans)


if __name__ == '__main__':
    main()

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

c = (n // (a + b)) * a
d = n % (a + b)
e = a if d >= a else d

print(c + e)

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

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

Solution (Python):
limit, blue, red = map(int, input().split())

paired = blue + red

ans = (limit // paired) * blue
additional = limit % paired

ans += min(additional, blue)

print(ans)

Solution (Python):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B = read_int()

def solve():
    ans = (N // (A + B)) * A
    r = (N % (A + B))
    ans += r if r < A else A
    return ans

if __name__ == "__main__":
    print(solve())

Solution (Python):
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,a,b = inm()
c = a+b
k = n//c
r = n%c
print(k*a + min(r,a))

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

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

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

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

print(ANS)

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

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

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

P = N // (A + B)
Q = min(N % (A + B), A)

print(P * A + Q)

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

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

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

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

print(ans)

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

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

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

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

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

x1 = N // (A+B) * A
mod = N % (A+B)

print(x1 + mod) if mod < A else print(x1 + A)

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

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

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

if m2 == 0 or m2 <= a:
    print(m1 * a + m2)
else:
    print(m1 * a + a)

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

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

if (N - (repeat * (A + B))) <= A:
    print(repeat * A + (N - (repeat * (A + B))))
else:
    print((repeat + 1) * A)

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

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

waru = int(N / (A + B))
amari = N % (A + B)

result = waru * A

if(amari > A):
  result += A
else:
  result += amari

print(result)

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

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

d, m = divmod(N, (A+B))
ans = 0


if m >= 0:
    if m <= A:



        ans = d*A + m
    else:
        ans = d*A + A
print(ans)

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

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

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

print(ans)

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

count = 0
t1 = (N // (A + B)) * A
t2 = N % (A + B)

count += t1
count += min(t2, A)

print(count)

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

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

print(ans)

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

rb = a[1] + a[2]
n = a[0] // rb
n = n * a[1]
m = a[0] % rb
if m > a[1]:
  l = a[1]
else:
  l = m



print(n+l)

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

c = a + b
ama = N % c
times = N // c

if ama > a:
    ama = a

ans = times * a + ama
print(ans)

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

if __name__=='__main__':
    main()

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

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

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

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

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

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

amari = N - syou*(A+B)

if amari <= A:
    answer = syou * A + amari
else:
    answer = syou * A + A

print(answer)

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

ans = 0

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

ans += set_count*A

nokori = N%(A+B)

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

print(ans)

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

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

Solution (Python):

def main():
    n,blue,red = map(int,input().split())
    total = blue+red
    answer = 0
    answer += (n // total) * blue
    amari = min(blue,(n % total))
    answer += amari
    print(answer)




if __name__ == '__main__':
    main()

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

Solution (Python):
N, A, B = map(int, input().split())
result = 0
d = N // (A + B)
r = N % (A + B)
blue = A if (A <= r) else r
result = d * A + blue
print(result)

Solution (Python):
N,A,B = list(map(int, input().split()))
q, mod = divmod(N, A+B)
ans = q*A + min(A,mod)
print(ans)

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

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

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

ans = div * a
if mod <=a:
    ans += mod
else:
    ans += a

print(ans)

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

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

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

ret = n // (a + b) * a
ret += a if (n % (a + b) >= a) else n % (a + b)
print(ret)

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    
    
    N, A, B = [int(x) for x in sys.stdin.readline().split()]  
    

    
    
    
    

    logger.debug('{}'.format([]))

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

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


if __name__ == "__main__":
    resolve()





import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """8 3 4"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8 0 4"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6 2 4"""
        output = """2"""
        self.assertIO(input, output)

Solution (Python):
n,a,b = (int(x) for x in input().split())
k = n//(a+b)
l = n%(a+b)
if l <= a:
  print(k*a+l)
else:
  print(k*a+a)

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

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

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

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

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

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

Solution (Python):
n, a,b = map(int,input().split())
num = n // (a + b)
if n % (a + b) == 0:
    ans = a * num
elif n % (a + b) >= a:
    ans = a * num + a
else:
    ans = a * num + n % (a + b)
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())

q, mod = divmod(N, A+B)

if mod >= A:
  print(A * (q+1))
else:
  print(A * q + mod)

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

i = n % (a + b)
j = n // (a + b)
ans = 0
if i <= a:
    ans = a * j + i
else:
    ans = a * j + a
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
if a==0 and b==0:
    print(0)
else:
    blue = n//(a+b)
    rm = n%(a+b)
    ans = blue*a
    if rm>a:
        ans += a
    else:
        ans += rm
print(ans)

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    ret = 0
    AB = A + B
    times = N // AB
    ret += (times * A)

    left = min(N - AB*times, A)
    ret += left
    print(ret)

main()

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

num = N // (A + B)

tmp = N - (A + B) * num
if tmp <= A:
    blue_num = tmp
    red_num = 0

else:
    blue_num = A

blue_num = blue_num + num*A
print(blue_num)

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

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

dai = (N//(A+B))*A

amari = (N%(A+B))*( (N%(A+B))<=A ) + A*( (N%(A+B))>A )

print( dai + amari )

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

Solution (Python):
n, a, b = map(int, input().split())
if a == 0:
    print(0)
else:
    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, open(0).read().split())

m = n // (a + b)
c = n % (a + b)

if(c <= a):
    print(a * m + c)
else:
    print(a * m + a)

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

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

Solution (Python):
n, a, b  = [int(x) for x in input().split()]
summ = a * (n // (a + b))
ama = n % (a + b)
if ama > a:
    summ += a
else:
    summ += ama
print(int(summ))

Solution (Python):
import sys

input = sys.stdin.readline

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

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

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

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

Solution (Python):
"""
// Author : snape_here - Susanta Mukherjee
     
"""
 
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
 
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())
 
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
    
 
def read():
    sys.stdin = open('input.txt', 'r')  
    sys.stdout = open('output.txt', 'w') 
 
 
import math

mod=1000000007 

def main():

    n,a,b=mi()
    s=a+b
    if a==0:
        print(a)
        exit() 
    c=(n//s)*a
    d=min(n%s,a) 
    print(c+d)


 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()
 
 
if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
 
input = lambda: sys.stdin.readline().rstrip("\r\n")
 

 
 
if __name__ == "__main__":
    
    main()

Solution (Python):
n,a,b = map(int,input().split())
s = a + b
r = n%s
f = n//s

if r > a:
    r = a

print(f*a+r)

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

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

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

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

if A + B == 0:
    print('0')
else:
    AB = A + B
    quo = N // AB
    rem = N % AB
    ans = quo * A + min(rem, A)
    print(ans)

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

Solution (Python):
i = [int(s) for s in input().split()]
n = i[0]
a = i[1]
b = i[2]

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

Solution (Python):
N , A , B = map ( int , input().strip().split(" ") ) ;
c = N // ( A + B ) ;

x = c * A

r = N - c * ( A + B ) ;
if r >=A :
	x += A ; 
else :
	x += r ; 
print ( x ) ;

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

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

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

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

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

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

print(ans)

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

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

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

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

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

print(ans)

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

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

rep = n//(a+b)



print(rep*a+min(n-rep*(a+b),a))

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

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

Solution (Python):

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


q=n//(a+b)
r=n%(a+b)
ans=0
if 0<=r<=a:
    print(q*a+r)
elif a<r:
    print(q*a+a)

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

ans = 0
tmp = A + B

syo = N // tmp
amari = N % tmp

ans += syo * A

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

Solution (Python):
n,a,b=[int(i) for i in input().split(" ")]

sum=(n//(a+b))*a
k=n%(a+b)
if k>a:
    k=a
sum+=k
print(sum)