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, b, r = map(int,input().split())
 
rep = n // (b+r)
mod = n % (b+r)
ans = rep * b
 
if mod > b:
	ans+= b  
else:
    ans+= mod
print(ans)

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

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

if __name__ == "__main__":
    run()

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

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

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

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

ab = a + b
print(a * (n // ab) + min(n - (n // ab) * ab, a))

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

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

Solution (Python):
N,A,B=map(int,input().split())
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, B, R = map(int, input().split())
sum_B = (N // (B+R)) * B
n = N % (B+R)
if n == 0:
  print(sum_B)
elif n > B:
  sum_B += B
  print(sum_B)
else:
  sum_B += n
  print(sum_B)

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

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

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

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

ans = d*a + min(m, a)

print(ans)

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

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

Syo = n //(a+b)
Amari = n%(a+b)


if Amari >= a:
    print(a+a*Syo)
else:
    print(Amari + a*Syo)

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

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

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

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

ad = A if A < m else m
if m == 0:
    ad = 0
answer = A * a + ad
if A == 0:
    answer = 0

print(answer)

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

Solution (Python):
n, a, b = map(int, input().split())
blue = 0
group_len = a + b
quotient = n // (a + b)
blue += quotient * a

mod = n % group_len
if mod <= a:
  blue += mod
else:
  blue += a
  
print(blue)

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

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

s=n//(a+b)

amari=n%(a+b)

answer=s*a

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

print(answer)

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):

    if N <= A : print(N)    
    else :
        k = N // (A+B)
        rem = N - (A+B)*k
        if  rem >= A:
            print(k*A+A)
        elif rem >= 0:
            print(k*A+rem)
        else : print(k*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, A, B = map(int, input().split())
n = N // (A + B)
k = N % (A + B)
if k <= A:
    print(n * A + k)
else:
    print(n * A + A)

Solution (Python):
import numpy as np

s = np.array(input().split()).astype(int)







N,A,B = s

print(N//(A+B)*A + np.array([N%(A+B),A]).min())

Solution (Python):
num_balls, num_blue, num_red = map(int, input().split())

if num_balls % (num_blue + num_red) <= num_blue:
    print((num_balls // (num_blue + num_red)) * num_blue + num_balls % (num_blue + num_red))
else:
    print((num_balls // (num_blue + num_red))*num_blue + num_blue)

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

mul = N // (A+B)

ret = A * mul

m = N % (A+B)

ret += min(m, A)

print(ret)

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

if i[1] == 0:
    print(0)

else:
    j = i[0] // (i[1] + i[2])
    k = j * i[1]

    l = j * (i[1]+i[2])
    l_max = min(l + i[1], i[0])

    k = k + (l_max - l)
  
    print(k)

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

C = N//(A+B)

out = C*A + min(N%(A+B),A)

print(out)

Solution (Python):

n, a, b = [int(i) for i in input().split()]
sy = n // (a+b)
am = n % (a+b)
print(sy*a + min(am, a))

Solution (Python):

n,a,b=map(int,raw_input().split())
if n<=a:
 print n
elif n<=a+b:
 print a
else:
 r=n%(a+b)
 print n/(a+b)*a+min(r,a)

Solution (Python):

def main():
    N,A,B = map(int,input().split())
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    ans1 += min(ans2,A)
    print(ans1)
if __name__ == '__main__':
    main()

Solution (Python):

def main():
    N,A,B = map(int,input().split())
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    if ans2 <= 0:
        ans2 = 0
    ans1 += min(ans2,A)
    print(ans1)
if __name__ == '__main__':
    main()

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

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

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

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

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

ans = shou*a+a if amari >= a else shou*a+amari

print(ans)

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

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

ans = shou*a+a if amari >= a else shou*a+amari

print(ans)

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

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

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

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

else: print(shou * a + amari)

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

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

if r>a:
    r=a

print(q*a+r)

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

Solution (Python):
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def solve():
    n, a, b = LI()
    ab = a + b
    print(n // ab * a + min(n % ab, a))
    return



if __name__ == '__main__':
    solve()

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

Solution (Python):
import math

N, A, B = map(int, input().split())
x = math.floor(N // (A + B))
y = N % (A + B)

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

Solution (Python):
S=list(map(int,input().split()))
N=S[0]
A=S[1]
B=S[2]
C=A+B
D=N//C
E=N%C
b=A*D
if E>A:
    b+=A
else:
    b+=E
print(b)

Solution (Python):
N, b, r = list(map(int, input().split(' ')))
q, mod = divmod(N, b + r)

if mod <= b:
	print(q * b + mod)
else:
  	print(q * 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 = [int(i) for i in input().split()]
K = A +B
m = N // K
ans = A * m
d = N - K * m
if d >= A:
    ans += A
else:
    ans += d
print(ans)

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

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

Solution (Python):
N, A, B = [int(i) for i in input().split()]
S = A+B
c = (N//S)*A
 
c += min(N%S,A)
print(c)

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N, A, B = na()
C = N % (A + B)
if C == N:
    print(min(N, A))
else:
    print((N // (A + B)) * A + min(C, A))

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

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

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

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

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

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

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

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

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

    if amari < a:
        print(syou*a+amari)
    else:
        print((syou+1)*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())
q = n // (a + b)
r = n % (a + b)
c = min(r, a)
print(q * a + c)

Solution (Python):
n, a, b = map(int, input().split())
full = a + b
ans = a * (n // full)
rem = n % full
ans += min(a, rem)
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())
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
ans += min(a, n%(a+b))

print(ans)

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

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

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

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7

N, A, B = MI()
p, q = divmod(N, A + B)
print(A * p + min(A, q))

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

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

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):
from math import floor

num = [int(_) for _ in input().split()]


col_num = num[1] + num[2]

line = floor(num[0] / col_num)

count = line * num[1]

temp = num[0] % col_num
if temp == 0:
    pass
else:
    count += min(temp,num[1])

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

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

print(ans)

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

ans = n // (a + b) * a
alp = min([n % (a + b), a])

print(ans + alp)

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

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

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

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

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

x = N//(A+B)

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

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

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

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

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

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

Solution (Python):
import math
import string


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


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

Solution (Python):
n,a,b = input().split()
n,a,b = [int(n), int(a), int(b)]
num = n // (a + b)
ber = n % (a + b)
ans = a * num

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

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

c = n // (a + b)
if c == 0:
    d = min(n, a + b)
else:
    d = n - (c * (a+b))

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

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

x, y = divmod(n, (a+b))
ans = x * a + min(n - (a + b) * x, a)
print(ans)

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

Solution (Python):


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

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

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

ab = A + B
q = N // ab
r = N % ab

b1 = q * A
b2 = min(r, A)
print(b1 + b2)

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())
ans=0

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

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

print(ans)

Solution (Python):

import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def solve(N: int, A: int, B: int):
    d, m = divmod(N, A+B)
    ans = d*A + min(m, A)
    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())
itr = n//(a+b)
nokori = min(n-(itr*(a+b)),a)
print(itr*a+nokori)

Solution (Python):
import math
n,a,b=map(int, input().split())
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
print(anc_a + min([n_b,a]))

Solution (Python):
import math
n,a,b=map(int, input().split())
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
cnt = anc_a + min([n_b,a])
print(cnt)

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 (A + B) == 0:
    print('0')
else:
    repeat = N // (A + B)
    blue = A * repeat
    remain = N % (A + B)
    if remain > A:
        blue += A
    else:
        blue += remain
    print(str(blue))

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
l1=input().split(" ")
n=int(l1[0])
a=int(l1[1])
b=int(l1[2])
c=a+b
q=n//c
mod=n%c
sub_b=0


if l1[1]=="0":
    print("0")
else:
    if mod<a:
        sub_b=mod
    else:
        sub_b=a
    b_c=sub_b+a*q
    print(b_c)

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

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

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

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

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

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

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

Solution (Python):
import sys, 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
 
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()

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

print(ans)

Solution (Python):
import math

str = input()

nums = [int(x) for x in str.split(' ')]

ct = nums[0] / (nums[1] + nums[2])
ct = math.floor(ct)
res = nums[0] % (nums[1] + nums[2])
res = math.floor(res)

if res > nums[1]:
  res = nums[1]

blue_ball = nums[1] * ct + res

print(blue_ball)

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

Solution (Python):
import sys, 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

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

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

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

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

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

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

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

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

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

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




print(d+min(a,e))

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

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


if __name__ == "__main__":
    main()

Solution (Python):

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

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

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

print(A * k + min(m, A))

Solution (Python):
l=list(input().split())
N=int(l[0])
A=int(l[1])

B=int(l[2])
syou=N//(A+B)
amari=N%(A+B)
kotae=syou*A+min(amari,A)
print(kotae)

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

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

a += min(A,b)

print(a)

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

Solution (Python):
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = n // (b + r)
bb = c * b
d = n % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)

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

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

if a + b == 0:
    b = 1

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

y = n % (a + b)



if y <= a:
    ans = x + y
else:
    ans = x + a





















print(ans)

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


ope1 = n//(a+b)
ope2 = n%(a+b)

if ope1 == 0:
    if n > a:
        print(a)
    else:
        print(n)
elif ope2 == 0:
    print(a*ope1)
elif ope2 < a:
    print(a*ope1 + ope2)
else:
    print(a*ope1 + a)

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

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

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

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

Solution (Python):
s = input()

ss = s.split(" ")

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

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  ans = 0
  div = N //( A + B ) 
  ans = div * A
  ans += min( 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):
s = input()

ss = s.split(" ")

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


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

mod = N % ( A + B )


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

print(ans)

Solution (Python):

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

Solution (Python):
s = input()

ss = s.split(" ")

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


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








print(ans)

Solution (Python):

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



i = 0
num_loop = int(N / (A+B))
tmp = num_loop * A

mod = N % ((A+B))

if mod > A:
    tmp2 = A
else:
    tmp2 = mod

print(tmp + tmp2)

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

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

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

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

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

Solution (Python):


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



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

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

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

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

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

S = d*A + min(p, A)
print(S)

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

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

    length_A_plus_B = A + B 
 
    quo = N // length_A_plus_B 
    rem = N % length_A_plus_B 

    ans = 0
    if N < length_A_plus_B: 
        if N <= A:
            ans = N
        else:
            ans = A
        print('{}'.format(ans))
        exit() 

    ans = quo * A 
    if rem <= A:
        ans += rem
    elif rem > A:
        ans += A
    
    print('{}'.format(ans))



if __name__ == '__main__':
    main()

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

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())
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
tmp = N%(A+B)

print(ans + min(tmp, A))

Solution (Python):
n, a, b = map(int, input().split())
 
if a == 0:
  print(0)
elif a + b == 0:
  print(0)
else:
  q1, mod1 = divmod(n, (a + b))
  if mod1 < a:
    ans = q1 * a + mod1
  else:
    ans = (q1 + 1) * 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 = [int(x) for x in input().split()]

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

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

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

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

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

ans=0

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

print(ans)

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

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

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

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

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

ans = A * C + min(A, D)
print(ans)

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

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


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