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

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

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

ans = 0

c = n // (a+b)

ans += a * c

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

print(ans)

Solution (Python):
list1=list(map(int,input().strip().split()))[:3]
n,a,b=list1[0],list1[1],list1[2]
k=(n//(a+b))*a
l=n % (a+b)
if(l < a):
	print(k+l)
else:
	print(k+a)

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

v = a//(b+c)
remain = a%(b+c)
if (remain <= b) :
    print(v*b+remain)
else:
    print(v*b+b)

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

Solution (Python):
import math
def myAnswer(N:int, A:int, B:int) -> int:
   counter =(N // (A + B))
   ans = counter * A
   if(N % (A + B) < A):
      ans += N % (A + B)
   else:
      ans += A
   return ans 

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))

if __name__ == '__main__':
   main()

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

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

ans = num * a
if num_a >= a:
    print(ans + a)
else:
    print(ans + num_a)

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

Solution (Python):


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

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

l=n/(a+b)
l=int(l)
s=n%(a+b)
if s>=a:
    sum=l*a+a
else:
    sum=l*a+s
print(str(sum))

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

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

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

Solution (Python):
n,b,r = [int(i) for i in input().split()]
k = n // (r+b) * b
l = min(n % (r+b), b)
print(k+l)

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

    if A == 0 and B == 0:
        print(ans)
        return

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

    print(ans)


main()

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

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

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

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

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

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

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

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

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

if amari > A:
    print(A*(loop+1))

else:
    print(A*loop+amari)

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

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

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

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

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

div = N//(A+B)
rest = N % (A+B)


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

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

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

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

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

res = 0

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

res += min((N % (A+B)), A)

print(res)

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

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

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

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

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

Solution (Python):


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

total = 0

p = N//(A+B)

total += p*A

q = N - p*(A+B)

if q>A:
  total += A
else:
  total += q
print(total)

Solution (Python):
import math

inputted = list(map(int, input().split()))

N = inputted[0]
A = inputted[1]
B = inputted[2]

AB = A + B
remainder = N % AB

num_of_repeat = math.floor(N / AB) * A
num_of_remainder = min(A, remainder)
total = num_of_repeat + num_of_remainder

print(total)

Solution (Python):

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

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

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

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

if amari>=0 and amari<=a:
    print(syo*a+amari)

else :
    print(syo*a+a)

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






x = N // (A + B)
ans1 = A * x
y = N - (A + B) * x
if y >= A:
    ans = A + ans1
elif y < A:
    ans = y + ans1
print(ans)
"""
y < (A + B)を条件に含める必要はない。yは余り部分だから必ずA+Bより小さい

"""

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

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

if q < A:
    print(p*A + q)
else:
    print(A * (p+1))

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

Solution (Python):

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

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

if(mod <= A):
  number = q*A + mod
elif(mod > A):
  number = q*A + A

print(number)

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

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

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

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

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

C = N // (A + B)
D = N % (A + B) 

if D >= A:
  Blue = C * A + A
else:
  Blue = C * A + D
  
print(Blue)

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

ans = 0

if n <= a:
    print(n)
else:
    d, m = divmod(n, a+b)

    if m > a:
        print((d+1)*a)
    else:
        print(d*a+m)

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

roop = A + B

kaisu = N//roop
amari = N % roop

blue = 0
blue = blue + kaisu*A

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


print(blue)

Solution (Python):

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

if N == 0:
    print(0)

if A + B < N:
    
    blocks = int(N/(A+B))
    
    remaining_slots = N % (A+B)
    if A <= remaining_slots:
        
        print(blocks*A + A) 
    else:
        print(blocks*A + remaining_slots)
else:
    if A < N:
        print(A)
    else:
        print(N)

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

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

s = N // (A + B)
t = N % (A + B)

print(s * A + min(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 = 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())
x = N // (A + B)
y = N % (A + B)
if y >= A:
    z = A
else:
    z = y
print(x*A + z)

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

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

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

m=n%(b+r)
l=n//(b+r)
x=n-l*(b+r)

if x<b:
    s=m
else:
    s=b

if m==0:
    n_b=l*b
else:
    n_b=l*b+s
print(n_b)

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

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

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

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

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

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

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

if a == 0:
    print("0")
elif n % (a+b) == 0:
    print(s*a)
elif n % (a+b) != 0:
    print(s*a + x)

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

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

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


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

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

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

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

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

if k >= b:
  print(l*b + b)
else:
  print(l*b + k)

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

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

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

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


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


r = A if mod > A else mod

num = A * q + r
print(num)

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

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

if N-y>A:
    print((x+1)*A)
else:
    print(x*A+(N-y))

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

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

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

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


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

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

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

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

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

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

Solution (Python):
N, A, B = map(int, input().split())
q, mod = divmod(N, (A+B))
print(q*A + min(mod, A))

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

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

c = a+b

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

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

s = N // (A+B)
t = N - s * (A+B)
ans = s*A

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

print(ans)

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

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

print(ans)

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

ab_set = N//(A+B)
ab_rem = N%(A+B)

if ab_rem >A:
    print(A + ab_set*A)
else:
    print(ab_rem + ab_set*A)

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

Solution (Python):
N,A,B=map(int,input().split())
total=(A+B)*(10**100)
cycle=N//(A+B)
amari=N-cycle*(A+B)
if amari>=A:
    print(A+cycle*A)
else:
    print(amari+cycle*A)

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

N = a[0]
A = a[1]
B = a[2]

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

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

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

s = a + b
n_s = n // s
l = n - s * n_s

if l <= a:
	ans = a * n_s + l
else:
    ans = a * n_s + a
    
print(ans)

Solution (Python):
N, A, B = [int(i) for i in input().split()]
x = N//(A+B)
y = N%(A+B)

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

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

count= N // (A+B)
N = N %(A+B)
blues=A*count
reds=B*count

if N<=A:
	blues+=N
else:
	blues+=A


print(blues)

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

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

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

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

print(ans)

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

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

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

Solution (Python):
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n,a,b=n1()

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

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,b,r=INTM()
    s=r+b
    print(n//s*b+min(b,(n%s)))
if __name__ == '__main__':
    do()

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, A, B = LI()

ans = 0

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

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

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

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

print(ans)

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

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

a, b = divmod(N, (A + B))
if A <= b:
    print((a+1) * A)
else:
    print((a * A) + b)

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

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

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

pair = a + b

s = n//pair
t = n%pair

adj = min(a, t)

print(s*a + adj)

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


taba = n // (a + b)
taba_blue = taba * a


rest = n - taba * (a + b)
if rest <= a:
  haji_blue = rest
else:
  haji_blue = a

print(taba_blue + haji_blue)

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

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

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

if b == 0:
    print(n)
    sys.exit()

ab = a + b

n_ab = n // ab

ans = n_ab * a

remain = n - ab * n_ab

ans += min(a, remain)

print(ans)

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

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

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

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

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,a,b = map(int,input().split())
  ans = n//(a+b) * a
  rem = n % (a+b)
  ans += min(rem,a)
  print(ans)
if __name__ == '__main__':
  main()

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

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

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

print(C)

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

Solution (Python):
N,A,B=[int(i) for i in input().split()]
bball=N//(A+B)*A
bamari=N%(A+B)
if bamari>A:
    bball=bball+A
else:
    bball=bball+bamari

print(bball)

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

l = a + b
set_cnt = n // l
rest = n % l
if rest >= a:
    ans = set_cnt * a + a
else:
    ans = set_cnt * a + rest

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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
if n%(a+b)<= a:
    c= n%(a+b)
else:
    c=a
print(a*(n//(a+b))+c)

Solution (Python):
import math
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
num_one_gr = y + z
num_gr = math.floor(x/num_one_gr)
amari = x - num_one_gr*num_gr
if amari <= y:
    total = y * num_gr + amari
else:
    total = y*(num_gr + 1)
print(total)

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

Solution (Python):
n,a,b=[int(i) for i in input().split()]
ans=0
ans+=a*(n//(a+b))
n=n%(a+b)
ans+=min(n,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 = map(int, input().split())
a = (N // (A + B)) * A
if N % (A+B) < A:
    print(a + (N % (A + B)))
else:
    print(a + A)

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

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

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

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

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


if __name__ == "__main__":
    main()

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

rate = N//(B+R)

m = 0
N %= (R+B)
if N!=0:
    if B >= N:
        m = N
    else:
        m = B
ans = rate * B + m
print(ans)

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

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

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

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

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

A_amari = A % 2
B_amari = B % 2




if A+B == 0:
    print(0)
    exit()
else:
    cnt = N // (A+B)
    amari = N % (A+B)



if amari <= A:
    print(A*cnt+amari)
else:
    if amari <= B or amari > A:
        print(A*(cnt+1))

Solution (Python):
N,A,B=map(int,input().split())
a=N//(A+B)
b=A*a
if A!=0:
    c=N-(A+B)*a
    if c<=A:
        print(b+c)
    else:
        print(b+A)
else:
    print('0')

Solution (Python):
import sys

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

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    print(n)
    sys.exit()
if n <= ball:
    print(blue)
    sys.exit()

ans = n // ball
additional = n % ball

if additional == 0:
    print(ans * blue)
elif additional <= blue:
    print(ans * blue + additional)
else:
    print((ans + 1) * blue)

Solution (Python):

import sys
n,blue,red = map(int, sys.stdin.readline().split())

total = blue + red
syo = n // total
amari = n % total
if n <= blue:
    print(n)
elif n <= total:
    print(blue)
elif amari<=blue:
    print(syo*blue + amari)
elif amari >blue:
    print(syo*blue + blue)

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

N, A, B = map(int, sys.stdin.readline().rstrip().split())
C = A + B
n = N // C
ans = n * A
r = N - n * C
ans += min(A, C - (C - r))

print(ans)

Solution (Python):
N,A,B = map(int,input().split())
X = A + B
Blue1 = int(N//X*A)
mod = N - N//X*X
if mod <= A:
    Blue2 = mod
else:
    Blue2 = A
print(Blue1 + Blue2)

Solution (Python):
import math
S,A,B=map(int,input().split())

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

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

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

if A == 0:
    print(0)
elif b <= A:
    print(a*A+b)
else:
    print(a*A+A)

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

sum = 0
times, mod = divmod(N, blue + red)
sum += blue * times
if mod < blue :
    sum += mod
else :
    sum += blue

print(sum)

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

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

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

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

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

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

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 = (int(i) for i in input().split())

    d,m = divmod(N, A+B)
    ans = d * A
    if A > m:
        ans += m
    else:
        ans += A
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 998244353
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]


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

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

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

quo = n//(a+b)
rem = n%(a+b)
print(quo*a+rem) if rem<=a else print(quo*a+a)

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

ans = 0

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

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

print(ans)

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

Solution (Python):
N,A,B = list(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())
n = N//(A+B)
p = N%(A+B)
if p<=A:
    print(n*A+p)
else:
    print(n*A+A)

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

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

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

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

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

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

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

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

Solution (Python):
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time

from fractions import gcd

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

def inp(): return int(sys.stdin.readline())
 
def inp_list(): return list(map(int, sys.stdin.readline().split()))

def lcm(x, y): return (x * y) // gcd(x, y)


n, a, b = inp_list()
q = n // (a + b)
n -= q * (a + b)

ans = q * a + min(a, n)
print(ans)

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

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

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

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

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

quotient = N // (A+B)
remainder = N % (A+B)

if quotient == 0:
    ans = N if A >= N else A
elif remainder > A:
    ans = quotient*A + A
else:
    ans = quotient*A + remainder

print(ans)

Solution (Python):

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

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

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

if remainder < a:
    print(num * a + remainder)
else:
    print((num+1) * a)

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

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

if N%(A+B)<=A:
 print(M*A+N%(A+B))
else:
  print(M*A+A)

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

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

stack = int(n / (a+b))
rem = n % (a+b)

if a > rem:
    print(stack * a + rem)
else:
    print(stack * a + a)

Solution (Python):
def resolve():
    N, A, B = map(int, input().split())
    div, mod = divmod(N, A+B)
    print(A*div + min(mod, A))

resolve()

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



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

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

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

Solution (Python):
N,A,B=map(int, input().split())
C=N//(A+B)*A
D=N%(A+B)
if D<=A:
    print(C+D)
else:
    print(C+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())
it = N//(A+B)
res = N%(A+B)
nb = it*A + min(res,A)
print(nb)

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

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

amari = min(a, amari)

print(sho * a + amari)

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