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:

def main(N: int , A: int , B: int):
    r = "b" * A
    r += "r" * B
    for i in range(10*100):
        r += r
        if N <= len(r):
            sub = r[:N]
            return sub.count("b")

if __name__ == "__main__":
    s = input().split()
    N = int(s[0])
    A = int(s[1])
    B = int(s[2])
    print(main(N, A, B))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
s=''
for i in range(n//(a+b)+1):
  s+='b'*a
  s+='r'*b
print(s[:n].count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
s = 'b'*A+'r'*B + 'b'*(N-A-B)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
data = input().split(" ")
tmp = 0
total =0
for i in data:
  i = int(i)
  
data1 = data[1]+data[2]
  
while (tmp<=data[0]):
  total = data[1]
  tmp += data1
  
if (tmp%data1 != 0) || (tmp%data1 < data[1]):
  total -= data[0] - tmp
  
print(total)

Submission status: Runtime Error

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

ans = []
for _ in range(N//(A+B)+1):
    ans.append("b"*A)
    ans.append("r"*B)
        
ans = "".join(ans)
print(ans[:N].count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = ""
b_cnt = 0
while len(s) + (a + b) <= n:
    s += "b"*a + "r"*b
    b_cnt += 1
rest = n - len(s)
ans = a * b_cnt + rest
print(ans)

Submission status: Runtime Error

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

rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)

if D == 0:
    ans = A * C
else:
    ans = A * C + rep[:D].count("b")
print(ans)

Submission status: Runtime Error

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


x = N // (A + B)
y = N % (A + B)
length = 'b' * A + 'a' * B

z = length[:y].count('b')
ans = x * A + z


print(int(ans))

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 = ""
  str_length = 0
  count = 0
  b_str = "b" * a
  r_str = "r" * b
  for i in range(v):
    s = b_str
    if b > 0:
      s += r_str
    
    str_length = (i + 1) * (a + b)
    if str_length >= n:
      target_length = n - (a+b) * i
      res = s[:target_length]
      count += res.count("b")
      print(count)
      break

    count += s.count("b")

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
C=A+B
if (0<C<10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue=("a"*A+"b"*B)*N
    number=queue.count("a",0,N)
    print(number)

Submission status: Runtime Error

Solution code:
print((n/(a+b)*a)+min(b,n%(a+b)))

Submission status: Runtime Error

Solution code:

N, A,B = map(int, input().split())
str = []
from math import floor
list_ab = []
list_b = ['b']*A
list_ab.append(list_b)
list_a = ['a']*B
list_ab.append(list_a)

count = (floor(N/(A+B))+1)
str.append(list_ab*count)


import itertools
str = list(itertools.chain.from_iterable(str))
str = list(itertools.chain.from_iterable(str))

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

Submission status: Runtime Error

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

N=int(li[0])
A=int(li[1])
B=int(li[2])

def firstcheck():
    sum=A+B
    count=A
    if(A>=N or A+B>=N):
        return A

    while True:
        if(i%2==0):
            sum+=A
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
                continue
        else:
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if A+B != 0:
  tmp = N //(A+B)
  x = ('b'*A + 'a'*B)*tmp + 'b'*(N-(A+B)*tmp)
  print(x.count('b', 0,N))
else:
  print(0)

Submission status: Runtime Error

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

N=int(li[0])
A=int(li[1])
B=int(li[2])

def firstcheck():
    sum=A+B
    count=A
    if(A>=N or A+B>=N):
        return A

    while True:
        print('he2')
        print(sum)
        if(i%2==0):
            sum+=A
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
                continue
        else:
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
N = list[0]
B = list[1]
A = list[2]


r = 0
while N >=0:

    if N <= B:
        print(N+r)
        break
        
    elif N >B and N<= A+B:
        print(B+r)
        break
        
    else:
        N = N -(A+B)
        r +=B

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
import sys
a,b=map(int, input().split())

x = math.floor(a/0.08)
#1の位が1-9
y = math.floor(b/0.1)
if (x + 1) * 0.08 == a:
    xx = x + 2
else:
    xx = x + 1

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
s = ['b'] * a + ['r'] * b
str = []
while len(str) < n:
  str.extend(s)
del str[n:-1]
print(str.count('b'))

Submission status: Runtime Error

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

N=int(li[0])
A=int(li[1])
B=int(li[2])

def firstcheck():
    sum=A+B
    count=A
    if(A>=N or A+B>=N):
        return A

    while True:
        print('he2')
        print(sum)
        if(i%2==0):
            sum+=A
            print("sumhere")
            print("cheksum"+str(sum))
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
                continue
        else:
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Runtime Error

Solution code:
N,B,R=map(int,input().split())
if B==0:
  print(0)
  exit()
ans=B×N//(R+B)
if N%(R+B)>=B:
  print(ans+B)
else:
  print(ans+B-N%(R+B))

Submission status: Runtime Error

Solution code:

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

list_ab = []
list_b = ['b']*A
list_ab.append(list_b)
list_a = ['a']*B
list_ab.append(list_a)

str.append(list_ab*(N//(A+B)+1))


import itertools
str = list(itertools.chain.from_iterable(str))
str = list(itertools.chain.from_iterable(str))

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
row = []
for _ in range(N):
    row += [1]*A
    row += [0]*B

print( sum(row[:N]) )

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

  x = n // (b + r)

  if n % (b + r) > b:
      print(x * b + b)

  else:
      print((x * b) + (n % (b + r)))
      

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if A==0:
    print(0)
else if B==0:
    print(N)
else:
    co=0
    i=0
    while (A+B)*i<N:
        co=co+A
        i+=1
    print(co)

Submission status: Runtime Error

Solution code:
print((n/(a+b))+min(b,n%(a+b)))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
strb="b"*A
stra="a"*B
str=strb+stra
bcount=0
lenstr=len(str)
if N <= lenstr:
    bcount=str[0:N].count('b')
    print(bcount)
else:
    bcount=str.count('b')
    bcount=bcount*int(N/lenstr)
    if N%lenstr>0:
        tmp=str.count("b",0,int(N%lenstr))
        bcount=bcount+tmp
    print(bcount)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
C=A+B
if (0<C<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue=("a"*A+"b"*B)*(10**100)
    number=queue.count("a",0,N)
    print(number)

Submission status: Runtime Error

Solution code:

def main():
    n, a, b = map(int, input().split())
    
    ball = [0]*n
    count = 0
    flag = True
    if a == 0 :
        print(0)
        exit(0)

    while flag:
        while flag:
            ball[count]="b"
            count += 1
            if count == n:
                flag = False
            if count % a == 0:
                break
    
        while flag:
            ball[count]="r"
            count += 1
            if count == n:
                flag = False
            if count % (a + b) == 0:
                break
            
     

    print(ball.count("b"))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

N=int(li[0])
A=int(li[1])
B=int(li[2])

def firstcheck():
    sum=A+B
    count=A
    if(A>=N or A+B>=N):
        return A

    while True:
        print('he2')
        print(sum)
        if(i%2==0):
            sum+=A
            print("sumhere")
            print("cheksum"+str(sum))
            if(sum>=N):
                count+=(A-(sum-N))
                return count
            else:
                count+=A
        else:
            sum+=B
            if(sum>=N):
                return count


res=firstcheck()
print(res)

Submission status: Runtime Error

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

if A+B != 0:
  tmp = math.floor(N /(A+B))
else:
  tmp = 0
  
x = ('b'*A + 'a'*B)*tmp + 'b'*(N-(A+B)*tmp)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=list(map(int,input().split()))
list=[]
liste=""
a=n[1]
b=n[2]
A="A"*a
B="B"*b
if n[1]==0:
    print(0)
elif n[2]==0:
    print(8)
else:
    list.append(A)
    list.append(B)
    list.append(A)
    list.append(B)
    list.append(A)
    list.append(B)
    list.append(A)
    list.append(B)
    for x in list:
        liste+=x
    listo=liste[0:8]
    print(listo)
    print(listo.count("A"))

Submission status: Runtime Error

Solution code:

n,a,b=map(int,input().split())
l=list('b'*a+'r'*b)

if n-(a+b)>0:
    s=n-(a+b)+1
else:
    s=1

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

Submission status: Runtime Error

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


x = N // (A + B)
y = N % (A + B)
length = 'b' * A + 'a' * B

z = length[:y].count('b')
ans = x * A + z


print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
qaws = ""
c = 0
while(N > len(qaws)):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

Submission status: Runtime Error

Solution code:
def main(N: int , A: int , B: int):
    r = "b" * A
    r += "r" * B
    for i in range(10*100):
        r += r
        if N <= len(r):
            sub = r[:N]
            return sub.count("b")

if __name__ == "__main__":
    s = input().split()
    N = int(s[0])
    A = int(s[1])
    B = int(s[2])
    print(main(N, A, B))

Submission status: Runtime Error

Solution code:
def main():
    N, A, B = map(int, input().split())
    ball = 'b'*A + 'r'*B
    l = ""
    for i in range(N):
        l += ball
        if len(l) > N:
            break

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

Submission status: Runtime Error

Solution code:

def main():
    n, a, b = map(int, input().split())
    
    ball = [0]*n
    count = 0
    flag = True
    if a == 0 :
        print(0)
        exit()

    while flag:
        while flag:
            ball[count]="b"
            count += 1
            if count == n:
                flag = False
            if count % a == 0:
                break
    
        while flag:
            ball[count]="r"
            count += 1
            if count == n:
                flag = False
            if count % (a + b) == 0:
                break
            
     

    print(ball.count("b"))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys

read = sys.stdin.readline
T = read()
a, b, c = map(int, T.split())

if b == 0:
    print(0)
else if b == 8:
    print(8)
else:
    print(a-c)

Submission status: Runtime Error

Solution code:
ball = lst[0]
blue = lst[1]
red = lst[2]
blue_red = int(ball / (red + blue)) + 1

blue_str = ''
for i in range(blue): blue_str += 'b'
red_str = ''
for i in range(red): red_str += 'r'

mojiretu = ''
for i in range(blue_red): mojiretu += (blue_str + red_str)
print(mojiretu[:ball].count('b'))

Submission status: Runtime Error

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

if A+B != 0:
  tmp = math.floor(N /(A+B))
else:
  tmp = 0
  
x = ('b'*A + 'a'*B)*tmp + 'b'*A

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

Submission status: Runtime Error

Solution code:
a=0
for i in range(10^100):
  N, A, B=list(map(int, input().split()))
  if A+B==N:
    a=a+A
  else:
    a=a+A+N-(A+B)
  
    
print(a)

Submission status: Runtime Error

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

if a == 0 and b == 0:
    print(0)
    exit()

count = n // (a+b)
mod = n % (a+b)


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

if n == a + b:
    print(a)
elif a == 0:
    print(0)
else:
    print(b + 1)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split(' '))
L = []
for _ in range(10000):
  L.extend(['a'] * A + ['b'] * B)
  if len(L) >= N:
    break
print(L[:N].count('a'))

Submission status: Runtime Error

Solution code:

N, A, B = map(int, input().split())
s = 'b'*A+'r'*B + 'b'*(N-(A+B))
count = 0
for i in range(0,N):
    if s[i] == 'b':
        count +=1

print(count)

Submission status: Runtime Error

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

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

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 = ""
  str_length = 0
  count = 0
  for i in range(v):
    s = ""
    if a > 0:
      s += "b" * a
    if b > 0:
      s += "r" * b
    
    str_length += len(s)
    
    if str_length >= n:
      target_length = n - (a+b) * i
      res = s[:target_length]
      count += res.count("b")
      print(count)
      break

    count += s.count("b")

Submission status: Runtime Error

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

n = 1
result_str = ""
while n <= N:
    result_str += "b"*a
    n += a
    result_str += "r"*b
    n+= b
    
print(result_str[:8].count("b"))

Submission status: Runtime Error

Solution code:
N, a, b = map(int, input().split())
x = (N//(a+b)) *a
l='b'*a
l+='r'*b
y = l[0:int(N%(a+b))]
print(x + y.count('b'))

Submission status: Runtime Error

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

ans = []
for i in range(1,10**18+1):
    ans.append("b"*A)
    ans.append("r"*B)
    if (A+B) * i >= N:
        break
    
ans = "".join(ans)
print(ans[:N].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
x = n // (a+b)
y = m - (a+b)*x
if a == 0:
  print(0)
elif y < a + 1:
  print (x * a + y)
else:
  print (x*a + a)

Submission status: Runtime Error

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

row = ""

if N[1] == 0:
    print(0)
else:
    remain = N[0] - N[1] - N[2]
    row += "b"*N[1]+"a"*N[2]+"b"*remain
    print(row.count("b"))

Submission status: Runtime Error

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

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

list = ('b' *A)* num
list += 'b' * mod if A > mod else  'b' * A
print(list.count('b'))

Submission status: Runtime Error

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

all = a + b

# a = 0
if a == 0:
    print(0)
    exit(0)

if N <= a:
    print(N)
    exit(0)

# a > 0
c = round(N / all)
d = N % all

roundCnt = a * c

if d != 0:
    if d <= a :
        amariCnt = d
    else:
        amariCnt = a

print(roundCnt + amariCnt)


#a = 0 print 0
#a > 0
# N <= a print N
# N > a
#  N/(a+b)=c     が割り切れる  a * c
#  N/(a+b)=c...d が余りが出る  a * c
#    d <= a のとき a * c + d
#    d >  a のとき a * c + a
#

Submission status: Runtime Error

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

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws[:N].count("B"))

Submission status: Runtime Error

Solution code:
N,A,B=input().split()
N=int(N)
A=int(A)
B=int(B)
C=A+B
if (0<C<=10**18)and(0<N<=10**18)and(A>=0)and(B>=0):
    queue=("a"*A+"b"*B)*(10**18)
    number=queue.count("a",0,N)
    print(number)

Submission status: Runtime Error

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

row = ""

if N[1] == 0:
    print(0)
else:
    remain = N[0] - N[1] - N[2]
    row += "b"*N[1]+"a"*N[2]+"b"*remain

print(row.count("b"))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

balls = "b"*blue + "r"*red

x = 0
if balls != "":
    x = n // len(balls) + 1

row = balls*x

print(row[:n].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 = ""
  str_length = 0
  count = 0
  for i in range(v):
    s = ""
    if a > 0:
      s += "b" * a
    if b > 0:
      s += "r" * b
    
    str_length += len(s)
    
    if str_length > n:
      target_length = n - (a+b) * i
      res = s[:target_length]
      count += res.count("b")
      print(count)
      break

    count += s.count("b")

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x = n - a
y = x % b
print(a + y)

Submission status: Runtime Error

Solution code:
line = input().split(" ")

N, A, B = int(line[0]), int(line[1]), int(line[2])

buff = []
for i in range(int(N/(A+B))+1):
    buff.extend([1]*A)
    buff.extend([0]*B)

print(sum(buff[:N]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
ball_list = []

for i in range(A):
    ball_list.append('b')
for j in range(B):
    ball_list.append('r')
    
ball_list_unit = ball_list
while len(ball_list) < N+1:
    ball_list.extend(ball_list_unit)
ball_list[:N].count('b')

Submission status: Runtime Error

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

BLUE = "b"
RED = "r"


balls = ""
while True:
    if len(balls) >= N:
        break
    balls += BLUE*A
    balls += RED*B

print(len([ball for ball in list(balls)[0:N] if ball == BLUE]))

Submission status: Runtime Error

Solution code:
import math
A,B = map(int,input().split())
a = A / 0.08
b = B / 0.1
if math.floor(a * 0.1) == B:
    ans = int(a)
elif math.floor(b * 0.08) == A:
    ans = int(b)
else:
    print(-1)
    exit()
if (math.floor((ans-1)*0.08) == A) and (math.floor((ans-1)*0.1) == B):
    ans = ans - 1
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
if(amari - len(blue) < 0):
    ans = 0
if(amari - len(blue) == 0):
    ans = len(blue)
else:
    ans = len(blue) - amari
print(ans)

Submission status: Runtime Error

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

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

if x>A:
    x=A

print(b*A+x)

Submission status: Runtime Error

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

if A+B != 0:
  tmp = math.ceil(N /(A+B))
else:
  tmp = 0
x = ('b'*A + 'a'*B)*tmp

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

Submission status: Runtime Error

Solution code:
def main():
	n,a,b = map(int,input().split())
	ans = 0
	if a == 0:
		print(0)
	elif b == 0:
		i = 0
		while a*i <= n:
			i += 1
			ans += a
	else:
		repeat = n // (a+b)
		for i in range(1,repeat+2):
			if (a + b)*i <= n:
				ans += a
			else:
				amari = n % ((a+b) *(i-1))
				if amari <= a:
					ans += amari
				else:
					ans += a

	print(ans)
	

if __name__ == '__main__':
	main()

Submission status: Runtime Error

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

c = N // (A + B)
mod = N % (A + B)
# print(c,mod)

if mod > A:
    mod_A = mod // A 
    # print(mod_A)
    print(c * A + mod_A * A)
else:
    print(c * A + mod)

Submission status: Runtime Error

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

s = ''
blue = 'b' * a
red = 'r' * b

while (len(s) <= n):
    s += blue
    s += red

tmp = s[0:n]

print(tmp.count('b'))

Submission status: Runtime Error

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

balls = "b"*blue + "r"*red
x = n // len(balls) + 1

row = balls*x

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

Submission status: Runtime Error

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

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

if x>A:
    x=A

    print(b*A+x)

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=count+1
print(count)

Submission status: Runtime Error

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


def check(N,A,B):
    if A == 0:
        return 0
    text = ("b"*A)+("r"*B)
    text =  (text*((A+B)*N))
    return text[:N].count("b")
    
print(check(N,A,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 >= N):
        break

    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,B,R = map(int,input().split())
k = N % (B + R)
k2 = int(N / (B + R))
s = ("b"*B + "r"*R)
s1 = s[:k]
if k <= B:
	print(k2*(B) + k)
else:
	print(k2*(B) + B)

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)
print(allball[:N].count("b"))

Submission status: Runtime Error

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

for i in range((n // (a + b)) + 1):
    ans += a * 'b' + b * 'r'

print(ans[: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(round(N/(A+B))+1):
    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())
str = []
for j in range(N//(A+B)+1):
    list_b = ['b']*A
    str.append(list_b)
    list_a = ['a']*B
    str.append(list_a)

    if len(str)>N:
        break


import itertools
str = list(itertools.chain.from_iterable(str))

count = 0
for k in range(N):
    if str[k] == 'b':
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
from collections import Counter

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

C = N // (A + B) + (0 if N % (A + B) == 0 else 1)

L = []
Co = Counter()
for n in range(C):
    L += ['b'] * A + ['r'] * B

Co = Counter(L[:N])

print(Co['b'])

Submission status: Runtime Error

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

if a == 0 and b == 0:
    print(0)
    exit()

count = n // (a+b)
mod = n % (a+b)
#print(count, mod)

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:
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(N==0):
  print(0)
elif(A==0):
  print(0)
elif(B==0):
  print(N)
elif(e==0):
  print(0)
else:
  num=int(N/e)+2
  b=d*num
  c=b[0:N]
  print(c.count('b'))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, raw_input().split()) 
if A == 0:
  print(0)
else:
  print(N-B)

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)
S = a*count
print(S[:N].count('b'))

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 A==B==0:
    print(0)
elif A==0:
    print(0)
else:

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

tmp = math.ceil(N /(A+B))
x = ('b'*A + 'a'*B)*tmp

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

Submission status: Runtime Error

Solution code:
n,a,b = list(map(int,input().split()))
kurikaeshi = n // (a + b)
amari = n - (kurikaeshi * (a+b))
ball_list = []
ans = 0
blue = 'b' * a
red = 'r' * b
if(amari - len(blue) < 0):
    ans = 0
else:
    ans = len(blue) - amari
print(ans)

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 = []

f = int(n/(blue + red)) + 1

for i in range(0,f):
  arr.extend(br)
  arr.extend(rr)
  
c = arr[0:n]
print(c)
print(c.count('b'))

Submission status: Runtime Error

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

c = N // (A + B)
mod = N % (A + B)
# print(c,mod)

mod_A = mod // A 
# print(mod_A)
print(c * A + mod_A * A)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
strb="b"*A
stra="a"*B
str=strb+stra
bcount=0
if N <= len(str):
    bcount=str[0:N].count('b')
    print(bcount)
else:
    bcount=str[0:len(str)].count('b')
    bcount=bcount*int(N/len(str))
    tmp=str[0:N%len(str)].count("b")
    bcount=bcount+tmp
    print(bcount)

Submission status: Runtime Error

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

rep = "b" * A + "r" * B
C = N // (A + B)
D = N % (A + B)

ans = A * C + rep[:D].count("b")
print(ans)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
goal = ''
if A == 0:
  print(0)
if B == 0 and A != 0:
  print(N)
if A != 0:
  howmany = (N//min(A,B)) + 1
  for i in range(howmany):
    goal += A*"b"
    goal += B*"r"
  print(goal[0:N].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 > N):
        break

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

qaws = ""
c = 0
while(N >= c):
  qaws = qaws + "B"*A
  qaws = qaws + "R"*B
  c += 1
print(qaws)
print(qaws[:N].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
if(e==0):
  print(0)
else:
  num=int(N/e)+2
  b=d*num
  c=b[0:N]
  print(c.count('b'))