peterverebics/CodeNet_Python_118 huggingface dataset:
n,a,b=map(int,input().split())
lis=""
ans=0
for i in range(n):
 for b in range(a):
  lis+='b'
  ans+=1
 for r in range(b+1):
  lis+='r'
print(ans)
n,a,b = map(int,input().split())
if n % (a + b) > a:
    print(n // (a + b) * a + n % (a + b) + a)
else:
    print(n // (a + b) * a + n % (a + b))
# Code for B - Count Balls
# Use input() to fetch data from STDIN
import math

[n, a, b] = map(int, input().split())
total = math.floor(n / (a + b)) * a
total += min(b, (n % (a + b)))
print(total)
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  str_length = a + b
  if n <= str_length:
    print(a)
  else:
    v = 10 ** 100
    s = ""
    str_count_all = str_length * v
    if n >= str_count_all:
      print(a*v)
    else:
      mod = str_length - n
      add = mod if mod < a else a
      print(a*(v-1)+add)
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 X > N:
    print(B)
N, A, B = map(int, input().split())
if A == 0:
  print(0)
else:
  print(N) if A > N else print(A if N < (A + B) else N - B)
n,a,b=map(int,input().split())

if a == 0:
    print(0)
elif n < a:
    print(n)
elif n < (a+b):
    print(a)
else:
    q = n // (a+b)
    mod = n % (a+b)
    print((a*q)+mod)
n,a,b = map(int, input().split())
n,a,b = map(int, "8 3 4".split())

tmp = int(n /(a+b))
amari = int(n %(a+b))

if amari >= a:
    print(tmp*a + a)
else:
    print(tmp*a + amari)
data = input().split(" ")
tmp = 0
total = 0
data[0] = int(data[0])
data[1] = int(data[1])
data[2] = int(data[2])
  
data1 = data[1] + data[2]
  
data2 = int(data[0]) / data1
total = data[1]*data2
tmp = data1*data2
data3 = data[0]%data1
  
if (data3 != 0) and (data3 < data[1]):
  total += data3
  
print(int(total))
N,A,B = map(int,input().split())
C=A+B
D=N//C #何セットあるか
E=C*D

if N-E>=A:
  ans= D*A
else:
  ans= D*A+ (N-E)
  
print(ans)
N,A,B = input().split(' ')
if int(A)+int(B)==int(N):
    print(A)
elif int(A)==0:
    print(0)
elif int(A)+int(B)<int(N):
    for x in range(int(N)):
        if int(A) + int(B) < int(N):
            A=int(A)+1
            if int(A) + int(B) == int(N):
                break
            else:
                B=int(B)+1
    print(A)
N, A, B = map(int, input().split())
print(N - B * (N//(A+B)))
N, A, B = map(int, input().split())

n = N // (A + B)
if n * (A + B) == N:
    print(n * A)
else:
    if n * (A + B) + A <= N:
        print(n * A + n)
    else:
        diff = N - n * (A + B)
        print(n * A + diff)
N, A, B = map(int, input().split())
if N >= (A+B):
    ans = A * (N//(A+B)) + min((N - ((A + B) * (N//(A+B)))), A)
else :
    ans = A
print(ans)
if __name__ == '__main__':
    (n, a, b) = map(int, input().split())
    a = n//(a+b)
    m = min(n%(a+b), a)
    print(a+m)
n,a,b=map(int,input().split())

ans=a*n//(a+b)
hoge=n%(a+b)
if(hoge>a):
  ans+=hoge-a
else:
  ans+=hoge

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

ans1 = (N//(A+B))*A
ans2 = (N%(A+B))
if ans2 > A:
    ans2 = ans2 -A

ans = ans1 + ans2

print(ans)
from sys import stdin
n,a,b = map(int,stdin.readline().rstrip().split())
if a <= n:
    print(a)
else:
    print(n)
n, b, r = map(int, input().split())
if b == 0:
    print(0)
else:
    print(n - r)
N,A,B = map(int, input().split())
if A == 0 or A + B == 0:
    print(0)
else:
    ans = (N // (A + B)) * A  + min(B, (N % (A+B)))
    #print(N // (A+B))
    #print(min(B, (N%(A+B))))
    print(ans)
n,a,b = list(map(int,input().split()))

t1 = n // (a+b)
t2 = n % (a+b)
ans = t1 * a + t2
print(ans)
n,b,r=map(int,input().split())
c=n//(b+r)
print(n-c*r)
N, A, B =[int(x) for x in input().split()]

if A!=0:
    ans = N*A//(A+B)
    mod = N%(A+B)
    plus = min(mod, A)
    c = ans + plus 
else:
    c = 0
print(c)
n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
diff = abs(a - b)

print(diff, x, mod)
if diff >= mod:
    print(a * x + mod)
else:
    if n % 2 == 0:
        print(a * (x + 1))
    else:
        print(a * x + mod)
n,a,b = map(int,input().split())
ans = 0

while True:
  if n > a + b:
    ans += a
    n -= a + b
  elif n == a + b:
    ans += a
    break
  else:
    ans += n
    break

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

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

print(ans)
N,A,B=map(int,input().split())
ball=A+B #3+4=7
s=N//ball #1
y=N%ball #1
print(s*A+y)
n,a,b = map(int, input().split())
print(int(n*a/(a+b)) + min((n%(a+b),a)))
N,A,B = map(int,input().split())

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

print(ans)
n, a, b = list(map(int, input().split()))
if (a == 0):
    print(a)
else:
    print(n-b)
n,a,b = map(int,input().split())
if a+b>=n:
    print(a)
else:
    cnt = 0
    while n>0:
        n -= a
        n -= b
        cnt += a
        if n<a:
            cnt += n
            break
    print(cnt)
n,a,b = map(int, input().split())
print(a*n//(a+b)+min(a,n%(a+b)))
n,a,b=map(int, input().split())

balls= 0
blue = 0

for i in range(10**18):
  if i % 2 == 0:
    balls = balls + a
    blue = blue + a
  else:
    balls = balls + b
  if balls > n:
    break

print(blue)
n, a, b = map(int, input().split())
if a + b == n:
  print(a)
elif a == 0:
  print(0)
else:
  print(n - b)
import math
N,A,B=map(int,input().split())
print(int(math.floor(N/(A+B))*A+(N-(A+B)*math.floor(N/(A+B)))))
n,a,b =map(int,input().split())
c = a+b

sum1 = n/c
l = n%c
if a>l:
  sum2 = l
else:
  sum2 = a
  
print(sum1+sum2)
n,a,b=map(int,input().split())

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

r = (bl * a) + m
print(r)
n, a, b = map(int, input().split())
repeat = n // (a+b)
remain = n - (a+b) * repeat
remain_blue = max(remain - a, 0)
print(b * repeat + remain_blue)
N, A, B = map(int, input().split())

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

ans = (n//(a+b))*a
ans += (n%(a+b))
print(ans)
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
if n%(a+b)==0:
    z=n//(a+b)
    print(z*a)
else:
    z=n//(a+b)+1
    print(z*a-(a-(n-(b+a))))
N,A,B = input().split()
N = int(N)
A = int(A)
B = int(B)
C = A + B

if N / C < int(N / C):
    T = int(N / C) - 1
else:
    T = int(N / C)

if T == 0:
    T = 1

if N - T * C > 0:
    if A >= N - T * C:
        count = T * A + (N - T * C)
    else:
        count = T * A + A
else:
    count = T * A

if B == 0:
    count = N
print(count)
import math
n , a , b  = map(int, input().split())
ans = n/(a+b)
print(math.ceil(ans*a))
n,a,b=map(int,input().split())
print(a*n//(a+b)+min(n%(a+b),a))
def solve():
    N, A, B = map(int, input().split())
    
    ans = A * (N // (A + B)) + N % (A + B)
    print(ans)


if __name__ == '__main__':
    solve()
inp = input().split()
inp = [int(i) for i in inp]
N, A, B = inp
print(((N//(A+B)*A + N%(A+B))))
n,a,b=map(int,input().split())
if a==0:
    print(0)
else:
    print((n//(a+b))*a+(a+b)%a)
n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-temp>=a:
  result=temp+a
else:
  result=temp+n
print(result)
n,a,b=map(int,input().split())
res=0
if a+b>=n:
    res=a
else:
    res=a*n//(a+b)
    if n//(a+b)>=a:
        res+=a
    else:
        res+=n%(a+b)
        
print(res)
n, a, b = map(int, input().split())

c =0
r = n%(a+b)
if r < 1: 
    print(a)
elif r >= 1:
    t = r//(a+b)
    c += t*a
    tr = r%(a+b)
    if tr < a:
        c += tr
        print(c)
    elif tr > a:
        c += a 
        print(c)
A, B, N = map(int, input().split())

ans = 0
ans += N // (A + B) * A
ans += min(N % (A + B), A)
print(ans)
N,A,B=(int(x) for x in input().split())
num=0

if N <= A+B:
    print(N-B)
else:
    while N > A+B:
        num=num+A
        N=N-A-B
        if(N <= A+B and N <= A):
            print(num+N)
        elif(N <= A+B and N >= A):
            print(num+A)
N, A, B = map(int, input().split())
stck = (N // (A+B)) * A
remn = N % (A + B)
if remn <= A:
  stck += remn
print(stck)
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())
print(N//(A+B)*A + N%(A+B))
N, A, B = map(int, input().split())
if A == 0:
    print(0)
    exit()
P = A + B
X = N//P
x = N%P

if x >= A:
    ans = A*X+4
    print(ans)
elif x < A:
    ans = A*X+x
    print(ans)
a,b,c=map(int,input().split())
print((a//(b+c))*b-a%(b+c))
import sys
n,a,b=map(int,input().split())
N=n
A=0
B=0
while 1:
    A+=a

    N-=(a+b)
    if N<=a:
        print(a+N)
        break
n, a, b = map(int, input().split())
if a==0:
    print(0)
elif n>=a+b:
    print((n//(a+b))*a+(n%(a+b))%a)
elif n<a+b and n>a:
    print(a)
else:
    print(n)
n = [int(x) for x in input().split(' ')]

x = n[0]
b = n[1]
r = n[2]
answer = 0
switch_blue = True

while x > 0:
    if switch_blue:
       answer += min(x, b)
       x -= answer
    else:
        x -= min(x, r)
    switch_blue = not switch_blue

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari > a:
    print(times * a + amari)
else:
    print(times * a )
n, a, b =(int(x) for x in input().split())

ans = 0
ab = a+b

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

ans = n // ab
ans = ans * a + (n%ab)
print(ans)
n,a,b=map(int,input().split())
x=n//(a+b)
print(a*x+n-(a+b)*x)
total,blue,red=map(int,input().split())
num = -(-total)//(blue+red)
if blue == 0:
    print(0)
else:
    if num < 10**100:
        print(num*blue+(total%(red+blue)))
    else:
        print((10**100)*blue)
n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
if n % 2 != 0:
    if a < b:
        print(a * x + mod)
    else:
        print(a * (x + 1))
else:
    print(a * x + mod)
n, a, b = map(int, input().split())

b_count = n // (a+b) 
print(n-(a+b)*b_count + a*b_count)
n,b,r = map(int, input().split())
if (n%(b+r))==0: print((n//(b+r))*b)
elif (n%(b+r)) <= b: print((n//(b+r))*b+(n%(b+r)))
else: print((n//(b+r))*(b+1))
# ABC 158: B – Count Balls
N, A, B = [int(s) for s in input().split()]

blues = A * (N // (A + B))
remains = N % (A + B)

if remains < A:
    blues += remains

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

ans = 0
kake = 0
if A + B == N:
    ans = A
elif A == 0:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

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

if a == 0:
    print(0)
elif n >= a + b:
    print(a + n // (a + b))
else:
    if n < a:
        print(n)
    else:
        print(a)
# -*- coding: utf-8 -*-
i_str = input()
N,A,B = map(int,i_str.split())

import sys
AB = A+B

if A == 0:
    print(0)
    sys.exit()
waru,amari = divmod(B,AB)
#waru = (N // AB)
#amari = N % AB
answer = waru * A + amari
print(answer)
n, a, b = map(int, input().split())
print(a * (n // (a + b)) + n - (a + b) * (n // (a + b)))
N,A,B=map(int,input().split())

if N%(A+B)<=A:
    print(N//(A+B)*A+N%(A+B))
else:
    print(N//(A+B+1)*A)
n, a, b = map(int, input().split())
if n < a:
    print(n)
elif n < a + b:
    print(a)
else:
    print(int(n / (a + b)) * a + n % (a + b))
N, A, B =[int(x) for x in input().split()]
line = []

for i in range(int(N/(A+B))):
    for x in range(A):
        line.append("b")
    for y in range(B):
        line.append("r")

print(line[0:N:].count("b"))
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
if A > 0:
    print(A + N % (A + B))
else:
    print(0)
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 amari_num <= A:
        ao_count += A


    print(ao_count)



if __name__ == "__main__":
    resolve()
N, A, B = map(int, input().split())
S = N//(A+B)
R = N%(A+B)
if R < A:
    print(S*A+R)
else:
    print((S+1)*R)
import math
N, a, b = map(int, input().split())

if N < b:
    print(N)
elif N < a + b:
    print(b)
else:
    times = math.floor(N / (a + b))
    amari = N % (a + b)
    no_blue = a * times + amari
    print(no_blue)
import sys

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

if blue == 0:
    print(0)
    sys.exit()
if n <= blue:
    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 - red))
N, A, B = map(int, input().split())
ans = 0

if A == 0:
    ans = 0
elif N <= A:
    ans = N
elif N <= A + B:
    ans = min(N, A)
else:
    total = A + B
    i = N // total
    mod = N % total
    ans = A * i + mod

print(ans)
a = input().split()

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

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

cut = N - (A+B)*(i-1)

if cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + ((A+B)*i - N)
  
print(Blue_Ball_Num)
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 )
n, a, b = map(int, input().split())
q = n // (a + b)
r = n % (a + b)

print(q*a + r)
N, A, B = map(int, input().split())

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

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

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

if a == 0:
    print("0")
else:
    ans = n // (a+b)
    remainder = n % (a+b)

    if remainder > b:
        print("{}".format(ans*a + a))
    else:
        print("{}".format(ans*a + remainder))
# 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)
elif N > A + B:
    num = int(N / (A + B)) * A
    # print("num:", num)
    num += N % (A + B)
    # print("num:", num)
    print(num)
else:
    print(A)
N,A,B=map(int,input().split())

c=A+B

b=0

if int(N/c)>0:
  b=(int(N/c)*A)+(N%c)
else:
  if N<A:
    b=N
  else:
    b=A

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


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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    times = times + 1

print(times * a)
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
ans=B+(S-B-R)
print(ans)
N, A, B = map(int, input().split())
if A > 0 and B > 0:
    A = A * (N // (A + B)) + N % (A + B)
    print(A)
else:
    print(0)
n,a,b = list(map(int, input().split()))

if (a+b) == 0:
  print(0)
else:
  trial_num = n // (a + b)
  amari = n % (a + b)
  
  if a == 0:
    print(0)
  else:
  	print(trial_num*a + amari)
# input
N,A,B = map(int, input().split())
# calc
blue = A*(N//(A+B)) + N%(A+B)
# output
print(blue)
N, A, B=map(int, input().split())
ans=(N//(A+B))*B+N%(A+B)-A
print(ans)
N,A,B=map(int,input().split())
a=(N//(A+B))*A
c=A+B
b=int(N%c)
if b<=A:
  print(a+b)
else:
  print(a)
N, A, B = map(int, input().split())
ans = 0

if A == 0:
    ans = 0
elif N <= A:
    ans = A
else:
    total = A + B
    i = N // total
    mod = N % total
    ans = A * i + mod

print(ans)
n, a, b = map(int, input().split())
print((n//(a + b)) * a + min((n//(a + b)) * a, (n % (a + b))))
a,b,c = map(int,input().split())
d = 0
l = a // (b+c)
k = a % (b+c)
if b == 0:
    print('0')
    
elif b + c >= a:
    if b < a:
        print(b)
    elif b > a:
        print(a)
    
elif b + c < a:
    if a % (b + c) == 0:
        print(int(l))
    elif a % (b + c) != 0:
        print(int(l*b + k))
n, a, b = list(map(int, input().split()))
ans = (n // (a + b)) * a + n % (a + b)
print(ans)
n,a,b=map(int,input().split())
if a==0 :
  print("0")
elif a==n or (a+b)==n :
  print(a)
elif (a+b)<n :
  print(a+(n-(a+b)))
elif (a+b)>n :
  print(n)
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: int, B: int):
    print(A*N//(A+B)+N%(A+B))
    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))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

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

if b==0:
    print(0)
else:
    sets=n//(a+b)
    res=n%(a+b)

    resa=min(res,a)

    print(sets*a+resa)
N, Blue, Red = map(int, input().split())

if(Blue >= N):
    print(N)
elif (Blue + Red) >= N or Blue == 0:
    print(Blue)
else:
    q = N // (Blue + Red)
    mod = N % (Blue + Red)
    print(q * Blue + mod)
N, A, B = map(int, input().split())
if N >= A+B:
  print(N-B)
elif N < A:
  print(N)
else:
  print(A)
n, a, b = map(int,input().split())

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

ans = d * a + c

print(ans)
N,B,R = map(int,input().split())
if B == 0:
  print(0)
if B == 0 and R != 0:
  print(N)
limit = N//(B+R) #genkai
blue = limit * B
print(blue)
red = limit * R
N-=(blue+red)
count = 0
while N > 0 and count < blue:
  N-=1
  blue += 1
  count += 1
  if count == B:
    N-=R
    if N>0:
      count = 0
      continue
print(blue)
n, a, b = map(int, input().split())
if n - (a + b) <= a:
    print(n // (a + b) * a + (n - (a + b)))
else:
    print(n // (a + b) * a + a)
n,a,b = input().split(" ")
n = int(n)
a = int(a)
b = int(b)
c = n//(a+b)
ans = c*a+(n-c*(a+b))
print(ans)
N,A,B = list(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 B==0 and A<=N:
    print(N)
elif A+B<N and (N-(A+B))-A>0:
    print(A+(A*(N//(A+B))))
else:
    print((N-(A+B))+A)
N, A, B = (int(x) for x in input().split())

number = int(N/(A+B))
r = int(N % (A+B))

print(A*number + r)
def main():
    n, a, b = map(int, input().split())
    q, mod = divmod(n, (a+b))
    x = mod if mod < n else a
    print(q*a+x)

if __name__ == "__main__":
    main()
n,b,r = map(int, input().split())
#if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
#else: print((n//(b+r))*(b+1))
ans = n//(b+r)+b
re = n%(b+r)
ans += min(re, ans)
print(ans)
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())

loop_count = n // (a + b)
amari = n % (a + b)
amari_a = a
if amari < a:
  amari_a = amari

print(a * loop_count + amari)
N,A,B = (int(x) for x in input().split())
c = N // (A + B)
p = N - c * (A + B)
a = c * A
a += a if p >= B else p
print(a)
N, A, B = map(int, input().split())
M = N // (A + B)

if N > (A + B):
    print(A * M + N - M * (A + B))
else:
    print(min(N, A))
N, A, B = map(int, input().split())

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

print(quotient * A + remainder)
N, A, B = map(int, input().split())
ans = 0
i = 0
while(N>0):
    if i%2==0:
        N-=A
        ans+=A
        if N<0:
            break
    else:
        N-=B
    i += 1
print(ans+N)
N,A,B=map(int,input().split())
t=N//(A+B)
ans=(t*A)+(N%(A+B))
print(ans)
n,a,b = map(int,input().split())
ans=(n//(a+b))*a+n%(a+b)
print(ans)
N,A,B=map(int,input().split())
a=(N//(A+B))*A
c=A+B
b=int(N%c)

if b<=A:
  print(a+b)
else:
  print(a)
def resolve():
    N,A,B=map(int,input().split())
    C=A+B
    S=N%C
    print(A*N//C+min(A,S))



if __name__ == "__main__":
    resolve()
n, a, b = [int(i) for i in input().split()]
out = (n // (a + b)) * a
t = n % (a + b)
out += t if(t <= a) else t - b
print(out)
N, A, B = map(int, input().split())

c = N // (A + B)

if (A == 0):
    print(0)
    exit()
if (N <= A):
    print(N)
    exit()
elif (N <= (A + B)):
    print(A)
    exit()

if (A + B) * c < N:
    if (N - (A + B) * c <= B):
        print(A * c + N - (A + B) * c)
    elif(N - (A + B) * c > B):
        print(A * c + A)
elif (A + B) * c == N:
    print(A * c)
n,a,b = list(map(int,input().split()))

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

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

print(int(res))
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))
print(int(tmp+min(tmp_2,A)))
char = input().split(" ")
n = int(char[0])
blue = int(char[1])
red = int(char[2])

num = blue + red

ans = n // num
res = n % num

print(ans * blue + res)
N, A, B = map(int, input().split())
result = A + (N - A - B)
if A == 0:
    print(0)
else:
    print(result)
n,a,b = map(int, input().split())

x = []
z = n // (a+b) + 1
for i in range(z):
    for j in range(a):
        x.append(0)
    for j in range(b):
        x.append(1)

print(x.count(1))
#https://atcoder.jp/contests/abc158/tasks/abc158_b
# -*- coding: utf-8 -*-
N,A,B = map(int,input().split())
syou = N//(A+B)
amari = N%(A+B)
if amari>A:
  amari=amari
ans = syou*A+amari
print(ans)
n,a,b = map(int,input().split())
s = a+b
if((n%s) < a):
    print(int(a*(n/s))+n%s)
else:
    print(int(a*(n/s)))
N, b, r = map(int, input().split())

s = 0
t = 0
for i in range(1000):
    t = t+b+r
    s += 1
    if N<=t:
        if (t-N)<r:
            print(s*b)
            exit()
        else:
            print((s-1)*b+N-t+b+r)
            exit()
N,A,B=map(int,input().split())
if A==0:
    print(0)
elif B==0:
    print(N)
else:
    co=0
    i=0
    while (A+B)*i<N:
        i+=1
    co=A*(i-1)+(N-(A+B)*(i-1))
    print(co)
n, a, b = map(int,input().split())

x = int((a+b)/n) #何周目か
y = (a+b)%n 
ans = x * a + y

print(ans)
N,A,B = map(int, input().split())
sum=0
for i in range(1000):
    sum = sum + B
    if (sum <= N):
        break
print(sum)
import math
import sys

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

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

ans = 0
rep = math.ceil(a / (a + b))

ans += min(n, a * (rep))
ans += max(0, n - (a + b) * (rep))

print(ans)
n,a,b=map(int,input().split())
mm=max(a,b)
if a==0:
    print(0)
    exit()
if b==0:
    print(n)
    exit()
xx=n//mm 
ans=((xx-1)*a)
baaki=n-((xx-1)*a)-((xx-1)*b)
# print(baaki)
while baaki>0:
    temp=min(baaki,a)
    baaki-=temp
    ans+=temp
    if baaki<=0:
        break
    temp=min(baaki,b)
    baaki-=temp
    if baaki<=0:
        break 
print(ans)
n, a, b = map(int,input().split())

if a + b == 0:
    x = 1
else:
    x = a + b

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

if d > a:
    ans = (c*a) + a
else:
    ans = (c*a) + d
    
print(ans)
N,A,B=map(int,input().split())
x=N//(A+B)
y=N%(A+B)
if y<=A:
  print(B*x)
else:
  print(B*x+y-A)
#inport
import sys
import numpy as np
#import itertools as itlt
#from collections import deque

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

num = np.floor(N/(A+B))*A
if N%(A+B)>=A:
    num = num + A
else:
    num = num + N%(A+B)

print(int(num))
N,A,B=list(map(int,input().split()))
a=0
s=0
for i in range(10**18):
  a+=A
  s+=A+B
  if N<s:
    break
    print(a)
n,a,b=(int(x) for x in input().split())
c = 0
if a == 0:
    print(0)
    
    
elif n - (a+b) == 0:
        print(a)
        
        
else:
        ans = a + (n-(a+b))
        print(ans)
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

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

if(r <= a):
  print("{}".format(q * a + r))
elif(r > a):
  print("{}".format((q + 1)* r))
N, A, B = map(int, input().split())

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