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, C =(input()).split(" ")

N=(int)(N)
A=(int)(A)
C=(int)(C)

kumi = A+C
kumi_syou = N//kumi
kumi_num = N%kumi

ans = kumi_syou*A

if kumi_num<A:
    print(ans+kumi_num)
else:
    print(ans+A)

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

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

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

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

comb = A+B
n = N//comb

nn = n*comb
dif = N - nn

if dif >= A:
  ans = (n+1)*A
else:
  ans = n*A + dif

print(ans)

Solution (Python):
import math
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
if N%(A+B)!=0:
    repTimes = math.floor(N//(A+B))
    bB = repTimes*A
    if N%(A+B) > A:
        extra = A
    else:
        extra = N%(A+B)
    bB += extra
else:
    repTimes = math.floor(N//(A+B))
    bB = repTimes * A
print(bB)

Solution (Python):
import math

N,A,B =input().split()
N = int(N)
A = int(A)
B = int(B)
count = divmod(N,A+B)
result = count[0]*A
if count[1]<=A:
    result+=count[1]
elif count[1]>A:
    result+=A

print(result)

Solution (Python):




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

    print(cell * A + min(mod, A))


if __name__ == "__main__":
    main()

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

    ao_count = 0

    count_num = N // (A + B)
    amari_num = N % (A + B)



    ao_count = count_num * A

    if A <= amari_num:
        ao_count += A
    else:
        ao_count += amari_num

    print(ao_count)



if __name__ == "__main__":
    resolve()

Solution (Python):
def main():
    N,A,B = map(int,input().split())
    a = N//(A+B)
    b = N - (a * (A+B))
    if b >= A:
        print(a*A+A)
    elif b < A:
        print(a*A+b)

if __name__ == "__main__":
    main()

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

AB = A + B

def blue(n):
    if n <= A:
        return n
    else:
        return A


if A == 0:
    print(0)
elif N <= AB:
    r = blue(N)
    print(r)
else:
    t = N // AB
    m = N % AB
    r = blue(m)
    print(t*A+r)

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

iteration = int(N/(A+B))
extra = N - iteration*(A+B)
extra_A = extra
if extra > A:
    extra_A = A
print(iteration*A+extra_A)

Solution (Python):



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

x = n // (b + r)

if n % (b + r) > b:
    print(x * b + b)
    
else:
    print((x * b) + (n % (b + r)))

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

Solution (Python):

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

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

print(blue_num)

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

s=n%(a+b)
w=int(n/(a+b))

if(s<a):
    print(w*a+s)
else:
    print((w+1)*a)

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

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

print(ans)

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

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

Solution (Python):
N, A, B = map(int, input().split())
if A == 0:
    print('0')
elif B == 0:
    print(N)
else:
    tmp = N // (A + B)
    result = tmp * A
    N -= tmp * (A + B)
    if N > A:
        result += A
    else:
        result += N
    print(result)

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

s = int(n / (a + b))

if n % (a + b) == 0:
  print(a * s)
else:
  rem = n % (a + b)
  if rem <= a:
    ans = a * s + rem
  else:
    ans = a * s + a
  print(ans)

Solution (Python):
n,a,b=map(int,input().split())
if a == 0:
  print(0)
  exit()
  
d = n//(a+b)
o = n-(d*(a+b))
if o == 0:
  print(d*a)
elif o < a:
  print(d*a+o)
else:
  print(d*a+a)

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

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

remainder=N%(A+B)

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

Solution (Python):


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


part = n//(a+b)
aa = a*part
rest = n%(a+b)
if rest >= a:
    print(aa+a)
else:
    print(aa+rest)

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

Solution (Python):
import math
n, b, r = map(int,input().split())
count = math.floor(n / (b + r))
amari = n % (b + r)
print(count * b + min(b, amari))

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











cnt=n//(a+b)
ans+=cnt*a
ama=n%(a+b)
if ama-a>=0:ans+=a
else:ans+=ama
print(ans)

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

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

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

c = n // (a+b)

res = c*a +(n%(a+b) - max(n%(a+b) - a ,0))

print(res)

Solution (Python):
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, A, B = MAP()



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

blues = sets * A + min(remain, A)
print(blues)

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

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

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

if __name__ == '__main__':
    main()

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

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


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

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

Solution (Python):


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



matmari = A + B

times = N / matmari



amari = (N - matmari * times)

if amari > A:
    remain = A
else:
    remain = amari

print (times * A) + remain

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

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

br = b + r

a = int(n / br)
a_ = n % br

print(a * b + (b if a_ >= b else a_))

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

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

print(ans)

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



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

f2 = N % (A + B)


if f2 > A:
  print(f1 + A)
else:
  print(f1 + f2)

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

x = N // (A + B)
y = N - (A+B)*x

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

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

ans = n //(a+b)

if n%(a+b) >= a:
  ans2 = a
elif n%(a+b) <a:
  ans2 = n%(a+b)
  
  
print(ans*a+ans2)

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

if a==0:
    print("0")
    exit()
elif b==0:
    print(n)
    exit()

t1=(n//(a+b))
t2=(n%(a+b))

if t2>a:
    print((t1*a)+a)
else:
    print((t1*a)+t2)

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

Solution (Python):
def conv(a):
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def main(n,blue,red):
    blueall = int(n/(blue + red))*blue
    n = n - (int(n/(blue + red))*(blue+red))
    if n >= blue:
        return blueall + blue
    else:
        return blueall + n
n,a,b = conv(input().split())
print(main(n,a,b))

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

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

Solution (Python):
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

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

    
    
    
    
    k = n // (a+b)
    eprint(k)
    eprint(min(n-(k*(a+b)), a))
    print(a*k + min(n-(k*(a+b)), a))
    return 

if __name__ == '__main__':
    main()

Solution (Python):
a, b , c = input().split()
ans = 0

n = int(a)
blue = int(b)
red = int(c)

if blue == 0:
  print("0")
elif red == 0:
  print(n)
else:
  if n%(blue+red) >= blue:
  	ans += (n//(blue+red))*blue + blue
  else:
  	ans += (n//(blue+red))*blue + n%(blue+red)
  print(ans)

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

c = a+b
S1 = n//c*a

S2 = n%c

if S2 > a:
    ans = a
else:
    ans = S2

print(S1+ans)

Solution (Python):
import math
a = input().split(" ")
res = int(a[0])
div = int(a[1])+int(a[2])
mult = math.floor(res/div)
plus = res%div
answer = int(a[1])*mult + min([plus,int(a[1])])
print(answer)

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

Solution (Python):
n,a,b=[int(v) for v in input().split()]
try:
    loop=n//(a+b)
except:
    loop=0
try:
    remainder=n%(a+b)
except:
    remainder=0
print(loop*a+min(remainder,a))

Solution (Python):
n, a, b = map(int,input().split())
count = 0
c = n // (a+b)
c2 = n % (a+b)

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

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

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

alpha = A if mod >= A else mod

print(q * A + alpha)

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

Solution (Python):
nab=list(map(int, input().split()))
n=nab[0]
a=nab[1]
b=nab[2]
answera=n//(a+b)
remainder=n%(a+b)
if(remainder<=a):
    answer=answera*a+remainder
else:
    answer=answera*a+a
print(answer)

Solution (Python):
f = [int(i) for i in input().split()]
n = f[0]
a = f[1]
b = f[2]

m = n // (a+b)
tmp = m * a
mod = n%(a+b)
print(tmp+min(mod,a))

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

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+1)*A)

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

a_extra = 0
amari = N%(A+B)
if amari > A:
  a_extra = A
else:
  a_extra = amari

goukei = N//(A + B)*A + a_extra
print(goukei)

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

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

if y > a:
  y = int(a)
  

print(int((x*a)+y))

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

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

AB = A + B

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

ans = A * (N // AB)
ans_mod = N % AB 

if ans_mod == 0:
    print(ans)
    sys.exit()

if ans_mod >= A:
    ans += A
elif ans_mod < A:
    ans += ans_mod

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

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

  print( int(n / (a+b)) * a + d )

Solution (Python):


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

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

print((A * q) + min(mod, A))

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

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

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

print(ans)

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

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

bl = int(n / (a + b))
m = n % (a + b)

if m >= a:
    m = a

r = (bl * a) + m
print(r)

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

Solution (Python):


def solve():
    N, A, B = list(map(int, input().split()))
    ans = (N//(A+B))*A
    N -= (N//(A+B))*(A+B)

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



if __name__ == "__main__":
    solve()

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

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

D = N - (A+B) * C

if D > A:
    E = A
    F = D - A
else:
    E = D
    F = 0

ans = C * A + E

print(ans)

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

s  = nab[0]//(nab[2]+nab[1])*nab[1]
am = nab[0]%(nab[1]+nab[2])

if am>nab[1]:
    s +=  nab[1]
elif nab[1]==0 :
    s = 0
else:
    s+= am

print(int(s))

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

if r >= A:
  print(A*n+A)
else:
  print(A*n+r)

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

set_num = A + B
set_iter_num = N // set_num
r = N % set_num

if r >= A:
    r_blue = A
else:
    r_blue = r

blue = set_iter_num *  A + r_blue
print(blue)

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

Solution (Python):
from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
import bisect
import heapq as hq

def main():
    try:
        n,a,b=In()
        temp=a+b
        t=n//temp
        t=(a*t)
        n=n%temp
        if n<=a and n>0:
            t+=(n)
        elif n>a:
            t+=(a)
        print(t)
    except:
        pass
def add(a, b, c):
    res = a + b;
    if (res >= c):return res - c;
    else:return res;
def mod(a, b, c):
    res = a * b
    if (res >= c):return res % c
    else:return res
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    w = a // gcd(a, b)
    return w * b
def expo(a, b):
    x, y = 1, a
    while (b > 0):
        if (b & 1):
            x = x * y
        y = y * y
        b >>= 1
    return x
def power(a, b, m):
    x, y = 1,
    while (b > 0):
        if (b & 1):x = mod(x, y, m)
        y = mod(y, y, m)
        b >>= 1
    return x
def L():
    return list(map(int, stdin.readline().split()))
def In():
    return map(int, stdin.readline().split())
def I():
    return int(stdin.readline())
P = 1000000007


if __name__ == '__main__':
    main()

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

num_ball = A + B
sets = N // (A + B)



last_balls = min(A, N % num_ball)

result = sets * A + last_balls

print(result)

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    count = int(N/(A + B))
    print(A * count + min(N-(A+B)*count, A))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

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

C = A + B

ans = 0

syou = N // C
amari = N % C

ans = syou * A


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

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

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


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

	res = 0
	
	if N<C:
		res = min(A,N)
	else:
		res = (N//C) * A
		res += min(N%C, A)
	
	
	
	
	print(res)
	
if __name__ == "__main__":
    main()

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



if A == 0 and B == 0:
    ans = 0
else:
  sho = N // (A+B)
  mod = N % (A+B)
  if mod > A:
  	ans = A * sho + A
  else:
  	ans = A * sho + mod

print(ans)

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

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

k = int(n / (blue + red))
kk = n % (blue + red)
print(k*blue + min(blue, kk))

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

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

print(ans)

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

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

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

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

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

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

Solution (Python):


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

temp = n // (a + b)
amari = n % (a + b)
result = temp * a

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

print(result)

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

res = int(n/(a+b)) * a

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

print(int(res))

Solution (Python):
a = list(map(int,input().split()))
b = a[0]//(a[1]+a[2])
c = a[0]%(a[1]+a[2])
if c<=a[1]:
    e=c
else:
    e=a[1]


d = a[1]*b + e

print(d)

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

cnt = int(N / (A + B))
rest = N % (A + B) 
if A == 0:
    print(0)
elif rest > A:
    print(cnt*A + A)
else:
    print(cnt*A + rest)

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

waru = n // (a + b)

amari = n % (a + b)

ans = a * waru

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

if a == 0:
    print(a)
else:
    print(ans)

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

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

if mod >= a:
    ans = num * a + a
elif mod < a:
    ans = num * a + mod

print(ans)

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

u = n // (a+b)
z = n % (a+b)
c = u * a
if a > z:
    ans = c + z
else:
    ans = c + a

print(ans)

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

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

ans = A*r

if s <= A:
    ans += s
elif s > A:
    ans += A


print(ans)

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

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


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



if __name__ == "__main__":
    main()

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

Solution (Python):

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

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

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

loops = n // (a + b)
ans = loops * a
remain = n - loops * (a + b)

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

print(ans)

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

Solution (Python):

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

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

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    x = N // (A+B)
    r = N % (A+B)

    ans = A * x + r
    if r >= A:
        ans -= (r - A)

    print(ans)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    solve(N, A, B)

if __name__ == '__main__':
    main()

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

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

x = n // (a+b)
c = a * x
n -= (a+b)*x
while n > 0:
    n = n - a
    if n > 0:
        c += a
    else:
        c += a+n
    n = n - b
print(c)

Solution (Python):

import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

if(irest>A):
    print((i+1)*A)
else:
    print(i*A+irest)

Solution (Python):
x = input().split(' ')
N = int(x[0])
A = int(x[1])
B = int(x[2])
o = int(N/(A+B))
x = int(N%(A+B))
print(int(o*A)+min(A,x))

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

Solution (Python):

import sys


def solve(N: int, A: int, B: int):
    dev = N // (A+B)
    rem = N % (A+B) if N % (A+B) <= A else A
    return A*dev + rem



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

if __name__ == '__main__':
    main()

Solution (Python):
n,a,b = [int(x) for x in input().split()]
answer = n//(a+b)*a
if n%(a+b) < a:
  answer = answer + n%(a+b)
elif n%(a+b) >= a:
  answer = answer + a
print(answer)

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

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


ans = a * d



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

print(ans)

Solution (Python):

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






taba = a+b

sho = n//taba
amari = n%taba
if amari >= a:
    amari = a
else:
    amari = amari
ans = sho*a + amari

print(ans)

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

repeat_num = n // (a+b)
bluenum = repeat_num*a
if a != 0:
  over = (n - (a+b)*repeat_num)
  if over > a:
    bluenum += a
  else:
    bluenum += over
print(bluenum)

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

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

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

amari = N%(A+B)

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

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

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

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

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

res = 0
if N >= (A + B) * pow(10, 100):
  print(A * pow(10, 100))
else:
  tmp1 = N // (A + B) * A
  if N % (A + B) >= A:
    tmp2 = A
  else:
    tmp2 = N % (A + B)

print(tmp1 + tmp2)

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

Solution (Python):
def main():
  n, a, b = list(map(int, input().split()))
  if(a == 0):
    print(0)
    return
  p = n % (a+b)
  if(p <= a):
    print(a * (n // (a+b)) + p)
  else:
    print(a * (1 + n//(a+b)))
  return

main()

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


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


all_set, mod_ = divmod(N, (A+B))

if mod_ == 0:
	print(all_set*A)
elif mod_ - A >= 0:
	print(all_set*A + A)
else:
	print(all_set*A + mod_)

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

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

if m <= A:
    print(q*A + m)
else:
    print( (q * A) + 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,A,B = map(int,input().split())

if A == 0 and B == 0:
    cnt = 0
    print(cnt)
elif A != 0 or B != 0:
    m = N // (A+B)
    n = N % (A+B)

    cnt = A * m
    if n <= A:
        cnt += n
    elif n > A:
        cnt += A
    print(cnt)

Solution (Python):
import numpy as np
N, A, B = map(int,input().split())
N,A,B=int(N),int(A),int(B)
AB=A+B
x=int(N/AB)
y=int(N%AB)
if y>=A:
    print(A*x+A)
else:
    print(A*x+y)

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

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

print(q * a + min(m, a))

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)


INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


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

Solution (Python):



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


num_sa = N // (A+B)
num_amari = N % (A+B)


ans_1 = num_sa * A
if num_amari>A:
    num_amari = A
ans_2 = ans_1 + num_amari


print(ans_2)

Solution (Python):
import math
import sys


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

p = N //(A+B)
q = N % (A+B)

if q <=A : 
    print(p * A + q)
else:
    print(p * A + A)

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

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

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

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

Solution (Python):
import sys


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




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

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

sum = 0
if a == 0:
  print(0)
elif n <= a:
  print(n)
elif int(n / (a + b)) == 0:
  print(a)
else:
  nn = int(n / (a + b))
  na = n % (a + b)
  sum = nn * a + min(na,a) 
  print(sum)

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

Solution (Python):
def count_ball(n, a, b):
    if n%(a+b) < a:
        print((n//(a+b))*a + n%(a+b))
    else:
        print((n//(a+b))*a + a)

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

count_ball(n, a, b)

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

S = N // (A + B)
n = N - S * (A + B)

if n >= A:
  n_a = A
else:
  n_a = n

print(S * A + n_a)

Solution (Python):
n,a,b=map(int,input().split())
answer=0
if a==0:
    answer=0
elif b==0:
    answer=n
elif a==1 and b==1:
    answer=n//2
else:
    while n>a+b:
        answer+=n//(a+b)*a
        n-=n//(a+b)*(a+b)
    if n>a:
        answer+=a
    else:
        answer+=n
print(answer)

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

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

Solution (Python):


n,a,b = map(int,input().split())
zyu = n // (a+b)
ans = 0
ans += a * zyu
nok = n - zyu * (a+b)
if nok >= a:
    ans += a
elif nok < a:
    ans += nok
print(ans)

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