peterverebics/CodeNet_Python_118 huggingface dataset:
N,A,B = map(int, input().split())

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

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

set_count = N // (A+B)
extra = N % (A+B)

print(set_count*A + extra)
(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 + rest)
else:
    print(cnt*A + A)
N, A, B = map(int, input().split())

count = 0
t1 = (N * A) // (A + B)
t2 = N % (A + B)

count += t1
count += min(t2, A)

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

if A == 0:
    print(0)

else:
    print(A+N-(A+B))
N, A, B = map(int, input().split())

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

if N <= A:
    print(N)
    exit()

if A+B == N:
    print(A)
    exit()

print( N - B )
n, a, b = map(int, input().split())
cnt = 0
ans = 0
if n//(a+b) <= 10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
else:
    ans += a * (10**100//(a+b))
    cnt += (10**100//(a+b))*(a+b)

if n - cnt >= a:
    ans += a
else:
    ans += n - cnt
print(ans)
n,a,b=list(map(int,input().split()))
if n<=a:print(n)
elif n<=b or a==0:print(a)
else:print(a+(n-a-b))
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
else:
    ans += ans_mod

print(ans)
ballinput = input().split(" ")
Nball = int(ballinput[0])
blue = int(ballinput[1])
red = int(ballinput[2])
diff = 0
sumball = blue + red
con1 = Nball >= 1 and Nball <= 10^18
con2 = sumball > 0 and sumball <= 10^18
if con1 == True and con2 == True:
  if blue >= 0 and red >= 0:
    if sumball == Nball:
      print(blue)
    elif blue == 0:
      print(0)
    elif red == 0:
      print(blue)
    else:
      diff = Nball - sumball
      blue = blue + diff
      print(blue)
  else:
    print()
else:
  print()
n,a,b = map(int,input().split())
result = 0
while True:
    if n  >= (a + b):
        result += a
        n -= a+b
    elif 0 <= n <= a:
        result += n
        break
    else:
        break

        
print(result)
date=input().rstrip().split(" ")
num0=int(date[0])
b=int(date[1])
r=int(date[2])
sum=b+r
if num0%sum==0:
  print(int((num0/sum)*b))
elif num0%sum>=b:
  print(int(((num0-num0%sum)/sum)*b+b))
else:
  print(int(((num0-num0%sum)/sum)*b+num0%sum))
n, a, b = map(int, input().split())

r = a+b

if n%r <= a:
    print(n//r * a + n%r)
else:
    print(n//r + a)
N, A, B = map(int, input().split())
C = A + B
x = N // C
y = N % C
p = x * A
q = min(y, A)
p + q
n,a,b=map(int,input().split())
kosuu=n//(a+b)*a+n%(a+b)
print(kosuu)
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 + a)
N, A, B = map(int, input().split())
X = N // (A + B)
R = X * A
X += min(A, N % (A + B))
print(X)
import sys
n, blue, red = map(int, input().split())
bcount = 0
arr = []

while n != 0:
  if n < (red + blue):
    break
  n -= (red + blue)
  bcount += blue

if n < (red + blue):
    if n >= blue:
      print(blue)
    else:
      print(blue - n)

print(bcount)
n,a,b=map(int, input().split())
(n//(a+b))*a+n%(a+b)
x, a, b = map(int, input().split())

cnt = 0
sum = 0
i = 0
if a == 0:
    print(0)
    exit()
while sum + a + b < x:
    i % 2 == 0
    sum += a
    cnt += a
else:
    sum += b

print(cnt + min(x - sum, a))
n, a, b = map(int,input().split())

if a >= n:
    k = a -n
elif a < n:
    k = a * (n // (a+b))

l = n % (a+b)

print(k + l)
n, a, b = map(int,input().split())
a_b = n//(a+b)*a
if n - n//(a+b)*(a*b) < a:
    print(a_b + n - n//(a+b)*(a+b))
else:
    print(a_b + a)
N, A, B = map(int, input().split())
N = N - B
if N - A >= 0 and A > 0:
    print(N)
else:
    print(0)
def main():
    N,A,B = map(int,input().split())
    if N < (A+B):
        if A == 0:
            print(0)
        else:
            print(N)
        exit()
    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()
N,A,B = (int(i) for i in input().split())

M = A+B

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

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

print(count)
N, A, B = map(int, input().split())
roop = int(N / (A + B))
nokori = N - roop * (A + B)
if nokori <= B:
    ans = roop * A + nokori
else:
    ans = roop * A + B
print(ans)
n,a,b=map(int,input().split())
c=a*n//(a+b)
r=n%(a+b)
if r<=a:
  print(c+r)
else:
  print(c+a)
n,a,b=map(int,input().split())
if n%(a+b)==0:
  print(a*n//(a+b))
else:
  t=n//(a+b)
  u=n%(a+b)
  uu=min([a,u])
  print(t*a+u)
n,a,b = (int(x) for x in input().split())

c = a+b

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

x = (a+b)//n + ((a+b)%n != 0)
rem = n - (a+b)*x
ans = a * x + min(a, rem)
print(ans)
N,A,B=map(int,input().split())
co=0
i=0
while (A+B)*i<N:
    co=co+A
    i+=1
print(co)
nums = list(map(int, input().split()))
n = nums[0]
a = nums[1]
b = nums[2]

if a == 0:
    print(0)
elif b == 0:
    print(a)
else:
   print(int(n / (a+b) * a))
N,A,B=map(int,input().split())
m=A+B
x=N//m
y=N%m
if y<=A:
    print(int(x*A+y))
else:
    print(int(x*(A+1)))
a,b,c=map(int,input().split())
l=[]
k=0
s=a-b-c+1
for i in range(s):
    for g in range(b):
        l.append("1")
    for g in range(c):
        l.append("2")
for j in range(a):
    if l==[]:
        k=0
        break
    elif l[j]== "1":
        k+=1
print(k)
def count_ball(n, a, b):
    print(n//(a+b)*a + n%(a+b))

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

count_ball(n, a, b)
n,a,b = input().split()
gokei = 0
b_sum = 0
n = int(n)
a = int(a)
b = int(b)
while gokei < n:
  b_sum += a
  gokei += a
  if gokei > n:
    b_sum = b_sum - (gokei - n)
    break
gokei += b  
print(b_sum)
n, a, b = map(int, input().split())

ans = a * (n // (a + b)) + (n % ( a + b))
print(ans)
n,a,b,=map(int, input().split())
print(int(n / (a+b)) * a + n % (a+b))
X,A,B = map(int, input().split())
if A == 0 or A == X-B:
    print(A)
else:
    print(X-B)
N, A, B = map(int,input().split())
AB = A + B
n = N//AB
if AB > N and A <= N:
  print(A)
else:
  amari = N - n*AB
  print(n*A+amari)
n,a,b =list(map(int,input().split()))

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

S = A+B
count = N//S
pre_cnt = A*count
S_amari  = N-S
if S_amari >= A:
  cnt  = pre_cnt + A
else:
  cnt = pre_cnt + S_amari

print(cnt)
N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
count=0

if a==0:
  print('0')
  exit()
else:
  while n>=a:
    n=n-a
    count+=1
    if n>=b:
      n=n-b
    else:
      break

ball=a*count+n

print(ball)
n,a,b = list(map(int,input().split()))
to, ans = 0 , 0

if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n <= a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)
N, A, B = [int(i) for i in input().strip().split()]
res = 0
cnt = 0

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

print(A*q + r)
n,a,b = map(int,input().split())
c = n//(a+b)
d = n % (a+b)
if d > a:
    ans = c * (a+1)
else:
    ans = c * a + d
print(ans)
# coding: utf-8
# Your code here!
N, A, B = map(int, input().split())
c=A+B

if A==0:
    print(0)
else:
    d = N//c
    e = d*A
    f = N%c
    print(e+f)
n,a,b = map(int,input().split())

if a == 0:
  print(0)
elif b == 0:
  print(n)
elif a >= n:
  print(n)
elif b >= n:
  print(a)
elif a+b >= n:
  print(a)

else:
  c = a*n//(a+b) + min(n%(a+b),a)
  print(c)
n, a, b = map(int, open(0).read().split())
q, r = divmod(n, a+b)
print(q*a + r)
from sys import stdin
N,A,B = list(map(int,stdin.readline().strip().split()))
C=A+B
ans=A*(N//C)
ans+=N%C
print(ans)
n, a, b =map(int, input().split())

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

num_A=int(N/(A+B))
sur=int(N-(A+B)*num_A)

print(num_A*A+sur)
N, A, B = map(int, input().split())

phrase = A + B

ans = N // phrase * A
ans += N % phrase if N % phrase <= A else 0
print(ans)
N, A, B=list(map(int, input().split()))
if A+B==N:
	a=A
elif A==0:
    a=0
else:    
    a=N-B
  
    
print(a)
N, A, B = map(int, input().split())
l = A + B
C = N // l
print(A * C + N - (l * C))
# -*- coding: utf-8 -*-

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

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

if B == 0:
    print(N)
    exit()

zentai_num = N // (A+B)
zentai_b = zentai_num * A


amari_num = N % (A+B)

amari_b = 0
if amari_num >= B:
    amari_b = B
else:
    amari_b = amari_num

# amari_b = max(amari_num - B,0)

# print(amari_num,amari_b)

print(zentai_b + amari_b)
import sys


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

    if a == 0 and b == 0:
        print(0)
        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())

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

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

blue = (x * A) + y
print(blue)
n,a,b = map(int, input().split())
m1 = n // (a + b)
m2 = n % (a + b)

if a ==0:
  print(0)
elif a >= n:
  print(n)
elif a + b >n:
  print(a)

else:
  if m2 >= a:
    print(m1 * (a +1))
  else:
    print(m1 * a + m2)
n,a,b = map(int,input().split())
x = n/(a+b)
y =n%(a+b)
print(x*a+y)
n,a,b=map(int,input().split())
print((n//(a+b))*a + min((n-(a+b)),a))
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:
    for i in range(10 ** 100):
      length = (i + 1) * str_length
      if length > n:
        blue_count = (i * 1) * a
        mod = n - i * str_length
        add = mod if mod < a else a
        print(blue_count + add)
        break
n, a, b = map(int, input().split())

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

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

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

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

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


ans = (N//(A+B)) * A
if((N % (A+B)) <= A):
    ans +=( N % (A+B))
print(ans)
N,A,B = map(int,input().split())
#n blue red
#8 3 4
#bbbrrrrb
#4
ans = 0
x = N // (A+B)
ans += (x * A)
N -= x * (A+B)
if N <= A:
  ans += N
else:
  ans += A
n,a,b = map(int,input().split())
c = n//(a+b)
d = (n%(a+b))-a
if b ==0:
    print(0)
elif n%(a+b)==0:
    print(c*b)
elif n%(a+b) != 0 and d >= 0:
    print((c*b)+d)
else:
    print(c*b)
N,A,B= input().split()
ans=int(N)//(int(A)+int(B))*int(A)+int(N)%(int(A)+int(B))
print(ans)
#

import sys
from decimal import Decimal
input=sys.stdin.readline

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

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

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

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

print(n // (a + b) * a + n % (a + b))
N, A, B = [int(i) for i in input().split()]
tmp = A * N//(A+B)
res = N - (A+B) * (N//(A+B))
if res > A:
    print(tmp + A)
else:
    print(tmp + res)
N,A,B=map(int,input().split())
c=N-(A+B)
d=int(N%(A+B))
if c==0:
    print(A)
else:
    print(A*c+min(A,(N%(A+B))))
n,a,b = map(int,input().split())

r_1 = n // (a + b)
r_2 = n % (a + b)
print(r_1*a + r_2)
n, a, b = map(int, input().split())
if b == 0:
  print(n)
else:
	print(a * n//(a+b) + min(a, n%(a+b)))
N,A,B = (int(x) for x in input().split())
S =  N % (A+B) - A
Acount = N % (A+B)
Ansn = int(N / (A + B) * A)
if S <= 0:
    print(Ansn + Acount)
else:
    print(Ansn + A)
n,a,b = map(int,input().split())
count=0
ans=0

while n>=a+b:
    count+=a
    n=n-(a+b)
if a==0:
    print(0)
elif n%(a+b)==0:
    print(count)
else:
    print(count+n)
# coding: utf-8
N, A, B = map(int, input().split())
# print("N:", N, "\nA:", A, "\nB:", B)
if A == 0 or N == 0:
    print(0)
if B == 0:
    print(N)
else:
    B = A + B
    q, mod = divmod(N, B)
    num = q * A + mod
    # num = (N // B) * A
    # print("num:", num)
    # num += N % B
    # print("num:", num)
    print(num)
N,A,B = map(int,input().split())
print(N//(A+B)*A + N%(A+B))
n,a,b=map(int,input().split())
temp1=n//(a+b)
temp=n-temp1
ans=min(a,temp)
ans+=(temp1*a)
print(ans)
n,a,b = map(int,input().split())
s = ''
length = len(s)
while len(s)<n:
  for i in range(a):
    s += 'b'
  for j in range(b):
    s += 'r'
  length = len(s)
#print(s)
print(s.count('b'))
# -*- coding: utf-8 -*-

import sys

def prob_b(n, a, b):
    x = int(n / (a + b)) * a
    y = n % (a + b)
    print(x+y)


if __name__ == '__main__':
    #args = sys.argv
    #n = args[1]
    #a = args[2]
    #b = args[3]
    n, a, b = map(int, input().split())
    prob_b(n,a,b)
n, a, b = map(int, input().split())
ans = n // (a + b)
x = n % (a + b)
ans += min(a, x)
print(ans)
n, a, b = map(int, input().split())

ans = n //(a+b) * a
rem = n % (a+b)
#ans += min(rem, a)
ans += rem
print(ans)
n, a, b = map(int, input().split())
x = n // (a+b)
y = n % (a+b)

print((a*x)+y)
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())

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

ans = 0
ans += x*A
ans += max(0, N-y, A)
print(ans)
import sys

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

Count_Blue = 0
if 1<=N<=10**18 and A > 0 and B >= 0 and \
   0< A + B <= 10**18:
    Add_Blue = 1 * A
    Add_Both = Add_Blue + 1 * B

    q = N // Add_Both
    mod = N % Add_Both
    if mod < 1 * A:
        Count_Blue = (q *(Add_Blue)) + mod
    else:
        Count_Blue = (q +(Add_Blue)) + Add_Blue
    print(Count_Blue)
elif A == 0:
    print(Count_Blue)
n,a,b = map(int,input().split())
num = 0
num = n // (a+b)

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

ans1 = a // (b + c)
ans2 = min(ans1, b)

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

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

print(A * N // (A+B) + min(N % (A+B), A))
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)

if blue_count + red_count > n:
  print(blue_count)

# この時点で bule_count と red_count b: 3, r: 4, n: 8 みたいな組みに
sum_ = 0
flag = True
ans = 0
while not sum_ >= n:
  if flag:
    if sum_ + blue_count > n:
      ans += n - sum_
      sum_ += blue_count
    else:
      ans += blue_count
      sum_ += blue_count
    flag = False
  else:
    sum_ += red_count
    flag = True

print(ans)
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print()
		elif a<=n:
			print(a)
		else:
			for i in range(1,10**100):
				if n > (a+b)*i:
					continue
				elif (a+b)*(i-1)<=n:
					print(a*(i-1)+n-(a+b)*(i-1))
					break
main()
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

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

import sys
AB = A+B
maxnum = pow(10,100)
if A == 0:
    print(0)
    sys.exit()
if N <= A:
    print(N)
    sys.exit()
waru,amari = divmod(B,AB)
#waru = (N // AB)
#amari = N % AB
if amari > A:
    amari = A
answer = waru * A + amari

print(answer)
n,a,b = list(map(int,input().split()))
to, ans = 0 , 0

if a == 0:
  print(0)
  exit()
if n < (a + b):
  if n < a:
    print(n)
  else:
    print(a)
  exit()

to = int(n / (a + b))
ans = to * a
ans += n - ((a + b) * to)

print(ans)
N,A,B=[int(s) for s in input().split(" ")]
Ans1=N//(A+B)
Ans2=N%(A+B)
Ans=A*Ans1+Ans2

print(int(Ans))
import math
N, A, B = map(int, input().split(' '))
r = math.floor(N / (A + B))
ans = r * A + N - r * (A + B)
print(ans)
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 = map(int, input().split())
ans  = (N//(A+B))*A
if N%(A+B)<=A and N%(A+B) !=0:
  ans += N%(A+B)
elif N%(A+B) !=0:
  ans += A-N%(A+B)
print(ans)
n,a,b = map(int,input().split())
x = n % (a+b)
if x <= a:
    a += x
elif x > a:
    a += a
print(int(a))
N,A,B=map(int,input().split())
if (N%(A+B)-A)<=0:
	M=N%(A+B)
else:
	M=N%(A+B)-A
print((N//(A+B))*A+M)
N, A ,B =map(int,input().split())

print(N//(A+B)*A+min(N%(A+B),B))
def main():
    n,a,b = map(int, input().split())
    if a == 0:
        print(0)
        exit()
    c = a + b
    d,e = divmod(n,c)
    f,g = divmod(e,a)
    if f == 0:
        print(a * d + g)
    else:
        print(a * d + a * f)

if __name__ == '__main__':
    main()
N,A,B = map(int, input().split())

S = A+B

x = N//S
y = N%S

print(x*A+y)
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:
  print(A*div + A)
n, a, b = map(int,input().split())

if a > 0 or b > 0:
    ope1 = n//(a+b)
    ope2 = n%(a+b)
    if ope1 == 0:
        print(n)
    elif ope2 == 0:
        print(a*ope1)
    elif ope2 < a:
        print(a*ope1 + ope2)
    else:
        print(a*ope1 + a)
else:
    print(0)
n,a,b=map(int,input().split())
count=int(n/(a+b))*a
n=n%(a+b)
if(n<=b):
    count=count+n
else:
    count=count+b
print(count)
n, a, b = map(int, input().split())
blue1 = a * n // (a+b)

n -= (a+b) * n // (a+b)
blue2 = min(n, a)

blue = blue1 + blue2
print(blue)
n,a,b=list(map(int,input().split()))

x=0
if a==0:
    x=0
elif n<a+b:
    x=n-a
else:
    x=b

print(x)
n, a, b = list(map(int, input().split()))
c, d = divmod(n, (a+b))
if d <= a:
    print(c*a+d)
else:
    print(c*a)
n, a, b = map(int, input().split())
print(int(n / (a + b)) * a + n % (a + b))
n, a, b = map(int, input().split())
print(((n // (a + b)) * a + n % (a + b)) if a > 0 else 0)
N, A, B = map(int, raw_input() .split())
x = A + N - (A + B)
if A == 0:
    x = 0
print x
n,A,B = list(map(lambda x:int(x),input().split(" ")))
x = n%(A+B)
r = min(x,A)
ans = (n-x)*A/(A+B)+r
print(int(ans))
n, a, b = map(int, input().split())
x = n // (a+b)
y = n % (a+b)
print(a*x + y)
N, A, B = list(map(int, input().split()))

try:
    blue_num = A * (N // (A + B)) + (N % (A + B) % (A + 1))
except ZeroDivisionError:
    blue_num = 0

print(blue_num)
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(n)
    else:
        res = a*cnt
        n -= (a+b)*cnt
        res += n
        print(res)
n, a, b = map(int, input().split())
if a == 0:
    print("0")
else:
    print(n - b)
N, A, B = map(int, input().split())
AB = A+B
if N % (AB) == 0:
    print(N//(AB) * A)
else:
    print(N//(AB) * A + (N % AB))
n, a, b = list(map(int, input().split()))
if a > n:
  print(n)
elif a == 0:
  print(0)
elif b == 0:
  print(n)
else:
  print(a)
a,b,c=map(int,input().split())
if a-b-c>0:
    print(a-c)
else:
    print(b)
n, a, b = map(int, input().split())
n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
elif n_mod_ab // a > 0:
    res = n_mod_ab // a * a
else:
    res = n_mod_ab
print(n_div_ab * a + res)
n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
print(ans, rem, a)
ans += min(rem, a)
print(ans)
import math
N, A, B = list(map(int, input().split(' ')))
S = A + B
count = N // S if S != 0 else 0
mod = N % S if S != 0 and count % 2 == 0 else 0
print(A*count + mod)
n,a,b=map(int,input().split())
if(a==0 or b==0):
  print("0")
else:
  print(min(n-a,n-b))
n,a,b=map(int,input().split())
if a==0:
  print('0')
elif (a+b)*10**100 <=n:
  n=(a+b)*10**100
  
  
  amari=n%(a+b)
  cnt=int(n/(a+b))
  if amari<=a:
    print(cnt*a+amari)
  else:
    print(cnt*(a+1))
n,a,b=map(int,input().split())
c=0
d=0
if a==0:
	print(0)
else:
	c=n//(a+b)
	d=a*c+n-c*(a+b)
	print(d)
n,a,b = list(map(int,input().split()))

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

if t2 <= b:
  ans = t1 * a + t2
else:
  ans = t1 * a + b

if n < a + b:
  if n < a:
    ans = n
  else:
    ans = a

if a == 0:
  ans = 0
elif b == 0:
  ans = n
print(ans)
N, A, B = map(int, input().split())
cnt = 0
cnt += N // (A + B) * A
cnt += min(N % (A + B), N)
print(cnt)
N, A, B = map(int, input().split())
A = A * (N // (A + B)) + N % (A + B)
print(A)
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)
    if Blue > mod:
        print(q * Blue  + Blue)
    else:
        print(q * Blue + mod)
N, A, B = map(int,input().split())

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

if  A == 0 :
    print(0)

elif q < 0 :
    print(N)

elif q >= 1:
    if mod == 0 :
        print(q*A)
    elif mod <= A :
        print(q*A+mod)
    elif mod > A :
        print(q*A+A)
input_line = [int(i) for i in input().split()]
n = input_line[0]
a = input_line[1]
b = input_line[2]

x, y = divmod(n, a+b)

if b >= y:
    print(a * x + y)
else:
    print(a * x + b)
N, A, B = map(int, input().split())
if A == 0:
  print(0)
elif N == A+B:
  print(A)
elif N > A+B:
  print(N-B)
elif N < A+B:
  print(A)
elif N <= A:
  print(N)
else:
  print(A)
n, a, b = map(int, input().split(' '))

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

ans = 0

num_rb = n//(a+b)

if num_rb ==0:
    if n >= a:
        print(a)
    else:
        print(n)

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

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

m = N % (A + B)
count = (N // (A + B)) * A

if 0 <= m <= A:
    count += m
else:
    pass

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

t=n//(a+b)

print(n-a*t-2*t*b)
N,A,B = map(int,input().split())
s = N/(A+B)
a = N-(A+B)*s
print(int(A*s+a if A>a else A*(s+1)))
n, a, b =map(int, input().split())

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

ans = c*a + c2
        
print(ans)