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:
import sys
n, a, b = map(int, input().split())
if (a + b) * (10**100) <= n:
    print(a * (10**100))
    sys.exit()
else:
    for i in range(n):
        if (a + b) * i <= n < (a + b) * (i + 1):
            j = i
            break
if n - (a + b) * j >= a:
    print(a * j + a)
    sys.exit()
else:
    print(a * j +n-(a + b)*j )
    sys.exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

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

print((A * q) + min(mod, A)))

Submission status: Runtime Error

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

    if(A == 0):
        print(0)
        exit(0)
    if(B == 0):
        print(0)
        exit(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'))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N , A , B = (map(int , input().split()))
a = ''
l = -(-N//(A + B))
for i in range(l):
    a += 'b'*A
    a += 'r'*B
    if len(a) >= N:
        break
print(list(a[:N]).count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

s = ''
for i in range(10**100):
    s += 'b' * a
    s += 'r' * b
    if len(s) > n:
        break
print(s[:n].count('b'))

Submission status: Runtime Error

Solution code:

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

ans = 0
#print(int(N/(A+B)))
for i in range(1, int(N/(A+B))+1):
    ans = ans + A

r = N-(A+B)*i
#print(r)

if r <= A:
    ans = ans + r
else:
    ans = ans + A

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter 
n, a, b = map(int, input().split())
red = "r"*b
blue = "b"*a
k=""
while len(k) <= n:
    k += blue+red 
count = Counter(k[:n]) 
print(count['b'])

Submission status: Runtime Error

Solution code:
#coding:utf-8
n, a, b = map(int, input().split())
count = n // (a+b)
mod = n % (a+b)
#print(count, mod)
ball = ('b'* a + 'r'* b) * count

if mod >= 1:
    ball = ball + 'b'* a + 'r'* b

ans_ball = ball[:n]
print(ans_ball.count('b'))

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

tmp = [1]*A + [0]*B
while len(tmp) < N:
    tmp += tmp
ans = sum(tmp[:N])

print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
blue='b'*a
red='r'*b
s = str(blue+red)*100
ss=s[:n]
print(ss.count('b'))

Submission status: Runtime Error

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

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

fulls = n // (a+b)
lefts = n % (a+b)

print(fulls*a + min(left, a))

Submission status: Runtime Error

Solution code:
import math

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

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

blue = a * k
if m >= a:
  blue = blue + a
else:
  blue = blue + m
  
print(blue)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
row = str('b')*a
while len(row) < n:
    if a == 0:
        print(0)
        break

    row += str('r')*b + str('b')*a
ans = row[0:n].count('b')
print(ans)

Submission status: Runtime Error

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

Blue='b'*A
Red='r'*B
ans = ''
for i in range(1,N):
    ans = ans + Blue + Red
    if N <= len(ans):
        ans2=ans[:N]
        print(ans2.count('b'))
        break

Submission status: Runtime Error

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

items = []
while len(items) < N:
     items.append('b' * A)
     items.append('r' * B)

print(items.count("b"))

Submission status: Runtime Error

Solution code:
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[:min(amari, len(S)-1)]

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

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

    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:
if A!= 0:
  print(A+N-(A+B))
else:
  print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

n, a, b = map(int, sys.stdin.readline().split())
s = 'b'*a + 'r'*b

x = n // (a+b)
y = n % (a+b)

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
addBlue = 'b'*A
addRed = 'r'*B
count = 0
boals = ''

while len(boals) < N:
    boals += addBlue
    boals += addRed
    count += A

print(count - boals[N:len(boals)].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
ball_str=""
for i in range(10**100):
    if len(ball_str)<=N:
        ball_str+="b"*A+"r"*B
    else:
        break
print(ball_str[:N].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 = int(n / (a + b))
m = n % (a + b)

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

print(r * a + v)

Submission status: Runtime Error

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

s = ''
i = 1
while len(s) < n:
  s += 'a' * a
  s += 'b' * b
  i += 1
  if i > 10**100:
    break
print(list(s)[:n].count('a'))

Submission status: Runtime Error

Solution code:
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
s = ''
while i <= n:
    s += 'b' * a
    s += 'r' * b
    i += a + b

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

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#AtCoder

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

b = 'b'*A
r = 'r'*B

s = ''
while True:
    if len(s) >= N:
        break
    s += b
    s += r

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
s=["b"]*a+["r"]*b 
rupu= n//len(s)
amari=n%len(s)
if amari>a :
    print(rupu*a+a)
else:
    print(rupu*a+amari)

Submission status: Runtime Error

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

count = 0
for i in lst[0:N]:
    if i == "b":
        count += 1
print(count)

Submission status: Runtime Error

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

s = "b"*a + "r"*b
s = s*(10**8)
print(s[:n].count("b"))

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-1].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
file = ''
while len(file) <= N+1:
  file += A*"b"
  file += B*"r"
res = file[0:N]
blue = res.count("b")
print(blue)

Submission status: Runtime Error

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

s = int(n / (a + b))

if n % (a + b) == 0:
  print(a * s)
else:
  rem = n % (a + b)
  if rem <= a:
    ans = a * s + rem
  else:
    ans = a * s + (rem % a)
  print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=input().split()
try:
    loop=n//(a+b)
except:
    loop=0
try:
    remainder=n%(a+b)
except:
    remainder=0
print(loop*a+min(reminder,a)

Submission status: Runtime Error

Solution code:
N, A, B = [int(i) for i in input().split()]
S = 'b' * A + 'r' * B
if A == 0 and B == 0:
    print(0)
else:
    while len(S) < N:
        S += S
    print(S[0:N].count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
blue='b'*a
red='r'*b
s = str(blue+red)*n
ss=s[:n]
print(ss.count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
str = ''
while len(str) < n:
    str += 'b'*a + 'r'*b
ans_str = str[0:n]
print(ans_str.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 = ''

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

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

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

s = "b" * a + "r" * b

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

if a <= ama:
    print(ans + s[:ama].count("b"))
else:
    print(ans + ama)

Submission status: Runtime Error

Solution code:
from collections import Counter

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

s = ""

while(len(s)<=N):
  s+="b"*A
  if len(s)>N:
      break
  s+="r"*B
ans = Counter(s[:N])["b"]
print(ans)

Submission status: Runtime Error

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

if a == 0:
  print(0)
elif b == 0:
  print(n)
else:
  while len(res) < n:
      res += 'b'*a
      res += 'r'*b

  res = res[:n]
  print(res)
  print(res.count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# ABC158 B

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

column = ""

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

print(column[:N].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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[:amari]

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

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

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

blue = "b"*A
red = "r"*B
br = blue + red

# print(blue, red, br)

S = br*N
import collections

print(collections.Counter(S[:N])["b"])

Submission status: Runtime Error

Solution code:
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, A, B = MAP()

# blues = 0
# while N > 0:
#     if N - A < 0:
#         A = N
#     N -= A
#     blues += A

#     N -= B

# print(blues)

S = []

while len(S) <= N:
    S += "b" * A
    S += "r" * B

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

Submission status: Runtime Error

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

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

s = ''
while len(s) < n:
  s += 'a' * a
  s += 'b' * b
print(list(s)[:n].count('a'))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

temp_plus = ("1" * a) + ("0" * b)
temp = ""
while len(temp) <= n:
    temp += temp_plus

print(temp[0:n].count("1"))

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 = ''

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

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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

x = 'b'*A + 'r'*B
while True:
  if len(x) > N:
    break
  x += 'b'*A + 'r'*B
  
cout =0
for i in range(N):
  if x[i] == 'b':
    cout += 1
    
print(cout)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int, input().split())
addBlue = 'b'*A
addRed = 'r'*B
boals = ''

while len(boals) < N:
    boals += addBlue
    boals += addRed

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def main():

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

    blue = ['b']*A
    red = ['r']*B
    l = []
    while len(l) <= N:
        l.extend(blue)
        l.extend(red)
    print(l[:N].count('b'))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
blue='b'*a
red='r'*b
s = str((blue+red)*n)[:n]
print(s.count('b'))

Submission status: Runtime Error

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

s = 'b'*a+'r'*b
ind = n%(a+b) 

print(s[ind-1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

length = ''
for i in range(10 ** 100):
    length += 'b' * A
    length += 'r' * B
    if len(length) >= N:
        ans = length[:N]
        print(ans)
        print(ans.count('b'))
        break

Submission status: Runtime Error

Solution code:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    count = math.ceil(n/(a+b))
    ball = []
    for _ in range(count):
        ball += ["b"] * a
        ball += ["r"] * b
    print(ball[:n].count("b"))



if __name__=="__main__":
    main()

Submission status: Runtime Error

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

s = "b" * a + "r" * b

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

print(ans + s[:ama].count("b"))

Submission status: Runtime Error

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

	ball = "b" * a +  "r" * b
	ball = list(ball)
	while n > len(ball):
		ball += ball

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

if __name__ == '__main__':
	main()

Submission status: Runtime Error

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

ans=""
for i in range(10**100):
    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().split())
s=""
while len(s)<N:
    s=s+"a"*A+"b"*B
s=[:N]
print(s.count("a"))

Submission status: Runtime Error

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

    while i <= n:
        ans += a * "b"
        i += a
        ans += b * "r"
        i += 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:
n, a, b = map(int, input().split())
cnt = 0
ans = 0
if n//(a+b) <= 10**100:
    ans += a * n//(a+b)
    cnt += (n//(a+b))*(a+b)
else:
    ans += a * (10**100//(a+b))
    cnt += (10**100//(a+b))*(a+b)

if n - cnt >= a:
    ans += a:
else:
    ans += n - cnt
print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = [int(i) for i in input().split()]
S = 'b' * A + 'r' * B
while len(S) < N:
    S += S

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

Submission status: Runtime Error

Solution code:
def main():
  n, a, b = map(int, input().split(' '))
  s = ''
  
  while len(s) <= n:
    s+='b'*a
    s+='r'*b
    
  print(s.count('b', 0, n))
  
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
def main():
    n,a,b=map(int,input().split())
    t=n//(a+b)
    ans=a*t+min(n%(t*(a+b)),a)
    print(ans)

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
cnt = 0
ball = ''
while cnt<n:
    ball += 'b'*a
    ball += 'r'*b
    cnt += a+b
print(ball.count('b',0,n))

Submission status: Runtime Error

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

while len(res) < n:
  res += 'b'*a
  res += 'r'*b
  
res = res[:n]
print(res.count('b'))

Submission status: Runtime Error

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

if 0 <= r <= A:
  blue = q * A + r
else:
  blue = a * A + A
  
print(blue)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = "b" * a + "r" * b
if a == 0 and b == 0:
    print(0)
if s[n % (a + b)] == "b":
    bcnt = n % (a+b)
else:
    bcnt = a
print(n // (a + b) * a + bcnt)

Submission status: Runtime Error

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

while len(S)<=N:
  S+=A*"b"
  S+=B*"r"

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

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(list(s)[:n].count('A'))

Submission status: Runtime Error

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

AB = "b" * A + "r" * B

o = N // len(AB) + 1
l = AB * o

print(l[:N].count("b"))

Submission status: Runtime Error

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