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())
x = n // (a+b)
y = n - (a+b)*x
if a == 0:
  print(0)
elif y < a + 1:
  print (x * a + y)
else:
  print (x*a + a)

Solution (Python):
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()

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

Solution (Python):

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

Solution (Python):

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


if A==0:
    print(0)
    exit()
else:
    b=N//(A+B)
    x=N%(A+B)

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

Solution (Python):
import math

if __name__ == "__main__":
    N, A, B = map(int, input().split())
    ret =  math.floor(N / (A + B)) * A
    if N % (A + B) >= A:
        ret = ret + A
    else:
        ret = ret +  N % (A + B)
    print(ret)

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

i = 0
ans = 0

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

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

print(ans)

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

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

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b = na()

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

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

print(a*p+min(a,q))

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

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

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

ans = (N // (B+R)) * B
rest = N % (B+R)

if rest <= B:
  print(ans+rest)
else:
  print(ans+B)

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

q, mod = divmod(N, A+B)
ans = q*A + min([A, mod])

print(ans)

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

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

if (rest > A):
    result = A*(num_move+1)
else:
    result = A*num_move+rest

print(result)

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

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

print(a*A+b)

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

c = n // (a + b)
d = n - (a+b) * c
ans = a * c

if a > d:
    ans += d
else:
    ans += a

print(ans)

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

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

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

Solution (Python):
n, a, b = map(int, input().split())
sum_num = a + b
if a == 0:
  print(0)
else:
  iter_num = int(n/sum_num)
  rest = n - iter_num * sum_num
  if rest >= a:
    print(a * iter_num + a)
  else:
    print(a * iter_num + rest)

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

print(x*A + add)

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()
 
from math import ceil
 
N, A, B = na()
C = N % (A + B)
if C == N:
    print(min(A, N))
else:
    print(A * (N // (A + B)) + (C if C <= A else A))

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

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

Solution (Python):
import math
n,a,b = map(int,input().split())
hako = a+b
hako_include = math.floor(n/hako)

nokori = n-hako_include*hako
if nokori >= a:
  print(hako_include*a + a)
else:
  print(hako_include*a + nokori)

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

Solution (Python):



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

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    p = n // (a + b)
    sum += a * p
    n -= p * (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a



print(sum)

Solution (Python):

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

    span_len = A+B
    
    span_count = N // span_len

    span_remain = N % span_len
    
    if (span_remain == 0) :
        ans = span_count * A
        print(ans)
    elif (span_remain < A) :
        ans = span_count * A + span_remain
        print(ans)
    else :
        ans = span_count * A + A
        print(ans)


main()

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


if __name__ == "__main__":
    print(main())

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

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

x = n // (b + r)

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

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

sum = A + B
yakusuu = int(N / sum)
amari = N % sum
num = 0

if amari >= A:
    num = A
else:
    num = amari

ans = (yakusuu*A) + num

print(ans)

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

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

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

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

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

if y >= A:
    x += A
else:
    x += y

print(x)

Solution (Python):


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


flg = True
if A == 0:
    print(0)
    flg = False

if B == 0:
    print(N)
    flg = False

if flg:

    zentai_num = N // (A + B)
    zentai_b = zentai_num * A

    
    amari_num = N % (A + B)


    amari_b = 0
    if amari_num >= A:
        amari_b = A
        
    else:
        amari_b = amari_num

    

    

    

    print(zentai_b + amari_b)

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

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

if a == 0:
    print(a)
elif mod >= a:
    print((a*q)+a)
elif mod < a:
    print((a*q)+mod)

Solution (Python):
char = input().split(" ")
n = int(char[0])
blue = int(char[1])
red = int(char[2])

num = blue + red

ans = n // num

res = n % num

if res >= blue:
  print(ans*blue + blue)
else:
  print(ans*blue + res)

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

c = a + b
num = int(n / c) * a
if (n % c) <= a:
  num = num + (n % c)
else:
  num = num + a

print(num)

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

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

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

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

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

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


def main():
    blue = (N // (A+B)) * A

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

    return blue


print(main())

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

s = q * A

if mod - A > -1:
    print(s + A)
else:
    print(s + mod)

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

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

Solution (Python):
n, a, b = map(int, input().split())
k = a + b
i = 0
res = 0

y = n // k  
res += y * a

x = k * y

if x + a <= n:
    res += a
elif x + a > n:
    res += n - x
    
print(res)

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

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

if A>=N:
    print(N)
else:
    if A+B>=N:
        print(A)
    else:
        s, a = divmod(N, A+B)
        print(s*A+min(A, a))

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

Solution (Python):
a, b, c=map(int,input().split())
list=[]
a_true=a//(b+c)
a_true2=a%(b+c)
k=b*a_true
if b>=a_true2:
  k+=a_true2
  print(k)
else:
  k+=b
  print(k)

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

Solution (Python):



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

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

print(q * a + min(a, mod))

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

Solution (Python):
from sys import stdin

def main():

    input = stdin.readline

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

    group_num = N // (A+B)

    amari = N % (A+B)
    amari_red = amari if  A >= amari else A

    
    ans_num = group_num * A + amari_red

    print(ans_num)

if __name__ == "__main__":
    main()

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

s = n // (blue + red)
a = n % (blue + red)

ans = 0
if blue > 0:
    if blue > a:
        ans += a
    else:
        ans += blue

print(ans + s * blue)

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

num = 0
i = 0
i = int(n / (a + b)) + 1
if ((a + b)*i) - n <= b:
    print(a * i)
else:
    num1 = ((a + b)* i) - n
    num2 = a * i
    num3 = num1 - b
    print(num2 - num3)

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

import math
n = math.ceil(N//(A+B))
mod = N % (A+B)
b = n*A
if mod <= A:
    b += mod
else:
    b += A

print(b)

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

x = n//(a+b)

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

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

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 fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()



x = 0
x = (n // (a + b)) * a
y = 0
if a != 0:
    y = n % (a+b)
    if not 0 <= y <= a:
        y = a

print(x + y)

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

if a != 0:
    rem = n % (a+b)
    quo = n // (a+b)

    if rem > a:
        rem = a
        
    print(quo*a + rem)
    
else:
    print(0)

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

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

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

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

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

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

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

Solution (Python):



def answer(N, A, B):

    if N < A:
        return N
    else:
        T = A + B
        P, Q = divmod(N, T)
        if Q < A:
            return A * P + Q
        else:
            return A * (P + 1)

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

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

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

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

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

Solution (Python):
N, A, B = map(int, input().split())
if A+B > N:
    if A == 0:
        print(0)
    elif A <= N:
        print(A)
    else:
        print(N)
elif A+B == N:
    print(max(A, 0))
else:
    x, y = divmod(N, A+B)
    if A == 0:
        print(0)
    else:
        if y > A:
            print(x*A+A)
        else:
            print(x*A+y)

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())
period = A + B
times = N//period
k = N%period
N =  A if k >A else k
print(times*A + N)

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

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

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

set = int(a / sum)

 

blue_1 = set * b 

 

amari = a % sum

 
if amari <= b:
  print(blue_1 + amari)
  
else :
  print(blue_1 + b)

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

Solution (Python):
"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
kat = int(N/(A+B))
kalan = N%(A+B)

a = A*kat
if kalan > A:
    a += A
else:
    a += kalan

print(a)

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



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

print(result)

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

if A == 0:
    print(0)




elif N < (A+B):
    print(min(A,N))
else:
    div = int(N/(A+B))
    quob = min(N%(A+B),A)
    ans = div*A+quob
    print(ans)

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

Solution (Python):

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

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

s = A + B

a = N // s

ans = A*a
nokori = N-s*a

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

print(ans)

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

if a == 0:
	print(0)
	exit()
ans = 0
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())

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

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

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

p,q = divmod(n, c)

print(p * a + min(q, a))

Solution (Python):


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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B == N:
    print(A)
elif A + B > N and N >= A:
    print(A)
elif A + B > N and N < A:
    print(N)


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

Solution (Python):
n,a,b  =map(int,input().split())
se = a+b
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n//se
    if cnt == 0:
        if n < a:
            print(n)
        else:
            print(a)
    else:
        res = a*cnt
        n -= se*cnt
        if n <= a:
            res += n
        else:
            res += a
        print(res)

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

q=n//(a+b)
r=n-q*(a+b)
if r>=a:
  print(a*(q+1))
else:
  print(a*q+r)

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())
k=N//(A+B)

if (A+B)*k==N:
  print(A*k)
else:
  if N-k*(A+B)>A:
    print(k*A+A)
  else:
    print(k*A+N-k*(A+B))

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

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

if a == 0:
  ans = 0
else:
  quoit = n//(a+b)
  mod  = n%(a+b)
  if mod <= a:
    ans = quoit*a + mod
  else:
    ans = quoit*a + 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=list(map(int,input().split()))
t=n//(a+b)
amari=n%(a+b)
if a+b==n:
    print(a)
if a >= n:
    print(n)
if a < n < a+b:
    print(a)
if a+b<n:
    if amari==0:
        print(t*a)
    elif amari<=a:
        print(t*a+amari)
    else:
        print(t*a+a)

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

Solution (Python):



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

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

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





S = A + B
quot, remainder = divmod(N, S)

blue_balls = A
if remainder < A:
    blue_balls = remainder

blue_balls += quot * A
print(blue_balls)

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

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

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

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

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

answer = A * q + min(A, r)
print(answer)

Solution (Python):

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


if a == 0:
    print(0)
else:
    count = (int)(n / (a + b))
    amari = (int)(n % (a + b))

    if amari > a:
        amari = a
    print(count * a + amari)

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

x,y = divmod(n,a+b)

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

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

N = int(x[0])
A = int(x[1])
B = int(x[2])

C = A + B

m = N % C
n = N // C

if m == 0:
    print(A*n)
else:
    if m >= A:
        print(A*(n+1))
    else:
        print(A*n + m)

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

if J > A:
    print((K+1)*A)
else:
    print((K*A)+J)

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

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

W = A + B
AB = N // W

exp = N - AB * W
if exp < A:
  ans = exp
else:
  ans = A
ans += AB * A
print(ans)

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

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

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

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

ans = 0

num_rb = n//(a+b)

if num_rb == 0:
    if n >= a:
        print(a)
        exit(0)
    else:
        print(n)
        exit(0)

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

print(ans)

Solution (Python):
N,A,B = map(int, input().split())
adds = A + B
times = N // adds
boalsLen = adds * times
count = A * times


while True:
    if boalsLen > N:
        break
    
    tmpBoalsLen = boalsLen + A
    if tmpBoalsLen > N:
        addBoals = N - boalsLen
        count += addBoals
        break
    
    boalsLen = tmpBoalsLen
    boalsLen += B
    count += A

print(count)

Solution (Python):
a,b,c=map(int,input().split())
d=0
e=0
ok=False

total=int(a/(b+c))
sa=a-(b+c)*total
if total==0:
    if a>=b:
        print(b)
    else:
        print(a)
else:
    if sa>=b:
        print(b+b*total)
    else:
        print(sa+b*total)

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

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*a)+a)

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

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

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

print(b1 + b2)

Solution (Python):


import math

s = input()
num = s.split(" ")
N = int(num[0])
A = int(num[1])
B = int(num[2])

X = math.floor(N/(A+B))
resid = N-(A+B)*X

if A>=resid:
  add_val = resid
else:
  add_val = A

print(A*X + add_val)

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

ans = (N // element) * A 
hanpa = N % element
if  hanpa <= A :
  ans += hanpa
else :
  ans += A

print(ans)

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

C=A+B
d=N//C
N -= C*d

b=0
r=0
while N>0:
    N-=A
    b+=A
    if N<=0:
        b+=N
        break

    N-=B
    r+=B
    if N<=0:
        break

print(b+d*A)

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

Solution (Python):
i = list(map(int, input().split()))
j=int(i[0]/(i[1]+i[2]))
k=j*i[1]
if i[0]%(i[1]+i[2])>=i[1]:
  print(k+i[1])
else:
  print(k+i[0]%(i[1]+i[2]))

Solution (Python):
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

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

print(d*a+m if m<a else d*a+a)

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

print(amari + A * o)

Solution (Python):
s = list(map(int, input().split()))
n = s[0]
a = s[1]
b = s[2]
if 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
ans = (n // sum) * a
val = n % sum
if val <= a: ans += val
else: ans+= a
print(ans)

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

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

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

sum = a + b
dev = n//sum

ans = 0
if a == 0:
    print(0)
else:
    if dev == 0:
        if n > a:
            print(a)
        else:
            print(n)
    else:
        ans = n - sum * dev 
        if ans < a:
            print(dev * a + ans)
        else:
            print(dev * a + 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 = [int(x) for x in input().split()]
times = N // (A + B)
mod = N % (A + B)

print(A * times + min(mod, A))

Solution (Python):
N , A , B = (map(int , input().split()))
def divmod_(a ,b):
    q, mod = divmod(a ,b)
    return q, mod
c , d = divmod_(N ,A+B)
if (d - A) > 0:
    d = A
print((c * A) + d)

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

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

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

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

j=i[1]+i[2]
k,mod=divmod(i[0],j)

if i[1]<mod:
	l=(k+1)*i[1]
else:
	l=k*i[1]+mod
print(l)

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

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

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

if N-cnt*(A+B)>A:
    print(res+A)
else:
    print(res+N-cnt*(A+B))

Solution (Python):

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

Solution (Python):
import math

N, A, B = list(map(int, input().split()))
print(math.floor(N / (A+B)) * A + min(N % (A+B), A))

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

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

if c+A<=N:
    print(s+A)
else:
    print(s+N-c)

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

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

s = n // (a + b)
amari = n - s * (a + b)

amarib = min(amari, a)
print(s * a + amarib)

Solution (Python):
N, blue, red = map(int, input().split())
repeat = N // (blue+red)
partial = N % (blue+red)

ans = repeat * blue
if partial > blue:
    ans += blue
else:
    ans += partial
print(ans)

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

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

Solution (Python):
import math


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

allcount = math.floor(n/(a+b))
if a < n - allcount * (a+b):
    nokori = a
else:
    nokori = n - allcount * (a+b)
ans = allcount * a + nokori
print(ans)

"""
ans = 0
count = 0
while(n>0 and count<=10000):
    n -= a
    if n >= 0:
        ans += a
    else:
        ans += a + n
    n -= b
    count += 1
print(ans)
"""

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

loop, m = divmod(N, A + B)
print(loop * A + (m if m < A else A))

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

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

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

Solution (Python):
N,A,B=[int(x) for x in input().rstrip().split()]
 
ans=N//(A+B)
amari=N%(A+B)
if A<=amari:
    amari=A
ans1=ans*A+amari
print(ans1)

Solution (Python):
import math

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

set_count = math.floor(n / one_set)

def get_blue_count():
  last_balls = n - one_set * set_count
  if last_balls >= a:
    return a
  else:
    return last_balls

print(a * set_count + get_blue_count())

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

if A + B == 0:
    print(0)
elif A >= N:
    print(N)
elif A+B >= N:
    print(A)
else:
    res = (N // (A+B))*A
    amari = N % (A+B)
    
    if amari <= A:
        print(res + amari)
    elif amari <= A+B:
        print(res + A)

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

if A + B <= N:
  C = N // (A+B)
  D = min(N-C*(A+B),A)
  print(C*A+D)
  
else:
  if A >= N:
    print(N)
  else:
    print(A)