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

Solution (Python):

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

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

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

if a == 0 and b == 0:
    print("0")
elif a >= n:
    print(n)
else:
    x = n // (a + b)
    if x == 0:
        print(a)
    else:
        if (n - ((a + b) * x)) >= a:
            print(a * x + a)
        else:
            print(n - b * x)

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

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

Solution (Python):

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

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

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

ans = a * count + min(mod, a)
print(ans)

Solution (Python):
n, a ,b = list(map(int,(input().split())))
k = n//(a+b)
am = n%(a+b)

print(a*k+min(am,a))

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

Solution (Python):


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

ro = a + b
s = int(n / ro)
r = n % ro
ra = min(r, a)
print(s * a + ra)

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

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

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

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

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

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

Solution (Python):
N,A,B = list(map(int,input().split()))
S = A + B
if N%S >= A:
  ama = A 
elif N%S < A:
  ama = N%S
print((N//S) * A + ama)

Solution (Python):
import math
N,A,B=map(int,input().split())
 
d = N//(A+B)*A
d+=min(A,N % (A+B))
 
print (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  = [int(x) for x in input().split(" ")]

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

Solution (Python):
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    ans = N//(A+B)*A
    rem = N%(A+B)
    print(ans+min(rem, A))
if __name__ == '__main__':
    main()

Solution (Python):

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

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

    else:
        res = ((n // sum)*a) + (n % sum)
        print(res)

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

Solution (Python):
import sys
input = sys.stdin.readline
N, A, B = [int(x) for x in input().strip().split()]
print(N//(A+B)*A+min(N%(A+B), A))

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

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

    tmp = n % ( a + b )

    if tmp >= a:
        tmp = a

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

if __name__ == '__main__':
    main()

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

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

print(ans)

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):

import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    if s==0:
        m=n
    else:
        absum=(a+b)*s
        m=n%(absum)
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)

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

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

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

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

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

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

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

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

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

print (d)

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

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

print(ans)

Solution (Python):
def main():
    N, A, B = map(int, input().split(" "))
    if (A + B) == 0:
        print(0)
        return
    amari = N % (A+B)
    kaisuu = N // (A+B)
    print(kaisuu*A+min(amari, A))
main()

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

print(ans)

Solution (Python):
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    C, D = divmod(N, A+B)
    print(A*C+min(A, D))

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

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

if A == 0:
    print(0)
else :
    q, r = divmod(N, A+B)

    output = q * A

    output += min(r, A)

    print(output)

Solution (Python):

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

if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)

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

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

ans += min(rem, a)
print(ans)

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

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

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

st = N // (A+B)
plus = min(N%(A+B), A)

ans = A * st + plus
print(ans)

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

st = N // (A+B)
plus = min(N%(A+B), A)

ans = A * st + plus
print(ans)

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

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    if add < A:
        print(A * s + add)
    elif add >= A:
        print(A * s + A)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)


if __name__ == "__main__":
    main()

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    s = N // (A + B)
    add = N - (A + B) * s
    if add < A:
        print(A * s + add)
    elif add < A + B:
        print(A * s + A)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)


if __name__ == "__main__":
    main()

Solution (Python):
N,B,R = input().split()
N = int(N)
B = int(B)
R = int(R)
X = B + R
Z = N // X
Y = N % X
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y >= B:
        print(B*Z + B)
elif X > N:
    if B > N:
        print(N)
    else:
        print(B)

Solution (Python):
import math


n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)

Solution (Python):


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

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

print(count)

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

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

Solution (Python):
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if (total%(red+blue)) <= blue:
        print(num*blue+(total%(red+blue)))
    else:
        print(num*blue+blue)

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 math
n,a,b=map(int, input().split())
cnt = 0
mode = 0
if a == 0:
    cnt = 0
elif a+b == n:
    cnt = a
else:
    roop = math.floor(n / (a+b))
    anc_a = a*roop
    n_b = n-(roop*(a+b))
    while True:
        if n_b >= a and mode == 0:
            n_b = n_b - a
            cnt += a
            mode = 1
        elif mode == 1:
            n_b = n_b-b
            mode = 0
        elif n_b < a and mode == 0:
            cnt += n_b
            n_b = n_b -a
        if n_b <= 0:
            break
    cnt += anc_a 
print(cnt)

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

def main(N, A, B):

    if A == 0:
        return 0
    if B == 0:
        return N
    
    
    sumBlue = A * (N // (A + B))

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

    return sumBlue

if __name__ == "__main__":

    answer = main(N, A, B)
    print(answer)

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

if a == 0:
  print(0)
elif b == 0:
  print(n)
elif a >= n:
  print(n)
elif a+b >= n:
  print(a)

else:
  c = a*int(n//(a+b)) + min(n%(a+b),a)
  print(c)

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

n = N-((A+B)*kaisu)
if n >= A:
    print(A*(kaisu+1))
else:
    print(A*kaisu+n)

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:
    print(n)
    exit()
katamari=max(n//(a+b),1)
if n>a+b:
    amari=min(n%(a+b),a)
else:
    amari=0
print(a*katamari+amari)

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

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

if __name__ == "__main__":
    resolve()

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

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

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

Solution (Python):
n, a, b = list(map(int, input().split()))
result = 0
if a + b != 0:
  roop = n // (a +b)
  extra = n - roop*(a+b)
  result = a*roop
  if extra >= a:
    result += a
  else:
    result += extra
print(result)

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

balls= 0
blue = 0

time = n // (a+b)
tmp = n % (a+b)
if tmp < a:
  blue = time*a + tmp
else:
  blue = (time+1)*a

print(blue)

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

d1, d2 = divmod(n, a + b)
if(a < d2):
    d2 = a

sum = d1 * a + d2
print(sum)

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

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

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

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

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

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

    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())
if a==0:
  print(0)
  exit()
elif b==0:
  print(n)
  exit()
s=a+b
cnt=n//s
r=n%s
ans=cnt*a+min(a,r)
print(ans)

Solution (Python):
def main():
  n, a, b = list(map(int, input().split()))
  if a == 0:
    return 0
  if b == 0:
    return n
  if n <= a:
    return n
  if (a + b) >= n:
    return a
  
  temp = n - a
  set_count = temp // (a + b)
  mod = temp % (a + b)
  blue_in_mod = 0 if mod <= b else mod - b
  
  return a + (set_count * a) + blue_in_mod

print(main())

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

blue_ball = a
red_ball = b

n_bai = n // (a + b)
n_amari = n % (a + b)

balls = []
ans = 0

balls_sum = 0

while balls_sum < n_amari:
    balls.append(a)
    balls.append(b)
    balls_sum = sum(balls)

while n_amari > 0:
    if n_amari > blue_ball:
        ans += blue_ball
    else:
        ans += n_amari
    n_amari = n_amari - blue_ball - red_ball

ans += n_bai * blue_ball

print(ans)

Solution (Python):
balls = input().split(" ")

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


if( b == 0 ):
  print( 0 )
else:
  
  step = b + r 
  cnt = n // step
  remain = n % step
  bcnt = cnt * b + min( remain, b)
  
  print( bcnt )

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

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

Solution (Python):

def main():
    n, a, b = map(int, input().split())
    res = n
    count = 0
    if a == 0:
        print(0)
        exit(0)
    count = res // (a + b)
    res = n - ( ( a + b ) * count )
    if a < res:
        print(a * (count + 1))
    else:
        print(a * count + res)
    


if __name__ == "__main__":
    main()

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

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

num = int((N-(N%pair))/pair)

if N - num*pair <= A:
  ans = num*A + N - num*pair
else:
  ans = num*A + A

print(ans)

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

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

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

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

if a == 0 :
    ans = 0
elif b == 0 :
    ans = n
else :
    roop = a + b
    roop_count = int(n/roop)
    roop_amari = n % roop
    if roop_amari <= a :
        ans = roop_count * a + roop_amari
    elif roop_amari > a :
        ans = roop_count * a + 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 = (int(x) for x in input().split())
num = N%(A+B)
cnt = 0
if num <= A:
  cnt = num
else:
  cnt = A
  
print(A*(N // (A+B))+cnt)

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

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

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


x = n // (b + r) 


y = n % (b + r)


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

if x<=a:
    t=x
else:
    t=a
print(t+(y*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 = list(map(int,input().split()))
to, ans = 0 , 0
 
if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n < a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
if n - ((a + b) * to) < a:
  ans += n - ((a + b) * to)
else:
  ans += a
print(ans)

Solution (Python):
import math
import sys

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

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

if a + b >= n:
    print(min(a, n))
    sys.exit()

ans = 0
rep = n // (a + b)

ans += a * rep
n -= (a + b) * rep

ans += (min(a, n))

print(ans)

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

if n == a + b:
    print(a)
    exit()

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



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

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

ans = 0
if m > 0:
  ans = a * x + min(a, m)
else:
  ans = a * x
print(ans)

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

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

g = a + b

ans1 = int((n / g)) * a
rem = n - (int(n / g) * g)
ans2 = min(rem, a)

print(ans1 + ans2)

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

ans = 0
if m > 0:
  ans = a * x + min(a, m)
else:
  ans = a * x
print(ans)

Solution (Python):
N,A,B=map(int,input().split())
if (0<A+B<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    if N%(A+B)<=A:
        c=(N//(A+B))*A+N%(A+B)
        print(c)
    else:
        d=(N//(A+B))*A+A
        print(d)

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

Solution (Python):
import math
N, A, B = [int(i) for i in input().split()]
if A == 0 and B == 0:
    print(0)
else:
    count = A + B
    setCount = math.floor(N / count)
    amari = N - setCount * count
    if amari > 0:
        if A > amari:
            result = setCount * A + amari
        else:
            result = setCount * A + A
    else:
        result = setCount * A
    print(result)

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

Solution (Python):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

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

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

b = 0
r = 0

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

    r = N // (A+B)
    m = N % (A+B)
    
    rest = 0
    if A >= m:
        rest = m
    else:
        rest = A

    ans = A*r + rest

    return ans

print(solve())

Solution (Python):
In = input().split()
N = int(In[0])
A = int(In[1])
B = int(In[2])
x = N // (A + B)
y = N - (A + B)*x
ans = x * A
if y <= A:
    ans += y
else:
    ans += A
print(ans)

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





if A==B==0:
    print(0)
elif A==0:
    print(0)
else:

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

Solution (Python):

N, A, B = list(map(int, input().split()))
su = A + B
ans = (N//su)*A
ext = N%su
if ext <= A:
    ans += ext
else:
    ans += A

print(ans)

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

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

Solution (Python):
line = input().split(" ")

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

S = A + B
if S == 0:
    print(0)
    exit(0)
div, mod = divmod(N, S)

answer = div * A
answer += mod if mod < A else A
print(answer)

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

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

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

sho = n // (a + b)
mod = n % (a + b)
if mod <= a:
    ret = sho * a + mod
else:
    ret = sho * a + a

print("{}".format(ret))

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

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
sys.setrecursionlimit(10 ** 7)

def main():
    n, a, b = na()
    
    if (a == 0 and b == 0) or a == 0:
        print(0)
        return

    if n <= a:
        print(n)
        return
      
    AB = a + b
    if n <= AB:
        print(min(n, a))
        return 
    
    x = int(n / AB)

    print(x * a + min(n - (x * AB), a))

if __name__ == '__main__':
    main()

Solution (Python):
n,m,l = map(int,input().split())
x, y = divmod(n, (m + l))
if y <= m:
    print(x*m+y)
else:
    print(x*m+m)

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

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

    cnt = 0
    if A <= amari:
        cnt = A
    else:
        cnt = amari
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Solution (Python):
import numpy as np

NAB=np.array(input().split(" "),dtype=np.int64)

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

div=int(N//(A+B))
mod=N%(A+B)

blue=0
if(mod<=A):
    blue=mod
else:
    blue=A

print(A*div+blue)

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:
    print("0")
    exit(0)

AB = A+B



if N <= AB*(10**100):
    print (min(A,(N-(N//AB)*AB)) + ((N//AB)*A))
else:
    print (A*(10**100))

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

"""
count = 0
retu = []
while count < 10 ** 100 and count < N:
    count += 1
    for index in range(A):
        retu.append(1)
    for index in range(B):
        retu.append(0)
retu = retu[0:N]
print(sum(retu))
"""

if 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 = map(int,input().split())
ab=a+b
s=(n//ab)*a
sd=n%ab
if(sd<=a):
    s+=sd
else:
    s+=a

print(s)

Solution (Python):
x = list(map(int,input().split(" ")))
n = x[0]
a = x[1]
b = x[2]

proc = a + b
mul_syo = n // proc
mul_ama = n % proc

ans = 0

if mul_ama <= a:
    ans = (mul_syo * a) + mul_ama
else:
    ans = (mul_syo * a) + a

print(ans)

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

am = n % (b + r)
s  = n // (b + r)





if am <= b:
    print((s * b) + am)
else:
    print((s+1) * b)

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

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

if N <= A:
    print(N)
    exit()

set_count = N // (A+B)
extra = N % (A+B)

if extra <= A:
    print(set_count*A + extra)
    exit()
else:
    print(set_count*A + A)
    exit()

Solution (Python):
if __name__ == '__main__':
    n, a, b = tuple([int(s) for s in input().split()])
    div = n // (a + b)
    mod = n % (a + b)

    print(a * div + min([a, mod]))

Solution (Python):
n,a,b=map(int,input().split())
mm=max(a,b)
if a==0:
    print(0)
    exit()
if b==0:
    print(n)
    exit()
xx=n//(a+b)
ans=((xx-1)*a)
baaki=n-((xx-1)*a)-((xx-1)*b)

while baaki>0:
    temp=min(baaki,a)
    baaki-=temp
    ans+=temp
    if baaki<=0:
        break
    temp=min(baaki,b)
    baaki-=temp
    if baaki<=0:
        break 
print(ans)

Solution (Python):


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

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

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

print(x)

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

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

    ret = 0
    cnt = N // (A + B)

    if N % (A + B) == 0:
        print(int(A * cnt))
    elif N < A + B:
        print(min(N, A))
    else:
        ret += A*cnt
        if N - (A+B)*cnt <= A:
            ret += N - (A+B)*cnt
        else:
            ret += A

        print(ret)


if __name__ == '__main__':
    main()

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

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

nokori = N - (result+(B*count))
if N % (A+B):
    if nokori <= A:
        result += nokori
    else:
        result += A

print(result)

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

M = A+B

C = N//M

b = N-(C*M)
if b>=A:
    print((C+1)*A)
else:
    print(b+C*A)

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

S = A+B
count = N//S
pre_cnt = A*count
S_amari  = N-S*count
if S_amari >= A:
  cnt  = pre_cnt + A
else:
  cnt = pre_cnt + S_amari

print(cnt)

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

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

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

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