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

if A==B==0:
    print(0)
else:
    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 = 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())
ab = a + b
syou = n // ab
amari = n % ab
print(syou * a + min(amari, a))

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

blue_ball = 0
if n / (a + b) > 1:
    answer = divmod(n, a + b)
    blue_ball = answer[0] * a
    n = answer[1]

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

print(blue_ball)

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

blue = 0
if n / (a + b) > 1:
    loop, remain = divmod(n, a + b)
    blue = loop * a
    n = remain

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

print(blue)

Solution (Python):
n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)

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

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

print(c + d)

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

Solution (Python):
N,A,B=[int(s) for s in input().split()]
C=A+B
Q=N//C
R=N%C
if R<=A:
  print(Q*A+R)
else:
  print((Q+1)*A)

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

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

num = N // (A + B)
res = N % (A + B)

if res > A:
    res = A

ans = num * A + res

print(ans)

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

AB = A + B

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

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

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

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

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

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

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

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

repeat = n // (a + b)
blue = repeat * a + min(n % (a+b) , a)

print(blue)

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

d = n-c*(a+b)
if d >= a:
    ans = ans + a
else:
    ans = ans + d

print(ans)

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

sum = 0

a = N // (A+B)
b = N % (A+B)
if b > A:
  b = A
else:
  b = b

print(a * A + b)

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

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

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

x = divmod(n, a+b)

if x[1] <= a:
    print(x[0]*a + x[1])
else:
    print(x[0]*a + 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):
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  
    
    cnt = N//(A+B)*A + (A if N%(A+B)>A else N%(A+B))
    
    print(cnt)

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

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

c = a + b

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

print(x)

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

s = 0
s = int(N / (A+B))*A
if N % (A+B) > A:
    s += A
else:
    s += N % (A+B)
print(s)

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

s=N//(A+B)
NA=N%(A+B)
if(A!=0):
  if(NA<A):
    sA=0
    sAG=NA
  else:
    sA=1
    sAG=0
else:
  sA=0
  sAG=0
print(s*A+sA*A+sAG)

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

Solution (Python):
def main():
    N, A, B = map(int, input().split())
    a, b = divmod(N, (A+B))
    blue = a*A
    if b < A:
        blue += b
    else:
        blue += A
    print(blue)
main()

Solution (Python):
N, A, B = map(int, input().split())
al = A+B
ama = N%(A+B)
k = N//(A+B)*A
if ama > A:
    print(k+A)
elif ama < A:
    print(k+ama)
elif A == 0:
    print(0)

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

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

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

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 = list(map(int, input().split(' ')))
l = N // (A+B)
r = A if (N - l*(A+B)) >= A else (N - l*(A+B))
ret = l*A + r
print(ret)

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

combo = A + B
num_of_combo = N // combo
remaining = N - combo * num_of_combo

print(num_of_combo * A + min(remaining, A))

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

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

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

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

ans=s*a
if we>=a:
  ans+=a
else:
  ans+=we
print(ans)

Solution (Python):

url = "https://atcoder.jp//contests/abc158/tasks/abc158_b"

def main():
    a, blue, red = list(map(int, input().split()))
    count, ab_count = divmod(a, blue + red)
    if ab_count > blue:
        ab_count = blue
    print(ab_count + count * blue)

if __name__ == '__main__':
    main()

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

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

if a == 0:
  ans = 0

print(ans)

Solution (Python):


import sys



















def main():
    mod = 1000000007                  
    inf = float('inf')
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, a, b = mi()
    q = n // (a + b)
    res = n % (a + b)
    print(q * a + min(res, a))

if __name__ == "__main__":
    main()

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

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

temp = N % (A+B)

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

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

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

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

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

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

Solution (Python):

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

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

Solution (Python):
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)


args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])



def main():
    N, A, B = input([int, 3])
    ans = 0
    ans += N // (A + B) * A
    temp = N % (A + B)
    ans += A if A <= temp else temp
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()

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



def main():
    NAB = list(map(int,input().split()))




    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    


    b = 0
    
    
    
    

    if NAB[0] < NAB[1]+NAB[2]:
        if NAB[0] < NAB[1]:
            b = NAB[0]
        else:
            b = NAB[1]

    else:
        tm = NAB[0]//(NAB[1]+NAB[2])
        amari = NAB[0] % (NAB[1]+NAB[2])

        
        if NAB[1] < amari:
            b = (tm*NAB[1])+ NAB[1]
        else:
            b = (tm*NAB[1])+ amari

    print(b)





if __name__ == '__main__':
    main()

Solution (Python):



def main():
    NAB = list(map(int,input().split()))

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    



    
    
    
    
    

    b = 0

    tm = NAB[0]//(NAB[1]+NAB[2])
    amari = NAB[0] % (NAB[1]+NAB[2])

    
    if NAB[1] < amari:
        b = (tm*NAB[1])+ NAB[1]
    else:
        b = (tm*NAB[1])+ amari

    print(b)


    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    



            
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




if __name__ == '__main__':
    main()

Solution (Python):



def main():
    NAB = list(map(int,input().split()))

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    b = 0

    tm = NAB[0] // (NAB[1] + NAB[2]) * NAB[1]
    amari = NAB[0] % (NAB[1] + NAB[2])
    tm += min(amari,NAB[1])

    print(tm)

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    



            
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




if __name__ == '__main__':
    main()

Solution (Python):



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

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    b = 0

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

    print(tm)

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    



            
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




if __name__ == '__main__':
    main()

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):
def Main(N, A, B):
    di, mo = divmod(N, A+B)
    return di*A + min(mo, A)

def main():
    N, A, B = map(int, input().split())
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

Solution (Python):
from decimal import Decimal
n, a, b = map(Decimal, input().split())
nr = n // (a+b)
nd = n%(a+b)
print(a*nr + min(a,nd))

Solution (Python):
N, A, B = (int(x) for x in input().split())
result = 0
if N <= A:
  result = N
elif N > A and N <= A+B:
  result = A
else:
  Q = N//(A+B)
  R = N%(A+B)
  P = N - Q*(A+B)
  if R<= A:
    result = Q*A + R
  else:
    result = Q*A + A
print(result)

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

Solution (Python):
from sys import stdin
N,A,B = list(map(int,stdin.readline().strip().split()))
C=A+B
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())
ans = (n//(a+b)) * a + min(n%(a+b), a)
print(ans)

Solution (Python):
N,A,B = list(map(int, input().split()))
Amari = N % (A+B)
Show = N // (A+B)

if Amari > A:
    Amari = A
ans = Amari + Show * A
if A == 0:
    ans = 0
print(ans)

Solution (Python):

import sys
input = sys.stdin.buffer.readline


from collections import defaultdict

con = 10 ** 9 + 7

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


def main():
	N, A, B = getlist()
	ans = int(N // (A + B)) * A + min(N % (A + B), A)
	print(ans)


if __name__ == '__main__':
	main()

Solution (Python):
n, a, b = map(int, input().split())
ans = n // (a+b)
ans *= a
if n % (a+b) != 0:
    ans += min(a, n % (a+b))
print(ans)
'''
i = 0
r = []
for _ in range(10*100):
    for _ in range(a):
        r.append('b')
    for _ in range(b):
        r.append('r')
    
print("".join(r[0:n]))
'''

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

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


tmp = int(n /(a+b))
amari = int(n %(a+b))

if amari >= a:
    print(tmp*a + a)
else:
    print(tmp*a + amari)

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

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

if r>=a:
  ans = h*a + a
else:
  ans = h*a +r
print(ans)

Solution (Python):
import math

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

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

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

if n<A:
	ans=A*m+n
else:
	ans=A*(m+1)
	
print(ans)

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

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

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

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

a = (A + B)
b = N // a

x = A * b
print(x + 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())

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

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

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

AplusB = A+B

action_num = N // AplusB
ans += action_num * A

action_mod = N % AplusB

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

print(ans)

Solution (Python):
s = input().split()
N = int(s[0])
A = int(s[1])
B = int(s[2])

if A == 0:
    print(0)
elif B == 0:
    print(N)
else:
    
    set_count = N // (A+B)
    
    mod = N % (A+B)
    
    if mod == 0:
        print(A*set_count)
    else:
        if mod < A:
            print(A*set_count+mod)
        else:
            print(A*set_count+A)

Solution (Python):


def main():
    N, A, B = map(int, open(0).read().split())

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


main()

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

Solution (Python):
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))

  print(int(num_a * a + min(a, num_b)))
  
if __name__ == '__main__':
  main()

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

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):
N, A, B = input().split();
N = int(N);
blue = int(A);
red = int(B);

sho = N // (blue + red);
amari = N % (blue + red);

last = min([amari, blue]);

ans = sho * blue + last;

print(ans)

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

Solution (Python):
def main():
    args = input().rstrip().split(' ')
    N, A, B = int(args[0]), int(args[1]), int(args[2])
    unit = int(N/(A+B))
    rem = N % (A+B)
    if(rem > A):
        brem = A
    else:
        brem = rem
    print(A*unit + brem)
    
if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Solution (Python):


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

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

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

print(c)

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

times=n//(a+b)

k=n%(a+b)

total= a if k>a else k
print(times*a+total)

Solution (Python):
N,b,r=map(int,input().split())
ball,x,y=0,0,0
ans=0

ball=b+r
x=N%ball
y=N//ball

ans+=y*b

if x>b:
    ans+=b
else:
    ans+=x


print(ans)

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

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

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())
ans=N//(A+B)*A
sur=0
if N%(A+B)>A:
  sur=A
else:
  sur=N%(A+B)
print(ans+sur)

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

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

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

print(ans)

Solution (Python):
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)
elif blue_count + red_count > n:
  print(blue_count)
else:
  set_count = blue_count + red_count

  margin = 0
  if n % set_count == 0:
    c =  n // set_count
  else:
    c =  n // set_count
    margin = n % set_count

  
  if margin > blue_count:
    margin = blue_count
    
  print(blue_count * c + margin )

Solution (Python):

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

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

nb = A + B
nt = int(N/nb)
nr = A if N % nb >= A else N % nb

print(nt*A + nr)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

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

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

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

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

print(total)

Solution (Python):
N, A, B = map(int, input().split())
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().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 = a + b
d = n // c
e = n % c
ans = a * d + min(e, a)
print(ans)

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

b = a[1] + a[2]
c = a[0] // b * a[1]
d = a[0] % b

if not d == 0:
    if d < a[1]:
        c += d
    else:
        c += a[1]

print(c)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  n, a, b = map(int, readline().split())
  ans = n//(a+b) * a + min((n%(a+b)),a)
  print(ans)
  
  
if __name__ == '__main__':
  main()

Solution (Python):
n,b,r=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)

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

Solution (Python):
from sys import stdin

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

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

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

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):
N, A, B = tuple(int(n) for n in input().split())

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

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

'''
ext = []
cnt = 0
while cnt <= n:
    for _ in range(a):
        ext.append('b')
    cnt += a
    for _ in range(b):
        ext.append('r')
    cnt += b
print("".join(ext[0:n]))
'''

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

Solution (Python):
N, A, B=map(int, input().split())
k=N//(A+B)
if N%(A+B)==0:
    print(k*A)
elif k*(A+B)+A<=N:
    print(k*A +A)
elif k*(A+B)+A>=N:
    print(k*A +N-k*(A+B))

Solution (Python):
N,A,B = map(int, input().split())
  
if N % (A + B) == 0:
  print(N // (A + B) * A)
elif N % (A + B) - A < 0:
  print(N // (A + B) * A + abs(N % (A + B)))
elif N % (A + B) - A > 0:
  print(N // (A + B) * A + A)

Solution (Python):
inp = input().split()
inp = list(map(int, inp))
n, a, b = inp[0], inp[1], inp[2]
div, mod = divmod(n, a+b)
if mod < a: print(div*a + mod)
else: print((div+1)*a)

Solution (Python):
x = input()
n = int(x.split()[0])
b = int(x.split()[1])
r = int(x.split()[2])

shou = n // (b + r)
amari = n % (b + r)

if amari - b == 0:
    sum = shou * b
elif amari - b < 0:
    sum = (shou * b) + amari
elif amari - b > 0:
    sum = (shou * b) + b
   
print(sum)

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

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())
amari = n % (a + b)
blue = 0
if amari > a:
    blue = a*(n // (a + b)) + a
else:
    blue = a*(n // (a + b)) + amari
print(blue)

Solution (Python):
def ma(): return map(int,input().split()) 



n,a,b=ma()
c_num=n//(a+b)   
c_sum=c_num*(a+b)
c_rest=min(n-c_sum, a)

c_want=a*c_num + c_rest
print(c_want)

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

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

print(ans)

Solution (Python):
import numpy as np
import sys
readline = sys.stdin.buffer.readline

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

Solution (Python):
N, A, B = map(int, input().split())
set_bule = N//(A+B) * A
other = N - N//(A+B) * (A+B)
hashi_bule=0
if 0 <= other <= A:
    hashi_bule = other
else :
    hashi_bule = A
print(set_bule + hashi_bule)

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

a = N // (A+B)

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

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):
import sys
input = sys.stdin.readline

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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

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

print(ans)

Solution (Python):
n , a, b = map(int, input().split())
syou = n // (a + b)
amari = n % (a + b)

if amari > a:
    print(syou * a + a)
else:
    print(syou * a + amari)

Solution (Python):

"""
Created on Sun Apr 12 20:10:24 2020

@author: Kanaru Sato
"""

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

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

if n%(a+b)>a:
    print(main+a)
else:
    print(main+n%(a+b))

Solution (Python):
from sys import stdin

N, A, B = [int(x) for x in stdin.readline().rstrip().split()]

div = int(N / (A + B))
mod = N % (A + B)

if A >= mod:
    add_mod = mod
else:
    add_mod = A

print(div * A + add_mod)

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

t=n//(a+b)

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

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""


"""import bisect 
print(A,bisect.bisect_left(A,4))
print(C,n - bisect.bisect_right(C,4))
print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))"""


"""import math
pi_ = math.pi"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7

def main():
  n,a,b = readInts()
  sum_ = a + b
  if n // sum_  == 0:
    if n >= a:
      print(a)
    else:
      print(n)
  else:
    quo = n // sum_ 
    if n % sum_ != 0:
      sur = n % sum_
      if sur >= a:
        print(quo * a + a)
      else:
        print(quo * a + sur)
    else:
      print(quo * a)
  
if __name__ == '__main__':
  main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
C = N // (A+B)

if N <= A+B:
  print(min(A, N))
elif N % (A+B) < A:
  print(A*C + N%(A+B))
else:
  print(A*(C+1))

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

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