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

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

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

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

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


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

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+a if n-n//(a+b)*(a+b) >= a else n-n//(a+b)*b)

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

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

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

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

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

m = n // (b+r)

last = min(n-(b+r)*m, b)

print(b*m + last)

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

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())

n,a,b=sep()
k=n//(a+b)
ans=(k*a)
k2=n%(a+b)
if k2<=a:
    ans+=k2
else:
    ans+=a
print(ans)

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

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    c = A + B
    d = N // c
    ans = d * A
    e = N % c
    if e >= A:
        ans += A
    else:
        ans += e
    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())

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

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

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

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

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

ans = k*b+min(p,b)
print(ans)

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

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

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

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

if r >= a:
    res = a
else:
    res = r

print(q * a + res)

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

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

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

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

s = q * a

if r > a:
    s += a
else:
    s += r

print(s)

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

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

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

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

c = a + b
div = n // c
mod = n % c

if mod > a:
    mod = a

ans = div * a + mod
print(ans)

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

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

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

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

ans = line * a
ans += min(a, remain)

print(ans)

Solution (Python):


def main():
    N, A, B = map(int, input().split())
    quo = N // (A + B)
    rem = N % (A + B)

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

    print(ans)

if __name__ == "__main__":
    main()

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

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

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

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

if amari >= A:
    ans=sho*A+A
else:
    ans=sho*A+amari
    
print(ans)

Solution (Python):
N,A,B = list(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())

r=N//(A+B)*A
s=N%(A+B)

x=r+min(A,s)
print(x)

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

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

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

sum = 0



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

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

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

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

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

if r < a:
  ans = a*q + r
else:
  ans = a*q + a
  
print(ans)

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

Solution (Python):

import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    a_count=0
    d,r=divmod(n,a+b)
    a_count+=a*d
    if r > a:
        a_count+=a
    else:
        a_count+=r
    print(a_count)

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

N, A, B = map(int, input().split(' '))
 
ans = 0
if (A + B) != 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A
    if B == 0: ans = N
    elif taple[1] > A: ans += A
    else: ans += taple[1]
 
print(ans)

Solution (Python):

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

ans = 0
if A + B > 0:
    taple = divmod(N, A + B)
    ans = taple[0] * A + min(A, taple[1])

print(ans)

Solution (Python):

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

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

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

if a+b ==0:
    print(0)
else:
    c = n//(a+b)
    d = n%(a+b)

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

Solution (Python):
import sys
import copy
import math
import itertools

a = [int(c) for c in input().split()]
N=a[0]
A=a[1]
B=a[2]

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

cnt += int(N/(A+B))*A
print(cnt)

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

if a+b == 0:
  print(0)
  
else:  

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

  
  if q <= a:
    print(a*d+q)
  else:
    print(a*d+a)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

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

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

s = A + B
q = N // s
r = N % s
if r == 0:
  print(A * q)
elif r < A:
  print(A*q + r)
else:
  print(A*q + A)

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

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

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

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

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

print(result)

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

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

blue = whole * a

if rest <= a:
	blue += rest
else:
	blue += a
	
print(blue)

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

kumi = n // (a + b)

kumi_ao = kumi * a

nokori = n % (a+b)

if nokori <= a:
  nokori_ao = nokori
  
else:
  nokori_ao = a
  
print(kumi_ao+nokori_ao)

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

Solution (Python):
N, A, B = [int(x) for x in input().split()]
n = N//(A+B)
ans = n * A
d = N - n*(A+B)
if d >= A:
  ans += A
else:
  ans += d
print(ans)

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

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

Solution (Python):







e1,e2,e3 = map(int,input().split())






ba1=e1//(e2+e3)
ba2=e1-ba1*(e2+e3)
if ba2<=e2:
    print(ba2+ba1*e2)
elif ba2>e2:
    print(e2+ba1*e2)

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

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

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

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

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

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

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

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

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

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


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

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

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

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

count += int(n/(a+b))*a
count += min(int(n%(a+b)),a)

print(count)

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

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

ans = 0

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

print(ans)

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

ans = 0

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

print(ans)

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

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

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

ans = 0

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

print(ans)

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


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

Solution (Python):
n,blue,red = [int(x) for x in input().split()]
p = n // (blue + red)
r = n % (blue + red)
if r > blue:
  c = blue
else:
  c = r
print(p * blue + c)

Solution (Python):

def main():
    n, a, b = map(int, input().split(" "))
    one_round = a+b
    x = n // one_round
    n = n % one_round
    ans = x * a
    ans += min(n,a)
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):

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

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

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

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

print(X*A+min(A, Y))

Solution (Python):
import math


def main():

    v = list(map(int, input().split()))
    n = v[0]
    a = v[1]
    b = v[2]

    answer = 0
    if n < a:
        answer = n
    elif n < a+b:
        answer = a
    elif a == 0 and b == 0:
        answer = 0
    else:
        answer += math.floor(n / (a+b)) * a
        rest = n % (a+b)
        if rest <= a:
            answer += rest
        else:
            answer += a
    print(answer)


if __name__ == "__main__":
    main()

Solution (Python):

import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // all_ball
rest = num % all_ball
print(count * blue_num + min(rest, blue_num))

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

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

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

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

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

if c<a:
  print(d*a+c)
else:
  print((d+1)*a)

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

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

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

print(ans)

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

Solution (Python):
import math

N, A, B = map(int, input().split())
K = math.floor(N // (A + B))
blue = A * K
L = N % (A + B)
if L > A:
  blue += A
else:
  blue += L
print(blue)

Solution (Python):
n, a, b = [int(i) for i in input().split()]
cnt = n // (a + b) * a
if n % (a + b) >= a:
  cnt += a
else:
  cnt += n % (a + b)
print(cnt)

Solution (Python):
ri = lambda S: [int(v) for v in S.split()]
N, A, B = ri(input())

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

blue = (A * q) + r if r <= A else (A * q) + A
print(blue)

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

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

if x >= 1:
    print(x*a+y)
else:
    print(min(n, a))

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

print(q+t)

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

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

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

cnt_A = i * A

if N < A:
  cnt_A += N
else:
  cnt_A += A
  
print(cnt_A)

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

d = N//(A+B)
z = N%(A+B)

print(d*A+min(z,A))

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

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N, A, B = MI()
    print((N // (A + B)) * A + min(N % (A + B), A))

if __name__ == "__main__":
    main()

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 A == 0:
    print(0)
    exit()

quotient = N // (A + B) * A
remainder = N % (A + B)

quotient += min((remainder, A))

print(quotient)

Solution (Python):
n,a,b=map(int,input().split())
ans=0
m=n//(a+b)
l=n%(a+b)
ans+=m*a
if l<=a:
  print(ans+l)
else:
  print(ans+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())
 
L = []
i = 0
k = 0
j = 0
P = N // (A + B)
Q = N % (A + B)

if A > Q:
    print((P * A) + Q)
else:
    print((P * A) + A)

Solution (Python):

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

quotient=N//(A+B)
remainder=N%(A+B)
quo_bball=quotient*A
if remainder <=A:
    rem_bball=remainder
else:
    rem_bball=A
print(quo_bball+rem_bball)

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

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


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

print(ans)

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

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

s = N // (A + B)
t = N % (A + B)

a = A
if t < A:
    a = t

print(s * A + a)

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

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

print(ans)

Solution (Python):









import os
import sys




def main():
    n, a, b = map(int, input().split())
    tmp = n - n // (a+b) * (a+b)
    ans = n//(a+b) * a
    if tmp <= a:
        print(ans+tmp)
    else:
        print(ans+a)


if __name__ == "__main__":
    main()

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

C = A + B

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

Solution (Python):
r=input().split()
N=int(r[0])
A=int(r[1])
B=int(r[2])
x=N//(A+B)
y=N%(A+B)
if y<=A:
    print(A*x+y)
else:
    print(A*(x+1))

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

Solution (Python):


n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)

if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

Solution (Python):
n, a, b = (int(x) for x in input().split())
if a == 0:
    print('0')
    exit()
count_a = n // (a + b)
leave = n % (a + b)
if leave >= a: leave = a
ans = a * count_a + leave
print(ans)

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd


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

Solution (Python):
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N,A,B = MI()
q = N // (A+B)
r = N % (A+B)
print(q*A+min(r,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 = map(int,input().split())
ans = N//(A+B) * A
ans += min(A, N%(A+B))
print(ans)

Solution (Python):
N, A, B = map(int, open(0).read().split())

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

print(ans)

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

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

    return ans

print(main())

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

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

loop = a+b
l_cnt = n//loop
rem = n%loop

ans = l_cnt*a
if rem < a:
    ans += rem
else:
    ans += a

print(ans)

Solution (Python):
def LI():
    return list(map(int, input().split()))


N, A, B = LI()
x = N//(A+B)
y = N-A*x-B*x
if y >= A:
    ans = (x+1)*A
else:
    ans = x*A+y
print(ans)

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

term = A + B
blue = (N // term) * A

if N - ((N // term) * term) <= A:
    blue += (N - ((N // term) * term))
else:
    blue += A

print(blue)

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

AB = A+B

shou = N//AB

amari = N%AB

ans = shou*A+min(A,amari)

print(ans)

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

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

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

Solution (Python):
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N, A, B = map(int, input().split())
    if A == 0:
        print(0)
        exit()

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


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

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

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

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

Solution (Python):

import sys

input = sys.stdin.readline


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


N, A, B = MI()

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

if r > A:
    print(q * A + A)
else:
    print(q * A + r)

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

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

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print((m1 + 1) * a )
  else:
    print(m1 * a + m2)

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

s = N // (A+B)

t = N % (A+B)

k = 0

if t <= A:
  k = t
else:
  k = A

print(s*A+k)

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

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

print(ans)

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

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

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

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: 
	print((number_turn * A) + nokori)
else: 
	print((number_turn * A) + A)

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

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

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

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

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

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

Solution (Python):


import numpy as np
import sys
N,A,B=map(int,input().split())

count=int(N/(A+B))
s=N%(A+B)

if s<=A:
    print(A*count+s)
else:
    print(A*count+A)

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

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

ans = N // (blue + red) * blue
rem = N % (blue + red)
ans += min(rem, blue)
print(ans)

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

Solution (Python):
import sys
import numpy as np
import math as mt

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Solution (Python):

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

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


if __name__ == '__main__':
    main()

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

ablen = A + B
n = int(N / int(ablen))
num = A * n
m = N % int(ablen)
num += min(m, A)
print(num)

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

Solution (Python):
def resolve():
    N, A, B = list(map(int, input().split()))
    base = (N // (A+B)) * A
    rem = N - (N//(A+B))*(A+B)
    ans = base
    ans += A if rem >= A else rem
    print(ans)


if '__main__' == __name__:
    resolve()

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())
if A==0:
  print(0)
  exit(0)

x = N//(A+B)
y = (N - x*(A+B))
blue=x*A + (A if y>=A else y%A)
print(blue)

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

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

pair = N // (A + B)
remain = N % (A + B)

print(A * pair + min(remain, A))

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

pair = N // (A + B)
remain = N % (A + B)

if remain > A:
    print(A * pair + A)
else:
    print(A * pair + remain)

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

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

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

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

n = N%(A+B)

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

Solution (Python):

import sys
input = lambda: sys.stdin.readline().strip()
n, a, b = [int(x) for x in input().split()]
print(a * (n // (a + b)) + min(a, n % (a + b)))

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

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

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

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

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

print(ans)

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

kotae= N//(A+B)*A
am = N%(A+B)

if am>A:
	am=A

print(kotae+am)

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

Solution (Python):
n, a, b = map(int, 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())
a_b = n//(a+b)*a
if n%(a+b) < a:
    print(a_b + n%(a+b))
else:
    print(a_b + a)

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

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