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

c=a+b
if c==0:
    print(0)
if a==0:
    print(0)
if c!=0 and a!=0:
    d=n//c
    num=a*d
    if n%a<=b:
        print(num)
    else:
        print(num+n%a-b)


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

c=a+b
if a==0:
    print(0)
if c!=0 and a!=0:
    d=n//c
    num=a*d
    if n%c<=a:
        print(num+n%c)
    elif n%c>a:
        print(num+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 & B==0):
  print("0")

else:
  r=N//(A+B)
  s=N-A*r
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)

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

r=N//(A+B)
s=N%(A+B)

if(B=0):
  t=N//A + N%A

else:
  if(A!=0):
    t=(A*r)+s
  else:
    t=0

print(t)

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

if(A==0 & B==0):
  print("0")

else:
  r=N//(A+B)
  s=N%(A+B)
  if(A<s):
    s=A
  if(A!=0):
    t=(A*r)+s
  else:
    t=0
  print(t)

Verdicts: 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):
def main():
    n,a,b = map(int,input().split())
    print((n // (a + b) ) * a + n % a)
main()

def main():
    N,A,B = map(int,input().split())
    bl = (N // (A + B)) * A
    rl = (N % (A + B))
    if rl <= A:
        print(bl + rl)
    else:
        print(bl + A)
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):
n,a,b=map(int, input().split())
if n%(a+b)>b:
    print(n//(a+b)*a+n%(a+b))
elif n%(a+b)==0:
    print(n//(a+b)*a)
else:
    print(n//(a+b)*a+a)

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

t=n//(a+b)

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

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

t=n//(a+b)

print(t*a+min(a,n-t*(a+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):
N, A, B = list(map(int, input().split()))

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * max(count, 1) + min(A, amari)
if N = 0: sum_blue = 0
print(sum_blue)

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

count = - (-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)
if N >= A + B: sum_blue = A
print(sum_blue)

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

count = -(-N // (A + B)) -1
amari = N%(A+B)
sum_blue = A * count + min(A, amari)
print(A * count)
print(amari)
print(sum_blue)

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

count = N // (A + B)
amari = N%(A+B)
sum_blue = A * count + min(A, amari)

print(sum_blue)

Verdicts: Runtime Error

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 = input().split()
print(min(n, a))

n, a, b = map(int, input().split())
s = ""
while len(s) <= n:
    s += 'b' * a + 'r' * b
cnt = 0
for si in s[:n]:
    if si == 'b':
        cnt += 1

n, a, b = map(int, input().split())
div, rest =divmod(n, (a + b))
#div, rest
ans = a * div
if rest >= a:
    ans += a
else:
    ans += rest
print(ans)


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

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

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

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

line = 'b'*A + 'r'*B

for i in 10**100:
  line += line
  if len(line) >= N:
    break
   
ans = line.count('b')
print(ans)

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

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

if amari < A:
  c = amari
else:
  c = A
  
ans = A * x + c
print(ans)

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

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

if amari < A:
  c = amari
else:
  c = A
  
ans = A * count + c
print(ans)


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


s=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>A:
    sum=A*a+A
    print(s)
    else:
    s=A*a+b
    print(s)

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


sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)


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-N%(A+B))*A/(A+B)+min(A,N%(A+B))
print(format(ans))


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


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


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

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

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

Verdicts: Wrong Answer

Runtime Error

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())
box = ''
for i in range(n//(a+b)+1):
  box += ('b' * a)
  box += ('r' * b)
print(box)
print(len([i for i in box[0:n] if i == 'b']))

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

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

ad = A if A > m else m
if m == 0:
    ad = 0
answer = A * a + ad
if A == 0:
    answer = 0

print(answer)


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

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

ad = A if A < m else m
if m == 0:
    ad = 0
answer = A * a + ad
if A == 0:
    answer = 0

print(answer)


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

c = N//(A + B)

rem = N - c * (A + B)

if rem >= A:
	sum = c * A + rem
else:
	sum =c + rem

print(sum)

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

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: 
	print((number_turn * A) + nokori)
else:　
	print((number_turn * A) + A)

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

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: 
	print((number_turn * A) + nokori)
else: 
	print((number_turn * A) + A)


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

x = N // (A+B)

y = N % (A+B)

ans = x + min(A, y)

print(ans)

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

X = N*(A*'b' + B*'r')
print(X)

cnt = X.count('b', 0, N)
print(cnt)

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

b = '1'
r = '0'

x =[]
cnt = 0
while len(x) < N:
  x.append(A*b)
  x.append(B*r)

for i in range(x):
  tmp = 0
  tmp = int(i)
  cnt += i

pint(cnt)

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

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())
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=input().split()
n=int(N)
a=int(A)
b=int(B)
m=n%(a+b)
l=(n-m)/(a+b)
if m>a:
  y=a
else:
  y=m
x=a*l+y
print(x)

N,A,B=input().split()
n=int(N)
a=int(A)
b=int(B)
m=int(n%(a+b))
l=int((n-m)/(a+b))
if m>a:
  y=a
else:
  y=m
x=a*l+y
x=int(x)
print(x)

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):
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
    print((count * blue_num)a + blue_rest)


# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num or blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)



# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = num % all_ball
print(count * all_ball + min(rest, blue_num))


# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = num % all_ball
    if rest <= blue_num:
        blue = rest
    count = num / all_ball
    print((count) * blue_num + rest)


# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = n % all_ball
print(count * all_ball + min(rest, blue_num))


# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // all_ball
rest = num % all_ball
print(count * blue_num + min(rest, blue_num))


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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):
import sys

readline = sys.stdin.buffer.readline

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

div,mod =divmod(N, A+B)
print(div)
print(mod)

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  print(A*div + A)
  

import sys

readline = sys.stdin.buffer.readline

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

div,mod =divmod(N, A+B)
print(div)
print(mod)

if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)
  

import sys
 
readline = sys.stdin.buffer.readline
 
N,A,B = map(int, readline().split())
 
div,mod =divmod(N, A+B)
 
if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + 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):
def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b
      
N, b, r = [int(i) for i in data.split()]

ball = int(N/total) * b + count(b, b+r, N)
print(ball)

def count(b):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b
      
 
data = input()

N, b, r = [int(i) for i in data.split()]

ball = int(N/total) * b + count()
print(ball)

def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
		return b

data = input()
N, b, r = [int(i) for i in data.split()]

ball = int(N/total) * b + count(b, b+r, N)
print(ball)

def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b

data = input()
N, b, r = [int(i) for i in data.split()]
 
ball = int(N/total) * b + count(b, b+r, N)
print(ball)

def count(b, total, N):
    remain = N%total
    if remain < b:
        return remain
    else:
        return b
      
data = input()
N, b, r = [int(i) for i in data.split()]
 
ball = int(N/total) * b + count(b, b+r, N)
print(ball)

def count(b, total, N):
  r = N%total
  if r < b:
    return r
  else:
    return b

data = input()
N, b, r = [int(i) for i in data.split()]

total = b + r

ball = int(N/total) * b + count(b, total, N)
print(ball)

Verdicts: Runtime Error

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):
# C - Tax Increase
from math import floor


def calc(a: int, b: int) -> int:
    for i in range(1, 1010):
        if floor(i * 0.08) == a and floor(i * 0.1) == b:
            return i
    return -1


def main():
    A, B = map(int, input().split())
    print(calc(A, B))


if __name__ == "__main__":
    main()


# B - Count Balls
def main():
    N, A, B = map(int, input().split())
    ans = N // (A + B) * A + min(A, N % (A + B))
    print(ans)


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):
N, A, B = map(int, input().split())

t = N // (A + B)
if N % (A + B) == 0:
  mod = 0
else:
  mod = A

print(t * A + mod)

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

t = N // (A + B)
mod = N % (A + B)

print(t * A + min(mod, 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())

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

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_A)


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

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

if A < mod:
	mod_A = A
else:
	mod_A = mod

print(A * q + mod_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):
a, b = [int(x) for x in input().split()]
 
if (b < a):
    temp = b
    b = a
    a = temp
 
 
x = 1
while True:
    if (int(x*0.08) == a and int(x*0.1) == b):
        print(x)
        break
    else:
        if (x > 1500):
            print(-1)
            break
        else:
            x += 1

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: 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, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

# x = n // (a + b)
# pr/int(x)
x = 0
x += (n // (a + b)) * a
x += (n % (a+b)) % b
print(x)

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

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

if 0 <= a <= A:
    c = a
else:
    c = A

print(b * A + c)

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):
# place A blue balls first,
# then place B red balls after
# go until you get to N
n, a, b = map(int, input().split())
x = 1
while a * x + b * x < n:
    x += 1
print(a * x)
# if (a * x + b * x) - n > b:



n, a, b = map(int, input().split())
x = max(n // (a + b) - 2, 1)
while a * x + b * x < n:
    temp = a * x + b * x
    x += 1
temp = a * x + b * x
if temp - b >= n:
    temp = temp - b
    print(a * x - (temp - n))
else:
    print(a * x)


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

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

if a >= n:
  print(n)
elif a+b >= n:
  print(a)
elif 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=input()
i=0;c=0
a=input()
b=input()
while True:
    for j in range(a):
        if i >= n:break
        i+=1
        c+=1
    for j in range(b):
        i+=1
    if i > n:break
print(c)

n, a, b = map(int, input().strip().split())
q, r = divmod(n, a+b)
blue = a*q
if r < a:
    blue += r
else:
    blue += a
print(blue)

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 = 'b'*a+'r'*b
ind = n%(a+b) 

print(s[ind-1])

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

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

if x<=a:
  ans += x
else:
  ans += 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 = [int(i) for i in input().split]

if a + b == 0:
  print(0)
else:
  c, r = n // (a + b), n % (a + b)
  nblue = c * a + min(a, r)
  print(nblue)


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

    if a + b == 0:
        print(0)
    else:
        c, r = n // (a + b), n % (a + b)
        nblue = c * a + min(a, r)
        print(nblue)

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):
N, A, B = map(int, input().split())
quot = N // (A + B)
resid = N % (A + B)
if resid:
    print(quot * A + max(resid, A))
else:
    print(quot * A )

N, A, B = map(int, input().split())
quot = N // (A + B)
resid = N % (A + B)
if resid:
    print(quot * A + min(resid, A))
else:
    print(quot * 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())
p,q=divmod(n,(a+b))
print(p*b + [b,q][q<b]) 

n,a,b=map(int,input().split())
p,q=divmod(n,(a+b))
print(p*a + [a,q][q<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):
# coding: utf-8
N, A, B = map(int, input().split())

lst = []
for i in range(A):
    lst.append("b")
for i in range(B):
    lst.append("r")
# print("lst:", lst)

if len(lst) >= N:
    lst = lst[:N]
    print(lst.count('b'))
else:
    lst2 = []
    while len(lst2) < N:
        lst2 += lst
    lst = lst[:N]
    print(lst.count('b'))

# coding: utf-8
N, A, B = map(int, input().split())

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

# coding: utf-8
import numpy as np
N, A, B = map(int, input().split())
print("N:", N, "A:", A, "B:", B)
if A == 0:
    print(0)
elif B == 0:
    print(N)
elif N <= A:
    print(N)
elif N <= A + B:
    print(A)
else:
    lst = np.array([1 for i in range(A)])
    # print(lst)
    lst2 = np.array([0 for i in range(B)])
    # print(lst2)
    lst3 = np.append(lst, lst2)
    # print(lst3)
    while lst3.size < N:
        lst3 = np.append(lst3, lst3)
    lst3 = lst3[:N]
    print(np.count_nonzero(lst3 == 1))

# coding: utf-8
N, A, B = map(int, input().split())

if A == 0:
    print(0)
elif B == 0 or N <= A:
    print(N)
else:
    num = int(N / (A + B)) * A + min(A, N % (A + B))
    print(num)


Verdicts: Wrong Answer

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 = map(int,input().split())
num = 0
num = n // (a+b)

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




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

if n % (a+b) <= a:
    print((num*a)+ (n % (a+b)))
else:
    print((num*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 = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
diff = abs(a - b)

print(diff, x, mod)
if diff >= mod:
    print(a * x + mod)
else:
    if n % 2 == 0:
        print(a * (x + 1))
    else:
        print(a * x + mod)


n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
print(ans, rem, a)
ans += min(rem, a)
print(ans)


n, a, b = [int(i) for i in input().split()]
x = n // (a + b)
mod = n % (a + b)
if a <= b:
    print(a * (x + 1))
else:
    print(a * x + mod)


n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
print(ans, rem, a)
ans += min(rem, a)
print(ans)


n, a, b = [int(i) for i in input().split()]
ans = (n // (a + b)) * a
rem = n % (a + b)
ans += min(rem, a)
print(ans)


Verdicts: Wrong Answer

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())
 
x = int(n/(a+b)) 
y = n%(a+b)

if y > a:
    ans = (x+1) * a
else:
    x * a + y

print(ans)

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

x = int((a+b)/n) 
y = (a+b)%n 
ans = x * a + y

print(ans)

n, a, b = map(int,input().split())
 
x = int(n/(a+b)) 
y = n%(a+b) 

if y > a:
    ans = (x+1) * a
else:
    ans = x * a + y

print(ans)

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, b, a = map(int, input().split())
print(n // (a + b) * b + min(n % (a + b), b)

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

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

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):
args = input()
nums = args.split(' ')
if int(nums[0]) < int(nums[1]):
  print(nums[0])
  exit()
print(nums[1])

args = input()
nums = args.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
blue_calc = int(n / (a + b))
blue_mod = n % (a + b)
if blue_mod < a:
  print(a * blue_calc + blue_mod)
  exit()
print(a * blue_calc + 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=list(map(int,input().split()))
x=0
if n-a-b>0 and b!=0:
    x=n-a-b
    b=b+x
print(b)

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

n,b,r=list(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)

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)

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)

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)

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

m=n%(b+r)
l=n//(b+r)
x=n-l*(b+r)

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

if m==0:
    n_b=l*b
else:
    n_b=l*b+s
print(n_b)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

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: 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 main():
  n, a, b = list(map(int, input().split()))
  if a == 0:
    return 0
  if b == 0:
    return n
  if n <= a:
    return n
  if (a + b) >= n:
    return a
  
  temp = n - a
  set_count = temp // (a + b)
  mod = temp % (a + b)
  blue_in_mod = 0 if mod <= b else mod - b
  
  return a + (set_count * a) + blue_in_mod

def main():
  n, a, b = list(map(int, input().split()))
  if a == 0:
    return 0
  if b == 0:
    return n
  if n <= a:
    return n
  if (a + b) >= n:
    return a
  
  temp = n - a
  set_count = temp // (a + b)
  mod = temp % (a + b)
  blue_in_mod = 0 if mod <= b else mod - b
  
  return a + (set_count * a) + blue_in_mod

print(main())

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, blue, red = map(int,input().split())
count = max(N % (blue+red), blue)
count += int(N/(blue+red)) * blue
print(count)

N, blue, red = map(int,input().split())
count = min(N % (blue+red), blue)
count += int(N/(blue+red)) * blue
print(count)

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())
sho,ama=divmod(N,a+b)
print(N*sho+min(ama,a))

N,A,B = map(int, input().split())
sho,ama=divmod(N,A+B)
print(A*sho+min(ama,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):
# coding: utf-8

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

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

# coding: utf-8

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

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

# coding: utf-8

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

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

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())
import math
x=math.floor(n/(a+b))
print(x*a+max(a,n-x*(a+b)))

n,a,b=map(int,input().split())
import math
x=math.floor(n/(a+b))
print(x*a+min(a,n-x*(a+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):
N, A, B = map(int, input().split())
repeat = N / (A+B)
mod = N % (A+B)
print(A*repeat + min(A, mod))

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

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

n,a,b = map(int,input().split())
ans=n//(a+b)*a
x=n%(a+b)
ans+=min(x,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):
# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = total//n
diff = n % total
if b < diff:
    print(diff + circle*b)
else:
    print(b + circle*b)


# A = [list(map(int, input().split())) for _ in range(3)]
# n = int(input())
# B = [int(input()) for _ in range(n)]
# X = list(map(int, input().split()))
n, b, r = map(int, input().split())
total = b+r
circle = n//total
diff = n % total
if b <= diff:
    print(b + circle*b)
else:
    print(diff + circle*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):
count = 0
i = 0
while (n>i):
    for bi in range(b):
        count += 1
        i += 1
        if n <= i:
            break
    for ri in range(r):
        i += 1
        if n<=i:
            break
print(count)

count = 0
i = 0
while (n>i):
    for bi in range(b):
        count += 1
        i += 1
        if n <= i:
            break
    for ri in range(r):
        i += 1
        if n<=i:
            break
print(count)

n, b, r = map(int, input().split())
i = 0
hoge = n // (b+r)
count = hoge*b
n = n - hoge*(b+r)
if n == 0:
    print(count)
while (n>i):
    count += b
    i += b
    if n<=i:
        print(count - (i-n))
        break
    i += r
    if n<=i:
        print(count)

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

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

Verdicts: Runtime Error

Accepted