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

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

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

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




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

print(ans)

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

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

Solution (Python):
if __name__ == '__main__':

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

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

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

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

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

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

before_count  = loop * a
after_count = min(r,a)
ans = before_count + after_count

print(ans)

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

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

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

else:
  print(r*A+(N-r*(A+B)))

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

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):
import math
N, A, B = map(int, input().split())
if math.log10(N)>math.log10(A+B)+100:
    print(A*(10**100))
elif N % (A+B) <= A:
    print((N//(A+B)*A)+(N%(A+B)))
else:
    print((N//(A+B)*A)+A)

Solution (Python):
a = [int(s) for s in input().split()]
b = int(a[0] // (a[1] + a[2]))
c = int(a[0] % (a[1] + a[2]))
d = b * a[1]
if c >= a[1]:
  d = d + a[1]
else:
  d = d + c

print(d)

Solution (Python):
N, A, B = map(int, input().split())
g = A + B
ct = N // g
cr = N % g
ct = A * ct
if cr > A:
    print(ct + A)
    exit()
print(ct + cr)

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

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

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

if c <= a:
    ans = d * a + c
else:
    ans = d * a + a

print(ans)

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

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

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

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

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

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

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

ans = q*A
ans += A if r >= A else r
print(ans)

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

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

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

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

Solution (Python):

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

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

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

ab=a+b
num=n//ab
n-=ab*num

if n>=a:
  ans=a
  
else:
  ans=n
  
print(ans+num*a)

Solution (Python):
if __name__ == '__main__':
    N, A, B = map(int, input().split())
    base = pow(10, 100)
    C = A+B
    mod = N%C
    n = N//C
    if mod>A:
        print(A*n+A)
    else:
        print(A*n+mod)

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

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

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

if a >= n:
    ans = n
elif a+b >= n:
    ans = a
else:
    set_ab = n//(a+b)
    ans += set_ab*a
    n -= set_ab*(a+b)
    if n < a:
        ans += n
    else:
        ans += a

print(ans)

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

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

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

print(A * M + min(N - M * (A + B), A))

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

if __name__ == "__main__":
    solve()

Solution (Python):
import os, sys
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

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

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

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

Solution (Python):

def resolve():
    import sys
    input = sys.stdin.readline
    
    
    nab = [int(x) for x in input().rstrip().split(" ")]
    n = nab[0]
    a = nab[1]
    b = nab[2]

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

    ans = kurikaesi * a
    ans += amari if amari < a else a
    print(ans)

if __name__ == "__main__":
    resolve()

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

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

s = N // (A+B)
p = N%(A+B)
if p//A == 0:
    ans = s*A+p
else:
    ans = s*A+A
print(ans)

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

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

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

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

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

Solution (Python):
def main():
  n,a,b = list(map(int,input().split()))
  ans=0
  count=int(n/(a+b))
  ans+=count*a
  amari=n-count*(a+b)
  if amari <= a:
    ans+=amari
  else:
    ans+=a
  print(ans)
main()

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

n = N//(A+B)

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

print(ans)

Solution (Python):
import sys

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


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

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

Solution (Python):
score = list(map(int,input().split()))
gokei = score[1] + score[2]
shou,amari = score[0]//gokei,score[0] % gokei
if amari > score[1]:
    print((shou+1)*score[1])
else:
    print(shou*score[1]+amari)

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

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

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

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

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

Solution (Python):
NN =input().split()
N =int(NN[0])
A = int(NN[1])
B = int(NN[2])
X =A+B
Y =N//X
Z = N%X

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

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

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

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

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

Solution (Python):
N, B, R = list(map(lambda x: int(x), input().split(" ")))

print((N // (B + R)) * B + min([N % (B + R), B]))

Solution (Python):
n, a, b = map(int, input().split())
q, mod = divmod(n, a+b)
print(a*q+mod if mod<=a else a*q+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())

N_syo = N//(A+B)
N_amari = N%(A+B)
ans = 0

if B == 0:
    print(N)

elif N_amari == 0:
    print(N_syo*A)
else:
    ans += N_syo*A
    N -= N_syo*(A+B)
    if N <= A:
        ans += N
        print(ans)
    else:
        ans += A
        print(ans)

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

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

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

print(N // (A + B) * A + tail)

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

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 = list(map(int, input().split()))
pair = n // (a + b)
frac = n % (a + b)
frac_red = a if frac >= a else frac
print(pair * a + frac_red)

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

ab = A + B

r1 = N // ab * A
r2 = min(A, N % ab)

print(r1 + r2)

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

s, e = divmod(n, (a + b))

if e >= a:
    print(s * a + a)
else:
    print(s * a + e)

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

cont_num = A+B

k = N // cont_num


adjust_num = N - k*cont_num
add_blue = 0
if adjust_num >= A:
    add_blue = A
else:
    add_blue = adjust_num

print(k*A + add_blue)

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

Solution (Python):

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

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

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

    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()

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

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

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

if list[0]%(list[1]+list[2])==0:
	print((list[0]//(list[1]+list[2]))*list[1])
elif list[0]%(list[1]+list[2])<=list[1]:
	print((list[0]//(list[1]+list[2]))*list[1]+list[0]%(list[1]+list[2]))
else:
	print(list[0]//(list[1]+list[2])*list[1]+list[1])

Solution (Python):
import numpy as np

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

C = A+B
set = N // C

ans = A if (N-C*set) >= A else N-C*set

ans += set*A

print(ans)

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

q, mod = divmod(n, (a+b))
if mod > a:
    print(q*a+a)
else:
    print(q*a+mod)

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(a) for a in input().split()]

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

lastseq = N%(A+B)

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

print(ans)

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

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

AB = A + B
NumABalls = 0

NumABalls = N//AB * A
M = N%AB

if A - M >= 0:
  NumABalls += M
else:
  NumABalls += A

print(NumABalls)

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

g = n // (b+r)
i = n % (b+r)

if b == 0:
    print(0)
elif i > b:
    print(g*b + b)
else: 
    print(g*b + i)

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

Solution (Python):


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

set, mod = divmod(N, (A + B))
ans = set * A

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

print(ans)

Solution (Python):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7

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

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

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


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

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

if a==0:
    print(0)
    
elif b==0:
    print(n)
    
else:
    
    quo=n//(a+b)
    
    
    if n%(a+b)==0:
        rem=0
    elif  1<=n%(a+b)<=a:
        rem=n%(a+b)
    else:
        rem=a
        
    print(quo*a+rem)

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


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


def main():

    sys.setrecursionlimit(10 ** 6)

    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))  
    print(f'{solve(N, A, B)}')


if __name__ == '__main__':
    main()

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

if A == 0:
    print(0)
else:
    i = N // (A + B)
    j = N % (A + B)
    if j >= A:
        count = A * (i + 1)
        print(count)
    else:
        count = A * i + j
        print(count)

Solution (Python):
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()


n, a, b = inpl()
l = n // (a + b)
m = n % (a + b)
print(a * l + min(m, a))


end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Solution (Python):

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


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

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

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

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

print(ans)

Solution (Python):





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


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

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

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

print (ans)

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

Solution (Python):




















































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    
    N, A, B = list(map(int, lines[0].split()))
    
    
    
    
    
    
    
    

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

    result = q*A + min(mod, A)

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['8 3 4']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['8 0 4']
        lines_export = [0]
    if pattern == 3:
        lines_input = ['6 2 4']
        lines_export = [2]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

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

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

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

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

print(ans)

Solution (Python):


M,A,B = map(int,input().split())
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A

if N >= A:
    E+=A
else:
    E+=N
print(E)

Solution (Python):


M,A,B = map(int,input().split())
import math
C = math.floor(M/(A+B))
N = M%(A+B)
E = C*A
A_A = 0
B_B = 0
for i in range(N):
    if N >= A:
        A_A +=A
        N -=A
    else:
        A_A +=N
        break
    if N >= B:
        B_B +=B
        N -=B
    else:
        B_B +=N
        break
print(A_A+E)

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


i = N // (A+B)
b = i*A
t = N % (A+B)
if t > A:
   t = A
print(b+t)

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

i = N // (A+B)
b = i*A
t = N % (A+B)

if t > A:
  t = A
  
print(b+t)

Solution (Python):


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

y = N % (A+B)
if y >= A:
  y = A

print(x + y)

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

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

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

if not ( 1 <= N <= 10**18 and 0 <= A and 0 <= B and 0 < A + B <= 10**18 ): sys.exit()
if not ( isinstance(N,int) and isinstance(A,int) and isinstance(B,int) ): sys.exit()

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

Solution (Python):
import sys


def main():
    input = sys.stdin.buffer.readline
    n, a, b = map(int, input().split())
    if a + b == 0:
        print(0)
    else:
        q, mod = divmod(n, a + b)
        print(q * a + min(mod, a))


if __name__ == "__main__":
    main()

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

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

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

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

n%=a+b

if a<=n:
    ans+=a
else:
    ans+=n

print(ans)

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

Solution (Python):
"""
A = 3, B = 4
[青青青][赤赤赤赤][青青青][赤赤赤]...

N = 8
[青青青赤赤赤赤青]

return 青 = 4
"""

def count_balls():
    
    N, A, B = map(int, input().split())
    
    comb_count = N // (A + B)
    remainder = N % (A + B)
    
    if remainder <= A:
        return A * comb_count + remainder
    else:
        return A * comb_count + A

result = count_balls()
print(result)

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

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

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

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

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

N = n//(a+b)
m = n%(a+b)

print(N*a+min(m,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())

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

print(ans)

Solution (Python):
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
    sys.exit()

if b == 0:
    print(n)
    sys.exit()

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

try:
    blue_num = A * (N // (A + B))
    residue = N - ((A + B) * (N // (A + B)))
    if(residue > A):
        blue_num += A
    else:
        blue_num += residue
except ZeroDivisionError:
    blue_num = 0

print(blue_num)

Solution (Python):

import sys
import collections as cl


def II(): return int(sys.stdin.readline())


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


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N,A,B = MI()
    oneset = A + B

    rep = N // oneset

    print(rep * A + min(N % oneset,A))


main()

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

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

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

print(result)

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



q, mod = divmod(N, A+B)
if mod < A:
    extra = mod
else:
    extra = A
result = q * A + extra

print(result)

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

Solution (Python):
n,a,b = map(int,input().split())
'''
bbbbrrbbbbrr...
n // (a+b) : a+b個の塊がn個のなかにいくつ入っているか
n % (a+b)  : a+b個の列のうち、いくつまで入るか
'''

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

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

num = A if (N%(A+B)) > A else N%(A+B)

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
n,a,b=map(int,input().split())
val = n//(a+b)
pos = n%(a+b)
if pos>a:
    pos = a
print(val*a + pos)

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

total = b + r
num = n // total
rest = n - (num * total)

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

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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

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


if __name__ == '__main__':
    main()

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

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

if x < A:
  print(ans+x)
elif x >= A:
  print(ans+A)

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())
num = int(N/(A+B))
blue = 0

blue = num*A
if (N-num*(A+B)) <= A:
    blue += (N-num*(A+B))
else:
    blue += A

print(blue)

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

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

if q - a >= 0:
    ans += a
if q - a < 0:
    ans = ans + a +(q-a)
print(ans)

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

Solution (Python):
N,A,B=map(int,input().split())
t=N//(A+B)
s=N%(A+B)
ans = t*A + min(s,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())
red = 0 ; blue = 0
if n >= a + b :
    stack = n // (a+b)
    red += b * stack
    blue += a * stack
    n -= (a+b) * stack
if n > a :
    n -= a
    blue += a
else :
    blue += n
if n > b :
    n -= b
    red += b
else :
    red += n
print(blue)

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())
c = a + b

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

print(ans)

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

set_num = n // (a + b)
remain_num = n - (a + b) * set_num

print(set_num * a + min(remain_num, a))

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

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

main()

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

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

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

num1 = n%(a+b)
num2 = n//(a+b)

print(num2*a+min(num1,a))