TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-
import math
import sys
a,b=map(int, input().split())

x = math.floor(a/0.08)

y = math.floor(b/0.1)
if (x + 1) * 0.08 == a:
    xx = x + 2
else:
    xx = x + 1

for i in range(y,y+10):
    for j in range(x, xx):
        if i == j:
            print(i)
            sys.exit(0)
print(-1)
      

# -*- coding: utf-8 -*-
n, a,b=map(int, input().split()) 
X = n//(a+b)
Y = n%(a+b)
if Y > a:
    print(X*a + a)
else:
    print(X*a + Y)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B = map(int, input().split())
  
if N % (A + B) == 0:
  print(N // (A + B) * A)
elif N % (A + B) - A < 0:
  print(N // (A + B) * A + abs(N % (A + B) - A)
elif N % (A + B) - A > 0:
  print(N // (A + B) * A + A)

N,A,B = map(int, input().split())
  
if N % (A + B) == 0:
  print(N // (A + B) * A)
elif N % (A + B) - A < 0:
  print(N // (A + B) * A + abs(N % (A + B)))
elif N % (A + B) - A > 0:
  print(N // (A + B) * A + A)

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b= map(int,input().split())
ans = (n//(a+b))*a
rem += (n%(a+b))
ans = min(rem,a)
print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
c = n%(a+b)
if c >a:
  print((n-c)*a/(a+b)+a)
else:
  print((n-c)*a/(a+b)+c)

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

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

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())

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

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

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

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int,input().split())
print(a)

n,a,b = map(int,input().split())
m = a+b
print(a*(n//m)+min(a,n-((n//m)*m)))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B = map(int,input().split())
s = N/(A+B)
a = N-(A+B)*s
print(int(A*s+a if A>a else A*(s+1)))

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-temp<=a:
  result=temp+a
else:
  result=temp+n
print(result)

n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-int(n/(a+b))*(a+b)<=a:
  result=temp+a
else:
  result=temp+n-int(n/(a+b))*(a+b)
print(result)

n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-temp>=a:
  result=temp+a
else:
  result=temp+n
print(result)

n,a,b=map(int,input().split())
temp=int(n/(a+b))*a
if n-int(n/(a+b))*(a+b)>=a:
  result=temp+a
else:
  result=temp+n-int(n/(a+b))*(a+b)
print(result)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
c=0
d=0
if a==0:
	print(0)
else:
	c=n//(a+b)
	print(c)
	d=a*c+n-c*(a+b)
	print(d)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
l = []
l_a = ['b' for i in range(A)]
l_b = ['r' for i in range(B)]
for val in range(N // (A + B)):
    l += l_a
    l += l_b
cnt = 0
for val in range(N):
    if l[val] == 'b':
        cnt += 1
print(cnt)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0

for i in range (10**100):
    if break_flag:
        break
    for j in range(A):
        counter += 1
        liste.append('b')
        if counter == N:
            break_flag = True
            break
    if break_flag:
        break
    for j in range(B):
        counter += 1
        liste.append('r')
        if counter == N:
            break_flag = True
            break
print(liste)
print(liste[:N+1].count('b'))

"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0

while counter < N:
    if break_flag:
        break
    for j in range(A):
        counter += 1
        liste.append('b')
        if counter == N:
            break_flag = True
            break
    if break_flag:
        break
    for j in range(B):
        counter += 1
        liste.append('r')
        if counter == N:
            break_flag = True
            break
print(liste)
print(liste[:N+1].count('b'))

N, A, B = map(int, input().split(' '))
liste = []
break_flag = False
counter = 0
a = 0
b = 0
while counter < N:
    a += A
    b += B
    counter += A+B
if counter > N:
    for i in range(counter-N):
        if break_flag:
            break

        for j in range(B):
            b -= 1
            counter -= 1
            if counter == N:
                break_flag=True
                break
        if break_flag:
            break
        for j in range(A):
            a -= 1
            counter -= 1
            if counter == N:
                break_flag=True
                break

"""
B - Count Balls
"""

N, A, B = map(int, input().split(' '))
kat = int(N/(A+B))
kalan = N%(A+B)

a = A*kat
if kalan > A:
    a += A
else:
    a += kalan

print(a)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B=map(int,input().split())
llist=[N]
r=B
b=A
for i in range(N-1 ):
    if b!=0:
       llist.append("blue")
       b=b-1
    elif r!=0:
        llist.append("red")
        r=r-1
        if r==0:
            b=A
    else : break
print(llist.count("blue"))


n, a, b = map(int, input().split())
period = a+b
times = n//period
k = n%period
n =  a if k >a else k
print(times*a + n)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
A,B=map(int, input().split())

for i in range(1,1100):
    if int(i*0.8)==A and int(i*0.1)==B:
        print(i)
        break
else:
    print(-1)


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

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
count=0
while n>0:
  n-=a
  count+=min(a,n)
  n-=b
print(count)

n,a,b=map(int,input().split())
c=a+b
d=n//(a+b)
e=n%(a+b)
print(a*d+min(e,a))

Verdicts: Wrong Answer

Accepted
Problem: 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?

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


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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B=map(int,input().split)
ans=N//(A+B)*A
rem=N%(A+B)
ans=ans+min(rem,A)
print(ans)

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
6 2 4

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

    ao_count = 0

    count_num = N / (A + B)
    amari_num = N % (A + B)

    ao_count = count_num * A
    if amari_num <= A:
        ao_count += A


    print(ao_count)



if __name__ == "__main__":
    resolve()

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

    ao_count = 0

    count_num = N // (A + B)
    amari_num = N % (A + B)



    ao_count = count_num * A

    if A <= amari_num:
        ao_count += A
    else:
        ao_count += amari_num

    print(ao_count)



if __name__ == "__main__":
    resolve()

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
ans = 'b' * A + 'r' * B
ans *= N // (A + B)
print(ans.count('b'))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
    # 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)

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

# 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 < N:
        print(A)
    else:
        print(N)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
def solve():
    N, A, B = map(int, input().split())

    n_times = N // (A+B)
    amari = N % (A+B)
    cnt = 0
    # if amari != 0:
    #     S = 'b' * A + 'r' * B
    #     S = S[0:amari]

    #     for ball in S:
    #         if ball == 'b':
    #             cnt += 1
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

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

    n_times = N // (A+B)
    amari = N % (A+B)

    cnt = 0
    if A <= amari:
        cnt = A
    else:
        cnt = amari
    
    print(n_times * A + cnt)

if __name__ == '__main__':
    solve()

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
s = np.array(input().split()).astype(int)
# =============================================================================
# if s.find("A") >= 0 and s.find("B") >= 0:
#     print("Yes")
# else:
#     print("No")
# =============================================================================

A,B,N = s

print((N//(A+B))*A+np.array(N%(A+B),A).max())

import numpy as np

s = np.array(input().split()).astype(int)
# =============================================================================
# if s.find("A") >= 0 and s.find("B") >= 0:
#     print("Yes")
# else:
#     print("No")
# =============================================================================

N,A,B = s

print(N//(A+B)*A + np.array([N%(A+B),A]).min())

# =============================================================================
# A,B = s
# 


# x1 = A*eight
# x2 = A*ten
# if (int)(A * 10/8) != B:
#     print(-1)
# else:
#     print(np.array(x1,x2).min().astype(int))
# =============================================================================


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n = int(input())
a = str(input())
b = str(input())

L =[(a+b)*n]

for i in range(n+1):
  if a == 0:
    print(b*n)
  else:
    print(b.count(n))

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


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())

kaisu = int(n // (a+b))
amari = int(n % (a + b))
ans = kaisu * b
if amari  > b:
    ans += b
else:
    ans += amari

print(ans)

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

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

amari = min(a, amari)

print(sho * a + amari)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int,input().split())
k = n//(a+b)
h = min(a,n%(a+b))
print(k+h)


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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,b,r = map(int,input().split())
syo = n//(b+r)
amari = n%(b+r)
print(syo,amari)
if amari == 0:
  print(b*syo)
else:
  if amari <= b:
    print(b*syo + amari)
  else:
    print(b*syo - (b-amari))

n,b,r = map(int,input().split())
syo = n//(b+r)
amari = n%(b+r)
if amari == 0:
  print(b*syo)
else:
  if amari <= b:
    print(b*syo + amari)
  else:
    print(b*syo + b)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math
N,A,B = list(map(int,input().split()))
ans = math.ceil(A*(N/(A+B)))
if N%(A+B)>=A:
    ans+=A
else: ans+=N%(A+B)
print(ans) 

import math
N,A,B = list(map(int,input().split()))
ans = A*(N//(A+B))
if N%(A+B)>=A:
    ans+=A
else: ans+=N%(A+B)
print(ans) 

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
L=""
for _ in range(10**100):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

n,a,b=map(int,input().split())
L=""
for _ in range(10**18):
  L += 'b'*a+'r'*b
print(L[:n].count('b'))

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int,input().split())
patternNum = N // (A + B)
remains = N % (A + B)
if (remains > A):
	print(patternNum * A + A)
else:
	print(patternNum * A)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
inp = input().split(" ")
N,A,B = inp
if (N%(A+B)) <= A:
  print((N/(A+B))*A + (N%(A+B)))
else:
  print((N/(A+B))*A + A)

inp = input().split(" ")
N, A, B = (int(inp[0]), int(inp[1]), int(inp[2]))
if int(N % (A + B)) <= A:
    print(int(N / (A + B)) * A + int(N % (A + B)))
else:
    print(int(N / (A + B)) * A + A)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
s=n//(a+b)
ans1=a*s
rem=n%(a+b)
if rem>=a:
  print(ans1+a)
else:
  print(ans1+a-rem)
  

n,a,b=map(int,input().split())
s=n//(a+b)
ans1=a*s
rem=n%(a+b)
if rem>=a:
  print(ans1+a)
else:
  print(ans1+rem)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
if y<a:
    print(a*(n//(a+b))+())
else:
    print(a*(n//(a+b)+1))


n,b,r = map(int, input().split())
#if (n%(b+r)) < b: print((n//(b+r))*b+(n%(b+r)))
#else: print((n//(b+r))*(b+1))
ans = n//(b+r)+b
re = n%(b+r)
ans += min(re, ans)
print(ans)

n,a,b=map(int,input().split())
#x=n//(a+b)
#y=n%(a+b)
if n%(a+b) < a: print(a*(n//(a+b))+(n%(a+b)))
else: print(a*((n//(a+b)+1)))


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n, a, b = map(int, input().split())

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

rest = n - n // (a + b) * (a + b)

if rest > a:
    result += rest - a

print(result)

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

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

print(result)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=map(int,input().split())
print(n//(a+b)*a+min(a,n//%(a+b)))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int, input().split())

if n == 0:
    print(0)
elif: 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)

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

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

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

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
#!/usr/bin/env python3
#  = input()
#a  = int(input())
n, a, b = map(int, input().split())
#  = list(map(int, input().split()))

#
# c = collections.Counter()

if a == 0:
  print(0)
else:
  ans = (n // a) // 2
  if (n // (a + b)) % 2 == 1:
      ans += ans % n
  print(ans)


#!/usr/bin/env python3
#  = input()
#a  = int(input())
n, a, b = map(int, input().split())
#  = list(map(int, input().split()))

#
# c = collections.Counter()

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

n, a, b = map(int, input().split())
blue1 = a * n // (a+b)

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

blue = blue1 + blue2
print(blue)

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

if a==0:
    blue = 0

else:
    brset = n // (a+b)
    blue1 = a * brset
    n -= (a+b) * brset
    blue2 = min(n, a)
    blue = blue1 + blue2

print(blue)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B=map(int,input().split())
ab='u'*A+'r'*B
S=ab*10**100
S4ans=S[:N]
print(S4ans.count('u'))

N,A,B=map(int,input().split())
ab='u'*A+'r'*B
S=ab*1000
S4ans=S[:N-1]
print(S4ans.count('u'))

N,A,B=map(int,input().split())
full=N//(A+B)
rest=N%(A+B)
if rest <=A:
    print(full*A+rest)
    exit()
else:
    print(full*A+A)
    exit()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
n, b, r = map(int, input().split())
i = 1
b_count = 0
while n:
  if i%2 == 0:
    if n > b:
      b_count += b
      n = n-b
    else:
      b_count += n
      n = 0
  else:
    if n > r:
      n = n-r
    else:
      n = 0
  i += 1
print(b_count)

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int,input().split())
ans = (n//(a+b))*a
ans += min((n-n%(a+b)),a)
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = map(int, input().split())
kaisu = N//(A+B)
print(kaisu)
n = N-((A+B)*kaisu)
if n >= A:
    print(A*(kaisu+1))
else:
    print(A*kaisu+n)

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

n = N-((A+B)*kaisu)
if n >= A:
    print(A*(kaisu+1))
else:
    print(A*kaisu+n)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int, input().split())

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


n,a,b = map(int, input().split())
 
x = n//(a+b)
y = n%(a+b)
z = 0
if y <= a :
  z = y
else :
  z = a
  
print(x*a+z)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b=input(),input(),input()
n=int(n)
a=int(a)
b=int(b)
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

n,a,b=input(),input(),input()
n=int(n)
a=int(a)
b=int(b)
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

n,a,b=input(),input(),input()
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

n,a,b=input(),input(),input()
n=int(n)
a=int(a)
b=int(b)
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i == A
count = j * A + i


a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i

a = list(map(int, input().split()))
N = a[0]
A = a[1]
B = a[2]
count = 0
i = N % (A + B) 
j = N //(A + B)
if i >= A:
  i = A
count = j * A + i
print(count)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,A,B=map(int,input().split())
ans=N//(A+B)*A
rem=N%(A+B)
ans+=ans+min(rem,A)
print(ans)

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,a,b = map(int,input().split())
dars = n // (a+b)*a
amari = n % (a+b)
dars = min(amari,a)
print(dars)

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


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
#include<bits/stdc++.h>

using namespace std;

long long n, a, b;

int main(){
	cin >> n >> a >> b;
	cout << a*n/(a+b)+min(a, n%(a+b)) << endl;
}

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
def main():
    s = input()
    q = int(input())
    hanten = False
    for i in range(q):
        query = input().split()
        if query[0] == "1":
            hanten = not hanten
        else:
            if query[1] == "1":
                if hanten:
                    s = s + query[2]
                else:
                    s = query[2] + s
            if query[1] == "2":
                if hanten:
                    s = query[2] + s
                else:
                    s = s + query[2]
    print(s if not hanten else s[::-1])



if __name__ == '__main__':
    main()



def main():
    n,blue,red = map(int,input().split())
    total = blue+red
    answer = 0
    answer += (n // total) * blue
    amari = min(blue,(n % total))
    answer += amari
    print(answer)




if __name__ == '__main__':
    main()



Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
if a == 0:
    print(0)
else:
    ans = (int(n / (a+b)) * a)
    if n % (a+b) > a:
        print(ans + a)
    else:
        print(ans + (n % (a+b)))

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b
    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

import sys
from io import StringIO
import unittest

doTest=0

def yn(n):
    if n==1:
        print("Yes")
    else:
        print("No")
    return

def resolve():
    readline=sys.stdin.readline

    n,a,b=list(map(int, readline().strip().split()))
    #arr=list(map(int, readline().strip().split()))
    #n=int(readline().strip())
    #yn(n)
    ab = a+b

    if n <= a:
        print(n)
        return

    if n <= ab:
        print(a)
        return
    t = n//ab
    print(t*a + min(n-t*ab, a))

    return

if doTest==0:
    resolve()
    sys.exit()

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = list(map(int,input().split()))
if A = 0:
  print(0)
elif A >= N:
  print(N)
elif A + B >= N:
  print(A)
else:
  print(N - B)

n, a, b = list(map(int, input().split()))
if int(a) > int(n):
  print(int(n))
else:
  if int(a) + int(b) > int(n):
    print(int(a))
  else:
    print(int(a) + (int(n) % int(a)))

N, A, B = list(map(int,input().split()))
if A == 0:
  print(0)
elif A >= N:
  print(N)
elif A + B >= N:
  print(A)
else:
  print(N//(A+B))

n, a, b = (int(x) for x in input().split())
if a > n:
  print(n)
else:
  if a + b > n:
    print(a)
  else:
    print(a + (n % a))

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

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

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

ans = 0
kake = 0
if A + B == N:
    ans = A
elif A == 0:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + A

print(ans)

N, A, B = [int(x) for x in input().split()]
ans = 0
kake = 0
AAA = 10 ** 18

if A + B == N:
    ans = A
elif N == 0:
    ans = 0
elif A == 0:
    ans = 0
elif B == 0:
    ans = N
elif A + B > AAA:
    ans = 0
elif N > AAA:
    ans = 0
else:
    kake = int(N / (A + B))
    mod = int(N/(A + B))
    if mod == 0:
        ans = A * kake
    else:
        ans = A * kake + min(A, N - (N/(A-B))*(A+B))

print(ans)

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

mod = int(N % (A + B))
kake = int(N // (A + B))
if mod <= A:
    print(kake*A + mod)
else:
    print(kake*A + A)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted