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
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	N,A,B = inputMap()

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

	print(ans)








def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy


from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n,a,b = inpm()
    if n%(a+b) == 0:
        print((n//(a+b))*a)
        return
    print( (n//(a+b)) * a + min(a,n%(a+b)) )
    
if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N,A,B = LI()

num = N//(A+B)
print(num*A + min(N-(num*(A+B)),A))

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

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

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

tasu = min(N % (A+B), A)
ans += tasu
print(ans)

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

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

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

print(x * A + min(y, A))

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

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

if c > a:
    c=a

print(d*a+c)

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

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

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

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

x1=(n//ab)*a
x2=min(n%ab,a)
print(x1+x2)

Solution (Python):
import sys

n, a, b = [int(s) for s in sys.stdin.readline().strip().split(' ')]
ab = a + b
dividend = n // ab

ans = dividend * a + min(n % ab, a)
print(ans)

Solution (Python):
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n,a,b = miinps()

k = a+b
ans = 0

p = n//k
q = n%k
ans +=  p*a

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

print(ans)

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

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

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

Solution (Python):



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

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

    print((p * a) + min(a, q))


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

ans = A * d + min(m, A)

print(ans)

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

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

if N%(A+B)!=0:
    a=N%(A+B)
    if a<A:
        ans+=a
    else:
        ans+=A
print(ans)

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

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

AB = A + B
ans = 0

ans += (N // AB) * A

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

print(ans)

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

Solution (Python):
n, a, b = map(int, raw_input().strip().split())
q = n / (a + b)
r = n % (a + b)

ans = a * q + min(a, r)
print ans

Solution (Python):




def solve(inp):
    (N, A, B) = map(int, inp.readline().strip().split(' '))

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

    return str(a)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()

Solution (Python):

import sys


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

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

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

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

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

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


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

print(p*a + min(q, a))

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

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)

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

x = n // (a+b)
d = n - x * (a+b)
a_left = min(a, d)
print(x * a + a_left)

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

k = n // (a + b)

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

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

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

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

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

cnt = N // (A + B)
res = cnt * A
N -= cnt * (A + B)

if N > A:
    res += A
else:
    res += N

print(res)

Solution (Python):
import copy

import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n,a,b = ips()

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

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

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

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

if n%(a+b)!=0:
  q=n%(a+b)
  ans+=min(a,q)

print(ans)

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    if A == 0:
        print(0)
        return
    All = A+B

    answer = (N//All)*A
    amari = N%All
    
    if amari > A:
        answer += A
    else:
        answer += amari
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

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

ans = A * mul + min(A, m)

print(ans)

Solution (Python):
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





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

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

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

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

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

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

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

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

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

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


if __name__ == "__main__":
    main()

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

cnt = 0

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

print(cnt)

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

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

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

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


main()

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

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

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

Solution (Python):
n,a,b = [int(i) for i in input().split()]
if a > 0:
    d = n//(a+b)
    r = n-d*(a+b)
    print(d*a+min(r,a))
else:
    print(0)

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

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

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

print(loop * A + min(A, rest))

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

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

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

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

print(s*A + min(d,A))

Solution (Python):
from collections import Counter,defaultdict,deque
from bisect import bisect_left
import sys,math,itertools,pprint,fractions,time
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
res = n//(a+b) * a
rrr = n%(a+b) 
print(res+min(rrr, a))

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

if __name__ == "__main__":
    main()

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

cnt, amari = divmod(N, (A + B))
print(cnt * A + min(amari,A))

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

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

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

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

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

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

div = n//(a+b)
rem = n%(a+b)

ans=div*a+min(rem,a)

print(ans)

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

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

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

c = N // (A + B)

print(c * A + min(A, N - c * (A + B)))

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

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

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

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

nokori = n - (n // len_) * len_
ans += min(nokori, a)
print(ans)

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

i, j = divmod(N, A+B)
print(A * i + min(A, j))

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+1))

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

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

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

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

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

Solution (Python):
import sys
import math
import bisect

def solve(n, a, b):
    ans = 0
    ans += n // (a + b) * a
    m = n % (a + b)
    if m <= a:
        ans += m
    else:
        ans += a
    return ans

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

if __name__ == "__main__":
    main()

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B = lr()
time, remain = divmod(N, (A+B))
answer = A * time + min(A, remain)
print(answer)

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

print(ans)

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

kaisu=n//(a+b)
remain=n-kaisu*(a+b)
print(kaisu*a + min(a,remain))

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

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n,a,b = m()

po = n // (a+b)

poo = n % (a+b)

if poo <= a:
    print(a*po + poo)
else:
    print(a*po + 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())

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

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

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

Solution (Python):
def main():

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

    m = N // (A+B)
    k = N % (A+B)
    return m * A + min(A, k)

if __name__ == '__main__':
    print(main())

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

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

Solution (Python):
import sys

if __name__ == "__main__":
    N,A,B = map(int, input().split())
    ans = 0
    shou = N // (A+B)
    ans += A * shou
    amari = N % (A+B)
    ans += min(amari, A)
    print(ans)

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

Solution (Python):
import sys
n, a, b = [int(i) for i in sys.stdin.readline().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 = n%(a+b)
if n >= a:
  ans += a
else:
  ans += n
print(ans)

Solution (Python):
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
c=a+b
x=n//c
y=n-x*c
ans=a*x
ans+=min(a,y)
print(ans)

Solution (Python):
def examA():
    S = SI()
    if S=="AAA" or S=="BBB":
        print("No")
    else:
        print("Yes")
    return

def examB():
    N, A, B = LI()
    loop = N//(A+B)
    ans = loop*A + min(A,N%(A+B))
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    C = N //(A+B)
    MOD_REMAIN = N % (A+B)
    print(C*A + min(MOD_REMAIN,A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

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

Solution (Python):
import os
import sys

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N, A, B = list(map(int, sys.stdin.buffer.readline().split()))

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

Solution (Python):

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

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

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

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = map(int, input().split())
if A == 0 and (B == 0):
  print(0)
  exit(0)
print((N // (A + B)) * A + min(A, N % (A + B)))

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

    ret = 0
    rep, rest = divmod(N, A + B)
    ret += rep * A
    ret += min(A, rest)

    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,A,B=map(int,input().split())
    ans=0
    z=N//(A+B)
    ans+=z*A
    ans+=min(A,N-z*(A+B))
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

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

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

q, r = divmod(n, a + b)
ans = q * a + min(r, a)
print(ans)

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

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline

n, a, b = [int(item) for item in input().split()]
loop = n // (a + b)
ans = loop * a + min(a, n%(a+b))
print(ans)

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

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

Solution (Python):
rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

def solve(N, A, B):
    P = A + B
    if A == 0: return 0
    Q, R = divmod(N, P)
    ans = Q * A
    if R >= A:
        ans += A
    else:
        ans += R
    return ans

print solve(*rrm())

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

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

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

div, mod = divmod(N, A + B)
ans = A * div
ans += min(mod, A)

print(ans)

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

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

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

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

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

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 = [int(i) for i in input().split()]
ans = n // (a + b) * a
ans += min(n % (a + b), a)
print(ans)

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

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

print(k * a + min(a, m))

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

Solution (Python):









import sys



ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n, a, b = list(map(int,ipti().split()))
    ab = a + b

    c = n // ab
    d = n % ab

    ans = c * a + min(a, d)
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
n,a,b = map(int, input().split())
c = a+b
cnt = n//c
res = n - cnt*c

ans = a*cnt + min(res, a)
print(ans)

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

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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    ans = N//(A+B)*A
    remain = N - (N//(A+B)*(A+B))
    ans += min(remain,A)
    print(ans)
if __name__ == '__main__':
    main()

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

full_loop = a+b

loop = n//full_loop

rest = n-(a+b)*loop

print(loop*a+min(rest,a))

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

Solution (Python):
N, A, B = [int(i) for i in input().split()]
S = A+B
c = (N//S)*A

c += min(N%S,A)
print(c)

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)
k = N%(A+B)

if k<=A:
    pass
else:
    k = A

print(A*t + k)

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

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

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

if d > a:
    print(c*a+a)
else:
    print(c*a+d)

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

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

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

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n, a, b = na()
m = n//(a+b)
r = n%(a+b)
print(a*m+min(r, a))

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