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


from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key



__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x



if __name__ == '__main__':
    N, A, B = mulinputs()

    ans = N//(A+B)
    mod = N - (A+B)*ans
    ans *= A
    if mod != 0:
        if mod > A:
            ans += A
        else:
            ans += mod
    
    print(ans)

Solution (Python):

 
import math
import itertools
import sys
import copy

 






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

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

ans = A * p + min(mod, A)
print (ans)

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

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

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

answer = d * A
if m <= A:
    answer += m
else:
    answer += A

print(answer)

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

sousa = n//(a+b)
nokori = n - sousa*(a+b)
if nokori > a:
    ao = a
else:
    ao = nokori

print(sousa*a+ao)

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

if a == 0 or b == 0:
    print(n if b == 0 else 0)
else:
    num_of_sets, rem = divmod(n, a + b)
    a_num = num_of_sets * a
    b_num = num_of_sets * b
    a_add = min(rem, a)
    rem -= a_add
    a_num += a_add
    print(a_num)

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




pea = (n//(a+b))
cnt = a*pea
cnt += min(a, n-(a+b)*pea)

print(cnt)

Solution (Python):
n,a,b=(int(x) for x in input().split())
su = a+b
co = 0
di = n//su
co = di*a
nokori = n-di*su
if nokori>=a:
	print(co+a)
else:
	print(co+nokori)

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

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

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


append_per_turn = A + B

d = N // append_per_turn
m = N % append_per_turn

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

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

s = N // (A + B)

a = min(N - s*(A+B), A)

print(s*A + 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())
roop = n // (a + b)
count = roop * a
if n - roop * (a + b) >= a:
    count += a
else:
    count += n - roop * (a + b)
print(count)

Solution (Python):




import sys
input = sys.stdin.readline



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

    tot = A + B
    set = N // tot
    res = N % tot

    ans = set * A

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

    print(ans)



main()

Solution (Python):



from math import *
from copy import *
from string import *				
from random import *				
from sys import stdin
from sys import maxsize
from operator import *				
from itertools import *
from collections import Counter		
from collections import defaultdict 

'''

'''

def solve(l):
	n = len(l)
	

N,blue,red = list(map(int, stdin.readline().rstrip().split()))
total = blue + red
x = N // total
ans = blue*x
ans += min(N%total,blue)
print(ans)

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

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

if B == 0:
    print(N)
else:
    s = A + B
    a = N // s
    r = N % s

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

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

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

Solution (Python):

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



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

temp=min(mod,a)
ans+=temp
print(ans)

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

Solution (Python):
import math

[n, a, b] = [int(i) for i in input().split()]
times = math.floor(n / (a + b))
rem = n % (a + b)
if rem <= a:
    output = times * a + rem
else:
    output = times * a + a
print(output)

Solution (Python):


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

k = n // (a + b)
if (n - k * (a + b)) > a:
    ans = a * (k + 1)
else:
    ans = a * k + (n - k * (a + b))

print(ans)

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

one_count = A + B
ans = divmod(N, one_count)
if ans[1] < A:
    print(ans[0]*A + ans[1])
else:
    print(ans[0]*A+A)

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

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

boxes = int(N/(A+B))
hasuu = N % (A+B)

blue = boxes*A
if hasuu >= A:
  blue += A
else:
  blue += hasuu

print(blue)

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

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

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

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


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


blue = n1 * A
if n2 <= A:
    blue += n2
else:
    blue += A
    
print(blue)

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

Solution (Python):

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

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



if r == 0:
    print(a*q)
elif r > a:
    print(a*q + a)
else:
    print(a*q + r)

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

res=N-(A+B)*cnt

if res>=A:
    print(cnt*A+A)
else:
    print(cnt*A+res)

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

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

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

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

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

print(num1 + num2)

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

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

group = n // (a + b)
hasuu = n %  (a + b)
total = group * a
if hasuu < a:
  total += hasuu
else:
  total += a
print(total)

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

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

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

div = n//(b+r)
res = n%(b+r)
resblue = min(res, b)
print(div*b + resblue)

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

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

if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
n,a,b = map(lambda x: int(x),input().split())

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

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())
ans = 0

repeat = N // (A + B)
residue = N % (A + B)

ans += A * repeat

if residue < A:
    ans += residue
else:
    ans += 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())

ans = 0
ans += (N // (a+b)) * a

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

print(ans)

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

print(ans)

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

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


if(n2 >= A):
    ans = n1 *A + A
else:
    ans = n1*A + n2

print(ans)

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

print(d + a if n > a else d + n)

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

if A==0:
    print(count)
else:
    div=int(N/(A+B))
    rem=N%(A+B)
    if rem<=A:
        print(div*A+rem)
    else:
        print((div+1)*A)

Solution (Python):
import sys
import math
sys.setrecursionlimit(int(1e6))

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

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

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

tmp=n//(a+b)

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

print(ans)

Solution (Python):
def bmon(n , a , b):

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

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

    return ans

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

if __name__ == '__main__':
    main()

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

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

cluster = NAB[1] + NAB[2]
q, mod = divmod(NAB[0], cluster)

q *= NAB[1]
q += NAB[1] if (NAB[1] < mod) else mod

print(q)

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

ab = a + b
div = n // ab
rem = n % ab


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


print(ans)

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())
trial = a+b
num = int(n/trial)
rest = min(a,n%trial)

print(a*num+rest)

Solution (Python):


def solve(N, A, B):
    loop = N // (A + B)
    delta = N % (A + B)
    return A * loop + min(delta, A)


def main():
    N, A, B = [int(n) for n in input().split()]
    print(solve(N, A, B))


if __name__ == '__main__':
    main()

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

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

tmp = n // (a + b)
amari = n % (a + b)
ans = a * tmp


if amari >= a:
    ans += a
elif amari < a:
    ans += amari

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


cnt = N // (A+B)
print(cnt * A + min(A, (N - cnt * (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())
num = N//(A+B)
rest = N%(A+B)
rest_a = rest-A
if rest_a > 0:
  print(num*A + A)
else:
  print(num*A + rest)

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    print(A*(N//(A+B))+min(N%(A+B), 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())
ans = (n//(a+b))*a
ans += min(n%(a+b),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())
c = n%(a+b)
if c > a:
    print(n//(a+b)*a+a)
else:
    print(n//(a+b)*a+c)

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

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

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

if A == 0:
    print(0)
else:
    count = N // (A+B)
    result = count*A
    if (N-(count*(A+B))) >= A:
        result += A
    else:
        result += (N-(count*(A+B)))

    print(result)

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

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

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

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

Solution (Python):


def resolve():
    N,A,B=map(int,input().split())
    if A==0:
        print(0)
        return
    if B==0:
        print(N)
        return

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

    print(A*D+min(A,S))



if __name__ == "__main__":
    resolve()

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

lot = a + b
div = n // lot
res = n % lot
ans = div * a + (a if res >= a else res)
print(ans)

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

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

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

if A == 0:
    print(0)
else:
    ans = N // (A + B)

    temp = N % (A + B)

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

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

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

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

ans += a if n >= a else n

print(ans)

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

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

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

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

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

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

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

print(int(ans))

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

if n%(b+k) < b:
    print(int(n//(b+k)*b + n%(b+k)))
else:
    print(int(n//(b+k)*b + b))

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

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]

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


if __name__ == "__main__":
    main()

Solution (Python):
n,a,b=map(int,input().split())
k=n//(a+b)
ans=a*k
ans+=max(0,min(a,n-(k*(a+b))))
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())

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

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

ab = a+b
c = n//ab
d = n%ab

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

print(ans)

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

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

if rem - a <= 0:
    print(a * num + rem)
else:
    print(a * num + a)

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

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)
if A>=r:
    print(A*q+r)
else:
    print(A*(q+1))

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

times = n//(a+b)
rest = n - (a+b)*times
print(a*times+min(a,rest))

Solution (Python):
N,A,B = map(int,input().split())
AB = A + B
kai = N // AB
amari = N % AB

if amari > A:
    nokori = A
else:
    nokori = amari
print(kai*A + nokori)

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

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

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



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

if amari < A:
    print(sho * A + amari)
else:
    print(sho * A + A)

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

Solution (Python):


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

    comp = n // (a + b)
    uncomp = n - comp * (a + b)

    ans = comp * a + min(a, uncomp)
    
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):

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


t = N%(A+B)
if t > A:
    t = A


print(N//(A+B)*A + t)

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(" ")]
ball=(N//(A+B))*A
if N%(A+B)>A:
    ball+=A
else:
    ball+=N%(A+B)

print(ball)

Solution (Python):
i = list(map(int, input().split()))
N = i[0]
A = i[1]
B = i[2]
Q = A + B
ans = (N // Q) * A + min(N % Q, A) 

print(ans)

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

set_count  = int(N/(A+B))
if  N % (A+B) != 0:
    ans = set_count * A
    last_ball = N - (A+B)*set_count
    if last_ball <= A:
        ans += last_ball
    else:
        ans += A
else:
    ans = set_count * A
print(ans)

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

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

amari = min(n,10**100)%(a+b)
wari = min(n,10**100)//(a+b)

print(wari*a + min(a, amari))

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

    tmp = a+b
    ans = 0
    if n>=tmp:
        d = n // tmp
        m = n % tmp
        ans += d * a
        ans += min(a,m)
    else:
        ans += min(a,n)

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

Solution (Python):
from sys import stdin
n,a,b = [int(x) for x in stdin.readline().rstrip().split()]
s = a + b
k = n // s
m = n % s
m = min(a,m)
print(k*a + m)

Solution (Python):
N, A, B = map(int, input().split())
if (A == 0):
    print(0)
    exit(0)
if (B == 0):
    print(N)
    exit(0)
l = A + B
C = N // l
print(A * C + min(A, (N - (l * C))))

Solution (Python):
import sys


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


def main():
    N, A, B = map(int, input().split())
    r = N // (A + B)
    l = N - r * (A + B)
    cnt = r * A
    if l < A:
        cnt += l
    else:
        cnt += A
    print(cnt)


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

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

cnt = 0
cnt += syou * A

if (mod <= A):
    cnt += mod
else:
    cnt += A

print(cnt)

Solution (Python):
def main():
    N, A, B= [int(x) for x in input().split()]
    if A == 0:
        print(0)
        return

    count = N // (A + B)
    left = N % (A + B)
    blue = count * A
    blue += A if left >= A else left
    print(blue)

if __name__ == "__main__":
    main()

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    p = N// (A + B)
    ans = p * A
    mod = N % ( A + B )
    if mod >= A:
        ans += A
    else:
        ans += mod

    print(ans)

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

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

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

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

Solution (Python):
x,y,z= map(int,input().split())
M=y+z
k=x//M
j=x-M*k
if j>y:
    print((k+1)*y)
else:
    print(k*y+j)

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

Solution (Python):
N,A,B=map(int,input().split())
blue=0
ans=[]
kouho=N//(A+B)
blue=A*kouho
if A-(N-(A+B)*kouho)>=0:
    blue+=N-(A+B)*kouho
else:
    blue+=A
print(blue)

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

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

ans = 0
if a == 0 and b == 0:
    print(ans)
    sys.exit(0)

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

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

print(ans)

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

total = A + B

blue = 0
blue += (N // total) * A
remain = min(N % total,A)
blue += remain

print(blue)

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60


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

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

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

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

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

print(ans)

Solution (Python):


import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

N, A, B = MI()

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

    print(ans)

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

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

print(ans)

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

A_B = A + B
one_loop = min(N//A_B, 10**100)
ext = min(A, N%A_B)
SUM = one_loop*A + ext
print(SUM)

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

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

ans = kaisu * A

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
else:
    a, b = divmod(N, A+B)
    print(a*A + min(b, A))

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

S = A+B

P = N//S

Ans = P*A + min((N-S*P),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] = [int(s) for s in input().rstrip().split(' ')]
m = N //(A+B) 
k = N - m*(A+B) 
if k <= A:
  print(m*A + k)
else:
  print((m+1)*A)

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

Solution (Python):
N,A,B = 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())

div = n // (a+b) * a
mod = n % (a + b)

if mod < a:
  s = div + mod
else:
  s = div + a

print(s)

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

Solution (Python):
d = input().split(" ")
n = int(d[0])
a = int(d[1])
b = int(d[2])
s = a + b
c = (n // s) * a
if n % s > a:
	c += a
else:
	c += n % s
print(c)

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

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

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

if amari > a:
    print((temp + 1) * a)
else:
    print(temp * a + amari)

Solution (Python):
from sys import stdin


def main():
    N, A, B = [int(x) for x in stdin.readline().rstrip().split()]
    x = N // (A + B)
    y = N % (A + B)
    print(A * x + min(y, A))


if __name__ == "__main__":
    main()

Solution (Python):
a, b, c = list(map(int, input().split()))
count = int(a / (b + c))
result = count * b
reg = int(a % (b + c))
if reg >= b:
    result += b
else:
    result += reg
print(result)

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

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

ans = a*x

if y >= a:
	print(ans+a)
else:
	print(ans+y)

Solution (Python):
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+1)*a)

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

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

ans = 0
ans += x*A
ans += max(0, min(N-y, A))
print(ans)

Solution (Python):
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''

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

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

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

Solution (Python):

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

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

answer = int((N / (A + B))) * A
amari = N % (A + B) 

if amari > A:
    answer += A
else:
    answer += amari

print(answer)

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

setb = N // (A+B)
amab = N % (A+B)

if amab <= A:
    print(setb*A + amab)
else:
    print(setb*A + A)

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

    if A == 0:
        print(0)
        return

    z = N % (A + B)

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


if __name__ == "__main__":
    main()

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