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())
print(n, a, b)

ans = 0
if a > 0:
    ans += a * (n // (a + b))
    if 0 < n % (a + b) < a:
        ans += n % (a + b)
    else:
        ans += a
print(ans)

Submission status: Wrong Answer

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

ans = 0
if a > 0:
    ans += a * (n // (a + b))
    if 0 < n % (a + b) < a:
        ans += n % (a + b)
    else:
        ans += b
print(ans)

Submission status: Wrong Answer

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

ans = 0
if a > 0:
    ans = a * (n // (a + b)) + (n % (a + b)) if (n % (a + b)) < a else a
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

	print(ans)
else:
	print(min(a,n))

Submission status: Wrong Answer

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

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

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

	print(ans)
else:
	print(min(a,n))

Submission status: Wrong Answer

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

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

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

	print(ans)
else:
	print(a)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if N==0:
  print(0)

elif A==0:
  print(0)

elif B==0:
  print(N)

elif N<=A:
  print(A)

elif N<A+B:
  print(A)

else:
  q,mod=divmod(N,A+B)
  print(q*A+mod)

Submission status: Wrong Answer

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

if A==0:
  print(0)

elif B==0:
  print(N)

elif N>=A+B:
  q,mod=divmod(N,A+B)
  print(q*A+mod)

elif N<A+B:
  print(A)

elif N<A:
  print(A)

Submission status: Wrong Answer

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

if a == 0:
    print(0)
elif b == 0:
    print(n)
elif a >= n:
    print(n)
elif a+b > n > a:
    print(a)
else:
    q,mod = divmod(n, a+b)
    print(q*a + mod)

Submission status: Wrong Answer

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

if a == 0:
    print('0')
elif a > n:
    print(n)
elif a+b > n:
    print(a)
else:
    q,mod = divmod(n, a+b)
    print(q*a + mod)

Submission status: Wrong Answer

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

if A==0:
  print(0)
else:
  q,mod=divmod(N,A+B)
  print(q*A+mod)

Submission status: Wrong Answer

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

if a == 0:
    print(0)
else:
    q,mod = divmod(n, a+b)
    print(q*a + mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
else:
    B_s = A + B
    B_block = (N - 1) // B_s
    B_rem = (N - 1) % B_s + 1
    print(A * B_block + B_rem)

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else:
    B_s = A + B
    B_block = (N - 1) // B_s
    B_rem = (N - 1) % B_s + 1
    print(A * B_block + B_rem)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
m=A+B
x=int(N/m)
y=int(N%m)
if y<=A:
    print(x*A+y)
else:
    print(x*(A+1))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
m=int(A+B)
x=int(N/m)
y=int(N%m)
if y<=A:
    print(int(x*A+y))
else:
    print(int(x*(A+1)))

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
m=int(A+B)
x=int(N//m)
y=int(N%m)
if y<=A:
    print(int(x*A+y))
else:
    print(int(x*(A+1)))

Submission status: Wrong Answer

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

if A == 0:
    print(0)
else:
    b_fl = True
    ans = 0
    while N > 0:
        if b_fl is True:
            ans += A
            N -= A
            if N < 0:
                ans -= N
            b_fl = False
        else:
            N -= B
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
if n >= a:
    while(n > a):
        n = n-a-b
        sum += a
    print(sum+n)
else:
    print(a)

Submission status: Wrong Answer

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

sum = 0

while(n > a):
    n = n-a-b
    sum += a

print(sum+n)

Submission status: Wrong Answer

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

l=a+b

if n%l>=a:
  print(round(n/l)*a+a)
else:
  print(round(n/l)*a+n%l)

Submission status: Wrong Answer

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

print(n-b)

Submission status: Wrong Answer

Solution code:
N, a, b = map(int, input().split())
s = a+b
if s < N:
    count = 0
    balls = N
    while s < N:
        s *= (a+b)
        count += 1
    if count > 0:
        s //= (a+b)
    count = a*count
    balls = N - s
    if balls < a:
        count = balls + count
        print(count)
    else:
        count = a + count
        print(count)
else:
    if N < a:
        # count = balls + count
        print(a-N)
    else:
        # count = a + count
        print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(q * A + mod) if mod <= A else print(q * A + (mod - B))

Submission status: Wrong Answer

Solution code:

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)

Submission status: Wrong Answer

Solution code:

n,a,b = map(int,input().split())
num = 0
num = n // (a+b)

if num % (a+b) <=a:
    print((num*a)+ (num % (a+b)))
else:
    print((num*a)+a)

Submission status: Wrong Answer

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

if a==0:
    blue = 0

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

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

blue = blue1 + blue2
print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n * a // (a+b)
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Submission status: Wrong Answer

Solution code:
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n * a // (a+b)
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Submission status: Wrong Answer

Solution code:
import sys
n, a, b = map(int, sys.stdin.readline().split())
balls = n * a / (a+b)
if n % (a+b) <= a:
  balls += n % (a+b)
else:
  balls += a
print(balls)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if a == 0:
    print(a)
else:
    print(n - b)

Submission status: Wrong Answer

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

print(n - b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

if N <= A + B:
    if N <= A:
        print(N)
    else:
        print(A)
else:
    print(A + N - A - B)

Submission status: Wrong Answer

Solution code:
import math
n,a,b=map(int,input().split())
c = a+b
d = math.floor(n/c)
count = d * a
n = n - (c * d)
count += n
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, b, r = map(int, input().split())
if b == 0:
    print(0)
else:
    print(n - r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = list(map(int,input().split()))
cnt = 0
c = n//(a+b)
d = n%(a+b)
if d <= a:
  cnt = c+d
else:
  cnt = c+a
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input().split(" ")
n = int(s[0])
a = int(s[1])
b = int(s[2])
row = []
blue = 0
answer = 0
div = n % (a+b)

for i in range(a):
  row.append("b")
  
for i in range(b):
  row.append("r")

if n > (a+b):
  row.append(row[div])

for i in row:
  if i == "b":
    answer += 1
    
print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = N // (A + B)

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

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,B,R=map(int,input().split())
b=0
total=0

for i in range(1000):
    total+=B
    b+=1
    if total>N:
        break
    total+=R
    if total>N:
        break
if B==0:
    print(0)

else:
    print(B*b-(total-N))

Submission status: Wrong Answer

Solution code:
N,B,R=map(int,input().split())
b=0
total=0

for i in range(10**10):
    total+=B
    b+=1
    if total>N:
        break
    total+=R
    if total>N:
        break
if B==0:
    print(0)

else:
    print(B*b-(total-N))

Submission status: Wrong Answer

Solution code:
N,B,R=map(int,input().split())
b=0
total=0

for i in range(10**100):
    total+=B
    b+=1
    if total>N:
        break
    total+=R
    if total>N:
        break
if B==0:
    print(0)

else:
    print(B*b-(total-N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,b,r = list(map(int,input().split()))
block=n//(b+r)
count_b=block*b;
extra_b=n%(b+r);
if(extra_b<=b):count_b+=extra_b;
print(count_b)

Submission status: Wrong Answer

Solution code:
n,b,r = list(map(int,input().split()))
block=n//(b+r)
count_b=block*b;
extra_b=n%(b+r);
if(extra_b<b):count_b+=extra_b;
print(count_b)

Submission status: Wrong Answer

Solution code:
n = list(map(int,input().split()))
if n[1]==0:
    print(0)
elif n[1]+n[2]==n[0]:
    print(n[1])
elif n[1]+n[2]!=n[0]:
    x = n[0]-(n[1]+n[2])
    print(n[1]+x)

Submission status: Wrong Answer

Solution code:
X,A,B = map(int, input().split())
if A == 0 or A == X-B or B==0:
    print(A)
else:
    print(X-B)

Submission status: Wrong Answer

Solution code:
X,A,B = map(int, input().split())
if A == 0 or A == X-B:
    print(A)
else:
    print(X-B)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0

answer = divmod(n, (a + b))

if a == 0  or n < (a + b):
    print(a)
elif n <= a:
    print(n)
elif n == 1:
    print('1')
else:
    blueBall = answer[0] * a
    if answer[1] > b:
        blueBall = blueBall + a
    else:
        blueBall = blueBall + answer[1]

    print(blueBall)

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0

answer = divmod(n, (a + b))

if a == 0:
    print(a)
elif n <= a:
    print(n)
elif n == 1:
    print('1')
else:
    blueBall = answer[0] * a
    if answer[1] > b:
        blueBall = blueBall + a
    else:
        blueBall = blueBall + answer[1]

    print(blueBall)

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0

answer = divmod(n, (a + b))

if a == 0 or n <= a:
    print(a)
elif n == 1:
    print('1')
else:
    blueBall = answer[0] * a
    if answer[1] > b:
        blueBall = blueBall + a
    else:
        blueBall = blueBall + answer[1]

    print(blueBall)

Submission status: Wrong Answer

Solution code:
n, a, b = list(map(int, input().split(' ')))
blueBall = 0

answer = divmod(n, (a + b))

if a == 0:
    print(a)
elif n == 1:
    print('1')
else:
    blueBall = answer[0] * a
    if answer[1] > b:
        blueBall = blueBall + a
    else:
        blueBall = blueBall + answer[1]

    print(blueBall)

Submission status: Wrong Answer

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

answer = divmod(n, (a + b))
blueBall = answer[0] * a

if a == 0:
    print(a)
else:
    if answer[1] > b:
        blueBall = blueBall + a
    else:
        blueBall = blueBall + answer[1]

    print(blueBall)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=[int(s) for s in input().split()]
C=A+B
Q=N//C
R=N%C
if R<=A:
  print(Q*A+C)
else:
  print((Q+1)*A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num = N // (A + B)
res = N % (A + B)

ans = num * A + res

print(ans)

Submission status: Wrong Answer

Solution code:
# import module
import sys
import math
import numpy as np

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

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

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

Submission status: Wrong Answer

Solution code:
# import module
import sys
import math
import numpy as np

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

x = N / (A+B) 

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

Submission status: Wrong Answer

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

x = n // (a + b)
ans = a * a + min(a, n - (a + b)*x)
print(ans)

Submission status: Wrong Answer

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

total = (a + b)*10**100

if n > total:
    print(a*10**100)
elif n % (a + b) == 0:
    print(a * (n // (a + b)))
elif n % (a + b) <= 3:
    print(a * (n // (a + b)) + n % (a + b))
else:
    print(a * (n // (a + b)) + 3)

Submission status: Wrong Answer

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

total = (a + b)*10**100

if n > total:
    print(3*10**100)
elif n % (a + b) == 0:
    print(a * (n // (a + b)))
elif n % (a + b) <= 3:
    print(a * (n // (a + b)) + n % (a + b))
else:
    print(a * (n // (a + b)) + 3)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=N//(A+B)
a=N*A
c=A+B
b=int(N%c)

if b<=A:
  print(a+b)
else:
  print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if b<=A:
  print(a+b)
else:
  print(a)

Submission status: Wrong Answer

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

if b<=A:
  print(a+b)
else:
  print(a)

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = N//(A+B)*A + N%(A+B)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Wrong Answer

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

s=N//(A+B)
NA=N-s*(A+B)
if(A!=0):
  if(NA//A>=1):
    sA=1
  else:
    sA=NA
else:
  sA=0
print(s*A+sA*A)

Submission status: Wrong Answer

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

s=N//(A+B)

NA=N-s*(A+B)
if(A!=0):
  if(NA//A>=1):
    sA=1
  else:
    sA=NA
else:
  sA=0
print(s*A+sA)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

combo = A + B
num_of_combo = N // combo
remaining = N - combo * num_of_combo

print(num_of_combo * A + remaining)

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc158/tasks/abc158_b"

def main():
    a, blue, red = list(map(int, input().split()))
    count, b_count = divmod(a, blue + red)
    print(b_count + count * blue)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys
# import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    n, a, b = mi()
    q = n // (a + b)
    res = n % (a + b)
    print(q * a + res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n % (a + b):
    print(a * t)
else:
    if n - (a + b) * t >= a:
        print((a * t) + a)
    else:
        print((a * t) + (n - (a + b) * t))

Submission status: Wrong Answer

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

if n % (a + b):
    print(a * t)
else:
    if n - (a + b) * t >= a:
        print((a * t) + a)
    else:
        print((a * t) + (n - (t * n)))

Submission status: Wrong Answer

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

if t == 1:
    print(a * t)
else:
    if n - (a + b) * t >= a:
        print((a * t) + a)
    else:
        print((a * t) + (n - (t * n)))

Submission status: Wrong Answer

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

if t == 1:
    print(a * t)
else:
    if n - (t * n) >= a:
        print((a * t) + a)
    else:
        print((a * t) + (n - (t * n)))

Submission status: Wrong Answer

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

if t == 1:
    print(b * t)
else:
    if n - (t * n) >= b:
        print((b * t) + b)
    else:
        print((b * t) + (n - (t * n)))

Submission status: Wrong Answer

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

if t == 0:
    print(b * t)
else:
    if n - (t * n) >= b:
        print((b * t) + b)
    else:
        print((b * t) + (n - (t * n)))

Submission status: Wrong Answer

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

while len(ab) < n and len(ab) != 0:
    ab = ab + ('a' * a) + ('b' * b)

print(ab[:n].count('a'))

Submission status: Wrong Answer

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

if a == 0:
  print(0)
else:
  x = n % (a + b)
  y = n // (a + b)
  
  if x // a == 1:
    print(a * y + a)
  elif x // a == 0:
    print(a * y + x)

Submission status: Wrong Answer

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

if a == 0:
  print(0)
else:
  x = n % (a + b)
  y = n // (a + b)
  
  if x // a == 1:
    print(a * y + a)
  else:
    print(a * y + x)

Submission status: Wrong Answer

Solution code:



def main():
    NAB = list(map(int,input().split()))




    # tm = NAB[0] // (NAB[1] + NAB[2]) * NAB[1]
    # amari = NAB[0] % (NAB[1] + NAB[2])
    # tm += min(amari,NAB[1])
    #
    # print(tm)

    # b = 0
    # 
    # tm = NAB[0]//(NAB[1]+NAB[2])
    # amari = NAB[0] % (NAB[1]+NAB[2])
    # 
    # # print(tm)
    # if NAB[1] < amari:
    #     b = (tm*NAB[1])+ NAB[1]
    # else:
    #     b = (tm*NAB[1])+ amari
    # 
    # print(b)


    b = 0
    if NAB[1] == 0:
        b = 0
    elif NAB[2] == 0:
        b = NAB[1]

    # elif NAB[0] < NAB[1]+NAB[2]:
    #     if NAB[0] < NAB[1]:
    #         b = NAB[0]
    #     else:
    #         b = NAB[1]

    else:
        tm = NAB[0]//(NAB[1]+NAB[2])
        amari = NAB[0] % (NAB[1]+NAB[2])

        # print(tm)
        if NAB[1] < amari:
            b = (tm*NAB[1])+ NAB[1]
        else:
            b = (tm*NAB[1])+ amari

    print(b)





if __name__ == '__main__':
    main()