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:
S = input()
N = int(S[0])
A = int(S[2])
B = int(S[4])
#print(A+B)
 
b_count = 0
for i in range(0, N):
  #print('i')
  #print(i)
  if i % (A+B) < A:
    #print(b_count)
    b_count = b_count + 1
print(b_count)

Submission status: Runtime Error

Solution code:
S = input()
N = int(S[0])
A = int(S[1])
B = int(S[2])
#print(A+B)
 
b_count = 0
for i in range(0, N):
  #print('i')
  #print(i)
  if i % (A+B) < A:
    #print(b_count)
    b_count = b_count + 1
print(b_count)

Submission status: Runtime Error

Solution code:
N = int(input())
A = int(input())
B = int(input())
#print(A+B)
 
b_count = 0
for i in range(0, N):
  #print('i')
  #print(i)
  if i % (A+B) < A:
    #print(b_count)
    b_count = b_count + 1
print(b_count)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
S = 0
for i in range(2*N):
  if i%2 == 0:
    S += A
  else:
    S += B:
  if S >= N:
    if i%2 == 0:
      ans = (i-1)/2*A + N - (i-1)/2*(A+B)
    else:
      ans = i/2 * A
    break
print(ans)

Submission status: Runtime Error

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

b_count = 0
for i in len(N):
  if i % (A+B) < A:
    b_count = b_count + 1
print(b_count)

Submission status: Runtime Error

Solution code:
info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info // group
b = info % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)

Submission status: Runtime Error

Solution code:
N,b,r = input().split()
if(b==0 and r == 0):
  print(0)
else :
  sets = N/(b+r)
  surplus = N%(b+r)
  Numbe_of_Blue = sets * b + b
  print(Numbe_of_Blue

Submission status: Runtime Error

Solution code:
N,b,r = input().split()
if(b==0 and r == 0):
  print(0)
else :
  set = N/(b+r)
  surplus = N%(b+r)
  Numbe_of_Blue = set * b + b
  print(Numbe_of_Blue)

Submission status: Runtime Error

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
if A == 0 and B == 0:
  print(0)
else:
  t1 = np.ones(A,dtype=np.int64)
  t2 = np.zeros(B,dtype=np.int64)
  t = np.hstack((t1, t2))

  L = len(t)

  if N == L:
    print(np.sum(t))
  elif N < L:
    print(np.sum(t[0:N]))
  elif N > L:
    Q = N // L
    R = N % L
    ANS = Q*(np.sum(t))+np.sum(t[0:R])
    print(ANS)

Submission status: Runtime Error

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
if A == 0 and B == 0:
  print(0)
else:
  t1 = np.ones(A,dtype=np.int16)
  t2 = np.zeros(B,dtype=np.int16)
  t = np.hstack((t1, t2))

  L = len(t)

  if N == L:
    print(np.sum(t))
  elif N < L:
    print(np.sum(t[0:N]))
  elif N > L:
    Q = N // L
    R = N % L
    ANS = Q*(np.sum(t))+np.sum(t[0:R])
    print(ANS)

Submission status: Runtime Error

Solution code:
import numpy as np

N, A, B = list(map(int,input().split()))
t1 = np.ones(A,dtype=np.int16)
t2 = np.zeros(B,dtype=np.int16)
t = np.hstack((t1, t2))

L = len(t)

if N == L:
  print(np.sum(t))
elif N < L:
  print(np.sum(t[0:N]))
elif N > L:
  Q = N // L
  R = N % L
  ANS = Q*(np.sum(t))+np.sum(t[0:R])
  print(ANS)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
if a>n:
  print(a)
ans = 0
else:
  temp = N//(a+b)
  ans = temp*a
  temp2 = N- temp
  if temp2 < a:
    print(ans+temp2)
  else:
    print(ans+a)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
2 ans = N // (A + B) * A
3 rem = N % (A + B)
4 ans += min(rem, A)
5 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:
a,b,c=input().split()

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

Submission status: Runtime Error

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

ans = "b"*a
count = len(ans)
switch = 0
while count < n:
    if switch == 0:
        count += b
        ans += "r"*b
        switch = 1
    else:
        count+= a
        ans += "b" *a
        switch = 0
print(ans[:n].count("b"))

Submission status: Runtime Error

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

b = "b"*A + "r"*B
print(b.count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

N, a, b = map(int, inp().split())
ball = ""
while len(ball) < N:
  ball += "b"*a
  ball += "r"*b
  
ans = ball[:N].count("b")
print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = input().split()
q, mod = divmod(N, A+B)

if mod > A:
  print((q+1)*A)
else :
  print(q*A+mod)

Submission status: Runtime Error

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

x=int(n/(a+b))
if x*(a+b)+a <= n:
	print(a*(x+1))
else:
	print(n-b*x)

Submission status: Runtime Error

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

rep = n // (a+b)
mod = n % (a+b)
ans = rep * b

if mod > a:
	ans+= a  
else:
    ans+= mod
print(ans)

Submission status: Runtime Error

Solution code:
a = int(input("A>"))
b = int(input("B>"))
n = int(input("N>"))

if a>0:
    if n-n//(a+b)*(a+b)>a:
        print(n//(a+b)*a+a)
    else:
        print(n//(a+b)*a+n-n//(a+b)*(a+b))
else:
    print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

total = int(N)
blue = int(A)
red = int(B)

string = ''

for num in range(10 * total):

    for num in range(blue):
        string += 'b'

    for num in range(red):
        string += 'r'

ball = string[:total]

print(ball.count('b'))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

int main(){
  int N,A,B,C;
  cin>>N>>A>>B;
  C=N/(A+B);
  if(N-C*(A+B)>A){
    cout<<C*(A+1)<<endl;
  }
  else{
    cout<<C*A+N-C*(A+B)<<endl;
  }    
}

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
 
 
def solve(N: int, A: int, B: int):
 
    # if A+B < N : N = A+B
    if N <= A : print(N)
    else : 
        k = N // (A+B)
        rem = N - (A+B)*k
        b_ = A - rem
        if  b_ >= 0: print(k*A+rem+1)
        else : print(k*A)
 
 
    return
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)
 
if __name__ ==

Submission status: Runtime Error

Solution code:
s = np.array(input().split()).astype(int)
# =============================================================================
# if s.find("A") >= 0 and s.find("B") >= 0:
#     print("Yes")
# else:
#     print("No")
# =============================================================================

A,B,N = s

print((N//(A+B))*A+np.array(N%(A+B),A).max())

Submission status: Runtime Error

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou*a+a if amari >= a　else shou*a+amari

print(ans)

Submission status: Runtime Error

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou * a + a if amari >= a　else shou*a+amari

print(ans)

Submission status: Runtime Error

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou * a + a if amari >= a　else ans = shou*a+amari

print(ans)

Submission status: Runtime Error

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

shou = n // (a+b)
amari = n % (a+b)

print(shou * a + a) if amari >= a　else print(shou*a+amari)

Submission status: Runtime Error

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

shou = n // (a+b)
amari = n % (a+b)

print(shou * a + a) if amari >= a

print(shou * a + amari) if amari < a

Submission status: Runtime Error

Solution code:
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    for i in range(int(data[0])):
        if i == cont:
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

print(int(np.count_nonzero(dataset == 1)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    print(cont, data)
    for i in range(int(data[0])):
        #print(i)
        if i == cont:
            print("px")
            dataset[cont:int(data[2]) + cont] = 2
            cont = i + int(data[2]) + int(data[1])

#print(dataset, data[1], int(np.count_nonzero(dataset == 1)))
print(int(np.count_nonzero(dataset == 1))

Submission status: Runtime Error

Solution code:
l = list(map(int,input().split()))
q, mod = divmod(l[0], (l[1]+l[2]))
qq, modd = divmod(mod, l[1])

if qq == 0 :
    ans = l[1] * q + modd
else:
    ans = l[1] * (q + qq)

print(ans)

Submission status: Runtime Error

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

S = N//(A+B)*A

S = S+(N%S,A)
print(S)

Submission status: Runtime Error

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

q, mod = divmod(N, AB)
qq, modd = divmod(mod, A)

if qq == 0 :
    ans = A * q + modd
else:
    ans = A * (q + qq)

print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
s=''
for i in range(10^100):
  s+="B"*a +"R"*b
print(s.count('B',0,n))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=map(int,input().split())
b=int(a[0]/(a[1]+a[2]))
c=a[0]-b*(a[1]+a[2])
if c>a[1]:
  print(b*a[1]+a[1])
else:
  print(b*a[1]+c)

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split()]
c = 0
while c <= n:
  s += [1 for _ in range(a)]
  s += [0 for _ in range(b)]
  c = len(s)
print(sum(s))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math

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

n = int(input())

s = math.floor(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:
import math

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

n = int(input())

s = math.floor(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:
#include<bits/stdc++.h>

using namespace std;

long long n, a, b;

int main(){
	cin >> n >> a >> b;
	cout << a*n/(a+b)+min(a, n%(a+b)) << endl;
}

Submission status: Runtime Error

Solution code:
x, y, z = map(int, input().split())
blist = ""
while len(blist) <= x:
    blist += "b"*y
    blist += "r"*z
blist = blist[:x]
num = blist.count("b")
print(num)

Submission status: Runtime Error

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

c = n // (a + b)
if c == 0:
    d = a + b
    assert False
else:
    d = n - (c * (a+b))

if d > a:
    ans = (c*a) + a
else:
    ans = (c*a) + d
    
print(ans)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
if  A==0:
    print(0)
elif N==A+B:
    print(A)
elif N<=A:
    print(N)
else N>A+B:
    print(N-B)

Submission status: Runtime Error

Solution code:
# C - Tax Increase
from math import floor


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


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


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
l=list(input())
N=int(l[0])
A=int(l[1])

B=int(l[2])
syou=N//(A+B)
amari=N%(A+B)
kotae=syou*A+amari
print(kotae)

Submission status: Runtime Error

Solution code:
l=list(input())
N=l[0]
A=l[1]
B=l[2]
syou=N//(A+B)
amari=N%(A+B)
kotae=syou*B+max(amari-A,0)
print(kotae)

Submission status: Runtime Error

Solution code:
a = input().split(" ")
n = int(a[0])
b = int(a[1])
r = int(a[2])
c = a // (b + r)
bb = c * b
d = a % (b + r)
if d >= b:
	bb += b
else:
	bb += d 
print(bb)

Submission status: Runtime Error

Solution code:
if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  ans = 0
  div = N //( A + B ) # A > 0
  ans = div * A
  ans += min( N % (A + B) , A)
  # mod = N % ( A + B )


  # if mod > A :
  #   ans += A
  # else :
  #   ans += mod
  
  print(ans)

Submission status: Runtime Error

Solution code:

// C++ program for implementation of Ford Fulkerson algorithm 
#include <iostream> 
#include <limits.h> 
#include <string.h> 
#include <queue> 
#include <set>
using namespace std; 

#include <stdio.h>

int main(int argc, char *argv[]) {
   long long int n=0,b=0,a=0;
   long long int tot=0;
   cin>>n>>b>>a;
   long long ans=n/(a+b)*b+min(b,n%(a+b));
  
  cout<<ans<<endl;
   return(0);
}

Submission status: Runtime Error

Solution code:
n,b,r = map(int, input().split())
s = n // (b+r)
a = n % (b+r)
ans = s * b
ans += min(a, b)
print({}.format(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)
 
ans = A * C + min(A, D)
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)

ans = A * C + min(A, D)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else: 
    if n%sum > a: 
        print ((n // sum)*a) + a

    else:
        res = ((n // sum)*a) + (n % sum)
        print(res)

Submission status: Runtime Error

Solution code:

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else:
    res = ((n // sum)*a) + (n % sum)
    
    if n%sum > a: 
        print( ((n // sum)*a) + a

    else:
        print(res)

Submission status: Runtime Error

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

ans = 0
ball = []

for i in range(N // (A + B)) :
    ball += list('b' * A + 'r' * B)

mod = N % (A + B)
if mod <= A :
    ball += list('b' * mod)
elif A < mod:
    ball += list('b' * A + 'r' * (mod - A))

#print(ball)
ans = ball.count('b')
print(ans)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
C = A+B
Line1 = ("b"*A+"r"*B)
Cnt = C

while Cnt < N:
	Line1 += ("b"*A+"r"*B)
	Cnt += C
print(Line1[:N].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input_line = input().split(" ")
numArray = [int(i) for i in input_line]
 
if numArray[1] == 0:
  print(0)
elif numArray[2] == 0:
  if numArray[0] <= numArray[1]:
    print(numArray[0])
  elif numArray[0] > numArray[1]:
    print(numArray[1])
elif numArray[0] <= (numArray[1] + numArray[2]):
  print(numArray[1])
elif numArray[0] > (numArray[1] + numArray[2]):
  if numArray[0] % (numArray[1] + numArray[2]) == 0:
    print(numArray[1] * (numArray[0]/ (numArray[1] + numArray[2])))
  else:
    count = numArray[0] // (numArray[1] + numArray[2])
    blueball = numArray[1] * count
    amount = numArray[0] - (numArray[1] * count) + (mArray[2] * count)
    if amount <= numArray[1]:
      print(blueball + amount)
    else:
      print(blueball + numArray[1])

Submission status: Runtime Error

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

print(int(N/(A+B))*A)+int(min(N%(A+B),A))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
 
 
x = N // (A + B)
y = N % (A + B)
z = 0
 
length = 'b' * A + 'a' * B
 
if y > 0:
    z = length[:y].count('b')
 
ans = x * A + z
print(int(ans))

Submission status: Runtime Error

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

i = 0

x = n//(a+b)

y = n%(a+b)
if y > a : z = a
else : z = y
    
a = x*a+z

print(a)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-03-07 21:21:27 +0900
# LastModified: 2020-03-07 22:31:57 +0900
#




def main():
    A,B = map(int,input().split())
    a_min = (A/0.08)
    a_max = (A+1)/0.08
    b_min = (B/0.1)
    b_max = (B+1)/0.1
    if a_min!=int(a_min):
        a_min = int(A/0.08)+1
    if b_min!=int(b_min):
        b_min = int(B/0.1)+1
    s_a = [i for i in range(int(a_min),int(a_max))]
    s_b = [i for i in range(int(b_min),int(b_max))]
    for common in s_a:
        if common in s_b:
            print(common)
            return
    print(-1)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def main():
    s = input()
    q = int(input())
    hanten = False
    for i in range(q):
        query = input().split()
        if query[0] == "1":
            hanten = not hanten
        else:
            if query[1] == "1":
                if hanten:
                    s = s + query[2]
                else:
                    s = query[2] + s
            if query[1] == "2":
                if hanten:
                    s = query[2] + s
                else:
                    s = s + query[2]
    print(s if not hanten else s[::-1])



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
s = list()
for s in range(A):
  append("b")
for s in range(B):
  append("r")
S = s[0:N]
S.print(count("b"))

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split()]
if a == 0:
    print(0)
else:
    x = (n // (a + b)) + 1
    balls = []
    for i in range(x):
        balls += list("b" * a) + list("r" * b)
    ans = 0
    for i in range(n):
        if balls[i] == "b":
            ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
N, A, B = [int(n) for n in input().split()]
if A == 0:
    print(0)
else:
    C = [1]*A+[0]*B
    ans = C*(N//(A+B))+C[:N%(A+B)]
    print(sum(ans))

Submission status: Runtime Error

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

x = N // (A + B)
y = N % (A + B)
z = 0

lngth = ''
if y > 0:
    while len(lngth) <= y:
        lngth += ('b' * A) + ('a' * B)

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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

total = int(N)
blue = int(A)
red = int(B)

string = ''

while total >= len(string):
    for num in range(blue):
        string += 'b'
        if(len(string) > total):
            break

    for num in range(red):
        string += 'r'

print(string.count('b')-1)

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
ballb=[]
ballr=[]
ballb.append('b')
ballb2=ballb*A
ballr.append('r')
ballr2=ballr*B
ball=(ballb2+ballr2)*N
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())

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


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


str = str[:N]
if str.count('b') != 0:
    print(str.count('b'))
else:
    print('0')

Submission status: Runtime Error

Solution code:
from collections import Counter
N, A, B = map(int, input().split())
ans = ''
while len(ans) < N:
    ans += 'b' * A + 'r' * B
ans = list(ans)
ans = ans[:N]
ans = dict(Counter(ans))
ans = list(ans.values())
print(ans[0])

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    (n, a, b) = map(int, input().split())
    if a == 0: print(0)
    elif n <= a+b:
        print(a)
    else:
    set_count = int(n/(a+b))*a+1
    print(set_count)

Submission status: Runtime Error

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

x = N // (A + B)
y = N % (A + B)
z = 0

lngth = ''
if y > 0:
    while len(lngth) <= N:
        lngth += ('b' * A) + ('a' * B)

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

Submission status: Runtime Error

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

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


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


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

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
s = ''
if (a=='0'):
    print(0)
else:
    s = "b"*int(a) + "r"*int(b)
    c = int(n) - len(s)
    s += 'b'*c
    print(s.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split()]
if a == 0:
    print(0)
else:
    x = (n // (a + b)) + 1
    balls = [*["b"] * a, *["r"] * b] * x
    ans = 0
    for i in range(n):
        if balls[i] == "b":
            ans += 1
    print(ans)

Submission status: Runtime Error

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

total = int(N)
blue = int(A)
red = int(B)

string = ''

while total > len(string):
    for num in range(blue):
        string += 'b'
        if(len(string) > total):
            break

    for num in range(red):
        string += 'r'

print(string.count('b'))

Submission status: Runtime Error

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    absum=(a+b)*s
    m=n%(absum)#余り
    if m<a:
        print(s*a+m)
    else:
        print((s+1)*a)

Submission status: Runtime Error

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

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

    if(N > 0 and A >= 0 and B >= 0):
        result = br * N

        if(len(result) >= N):
            print(result[:N].count('b'))
        else:
            print(result.count('b'))
    else:
        print(0)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ballb=[]
ballr=[]
ballb.append('b')
ballb2=ballb*A
ballr.append('r')
ballr2=ballr*B
ball=(ballb2+ballr2)*(10**100)
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())
s = 'b' * a + 'r' * b
sl = 0
str = ''
for sl in range(n):
  str += s
  sl = len(str)
print(str[:n].count('b'))

Submission status: Runtime Error

Solution code:
n,a,b = input().split()
s = ''
if (a=='0'):
    print(0)
else:
    s += "b"*int(a) + "r"*int(b)
    c = int(n) - len(s)
    s += 'b'*c
    print(s.count('b'))

Submission status: Runtime Error

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

cb = ''
balls = ''

aa = n[1] + n[2]
ab = (n[0] * aa) / aa


for i in range(n[1]):
    cb += 'b'
for i in range(n[2]):
    cb += 'r'

for i in range(ab):
    balls += cb
    if len(balls) >= n[0]:
        break

bcnt = balls.count('b', 0, n[0])

print(bcnt)

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

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

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

total = int(N)
blue = int(A)
red = int(B)

string = ''

while total > len(string):
    for num in range(blue):
        string += 'b'
        if(len(string) > total):
            break

    for num in range(red):
        string += 'r'

print(s.count('b'))

Submission status: Runtime Error

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

x = N // (A + B)
y = N % (A + B)
z = 0

if y > 0:
    for i in range(10 * 100):
        lngth = ('b' * A) + ('a' * B)
        if lngth >= N:
            z = lngth[:y].count('b')
            break
ans = (x * A) + z
print(ans)

Submission status: Runtime Error

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

count = int(n/c)*a+min(n%c,a)

print(count)# coding: utf-8
# Your code here!
n,a,b = map(int,input().split())
c = a+b

count = int(n/c)*a+min(n%c,a)

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

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

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

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Line1 = ("b"*A+"r"*B)
Line2 = ("b"*A+"r"*B)
Cnt = 0
for i in range(N):
	Line2 += Line1
	Cnt += i

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

Submission status: Runtime Error

Solution code:
#B
import sys
n,a,b=map(int,input().split())
if a==0:
    print(0)
    sys.exit()
else:
    s=int(n/(a+b))
    absum=(a+b)*s
    n=n%(absum)#余り
    if n<a:
        print(s*a+n)
    else:
        print((s+1)*a)

Submission status: Runtime Error

Solution code:
import numpy as np
data = input()
data = data.split(" ")
ans = 0
dataset = np.zeros(int(data[0]), dtype=np.int)
cont = int(data[1])
if int(data[1]) == 0:
    ans = 0

else:
    for i in range(int(data[0])):
        dataset[i] = 1
    for i in range(int(data[0])):
        if i == cont:
            dataset[cont:(int(data[2]) + i)] = 2
            cont = cont + int(data[2]) + int(data[1])

print(int(np.count_nonzero(dataset == 1)))