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 math
def myAnswer(N:int, A:int, B:int) -> int:
   counter = math.ceil(N / (A + B))
   string = ("b"*A + "r"*B)*counter
   return list(string)[:N ].count("b")

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))

if __name__ == '__main__':
   main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = str(input())
b = str(input())

L =[(a+b)*n]

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

Submission status: Runtime Error

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

print(n//(a+b)*a+mi,min(a,n%(a+b))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
    # N: number of balls to take, A: blue, B: red
    N, A, B = list(map(int, input().split()))

    if N == 0:
        print(0)

    if A + B < N:
        # want to know how much A + B blocks can we place such that A + B < N (i.e. solve x(A+B) < N)
        blocks = int(N/(A+B))
        # for each block, there are A blue balls, plus potentially some reamining slots to fill the remaining space of N
        remaining_slots = N % (A+B)
        if A <= remaining_slots:
            # if it can fit A, place A more balls in the row
            print(blocks*A + A) 
        else:
            print(blocks*A + remaining_slots)
    else:
        if A + B == N:
            print(A)
        else:
            print(A-N)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

ball_n = ball[:N]
print(ball_n.count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())
t=''
while len(t)<n:
  t+='b'*a+'r'*b
t=t[::-1]
t=list(t)
g=0
for i in range(n):
  f=t.pop()
  if f=='b':
    g+=1
print(g)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

line =''

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,a,b = map(int,input().split())
  cnt = 0
  new = ""
  while True:
    if cnt + a <= n:
      cnt += a
      new += 'b' * a
    else:
      #print(cnt)
      a = n-cnt
      cnt += n-cnt
      #print(n-cnt)
      new += 'b' * (a)
      break
    if cnt + b <= n:
      cnt += b
      new += 'r'*b
    else:
      a = n-cnt
      cnt += n-cnt
      new += 'r' * (a)
      break
  #print(new)
  print(new.count('b'))
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  n,a,b = map(int,input().split())
  cnt = 0
  new = ""
  while True:
    if cnt + a <= n:
      cnt += a
      new += 'b' * a
    else:
      #print(cnt)
      a = n-cnt
      cnt += n-cnt
      #print(n-cnt)
      new += 'b' * (a)
      break
    if cnt + b <= n:
      cnt += b
      new += 'r'*b
    else:
      a = n-cnt
      cnt += n-cnt
      new += 'r' * (a)
      break
  print(new)
  print(new.count('b'))
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A, B; cin >> N >> A >> B;
  
  cout << ((N / (A + B)) * A + min(A, (N % (A + B)))); 
}

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
if a==0:
    print(0)
elif len("b"*a+"r"*b)==n:
    print(a)
elif len("b"*a+"r"*b)<n:
    print((n-len("b"*a+"r"*b))+a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
s = "b" * a
r = "r" * b
ans = ""
for i in range(n):
    ans += s
    ans += r
    if len(ans) >= n:
        break
print(ans[:n].count("b"))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
ans = ""
s = "b" * a
t = "r" * b
while(True):
    if len(ans) <= n:
        ans += s
        if len(ans) <= n:
            ans += t
        else:
            print(ans[:n].count("b"))
            break
    else:
        print(ans.count("b"))
        break

Submission status: Runtime Error

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if a == 0:
    res = 0
if n_mod_ab // a > 0:
    res = n_mod_ab // a * a
else:
    res = n_mod_ab
print(n_div_ab * a + res)

Submission status: Runtime Error

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

n_div_ab = n // (a+b)
n_mod_ab = n % (a+b)
if n_mod_ab // a > 0:
    res = n_mod_ab // a * a
else:
    res = n_mod_ab
print(n_div_ab * a + res)

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)
s = s[:n]
print(s.count('b'))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
s = ''
length = len(s)
while len(s)<n:
  s += 'b'*a
  s += 'r'*b
  length = len(s)
print(s)
print(s.count('b'))

Submission status: Runtime Error

Solution code:
n,a.b = map(int,input().split())
s = ''
length = len(s)
while len(s)<n:
  for i in range(a):
    s += 'b'
  for j in range(b):
    s += 'r'
  length = len(s)
#print(s)
print(s.count('b'))

Submission status: Runtime Error

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

if N >= AB:
    iters, div = divmod(N, (A +B))
    print((A*iters + div))
else:
    print(A)

Submission status: Runtime Error

Solution code:
n, b, r = map(int, input().split())
# inputText1 = "8 3 4"
inputText1List = inputText1.split()
# n = int(inputText1List[0])
# b = int(inputText1List[1])
# r = int(inputText1List[2])
if b == 0:
    print(b)
else:
    # i = (count // (b + r)) + 1 # 最大繰り返し数
    baseTextCount = b + r # 7
    i = n // baseTextCount
    mod = n % baseTextCount
    # print(i * b) # あまりを除いた青のボール数
    if mod < b:
        print(i * b + mod)
    else:
        print(i * b + b)

Submission status: Runtime Error

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

List=["b"]*int(a)+["a"]*int(b)

List *= 10
c=0


for i in range(int(N)+1):
    if List[i]=='b':
        c += 1
        
print(str(c))

Submission status: Runtime Error

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

List=["a"]*int(a)+["b"]*int(b)

List *= 10
c=0


for i in range(int(N)+1):
    if List[i]=='b':
        c += 1
        
print(str(c))

Submission status: Runtime Error

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

List=["a"]*int(a)+["b"]*int(b)
print(List)
List *= 10
c=0
print(int(N))
print(List)

for i in range(int(N)+1):
    if List[i]=='b':
        c += 1
        
print(str(c))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
if n == (a + b):
    print(a)
else:
    q, mod = divmod(n, (a + b))
    if mod > a:
    print(a * q + a)
    else:
        print(a * q + mod)

Submission status: Runtime Error

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

s = 'b'*a[1]
s = s + 'r'*a[2]
   
print(s.count('b'))

Submission status: Runtime Error

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

for i in range(a[0]):
  s = 'b'*a[1]
  s = s + 'r'*a[2]
   
print(s.count('b'))

Submission status: Runtime Error

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

sum_num = a + b
times = n // sum_num
amari = n % sum_num
if amari >= a:
    print(times * a + amari)
elif:
    print(times * a + a)

Submission status: Runtime Error

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

C = N // (A+B)
D = N % (A+B)

if A > D:
    print(A*C + D)
else:
    print(A*C + A)

Submission status: Runtime Error

Solution code:
L = list(map(int,input().split()))
q = L[0]//(L[1]+L[2])
mod = L[0]%(L[1]+L[2])
if mod > L[1]:
    print(q*L[1]+L[1])
else:
    print(q*L[1]+mod%L[1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

bu = ['b']*a
re = ['r']*b

for i in range(n):
  li.extend(bu)
  li.extend(re)
  
print(li[:n].count('b'))

Submission status: Runtime Error

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

if (A+B)==0:
  print(0)
  exit()

n=N//(A+B)

line=''
for i in range(n):
  line+='b'*A
  line+='r'*B

remainder=N%(A+B)
if remainder<=A:
  line+='b'*remainder
else:
  line+='b'*A
  line+='r'*(remainder-A)

print(line.count('b'))

Submission status: Runtime Error

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

line=''
for i in range(n):
  line+='b'*A
  line+='r'*B

remainder=N%(A+B)
if remainder<=A:
  line+='b'*remainder
else:
  line+='b'*A
  line+='r'*(remainder-A)

print(line.count('b'))

Submission status: Runtime Error

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

test_1 = 'b'*A + 'r'*B
test_2 = test_1 * N 
test_3 = test_2[:N]

summ = 0
for i in test_3:
    if i == 'b':
        summ += 1
    else:
        pass
print(summ)

Submission status: Runtime Error

Solution code:
x=n//(a+b)
if (a+b)*x<=a:
  t=n-x*(a+b)
else:
  t=a
print(a*x+t)

Submission status: Runtime Error

Solution code:
n=input()
a=input()
b=input()
t=0
i=0
while t<=n:
    if t+a>n:
        i+=n-t
        break
    i+=a
    t+=a
    t+=b
print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
i=0
a=input()
b=input()
c=0
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)

Submission status: Runtime Error

Solution code:
A,B=[int(s) for s in input().split(" ")]
N1list=[]
N2list=[]

for i in range(0,10,1):
    N1list.append((A+(i/10))/0.08)   
    N2list.append((B+(i/10))/0.1)

N3=-2
N1list.sort(reverse=True)
N2list.sort(reverse=True)

if N1list[9]<N2list[0]:
    for i in range(10):
        N=N1list[i]
        if N==int(N):
            for j in range(10):
                if N==N2list[j]:
                    N3=N
                    break
        else:
            N4=-1
else:
    N4=-1
            
print(int(N3) if N4<N3 else N4)

Submission status: Runtime Error

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

count="b"*a
count+="r"*b

if len(count)==n:
  print(count.count("b"))
elif a==0:
  print(0)
else:
  n-=len(count)
  if n<=a:
    count+="b"*n
    print(count.count("b"))
  else:
    while n>0:
      if n==a+b:
        count+="b"*a
        count+="r"*b
        print(count.count("b"))
      elif n<=a+b:
        count+="b"*n
        print(count.count("b"))
      else:
        count+="b"*a
        count+="r"*b
        n-=a+b

Submission status: Runtime Error

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

count="b"*a
count+="r"*b

if len(count)==n:
  print(count.count("b"))
else:
  n-=len(count)
  if n<=a:
    count+="b"*n
    print(count.count("b"))
  else:
    for i in range(n):
      if i+1<=a:
        count+="b"
      if i+1==a+b:
        n-=a+b
    print(count.count("b"))

Submission status: Runtime Error

Solution code:
a,b,n = input().split()
set = n//(a+b)
rem = n % (a+b)
if rem <= a:
	return set * (a+b) + a
else:
	return set * (a+b) + rem

Submission status: Runtime Error

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

s = ""
while True:
    s += "b" * a +  "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())
if A == :
  print(0)
else:
  print(N) if A > N else print(A if N < (A + B) else N - B)

Submission status: Runtime Error

Solution code:
def LI(): return list(map(int, sys.stdin.readline().split()))
a = LI()
sum = a[0]
b = 0
while sum > 0:
  if sum - a[1] >= 0:
    b += a[1]
    sum -= a[1]
  else:
    b += sum
    sum = 0
  sum -= a[2]
print(b)

Submission status: Runtime Error

Solution code:
def LI(): return list(map(int, sys.stdin.readline().split()))
a = LI()
sum = a[0]
b = 0
while sum > 0:
  if sum - a[1] >= 0:
    b += a[1]
    sum -= a[1]
  else:
    b += sum
    sum = 0
  sum -= a[2]

Submission status: Runtime Error

Solution code:
def LI(): return list(map(int, sys.stdin.readline().split()))
a = LI()
sum = a[0]
b = 0
while sum >= 0:
  if sum - a[1] >= 0:
    b += a[1]
    sum -= a[1]
  else:
    b += sum
    sum = 0
  sum -= a[2]
print(b)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split(" "))
S = ""
while(True):
    S+="{}".format("b"*A)
    S+="{}".format("r"*B)
    if len(S) >= N:
        break
st = S[:N]
r = st.count("b")
print(r)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

s_blue= "b"*aa[1]
s_red = "r"*aa[2]

string_tot = (s_blue + s_red)*N#m.ceil(N/(len(s_blue)+len(s_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

s_blue= "b"*aa[1]
s_red = "r"*aa[2]

string_tot = (s_blue + s_red)*33#m.ceil(N/(len(s_blue)+len(s_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

s_blue= "b"*aa[1]
s_red = "r"*aa[2]

string_tot = (s_blue + s_red)*int(N/(len(s_blue)+len(s_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

s_blue= "b"*aa[1]
s_red = "r"*aa[2]

string_tot = (s_blue + s_red)*m.ceil(N/(len(s_blue)+len(s_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

string_blue= "b"*aa[1]
string_red = "r"*aa[2]

string_tot = (string_blue + string_red)*\
m.ceil(N/(len(string_blue)+len(string_red)))


#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

string_blue= "b"*aa[1]
string_red = "r"*aa[2]
string_tot = (string_blue + string_red)*m.ceil(N/(len(string_blue)+len(string_red)))

print("16")
"""
#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)
"""

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np
import math as m

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        

    
i = input()
aa = np.array(str.split(i)).astype(int)
#print(aa)
N = aa[0]

char_blue= "b"
char_red = "r"

string_blue= "b"*aa[1]
string_red = "r"*aa[2]
string_tot = (string_blue + string_red)*m.ceil(N/(len(string_blue)+len(string_red)))

#print(string_tot)
#print(string_tot[:N])

count_blue = 0

for i in string_tot[:N] :
    if i == 'b':
        count_blue += 1
    
print(count_blue)

Submission status: Runtime Error

Solution code:
from math import floor

N = int(input())
A = int(input())
B = int(input())

steps = floor(N / (A + B))
cap = steps * (A + B)
blue_balls = steps * A + min([N - cap, A])
print(blue_balls)

Submission status: Runtime Error

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

import sys

def prob_b(n, a, b):
    n, a, b = int(n), int(a), int(b)
    x = int(n / (a + b)) * a
    y = n % (a + b)
    print(x+y)


if __name__ == '__main__':
    args = sys.argv
    n = args[1]
    a = args[2]
    b = args[3]
    prob_b(n,a,b)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

tmp1,tmp2=divmod(N,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
eles:
  blue=blue+tmp2
  
print("blue")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
F = A + B
C = N // F
D = N % C
E = A * C
if A == 0:
  print(0)
elif B == 0:
  if A > N:
    print(A - N)
  else:
    print(N)
elif C == 0:
  if N < A:
    print(N)
  else:
    print(A)
else:
  if D < A:
    print(E + D)
  else:
    print(E + A)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
F = A + B
C = N // F
D = N % C
E = A * C
if A == 0:
  print(0)
elif B == 0:
  print(A)
elif C == 0:
  if N < A:
    print(N)
  else:
    print(A)
else:
  if D < A:
    print(E + D)
  else:
    print(E + A)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
t = 'r' * a + 'b' * b
t=(t*n)[0:n]
print(t.count('r'))

Submission status: Runtime Error

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

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

    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())
color = ''
while True:
    if len(color) < N:
        color = color + 'b' * A + 'r' * B
    else:
        break
num = color[:N].count('b')
print(num)

Submission status: Runtime Error

Solution code:
s = input()
s = s.split(" ")
n = int(s[0])
b = int(s[1])
a = int(s[2])

num = (n //(a+b))*b +(n%(a+b))%a
print(num)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input(),split())
ans=N//(A+B)*A
r=N%(A+B)
ans+=min(r,A)

print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input(),split())
ans=N/(A+B)
r=N%(A+B)
ans+=min(r,A)

print(ans)

Submission status: Runtime Error

Solution code:
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

Times = N // (A + B)
rest = N - Times * (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)

Submission status: Runtime Error

Solution code:
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

Times = N // (A + B)
rest = N % (A + B)

if rest < A:
        ans = A * Times + rest
else:
        ans = A * Times + A

print(ans)

Submission status: Runtime Error

Solution code:
a=list(input())

IN=[int(x) for x in a if x != " "]
N=IN[0]
A=IN[1]
B=IN[2]

ALL=A+B
times=N//ALL
rest=N%ALL

if A < rest:
        ans=A*times+A
else:
        ans=A*times+rest

print(ans)

Submission status: Runtime Error

Solution code:
n,b,r=list(map(int,input().split()))
l=[]
while True:
    l.extend(list("b"*b))
    l.extend(list("r"*r))
    if len(l) > n:
        break

for i in range(len(l)-n):
    l.pop(-1)
print(l.count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=(int(x) for x in input().split())
s0=a+b
s1=n//s0
s2=n%s0
if s2>a:
    print s1*a+a
else:
    print s1*a+s2

Submission status: Runtime Error

Solution code:
n = input()
a = input()
b = input()
s0=a+b
s1=n/s0
s2=n%s0
if s2>a:
    print s1*a+a
else:
    print s1*a+s2

Submission status: Runtime Error

Solution code:
import numpy as np

info = np.array(input().split(" "), dtype="int64")
o = info[1] + info[2]
if o == 0:
    print(0)
else:
    q, mod = divmod(info[0], o)
    if mod > info[1]:
        print((q+1)* info[1])
    else:
        print(q*info[1] + mod)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B=map(int(),input().split())
K=A*int(N/(A+B))
amari=N%(A+B)
i=1
while ((amari-i)>0):
  i=i+1
K=K+i
print(K)

Submission status: Runtime Error

Solution code:
N,A,B=map(int(),input().split())
K=A*int(N/(A+B))
amari=N%(A+B)
i=1
while ((amari-i)>0):
  i=i+1
K=K+i

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
List= []
List.append(("a"*A)+("b"*B))
S = str(List)
print(S.count("a")*(N//(A+B))+S[0:N%(A+B)+2].count("a"))

Submission status: Runtime Error

Solution code:
N = int(input())
A = int(input())
B = int(input())
List= []
List.append(("a"*A)+("b"*B))
S = str(List)
print(S)
print(S.count("a")*(N//(A+B))+S[0:N%(A+B)+2].count("a"))

Submission status: Runtime Error

Solution code:
A = int(input())
B = int(input())
N = int(input())
List= []
List.append(("a"*A)+("b"*B))
S = str(List)
print(S.count("a")*(N//(A+B))+S[:N%(A+B)-1].count("a"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
ikd=[]
ikd2=[0]*n
count=0
if n>(a+b):
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
  for k in range(0,n-(a+b)*(n//(a+b))):
    ikd2[k]=ikd[k]
  count=a*(n//(a+b))+ikd2.count("b")
else:
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
  for k in range(0,n):
    ikd2[k]=ikd[k]
  count=ikd2.count("b")
print(count)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
ikd=[]
ikd2=[0]*n
count=0
if n>(a+b):
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
  for k in range(0,n-(a+b)*(n//(a+b))):
    ikd2[k]=ikd[k]
  count=a*(n//(a+b))+ikd2.count("b")
else:
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
  for k in range(0,n):
    ikd2[k]=ikd[k]
  count=ikd2.count("b")
print(count)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N A B = tuple(input().split())
print((N // (A + B)) * A + N % (A + B))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B= map(int, input().split())
re += N//(A+B) 
re += min(N%(A+B),A)
print(re)

Submission status: Runtime Error

Solution code:
N, A, B= map(int, input().split())
a = [1]*A + [0]*B
li = []
while len(li) < N:
  li.extend(a)
li_N = li[0:N-1]
print(sum(li_N))

Submission status: Runtime Error

Solution code:
N, A, B= map(int, input().split())
a = [1]*A + [0]*B
li = []
while len(li) < N:
  li.extend(a)
li_N = li[:N-1]
print(sum(li_N))

Submission status: Runtime Error

Solution code:
n,a,b=input().split()
n=int(n)
a=int(a)
b=int(b)
red=0
blue=0
rcount=0
count=0
for i in range(n):
  if rcount<a:
    rcount+=1
  if rcount==a:
    bcount+=1
    count+=1
    if bcount==b:
      rcount=0
      bcount=0

print(count)

Submission status: Runtime Error

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

for k in range(0,1000):
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
ikd2=[0]*n
for l in range(0,n):
  ikd2[l]=ikd[l]

g=ikd2.count("b")
print(g)

Submission status: Runtime Error

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

for k in range(0,30):
  for i in range(0,a):
    ikd.append("b")
  for j in range(0,b):
    ikd.append("r")
ikd2=[0]*n
for l in range(0,n):
  ikd2[l]=ikd[l]

g=ikd2.count("b")
print(g)

Submission status: Runtime Error

Solution code:
x, b, r = map(int, input().split())
count=0
flag_b=0
flag_r=0
while:
  count+=b if count!=x else break
  flag_b+=1
  count+=r if count!=x else break
  flag_r+=1
  
  
print(x-(flag_r*r))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding:utf-8


from math import ceil

import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
numGroup = floor(N / (A + B))
numExtendBall = N % (A + B)
if numExtendBall >= A:
    numExtendBlueBall = A
else:
    numExtendBlueBall = numExtendBall
print(numGroup * A + numExtendBlueBall)