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-----
8 3 4

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

Solutions:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    a_count=0
    d,r=divmod(n,a+b)
    a_count+=a*d
    if r > a:
        a_count+=a
    else:
        a_count+=r
    print(a_count)

def __starting_point():
    main()
__starting_point()

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

words_b = a
l_a_b = a + b

if a == 0 and b == 0:
    print('0')
    return

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

if m == 0:
    print(words_b * d)
    return

if m <= a:
    print(int(words_b) * d + m)
else:
    print(int(words_b) * d + a)

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

sum = 0
#print (N//(A+B))


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

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

def main():
    n,a,b = map(int, input().split())
    f = a * (n//(a+b))
    l = n%(a+b)
    rest  = 0
    if l < a:
        rest = l
    else:
        rest = a
    return f+rest
    
def __starting_point():
    print(main())
__starting_point()

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())
s=A+B
print(N//s*A+min(N%s,A))

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

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

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

if A == 0 and B == 0:
    print((0))
elif A == 0:
    print((0))
elif B == 0:
    print(N)
else:
    q, mod = divmod(N, A + B)
    print((min(mod, A) + q * A))


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

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

N,A,B=map(int,input().split())
s=(N%(A+B)>A)
t=not s
print(A*(N//(A+B))+s*A+t*N%(A+B))

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

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

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


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

ans = 0

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

if n % (a+b) >= a :
    print(b1 + a)
else :
    b2 = n % (a+b)
    print(b1 + b2)

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

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

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

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

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

div, mod = divmod(n, a + b)
ans = div * a + min(mod, a)
print(ans)

n = input()
n = n.split()
a = int(n[1])
b = int(n[2])
n = int(n[0])
if n%(a+b)<a:
    print(int(n/(a+b))*a+n%(a+b))
else:
    print(int(n/(a+b))*a+a)

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

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

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

import os, sys, re, math

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

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


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

if A==0:
  print(0)
  return

C=A+B
D=N//C
F=N%C

if F >= A:
  print((D+1)*A)
else:
  print(D*A + F)

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

c = a + b
div = n // c
mod = n % c

if mod > a:
    mod = a

ans = div * a + mod
print(ans)


n, a, b = map(int, input().split(' '))
q, r = divmod(n, a + b)

s = q * a

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

print(s)

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

m = n // (b+r)

last = min(n-(b+r)*m, b)

print((b*m + last))


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


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

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

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)
    
def __starting_point():
    main()
__starting_point()

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

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

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

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

if amari >= A:
    ans=sho*A+A
else:
    ans=sho*A+amari
    
print(ans)

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

N,A,B=map(int,input().split());d,m=divmod(N,A+B);print(d*A+min(m,A))

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

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

C = A + B

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

print(ans)

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

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


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


def main():
    N, A, B = tuple([int(_x) for _x in input().split()])
    turn = A + B
    iteration = (N // turn)
    rest = N - iteration * turn
    restb = min(A, rest)
    print((A*iteration+restb))


main()


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

n,a,b = list(map(int,input().split()))
cnt = n//(a+b)
rem = n-cnt*(a+b)
ans = cnt*a
if(rem > a):
    ans += a
else:
    ans += rem    
print(ans)


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

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

x=r+min(A,s)
print(x)

N,A,B=map(int,input().split())
s,d=divmod(N,A+B)
print(A*s+min(d,A))

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

p=n//(a+b)
q=n%(a+b)
if q<=a:
    amari=q
else:
    amari=a
    
if a==0:
    print(0)
elif q<=a:
    print(a*p+amari)
else:
    print(a*p+amari)

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

n,a,b=map(int,input().split())
ns=n % (a+b)
# print(ns)
if a==0:
    print(0)
else:
    print(1*min(ns,a)+a*(n//(a+b)))

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

a,b,c = list(map(int,(input().split())))
d = (a//(b+c))*b + min((a%(b+c)),b)
print(d)


# 入力を取得する
N,A,B = list(map(int, input().split()))

# A+B が Nの中に何セットあるかを取得
sets = N // (A+B)

# A * セット数を取得
a_count = A * sets

# NをA+Bで割った余りがAより小さければ余りを大きければAを足す
mod = N % (A+B)
a_count += mod if mod < A else A

print(a_count)

n, a, b = map(int, input().split())
 
if a == 0:
    print(0)
    return
 
syou = n // (a+b)
amari = n % (a+b)
 
if amari <= a:
    print(syou*a + amari)
else:
    print(syou*a + a)

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

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

if r >= a:
    res = a
else:
    res = r

print(q * a + res)

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

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


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

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

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

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

# -*- coding:utf-8 -*-
N,A,B = map(int,input().split())

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

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

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

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

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

M = N//(A+B)

L = N%(A+B)

if L > A:
    L = A
    
print((A*M + L))


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

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

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

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)

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

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

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

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

ans = 0
if A + B > 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A + min(A, taple[1])

print(ans)

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

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

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





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

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

# N,A,Bを受け取る
N,A,B = list(map(int,input().split()))

# NをA+Bで割った商をxとし、余をyとする
x = N // (A+B)
y = N % (A+B)

# yがAより大きいかどうかで場合わけをする
print(( A*x+A if y >= A else A*x+y ))


N, A, B = list(map(int, input().split()))
C = int(N/(A+B))
D = N%(A+B)
ans = 0
if 0 <= D <= A:
    ans = A*C + D
else:
    ans = A*C + A

print(ans)


n,a,b = map(int,input().split())
x,y = divmod(n,a+b)
if y > a: y = a
print((x*a)+y)

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

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

# n / (blue + red) = quot ...rem
quot = n // (blue + red) #商 quotient
rem = n % (blue + red) #余り remainder

ans = blue * quot + min(blue,rem)

print(ans)

N, A, B = map(int, input().split())
times, residue = divmod(N, A+B)
blue = times*A + min(residue, A)
print(blue)

def answer(n: int, a: int, b: int) -> int:
    q, mod = divmod(n, a + b)
    return q * a + min(a, mod)


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


def __starting_point():
    main()

__starting_point()

n,a,b = map(int, input().split())
ans = 0
x = n // (a+b)
y = n % (a+b)
if y < a:
  print(x*a + y)
else:
  print(x*a + a)

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

import math
def i_input(): return int(input())


def i_map(): return map(int, input().split())


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


def i_row(N): return [int(input()) for _ in range(N)]


def i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]

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

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

ans = 0
if A + B > 0:
    ans = N // (A + B) * A + min(A, N % (A + B))

print(ans)

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

if a + b == 0:
	print(0)
	return

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

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

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

n, a, b = list(map(int, input().split()))
line = n // (a + b)
remain = n % (a + b)

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

print(ans)


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

n1 = N // (A + B)
n2 = N % (A + B)

if n2 > A:
    print(A*(n1+1))
else:
    print(A*n1 + n2)

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

n,a,b = map(int,input().split())
i = a+b
div = n // i
rm = n%i

print(div*a+min(rm,a))

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

# coding=utf-8

def __starting_point():
    N, A, B = map(int, input().split())
    S = (A+B)*1000

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

            ans += A

    elif N < A+B:
        if A > N:
            ans = N
        else:
            ans = A

    else:
        ans = A

    print(ans)
__starting_point()

n,b,c=map(int,input().split());x=b+c;print(n//x*b+min(b,n%x))

# 27
N, A, B = map(int, input().split(' '))
 
ans = 0
if (A + B) != 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A
    if B == 0: ans = N
    elif taple[1] > A: ans += A
    else: ans += taple[1]
 
print(ans)

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

if r <= a:
    print(s*a + r)
elif r > a:
    print(s*a + a)

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

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

print(ans)


# coding: utf-8

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

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

    print(ans)

def __starting_point():
    main()

__starting_point()