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:
# coding:utf-8


import numpy as np

strInput = input()
N, A, B = np.array(strInput.split(' ')).astype(int)
lsStrBall = []
while True:
    lsStrBall += ['b'] * A
    lsStrBall += ['r'] * B
    if len(lsStrBall) >= N:
        break

arrStrBall = np.array(lsStrBall)
print((arrStrBall[:N] == 'b').sum())

Submission status: Runtime Error

Solution code:
nums_list = input().split()
print(nums_list[1] + nums_list[0] - nums_list[2])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input = input().split()
N = int(input[0])
A  = int(input[1])
B  = int(input[2])
arr = []
for index in range(A):
  arr.append('a')
for index in range(B):
  arr.append('b')

for index in range(0,N):
  if len(arr) == 0:
    print(0)
    break
  if arr[index] == 'b':
    print(index)
    break
  elif index + 1 == N:
    print(N)
    break

Submission status: Runtime Error

Solution code:
input = input().split()
N = int(input[0])
A  = int(input[1])
B  = int(input[2])
arr = []
for index in range(A):
  arr.append('a')
for index in range(B):
  arr.append('b')

for index in range(0,N):
  if arr[index] == 'b':
    print(index)
    break
  elif index + 1 == N:
    print(N)
    break

Submission status: Runtime Error

Solution code:
n,a,b = int(input())
c = (n//(a+b))*a
if n-(n//(a+b)) >= a:
	print(c+a)
else:
 	print(n-(n//(a+b)) +c)

Submission status: Runtime Error

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


s=0

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

    # print(a)
    # print(b)
    if b>A:
    sum=A*a+A
    print(s)
    else:
    s=A*a+b
    print(s)

Submission status: Runtime Error

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

a = int(N - B)

pritn(a)

Submission status: Runtime Error

Solution code:
class Ball_line:
    
    def __init__(self):
        self.line = ''
    
    def ball_add(self):
        self.line += 'b' * blue
        self.line += 'r' * red
        
        return len(self.line)

    def return_line(self):
        return self.line[:search_area].count('b')   

#try_cnt = 10 ** 100

search_area,blue,red = map(int,(input().split()))
my_line = Ball_line()

for i in range(search_area):  
    temp = Ball_line.ball_add(my_line)
    if temp > search_area:
        break
  
print(Ball_line.return_line(my_line))

Submission status: Runtime Error

Solution code:
class Ball_line:
    
    def __init__(self):
        self.line = ''
    
    def ball_add(self):
                
        self.line += 'b' * blue
        self.line += 'r' * red

    def return_line(self):

        return self.line[:search_area].count('b')   

#try_cnt = 10 ** 100

search_area,blue,red = map(int,(input().split()))
my_line = Ball_line()

for i in range(search_area):
    Ball_line.ball_add(my_line)
    
print(Ball_line.return_line(my_line))

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, a, b = LI()
    li = ''
    while len(li) <= n:
        li += 'a' * a
        li += 'b' * b
    print(li[:n].count('a'))
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, a, b = LI()
    li = ''
    i = 0
    while i <= n:
        i = len(li)
        li += 'a' * a
        li += 'b' * b
    print(li[:n].count('a'))
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, a, b = LI()
    li = ''
    for _ in range(10 ** 100):
        li += 'a' * a
        li += 'b' * b
    print(li[:n].count('a'))
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, a, b = LI()
    li = ''
    for _ in range(10 ^ 100):
        li += 'a' * a
        li += 'b' * b
    print(li[:n].count('a'))
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


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


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n, a, b = LI()
    li = ''
    for _ in range(n):
        li += 'a' * a
        li += 'b' * b
    print(li[:n].count('a'))
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Runtime Error

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

n = s[0]
blue = s[1]
red = s[2]

temp = ""

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

print(temp[:n].count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    m = N % (A+B)
    n = N // (A+B)
    ans = A * n
    if m > A:
        print(ans+A)n
    else:
        print(ans+m)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
if A ==0 :
    print(0)
elif B==0:
    print(N)
else:
    n = N // (A+B)
    ans = A * n
    m = N % n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
if A+B != 0:
    n = N // (A+B)
    ans = A * n
    m = N % n
    if m > A:
        print(ans+A)
    else:
        print(ans+m)
else:
    print(0)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
n = N // (A+B)
ans = A * n
m = N % n
if m > A:
    print(ans+A)
else:
    print(ans+m)

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
i=((A+B)*(10**100)//N)*A
if ((A+B)*(10**100))%N>A:
    i=i+A
else:
    i=i+((A+B)*(10**100)%N)
print(i)

Submission status: Runtime Error

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

# 整数の入力
#a = int(input())

# スペース区切りの文字列の入力
st = input().split()
#商
div = int(st[0]) // (int(st[1]) + int(st[2]))
#余り
rem = int(st[0]) % (int(st[1]) + int(st[2]))

if(rem < int(st[1])):
  print(div * int(st[1]) + rem)
else:
  print(div * int(st[1]) + st[1])

Submission status: Runtime Error

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

if a != 0:
  ans = n // (a + b) * a
  rem = n % (a + b)
  ans += min(a, rem)
print(ans)

Submission status: Runtime Error

Solution code:
def findB(tmp):
    count = 0
    for i in tmp:
        if i == "b":
            count += 1
    return count


n, a, b = list(map(int, input().split()))
if a != 0:
    tmp = "b" * a + "r" * b
    all_str = tmp
    while True:
        if len(all_str) >= n:
            break
        all_str = all_str + tmp
    print(findB(all_str[:n]))
else:
    print("0")

Submission status: Runtime Error

Solution code:
import sys

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

Result = ''

Count_Blue = 0
if 1<=N<=10**18 and A >= 0 and B >= 0 and \
   0< A + B <= 10**18:
    for Count in range(1,10**100+1):
        if len(Result) < N:
            Mod = Count % 2
            if Mod==1:
                for i in range(A):
                    if len(Result) < N:
                        Result = Result + 'B'
                        Count_Blue += 1
            elif Mod==0:
                Result = Result + 'R' * B
        else:
            print(Count_Blue)
            sys.exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a, b = map(int, input().split())
l = []
for i in range(10 ^100):
    l.extend([1]*a)
    l.extend([0]*b)

print(sum(l[:n]))

Submission status: Runtime Error

Solution code:
    n,a, b = map(int, input().split())
    l = []
    for i in range(10 ^100):
        l.extend([1]*a)
        l.extend([0]*b)
    
    print(sum(l[:n]))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <map>
#include <bitset>
#include <climits>
#include<algorithm>
#include <vector>
#include <unordered_map>
#define loop for(int i=0;i<n;i++)
#define pb push_back
using namespace std;
typedef   long long int ll;
int main()
{
	ll n;
	cin>>n;
	ll a;
	ll b;
	cin>>a>>b;
   ll	c=a+b;
	cout<<((n/c)*a)+min(n%c,a);
}

Submission status: Runtime Error

Solution code:
n, b, r = map(int, input().split())
bl = ["b"]*b
rl = ["r"]*r
br = bl + rl
ball = []
sav = n
while n>0:
  ball += br
  n -= (b+r)
print(ball[:sav].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
string = ''
for i in range(10**100):
  string += 'b'*A
  string += 'r'*B
  if len(string) >= N:
    break
str2 = string[0:N]
cnt = str2.count('b')
print(cnt)

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)3

Submission status: Runtime Error

Solution code:
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]

count = 0
sum = 0
while 1:
  for i in range(0, a):
  	count += 1
	if( count > n):
		break
	sum += 1
  if( count > n):
	break
  for i in range(0, b):
  	count += 1
	if( count > n):
		break
  else:
  	continue
  break

print sum
sys.stdout.flush()

Submission status: Runtime Error

Solution code:
import sys

f = sys.stdin.readline()
xx = f.split(' ')
x = [int(str) for str in xx]

n = x[0]
a = x[1]
b = x[2]

count = 0
sum = 0
while 1:
  for i in range(0, a):
  	count += 1
	if( count > n):
		break
	sum += 1
  for i in range(0, b):
  	count += 1
	if( count > n):
		break
  else:
  	continue
  break

print sum
sys.stdout.flush()

Submission status: Runtime Error

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

blue="B"*a
red="R"*b
line=""

while len(line)<=n:
    line+=(blue+red)
print(line)
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=""

if len(line)>=n:
    line+=(blue+red)
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=""

if len(line)<n:
    line+=(blue+red)
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=(blue+red)*(10**100)
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
zn,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=(blue+red)*1000
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=(blue+red)*1000
print(len(line[:n].replace("R","")))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
blue="B"*a
red="R"*b
line=(blue+red)*1000
print(len(line[:n].replace("R",""))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
a="B"
b="R"
line=(a+b)*1000
print(len(line[:n].replace("R", ""))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
i = a + b
for i in range(n):
  sum += sum + 1

sum = sum + a
print(sum)

Submission status: Runtime Error

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

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

i = int(N/(A+B))

cut = N - (A+B)*i
if n < A:
  Blue_Ball_Num = N
elif N < A+B:
  Blue_Ball_Num = A
elif cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + (N - (A+B)*i)
  
print(Blue_Ball_Num)

Submission status: Runtime Error

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

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

count = 0
i = 0

while 1:
  count = count + A + B
  i += 1
  if count > N:
    break

cut = N - (A+B)*(i-1)
print(cut)

if cut > A:
  Blue_Ball_Num = A*i
else:
  Blue_Ball_Num = A*i + ((A+B)*i - N)
  
print(Blue_Ball_Num)

Submission status: Runtime Error

Solution code:
N=int(input())
A=int(input())
B=int(input())
a=int(A+B)
b=int(N/a)
c=int(N%a)
if c<A:
  print(int(b*A+c))
else:
  print(int(b*A+A))

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
a=int(A+B)
b=int(N/a)
c=int(N%a)
if c<A:
  print(int(b*A+c))
else:
  print(int(b*A+A))

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
a=str(A+B)
b=str(N/a)
c=str(N%a)
if c<A:
  print(str(b*A+c))
else:
  print(str(b*A+A))

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
a=A+B
b=str(N/a)
c=str(N%a)
if c<A:
  print(b*A+c)
else:
  print(b*A+A)

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
a=A+B
b=N/a
c=N%a
if c<A:
  print(b*A+c)
else:
  print(b*A+A)

Submission status: Runtime Error

Solution code:
n, blue, red = map(int, input())
arr = []

for i in range(n):
  for j in range(blue):
    arr.append('b')
  for k in range(red):
    arr.append('r')

print(arr.count('b'))

Submission status: Runtime Error

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

print(x)

Submission status: Runtime Error

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

print(x)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input(),split())
if not N%(A+B)==0:
	print(A+N%(A+B))
elif A==0:
	print(0)
elif A+B==N:
	print(A)
elif B==0:
	print(N)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input(),split())
if not N%(A+B)==0:
	print(A+N%(A+B))
elif A==0:
	print(0)
elif A+B==N:
	print(A)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input(),split())
if N<=A:
	print(N)
elif N>A:
	print(A);

Submission status: Runtime Error

Solution code:
N=input()
A=input()
B=input()
if N<=A:
	print(N)
elif N>A:
	print(A);

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
[n, a, b] = list(map(int, input()))
cnt = 0
sum = 0
while cnt < = n:
  cnt += a
  cnt += b
  sum += b
if cnt - b >= n:
  print(sum - b)
else:
  print(sum - (cnt - n))

Submission status: Runtime Error

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

if n < a + b:
    if n < a:
        result = n
    else:
        result = a
else:
    if n % (a + b) < a:
        result = n % (a + b) + n*a //(a + b)
    else:
        result = n*a // ( a + b) + a

print(int(result))

Submission status: Runtime Error

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

if n < a + b:
    if n < a:
        result = n
    else:
        result = a
else:
    if n % (a + b) < a:
        result = n % (a + b) + n*a / (a + b)
    else:
        result = n*a / ( a + b) + a

print(int(result))

Submission status: Runtime Error

Solution code:
# N
num = int(input())
# A
greenNum = int(input())
# B
redNum = int(input())

# output
totalGreen = 0
while (num > 0):
  if (num <= greenNum):
    totalGreen += num
    num = 0
  else:
    totalGreen += greenNum
    num -= (greenNum + redNum)
    
print(totalGreen)

Submission status: Runtime Error

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

count = N//(A+B)
amari = N%(A+B)

if amari < A:
  c = amari
else:
  c = A
  
ans = A * x + c
print(ans)

Submission status: Runtime Error

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

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

for i in 10**100:
  line += line
  if len(line) >= N:
    break
   
ans = line.count('b')
print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = map(int,input().split())
ans = list()
aaa = ['b']*a
bbb = ['r']*b
if a == 0 and b == 0:
    print(0)
else:  
    while len(ans) < n:
        ans.extend(aaa)
        ans.extend(bbb)
    ans = ans[0:n]
    print(ans.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int,input().split())
ans = list()
aaa = ['b']*a
bbb = ['r']*b
kara = ['kara']*n
if a == 0 and b == 0:
    print(0)
else:  
    while len(ans) < n:
        ans.extend(aaa)
        ans.extend(bbb)
    ans = ans[0:n]
    print(ans.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int,input().split())
ans = list()
aaa = ['b']*a
bbb = ['r']*b
kara = ['kara']*n
while len(ans) < n:
    ans.extend(aaa)
    ans.extend(bbb)
    if len(ans) == 0:
        ans.extend(kara)
        break
ans = ans[0:n]
print(ans.count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int,input().split())
ans = list()
aaa = ['b']*a
bbb = ['r']*b
kara = ['kara']*n
while len(ans) < n:
    ans.extend(aaa)
    ans.extend(bbb)
    if len(ans) == 0:
        ans.extend(kara)
ans = ans[0:n]
print(ans.count('b'))

Submission status: Runtime Error

Solution code:
s=input()
x=s.split()
N=int(x[0])
A=int(x[1])
B=int(x[2])
all_ball =''
add_ball = 'b'*A + 'r'*B
 
while len(all_ball) < N:
    all_ball += add_ball
    
all_ball = all_ball[:N]
print(all_ball.count('b'))

Submission status: Runtime Error

Solution code:
S = Input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
ans = N //(A+B) * A
left = N % (A+B)
if left > A:
    ans += A
else:
    ans += left
print(ans)

Submission status: Runtime Error

Solution code:
S = input()
N,A,B = S.split(' ')
N = int(N)
A = int(A)
B = int(B)
till = int(N/(A+B))*(A+B)
left = N - till
leftover = ('b'*A + 'r'*B)[:left]
leftcount = leftover.count('b')
print(int(N/(A+B))*A + leftcount)

Submission status: Runtime Error

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

se=n//(a+b)
n%=a+b
ans+=se*a + min(a,n)
prnit(ans)

Submission status: Runtime Error

Solution code:
import unittest
from solution import Solution


class TestSolution(unittest.TestCase):

    def test_001(self):
        # class under test
        solution = Solution()

        # actual
        N, A, B = 6, 2, 4

        actual = solution.solve(N, A, B)

        # expect
        expect = 2

        # assert
        self.assertEqual(actual, expect)

    def test_002(self):
        # class under test
        solution = Solution()

        # actual
        N, A, B = 10**18, 5, 5

        actual = solution.solve(N, A, B)

        # expect
        expect = 5 * 10**17

        # assert
        self.assertEqual(actual, expect)


if __name__ == '__main__':
    unittest.main()

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
r=-1
for i in range(1001):
    if i*8//100==a and i*10//100==b:
        r=i
        break
print(r)

Submission status: Runtime Error

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

q, x = divmod(N, A+B)
#q = N//(A+B)
#x = N % (A+B)
ans = q*A+int(min(x,A))
#print(type(ans))
print(ans

Submission status: Runtime Error

Solution code:
def main():
  n,a,b = list(map(int, input().split()))
  
  p = n // (a+b)
  q = n % (a+b)
  r = q // a

  if r == 0:
    print(p*a)
  else:
    print(p*a + a)
  
main()

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ans=0
if A>=N:
  ans=N
elif A<N<=A+B:
  ans=A
elif N>A+B:
  num=int(N/(A+B))
  ans=num*A+N-(A+B)*num
  if n-(A+B)*num>=A:
    ans=(num+1)*A
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
n, a, b = map(int,input().split())
count = 0
if 1 <= (n/(a+b)):
    if a < n%(a+b):
        print ((n/(a+b)*a) +a)
    else:
        print (n/(a+b)*a) + n%(a+b)
else:
    if a < n%(a+b):
        print (a)
    else:
        print (n%(a+b))

Submission status: Runtime Error

Solution code:
import math
N, A, B = (int(x) for x in input().split(' '))
tmp = A * math.floor(N/(A+B))

if ( N % (A+B) ) > A:
  print(ans+A) 
else:
  print(ans+( N % (A+B)))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>

using namespace std;

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
a_str='b'*A
b_str='r'*B
st=a_str+b_str
num=A+B
sum_str=''
sum_num=0

sum_str=st*N
b=sum_str[0:N]
print(b.count('b'))

Submission status: Runtime Error

Solution code:
a=input().split()
N,A,B=int(a[0]),int(a[1]),int(a[2])
a_str='b'*A
b_str='r'*B
st=a_str+b_str
num=A+B
sum_str=''
sum_num=0

while sum_num<=N:
    sum_str+=st
    sum_num+=num
b=sum_str[0:N]
print(b.count('b'))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
if a==0:
    print(0)
else:
    blue=['b']*a
    red=['r']*b
    s=blue+red
    ans=(s[:n%(a+b)].count('b')) + (a*(n//(a+b)))
    print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,blue,red = input().split()
count = 0
while(1):
  if N > 0:
    N -= blue
    count += 1
  if N > 0:
    N -= red
  else:
    break
print(blue*count + N)

Submission status: Runtime Error

Solution code:
if A==0:
    print(0)
elif A!=0 and N>(A+B):
    print(num_A*A+int(sur/(A+B)))
elif A!=0 and N<=(A+B) and N>=A:
    print(A)
elif A!=0 and N<=(A+B) and N<A:
    print(N)

Submission status: Runtime Error

Solution code:
import numpy as np

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

t1 = np.ones(A,dtype=np.int64)
t2 = np.zeros(B,dtype=np.int64)
t = np.hstack((t1, t2))

L = len(t)

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.int64)
  t2 = np.zeros(B,dtype=np.int64)
  t = np.hstack((t1, t2))

  L = len(t)

  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())
ba=('b'*a+'r'*b)*(n//(a+b)+1)
print(ba[:n].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
ba=('b'*a+'r'*b)*(n//(a+b))
print(ba.count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
looptxt = "b" * a + "r" * b
looplen = a + b
i = 0
while i < n:
  looptxt += looptxt
  i += looplen
bnum = 0
for i in range(0, n):
  if looptxt[i] == "b":
    bnum += 1
print(bnum)

Submission status: Runtime Error

Solution code:
n, a, b = map(input(), int)
looptxt = "b" * a + "r" * b
looplen = a + b
i = 0
while i < n:
  looptxt += looptxt
  i += looplen
bnum = 0
for i in range(0, n):
  if looptxt[i] == "b":
    bnum += 1
print(bnum)

Submission status: Runtime Error

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


ans = (n //(a + b)) * a
if n % (a + b) <= a:
  print(ans + (n % (a + b))
elif n % (a + b) >= a:
  print(ans + a)

Submission status: Runtime Error

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


ans = (n //(a + b)) * a
if n % (a + b) < a:
  print(ans + (n % (a + b))
elif n % (a + b) >= a:
  print(ans + a)

Submission status: Runtime Error

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


ans = (n //(a + b)) * a
if n % (a + b) < a:
  print(ans + (n % (a + b))
elif n % (a + b) > a:
  print(ans + a)

Submission status: Runtime Error

Solution code:
n, a b = map(int, input().split())
ans = n// (a + b)
rem = n % (a + b)
ans += min(rem, A)
prnit(ans)

Submission status: Runtime Error

Solution code:
n, b_n, r_n = input().split()
b= "b" * int(b_n)
r = "r" * int(r_n)

total = (b + r) * int(n)
total = total[:int(n)]

b_n2 = 0
for _ in total:
  if _ == "b":
    b_n2 += 1
  
print(b_n2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split());a+b=c;print(n//c+max(n%c-a,0))

Submission status: Runtime Error

Solution code:
N = list(map(int, input().split()))
print((N[0]//(N[1]+N[2])*N[1] + min([N[0]%(N[1]+N[2]), N[1]]))

Submission status: Runtime Error

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

for i in range(N/(A+B)):
    for x in range(A):
        line.append("b")
    for y in range(B):
        line.append("r")

print(line[0:N:].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
if a==0:
  print('0')
elif (a+b)*(10**100 )<=n:
  print(a*(10**100))
    
else:
  amari=n%(a+b)
  cnt=int(n/(a+b))
if amari<=a:
  print(cnt*a+amari)
else:
  print(cnt*(a+1))

Submission status: Runtime Error

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

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:
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
x=S//(B+R)#brグループが何回
y=S//(B+R)
print(b*x+y)

Submission status: Runtime Error

Solution code:
inp=list(map(int,input().split()))
S=inp[0]
B=inp[1]
R=inp[2]
ans=B+(S-B-A)
print(ans)