Problem:


Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
    
l = ""
flag = True
count = 0
while True:
    if flag == True:
        for x in range(a):
            l += "b"
        flag = False
    else:
        for y in range(b):
            l += "r"
        flag = True

    if len(l) >= n:
        break
         
for c in l:
    if c == "b":
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,a,b = map(int, input().split())

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

if(r <= a and a != 0):
  print("{}".format(q * a + r))
elif(r > a and a != 0):
  print("{}".format((q + 1)* r))
elif(a == 0):
  print("0")

Submission status: Wrong Answer

Solution code:
# -*- 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))

Submission status: Wrong Answer

Solution code:
s = input().split(' ')
n = int(s[0])
a = int(s[1])
b = int(s[2])
if n == 0 or a == 0:
    print(0)
elif b == 0 and a > 0:
    print(n)
elif a >= n:
    print(n)
elif (a + b) >= n:
    print(a)
else:
    print(a + (n - (a + b)))

Submission status: Wrong Answer

Solution code:
s = input().split(' ')
n = int(s[0])
a = int(s[1])
b = int(s[2])
if n == 0:
    print(0)
elif b == 0 and a > 0:
    print(n)
elif a >= n:
    print(n)
elif (a + b) >= n:
    print(a)
else:
    print(a + (n - (a + b)))

Submission status: Wrong Answer

Solution code:
s = input().split(' ')
n = int(s[0])
a = int(s[1])
b = int(s[2])
if a == 0 or n == 0:
    print(0)
elif a >= n:
    print(n)
elif (a + b) >= n:
    print(a)
else:
    print(a + (n - (a + b)))

Submission status: Wrong Answer

Solution code:
s = input().split(' ')
n = int(s[0])
a = int(s[1])
b = int(s[2])
if a == 0 or n == 0:
    print(0)
else:
    print(a + n - (a + b))

Submission status: Wrong Answer

Solution code:
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 N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*(i+1)
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)

Submission status: Wrong Answer

Solution code:
a = input().split()

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

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

cut = N - (A+B)*i

if N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*(i+1)
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)

Submission status: Wrong Answer

Solution code:
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 N < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Submission status: Wrong Answer

Solution code:
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 i*(A+B) > 10**100:
  Blue_Ball_Num = A*i
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Submission status: Wrong Answer

Solution code:
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 N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
a = input().split()

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

count = 0
i = 0

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

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)

Submission status: Wrong Answer

Solution code:
a = input().split()

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

count = 0
i = 0

while 1:
  count = count + A + B
  i += 1
  if count > N:
    break

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n, blue, red = map(int, input().split())
arr = []
bool = True

while bool:
    for j in range(blue) :
        arr.append('b')
        n = n - 1
        if n == 0:
            bool = False
    for k in range(red) :
        arr.append('r')
        n = n - 1
        if n == 0:
            bool = False
print(arr.count('b'))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if not N%(A+B)==0:
	print(A+N%(A+B))
elif A==0:
	print(0)
elif A+B==N:
	print(A)
elif B==0:
	print(N)
elif A+B>N:
	print(A)

Submission status: Wrong Answer

Solution code:
n,a,b=(int(x) for x in input().split())
if a+b==0:
  print(0)
else:
  d=n%(a+b)
  if d==0:
    print(int(a*n/(a+b)))
  elif d<=a:
    print(int((a*(n-d)/(a+b))+d))
  else:
    print(int((a*(n-d)/(a+b))+a))

Submission status: Wrong Answer

Solution code:
n,a,b=(int(x) for x in input().split())
d=n%(a+b)
if d==0:
  print(int(a*n/(a+b)))
elif d<=a:
  print(int((a*(n-d)/(a+b))+d))
else:
  print(int((a*(n-d)/(a+b))+a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

ans = N / (A + B) * A

r = N % (A + B)

ans = ans + min(r, A)

print(ans)

Submission status: Wrong Answer

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

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

r = N % (A + B)

ans = ans + min(r, A)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
[n, a, b] = map(int, input().split())
cnt = 0
sum = 0
while cnt < n:
  cnt += a
  sum += a
  cnt += b
print(sum - (cnt - n))

Submission status: Wrong Answer

Solution code:
# N, A, B
num, greenNum, redNum = map(lambda x: int(x), input().split(' '))

# output
totalGreen = (num // (greenNum+redNum) * greenNum) + (num % (greenNum+redNum))

print(totalGreen)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

ans = N % (A+B)
ans += (N // (A+B)) * A
print(int(ans))

Submission status: Wrong Answer

Solution code:
N, blue, red = map(int,input().split())
count = max(N % (blue+red), blue)
count += int(N/(blue+red)) * blue
print(count)

Submission status: Wrong Answer

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

ans = n / (a + b) * a
rem = n % (a + b)
ans += min(rem, a)
print(int(ans))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
ans = list()
aaa = ['b' for i in range(a)]
bbb = ['r' for i in range(b)]
while len(ans) <= n:
    ans.extend(aaa)
    ans.extend(bbb)
ans = ans[0:n]
ans.count('b')

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
ans = list()
while len(ans) <= n:
    aaa = ['b' for i in range(a)]
    bbb = ['r' for i in range(b)]
    ans.extend(aaa)
    ans.extend(bbb)
ans = ans[0:n]
ans.count('b')

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
repete = N//(A+B)
sub = N%(A+B)
print(A*repete+sub)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
repete = N//(A+B)
sub = N%(A+B)
print(repete+sub)

Submission status: Wrong Answer

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

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

print(int(A * a + b))

Submission status: Wrong Answer

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

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

print(int(A * a + b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
count = 0
if 1 <= (n/(a+b)):
    if a < n%(a+b):
        print ((n/(a+b)*a) +a)
    else:
        print (int(n/(a+b)*a) + int(n%(a+b)))
else:
    if a < n%(a+b):
        print (a)
    else:
        print (n%(a+b))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
count = 0
if 1 <= (n/(a+b)):
    if a < int(n%(a+b)):
        print ((n/(a+b)*a) + a)
    else:
        print (int(n/(a+b)*a) + int(n%(a+b)))
else:
    if a < int(n%(a+b)):
        print (a)
    else:
        print (int(n%(a+b)))

Submission status: Wrong Answer

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

t = n //(a+b)
s = min(n-(a+b), a)
print(t*a+s)

Submission status: Wrong Answer

Solution code:
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
print(int(N/(A+B))*A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
patternNum = N // (A + B)
remains = N % (A + B)
if (remains > A):
	print(patternNum * B + (remains - A))
else:
	print(patternNum * B)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
range=10**100
count=N//(A+B)
amari=N%(A+B) 
add=B if B < amari else amari
print(count*A+add)

Submission status: Wrong Answer

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

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

ans = q*A+x

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
q = N//(A+B)
x = N % (A+B)
ans = q*A+x
#print(type(ans))
print(ans)

Submission status: Wrong Answer

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

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

print(q*A+x)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
x = N%(A+B)
y = N//(A+B)

if x > A:
  print(y*B + (x-A))
else:
  print(y*B)

Submission status: Wrong Answer

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

X = N // (A+B)
Y = N % (A+B)
print(X*A+Y)

Submission status: Wrong Answer

Solution code:
def main():
  n,a,b = list(map(int, input().split()))
  
  if a == 0:
    print(0)
  else:
    p = n // (a+b)
    q = n % (a+b)
    r = q // a
 
    if r == 0:
      print(p*a)
    else:
      print(p*a + a)
  
main()

Submission status: Wrong Answer

Solution code:
def main():
  n,a,b = list(map(int, input().split()))
  sum = 0
  count = 0
  
  while sum < n:
    sum += a
    count += 1
    if sum < n:
      sum += b
  print(a*count)
  
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
num=N//(A+B)
if num==0:
  ans=A
else:
  com=N%(A+B)
  num1=min(com,A)
  ans=A*num+num1
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
num=N//(A+B)
if num==0:
  ans=A
elif num>=1:
  com=N-(A+B)*num
  num1=min(com,A)
  ans=A*num+num1
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
num=int(N/(A+B))
if num==0:
  ans=A
elif num>=1:
  com=N-(A+B)*num
  num1=min(com,A)
  ans=A*num+num1
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ans=0
if A>=N:
  ans=N
elif A<N<=A+B:
  ans=A
elif N>A+B:
  num=int(N/(A+B))
  ans=num*A+N-(A+B)*num
print(ans)

Submission status: Wrong Answer

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

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

ans = q * b
if(mod > a):
  ans = q * b + (q - a)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=list(map(int,input().split()))
a=N//(A+B)*A
print(a)

Submission status: Wrong Answer

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

x, y = divmod(N, A+B)
print(x*A + (y if y!= 0 else 0))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int,input().split())
print(A*(N//(A+B)) + max(N%(A+B), 0))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num = input().split()
n, b, r = [int(N) for N in num]

n = n % (b+r)
if n>b:
    print((int(n / (b+r))+1) * b)
else:
    print((int(n / (b+r))+1) * b + n)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num = input().split()
n, b, r = [int(N) for N in num]

n = n % (b+r)
if n>b:
    print((int(n / (b+r))+1) * b)
else:
    print((int(n / (b+r))+1) * b - n)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

num = input().split()
n, b, r = [int(N) for N in num]

time=0
while n>0:
    time += 1
    n -= b
    if n<=0:
        print(b * time + n)
    n -= r
    if n<=0:
        print(b * time)

Submission status: Wrong Answer

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

multiple = 1
x = 0

while True:
    l = (A * multiple) + (B * multiple)
    if l < N: 
        multiple = multiple + 1
        x = l
    else:
        break

print((A * (multiple - 1)) + (N - x))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A != 0:
    ans = N - B
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x,y = divmod(N,(A+B))

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  print(A*x+y)

Submission status: Wrong Answer

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

x,y = divmod(N,(A+B))

print(A*x+y)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = (int(x) for x in input().split(' '))
print(A * math.floor(N/(A+B)) + ( N % (A+B)))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
if a == 0 and b == 0:
    print(0)
if a != 0 or b != 0:
         
    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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
ana=N//(A+B)*A
rem=N%(A+B)
ana=ana+max(rem,A)
print(ana)

Submission status: Wrong Answer

Solution code:
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+max(N-x*C, A))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
b=N/(A+B)
ans=int(A*b)
if(N-b*(A+B)<=A):
    ans=ans+N-b*(A+B)
print(int(ans))

Submission status: Wrong Answer

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
b=N/(A+B)
ans=int(A*b)
if(N%(A+B)<=A):
    ans+=(N%(A+B))
print(ans)

Submission status: Wrong Answer

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

c = a + b
n_1 = n % c
amari = n - n_1 * c

print(n_1 * a + min(amari,a))

Submission status: Wrong Answer

Solution code:
N,blue,red = list(map(int, input().split()))
b=("")
r=("")
count=0
for j in range (blue):
    b=str(b)+"b"
    j+=1

for i in range (red):
    r=str(r)+"r"
    i+=1
print(blue+red)
while (1):
       count+=1
       M=N-(blue+red)*count
       if M < 0:
        break
if  M+blue+red>blue:
    print(blue*(count-1))
else:print((count-1)*blue+M+blue+red)

Submission status: Wrong Answer

Solution code:
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


n, a, b = sp()
answer = a * n//(a+b)
answer += min(a, n % (a+b))
out(str(answer))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
i = input()
j = i.split(' ')
print(int(j[0])-int(j[2]))

Submission status: Wrong Answer

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

ans=(N//(A+B))*A
N%=(A+B)
print(ans+N)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
    print(0)
    exit()
if b==0:
    print(n)
    exit()
if n<=(a+b):
  print(a)
else:
  amari=n%(a+b)
  cnt=n//(a+b)
  print(cnt*a+min(amari,a))

Submission status: Wrong Answer

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

ans=(N//(A+B))*A
N%=A+B
print(ans+N)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
    print(0)
else:
    if n<=a:
        print(n)
    else:
        print(a*(n//(a+b))+min(b,n-(a+b)))

Submission status: Wrong Answer

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

ans = N // (A + B) * B + max(0, (N % (A + B)) - A)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,blue,red = map(int,input().split())
count = 0
while(1):
  if N > 0:
    N -= blue
    count += 1
  if N > 0:
    N -= red
  else:
    break
print(blue*count + N)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
x=a+b
r=int(n/x)
if n%x!=0:
	s=a*r+(n%x-b)
else:
  s=a*r
  
print(s)

Submission status: Wrong Answer

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

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

if A==0:
    print(0)
elif A!=0 and N>(A+B):
    print(num_A*A+sur)
elif A!=0 and N<=(A+B) and N>=A:
    print(A)
elif A!=0 and N<=(A+B) and N<A:
    print(N)

Submission status: Wrong Answer

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

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

if num_A>0 and A!=0:
    print(num_A*A+sur)
elif num_A<0 and N>A:
    print(A)
else:
    print(N)

Submission status: Wrong Answer

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

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

if num_A!=0:
    print(num_A*A+sur)
elif num_A==0 and N>A:
    print(A)
else:
    print(N)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

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

sum = A + B

count_blue_red = int(N / sum)

surplus = N % sum

#青の列が１回目のとき　　１回目の途中のとき
if count_blue_red == 0:
    #青の玉が全体より大きい
    if N < A:
        print(N)
    #青の玉が全体より小さい    
    else:# N >= A
        print(A)
else:#青の列が1以上
    #青の個数
    b = count_blue_red * A
    print(b + surplus)

Submission status: Wrong Answer

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

if A == 0:
  print(0)
else:
  print(N-B)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
c = a + b
if (n % c >= a):
  m = a
else:
  m = n % c
print(math.floor(n / c * a + m))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
c = a + b
if (n % c >= a):
  m = a
else:
  m = n % c
print(round(n / c * a + m))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split());c=a+b;print(n//c*a+n%c)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split());c=a+b;print(n//c+n%c)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split());c=a+b;print(n//c+max(n%c-a,0))

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
import math

N, A, B =[int(x) for x in input().split()]
line = []
if A!=0:
    c = math.ceil(N*A/(A+B))
else:
    c = 0
print(c)

Submission status: Wrong Answer

Solution code:
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"))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n<=(a+b):
  print(a)
else:
  amari=n%(a+b)
  cnt=n//(a+b)
  print(cnt*a+min(amari,a))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n<=(a+b):
  print(a)
else:
  amari=n%(a+b)
  cnt=n//(a+b)
  if amari<=a:
    print(cnt*a+amari)
  else:
    print(cnt*(a+1))

Submission status: Wrong Answer

Solution code:
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)))

Submission status: Wrong Answer

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

for i in range(100):
    for x in range(A):
        line.append("b")
    for y in range(B):
        line.append("r")

print(line[0:N:].count("b"))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = [0,0]
while(sum(ans) < n):
    if(sum(ans)+a >= n):
        ans[0] += a-(n-sum(ans) +1)
        break
    ans[0] += a
    ans[1] += b
print(ans[0])

Submission status: Wrong Answer

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

c = a+b

product = n//c
remainder = n%c

if a == 0: ans=0
elif b == 0: ans = n
else:
	ans = product*a+remainder

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
amari=n%(a+b)
cnt=int(n/(a+b))
if amari<=a:
  print(cnt*a+amari)
else:
  print(cnt*(a+1))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print('0')
elif (a+b)*(10**100 )<=n:
  print(a*(10**100))
    
else:
  amari=n%(a+b)
  cnt=int(n/(a+b))
  if amari<=a:
    print(cnt*a+amari)
  else:
    print(cnt*(a+1))

Submission status: Wrong Answer

Solution code:
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))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = 0
if a>n:
    print(a)
else:
    temp = n//(a+b)
    ans = temp*a
temp2 = n%(a+b)
#   temp2 = n - temp*(a+b)
print(ans+min(temp2,a))

Submission status: Wrong Answer

Solution code:
N,A,B = input().split()

if int(A) == 0:
    print('0')
else:
    k = (int(N)//(int(A)+int(B))) * int(A) + int(N)%int(A)
    print(str(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B = input().split()

if int(A) == 0:
    print('0')
else:
    k = int(A) + int(N)%int(A)
    print(str(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print('0')
else:
  amari=n%(a+b)
  cnt=int(n/(a+b))
  if amari<=a:
    print(cnt*a+amari)
  else:
    print(cnt*(a+1))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
roop = N//(A+B)
print(roop)
remainder = N % (A+B) 
print(remainder)

if A==0:
  print(0)
elif A>=N:
  print(N)
elif N>A and N<=A+B:
  print(A)
elif N>A and N>A+B and A>=remainder:
  out = roop * A + remainder
  print(out)
elif N>A and N>A+B and A<remainder:
  out = roop * A + A
  print(out)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, input().split())
roop = N//(A+B)
remainder = N % (A+B) 

if A==0:
  print(0)
elif A>=N:
  print(N)
elif N>A and N<A+B:
  print(A)
elif N>A and N>A+B and A>remainder:
  out = roop * A + remainder
  print(out)
elif N>A and N>A+B and A<remainder:
  out = roop * A + A
  print(out)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
ans=B+(S-B-R)
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
s = N // (A+B)
a = N % (A+B)
print(A*s + min(3, a))

Submission status: Wrong Answer

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

sum = A + B

count_blue_red = int(N / sum)

surplus = N % sum

#青の列が１回目のとき　　１回目の途中のとき
if count_blue_red == 0:
    #青の玉が全体より大きい
    if N < A:
        print(N)
    #青の玉が全体より小さい    
    else:# N >= A
        print(A)
else:#青の列が1以上
    #青の個数
    b = count_blue_red * A
    print(b + surplus)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
S = 0
for i in range(2*N):
  if i%2 == 0:
    S += A
    if S >= N:
      ans = (i-1)/2*A + N - (i-1)/2*(A+B)
      break
  else:
    S += B
    if S >= N:
      ans = i/2 * A
      break
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
ans = n//(a+b) + n%(a+b)
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
cycle=A+B
a=N//cycle
b=N%cycle
if b>A:
    b=a
cnt=a*A+b
print(cnt)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
ans = min (A, N)
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
ans = max (N - A, 0)
print(ans)

Submission status: Wrong Answer

Solution code:
N,b,r = map(int,input().split())
if(b == 0 and r == 0):
  print(0)
elif (b ==0):
  print(0)
else :
  sets = N//(b+r)
  surplus = N%(b+r)
  Number_of_Blue = sets * b + surplus
  print(Number_of_Blue)