peterverebics/CodeNet_Python_118 huggingface dataset:
n, a, b = map(int, input().split())
if a == 0:
    print(0)
elif a+b >= n:
    print(a) if a <= n else print(n)
else:
    ab = a + b
    ans = n // ab * a + n % ab
    print(ans)
N,A,B=map(int, input().split())
ans=(N-N%(A+B))*A/(A+B)+min(A,N%(A+B))
print(ans)
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,A,B = LI()

num = N//(A+B)
print(num*A + N-(num*(A+B)))
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

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

print(d*a+m if m<a else d*a+m-b)
N,A,B=map(int,input().split())
t=N//(A+B)
if N%(A+B)==0:
  print(t*A)
else:
  print(t*A+N%(A+B))
import math
N,A,B = map(int,input().split())
c = N%(A+B)
p = math.floor(N/(A+B))
print((A*p)+c)
N, A, B = map(int, input().split())

t = N // (A + B)
if N % (A + B) == 0:
  mod = 0
else:
  mod = A

print(t * A + mod)
n,a,b = map(int,input().split())

if a ==0:
  print(0)
elif b == 0:
  print(a)
else:
  print(n-b)
n,a,b = [int(i) for i in input().split()]
k = n // (a + b)
q = n % (a + b)
if n > (a + b):
    print(a * k + q)
else:
    print(min(n,a))
n,a,b = map(int,input().split())

if a == 0:
  print(0)
elif b == 0:
  print(n)
elif a >= n:
  print(n)
elif a+b >= n:
  print(a)
else:
  c = a*n//(a+b) + min(n%(a+b),a)
  print(c)
n, a, b = (int(x) for x in input().split())

nokori = n
ans = 0

# 最後の1回前までの処理
while a + b <= nokori :
    ans = ans + a
    nokori = nokori - (a + b)

# 最後の1回の処理
ans = ans + nokori

print(ans)
N,A,B = list(map(int,input().split()))
ans = A*N//(A+B)
if N%(A+B)>=A:
    ans+=A
else: ans+=N%(A+B)
print(ans)
n,a,b = map(int,input().split())
if a+b>=n:
    print(a)
elif a == 0:
    print(0)
else:
    c = n//(a+b)
    d = n%(a+b)
    if a>d:
        print(c*a + d)
    else:
        print(c*a + a)
N, A, B = map(int, input().split())

print((N // (A + B)) * A + (N % (A + B)))
def main():
  n, blue, red = input_list()
  d = n % (blue+red)
  if d == 0:
    print(blue * (n // (blue+red)))
  else:
    print(blue * (n // (blue+red))+d)
    
def input_list():
  return map(int, input().split())

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

import math
import fractions
from functools import reduce
main()
N,A,B = map(int, input().split())
X = N//(A+B)
Y = N%(A+B)
if Y < B:
  print(A*X+Y)
else:
  print(A*(X+1))
n, a, b = map(int,input().split())
 
x = int(n/(a+b)) #何周目か
y = n%(a+b) 
ans = x * a + y

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

count = (a+b) // n 
if count == 0:
    count = 2
con = count*(a+b)
if con - n > b:
    con -= b
    if con - n > a:
        print(a*(count-1))
    else:
        print(a*(count-1)+(a+b)*(count-1) + a -n-1)
else:
    print(a*count)
import math
N, A, B = [int(i) for i in input().split()]
count = A + B
setCount = math.floor(N / count)
amari = N - math.floor(setCount) * count
result = setCount * A + amari
print(result)
n,a,b = map(int,input().split())
S = n//(a+b)
N = n%(a+b)
if a+b > n:
    print(a)
if (a+b <= n) and N <= a:
    print(S*a+N)
if (a+b <= n) and N > a:
    print(S*a)
import sys

n, blue, red = map(int, input().split())
ball = blue + red

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    print(n)
    sys.exit()
if n <= ball:
    print(blue)
    sys.exit()

ans = n // ball
additional = n % ball

if additional == 0:
    print(ans * blue)
#elif additional <= blue:
#    print(ans * blue + additional)
else:
    print(ans * blue + additional)
N, A, B = map(int, input().split())
num = A * N // (A + B)
if N % (A + B) > A:
  print(num + A)
else:
  print(num + (N % (A + B)))
n, a, b = list(map(int, input().split()))

print (a* (n//(a+b)) + n%(a+b))
# -*- coding: utf-8 -*-

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

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

print((A * q) + max((mod - B), mod))
N,A,B = map(int,input().split())
print(A*N//(A+B) + N%(A+B))
N,A,B=map(int,input().split())
if A==0 :
  print(0)
elif A>=N :
  print(N)
elif A+B<N :
  print(A+(N-(B+A)))
else :
  print(A)
n, a, b = map(int, input().split())
ans = []
for i in range(10000):
  for j in range(a):
    ans.append('b')
  for k in range(b):
    ans.append('r')
hints = ans[0:n]
count = 0
for l in hints:
  if l == 'b':
    count += 1
print(count)
X = list(map(int,input().split()))

N = X[0]
b = X[1]
r = X[2]

if b == 0:
    print(0)
elif b + r == N:
    print(b)
else:
    print(b + (N - (b + r)))
N, A, B = map(int, input().split())
r = N // (A + B)
m = N % (A + B)
if A != 0:
    if A > N:
        print(N - A)
    else:
        print(A * r + m)
else:
    print(0)
n, a, b = map(int,input().split())
kumi = n // (a + b)
nokori = n % (a + b)
if nokori == 0:
    print(a * kumi)
elif nokori >= 1 and nokori< a:
    print(a * kumi + n - a - b)
elif nokori >= a:
    print(a * kumi + a)
# coding: utf-8
N, A, B = map(int, input().split())
 
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A
    #print("num:", num)
    num += N % (A + B)
    # print("num:", num)
    print(num)
X = list(map(int,input().split()))

N = X[0]
b = X[1]
r = X[2]

if b == 0:
    print(0)
elif r == 0:
    print(N)
elif b + r == N:
    print(b)
else:
    b_count = 0
    Line = 0
    while Line <= N:
        Line += b
        b_count += b
        Line += r
        
    
    print(b_count)
nums = [int(e) for e in input().split()]
n = nums[0]
a = nums[1]
b = nums[2]

sum = a + b
iter = n // sum
amari = n % sum
if amari >= b:
	print(iter * a + (b))
else:
  print(iter * a + (amari))
n, b, r = map(int, input().split())
print((n //(b+r))*b + n - (b+r)*(n //(b+r)))
N,B,R = input().split()
N = int(N)
B = int(B)
R = int(R)
X = B + R
Z = N // X
Y = N % X
if B == 0:
    print(0)
elif  X == N:
    print(B)
elif X < N:
    if Y < B:
        print(B*Z + Y)
    elif Y == B:
        print(B*Z + B)
    elif Y > B:
        print(B*Z + B)
n,a,b = map(int,input().split())
if(a==0):
  print(0)
  exit()

c = n//(a+b)
d = n%(a+b)
if(c==0):
  print()
elif(d==0):
  print(a*c)
elif(d%a==0):
  print(a*c+(d%a)+a)
else:
  print(a*c+(d%a))
n,a,b = map(int, input().split())
m1 = n // (a + b)
m2 = n % (a + b)

if a ==0:
  print(0)
elif a + b >n:
  print(a)
elif a > n:
  print(n)
else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest < blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + rest)
n,a,b=map(int,input().split())
if(n<=a):
    print(n)
elif(n<=a+b):
    print(a)
else:
    print(n//(a+b)+n%(a+b))
n,a,b = map(int,input().split())

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

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

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

sum=0

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

    # print(a)
    # print(b)

    sum=A*a+b

    print(sum)
a,b,c = map(int,input().split())

l= []
while(len(l)<=a):
    for _ in range(b):
        l.append(1)
    for _ in range(c):
        l.append(0)
        
print(l[:8].count(1))
N, A, B = map(int, input().split())
ans = (N//(A+B)) * A
if(N % (A+B) <= A):
    ans += (N % (A+B))
print(ans)
import math
n, a, b = map(int,input().split())
try:
    ans = math.ceil(n / (a + b) * a)
except Exception as e:
    ans = 0
print(ans)
# coding: utf-8
N, A, B = map(int, input().split())

if A == 0 or N == 0:
    print(0)
else:
    num = int(N / (A + B)) * A
    #print("num:", num)
    num += N % (A + B)
    # print("num:", num)
    
    print(num)
n,a,b = map(int,input().split())
dars = n // (a+b)
amari = n % (a+b)
if amari < b:
    ans = dars*a + amari
else:
    ans = dars*a + a
print(ans)
n,a,b = map(int,input().split())
dars = n // (a+b)
amari = n % (a+b)
if b == 0:
    print(n)
    exit()
if amari < b:
    ans = dars*a + amari
else:
    ans = dars*a + a
print(ans)
s = input()

ss = s.split(" ")

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

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  if N <= ( A + B ) :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) 
    mod = N % ( A + B )
    ans = div * A

    if mod > A :
      ans += A
    else :
      ans += mod
    
    print(ans)
n,a,b=map(int,input().split())
katamari=n//(a+b)
amari=n%(a+b)
print(a*katamari+amari)
n,a,b=map(int,input().split())
if b!=0:
	count = n//(a+b)*a + n%(a+b)
	print(count)
else:
	print(a)
#

import sys
input=sys.stdin.readline

def main():
    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)
    
    
    
if __name__=="__main__":
    main()
N, A, B = map(int, input().split())
print(A * N // (A + B) + min(A, N % (A + B)))
n,a,b = map(int,input().split())
if a!=0:
    if n<a+b:
        print(a)
    else:
        res = n - (a+b)
        num = (res+1)//2
        print(a+num)
else:
    print(0)
n, a, b = map(int, input().split())

NumberOfRotations = int(n/(a+b))
surplus = n%(a+b)

ans = 0

if NumberOfRotations == 0:
    if a > n:
        print(surplus)
        exit
    else:
        print(a)
        exit

ans = a*NumberOfRotations
if a > n - ((a+b)*NumberOfRotations):
    print(ans+surplus)
else:
    print(ans+a)
n, a, b = map(int, input().split())
c = a + b
q = n // c
mod = n % c
if a == 0:
    print(0)
else:
    print(q*a+mod)
N,A,B = map(int, input().split())
if A==0:
  print(0)
elif (A+B)>N:
  if N<=A:
    print(A)
  else:
    print(N)
else:
  x=N//(A+B)
  y=N%(A+B)
  print(A*x+y)
n,a,b = map(int,input().split())

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

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

	print(ans)
else:
	print(a)
N,A,B=map(int,input().split())
if  A==0:
    print(0)
elif N>=A+B:
    print(N-B)
elif N<A+B and N<A:
    print(N)
else:
    print(A)
array = input().split()
n = int(array[0])
a = int(array[1])
b = int(array[2])

print(n//(a+b)*a + n%(a+b))
N,A,B = map(int,input().split())
print((N//(A+B))*B)
i = input()
a = i.split(" ")
n = len(i)
if n == 5:
  N = int(a[0])
  A = int(a[1])
  B = int(a[2])
  if A == 0:
    print("0")
  elif N-(A+B) == 0:
    print(A)
  elif A+B != N:
    x = N-(A+B)
    print(A+x)
N, A, B = [int(i) for i in input().split()]

g = 0

while N > A:
    N = N - A - B
    g = g + A

print(g + N)
N, A, B = map(int, input().split(' '))
count = 0
count += N // (A + B) * A
count += N % (A + B) % (A + 1)
print(count)
#coding:utf-8

import queue

def main():
    n, a, b = map(int, input().split())
    p = n // (a + b)
    print(p * a + n - p * (a + b))
    
if __name__ == '__main__':
    main()
#!/usr/bin/env python3

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B == N or A + B > N and N >= A:
    print(A)
elif A + B > N and N < A:
    print(N)
else:
    r = int(N / (A+B))
    q = N % (A+B)
    print(r * A + q)

# -----
# 8 4 2
# bbbbrrbb bb

# 13 4 2
# bbbb rr bbbb rr b

# 2 4 2
# bb

# r = N / (A+B)
# q = N % (A+B)
# r * A + q
N,A,B=map(int,input().split())
print(N//(A+B)*A+N%(A+B))
if __name__ == '__main__':
    (n, a, b) = [int(e) for e in input().split()]
    ans = (int(n/(a+b)))*a
    if n%(a+b) == 0:
        print(ans)
    elif n%(a+b) > a:
        print(ans + a)
    else:
        print(ans + a - n%(a+b) - 1)
n,b,r= map(int,input().split())
if b==0 and r==0:
  print(n)
elif b==0:
  print(0)
else:
  print(n-r)
n, b, r = map(int, input().split())
s = 0
while(n != 0):
    if n >=b:
        n -= b
        s += b
    else:
        s += n
    if n >= r:
        n -= r
    else:
        break
print(s)
A, B, C = input().split()
A = int(A)
B = int(B)
C = int(C)
if B == 0:
  print(0)
else:
  print(A-C)
n,a,b = map(int,input().split())


SET = a+b
SET_NUM = n//SET
remain_spot = n%SET
print(a*SET_NUM+remain_spot)
n, a, b  = list(map(int, input().split()))

sum = a+b
n % sum  

res = (n//sum)*a + n % sum
print(res)
def main():
    N,A,B=map(int,input().split())
    count=(N//(A+B))
    if (A+B)*10**100 <= N:
        print(A*10**100)
        return 0
    ans=count*A
    if A>=N-(A+B)*count:
        ans+=(N-(A+B)*count)
        print(ans)
    else:
        print(ans)
main()
n,a,b  =map(int,input().split())
se = a+b
br = 0
cnt = 0
if a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n//(a+b)
    if cnt == 0:
        print(a)
    else:
        res = a*cnt
        n -= (a+b)*cnt
        res += n
        print(res)
X = list(map(int,input().split()))

N = X[0]
b = X[1]
r = X[2]

if b == 0:
    print(0)
elif r == 0:
    print(N)
elif b + r >= N:
    print(b)
else:
    if N % (r + b) == 0:
        print(b * (N // (r + b)))
    else:
        print(b * (N // (r + b)) + 1)
n, a, b = map(int, input().split())
num_of_t = n // (a + b)
if num_of_t == 0:
    if a >= n:
        print(n)
    else:
        print(a)
    exit()
print(a * num_of_t + n - num_of_t * (a + b))
#abc 158 b
"""
input().split()
map(int,input().split())
print("Yes" if flag else "No")
for i in range():
"""
n,a,b=map(int,input().split())
ans=0
if a+b>=2:
    ans=n//(a+b)
elif a==0:
    ans=0
elif b==0:
    ans=n
elif n%(a+b)-b<0:
    ans+=n%(a+b)
else:
    ans+=n%(a+b)-b
print(ans)
n,b,r = map(int, input().split())		# 5 7 2

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

print(ans)
a,b,c=map(int,input().split())
k=a//(b+c)
h=k*b
t=a-b*k-c*k
print(t+h)
n, a, b = map(int, input().split())

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

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

print(ans)
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    num_x = a
  elif(n == (a + b)):
    num_x = 0
  elif(num_b >= a):
    num_x = a
  elif(a != 0):
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()
n,a,b = [int(i) for i in input().split()]

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

print(div * a + mod)
import sys
import os


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

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


if __name__ == '__main__':
    main()
import math

N, A, B = map(int, input().split())
print(math.floor(A * N / (A + B)) + min(A, N % (A + B)))
n, a, b = map(int, input().split())
m = n % (a+b)
sum_blue = m*a + min(n - m * (a+b), a)
print(sum_blue)
import math
n,a,b = map(int,input().split())

if a==0:
    print(0)
elif n%(a+b)==0:
    print(math.floor((n/(a+b))*a))
elif n<(a+b):
    print(math.floor((a+b)/n)*a)
elif n>(a+b):
    print(a+n-(a+b))
n,b,r = map(int,input().split())
syo = n//(b+r)
amari = n%(b+r)
print(syo,amari)
if amari == 0:
  print(b*syo)
else:
  if amari <= b:
    print(b*syo + amari)
  else:
    print(b*syo - (b-amari))
N, A, B = map(int,input().split(" "))

cnt_a = cnt_b = 0

while True:
    if cnt_a + cnt_b + A >= N: 
        # N - cnt_a - cnt_b はみ出た分
        ans = N - cnt_b
        break
    else:
        cnt_a += A
        cnt_b += B

print(ans)
N, A, B = map(int, input().split())
print(A*(int(N/(A+B)))+(N%(A+B)))
def solve():
    n, a, b = map(int, input().split())
    ab = a + b
    ans = n // ab * a
    print(ans + n % ab)
solve()
N, A, B = map(int, input().split())

if A == 0:
    print(0)
else:
    B_s = A + B
    B_block = (N - 1) // B_s
    B_rem = (N - 1) % B_s + 1
    print(A * B_block + B_rem)
import math
n,a,b = map(int,input().split())
ans = math.ceil(n*(a/(a+b)))
print(ans)
n, b, r = map(int, input().split())

if b == 0:
    print(0)
elif n % (b+r) <= b:
    print((n//(b+r))*b + n%(b+r) )
else:
    print((n//(b+r))*b)
n,a,b=map(int,input().split())
if 1<=n%(a+b) and n%(a+b)<=a:
  ans=(n//(a+b))*a+n%(a+b)
else:
  ans=(n//(a+b))*a
print(ans)
n,a,b=map(int,input().split())
print(n//(a+b)*a+(n-n//(a+b)*(a+b)))
N,A,B=list(map(int,input().split()))
print(A*(N//(A+B))+max(A,N%(A+B)))
n,a,b=map(int,input().split())
sho=n//(a+b)
amari=n%(a+b)
if amari > 3:
  ex=3
else:
  ex=amari
blue=a*sho+ex
print(blue)
N,A,B=map(int,input().split())
if A==0:
    print(0)
elif N==1 and A>0:
    print(1)
elif B==0 and A<=N:
    print(N)
elif A+B<N and (N-(A+B))-A>0:
    print(abs(A+(A*(N//(A+B)))))
else:
    print(abs((N-(A+B))+A))
n,a,b = map(int, input().split())

q, mod = divmod(n, a+b)
print(q*a + mod)
n, a, b = map(int, input().split())
count = 0

if n < a :
    print(n)

elif n < a+b :
    print(a)

else:
    while n > 0:
        if n >= a:
            count += a
            n -= a+b

        else:
            count += n
            n -= a+b
            break

print (count)
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
z = int(N % (A + B))
y = x * A
y = y + z
print(y)
n, a, b = map(int, input().split())
x = n // (a + b)
y = min(n % (a+b), b)
print(x*a + y)
n, a, b = map(int, input().split())
if a == 0:
  ans = 0
elif 1 <= n % (a + b) and n % (a + b) <= a:
  ans = (n // (a + b)) * a + n % (a + b)
else:
  ans = (n // (a + b)) * a + a
print(ans)
import sys

readline = sys.stdin.buffer.readline

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

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

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

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

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

print(d*a+m if m<b else d*a+m-b)
N, A, B = map(int, input().split())

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

blue_num = 0
if amari <= B:
    blue_num += A * sho + amari
else:
    blue_num += A * sho + B
    
print(blue_num)
total,blue,red=map(int,input().split())
num = total//(blue+red)
if blue == 0:
    print(0)
else:
    print(num*blue+(total%(blue+red)))
n, a, b = map(int, input().split())

if n%(a+b) >a:
    print((n//(a+b))*a)
else:
    print((n//(a+b))*a +n%(a+b))
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest <= blue_num:
        blue = rest
    count = num / all_ball
    print((count) * blue_num + rest)
import sys


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

    if a == 0:
        print(0)
        sys.exit(0)
    if b == 0:
        ans = n
        print(ans)
        sys.exit(0)
    div = n // (a+b)
    mod = n % (a+b)
    ans = div * a
    if mod <= b:
        ans += mod
    else:
        ans += b
    print(ans)


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

print(ans)
N,A,B=map(int,input().split())
rest = N-A-B
if A ==0:
    print(0)
elif N>A+B:
    answer = A + rest
    print(answer)
elif A<=N<=A+B:
    print(A)
elif A>=N:
    print(N)
# -*- coding: utf-8 -*-
n, a,b=map(int, input().split()) 
X = int(n/(a+b))*a
Y = n%(a+b)
print(X+Y)
n,a,b=map(int,input().split())
ans=0
if a==0:
    ans=0
elif b==0:
    ans=n
elif n>(a+b):
    ans=a*(n//(a+b))
    n=n%(a+b)
else:
    while True:
        if n==0:
            break
        if n-a>=0:
            n-=a
            ans+=a
        else:
            ans+=n
            break
        n-=b
        if n<=0:
            break
print(ans)
N, A, B = map(int, input().split())
print(min((N//(A+B))*A + N-(N//(A+B)), (N//(A+B))*A + A))
n,a,b=map(int,input().split())
c=0
while n>=a:
    n-=a
    c+=a
    n-=b
    if n<=0:
        break
    else:
        continue
print(n+c)
N,A,B = map(int,input().split(" "))
if A == 0:
    print(0)
    exit()
ans = N//(A+B)
tmp = N%(A+B)
ans = ans*A+tmp
print(ans)
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0:
    print(0)
if B == 0:
    print(N)
else:
    B = A + B
    num = N // B * A
    # print("num:", num)
    num += N % B
    # print("num:", num)
    print(num)
n,a,b = list(map(int, input().split()))
q=n//(a+b)
mod=n%(a+b)
ans=a*q+mod
print(ans)
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

tmp=(int(N/(A+B))*A)
tmp_2=int(N-(N-int((N%(A+B)))))
print(tmp)
print(tmp_2)
if (N%(A+B))==0:
  print(tmp)
else:
  print(tmp+tmp_2)
n,a,b=map(int,input().split())
x=a+b
r=int(n/x)
#print(r)
if n%x!=0:
  d=n%x
  if n%x>a:
    d=n%x-b
  s=a*r+d
else:
  s=a*r
  
print(s)
N, A, B = map(int, input().split())

x = N // (A + B)

ans = 0
if x == 0:
    ans = N
elif N - (A + B)*x > A:
    ans = A * (x + 1)
else:
    ans = N - B * x

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

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

if A>=N:
    print(N)
else:
    s, a = divmod(N, A+B)
    print(s*A+a)
n,a,b=map(int,input().split())
c = a+b
d = n // c
count = d * a
n = n - (c * d)
count += n
print(count)
N,A,B = map(int, input().split())
count=0
flag=True
pattern=True
ans=0
num=A+B
while flag:
    x=N%num
    if A==0:
        ans=0
    elif x==0:
        ans=int((N/num)*A)
    elif N<num:
        ans=A
    else:
        ans=(A*x)+x


    flag=False


print(ans)
n, an, bn = map(int, input().split())
print("0" if an == 0 else an + max(max(n - an, 0) - bn, 0))
n, b, r = map(int, input().split())

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

ans += n - (b+r) * ( n // (b+r))
print(ans if b != 0 else 0)
n, a, b = list(map(int, input().split()))

sum = a+b

if n<a+b:
    print(n)

else:
    res = (n // (a+b))*a + n % sum
    print(int(res))
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)
n,a,b = input().split()
N = int(n)
A = int(a)
B = int(b)
x = int(N / (A + B))
y = x * A
z = N - y
z = z - B
if N % (A + B) == 0:
    print(y)
elif A == 0:
    print(0)
else:
    print(y + z)
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(N)
  sys.exit()

tmp=int((N/(A+B))*A)
if (N%(A+B))==0:
  print(tmp)
else:
  tmp_2=int(N-(N-int((N/(A+B)))))
  print(tmp+tmp_2)
N, A, B = map(int, input().split())

a = N // (A + B) * A
b = N % (A + B)

print(a + b)
n,a,b=map(int,input().split())
ans=0
ans=n//(a+b)*a
if n%(a+b)!=0:
  ans=n-(n//(a+b)*(a+b))+ans
print(ans)
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
INF = 500000
mod = 10**9+7

N, A, B = map(int, input().split())
C = A+B
x = N//C
print(x*A+N-x*C)
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print(n)
		# elif a<=n:
			# print(a)
		else:
			for i in range(1,10**100):
				if n < (a+b)*i and (a+b)*(i-1)<=n:
						if n-(a+b)*(i-1)<a:
							print(a*(i-1)+n-(a+b)*(i-1))
						else:
							print(a*i)
						break
				break
main()
n,a,b= list(map(int, input().split()))
s=(n//(a+b))*a
if n%(a+b)>a:
    s+=n%(a+b)+a
else:
    s+=n%(a+b)
if a==0:
    print(0)
else:
    print(s)
N, A, B = map(int, input().split())
print((N // (A + B)) * A + N - (A + B) * (N // (A + B)))
# problem B
N,A,B = map(int,input().split())

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

ans = syou * A 
if amari >= A:
    ans += B
else:
    ans += amari
    
print(ans)
import sys
N,A,B=map(float,input().split())
if A==0:
  print("0")
  sys.exit()
elif B==0:
  print(int(N))
  sys.exit()
  
tmp=(int(N/(A+B))*A)
tmp_2=int(N%(A+B))
if (N%(A+B))==0:
  print(int(tmp))
else:
  print(int(tmp+tmp_2))