peterverebics/CodeNet_Python_118 huggingface dataset:
n,a,b=map(int,input().split())
p=a+b
nite=n//p
rest=n%p
sa=min(a,rest)
print(nite*a+sa)
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

print(n // (a + b) * a + min(n % (a + b), a))
n,a,b=map(int,input().split())
q=n//(a+b)
r=n%(a+b)
print(a*q+min(r,a))
N, A, B = map(int, input().split())

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

print(q * A + mod) if mod <= A else print(q * A + A)
N, A, B = list(map(int, input().split()))

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

answer = d * A
if m <= A:
    answer += m
else:
    answer += A

print(answer)
a,b,c = map(int, input().split())
print(a//(b+c)*b + min(b,a%(b+c)))
n, a, b = map(int, input().split())
oneRound = a + b
roundCnt = n // oneRound
mod = n % oneRound

ans = roundCnt * a + min(mod, a)
print(ans)
N,A,B = map(int,input().split())
chance = N//(A+B)
spare = N%(A+B)
ans = chance*A + min(spare,A)
print(ans)
n = 0

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

n += int(N/(A+B)) * A

amari = N % (A+B)
n += min(amari, A)

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

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

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

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


print(m*a+min(amari,a))
n,a,b=map(int,input().split())

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

ans=c*a+min(d,a)
print(ans)
n,a,b = map(int,input().split())
c = a + b #一つの塊
d = n //c #塊が何個あるか
e = n%c #塊じゃないものが何個残るか
katamariblue = a*d
if e >=a:
    blue = a
else:
    blue = e
print(blue + katamariblue)
import math
n, a, b =map(int,input().split())
x=a+b
#yはn/(a+b)の商
quotient=math.floor(n/x)
#zはn/(a+b)の余り
rmd=n%x
if rmd==0:
  blue=quotient*a
  print(blue)
elif rmd<=a:
  blue=quotient*a+rmd
  print(blue)
else:
  blue=quotient*a+a
  print(blue)
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)
inf = input().split()
info = list(map(int, inf))
o = info[1] + info[2]
if o == 0:
    print(0)
else:
    q, mod = divmod(info[0], o)
    if mod > info[1]:
        print((q+1)* info[1])
    else:
        print(q*info[1] + mod)
N, A, B = map(int, input().split())
print(A * (N // (A + B)) + min(N % (A + B), A))
# -*- coding: utf-8 -*-

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

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

print(x + z)
n, a, b = map(int, input().split())

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

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

x, y = divmod(N, A+B)
print(x * A + min(A, y))
n, a, b = map(int, input().split())

c = a+b

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

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

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

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

print(min(count, a * (10 ** 100)))
N,A,B=map(int,input().split())
result=0

# 処理

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

print(result)
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*A+A)
# -*- coding: utf-8 -*-
import math
def main():
    N,A,B = map(int,input().split())
    ans0 = N//(A+B)
    ans1 = A*ans0
    ans2 = (N-(A+B)*ans0)
    if ans2 <= 0:
        ans2 = 0
    if ans2 < A:
        ans1 += ans2
    elif ans2 >= A:
        ans1 += A

    print(ans1)

if __name__ == '__main__':
    main()
n, a, b = map(int,raw_input().split())
c = 0
if a == 0:
  print 0
else:
  if n%(a+b) == 0:
    print a * (n/(a+b)) 
  else:
    if a > n%(a+b):
      c = n%(a+b)
    else:
      c = a
    print a * (n/(a+b)) + c
n,a,b = map(int,input().split())
c = n//(a+b)
d = n%(a+b)

if d>a:
    d = a
print(a*c+d)
import math

#Maps all three inputs into a variable. N is total, A is blue balls, B is red balls
N, A, B = map(int, input().split())
leftOver = N % (A + B)
divTime = N / (A + B)
#print('leftOver: %s' % leftOver)
#print('divTime: %s' % divTime)

if divTime == 1:
  print(A)
elif divTime != 1:
  if leftOver > A:
    print(math.floor(divTime) * A + A)
  elif leftOver <= A:
    print(math.floor(divTime) * A + leftOver)
N,A,B=map(int,input().split())
M=0
ans=0
C=A+B
c=N//C
ans=A*c
if N-C*c<A:
    ans+=N-C*c
else:
    ans+=A
print(ans)
n,a,b=map(int,input().split())
c = n//(a+b)
d = n%(a+b)
if d < a:
  print(c*a+d)
else:
  print(c*a+a)
N, A, B = map(int, input().split())
M = N % (A+B)
cnt = (N // (A+B))*A
if M < A:
    print(cnt+M)
else:
    print(cnt+A)
N,A,B = map(int,input().split())
print((N//(A+B))*A+min(N%(A+B),A))
N,A,B = map(int,input().split())
ans = N//(A+B)*A
rem = N%(A+B)
ans +=min(rem,A)
print(ans)
# coding: utf-8
# Your code here!

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

num_blue = (N // (A + B)) * A
if N % (A + B) <= A:
    num_blue += N % (A + B)
else:
    num_blue += A
    
print(num_blue)
def resolve():
    n, a, b = map(int, input().split())
    if a==0:
        print(0)
    else:
        i = n//(a+b)
        if (n-(a+b)*i) >= a:
            print(i*a+a)
        else:
            print(i*a+(n-(a+b)*i))
resolve()
n, b, r = map(int, input().split())

am = n % (b + r)
s  = n // (b + r)
# print(b)
# print(r)
# print(am)
# print(s)

if am <= b:
    print((s * b) + am)
else:
    print((s+1) * b)
import math
n, a, b = map(int, input().split())
if n % (a+b) >= a:
  print(a*math.floor(n/(a+b)) + a)
else:
  print(a*math.floor(n/(a+b)) + n%(a+b))
N, A, B  = [int(x) for x in input().split(" ")]

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

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

print(ans)
N,A,B = map(int,input().split())
num_set = int(N /(A+B))
amari  = int(N % (A+B))
if(amari <= A):
    print(num_set * A + amari)
else:
    print(num_set * A + A)
n, a, b = map(int, input().split())

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

ans += min(rem, a)
print(ans)
N,A,B = map(int,input().split())
RepNum = int(N/(A+B))
Atotal = A * RepNum
amari = N-RepNum*(A+B)
if amari > 0:
  if amari >= A:
    amari = A
print([0,Atotal + amari][A!=0])
N, A, B = map(int, input().split())
answer = N // (A+B) * A
answer += min(N % (A + B), A)
print(answer)
n, a, b = map(int, input().split())

w = n // (a + b)
m = n % (a + b)
if m >= a:
    print(w * a + a)
else:
    print(w * a + m)
n, red, blue = map(int, input().split())
unit = red + blue
print((n // unit) * red + min([n%unit, red]))
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())
n_a_b = list(map(int, input().split()))

n = n_a_b[0]
a = n_a_b[1]
b = n_a_b[2]

division = n // (a+b)
remainder = n % (a+b)

answer = division * a

if remainder <= a:
  answer += remainder
else:
  answer += a

print(answer)
n,a,b = map(int,input().split())   
x = n//(a+b)
c = n-(a+b)*x
print(a*x+min(a,c))
N,A,B=map(int,input().split())
out=N//(A+B) * A
ama=min(N % (A+B),A)
print(out+ama)
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)
#coding:utf-8

import queue

def main():
    n, a, b = map(int, input().split())
    p = n // (a + b)
    remain = n - p * (a + b)
    print(p * a + min(a, remain))
    
if __name__ == '__main__':
    main()
n, a, b = map(int, input().split())

cycle = a + b
print(n // cycle * a + min(n % cycle, a))
import math
n,a,b = map(int,input().split())
ans = 0
if n % (a+b) >a:
    ans = a*math.floor(n/(a+b))+a
else:
    ans =  a*math.floor(n/(a+b))+n%(a+b)
print(ans)
n,a,b = map(int,input().split())
if n%(a+b) <= a and n%(a+b)!=0:
    print(n//(a+b)*a+n%(a+b))
elif n%(a+b)==0:
    print((n//(a+b))*a)
else:
    print(n//(a+b)*a+a)
n,a,b=map(int,input().split())
x=(n//(a+b))*a
y=n%(a+b)
if y>=a:
    print(x+a)
else:
    print(x+y)
n,a,b = map(int,input().split())
answer = 0
answer = a*(n//(a+b))
n = n%(a+b)
answer += min(a,n)
print(answer)
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)
def main():
    N,A,B = map(int,input().split())
    bl = (N // (A + B)) * A
    rl = (N % (A + B))
    if rl <= A:
        print(bl + rl)
    else:
        print(bl + A)
main()
N,A,B=map(int,input().split())

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

if y<=A:
    ans=x*A+y
else:
    ans=x*A+A

print(ans)
N,A,B=map(int,input().split());B+=A;print(N//B*A+min(N%B,A))
n, a, b = map(int, input().split())

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

q, r = divmod(n, (a+b))
ans = q * a
if r < a:
    ans += r
else:
    ans += a

print(ans)
N, A, B = map(int, input().split())
countA = int(N / (A+B)) * A
rest = N % (A+B)
countA += min(rest, A)
print (countA)
n, a, b = map(int, input().split())

blue_ball = a
red_ball = b

n_bai = n // (a + b)
n_amari = n % (a + b)

balls = []
ans = 0

balls_sum = 0

while balls_sum < n_amari:
    balls.append(a)
    balls.append(b)
    balls_sum = sum(balls)

while n_amari > 0:
    if n_amari > blue_ball:
        ans += blue_ball
    else:
        ans += n_amari
    n_amari = n_amari - blue_ball - red_ball

ans += n_bai * blue_ball

print(ans)
def main():
    n,a,b = map(int,input().split())
    x = (n // (a + b) ) * a 
    y = n % (a + b)
    ans = x + min(y,a)
    print(ans)
main()
N,A,B = map(int ,input().split())

m = int(N/(A+B))*A

if N%(A+B) > A:
    print(m + A)
else:
    print(m +(N%(A+B)))
from sys import stdin


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

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


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)
n, a, b = map(int, input().split())
ans = n // (a + b) * a + min(a, n % (a + b))
print(ans)
n,a,b = map(int,input().split())
c = a + b
z = n // c

if n % c != 0:
    m = n % c
    if a <= m:
        print(z * a + a)
    else:
        print(z * a + m)
else:
    print(z * a)
N, A, B = map(int,input().split())
if N % (A+B) == 0:
	print((N//(A+B))*A)
elif N % (A+B) <= A:
	print((N // (A+B))*A + N % (A+B))
else:
	print( (N // (A+B))*A + A)
#!/usr/bin/env python3

def main():
    N, A, B = map(int, open(0).read().split())

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


main()
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)
n,a,b=map(int,input().split())
ans=n//(a+b)*a
t=n%(a+b)
ans+=min(t,a)
print(ans)
N,A,B=map(int,input().split())
ans = A*(N//(A+B)) +min(A,N%(A+B))
print(ans)
n, a, b = list(map(int, input().split(' ')))
blueBall = 0
answer = []

if a == 0:
    print(a)
else:
    if n / (a + b):
        answer = divmod(n, (a + b))
        blueBall = answer[0] * a
        if answer[1] > a:
            blueBall = blueBall + a
        else:
            blueBall = blueBall + answer[1]

        print(blueBall)
    else:
        if n <= a:
            print(n)
        elif n <= b:
            print(a)
N,A,B = map(int,input().split())
a = min(N%(A+B),A)
print(N//(A+B)*A + a)
n,a,b=map(int,input().split())
a_l=n//(a+b)
b_l=n%(a+b)
if b_l > a : b_l = a
print(a_l*a+b_l)
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)
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)
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)
import math
n,a,b=map(int, input().split())
roop = math.floor(n / (a+b))
anc_a = a*roop
n_b = n-(roop*(a+b))
cnt = anc_a + min([n_b,a])
print(cnt)
N,A,B=map(int,input().split())

if(N%(A+B)>A):
    print(A+(N//(A+B))*A)
else:
    print((N//(A+B))*A+N%(A+B))
# -*- coding: utf-8 -*-

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

    comp = n // (a + b)
    uncomp = n - comp * (a + b)

    ans = comp * a + min(a, uncomp)
    # print('comp:{}, uncomp:{}'.format(comp, uncomp))
    print(ans)

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

x = n // (a+b)
y = n - x * (a+b)

if y > a:
    print(a*x + a)
else:
    print(a*x + y)
N, A, B = map(int, input().split())
ab = A + B
x = N // ab
y = N % ab

if y >= A:
  print((x + 1) * A)
else:
  print(x * A + y)
N,A,B = map(int,input().split())

div = N//(A+B)
rest = N % (A+B)


if rest>A:
  ans = div*A + A
else:
  ans = div*A + rest
  
print(ans)
n,a,b = map(int, input().split())
ans = (n // (a+b))
n -= ans * (a+b)
print(ans * a + min(n,a))
n, a, b = map(int, input().split())

sho = n // (a + b)
mod = n % (a + b)
if mod <= a:
    ret = sho * a + mod
else:
    ret = sho * a + a

print("{}".format(ret))
N,A,B = map(int,input().split())
ans = N//(A+B) * A 

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

#print(n)
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)
N, A, B = map(int, input().split())
if A == 0:
    print(0)
    exit()
sho = N // (A + B)
amari = N % (A + B)
if amari >= A:
    amari = A
ans = sho * A + amari
print(ans)
N, A, B = map(int, input().split())
q, r = divmod(N, A + B)
if r <= A:
    blues = q * A + r
else:
    blues = (q + 1) * A
print(blues)
n, a, b = map(int, input().split())
ans = n // (a + b) * a
r = n % (a + b)
ans += min(r, a)
print(ans)
# input
N, A, B = map(int, input().split())

# process
t = N%(A+B)
if t > A:
    t = A

# output
print(N//(A+B)*A + t)
n, a, b = map(int, input().split())
ans = (n//(a+b)) * a + min(n%(a+b), a)
print(ans)
N, A, B = input().split()
N = int(N)
A = int(A)
B = int(B)
ans=0

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

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

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

print(ao1+ao2)
n, a, b = map(int, input().split())
m = n//(a+b)
total = n//(a+b) * a
total += min(n - m*(a+b), a)
print(total)
N, A, B = map(int, input().split())
r = (N//(A+B))*A
N = N%(A+B)
print(r+N if N<=A else r+A)
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)
def main():
    n, a, b = map(int, input().split())
    ans = a*(n//(a+b))
    n %= a+b
    if n >= a:
        ans += a
    else:
        ans += n
    print(ans)

if __name__ == "__main__":
    main()
n, a, b = [int(c) for c in input().split()]
num = n // (a+b)
amari = n % (a+b)
out = num * a + min(amari, a)
print(out)
# -*- coding: utf-8 -*-

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

sum = 0

if n <= a:
    sum = n

elif n <= (a + b):
    sum = a

else:
    p = n // (a + b)
    sum += a * p
    n -= p * (a + b)

    if n <= a:
        sum += n

    elif n <= (a + b):
        sum += a


#出力
print(sum)
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)
n,a,b = map(int,input().split())
rest = n%(a+b)

ans = n//(a+b)*a
if rest >= a:
  ans += a
elif rest < a:
  ans += rest

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

ab = a + b

repeat = n // ab
modular = n % ab

print(a * repeat + min(modular, a))
n, a, b = map(int, input().split())

t = n // (a + b) * a
t += min(n % (a + b), a)
print(t)
n,a,b= list(map(int, input().split()))
s=(n//(a+b))*a
if n%(a+b)>a:
    s+=a
else:
    s+=n%(a+b)
print(s)
N, A, B = map(int, input().split())

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

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

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

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


if l >= A:
    t = A
else:
    t = l

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

da = (n // (a+b)) * a
db = min(a, n % (a+b))
print(da+db)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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

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

ans = x + min(y, A)
print(ans)
N,A,B = map(int, input().split())

count = N//(A+B)
if (N-count*(A+B))>A:
    print(count*A+A)
else:
    print(count*A+(N-count*(A+B)))
N,A,B = map(int,input().split())
ans = N // (A + B) * A
rem = N % (A + B)
ans += min(rem, A)
print(ans)
N, A, B = map(int,input().split())

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

if  A == 0 :
    print(0)

elif q < 1 and N <= A:
    print(N)
    
elif q < 1 and N > A:
    print(A)
    
elif q >= 1:
    if mod == 0 :
        print(q*A)
    elif mod <= A :
        print(q*A+mod)
    elif mod > A :
        print(q*A+A)
n, a, b = map(int, input().split())
c = a + b
q = n // c
mod = n % c
ans = q * a
if mod >= a:
    ans += a
else:
    ans += mod
    
print(ans)
Str = input().split()
N = int(Str[0])
A = int(Str[1])
B = int(Str[2])
answer = A*(N//(A+B))
res = N % (A+B) 
if res <= A:
  answer+= res
else:
  answer+= A

print(answer)
n, a, b = map(int, input().split())
r = n // (a + b)
q = n % (a + b)
print(a * r + min(q, a))
N, A, B = map(int, input().split())

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

ans = A * syou

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

print(ans)
N, A, B = [int(i) for i in input().split()]
S = A+B
c = (N//S)*A
 
c += min(N%S,A)
print(c)
import math
N,A,B = map(int,input().split())
c = N%(A+B)
p = math.floor(N/(A+B))
if c >= A:
  print((A*p)+A)
else:
  print((A*p)+c)
#26
N,A,B = map(int,input().split())
num = int(N/(A+B))
blue = 0

blue = num*A
if (N-num*(A+B)) <= A:
    blue += (N-num*(A+B))
else:
    blue += A

print(blue)
N,A,B = map(int,input().split())
if A == 0:
    print(0)
else:
    ans = A*(N//(A+B))
    rem = N%(A+B)
    ans += min(rem,A)
    print(ans)
def main():
    N, A, B = (int(i) for i in input().split())
    ans = (N//(A+B)) * A
    less = N - (N//(A+B)) * (A+B)
    print(ans + min(less, A))


if __name__ == '__main__':
    main()
import sys
n,a,b = map(int,input().split())
if a == 0:
    print(0)
    sys.exit()


num = n // (a + b)
div = n % (a + b)
print(num * a +min(div,a))
N, A, B = map(int, input().split())

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

print(x + min(A, y))
n,a,b = [int(i) for i in input().split()]

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

print(div * a + min(mod,a))
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)))
N, A, B = map(int, input().split())
ans = N //(A + B)*A
rem = N % (A +B)
ans += min(rem, A)

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

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

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

print(ans)
#-*-coding:utf-8-*-
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()
N, A, B = map(int,input().split())

roop = A + B

kaisu = N//roop
amari = N % roop

blue = 0
blue = blue + kaisu*A

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


print(blue)
n,a,b = [int(i)for i in input().split()]
cycles = n//(a+b)
remain = n%(a+b)
ans = cycles*a+min(remain,a)
print(ans)
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))
n, a, b = map(int, input().split())
c = a + b

if c < n:
  a += n-c

print(a)
n,a,b = map(int,input().split())
print((a)*n//(a+b) + min(n%(a+b),a))
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)
# coding: utf-8
import os, sys
import numpy as np

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

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

diff = A if rest >= A else rest  
ans = A * rep + diff

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

c = n // d
n = n % d

if n <= a:
    print(Total - c*b)
else:
    print(a * c)
n,bl,re = map(int,input().split())
ans = 0
while n > 0:
  n = n - bl -re
  ans += bl
if bl == 0 or n < 0:
  print(round(ans))
elif bl >= n:
  ans = ans + n
  print(round(ans))
N, A, B = map(int, input().split())
if A == 0:
  print(0)
else:
  print(N) if A > N or B == 0 else print(A if N < (A + B) else N - B)
n,a,b = map(int,input().split())
ans = 0

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

loop = n/(b+r)
mod = n%(b+r)
extra = min([b,mod])

print(int(loop*b + extra))
N, A, B = map(int, input().split())
 
x = A + B
 
num = 1
y = 0
while N <= y:
  y = x * num
  num += 1
 
if N - num * x < A:
  print( A * num + ( N - num * x ) )
else:
  print( A * ( num + 1 ) )
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N, A, B = MI()
    if A != 0:
        print(N-pow(10, 100, A+B))
    else:
        print(0)
if __name__ == '__main__':
    main()
import math


def main():

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

    answer = 0
    if 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()
N, A, B = map(int, input().split())

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

r = N % (A + B)

ans = ans + min(r, A)

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

while n >= 0:
    if n >= a+b:
        n -= (a+b)
        c += 1
    else:
        if n <= a:
            print(a*c + n)
        else:
            print(a*c)
        break
n,a,b = map(int,input().split())
if a+b>=n:
    print(a)
elif a == 0:
    print(0)
elif b == 0:
    print(n)
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())
num = N // (A + B) * A
num += N % (A + B)
print(num)
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
Ans=A*Ans1+Ans2

print(Ans)
N, A, B = map(int, input().split())
count = N//(A+B)
print(count*A+N-count*(A+B))
N, A, B = map(int, input().split())

a = N // (A + B)
if N % (A+B) != 0:
    a_cnt = ( a * A ) + ( N % (A+B) )
else:
    a_cnt = a * A

print(a_cnt)
n,b,r = map(int,input().split())
syo = n//(b+r)
amari = n%(b+r)
if amari == 0:
  print(b*syo)
else:
  if amari <= b:
    print(b*syo + amari)
  else:
    print(b*syo - (b-amari))