Problem:


Score : 200 points

Problem Statement

Takahashi has many red balls and blue balls. Now, he will place them in a row.

Initially, there is no ball placed.

Takahashi, who is very patient, will do the following operation 10^{100} times:

Place A blue balls at the end of the row of balls already placed. Then, place B red balls at the end of the row.

How many blue balls will be there among the first N balls in the row of balls made this way?

Constraints

1 \leq N \leq 10^{18}

A, B \geq 0

0 < A + B \leq 10^{18}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the number of blue balls that will be there among the first N balls in the row of balls.

Sample Input 1

8 3 4

Sample Output 1

4

Let b denote a blue ball, and r denote a red ball. The first eight balls in the row will be bbbrrrrb, among which there are four blue balls.

Sample Input 2

8 0 4

Sample Output 2

0

He placed only red balls from the beginning.

Sample Input 3

6 2 4

Sample Output 3

2

Among bbrrrr, there are two blue balls.



Sample input:
8 3 4


Sample output:
4

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().rstrip().split())
if A + B == 0:
    ret = 0
else:
    ret = (N // (A + B) * A + ('b'*A + 'r'*B)[:(N % (A + B))].count('b'))
print(ret)

Submission status: Runtime Error

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

L = []

for i in range(10**100):
    L += A*["b",]
    L += B*["r",]
    if len(L) >= N:
        break

#print(L,L[:N])
cnt = 0
for l in L[:N]:
    if l == "b":
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split())
a = list()
a = ["b"]*A + ["r"]*B
import math
n = math.ceil(N//(A+B))
for i in range(n):
    a = a + a
del a[N:]
print(n)
print(a)
print(a.count("b"))

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
l = []

for i in range(1000):
    for j in range(n[1]):
        l.append('blue')
    for k in range(n[2]):
        l.append('red')

blue = 0
red = 0

for i in range(n[0]):
    if l[i] == 'blue':
        blue = blue + 1


print(blue)

Submission status: Runtime Error

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

tmp_init = [1]*A + [0]*B
#len_add = len(tmp)
sum_tmp_init = sum(tmp_init)
len_tmp = len(tmp_init)
sum_b = 0
len0 = 0
tmp = []
while len(tmp) < N:
    sum_b += sum_tmp_init
    len0 += len_tmp
    tmp += [1]*A + [0]*B

ans = sum_b -sum_tmp_init  + sum(tmp_init[:N-len0+len_tmp])

print(ans)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if A==0 and B==0:
    print(0)
else:
    s=""
    while len(s)<N:
        s=s+"a"*A+"b"*B
    s=s[:N]
    co=0
    for i in range(len(s)):
        if "a" in s[i]:
            co+=1
    print(co)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
a = ""
b = ""
for i in range(A):
  a += "a"
for j in range(B):
  b += "b"
c = a+b
while len(c) <= N:
  c += c

d = c[:N]
print(d.count("a"))

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
st_a='b'*A
st_b='r'*B
d=st_a+st_b
e=A+B
if(e==0):
  print(0)
else:
  num=int(N/e)+2
  b=d*num
  print(b)
  c=b[0:N]
  print(c)
  print(c.count('b'))

Submission status: Runtime Error

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

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

    ans = 0
    
    if(N > 0 and A > 0 and B > 0):
        count = N // (A+B) + 1
        result = br * N

        for i in range(N):
            if(result[i] == 'b'):
                ans+=1

    print(ans)
    #print(result[:N].count('b'))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, Ablue, Bred = map(int, input().split())
row = ''
for _ in range(N):
  row += str( Ablue * 'b' ) + str(Bred * 'r' )

print(row[:N].count('b') )

Submission status: Runtime Error

Solution code:
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
ballcolumn = ''
for i in range(10**100):
    ballcolumn+=blue*A
    ballcolumn+=red*B
targetstring = ballcolumn[:N]
print(targetstring.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  v = 10 ** 100
  s = ""
  for i in range(v):
    if a > 0:
      s += "b" * a
    if b > 0:
      s += "r" * b
    if len(s) >= n:
      res = s[:n]
      print(res)
      print(res.count("b"))
      break

Submission status: Runtime Error

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

length = ''
while len(length) <= N:
    length += 'b' * A
    length += 'r' * B
ans = length[:N]
print(ans.count('b'))

Submission status: Runtime Error

Solution code:
N = input()
A = input()
B = input()

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

Submission status: Runtime Error

Solution code:
inputarray = input().split(' ')
N = int(inputarray[0])
A = int(inputarray[1])
B = int(inputarray[2])
blue = 'b'
red = 'r'
ballcolumn = ''
for i in range(10):
    ballcolumn+=blue*A
    ballcolumn+=red*B
targetstring = ballcolumn[:N]
print(targetstring.count('b'))

Submission status: Runtime Error

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

L = []

for i in range(10*100):
    L += A*["b",]
    L += B*["r",]
    if len(L) >= N:
        break

#print(L,L[:N])
cnt = 0
for l in L[:N]:
    if l == "b":
        cnt += 1

print(cnt)

Submission status: Runtime Error

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

s = ''
while len(s) < n:
  if 0 < a:
    s += 'a' * a
  if 0 < b:
    s += 'b' * b
print(s.count('a', 0, n))

Submission status: Runtime Error

Solution code:
N,A,B =int(input())
r = 1
S=string()
while r<=10**100:
	S='b'*B+ S+ 'r'*A
    r += 1


print(S[1:N].count(b))

Submission status: Runtime Error

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

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

    count = N // (A+B) + 1
    result = br * N

    ans = 0
    for i in range(N):
        if(result[i] == 'b'):
            ans+=1

    print(ans)
    #print(result[:N].count('b'))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
ball = []
kaisu = -(-N//(A+B))

for n in range(kaisu):
    ball += [0]*A
    ball += [1]*B

ball = ball[:N]
print(ball.count(0))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
S = ''
a = 'b'*A+'r'*B
count=int(N/len(a))+N//len(a)
for i in range(0,count):
    S += a
print(S[:N].count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = 'b'*A + 'a'*B
while True:
  if len(x) >= N:
    break

  x += 'b'*A + 'a'*B

print(x.count('b', 0,N))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  str += red

print(str[:N].count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
l = ""
cnt = 0
for i in range(10 **100):
    n1 = "b" * A
    n2 = "r" * B
    l += n1 + n2
    for j in range(N):
       if j == "b":
           cnt += 1
print(cnt)

Submission status: Runtime Error

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

boals = ''
while len(boals) < N:
    boals += 'b' * A + 'r' * B
print(boals.count('b', 0, N))

Submission status: Runtime Error

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

moji="b"*A+"r"*B
#print(moji)

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

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb=ballb*A
ballr.append('r')
ballr=ballr*B
ball=(ballb+ballr)*(10**18)
count=0
for i in range(N):
    if ball[i]=='b':
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split())
a = list()
a = ["blue"]*A + ["red"]*B
import math
n = math.ceil(N/(A+B))
for i in range(n):
    a = a + a
del a[N:]
print(a.count("blue"))

Submission status: Runtime Error

Solution code:
import math

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

def make():
    b = [1] * A
    r = [0] * B
    return b + r

a = N / (A + B)
a = math.ceil(a)

result = []
for i in range(a):
    result = result + make()

acc = sum(result[0:N])
print(acc)

Submission status: Runtime Error

Solution code:
s = input().split()

n = int(s[0])
blue = int(s[1])
red = int(s[2])
br = ["b"]*blue
rr = ["r"]*red
arr = []

for i in range(0,n):
  arr.extend(br)
  arr.extend(rr)
  
c = arr[0:n]

print(c.count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
result = ""
ballCount = 0
ballStr = ""
i = 0
while len(result) < N:
    if i % 2 == 0:
        ballCount = A
        ballStr = "b"
    else:
        ballCount = B
        ballStr = "r"
    result += (ballStr * ballCount)
    i+=1

count = 0
for i in result[:-(len(result) - N)]:
    if i == "b":
        count += 1
# print(result[:-(len(result) - N)])
print(count)

Submission status: Runtime Error

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

x = ''
s_length = A+B
while True:
  x = 'b'*A + 'a'*B

  t_length = N - len(x)
  if s_length >= t_length:
    break

if N - len(x) > A:
  x += 'b'*A + 'a'*t_length
else:
  x += 'b'*t_length

print(x.count('b'))

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
st_a='b'*A
st_b='r'*B
d=st_a+st_b
e=A+B
num=int(N/e)+1
b=d*num
c=b[0:N]
print(c.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  s = ""
  for i in range(10 ** 100):
    if a > 0:
      s += "b" * a
    if b > 0:
      s += "r" * b
    if len(s) >= n:
      res = s[:n]
      print(res)
      print(res.count("b"))
      break

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x = ""
if a == 0:
    print("0")
else:
    x = (("b"*a) + ("r"*b))
    x = x*(n//len(x)+1)
    print(x[:n].count("b"))

Submission status: Runtime Error

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

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

    count = N // (A+B) + 1
    result = br * count

    print(result[:N].count('b'))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if A==0 and B==0:
    print(0)
else:
    s=""
    i=1
    while (A+B)*i<N:
        s=s+"a"*A+"b"*B
        i+=1
    s=s[:N]
    print(s.count("a"))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

while len(str) < N:
  str += blue
  if len(str) < N:
    str += red

print(str[:N].count('b'))

Submission status: Runtime Error

Solution code:
#coding:utf-8
n, a, b = map(int, input().split())

if n >= (a+b):
    count = n // (a+b)
    mod = n % (a+b)
    #print(count, mod)
else:
    count = 1
    mod = 0

if mod != 0:
    ball = ('b'* a + 'r'* b) * (count + 1)
else:
    ball = ('b'* a + 'r'* b) * count

ans_ball = ball[:n]

print(ans_ball.count('b'))

Submission status: Runtime Error

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

    if(A != 0):
        b = 'b'*A
        r = 'r'*B
        br = b + r

        count = N // (A+B) + 1
        result = br * count

        print(result[:N].count('b'))
    else:
        print(0)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():
	n,a,b = map(int, input().split())
	if a==0:
		print(0)
	else:
		if n<a:
			print()
		elif a=<n:
			print(a)
		else:
			for i in range(1,10**100):
				if n > (a+b)*i:
					continue
				elif (a+b)*(i-1)=<n:
					print(a*(i-1)+n-(a+b)*(i-1))
					break
main()

Submission status: Runtime Error

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

X = ''
Y = 1

while len(X) < N:
    if Y%2 == 1:
        X = X + 'b' * A
    elif Y%2 == 0:
        X = X + 'r' * B
    Y += 1

print(X[0:N].count('b'))

Submission status: Runtime Error

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


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]

# print(bakks)
count = 0
for x in balls:
    if x == 'b':
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
count = 0
Bs = "b"*A
Rs = "r"*B
ballset = Bs+Rs
#print(Bs)
#print(Rs)
n = (N//len(ballset)+1)
#print(len(ballset))
#print(n)
allball = ballset*n
print(allball[:N].count("b"))

Submission status: Runtime Error

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

if a + b < n:
  s = 'a' * a
  s += 'b' * b
  print(s.count('a'))
  exit()

s = ''
while len(s) < n:
  s += 'a' * a
  s += 'b' * b

print(s.count('a', 0, n))

Submission status: Runtime Error

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

row = ''
for i in range(1000):
    row +='b' * A
    row+= 'r' * B

print(list(row[:N]).count('b'))

Submission status: Runtime Error

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

balls= ""
count = 0
blue = 0

for i in range(10**18):
  count= count+1
  if count % 2 == 1:
    balls = balls +'b'*a
  else:
    balls = balls +'r'*b
  if i > n:
    break

for i in range(n):
  if balls[i] == 'b':
  	blue = blue+1

print(blue)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
l=list('b'*a+'r'*b)
s=n-(a+b)+1

m=l*s
val=0
for i in m[:n]:
    if i=='b':
        val+=1
print(val)

Submission status: Runtime Error

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

n = int(input())

s = n // (a + b)
m = n % (a + b)

if a > m:
    print(a * s + m)
else:
    print(a * s + a)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = 'b'*a + 'r'*b
s_len = len(s)
ret = 0
ret = n // s_len * a
if n % s_len < a:
  ret += n% s_len
else:
  ret += a
print(ret)

Submission status: Runtime Error

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

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // len(BlueRed))+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N_A_B = list(map(int, input().split()))
ball = ""
num = 10 ** 100
for i in range(num):
  if (len(ball) >= N_A_B[0]):
    break
  ball += "A" * N_A_B[1]
  if (len(ball) >= N_A_B[0]):
    break
  ball += "B" * N_A_B[2]
  if (len(ball) > N_A_B[0]):
    break

print(ball[:N_A_B[0]].count("A"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
if a == 0 or n == 0:
  print(0)
else:
  s = ""
  for i in range(1000):
    if a > 0:
      s += "b" * a
    if b > 0:
      s += "r" * b
    if len(s) >= n:
      res = s[:n]
      print(res.count("b"))
      break

Submission status: Runtime Error

Solution code:
import math

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

def make():
    b = 'b' * A
    r = 'r' * B
    balls = b + r
    return balls

a = N / (A + B)
a = math.ceil(a)

result = ''
for i in range(a):
    result = result + make()

acc = result[0:N].count('b')

print(acc)

Submission status: Runtime Error

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

n = int(input())

s = n // (a + b)
m = n % (a + b)

if a > m:
    print(a * s + a)
else:
    print(a * s + m)

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split())
a = list()
a = ["blue"]*A + ["red"]*B
for i in range(N):
    a = a + a
del a[N:]
print(a.count("blue"))

Submission status: Runtime Error

Solution code:
N,B,R = map(int,input().split())
k = N % (B + R)
k2 = int(N / (B + R))
s = ("b"*B + "r"*R)
s1 = s[:(k)]
print(k2*(B) + s1.count("b"))

Submission status: Runtime Error

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

row = ""
while len(row) <= n:
    row += "b"*blue + "r"*red

print(row[:n].count("b"))

Submission status: Runtime Error

Solution code:
N,A,B = (int(x) for x in input().split())
S =  n % (A+B) - A
Acount = n % (A+B)
Ansn = n / (A+ B) * A
if S <= 0
    print(Ansn + Acount)
else
    print(Ansn + A)

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
st_a='b'*A
st_b='r'*B

sum=0
b=''
d=st_a+st_b
e=A+B
while sum<=N:
  sum+=e
  b+=d
c=b[0:N]
print(c.count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
St = ''
while len(St) < N:
    St += 'b' * A + 'r' * B
ans = 0

for i in range(0, N):
    if St[i] == 'b':
        ans += 1
    

print(ans)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, A, B = map(int, input().split())
    lst = ""
    for i in range(int(N/(A+B)) + 1):
        lst += "b"*A + "r"*B

    print(lst[0:N].count("b"))
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // 7)+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

Submission status: Runtime Error

Solution code:
import math

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

string = 'r'* A + 'b'*B
res = ''
for _ in range(math.ceil(N/(A+B))):
    res += string

print(res[:N].count('r'))

Submission status: Runtime Error

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

i = 0
l = [0]*N
while i < N:
  for a in range(A):
    l[i] = 'b'
    i += 1
    if i > N : break
    
  for b in range(B):
    l[i] = 'r'
    i+= 1
    if i >N : break
      
print(l.count('b'))

Submission status: Runtime Error

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

ans = []
for _ in range(10**18):
    ans.append("b"*A)
    ans.append("r"*B)
    
    if len("".join(ans)) >= N:
        break

ans = "".join(ans)
print(ans[:N].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

list = ''
while len(list) < N :
  list  += 'b'*A
  if len(list) < N:
    list += 'r'*B

print(list[0:N].count('b'))

Submission status: Runtime Error

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

    if(A > 0):
        b = 'b'*A
        r = 'r'*B
        br = b + r

        count = N // (A+B) + 1
        result = br * N

        print(result[:N].count('b'))
    else:
        print(0)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

pair = A + B
loop = (N // (A+B)) + 1
message = ''
for _ in range(loop):
    message += 'b' * A + 'r' * B
print(message[0:N].count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
blue = 'b' * A
red = 'r' * B
str = ''

for _ in range(N):
  for i in range(A):
    if len(str) < N:
      str += blue
  for j in range(B):
    if len(str) < N:
      str += red

print(str.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
ans = ""
while True:
  ans += "b" * a
  ans += "r" * b
  if len(ans) >= n:
    break
print(ans[:n].count("b"))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().rstrip().split())
if A == B == 0:
    print(0)
else:
    print((N//(A+B) * A + ('b'*A+'r'*B)[:(N % (A+B))].count('b')))

Submission status: Runtime Error

Solution code:
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
ans = kurikaeshi * a
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
for i in range(1,kurikaeshi+2):
    ball_list.append(blue)
    ball_list.append(red)
for l in range(0,a+1):
    if(list(ball_list)[amari] == 'b'):
        ans += 1
print(ans)

Submission status: Runtime Error

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

s = "b"*a + "r"*b
d = n//(a+b)+1
s = s*d
print(s[:n].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s = ''
while len(s) < n:
  s += 'a' * a
  s += 'b' * b

print(s.count('a', 0, n))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
str=""
strb="b"*A
stra="a"*B
str=str+strb
str=str+stra

ans=0
if N <= len(str):
    for i in str[0:N]:
        if i=="b":
            ans+=1
    print(ans)
else:
    for i in str:
        if i=="b":
            ans+=1
    ans=ans*int(N/len(str))
    for i in str[0:N%len(str)]:
        if i=="b":
            ans+=1
    print(ans)

Submission status: Runtime Error

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


balls = ''
for i in range(N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

Submission status: Runtime Error

Solution code:
# c = list(map(int, input().split()))
# a, b, c = map(int, input().split())
# a = [list(map(int, list(input()))) for i in range(n)]
n, a, b = map(int, input().split())

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

if (m <= a):
    v = m
elif m >= a and m <= b:
    v = a

print(int(r * a + v))

Submission status: Runtime Error

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

balls= ""
count = 0
blue = 0

while len(balls)<=n:
  count= count+1
  if count % 2 == 1:
    balls = balls +'b'*a
  else:
    balls = balls +'r'*b

for i in range(n):
  if balls[i] == 'b':
  	blue = blue+1

print(blue)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
st_a='b'*A
st_b='r'*B

sum=0
b=''
while sum<=N:
  b+=st_a
  sum+=A
  if(sum>=N):
    break
  b+=st_b
  sum+=B
c=b[0:N]
print(c.count('b'))

Submission status: Runtime Error

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

    if(A > 0):
        b = 'b'*A
        r = 'r'*B
        br = b + r

        count = N // (A+B) + 1
        result = br * count

        #result += br

        print(result[:N].count('b'))
    else:
        print(0)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":pass
n, a, b = i2()
if a == 0 and b == 0:
    print(0):
elif a == 0:
    print(0)
elif b == 0:
    print(n)
else:
    cnt = n // (a+b)
    c = n%(a+b)
    if c <= a:
        print(a*cnt+c)
    else:
        print(a*cnt+c-b)

Submission status: Runtime Error

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B == N or A + B > N and N >= A:
    print(A)
else A + B > N and N < A:
    print(N)
else:
    r = int(N / (A+B))
    q = N % (A+B)
    print(r * A + q)

Submission status: Runtime Error

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

s = 'b'*a+'r'*b
x = n//(a+b) 
y = n%(a+b) 

print(x*a+s[:y].count('b'))

Submission status: Runtime Error

Solution code:

if __name__ == "__main__":
    N, A, B = map(int, input().split())
    S = "b" * A + "r" * B 
    S = S * 1000
    ret = S[:N].count("b")
    print(ret)

Submission status: Runtime Error

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

i = 0
l = [0]*N
while i < N:
  for a in range(A):
    l[i] = 'b'
    i += 1
    if i >= N : break
    
  for b in range(B):
    l[i] = 'r'
    i+= 1
    if i >= N : break
      
print(l.count('b'))

Submission status: Runtime Error

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

str = ""
b = 0
r = 0

while b + r <= N:
  for i in range(0,A):
    str = str + "b"*A
    b = b + A
    str = str + "r"*B
    r = r + B

print(list(str)[:N].count("b"))

Submission status: Runtime Error

Solution code:
6 2 4

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main()
{
  int64_t n, a, b, ans = 0;
  cin >> n >> a >> b;
  if (a == 0)
  {
    cout << "0\n";
    return 0;
  }
  if (n <= a)
    ans = n;
  else
  {
    if (n == a + b)
      ans = a;
    else if (n > a + b)
      ans = n - b;
    else
      ans = min(n, a);
  }
  cout << ans << "\n";
}

Submission status: Runtime Error

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

answer =0

if A==0:
    answer = 0
elif b==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

Submission status: Runtime Error

Solution code:

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

Submission status: Runtime Error

Solution code:
def main():
    N, A, B = map(int, input().split())
    lst = ""
    for i in range(N):
        lst += "b"*A + "r"*B

    print(lst[0:N].count("b"))
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls.count('b'))

Submission status: Runtime Error

Solution code:
N_A_B = list(map(int, input().split()))
ball = ""
for i in range(10**100):
  ball += "A" * N_A_B[1]
  if (len(ball) >= N_A_B[0]):
    break
  ball += "B" * N_A_B[2]
  if (len(ball) >= N_A_B[0]):
    break

print(ball[:N_A_B[0]].count("A"))

Submission status: Runtime Error

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

ans=""
i=1
while i<=x:
    ans=ans+"A"*a+"B"*b
    i+=1
#ans2=[ans]
ans2=ans[:n]
print(ans2.count("A"))

Submission status: Runtime Error

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

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

if A == 0:
    print(0)
elif B == 0:
    print(N)
elif A + B = N or A + B > N and N >= A:
    print(A)
else A + B > N and N < A:
    print(N)
else:
    r = int(N / (A+B))
    q = N % (A+B)
    print(r * A + q)

# -----
# 8 4 2
# bbbbrrbb bb

# 13 4 2
# bbbb rr bbbb rr b

# 2 4 2
# bb

# r = N / (A+B)
# q = N % (A+B)
# r * A + q

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
print(n)
print(a)
print(b)
if a == 0:
  print(0)
else:
  s = ""
  for i in range(1000):
    s += "b" * a
    s += "r" * b
    if len(s) >= n:
      res = s[:n]
      print(res.count("b"))
      break

Submission status: Runtime Error

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

s = ''

while (len(s) <= n):
    s += 'b' * a
    s += 'r' * b

tmp = s[0:n]

print(tmp.count('b'))

Submission status: Runtime Error

Solution code:
def main(n, a, b):
    i = 0
    ans = ""

    while i <= n:
        ans += a * "b" + b * "r"
        i += a + b

    print(ans[:n].count("b"))


if __name__ == "__main__":
    n, a, b = map(int, input().split())

    main(n, a, b)

Submission status: Runtime Error

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

    if(A > 0):
        b = 'b'*A
        r = 'r'*B
        br = b + r

        count = N // (A+B) + 1
        result = ''

        for _ in range(count):
            result += br

        print(result[:N].count('b'))
    else:
        print(0)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

    if A + B == 0:
        return 0

    s = 'b'*A + 'r'*B
    r = N // (A+B)
    m = N % (A+B)
    
    rest = 0
    if A >= m:
        rest = m
    else:
        rest = A

    ans = A*r + rest
    
    return ans

print(solve())

Submission status: Runtime Error

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

br = ''
for i in range(cnt):
    br += 'b'*A + 'r'*B

br = br[:N]
print(br.count('b'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if A==0 and B==0:
    print(0)
else:
    s=""
    while len(s)<N:
        s=s+"a"*A+"b"*B
    s=s[:N]
    print(s.count("a"))

Submission status: Runtime Error

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


balls = ''
for i in range(2*N):
    balls += 'b'*A + 'r'*B
balls = balls[0:N]
print(balls)
print(balls.count('b'))

Submission status: Runtime Error

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

num = 0
count = 0
res = ''

while num <= n:
  if count % 2 == 0:
    res += 'b'*b
    num += b
  else:
    res += 'r'*r
    num += r
  count += 1

ans = 0
for i in range(n):
  if res[i] == 'b':
    ans += 1
print(ans)

Submission status: Runtime Error

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

answer =0

if A==0:
    answer = 0
if b==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

Submission status: Runtime Error

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

if b >> A:
    print( a * A + A )
else:
    print( a * A + b )

Submission status: Runtime Error

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

    if(B >= 0):
        b = 'b'*A
        r = 'r'*B
        br = b + r

        count = N // (A+B) + 1
        result = ''

        for _ in range(count):
            result += br

        print(result[:N].count('b'))
    else:
        print(0)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
S = ''
r = 'r'*B
b = 'b'*A
while len(S) < N+5:
    S += b
    S += r
print(S[:N].count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x = ""
if a == 0:
    print("0")
else:
    while len(x) < n:
        x += (("b"*a) + ("r"*b))
    print(x[:n].count("b"))

Submission status: Runtime Error

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

while N > 0:
  if cnt % 2 == 0:	# 青
    i = min(A, N)
    ball = ball + 'b' * i
  else:				# 赤
    i = min(B, N)
    ball = ball + 'r' * i
  N -= i
  cnt += 1

print(ball.count('b'))