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:



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

    # X = NAB[0]
    # a = 0
    # b = 0
    #
    # while X >= 0:
    #     X -= NAB[1]
    #     a += 1
    #     # print("go")
    #
    #     if X <= 0:
    #         break
    #
    #     X -= NAB[2]
    #     b += 1
    #
    # # print(a)
    # # print(b)
    #
    # if b < 0:
    #     print(NAB[1]*a - abs(X))
    # else:
    #     print(NAB[1]*a)

    b = 0

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

    print(tm)

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



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    X = NAB[0]
    a = 0
    b = 0

    while X >= 0:
        X -= NAB[1]
        a += 1
        # print("go")

        if X <= 0:
            break

        X -= NAB[2]
        b += 1

    # print(a)
    # print(b)

    if b < 0:
        print(NAB[1]*a - abs(X))
    else:
        print(NAB[1]*a)



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



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    b = NAB[0]
    a = 0
    b = 0
    
    while b <= 0:
        b -= NAB[1]
        a += 1
        
        if b <= 0:
            break
        
        b -= NAB[2]
        b += 1
    
    if b < 0:
        print(NAB[1]*a - abs(b))
    else:
        print(NAB[1]*a)
        
        

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



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    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)



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

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



            # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    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 = int(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



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    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 = int(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



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    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 = int(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



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

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

        b = (tm*NAB[1])+amari



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    b = 0
    if NAB[1] == 0:
        b = 0
    elif NAB[2] == 0:
        b = NAB[1]
        
    elif NAB[0] < NAB[1]+NAB[2]:
        b = abs(NAB[0]-NAB[1])

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

        b = (tm*NAB[1])+amari



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

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

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

        b = (tm*NAB[1])+amari



    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

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

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

        b = (tm*NAB[1])+amari





    # cA = NAB[1]
    # cB = NAB[2]
    #
    # for i in range(NAB[0]):
    #
    #     if NAB[1] == 0:
    #         break
    #     if NAB[2] == 0:
    #         b = NAB[1]
    #         break
    #
    #     if cA != 0:
    #         b += 1
    #         cA -= 1
    #     elif cB != 0 and cA == 0:
    #         cB -=1
    #     else:
    #         cA = NAB[1]
    #         cB = NAB[2]
    #
    #         b += 1
    #         cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:



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

    b = 0
    cA = NAB[1]
    cB = NAB[2]

    for i in range(NAB[0]):

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

        if cA != 0:
            b += 1
            cA -= 1
        elif cB != 0 and cA == 0:
            cB -=1
        else:
            cA = NAB[1]
            cB = NAB[2]

            b += 1
            cA -= 1


    print(b)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = (int(x) for x in input().split())
result = 0
if N <= A:
  result = N
elif N > A and N <= A+B:
  result = A
else:
  Q = N//(A+B)
  R = N%(A+B)
  if R<= A:
    result = Q*A + R
  else:
    result = Q*(A+1)
print(result)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = list(map(int,stdin.readline().strip().split()))
C=A+B
ans=A*(N//C)
if N%C>A:
    ans+=N%C-B
else:ans+=N%C
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = list(map(int,stdin.readline().strip().split()))
C=A+B
ans=A*(N//C)
ans+=N%C
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = list(map(int, input().split()))
Amari = N % (A+B)
Show = N // (A+B)
ans = Amari + Show * A
if A == 0:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	ans = int(N // (A + B)) * A + N % (A + B)
	print(ans)


if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
n,a,b = map(int, "8 3 4".split())

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

if amari >= a:
    print(tmp*a + a)
else:
    print(tmp*a + amari)

Submission status: Wrong Answer

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

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

print(tmp*a)

if amari >= a:
    print(tmp*a + a)
else:
    print(tmp*a + amari)

Submission status: Wrong Answer

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

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

if amari >= a:
    print(tmp*a + a)
else:
    print(tmp*a + a-amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(N//(A+B)*A+min(N%(A+B),B))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

    one_action = "B"*A + "R"*B
try:
    for i in range(action_mod):
        if one_action[i] == "B":
            ans += 1
except:
    pass

print(ans)

Submission status: Wrong Answer

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

try:
    one_action = "B"*A + "R"*B
    for i in range(action_mod):
        if one_action[i] == "B":
            ans += 1
except:
    pass

print(ans)

Submission status: Wrong Answer

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

AplusB = A+B

try:
    action_num = N // AplusB
except:
    action_num = 0
ans += action_num * A

try:
    action_mod = N % AplusB
except:
    action_mod = 0

# one_action = "B"*A + "R"*B
for i in range(action_mod):
    # if one_action[i] == "B":
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    num_x = a
  elif(n == (a + b)):
    num_x = 0
  elif(num_b > a):
    num_x = a
  else:
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    num_x = a
  elif(n == (a + b)):
    num_x = 0
  elif(num_b >= a):
    num_x = a
  elif(a != 0):
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    num_x = a
  elif(n == (a + b)):
    num_x = 0
  elif(num_b >= a):
    num_x = a
  else:
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    num_x = a
  elif(n < (a + b)):
    if(num_b >= a):
      num_x = a
    else:
      num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_a == 0):
    nun_x = a
  elif(n < (a + b)):
    if(num_b >= a):
      num_x = a
    else:
      num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import math

def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = (math.floor(n/(a + b)))
  num_b = int(n % (a + b))
  
  if(num_b >= a):
    nun_x = a
  else:
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = int(n)/ (a + b)
  num_b = int(n) % (a + b)
  
  if(num_b >= a):
    nun_x = a
  else:
    num_x = num_b

  print(int(num_a * a + num_x))
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n,a,b = (int(x) for x in input().split())

  num_x = 0
  num_a = int(n / (a + b))
  num_b = int(n % (a + b))
  
  if(num_b >= a):
    nun_x = a
  else:
    num_x = num_b

  print(num_a * a + num_x)
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
  n,a,b = (int(x) for x in input().split())

  num = int(n % (a + b))
  
  print(n - b)
  
if __name__ == '__main__':
  main()

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:
a = list(map(int, input().split()))
if a[0] > a[1] + a[2]:
  print(a[0]-a[2])
elif a[0]<= a[1]:
  print (a[0])
elif a[0] > a[1]:
  print (a[1])

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[0] > a[1] :
  print(a[1])
elif a[0]<= a[1]:
  print (a[0])

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, readline().split())
ans = n // (a + b) * a
if n % (a + b) <= a:
    ans += n % (a + b)
if ans == 0:
    ans += a
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, a, b = map(int, readline().split())
ans = n // (a + b) * a
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 = N%(A+B)
if C> A:
    print(A*N//(A+B)+A)
else:
    print(A*N//(A+B)+C)

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 = list(map(int, input().split()))

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = [int(x) for x in input().split()]

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

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)
elif blue_count + red_count > n:
  print(blue_count)
else:
  set_count = blue_count + red_count

  margin = 0
  if n % set_count == 0:
    c =  n // set_count
  else:
    c =  n // set_count
    margin = n % set_count

  print(blue_count * c + margin )

Submission status: Wrong Answer

Solution code:
n, blue_count, red_count = map(int, input().split())

if blue_count >= n:
  print(n)

if blue_count + red_count > n:
  print(blue_count)

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

print(ans)

Submission status: Wrong Answer

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

for n in range(1000):
    for i in range(A):
        List.append('b')
    i = 0
    for i in range(B):
        List.append('r')

ans = ''.join(List)
ans = ans.count('b',0,N)
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
k = n//(a+b)
total = k * a
new_k = n % (a+b)
for i in range(new_k):
    total += 1
print(total)

Submission status: Wrong Answer

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

c = 0

for i in range(0, n//(a+b)):
    c += a * (n//(a+b))

if n%(a+b) > a:
    c += a
else:
    c += n%(a+b)
    
print(c)

Submission status: Wrong Answer

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

c = 0


for i in range(0, n//(a+b)):
    c += a * (n//(a+b))

if n%(a+b) > a:
    c += a
else:
    c += n%(a+b)
    
print(c)

Submission status: Wrong Answer

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


count = n // (b+r)
counts = n % (b+r)

countss=b*count
coun=(b-1)-counts
if coun < 1 or counts==0:
  coun = 0

print(countss+coun)

Submission status: Wrong Answer

Solution code:
inp = input().split()
inp = list(map(int, inp))
n, a, b = inp[0], inp[1], inp[2]
div, mod = divmod(n, a+b)
if a == 0:
    print(0)
else:
    if mod < a: print(div*a + mod)
    else: print(div*(a+1))

Submission status: Wrong Answer

Solution code:
N, b, r = map(int, input().split())
blue = 0

while N > 0:
    if N >= r+b:
        N -= (r+b)
        blue += b
    else:
        if N < b:
            blue += N
        else:
            blue += b
        N -= r
print(blue)

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 a == 0:
  print(0)
else:
  print( (n //(a+b))*a + max(a, n%(a+b)) )

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())
print( (n //(a+b))*a + n%(a+b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
cnt += a*int(n/(a+b))
if n//(a+b) > a:
  cnt += a
else:
  cnt += int(n//(a+b))
  
print(cnt)

Submission status: Wrong Answer

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

t=n//(a+b)

print(n-t*b)

Submission status: Wrong Answer

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

t=n//(a+b)

print(n-a*t-2*t*b)

Submission status: Wrong Answer

Solution code:
x = input()
x = x.split()
sum = int(x[0])
b_num = int(x[1])
r_num = int(x[2])

if sum == (b_num + r_num):
    print(b_num)
elif sum > (b_num + r_num):
    if b_num == 0:
        print(0)
    elif r_num == 0:
        print(sum)
    else:
        print(b_num + (sum - (b_num + r_num)))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
C = N // (A+B)

if N <= A+B:
  print(A)
elif N % (A+B) < A:
  print(A*C + N%(A+B))
else:
  print(A*(C+1))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()
C = N // (A+B)
if N <= A+B:
  print(A)
elif N % (A+B) <= A:
  print(A*C + N%(A+B))
else:
  print(A*(C+1))

Submission status: Wrong Answer

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

if (A+B)<N and A!=0:
  print(N-B)
elif (A+B)==N:
  print(A)
elif A==0:
  print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

l= []
while(len(l)<=a):
    for _ in range(b):
        l.append(1)
    for _ in range(c):
        l.append(0)
        
print(l[:8].count(1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,A,B=map(int, input().split())
print('{:.0f}'.format( math.floor(N/(A+B))*A + min([ N%(A+B) ,A ])      ))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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