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 = 0

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

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

print(num)

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

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

b_count = n // (a+b) 
if (n-(a+b)*b_count) <= a:
    print(n-b*b_count)
else:
    print(a*b_count + a)

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

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

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

ans += min(n, b)

print(ans)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

n,a,b = imap()
div,mod = divmod(n, a+b)
ans = div*a + min(mod, a)
print(ans)

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

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

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

if amari>A:
    amari=A


print(A*count+amari)

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())
c=N//(A+B)
d=N%(A+B)
if d<A:
  k=d
elif d>=A:
  k=A
print(c*A+k)

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

    ans = (n // (a + b)) * a
    r = n % (a + b)
    ans += r if r < a else a
    print(ans)


if 'unittest' not in globals():
    resolve()

Solution (Python):
def actual(n, a, b):
    n_op_least = n // (a + b)

    n_blue_least = a * n_op_least
    adjustment = min(n % (a + b), a)

    return n_blue_least + adjustment

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

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

Solution (Python):
n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*a + [a,q][q<a])

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

num_sets = N // (A + B)
rem = N % (A + B)

print(num_sets * A + min(rem, A))

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


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

    q, r = divmod(N, A + B)
    ans = q * A + min(r, A)
    print(ans)


if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):
def solve():
    N,A,B = map(int, input().split())
    x,y = divmod(N, A+B)
    if y>A:
        y = A
    print(A*x + y)


if __name__ == '__main__':
    solve()

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

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

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

sum=0
L=n//(a+b)
M=n%(a+b)

if a<=M:
  print(a*L+a)
else:
  print(a*L+M)

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

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

print(ans)

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

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

div,mod=divmod(N,A+B)
ans=div*A + min(A,mod)
print(ans)

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

def main():
    n, a, b = map(int, input().split())
    blue = (n // (a+b)) * a
    r = n % (a+b)
    if r <= a:
        print(blue+r)
    else:
        print(blue+a)

if __name__ == '__main__':
    main()

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

print(count)

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

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

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

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):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")



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

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


if __name__ == '__main__':
    main()

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

t = N%(A+B)

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

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

turn = n //(a+b)
rest = n%(a+b)

if turn == 0:
  if n >= a:
    print(a)
  else:
    print(n)
else:
  if rest >= a:
    print((turn + 1) * a)
  else:
    print(turn * a + rest)

Solution (Python):
N, num_of_blue, num_of_red = map(int, input().split())

num_of_repetition = (N // (num_of_blue + num_of_red))
remainder_s = N % (num_of_blue + num_of_red)

count_b = num_of_blue * num_of_repetition + min(num_of_blue, remainder_s)

print(count_b)

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

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

if B==0:
    print(N)
elif A==0:
    print(0)
else:
    n = (N//(A+B))
    ans = n * A
    N -= n*(A+B)
    if N >= A:
        ans+=A
    else:
        ans+=N
    print(ans)

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

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

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

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    per, remain = divmod(N, A + B)
    print(per * A + min(A, remain))
    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):
    if A == 0:
        print(0)
        return

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



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

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


if __name__ == "__main__":
    main()

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

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

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

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

    q, r = divmod(N, AB)
    print(A * q + min(r, A))


if __name__ == '__main__':
    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(min((N//(A+B))*A + N - (N//(A+B))*(A+B), (N//(A+B))*A + A))

Solution (Python):
def li():
    return list(map(int, input().split()))
def mi():
    return map(int, input().split())
def ii():
    return int(input())

N, A, B = mi()

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

blue = div * A

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

print(blue)

Solution (Python):
n,a,b = map(int,input().split())
if n <= a:
    print(n)
elif a < n and n <= a+b:
    print(a)
else:
    s,v = divmod(n,a+b)
    if v <= a:
        print(s*a+v)
    else:
        print(s*a+a)

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

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

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

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

print(a*l+y if y<a else a*l+a)

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

X = A * (N // (A+B))
Y = N % (A+B)

print(X + Y if Y <= A else X + A)

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

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

ans = a*c + min(r,a)
print(ans)

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

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




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

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

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

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

SET = N // (A + B)
BAL = N % (A + B)

if BAL >= A:
    print(SET * A + A)
else:
    print(SET * A + BAL)

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

c = a+b
m = n//c
l = n%c
ans = 0
if l<a:
  ans = ans + l
elif l>a:
  ans = ans + a
  
print(ans + (a*m))

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

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

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

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

loop = n//(b+r)
extra = n%(b+r)

if extra > b:
    print(b*(loop+1))
else:
    print(b*loop +extra)

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

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

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

ans = count * a
if mod > a:
  ans += a
else:
  ans += mod
print(ans)

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

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

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

X = N // AB
C1 = A * X

Y = N % AB
if A >= Y:
    C2 = Y
else:
    C2 = A

print( C1 + C2 )

Solution (Python):
N, A, B = map(int, input().split())
apple = N % (A + B)
print(A * (N // (A + B)) + min(apple, 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())

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

print(ans)

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

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

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))

def resolve():
    N,A,B=pin()
    C=A+B
    n=N%C
    m=N//C
    ans=A*m
    if n<=A:
        ans+=n
    else:
        ans+=A
    print(ans)

resolve()

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 heapq import heapify, heappop, heappush
 
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()

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

if 0 <= a <= A:
    c = a
else:
    c = A

print(b * A + c)

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

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





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

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

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

ans = n // (a+b) * a
ans += n % (a + b) if n % (a + b) <= a else a

print(ans)

Solution (Python):
import math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, a, b = map(int, input().split())
ans = 0
tmp = 0
ans = (n//(a+b))*a
tmp = n % (a+b)
ans += min(tmp, a)
print(ans)

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

Solution (Python):
import sys

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


def resolve():
    n, a, b = map(int, input().split())
    q, r = divmod(n, a + b)
    if r < a:
        res = q * a + r
    else:
        res = q * a + a

    print(res)


if __name__ == '__main__':
    resolve()

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

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

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

if __name__ == "__main__":
  resolve()

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

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

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

T = A+B

ans = (N//T)*A

if N%T >= A:
  ans += A
  print(ans)
else:
  ans += N%T
  print(ans)

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

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

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

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

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

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

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

print(count)

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

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

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

print(ans)

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

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

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

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

Solution (Python):
def numberofblues(N,A,B): 
    
    if A==0:
        return 0
    elif N<=A:
         return N
    else:
        k=(N-A)//(A+B)
        l=N-A-k*(A+B)
        if l<=B:
            return A+k*A
        else:
            return A+k*A+l-B
   
N,A,B=map(int, input().split())
print(numberofblues(N,A,B))

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

ans = n //(blue + red) * blue

plus = n % (blue + red)
ans += min(plus, blue)

print(ans)

Solution (Python):
import math
x = input().split()
n = int(x[0])
a = int(x[1])
b = int(x[2])
z = 0
z = math.floor(n / (a+b)) * a
amari = math.floor(n % (a+b))
if amari == 0:
  pass
elif amari <= a:
  z += amari
else:
  z += a
print(z)

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

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

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

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

Solution (Python):

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

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

if u > a:
    print(t*a+a)
else:
    print(t*a+u)

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

Solution (Python):
n, a, b = [int(_) for _ 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)
d = 0
if a >= n % (a + b):
    d = n % (a + b)
else:
    d =  a
print(c*a+d)

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

rep = n // (a + b)
rem = n % (a + b)

ans = rep * a

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

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

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

if d <= a:
    e = d
else:
    e = a

print(a*c + e)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N,A,B = LI()
    ans = 0
    n_ab = int(N/(A+B))
    amari = N-n_ab*(A+B)
    ans = n_ab*A+A if amari >= A else n_ab*A+amari
    print(ans)

main()

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(IN())
mod=1000000007



def main():
	
	n, a, b = tin()
	
	ra = n // (a+b)
	blue_num = ra * a
	amari = n % (a+b)
	blue_num += min(amari, a)
	
	print(blue_num)
	
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

Solution (Python):
import sys

def ep(*params):
    print(*params,file=sys.stderr)

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

times = N // (A+B)
left = N % (A+B)
ba = times * A
if left >= A:
    ba += A
else:
    ba += left
print(ba)
sys.exit()

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

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

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

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())
tama = int(n/(a+b))*(a+b)
blue = int(n/(a+b))*a
nokori = n - tama
if nokori<a:
    blue += nokori
else:
    blue += a


print(blue)

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

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

Solution (Python):

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

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

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

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

if a > A:
    a = A
    
print(cnt*A + 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 = 0
y = 0
if(n%(a+b) == 0):
  x=int(n/(a+b))*a
else:
  y = n%(a+b)
  x = int(n/(a+b))*a + min(a,y)
print(x)

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

s=a+b

shou=int(n//s)

amari=int(n%s)

if n<s:
    if a<n:
        print(a)
    else :
        print(n)
else :
    if amari<a:
        print(a*shou+amari)
    else :
        print(a*shou+a)

Solution (Python):
import sys
 
readline = sys.stdin.buffer.readline
 
N,A,B = map(int, readline().split())
 
div,mod =divmod(N, A+B)
 
if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)

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

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

c1 = (N // (A + B))

c2 = (N % (A + B))
c3 = A if c2 > A else c2

print(c1*A + c3)

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

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

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

Solution (Python):
import sys

def ISI(): return map(int, sys.stdin.readline().rstrip().split())

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

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

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

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

m = N%(A+B)

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

Solution (Python):

def inp():
    return(int(input()))



def inlist():
    return(list(map(int, input().split())))



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


n, a, b = invr()

p = int(n/(a+b))
r = n % (a+b)

res = a*p
res += min(r, a)
print(res)

Solution (Python):


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

cycle=a+b
cycle_cnt=n//cycle
rest=n-cycle*cycle_cnt
if rest<=a:
    print(cycle_cnt*a+rest)
else:
    print(cycle_cnt*a+a)

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

print(count)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    quotient = N // (A+B)
    remainder = N % (A+B)
    return quotient * A + min(remainder, A)


def main():
    N, A, B = map(int, sys.stdin.readline().split())
    print(solve(N, A, B))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    N,A,B = map(int, input().split())
    x = A+B
    q,r = divmod(N,x)
    ans = A*q + min(r,A)
    print(ans)

main()

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

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

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

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

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

Solution (Python):

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

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

mod = n%(a+b)

if mod < a:
    count_b += mod
else:
    count_b += a

print(count_b)

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

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

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

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

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

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

print(ans)

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

ans = N//(A+B) * A
ra = N % (A+B)
if ra <= A:
    ans += ra
elif ra > A:
    ans += A

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())
cnt = 0
n = N // (A+B)
m = N % (A+B)

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

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

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

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

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

print(res)

Solution (Python):
def count_balls(n, b, a):
	if b == 0:
		return 0
	
	num = n // (a + b)
	mod = n % (a + b)
	if mod != 0:
		if mod < b:
			return num * b + mod
		else:
			return num * b + b
	else:
		return num * b

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

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

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

Set0 = List[0]//(List[1]+List[2])

Blue = Set0 * List[1] + min(List[0] - (List[1]+List[2])*Set0, List[1])

print(Blue)

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

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

Set0 = List[0]//(List[1]+List[2])
E = List[0] - (List[1]+List[2])*Set0

if E >= List[1]:
    Blue = Set0 * List[1] + List[1]
else:
    Blue = Set0 * List[1] + E

print(Blue)

Solution (Python):
import math

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

if a == 0:
    print(0)

elif a >= n:
    print(n)

else:
    num_a = (n // (a+b)) * a
    left_repeated = (n % (a+b))
    print(num_a + min(left_repeated, a))

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

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

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

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

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

p, q = n//(a+b), n%(a+b)
x = min(q, a)
print(p*a + x)

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

pair = N//(A+B)

res = pair * A + min(A, (N - pair*(A+B)))
print(res)

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

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

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

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

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

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

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

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

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

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

print(m)