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,r,b = [int(i) for i in input().split()]
k = n * b// (r+b)
l = max(n % (r+b) - r,0)
print(k+l)

Submission status: Wrong Answer

Solution code:
n,r,b = [int(i) for i in input().split()]
k = n * b// (r+b)
l = min(n % (r+b) - r,0)
print(k+l)

Submission status: Wrong Answer

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

if a == 0:
    print(a) 
elif n <= (a + b):
    print(min(n, a))
else:
    print((n // (a + b)) * a + n % (a + b))

Submission status: Wrong Answer

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

    if A == 0 and B == 0:
        print(ans)
        return

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

    print(ans)


main()

Submission status: Wrong Answer

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

    if A == 0 and B == 0:
        print(ans)
        return

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

    print(ans)


main()

Submission status: Wrong Answer

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

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

    print(ans)


main()

Submission status: Wrong Answer

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

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

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n//(a+b)==0:
    if n>=a+1:
        print(a)
    else:
        print(n)
        
else:
    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)==0:
    if n>=6:
        print(5)
    else:
        print(n)
        
else:
    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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
loop = N // (A + B)
amari = N % (A + B)
if amari >= A:
    blue_amari = amari - A
else:
    blue_amari = 0
blue = B * loop + blue_amari
print(blue)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, raw_input() .split())
x = A + N - (A + B)
if A == 0:
    x = 0
print x

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

inputted = list(map(int, input().split()))

N = inputted[0]
A = inputted[1]
B = inputted[2]

AB = A + B

num_of_repeat = math.floor(N / AB) * A
num_of_remainder = N % AB
total = num_of_repeat + num_of_remainder

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# N: number of balls to take, A: blue, B: red
N, A, B = list(map(int, input().split()))

if N == 0:
    print(0)

if A + B < N:
    # want to know how much A + B blocks can we place such that A + B < N (i.e. solve x(A+B) < N)
    blocks = int(N/(A+B))
    # for each block, there are A blue balls, plus potentially some reamining slots to fill the remaining space of N
    remaining_slots = N % (A+B)
    if A <= remaining_slots:
        # if it can fit A, place A more balls in the row
        print(blocks*A + A) 
    else:
        print(blocks*A + remaining_slots)
else:
    if A + B == N:
        print(A)
    else:
        print(A-N)

Submission status: Wrong Answer

Solution code:
# N: number of balls to take, A: blue, B: red
N, A, B = list(map(int, input().split()))

# Want to know m*A + n*B < N
total = 0
single_placements = A + B

if A + B < N:
    # want to know how much A + B blocks can we place such that A + B < N (i.e. solve x(A+B) < N)
    blocks = int(N/(A+B))
    # for each block, there are A blue balls, plus potentially some reamining slots to fill the remaining space of N
    remaining_slots = N % (A+B)
    if A <= remaining_slots:
        # if it can fit A, place A more balls in the row
        print(blocks*A + A) 
    else:
        print(blocks*A + remaining_slots)
else:
    if A + B == N:
        print(A)
    else:
        print(A-N)

Submission status: Wrong Answer

Solution code:
# N: number of balls to take, A: blue, B: red
N, A, B = list(map(int, input().split()))

# Want to know m*A + n*B < N
total = 0
single_placements = A + B

if A + B < N:
    # want to know how much A + B blocks can we place such that A + B < N (i.e. solve x(A+B) < N)
    blocks = N/(A+B)
    # for each block, there are A blue balls, plus potentially some reamining slots to fill the remaining space of N
    remaining_slots = N % (A+B)
    if remaining_slots >= A:
        # if it can fit A, place A more balls in the row
        print(blocks*A + A) 
    else:
        print(blocks*A + (A-remaining_slots))
else:
    if A + B == N:
        print(A)
    else:
        print(A-N)

Submission status: Wrong Answer

Solution code:
# N: number of balls to take, A: blue, B: red
N, A, B = list(map(int, input().split()))

total = 0
blue = 0
red = 0
while total < N:
    if total + A > N:
        blue += N - total
    else:
        blue += A

    if total + B > N:
        red += N - total
    else:
        red += B

    total += blue + red

print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m=n%(b+r)
l=n//(b+r)

if m<b:
    s=b
else:
    s=m

if m!=0:
    n_b=l*b+s
else:
    n_b=l*b

print(n_b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
x=0
if n-a-b>0 and a!=0:
    x=n-a-b
    b=b+x
print(b)

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
x=0
if n-a-b>0 and b!=0:
    x=n-a-b
    b=b+x
print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

all_bowl=n
blue_bowl=a
red_bowl=b
if all_bowl-blue_bowl-red_bowl>0:
    rest_bowl=all_bowl-blue_bowl-red_bowl
    blue_bowl=blue_bowl+rest_bowl
print(blue_bowl)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
count=0
while A + B <= N:
    count +=1
    N -= A + B
if A >= N:
    exit 
else:
    N = 0
print(A*count + N)

Submission status: Wrong Answer

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

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

print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if (N % (A+B)) != 0:
    print((N//(A+B)) * A + (N-(A+B)*(N//(A+B))))
else:
    print((N//(A+B)) * A)

Submission status: Wrong Answer

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

que = []

if (N % (A+B)) != 0:
    print((N//(A+B)) * A + (N-(A+B)*(N//(A+B))))
else:
    print((N//(A+B)) * A)

Submission status: Wrong Answer

Solution code:
import math
totalBalls, blueBalls, redBalls= list(map(int,input().split()))
answer=0
totalStack=blueBalls + redBalls
countStack=math.ceil(totalBalls/totalStack)

if countStack*totalStack>totalBalls:
  answer = (countStack-1) * blueBalls
  before=totalStack*(countStack-1)
  difference = totalBalls-before
  if difference>= blueBalls: answer+=blueBalls
  else: answer+=difference
else: answer=(countStack)*blueBalls
print(answer)

Submission status: Wrong Answer

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

g = a + b
if n%g<=a: print(int(g*a+n%g))
else: print(int((g+1)*a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
m=A+B
x=N//m
y=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())
x=N//(A+B)
y=N%(A+B)
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())

x = N // (A+B)

y = N % (A+B)

ans = x + min(A, y)

print(ans)

Submission status: Wrong Answer

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

if (a*b)-n>0:
  print((a*b)-n)
elif (a*b)-n<0:
  print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
a = N % (A + B)
x = N - a
if x > A:
    a += A
print(a)

Submission status: Wrong Answer

Solution code:
N, A, B = list(map(int, input().split()))
c = 0
while N:
    if N > A:
        N -= A
        c += A
    else:
        c += N
        break
    N -= B
    
print(c)

Submission status: Wrong Answer

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

    else:
        total += B
        if total > N:
            break

print(ans)

Submission status: Wrong Answer

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

if ama > A:
    print(A*(num+1)-B)
else:
    print(A*num+ama)

Submission status: Wrong Answer

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

ans = int((N - (N%(R+B))) * (B / (R+B)))

if B > 0:
    ans +=  int(N%(B+R))

print(ans)

Submission status: Wrong Answer

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

ans = int((N - (N%(R+B))) * (B / (R+B)) + (N%(B+R)))

print(ans)

Submission status: Wrong Answer

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

ans = (N - (N%(R+B))) * (B / (R+B)) + (N%(B+R))

print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
c=N-(A+B)
d=int(N%(A+B))
if A==0:
    print(0)
elif N<=A:
    print(A)
elif A+1<=N<=A+B:
    print(A)
else:
    print(A*d+c)

Submission status: Wrong Answer

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

mod = n % (a+b)
num = n // (a+b)
if a == 0:
    print(0)
else:
    print(num*a+mod)

Submission status: Wrong Answer

Solution code:
import sys

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

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

	c = N // (A + B)
	cc = N % (A + B)
	print(A * c + cc)

Submission status: Wrong Answer

Solution code:
import sys

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

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

	c = N // (A + B)
	print(A * c + (N - (A+B)*c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = [int(x) for x in input().split(' ')]
temp = int(n//(a+b))
temp += int(min(n%(a+b), a))
print(temp)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split(' ')]
temp = n//(a+b)
temp += min(n%(a+b), a)
print(temp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import math
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
num_one_gr = y + z
num_gr = math.floor(x/num_one_gr)
amari = x - num_one_gr*num_gr
if amari <= y:
    total = y * num_gr + amari
else:
    total = y*(num_gr + 1)

Submission status: Wrong Answer

Solution code:
num = input().split()
blue_ball   = num[1]
red_ball    = num[2]
all_ball    = 0
flag = True

all_ball = all_ball + int(blue_ball)
all_ball = all_ball + int(red_ball)

while flag:
    if((all_ball >= int(num[0]) or int(num[1]) <= 0)):
        flag = False
    else:
        all_ball = all_ball + 1
        blue_ball = int(blue_ball) + 1

print(int(blue_ball))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
readline = sys.stdin.buffer.readline
N,A,B = map(int, readline().split())
if N==A==B==0:
    print(0)
else:
    R=A*(N//(A+B))+N%(A+B)
    print(R)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
readline = sys.stdin.buffer.readline
N,A,B = map(int, readline().split())
R=A*(N//(A+B))+N%(A+B)
print(R)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
balls = 0
ans = 0
count = 0
while balls < N and count <= 1000:
    count += 1
    if balls + A <= N:
        balls += A + B
        ans += A
    else:
        ans += N - balls
        balls += A + B
print(ans)

Submission status: Wrong Answer

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

r = 3*math.floor(n/7)
res = n%7
if res>3:
  r += 3
else:
  r += res

print(str(int(r)))

Submission status: Wrong Answer

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

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

if A+B == 0:
    print(0)
    exit()
else:
    cnt = N // (A+B)
    amari = N % (A+B)

# print(cnt)
# print(amari)
if amari <= A:
    print(A*cnt+amari)
else:
    if amari <= B:
        print(A*(cnt+1))

Submission status: Wrong Answer

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

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

cnt = N // (A+B)
amari = N % (A+B)
# print(cnt)
# print(amari)
if amari <= A:
    print(A*cnt+amari)
else:
    if amari <= B:
        print(A*(cnt+1))

Submission status: Wrong Answer

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

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

cnt = N // (A+B)
amari = N % (A+B)
# print(cnt)
# print(amari)
print(A*cnt+amari)

Submission status: Wrong Answer

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

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

cnt = N // (A+B)
amari = N % (A+B)
# print(cnt)
# print(amari)

if A_amari == B_amari:
    print(A * cnt + N - (A+B) * cnt)
elif A_amari == 1 and amari:
    print(A * (cnt+1) + (N - (A * (cnt+1) + B * cnt)))
elif B_amari == 1 and amari:
    print(N - (B * (cnt + 1) + (N - (B * (cnt + 1) + A * cnt))))

Submission status: Wrong Answer

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

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

cnt = N // (A+B)
amari = N % (A+B)
# print(cnt)
# print(amari)

if A_amari == B_amari:
    print(A * cnt)
elif A_amari == 1 and amari:
    print(A * (cnt+1) + (N - (A * (cnt+1) + B * cnt)))
elif B_amari == 1 and amari:
    print(N - (B * (cnt + 1) + (N - (B * (cnt + 1) + A * cnt))))

Submission status: Wrong Answer

Solution code:
import sys

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

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    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 + 1))

Submission status: Wrong Answer

Solution code:
import sys

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

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    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)

Submission status: Wrong Answer

Solution code:
import sys

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

if blue == 0:
    print(0)
    sys.exit()
if n <= blue or red == 0:
    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))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 + (n - red))
    sys.exit()
elif n == ball:
    print(blue)
    sys.exit()

ans = n // ball
additional = n % ball
if red == 0:
    print(ans * blue)
if additional == 0:
    print(ans * blue)
elif additional <= blue:
    print(ans * blue + additional)
else:
    print(ans * blue + (additional - red))

Submission status: Wrong Answer

Solution code:
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 + (n - red))
    sys.exit()
elif 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))

Submission status: Wrong Answer

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

if blue == 0:
    print(0)
if n <= blue:
    print(n)
if n <= ball:
    print(blue + (n - red))

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

Submission status: Wrong Answer

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

if blue == 0:
    print(0)
if n <= blue:
    print(n)
if n <= ball:
    print(blue + (n - red))

"""
count = 0
while n >= (blue + red):
    n -= (blue + red)
    count += 1
ans = count*blue
"""

ans = n / ball
additional = n % ball
if additional == 0:
    print(ans * blue)
elif additional <= blue:
    print(ans * blue + additional)

Submission status: Wrong Answer

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

if blue == 0:
    print(0)
if n <= blue:
    print(n)
if n <= ball:
    print(blue + (n - red))

"""
count = 0
while n >= (blue + red):
    n -= (blue + red)
    count += 1
ans = count*blue
"""

ans = n / ball
additional = n % ball
if additional == 0:
    print(ans * blue)
elif additional <= blue:
    print((ans -1) * blue + additional)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC158B
import sys
n,blue,red = map(int, sys.stdin.readline().split())

total = blue + red
syo = n // total
amari = n % total
if n <= blue:
    print(n)
elif n <= total:
    print(blue)
else:
    print(syo*blue + amari)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
for i in range(100):
    if i*(A+B) < N <= (i+1)*(A+B):
        print(min(N-i*B, (i+1)*A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
List=[]
while len(List) <N:
  for i in range(A):
    List.append("b")
  for j in range(B):
    List.append("r")
if len(List) > N:
  ans=List[:N]
  print(ans.count("b"))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(a*int(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)
kumi = N // (A + B)
amari = N % (A + B)
if amari > A:
    print(kumi * A + N)
else:
    print(kumi * A + amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC158B
import sys
n, blue, red = map(int, sys.stdin.readline().split())
print(n,blue,red)

if n<=blue:
    print(blue)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=N//(A+B)
b=A*a
if A!=0:
    c=N-(A+B)*a
    print(b+c)
else:
    print('0')

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
a=N//(A+B)
b=A*a
if b!=0:
    c=N-(A+B)*a
    print(b+c)
else:
    print('0')

Submission status: Wrong Answer

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

count = 0
num = 0
remainder = 0

while count < n:
    num += 1
    count += a
    if count >= n:
        remainder = count % n
        break
    count += b

print(num * a - remainder)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
x = n // (a + b)
r = n % (a + b)
print(a * x) if r == 0 else print(a * x + r)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=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=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())

if a == 0 :
    print(0)
elif n <= a + b :
    print(a)
else:
    if n%(a+b) <= a :
        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())
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)

Submission status: Wrong Answer

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
print(n_div_ab * a + n_mod_ab)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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 = [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)

Submission status: Wrong Answer

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

if N >= AB:
    iters, div = divmod(N, AB)
    print((A*iters + div))
elif N >= A:
    print(A)
else:
    print(N)

Submission status: Wrong Answer

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

if N >= AB:
    iters, div = divmod(N, AB)
    print((A*iters + div))
else:
    print(A)

Submission status: Wrong Answer

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

AB = A + B
iters, div = divmod(N, (A +B))
print((A*iters + div))

Submission status: Wrong Answer

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

x = n//(a+b)
y = n%(a+b)
if a-y > 0:
  z = y
else:
  z = a-y

ans = x*a + z


print(ans)

Submission status: Wrong Answer

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

x = n//(a+b)
y = n%(a+b)
z=0
if y-a > 0:
  z = y-a

ans = x*b + z


print(ans)

Submission status: Wrong Answer

Solution code:
l = list(map(int, input().split()))
#print(l)
ans = 0

mm = l[0]//(l[1]+l[2])
nn = l[0]%(l[1]+l[2])

ans = l[1]*mm + nn
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())
l, m = divmod(n, a+b)
print(l*a+m)

Submission status: Wrong Answer

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

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

print(a + b)