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())
total=A+B
if N<=A:
  print(N)
else:
  c=N//total
  m=N%total
  o=min(A,m)
  print(c*A+o)

Solution (Python):

"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""


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

S=N//(A+B)
M=N%(A+B)
if M>A:M=A
ans=S*A+M

print(ans)

Solution (Python):
line = input().split()
N = int(line[0])
nB = int(line[1])
nR = int(line[2])

if nB == 0:
  print(0)
  quit()

nball = nB + nR
nGroup = N // nball
nAdditional = N % nball

if nAdditional > nB:
  nAdditional = nB

nBlueTotal = nB * nGroup + nAdditional
print(nBlueTotal)

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

result = 0

tmp = N // (A + B)

result += tmp * A


rest = N - tmp * (A + B)

if rest <= A:
    result += rest
else:
    result += A


print(result)

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

each=a+b

baisu=n//each
amari=n%each

ans+=(a*baisu)

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

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

Solution (Python):
import sys

n, a, b = map(int, input().split())
ans = 0
allcnt = 0
if a > n:
    print(n)
    sys.exit()
elif a+b >= n:
    print(a)
    sys.exit()
else:
    allcnt = n//(a+b)
    amari = n%(a+b)
    if amari > a:
        amari = a 
    print(allcnt*a+amari)

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

t = a + b
na1 = a * (n // t)
na2 = n % t if (n % t) < a else a

print(na1 + na2)

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

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

if b == 0:
    print(0)
else:
    x = n // (b + r)
    a = n % (b + r)

    if a <= b:
        print(x * b + a)
    else:
        print(x * b + b)

Solution (Python):
N,A,B=map(int,input().split())
ab=A+B
if N <= ab and N>=A:
    print(A)
elif N <= ab:
    print(N)
else:
    t = N//ab
    t2 = N%ab
    if t2>=A:
        print(A*t + A)
    else:
        print(A*t + t2)

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

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

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

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

Solution (Python):
N,B,R=map(int,input().split())
process_n = N//(B+R)
amari = N%(B+R)
result = process_n*B

if amari <= B:
    result += amari
else:
    result += B
print(result)

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

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

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

def solve(N, A, B):
    if A == 0:
        return 0
    repeats = N // (A + B)
    right = N - (A + B) * repeats
    blues = A * repeats + min(right, A)
    return blues


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))

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


import queue

def main():
    n, a, b = map(int, input().split())
    p = n // (a + b)
    remain = n - p * (a + b)
    print(p * a + min(a, remain))
    
if __name__ == '__main__':
    main()

Solution (Python):
import math

[n, a, b] = [int(x) for x in input().split(" ")]
quotient = n // (a + b)
remainder = min(a, n % (a + b))
print(quotient * a + remainder)

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

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



a = N // (A+B)

M = N - (A+B)*a

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

else :
    print(a*A+M)

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

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

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

def main(): 
    if a == 0:
        print(0)
        return
    if b == 0:
        print(n)
        return
    r = n % (a+b)
    d = int(n // (a+b))
    ans = a * d + min(r, a)
    print(ans)
main()

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

  if N%(A+B)==0:
    print(A*N//(A+B))
  else:
    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=list(map(int,input().split()))

if a==0:
    print(0)
else:
    sets=n//(a+b)
    res=n%(a+b)

    resa=min(res,a)

    print(sets*a+resa)

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

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

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

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

if a <= ama:
    print(ans + a)
else:
    print(ans + ama)

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

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

Solution (Python):
nums=input().split(" ")
N,B,R= [int(nums[i]) for i in range(len(nums))]
sum=B+R

sets,amari=N//sum,N%sum
if amari>=B:
	x=B
else:
	x=amari

print(sets*B+x)

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

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

    print(blue)

Solution (Python):

import sys

x = input().split(" ")
ans = 0

n = int(x[0])
b = int(x[1])
r = int(x[2])

set = n // (b + r)
ama = n % (b + r)

ans = set * b

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

print(ans)

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

n,a,b = map(int,readline().split())
if a == 0:
    print(0)
    exit()
ans = n//(a+b)
ans *= a
res = n%(a+b)

res = min(a,res)

ans += res

print(ans)

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

val =  n - ((a + b) * (n // (a + b)))


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

print(ans)

Solution (Python):
numbers=input().rstrip().split(" ")
N=int(numbers[0])
A=int(numbers[1])
B=int(numbers[2])
X=int(N/(A+B))
Y=N-X*(A+B)
if Y>=A:
    delta=A
elif Y<A:
    delta=Y
print(X*A+delta)

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

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

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

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

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

amari = n%(a+b)

nokori = min(a,amari)

ans += nokori
print(ans)

Solution (Python):
def main():

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

    
    
    
    
    
    
    

    
    
    
    
    
    
    

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


if __name__ == '__main__':
    main()

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

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

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

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

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

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

ans += count * A

if N % (A + B) < A:
    ans += N % (A + B)
else:
    ans += A

print(ans)

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

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

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

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

if a == 0:
    print(0)
    exit()
tmp = N % (a+b)
print((N // (a+b))*a + min(tmp, a))

Solution (Python):
from sys import stdin

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



if N%(A+B)==0:
    print(A*int(N/(A+B)))
else:
    temp1=int(N/(A+B))
    temp=N-(temp1*(A+B))
    if temp<A:
        print(temp1*A+temp)
    else:
        print(temp1*A+A)

Solution (Python):
n,a,b=(int(x) for x in input().split())
l=n//(a+b)
m=n%(a+b)
if m>=a:
    m=a
print(l*a+m)

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

blue_count = a * (n // (a + b))
n -= (a + b) * (n // (a + b))
if n >= a:
    blue_count += a
else:
    blue_count += n
print(blue_count)

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

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

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

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

if amari > a:
    amari = a

print(ite*a + amari)

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

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

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

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

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

Solution (Python):
from math import ceil as c
n,a,b=map(int,input().split())
q,r=divmod(n,a+b)
s=q*a
if r<=a:
  print(s+r)
else:
  print(s+a)

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

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

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

q = n // (a + b)
r = n % (a + b)
result = q * a
if r <= a:
    print(result + r)
else:
    print(result + a)

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

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

l=n%u
if l<=a:
    l=l
else:
    l=a

s=s+l

print(s)

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

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

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

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

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

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

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

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

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

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

from math import ceil

x = N // (A+B)

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

ans += min(N, A)

print(ans)

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

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

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

Solution (Python):


import sys, math
sys.setrecursionlimit(300000)


def solve(N: int, A: int, B: int):
    tmp = math.floor(N / (A + B))
    ret = tmp * A
    ret += min(A, N - tmp * (A + B))
    print(ret)
    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 = [int(x) for x in input().split()]



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

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

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

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

print(ans)

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


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

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

reps = int(N / (A+B))
complete_block = (A+B) * reps
complete_As = A * reps
left = min(N - complete_block, A)
print(complete_As+left)

Solution (Python):

import collections


class Solution:
    def solve(self, N, A, B):
        return A * (N//(A+B)) + min(N % (A+B), A)


sol = Solution()

[N, A, B] = list(map(int, input().strip().split()))
print(sol.solve(N, A, B))

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

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

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

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

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

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

print(d + r)

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

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

if a > d:
    s = c * a + d
else:
    s = (c+1) * a

print (s)

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

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

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

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

def calculate(n,a,b):
    s1 = n // (a + b)
    sum = a * s1

    s2 = n % (a + b)

    if s2 <= a:
        sum = sum + s2
    else:
        sum = sum + a

    return sum

result = calculate(N,A,B)

print(result)

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

    print(ans)

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

Solution (Python):


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

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

if(N-c*(A+B) > A):
    print((c+1)*A)
else:
    print(c*A + N - c*(A+B))

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

Solution (Python):


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

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

print d * a + min(a, m)

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

x = n//(a+b)

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

operation_count = N // (A+B)
blue_count = A * operation_count
if N % (A+B) > 0:
    rest = N % (A+B)
    blue_count += min([rest, A])

print(blue_count)

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

Solution (Python):





def get_num_blue(n, a, b):
  if a == 0: return 0
  q, r = divmod(n, a+b)
  return q*a + min(a, r)


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

Solution (Python):
def main():
    N, A, B = map( int, input().split())
    n = N//(A+B)
    ans = n*A
    N -= n*(A+B)
    if N <= A:
        ans += N
    else:
        ans += A
    print(ans )
if __name__ == '__main__':
    main()

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

if N-E>=A:
  ans= D*A + A
else:
  ans= D*A+ (N-E)
  
print(ans)

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

comb = int(N / (A + B))
index = N % (A + B)
n_bule = A * comb + min(index, A)

print(n_bule)

Solution (Python):
def main():
  n, blue, red = input_list()
  d = n % (blue+red)
  if d == 0:
    print(blue * (n // (blue+red)))
  else:
    if d > blue:
      d = blue
    print(blue * (n // (blue+red))+d)
    
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

import math
import fractions
from functools import reduce
main()

Solution (Python):

''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    
    ab = n//(a+b)
    cnt = a * ab
    print(cnt + min(n-(a+b)*ab, a))


if __name__=="__main__":
    main()

Solution (Python):
N,b,r = map(int, input().split())
 
num = int(N / (b+r))
rest = N - num * (b + r)

if rest >= b:
	print(num * b + b)
else:
	print(num * b + rest)

Solution (Python):

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

M = int(N/(A+B))
m = N%(A+B)

Bsum = M*A
if(m <= A):
  Bsum += m
else:
  Bsum += A

print(Bsum)

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

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

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

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

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

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

Solution (Python):
def main():
    n, a, b = input().split()
    n, a, b = int(n), int(a), int(b)
    syou = int(n / (a + b))
    amari = n % (a + b)
    
    if amari - a < 0:
        print(a * syou + amari)
    else:
        print(a * syou + a)

if __name__ == '__main__':
    main()

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

blue = 0

if n <= (a+b):
  if n > a:
    blue = a
  else:
    blue = n
else:
  blue = (n // (a+b))*a

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

Solution (Python):
import sys
import numpy as np



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

sho = n // (a + b) 

mod = n % (a + b)

if mod <= b:
    b_num = sho * b + mod
else:
    b_num = sho * b + b
print(b_num)

Solution (Python):
import math
from collections import deque
def main():
    n,a,b = tuple([int(t)for t in input().split()])

    if b == 0:
        print(n)
    else:
        t = a+b
        res = (n // t)*a+min(n%t,a) 
        print(res)
if __name__ == "__main__":
    main()

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

blue = 0
ab_num = n // (a + b)

trunk = ab_num * a

remain = n - ab_num * (a + b)

blue = trunk + min(remain, a)

print(blue)

Solution (Python):

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

ans = 0

if a + b > 0:
    step = a + b
    ans += a * (n // step)
    
    ans += min(a, n % step)

print(ans)

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

Solution (Python):


def abc158b(n, a, b):
    num_b = 0
    if a+b != 0:
        rep = n // (a+b)
        mod = n % (a+b)
        num_b = rep * a
        if mod < a:
            num_b += mod
        else:
            num_b += a

    return num_b



if(__name__ == '__main__'):
    
    n, a, b = map(int, input().split(" "))
    
    accomplishment = abc158b(n, a, b)
    
    
    print(accomplishment)

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians

from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    main()

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

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

amari=a

if a>y:
  amari=y

print(a*x+amari)

Solution (Python):

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

if N <= A:
    print(N)
elif N <= (A+B):
    print(A)
else:
    sum = A+B
    repeat = int(N/sum)
    amari = N%sum

    if amari <=A:
        print(A*repeat+amari)
    else:
        print(A*repeat+A)

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

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

Solution (Python):
import numpy as np

n, a, b = np.asarray(input().split(), dtype=np.uint64)

times = np.asarray([0], dtype=np.uint64)
times += n // (a+b)

last = np.asarray([0], dtype=np.uint64)
last += n % (a+b)

answer = np.asarray([0], dtype=np.uint64)

if last <= a:
    answer += times * a + last
else:
    answer += a * (times + 1)

print(int(answer))

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

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

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

modans = X % (A + B)
n = X // (A + B)

if modans <= A:
	ans = (A * n) + modans
elif modans == 0:
	ans = A * n
else:
	ans = A * (n + 1)

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

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

y = n - x*(a+b)
if y >= a:
    res += a
else:
    res += y

print(res)

Solution (Python):
n,a,b=[int(i) for i in input().split()]
c = n//(a+b)
ans = c*a+min(n-c*(a+b),a)
print(ans)

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

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

if b_ball == 0:
  print(0)
else:
  cycle = int(n / (b_ball + r_ball))
  amari = int(n % (b_ball + r_ball))
  if amari > b_ball:
    amari = b_ball
  
  sum_ball = cycle * b_ball + amari
  print(sum_ball)

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


if __name__ == '__main__':
    solve()

Solution (Python):
from sys import stdin

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]

result = int(n / (a + b)) * a
temp = n % (a + b)

if temp > a:
    result += a
else:
    result += temp

print(result)

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

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

if amari < A:
    count = shou * A + amari
else:
    count = shou * A + A
    
print(count)

Solution (Python):
if __name__ == '__main__':
    n,blue,red = [int(a.strip()) for a in input().strip().split(' ')]
    length = blue + red
    a= n / length
    sho = int(a)
    amari = n % length

    if amari >= blue:
        chibi = blue
    else:
        chibi = amari
        
    print(sho*blue+chibi)

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

last = n % (a + b)
if last > a:
    last = a

loop = int(n / (a + b))

print(loop * a + last)

Solution (Python):

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

a = N % (A+B)
b = N // (A+B)
if a <= A:
    print(b*A+a)
else:
    print(b*A+A)

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

if __name__ == '__main__':
    main()

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

count = A + B
hoge1 = N // count
hoge2 = N % count

ans1 = A * hoge1

if hoge2 < A:
    print(ans1 + hoge2)
else:
    print(ans1 + A)

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

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

nab = 0
if N % AB != 0:
    nab = N % AB
    nab = nab if nab < A else A

print(((N // AB) * A) + nab)

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

SYO = N // (A+B)
AMARI = N % (A+B)
if AMARI < A:
    print(SYO*A+AMARI)
else:
    print((SYO+1)*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:
    print(N)
elif N <= (A + B):
    print(A)
elif N % (A + B) <= A:
    print((N // (A + B))*A + (N % (A + B)))
else:
    print((N // (A + B))*A + A)

Solution (Python):
import math

number, blue, red = map(int, input().split())

many = math.floor(number / (blue + red))

count = many * blue

number = number - (blue + red)*many

if number <= blue:
    count += number
else:
    count += blue

print(count)

Solution (Python):
import math

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

mod = N % (A+B)
n = math.floor(N/(A+B))

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

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

loop = n // (a + b)
rem = n - loop * (a + b)
if rem < a:
  print(loop * a + rem)
else:
  print(a * (loop + 1))

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


q, mod = divmod(n, a+b)
aaa= min(mod, a)

print(a*q + aaa)

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

else:
    q = n % c
    q = a if q > a else q
    print((n // c) * a + q)

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

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

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

print(ans)

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

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

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

value_size = A + B

number_blue = A * (N // value_size)


resid = N % value_size


if resid > A:
    resid = A
print(number_blue + resid)

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

tot = A+B

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

Solution (Python):


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

len = A + B
c = int(N/len)
m = N%len
sum = c * A

if A < m:
    sum += A
else:
    sum += m
print(sum)

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

ab = a+b

i = 0

r = n//ab
m = n%ab

if m>a:
  m=a

ans = a*r + m

print(ans)

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

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

X = N // (A+B)

if N % (A+B) <=A:
    Y = N % (A+B)
else:
    Y = A

print(X*A+Y)

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

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