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

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

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

    print(ans)





if __name__ == '__main__':
    main()

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

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

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

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

se=n//(a+b)
am=n%(a+b)

print(se*a+min(a, am))

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

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N,A,B = input_int()

temp_B = N%(A+B)
temp_A = N//(A+B)



print(temp_A * A + min(temp_B, A))

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

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

n1=N//(A+B)
n2=N%(A+B)

print(int(n1*A+min(n2,A)))

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

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

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

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

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

Solution (Python):



def count_blue_balls(n, a, b):
    d, m = divmod(n, a + b)
    num_blues = d * a + min(a, m)
    return num_blues


def main():
    n, a, b = (int(z) for z in input().split())
    res = count_blue_balls(n, a, b)
    print(res)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

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

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

c = A + B

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

ans = 0
cnt = N // c
ans += cnt * A
N -= cnt * c

ans += min(N, 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):
N, A, B = map(int, input().split())

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

if mod > A:
    ans = (shou * A) + A
else:
    ans = shou * A + mod

print(ans)

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

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


if __name__ == "__main__":
    main()

Solution (Python):

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

S = A+B

if S==0:
  print(0)
else:
  Q = N//S
  R = N%S
  if R>=A:
    print((Q+1)*A)
  else:
    print(Q*A+R)

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

v = N // (A + B)
amari = N % (A + B)
r = v * A
if amari > A:
    r += A
else:
    r += amari

print(r)

Solution (Python):
N,a,b=map(int,input().split())
x=N//(a+b)
y=N%(a+b)
ans=x*a
if a+1<=y<=(a+b-1):
  ans+=a
else:
  ans+=y
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 = A + B
c, d = divmod(N, M)
ans = c * A + min(d, 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())
sum = A + B
ans = A * (N // sum) + min(A, N % sum)
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):
N, A, B = map(int, input().split())

A_B = A + B

sho = N // A_B

ama = N % A_B

if ama > A:
    print((sho+1)*A)
else:
    print(sho*A + ama)

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

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

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

loop = n // (a+b)
count = a * loop
residue = n - loop * (a+b)

if residue >= a:
    residue = a

count += residue
print(count)

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

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

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

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

Solution (Python):

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

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

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

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

Solution (Python):


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

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

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

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

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

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

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

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

k = N // (A+B)
l = N % (A+B)

ans = k * A + min(l,A)

print(ans)

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

c = A + B
d = N // c
e = N % c
a, b = d*A, d*B
a += min(e, A)
b += max(0, min(e-min(e, A), B))
print(a)

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




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

if __name__ == '__main__':
    main()

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

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

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

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

s = (A+B)*k

if N - s <= A:
    print(ans + (N - s))
else:
    print(ans + A)

Solution (Python):










import math
import statistics
import string


def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

N, A, B = splitintinput()
amari = 0
ans = 0
ans += A * int(N/(A+B))

amari = N%(A+B)

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

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

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

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

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

Solution (Python):
N, A, B = [int(i) for i in input().strip().split(" ")]
if A == 0:
  print(0)
else:
  w = N // (A+B)
  r = N % (A+B)
  if r > A:
    r = A
  print(w*A+r)

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

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

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

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

Solution (Python):
import sys
n,a,b=map(int,input().split())
if a==0 and b==0:
    print(0)
    sys.exit()
seq=a+b
if n % seq==0:
    print(n//seq * a)
else:
    print(n//seq *a+ min(n%seq,a))

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


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

print(result)

Solution (Python):


if __name__ == '__main__':
    n, a, b = map(int, input().split())

    c = n // (a + b)

    ans = c * a

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

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

    print(ans)

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

print(main())

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

Solution (Python):

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

ab = a+b
r1 = (n//ab)*a
r2 = min((n%ab),a)
print(r1+r2)

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

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

Solution (Python):

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

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

print(r1)

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

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


main()

Solution (Python):
from sys import stdin
def main():
    readline=stdin.readline
    N,A,B=map(int,readline().split())
    s=A+B
    l=N//s
    r=N%s
    res=l*A+min(r,A)
    print(res)
if __name__=="__main__":
    main()

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

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

d, r = divmod(N, A + B)
print(d * A + min(r, 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())

n_AB = N // (A + B)

N_tmp = N % (A + B)
n_A = min(A, N_tmp)

N_tmp -= n_A
n_B = min(N, N_tmp)

print(n_AB * A + n_A)

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

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

Solution (Python):

import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '
    return ret


N, A, B = read_ints()
ab = A + B
syou, amari = divmod(N, ab)
print(syou * A + min(amari, A))

Solution (Python):
import sys
import math
import collections

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



c = a + b
d = math.floor(n / c)
e = n % c

ans = d * a
ans += min(e, a)
print(ans)

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

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

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

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

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

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

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

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

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

Solution (Python):



import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

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

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

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

K=N//(A+B)

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

Solution (Python):
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, A, B = lr()
    r = N%(A+B)
    if r <= A:
        print(N//(A+B)*A+r)
    else:
        print(N//(A+B)*A+A)
resolve()

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

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

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

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

ans = repeat*A

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

print ans

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

T = A + B
k = N // T
rem =  N % T
print(k * A + min(rem, A))

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

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

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

print(ans)

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

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

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

Solution (Python):
def main():
    import sys
    
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    
    from itertools import combinations, permutations
    
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    

    

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



if __name__ == '__main__':
    main()

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

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

Solution (Python):



def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    

    def dump(*args):
        sys.stderr.write(str(args))

    n, a, b = map(int, input().split())
    loo = n // (a + b)
    wa = n - loo * (a + b)
    

    print(loo*a+min(wa, a))


if __name__ == '__main__':
    main()

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

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

print(shuki*a+ min(n-(shuki*(a+b)), a))

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

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

print(ans)

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())
ans=0
ans+=N//(A+B)*A
C=N-N//(A+B)*(A+B)
if C>A:
    ans+=A
else:
    ans+=C
print(ans)

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

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

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007




def main():
	N,A,B = inputMap()

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

	print(ans)








def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y



def H(n, r, mod=10**9+7):
	
	
    return combination(n+r-1, r, mod)

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        
        
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

if __name__ == "__main__":
	main()

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


groups = N // (A+B)

amari = N % (A+B)


if amari > A:
  print(groups*A + A)
else:
  print(groups*A + amari)

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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,a,b=LI()

  ab=a+b
  c=n//ab

  return c*a+min(n%ab,a)


print(main())

Solution (Python):
def main():
    import numpy as numpy
    import sys
    n,a,b=list(map(int,sys.stdin.readline().split()))

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



main()

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

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

print(answer)

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

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

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

print(ans)

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

    if am < a:
        ans += am
    else:
        ans += a
    print(ans)

Solution (Python):


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


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

ans = loops * a
ans += min(amari, a)

print(ans)

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

Solution (Python):


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

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 7)

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

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

print(ans + min(A, c))

Solution (Python):
import sys

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

def main():
    c = a + b 
    q, r = divmod(n, c)
    res = a * q + min(a, r)
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

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

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

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

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

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

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

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

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

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

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

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

k = n//(a+b)

ans = k*a

p = n%(a+b)

ans += min(a,p)
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())

t = N // (A+B)
b1 = t * A
r = N - (A+B) * t
b2 = min(r, A)
print(b1 + b2)

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

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

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

print(ans)

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

print(ANS)

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

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

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

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

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

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

print(ret)

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

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

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

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

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

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

Solution (Python):


iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, A, B = iim()
    ans = A * (N // (A+B))
    ans += min(A, N % (A+B))
    print(ans)

if __name__ == "__main__":
    resolve()

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math

import itertools



import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default






def main():
    n,a,b=map(int,input().split())
    mato=a+b
    amari=n%mato
    kazu=n//mato
    temp=0
    if amari<=a:
        temp=amari
    else:
        temp=a
    print(kazu*a+temp)


if __name__ == "__main__":
    main()

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

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

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

print(cnt)

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


if __name__ == '__main__':
    main()

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

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

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

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

ans=c*a+min(d,a)
print(ans)

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

Solution (Python):

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

num = n // (a + b)
res = n % (a + b)

if res > a:
    print(num * a + a)
else:
    print(num * a + res)

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

x = N // s 
y = N % s

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

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

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

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rep=N//(A+B)
    ans+=rep*A
    res=N-rep*(A+B)
    ans+=min(res,A)
    print(ans)

main()

Solution (Python):

N,a,b=map(int,input().split())
num=N//(a+b)
x = N-num*(a+b)
res = num*a
if a<=x:
    res += a
else:
    res += x
print(res)

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

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

n, a, b = get_ints()
cycle = n // (a + b)
rest = min(a, n - cycle * (a + b))
print(cycle * a + rest)

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

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

print(res)