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):
o=input().split()
n=int(o[0])
a=int(o[1])
b=int(o[2])

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

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

print(str(ans)+'\n')

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

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

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

ans = (n//c)*a
l = n%c
if a>l:
  ans += l
else:
  ans += a
  
print(ans)

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):
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


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

main()

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

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

if a>=q:
  answer=(a*r)+q
else:
  answer=a*(r+1)
  
print(answer)

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

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

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

cycle = a + b

count = (n // cycle) * a
if n % cycle == 0:
    pass
elif n % cycle < a:
    count += n % cycle
else:
    count += a

print(count)

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

print(q+r)

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

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

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

Times = N // (A + B)
rest = N - Times * (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)

Solution (Python):
def B():
    N, A, B = map(int, raw_input().split())
    nf = N // (A + B)
    return nf * A + min(N - nf * (A + B), A)

print(B())

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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + A
else:
	sum =c * A + rem

print(sum)

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

div, mod = divmod(n, a+b)
ans = div*a+(mod if mod < a else a)
print(ans)

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

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

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

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

count_blue = 0

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

if amari > A:
    count_blue = A * syou + A
else:
    count_blue = A * syou + amari

print(count_blue)

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

c = a + b
d = n // c
e = n % c

if e >= a:
    f += a

else:
    f += e

count = a * d + f
print(count)

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):
inf = input().split()
info = list(map(int, inf))
o = info[1] + info[2]
if o == 0:
    print(0)
else:
    q, mod = divmod(info[0], o)
    if mod > info[1]:
        print((q+1)* info[1])
    else:
        print(q*info[1] + mod)

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

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

phrase = A + B

ans = N // phrase * A
ans += N % phrase if N % phrase <= A else A
print(ans)

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


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 = [int(x) for x in input().strip().split()]
p = N // (A + B) * A
q = N % (A + B)
if q > A:
    q = A
print(p + q)

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

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

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

if amari >= a:
    tsuika = a
else:
    tsuika = amari

ans = syou * a + tsuika

print(ans)

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

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

Solution (Python):
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i
print(count)

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

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

q, r = divmod(N, A + B)
res = q * A + A if r > A else q * A + r

print(res)

Solution (Python):
N, A, B = map(int, input().split())
if (A == 0):
    print('0')
elif (B == 0):
    print(N)
else:
    sum = A + B
    div = N // sum
    mod = N % sum
    plus = mod - A
    if (plus > 0):
        ans = div*A + A
        print(ans)
    else:
        ans = div*A + mod
        print(ans)

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):
def CountBall_158():
    N, A, B = [int(_) for _ in input().split()]
    X = int(N / (A + B))
    Y = int(N % (A + B))
    if Y > A:
        Y = A
    print(A * X + Y)

if __name__ == "__main__":
    CountBall_158()

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

Solution (Python):




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

    r1 = n // (a + b)
    r2 = n % (a + b)

    r = r1 * a + min(r2, a)
    print(r)


if __name__ == '__main__':
    main()

Solution (Python):
nancy,alpha,beta = map(int,input().split())
delta = nancy // (alpha+beta)
echo = nancy % (alpha+beta)
print(delta * alpha + min(echo, alpha))

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

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

if n < a + b:
    print(min(a, n))
else:
    m = n % (a + b)
    d = n // (a + b)
    print(d * a + min(a, m))

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

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

print(value)

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

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, blue, read = [int(i) for i in input().split() ]

step1 = (N // (blue + read)) * blue
if N % (blue + read) <= blue:
  step2 = N % (blue + read)
else:
  step2 = blue
result = step1 + step2
print(result)

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

c=a+b

q, mod=divmod(n,c)

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


print(A)

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

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

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

Solution (Python):

import os, sys

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


rep = N // (A+B)
rest = N - (A + B) * rep


ans = A * (rep) + min(rest, A)

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

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

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

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

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

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

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

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

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

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

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

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

ans = q * a + m if m < a else q * a + a

print(ans)

Solution (Python):
Nf,Af,Bf = (input().split(' '))
N = int(Nf)
A = int(Af)
B = int(Bf)
a = N % (A + B)
b = N // (A + B)

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

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

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

cnt = a*r + min(n - r*(a+b), a)

print(cnt)

Solution (Python):
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
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
ad = n%(a+b)
ans = ans + ad if ad < a else ans + a
print(ans)

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

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

blue_num = 0

if amari < A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A

print(blue_num)

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

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

blue_num = 0
if amari <= A:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + A
    
print(blue_num)

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

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

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

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

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

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

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

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

print(ball)

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

if N <=A:
    print(N)
    sys.exit()
if N <= (A+B):
    print(A)
    sys.exit()

count = 0

most = N//(A+B)
amari = (N - (A+B)*most)

if amari <= A:
    print((most*A) + amari)
else:
    print((most*A) + A)

Solution (Python):
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')


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

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

l=min(m,a)

print(k*a+l)

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)

if mod > A:
  mod = A

print(q*A+mod)

Solution (Python):




n, b, r = map(int, input().split())
total = b+r
circle = n//total
diff = n % total
if b <= diff:
    print(b + circle*b)
else:
    print(diff + circle*b)

Solution (Python):




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

Solution (Python):




n, a, b = map(int, input().split())
total = a+b
diff = n-((n//total)*total)
omake = n//total*a
if a <= diff:
    print(a+omake)
else:
    print(diff+omake)

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

Solution (Python):
import sys

ball = list(map(int, input().split()))

if ball[1] == 0:
    print(0)
    sys.exit()

if ball[2] ==0:
    print(ball[0])
    sys.exit()

number = ball[0]%(ball[1]+ball[2])

if number > ball[1]:
    number = ball[1]

print((ball[0]//(ball[1]+ball[2]))*ball[1]+number)

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

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

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

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

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

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

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

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

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

mod = n % (blue+red)
if mod <= blue:
    print(blue*(n//(blue+red))+mod)
else:
    print(blue*(n//(blue+red))+blue)

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

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

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

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

X = math.floor(N/(A+B))

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

Solution (Python):
import math

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

QUO = math.floor(N / (A + B))

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

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

Solution (Python):
import sys
import os


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

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os


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

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A) if m > A else A*n + m)


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=input().split()
N=int(N);A=int(A);B=int(B);

bai=int(N/(A+B))
amari=N%(A+B)


if amari>A:
    nokoriA=A
else:
    nokoriA=amari

sumA=bai*A+nokoriA
print(sumA)

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

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

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

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

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

if A >= rem:
  ans = quo * A + rem
else:
  ans = (quo + 1) * A

print(ans)

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

count = n // (blue + red)
amari = n % (blue + red)

if amari > blue:
    amari = blue

print(amari + count * blue)

Solution (Python):



from math import floor

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)

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

quotient = n //(a+b)
remain = n % (a+b)

if remain > a:
    remain = a

print(remain + quotient*a)

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

pattern = (n // (a + b)) * a
diff = n % (a + b)

count = 0
count += pattern + min(a, diff)

print(min(count, a * (10 ** 100)))

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

if a == 0:
    print(0)
elif a+b >= n:
    print(a) if a <= n else print(n)
else:
    ab = a + b
    ans = n // ab * a
    ans += a if n % ab > a else n % ab 
    print(ans)

Solution (Python):

n, a, b = list(map(int, input().split()))
count = -1
if n == 0:
    count = 0
else:
    e_1 = int(n / (a+b)) * a
    e_2 = min(n%(a+b), a)
    count = e_1 + e_2
print(count)

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

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

if A[0]%(A[1]+A[2])>=A[1]:
  amari = A[1]
else:
  amari = A[0]%(A[1]+A[2])
print(A[0]//(A[1]+A[2])*A[1] + amari)

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

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

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

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

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

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

reply = text[0] // (text[1] + text[2]) * text[1]

reply += text[1] if text[0] % (text[1] + text[2]) > text[1]else text[0] % (text[1] + text[2])

print(reply)

Solution (Python):


N,A,B = map(int,input().split())
syou = N//(A+B)
amari = N%(A+B)
if amari>A:
  amari=A
ans = syou*A+amari
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() )

x = (N // (A + B)) * A 
mod = N % (A + B)
if mod <= A :
    z = mod
else :
    z = A

print(x + z)

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

sum = A + B
ans = int(N / sum)
les = N % sum

if les < A:
    print(ans * A + les)
else:
    print(ans * A + A)

Solution (Python):
import math
input_line = input().split()

N = int(input_line[0])
A = int(input_line[1])
B = int(input_line[2])
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 = 0
d = a+b
if a==0:
    print(0)
else:   
    q, mod = divmod(n, d)
    if mod<=a:
        print(q*a +mod)
    else:
        print(q*a +a)

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

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

Solution (Python):
n, a, b = map(int, input().split())
ab = a + b
nab = n // ab
jouyo = n % ab

if ab == n:
    print(a)
elif a == 0:
    print(a)
elif ab < n:
    naba = nab * a
    if jouyo <= a:
        print(naba + jouyo)
    else:
        print (naba + a)
elif ab > n:
    if n <= a:
        print(n)
    else:
        print(a)

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

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

N %= A + B

ans += A if N > A else N

print(ans)

Solution (Python):
from sys import stdin
N, A, B = [int(_) for _ in stdin.readline().rstrip().split()]
ans = N // (A + B) * A
mod = N % (A + B)
ans += min(A, mod)
print(ans)

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


sum=0

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

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

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

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

z = x * A + min(y, A)

print(z)

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

else:
  res += n - (a + b) * d
print(res)

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

number = n // (blue + red)          
count_blue = number * blue          
number2 = n - number * (blue + red) 
if blue ==0:
    print("0")
    exit()
if number2 > blue:
    count_blue += blue
else:
    count_blue += number2

print(count_blue)

Solution (Python):
args = input()
nums = args.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
blue_calc = int(n / (a + b))
blue_mod = n % (a + b)
if blue_mod < a:
  print(a * blue_calc + blue_mod)
  exit()
print(a * blue_calc + a)

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

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


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

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())
c = (n//(a+b))*a
d = n%(a+b)
if d >a:
    d = a
print(c+d)

Solution (Python):
N=[int(e) for e in input().split()]
A=N[0]//(N[1]+N[2])*N[1]
M=N[0]%(N[1]+N[2])
if N[1]>M:
    A+=M
else:
    A+=N[1]
print(A)

Solution (Python):
import math

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

num = math.floor( n/(a+b) ) * a

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

print(num)

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

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

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

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N,A,B=map(int,input().split())
C=A+B
D=N//C
count=D*A
N=N-C*D
while N>0:
    N=N-A
    if N>0:
        count=count+A
    elif N<=0:
        count=count+(A+N)
        break
    N=N-B
    if N<=0:
        break
    else:
        pass
print(count)

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

Solution (Python):
import math
list = input().rstrip().split(" ")
n = int(list[0])
a = int(list[1])
b = int(list[2])
n_num = n / (a + b) 
n_number = int(math.floor(n_num)) 
a_num = n_number * a 
n_amari = n % (a + b) 
n_min_a = n_amari - a 
if n_min_a >= 0:
  a_total = a_num + a
else:
  a_total = a_num + n_amari
print(a_total)

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

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

ans = A * shou

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

print(ans)

Solution (Python):
a,b,c=input().strip().split(" ")
a,b,c=[int(a),int(b),int(c)]
p=b+c
x=a//p
m=a%p
pp=min(b,m)
print(pp+x*b)

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

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

Solution (Python):



st = input().split()

div = int(st[0]) // (int(st[1]) + int(st[2]))

rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + int(st[1]))

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

Solution (Python):

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


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

f = n // (a+b)
g = n % (a+b)

if g <= a:
    print(a * f + g)
    
else:
    print(a * (f+1))

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

Solution (Python):
from sys import stdin


def get_result(data):
    N, A, B = data
    if A == 0:
        return 0

    remainder = N % (A+B)
    tmp = remainder if remainder < A else A
    quotient = N // (A+B)
    ans = A * quotient + tmp
    return ans


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)

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

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

c = a + b

ans = n // c * a

if(n%c <= a):
  ans += n%c
else:
  ans += 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())

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

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

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

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

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

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

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

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

print(ans)

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

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

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

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)

Solution (Python):

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

C=A+B
D=N//C
E=N-C*D

ans=A*D

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


print(ans)

Solution (Python):
import sys
readline = sys.stdin.readline
n, a, b = [int(x) for x in readline().strip().split(" ")]
ans = n // (a + b) * a
amari = n % (a + b)
if amari > a:
    print(ans + a)
else:
    print(ans + amari)

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

Solution (Python):
from math import floor


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

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

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

print(ans)

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

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

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

Solution (Python):






st = input().split()

div = int(st[0]) // (int(st[1]) + int(st[2]))

rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + int(st[1]))

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

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

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

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

Solution (Python):

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

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

print(blue)

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

set = blue+red
if blue == 0:
  end = 0
else:
  end = blue*int(stop/set)+min(stop%set,blue)
print(end)