Problem:
 Score : 200 points    Problem Statement Takahashi has many red balls and blue balls. Now, he will place them in a row.  Initially, there is no ball placed.  Takahashi, who is very patient, will do the following operation 10^{100} times:   Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.   How many blue balls will be there among the first N balls in the row of balls made this way?      Constraints  1 \leq N \leq 10^{18}  A, B \geq 0  0 < A + B \leq 10^{18}  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  A  B       Output Print the number of blue balls that will be there among the first N balls in the row of balls.        Sample Input 1 8 3 4      Sample Output 1 4  Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb , among which there are four blue balls.       Sample Input 2 8 0 4      Sample Output 2 0  He placed only red balls from the beginning.       Sample Input 3 6 2 4      Sample Output 3 2  Among bbrrrr , there are two blue balls.

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

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

if d>a:
    d = a
print(a*c+d)

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

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

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

if diff > a:
    blue += a
else:
    blue += diff

print(blue)

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

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

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)

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

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
    else:
        print(a)
else:
    ans = a*NumberOfRotations
    if a > n - ((a+b)*NumberOfRotations):
        print(ans+surplus)
    else:
        print(ans+a)

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

NumberOfRotations = n//(a+b)
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
    else:
        print(a)
else:
    ans = a*NumberOfRotations
    if a > n - ((a+b)*NumberOfRotations):
        print(ans+surplus)
    else:
        print(ans+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):
n,a,b=(int(x) for x in input().split())
y=n//(a+b)*a+min(n%(a+b),a)
print(y)

Solution (Python):

import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n,a,b = MAP()

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

ans = q*a
if(rem>a):
    print(ans + a)
else:
    print(ans + rem)

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

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

if N- (A+B)*ans <= A:
    print(A*ans + N- (A+B)*ans)

else:
    print(A*ans+A)

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

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

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

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

if a == 0:
  print("0")
elif b == 0:
  print(n)
else:
  ab = a + b
  sets = n // ab
  mods =  n % ab
  mods = min (a, mods)
  print(sets*a + mods)

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

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

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

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

Solution (Python):
N, A, B = map(int, input().split())
if A == 0:
    print(0)
    exit()
P = A + B
X = N//P
x = N%P

if x >= A:
    ans = A*X+A
elif x < A:
    ans = A*X+x

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())
q, m = divmod(n, a+b)
print(a * q + min(m, a))

Solution (Python):
import math
N,A,B=map(int,input().split())
if divmod(N,A+B)[1]<=A:
  print(math.floor(N/(A+B))*A+(N-(A+B)*math.floor(N/(A+B))))
else:
  print(math.ceil(N/(A+B))*A)

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

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

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

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

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

t1 = n // (a+b)
t2 = n % (a+b)
if t2 >= a :
    t3 = a
else :
    t3 = t2

print(t1*a + t3)

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

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

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

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

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())
r = divmod(N,A+B)
if r[1] >= A :
    print(A * (r[0] + 1))
else:
    print(A*r[0]+r[1])

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

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

num=N//(A+B)
amari=N%(A+B)
tasu=0
if amari<=A:
  tasu=amari
else:
  tasu=A

print(num*A+tasu)

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

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

if n % (a + b) != 0:
   ans += min(a, n % (a + b))

print(ans)

Solution (Python):
import sys
N, A, B = map(int,input().split())
AB = A + B
n = N//AB
amari = N%AB
if A >= N:
  print(N)
  sys.exit()
if AB > N:
  print(A)
  sys.exit()
add = min(amari, A)
print(n*A + add)

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

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

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

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

cycles = n//(a+b)
count = 0
count += a*cycles
rest = n - (a+b)*cycles
if rest > a:
    count += a
else:
    count += rest
print(count)

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

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

period = N // (A + B)
number = N % (A + B)

if number >= A:
  print(A * period + A)
else:
  print(A * period + number)

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

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

cycle = A + B
cyclecount =  N // cycle
blueincycle = A * cyclecount
amari = N % cycle

if amari < A:
    print(blueincycle + amari)
else:
    print(blueincycle + A)

Solution (Python):
import sys
sys.setrecursionlimit(10**6) 
import math

from copy import copy, deepcopy
from operator import itemgetter

import bisect

from collections import deque 



from collections import Counter

from itertools import accumulate

from heapq import heapify,heappop,heappush


def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s): return sorted(range(len(s)), key=lambda k: s[k])




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





















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

count=div*A
count+=min(mod,A)

print(count)

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

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

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

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

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

Solution (Python):


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

Q = N //(A+B)
r = N -(A+B)*Q

if r < A:
    ans = Q*A + r
else:
    ans = Q*A + A

print(ans)

Solution (Python):
n,a,b=map(int,input().split(" "))
ka=n//(a+b)
ja=n%(a+b)

bl=ka*a
bl+=min(ja,a)
print(bl)

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

pattern = N // (A + B)

ans = 0
ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)

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

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

Solution (Python):
N, A, B = map(int, input().split())
num = N // (A + B) + 1
zan = num * (A + B) - N

if zan <= B:
    print(num * A)
else:
    print(num * A + B - zan)

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

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

set = a + b

set_num = n // set
remain = n%set

if remain <= a:
    blue = a * set_num + remain
else:
    blue = a * (set_num + 1)

print(blue)

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

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

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

n = N//(A+B)
m = N%(A+B)

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

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

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

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

block = N//(A + B)
other_balls = N%(A + B)

if other_balls >= A :
    print((block*A)+A)
elif other_balls < A :
    print((block*A)+other_balls)
else :
    print(0)

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

one_set = a + b
amari = n % one_set
ans = (n // one_set) * a

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

print(ans)

Solution (Python):


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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

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

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

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
else:
    br_block = A + B
    pre_b = (N - 1) // br_block
    if (N - 1) % br_block < A:
        b = (N - 1) % br_block + 1
    else:
        b = A
    print(A * pre_b + b)

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

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

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

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

if n>=(a+b):

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

    l=int(n%(a+b))

    if l>=a:

        print(a*k+a)

    else:
        print(a*k+l)

else:

    if n>=a:

        print(a)

    else:
        print(n)

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

Solution (Python):
N,A,B=map(int,input().split())
m=A+B
x=int(N/m)
y=int(N%m)
if y<=A:
    print(x*A+y)
else:
    print((x+1)*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):
n,a,b = map(int, input().split())
s = n//(a+b)
rest = n%(a+b)
print(s*a+min(a,rest))

Solution (Python):
import math
N, A, B = map(int, input().split())
oneSet = A + B
blue = 0

remainBalls = 0
if N % oneSet > A: remainBalls = A
else: remainBalls = N % oneSet

blue = math.floor(N / oneSet) * A + remainBalls

print(blue)

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

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

print(result)

Solution (Python):

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


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

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

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

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

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

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

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

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

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


if __name__ == "__main__":
    main()

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

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

mod = N % (A+B)
ans = 0
if 0 < mod and mod <= A:
    ans = mod
elif mod != 0:
    ans = A

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

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

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

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

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

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

sum = n//(a+b)*a
res = n%(a+b)
sum += min(res,a)

print(sum)

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().strip().split())
q = n // (a + b)
r = n % (a + b)

if r > a:
    res_b = a
else:
    res_b = r

ans = q * a + res_b
print(ans)

Solution (Python):
Str = input().split()
N = int(Str[0])
A = int(Str[1])
B = int(Str[2])
answer = A*(N//(A+B))
res = N % (A+B) 
if res <= A:
  answer+= res
else:
  answer+= A

print(answer)

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

l=a+b

if n%l>=a:
  print(math.floor(n/l)*a+a)
else:
  print(math.floor(n/l)*a+n%l)

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

Solution (Python):
import math

N,A,B = map(int,input().split())
a = math.floor(N/(A+B))
if(N-a*(A+B)>=A):
  print(A*(a+1))
else:
  print(A*a+(N-a*(A+B)))

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

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

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

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

brset = A + B
inside = N // (A+B)
count = inside*A

if inside*brset + A <= N:
    count += A
else:
    count += N - (inside*brset)

print(count)

Solution (Python):
import sys;input=lambda:sys.stdin.readline().rstrip();aint=lambda:int(input());ints=lambda:list(map(int,input().split()))
import math;floor,ceil=math.floor,math.ceil
from collections import deque
Yes=lambda b:print('Yes')if b else print('No');YES=lambda b:print('YES')if b else print('NO')
is_even=lambda x:True if x%2==0 else False

def main():
  n,a,b=ints()
  print(((n-1)//(a+b))*a+min(a,(n-1)%(a+b)+1))

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

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

print(ans)

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

m = a + b
n_set = n // m
n_mod = n % m

ans = a * n_set

if n_mod > a:
    ans += a
else:
    ans += n_mod
print(ans)

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

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

Solution (Python):
import sys

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

s = a + b

amari = n % s
syou = n // s

if amari == 0:
    print(a*syou)
    sys.exit()

else :
    if amari > a:
        print(a*syou+a)
    else :
        print(a*syou+amari)

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

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

print(pre)

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

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















p = N//(A+B)

if N - p*(A+B) < A:
    print(A*p + N - p*(A+B) )
else:
    print(A*p+A)

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

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

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

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

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

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

print(sets*a + min(amari, a))

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

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

Solution (Python):
import numpy as np
import sys

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

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

res = cnt*A

if amari <= A:
    print(res+amari)
else:
    print(res+A)

Solution (Python):

n,a,b = map(int,input().split())
num = 0
num = n // (a+b)

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

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

if a==0:
    blue = 0

else:
    brset = n // (a+b)
    blue1 = a * brset
    n -= (a+b) * brset
    blue2 = min(n, a)
    blue = blue1 + blue2

print(blue)

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

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

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

Solution (Python):

import sys
import math
import numpy as np

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

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

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

Solution (Python):
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n // (a+b) * a
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Solution (Python):
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n // (a+b) * a
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

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

if (A+B)>0 and A>0:
  n=N//(A+B)
  AB=N%(A+B)
  A_cnt=AB//A
  if A_cnt>0:
    print((n+1)*A)
  else:
    print(n*A+AB)
elif A==0:
  print(0)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    n, a, b = map(int, rl().split())
    c = n // (a + b)
    d = n % (a + b)
    ans = c * a
    if a > d:
        ans += d
    else:
        ans += a
    print(ans)


if __name__ == '__main__':
    solve()

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

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

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

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

Solution (Python):
def main():
    N,A,B=map(int,input().split())
    result=(N//(A+B))*A
    if N%(A+B)>A:
        result+=A
    else:
        result+=N%(A+B)
    print(result)
if __name__ == '__main__':
    main()

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

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

Solution (Python):
n,b,r=map(int,input().split())
e=n//(b+r)
f=n%(b+r)
if f==0:
  print(e*b)
elif f<=b:
  print(e*b+f)
else:
  print(e*b+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())
div=n//(a+b)
if n-div*(a+b) <= a:print(div*a+n-div*(a+b))
else:print(div*a+a)

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

period = a + b
num_periods = n // period

remainder = n - (a+b)*num_periods

answer = a*num_periods + min(remainder, a)
print(answer)

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

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

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

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

print(str(n//(a+b)*a+mod))

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

ans = A * n  + min(A, r)
print(ans)

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

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

if n%(a+b) != 0:
    n -= tmp*(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):


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

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

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

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

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

Solution (Python):


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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

X = A + B
Y = N // X
Z = N % X

if Z >= A:
  print(A * Y + A)
else:
  print(A * Y + Z)

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

print(ans)

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

q = N//(A + B)
r = N%(A + B)
ans = q*A + min(r,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())
x=n%(a+b)
y=n//(a+b)
print(y*a+min(x,a))

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

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

Solution (Python):
import sys
from copy import copy
input = sys.stdin.readline
'''
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
for test in range(int(input())):
'''
inf = 100000000000000000  
mod = 998244353

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

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

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

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

Solution (Python):

N, A, B = [int(s) for s in input().split()]

blues = A * (N // (A + B))
remains = N % (A + B)

if remains < A:
    blues += remains
elif A <= remains < A + B:
    blues += A

print(blues)

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

Solution (Python):

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




t = A + B


kumi = N // t


amari = N % t


if amari >= A:
  amari_ao = A
else:
  amari_ao = amari


print(A * kumi + amari_ao)

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

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


quot = n // (blue + red)  
rem = n % (blue + red)  

ans = blue * quot + min(blue, rem)

print(ans)

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

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

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

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N,A,B = MI()
    x = N//(A+B)
    c = N%(A+B)

    if c>A:
        c = A

    print(x*A+c)


if __name__ == "__main__":
	main()

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

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

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

c = N // (A + B)

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

if (A + B) * c < N:
    if (N - (A + B) * c <= A):
        print(A * c + N - (A + B) * c)
    elif(N - (A + B) * c > A):
        print(A * c + A)
elif (A + B) * c == N:
    print(A * c)

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

if m > a:
    m = a

sum_b = a * s + m
print(sum_b)

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

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

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

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

print(cnt)

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

Solution (Python):
N,B,R=map(int,input().split())
b=0
i=int(N/(B+R))
tari=N-(i*(B+R))

b+=B*i
if tari >= B:
    b+=B
else:
    b+=tari

print(b)

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

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

blue_ball = 0
if n / (a + b) > 1:
    answer = divmod(n, a + b)
    blue_ball = answer[0] * a
    n = answer[1]

if n > a:
    blue_ball += a
else:
    blue_ball += n

print(blue_ball)

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

Solution (Python):
n,b,r = list(map(int,input().split()))
block=n//(b+r)
count_b=block*b;
extra_b=n%(b+r);
if(extra_b<=b ):count_b+=extra_b;
else: count_b+=b;
print(count_b)

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