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

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

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

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

Solution (Python):
N,A,B=map(int,input().split())
ans=0
count=0
Flag=False
waru=N//(A+B)
amari=N%(A+B)
if amari>A:
    print(waru*A+A)
else:
    print(waru*A+amari)

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

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

print(ans)

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





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

Solution (Python):


import sys

DEBUG = False

def solve():
    return


def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]

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

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n, blue, red = read_int_list()
    ans = 0
    nr_cycle = n // (blue + red)
    ans += nr_cycle * blue
    n = n % (blue + red)
    if blue < n:
        ans += blue
    else:
        ans += n
    print(ans)

if __name__ == "__main__":
    main()

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

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

Solution (Python):

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

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

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

if time == 0 or (time == 1 and N / (A + B) == 1):
  if N - A <= 0:
    print(N)
  else:
    print(A)
else:
  N -= (A + B) * time
  if N - A <= 0:
    print(N + A*time)
  else:
    print(A + A*time)

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

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

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

c = 0
if A == 0:
    print(0)
    exit()
if B == 0:
    print(N)
    exit()

x = N // (A+B)
y = N % (A+B)
c = x * A
if A <= y:
    c += A
else:
    c += y

print(c)

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



if b > A:
    print( a * A + A )
else:
    print( a * A + b )

Solution (Python):
inp = input().split(" ")
N, A, B = (int(inp[0]), int(inp[1]), int(inp[2]))
if int(N % (A + B)) <= A:
    print(int(N / (A + B)) * A + int(N % (A + B)))
else:
    print(int(N / (A + B)) * A + A)

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

sum = A + B
result1 = N // sum

result2 = N % sum

if result2 > A:
    result2 = A

result = result1 * A + result2
print(result)

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


c=a+b


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

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

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

if a==0:
	print(0)
elif b==0 or a>=n:
	print(n)
elif (a+b)>=n:
	print(a)
else:
	print(((n//(a+b))*a)+min(a,n%(a+b)))

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

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

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

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

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

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

    tmp = n // (a + b)

    if n - tmp * (a + b) > a:
        print(tmp * a + a)
    else:
        print(tmp * a + n - tmp * (a + b))

    
    
    
    
    
    
    
    

    
    
    
    


if __name__ == '__main__':
    main()

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

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

if(y>a):
    print(a*(x+1))
else:
    print(x*a+y)

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

Solution (Python):
n,A,B = list(map(lambda x:int(x),input().split(" ")))
x = n%(A+B)
r = min(x,A)
ans = n//(A+B)*A+r
print(int(ans))

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

C = A+B

amari = N % C

if amari <= A:
    print((N // C)*A + amari)
else:
    print((N // C)*A + A)

Solution (Python):
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    elif b == 0:
        print(n)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    if f == 0:
        print(a * d + g)
    else:
        print(a * d + a)

if __name__ == '__main__':
    main()

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

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

box = n // (blue + red)       
mod = n % (blue + red)


if mod <= blue:    
    r_blue = mod
else:              
    r_blue = blue

print(box * blue + r_blue)

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

div = N // (A+B)

ans = A*div

diff = N - ((A+B)*div)

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

print(ans)

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

n = input1[0]
a = input1[1]
b = input1[2]

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

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

print(c + d)

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

M = N // (A + B)
x = M * A + min(N - M * (A + B), A)

print(x)

Solution (Python):
import glob



REL_PATH = 'ABC\\158\\B'


TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        N = q[0]
        A = q[1]
        B = q[2]

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

        if amari <= A:
            result = shou * A + amari
        else:
            result = (shou+1) * A


        print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()

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

Solution (Python):
import sys

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

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

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

if amari <= a:
    print(syou*a + amari)
else:
    print(syou*a + a)

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

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

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

cnt = n//(a+b)
mod = n%(a+b)
if a < mod:
    ans = (cnt+1) * a
else:
    ans = cnt * a + mod

print(ans)

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

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

Solution (Python):
if __name__ == '__main__':
	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())
q=n//(a+b)
r=n%(a+b)
s=min(a,r)
print(a*q+s)

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

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

x = N // (A + B)

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

print(ans)

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

b_r = blue + red

round = int(n/b_r)

if n - (b_r * round) == 0:
  print(blue * round)
else:
  empty = n - (b_r * round)
  if empty < blue:
    print((blue * round) + empty)
  else:
    print((blue * round) + blue)

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

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

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

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

print(ans)

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

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

ans = 0
ab = a+b

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

ans = n // ab
ans = ans * a
if n % ab > a:
    ans += a
else:
    ans += n % ab

print(ans)

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

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


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

if n - int(n/(a+b))*(a+b) > a:
    answer = answer + a
else:
    answer = answer + (n - int(n/(a+b))*(a+b))

print(answer)

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

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

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

Solution (Python):
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left 

enu = enumerate

sys.setrecursionlimit(10**7)
N, A, B = map(int, input().split())

AB = A+B
if AB == 0:
    print(0)
    exit()

if A >= N:
    print(N)
elif AB >= N:
    print(A)
else:
    cnt = A * (N//AB)
    if N % AB >= A:
        cnt += A
    else:
        cnt += N % AB
    print(cnt)

Solution (Python):


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

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

    print(ans)

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

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

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

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

    if amari - a < 0:
        print(count*a + amari)
    else:
        print((count + 1) * a)


if __name__ == "__main__":
    main()

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

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

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

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

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

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

if mod <= A:
    print(int(A * n + mod))

else:
    print(int(A * (n + 1)))

Solution (Python):

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

cnt = 0
sum = 0
i = 0
if a == 0:
    print(0)
    exit()
i = x // (a + b)
cnt = i * a
sum = i * a + i * b


print(cnt + min(x - sum, a))

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

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

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

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

Solution (Python):
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = min(N % S, A) if S != 0 else 0
print(A*count + mod)

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

S=N//(A+B)
E=N%(A+B)

if E>A:
  print(S*A+A)
else:
  print(S*A+E)

Solution (Python):
def main():
    
    
    
    
    
    
    
    
    
    
    
    
    
    n, a, b = map(int, input().split())
    cnt = 0
    if a == 0:
        print(0)
        return 0
    div = n // (a+b)
    cnt = div * a
    n -= div * (a+b)
    while n > 0:
        cnt += min(n,a)
        n -= a
        n -= b
    print(cnt)

if __name__ == '__main__':
    main()

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

nn = N // (A+B)

amari = N % (A+B)

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

Solution (Python):
n, b, r = map(int, input().split())
i = 0
hoge = n // (b+r)
count = hoge*b
n = n - hoge*(b+r)
if n == 0:
    print(count)
while (n>i):
    count += b
    i += b
    if n<=i:
        print(count - (i-n))
        break
    i += r
    if n<=i:
        print(count)

Solution (Python):

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

ans = 0
S=A+B
Q=int(N/S)



ans = Q*A

r = N-Q*S


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

print(ans)

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

b_r = blue + red

round = int(n/b_r)

if n - (b_r * round) == 0:
  print(blue * round)
else:
  empty = n - (b_r * round)
  if empty < blue:
    print((blue * round) + empty)
  else:
    print((blue * round) + blue)

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

ans = 0
shou = n // (a + b)
amari = n % (a + b)
if a == 0:
    ans = 0
else:
    ans = a * shou + min(a, amari)
print(ans)

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

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

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

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

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

print(ans)

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

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

N = N - ((A + B) * x)
if N < A:
  result += N
else:
  result += A
print(result)

Solution (Python):
import math

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

answer = math.floor(N / (A+B))*A

remain = N - math.floor(N / (A+B))*(A+B)
if remain<=A:
  answer += remain
else:
  answer += A

print(answer)

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

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

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

tms = n // (a + b)
mod = n % (a + b)
cnt = 0

cnt += a * tms
if (mod - a) >= 0:
    cnt += a
else:
    cnt += mod
print(cnt)

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

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

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

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

Solution (Python):
import math
s,b,r=map(int,input().split())
sum=math.floor(s/(b+r))
ans=b*sum
rem=s-(sum*(b+r))
if rem>=b:
    ans+=b
else :
    ans+=rem
print(ans)

Solution (Python):

ls = input().split()
l = [int(i) for i in ls]


b = l[1]+l[2]
n = int(l[0]/b)
a = n*l[1]
if l[0]%b>=l[1]:
    a+=l[1]
else:
    a+=l[0]%b
    
print(int(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())
ab = A + B
cnt = N // ab
remain = N - (cnt * ab)
blue = 0
if remain > A:
    blue = A
else:
    blue = remain
ans = A * cnt + blue
print(ans)

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

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

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

Solution (Python):
num_str = input().split()

num = [0, 0, 0]

for i in range(3):
  num[i] = int(num_str[i])

count_rb = int(num[0] / (num[1] + num[2]))
amari = int(num[0] % (num[1] + num[2]))



if amari >= num[1]:
  print(count_rb * num[1] + num[1])
else:
  print(count_rb * num[1] + amari)

Solution (Python):
import numpy as np

grid = []

array = list(map(int,input().strip().split()))


n = array[0]
a = array[1]
b = array[2]
if a == 0:
    print(0)
else:
    kaisuu = int(n/(a+b))
    nokori = n%(a+b)
    if nokori < a:
        print(kaisuu*a+nokori)
    else:
        print(kaisuu*a+a)

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

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

print(s)

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

i = 0
ab = a+b
ans = (n//ab+1) * a
if n%ab < a:
    ans -= a - n%ab
print(ans)

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

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

c = a + b

d = n // c

tmp = n - c * d
if tmp <= a:
    e = tmp
else:
    e = a
print(d * a + e)

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

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

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

k = n // (a+b)
l = n - (a+b) * k
l = a if l > a else l

ans = k * a + l
print(ans)

Solution (Python):
n,a,b=(int(x) for x in input().split())
c=a+b
m=n//c
k=m*c
d=n-k
if d-a>0:
    g=a
else:
    g=d
print(m*a+g)

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

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

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

if c > 0:
    ans = a*c + min((n - (a+b)*c),a)
    if ans > (a+b)*(10**100):
        ans = a*(10**100)
else:
    ans = min(a,n)
    
print(ans)

Solution (Python):
import math
n, a, b = map(int,input().split())
try:
    ans = int(n / (a + b)) * a + min(n % (a + b),a)
except Exception as e:
    ans = 0
print(ans)

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

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


if __name__ == "__main__":
    main()

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

k = int(n / ab)
amari = n - k * ab
bcount += k * a
if amari >= a:
    bcount += a
else:
    bcount += amari

print(bcount)

Solution (Python):
li = list(map(int,input().split()))
out = int(li[0] / (li[1] + li[2])) * li[1]
remain = li[0] - int(li[0] / (li[1] + li[2])) *  (li[1] + li[2])
if(remain > li[1]):
    out += li[1]
else:
    out += remain
print(out)

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

shou = N//(A+B)

amari = N%(A+B)


if amari >= A:
    print(A*shou+A)

elif amari < A:
    print(A*shou+amari)

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

amari = N % (b+r)
rupu = N // (b+r)

if amari >= b:
    ans = rupu * b + b
elif amari < b:
    ans = rupu * b + amari

print(ans)

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

if s >= 1 and t >= a:
  ans = a*(s+1)
elif s >= 1 and t < a:
  ans = a*s+t
elif s == 0 and t >= a:
  ans = a
elif s == 0 and t < a:
  ans = t

print(ans)

Solution (Python):
N, A, B = list(map(int, input().split()))
C = A + B
result = 0
if A < N:
    q, mod = divmod(N, C)
    result = q * A + min(mod, A)
else:
    result = N

print(result)

Solution (Python):
a = input()
N, A, B = [int(b) for b in a.split(" ")]
blue = (N // (A+B)) * A

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

Solution (Python):

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


n = N // (A+B)

r = N % (A+B)


if(r > A):
    b_r = A
else:
    b_r = r


blue = n * A + b_r

print(blue)

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

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

print(p*(a+b)-p*b + (q if q <= a else a))

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

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,a,b=mi()

if(a == 0):
    print(0)
elif(n == 0):
    print(0)
else:
        
    ans = (n//(a+b)) * a

    tmp = n%(a+b) 

    if(tmp >0):
        ans += min(tmp,a)

    print(ans)

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

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

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

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

count = a + b
batch = n // count
remain = n % count

if remain > a:
  result = (a * batch) + a
else:
  result = (a * batch) + remain

print(result)

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

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

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

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


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

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

print(set_blue + rem_blue)

Solution (Python):
i = list(map(int,input().split()))
a=i[0]//(i[1]+i[2])
b=i[0]%(i[1]+i[2])
if b-i[1]<=0:
  c=b
else:
  c=i[1]
print(i[1]*a+c)

Solution (Python):
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
 
if N >= A+B:
    ans = A*(N//(A+B))
    ans += min(A,N%(A+B))
else:
    ans = min(A,N)
print(ans)

Solution (Python):



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

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


m = n // (a+b)


amari = n % (a+b)


blue_num = m * a

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

print(blue_num)

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

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

Solution (Python):
N, A, B = [int(i) for i in input().split()]
tmp = A * (N//(A+B))
res = N - (A+B) * (N//(A+B))
if res > A:
    print(tmp + A)
else:
    print(tmp + res)

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

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

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

Solution (Python):
def inputs(): return [int(x) for x in input().split()]
n,a,b = inputs()
ans = n//(a+b)*a
re = n%(a+b)
if re<=a:
  print(re+ans)
else:
  print(a+ans)

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

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

ans = syou * A

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

print(ans)

Solution (Python):
import math

line = input().split(" ")
capture = int(line[0])
blue = int(line[1])
red = int(line[2])

amari = capture % (blue + red)
waru = math.floor(capture / (blue + red))

if amari > blue:
	print(blue * waru + blue)
else:
    print(blue * waru + amari)

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

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

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

Solution (Python):
def main():
    N,A,B=map(int,input().split())
    count=(N//(A+B))
    if (A+B)*10**100 <= N:
        print(A*10**100)
        return 0
    ans=count*A
    left_ball=N-(A+B)*count
    if A>=left_ball:
        ans+=left_ball
        print(ans)
    else:
        print(ans+A)
        
main()

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

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

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

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

Solution (Python):
N, A, B = (int(i) for i in input().split())
k = N//(A+B)
m = N%(A+B)
if m <= A:
    s = m
else:
    s = A
print(k*A+s)

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

Solution (Python):

n, a, b, =map(int, input().split())
q = n // (a+b)
mod = n % (a+b)
if mod < a:
    print(q * a + mod)
else:
    print((q+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())
cnt_blue=A*(N//(A+B))
cnt_all=(A+B)*(N//(A+B))    
print(cnt_blue+min(A,N-cnt_all))

Solution (Python):
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    
    
    
    ab = a+b

    if n <= a:
        print(n)
        return

    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

if doTest==0:
    resolve()
    sys.exit()

Solution (Python):
N, A, B = (int(x) for x in input().split())
M = N//(A+B)
L = N%(A+B)
if L>=A:
    L = A
print(M*A + L)

Solution (Python):

def main():

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

    if n % (a + b) > 0:
        if n % (a + b) >= a:
            result += a
        else:
            result += n % (a + b)
    print(result)

if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    n, b, r = map(int, input().split())
    ans = n // (b + r)
    ans *= b
    res = n % (b + r)

    if res < b:
        ans += res
    else:
        ans += b

    print(ans)
    
resolve()

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

b =  a[1] + a[2]

sho = a[0] // b
amari = a[0] % b

if amari < a[1]:
    print(sho * a[1] + amari)
else:
    print((sho +1 )* a[1] )

Solution (Python):






import math
from functools import lru_cache





MOD = 10**9 +7
INF = float('inf')





kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr





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


amari = N % (A+B)
sho = math.floor(N/(A+B))

if amari<A:
  last = amari
else:
  last = A



print(int(sho*A+last))