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: Accepted

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()
    s = a+b
    k = n//s
    n -= k*s
    n = min(n,a)
    print(k*a+n)
    return

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n,a,b=MI()
    p,r=divmod(n,(a+b))
    print(p*a+min(r,a))

main()

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
total=[]
for i in range(10**100):
    total+=["b"]*a
    total+=["r"]*b
print(total[0:n].count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
a,b,c = map(int,input().split())
d = ""
e = ("1"*b + "0"*c)*a
f = e[:a]
g = Counter(f)
print(g["1"])

Submission status: Runtime Error

Solution code:
from collections import Counter
a,b,c = map(int,input().split())
d = ""
e = ("1"*b + "0"*c)*a
f = d[:a]
g = Counter(f)
print(g["1"])

Submission status: Runtime Error

Solution code:
from collections import Counter
a,b,c = map(int,input().split())
d = ""
for i in range(a):
    e = "1"*b + "0"*c
    d += e
f = d[:a]
g = Counter(f)
print(g["1"])

Submission status: Runtime Error

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

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

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

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*int(N/(A+B)+1))
print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
blue=[1]*A
red=[-1]*B
ball=(blue+red)*N
X=ball[0:N]
print(X)
print(X.count(1))

Submission status: Runtime Error

Solution code:
import numpy as np

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

blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

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

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
ball=list(ball[0:N])
print(ball.count(1))

Submission status: Runtime Error

Solution code:
import numpy as np

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

blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

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

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)
ball=np.array(list(np.concatenate([blue,red]))*N)
print(ball)
print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

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

import numpy as np
blue=np.array([1]*A)
red=np.array([-1]*B)

ball=np.concatenate(([blue, red]*N))

print(np.count_nonzero(ball[0:N]==1))

Submission status: Runtime Error

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

import numpy as np
ball=np.array([])
blue=np.array([1]*A)
red=np.array([-1]*B)
while len(ball)<N:
    ball=np.concatenate([ball, blue, red])
print(np.count_nonzero(ball==1))

Submission status: Runtime Error

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n,a,b = map(int,input().split())
    count=0
    blue_count=0
    blue=""
    red=""
    tmp=""
    ball_list=[]

    while count < n:
        blue = "b"*a
        red = "r"*b
        tmp+=blue+red
        count=len(tmp)
    ball_list.append(tmp)
    print(str(ball_list[0])[:n].count("b"))

if __name__=="__main__":
    main()

Submission status: Runtime Error

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

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

  
  if q <= a:
    print(a*d+q)
  else:
    print(a*d+a)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
s = 'b'*a + 'r'*b
d = n//(a+b)
q = n % (a+b)

if q <= a:
  print(a*d+q)
else:
  print(a*d+a)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
s = 'b'*a + 'r'*b
d = n//(a+b)
q = n % (a+b)

if q <= a:
  print(b*d)
else:
  print(b*d+q-a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()
A=input()
B=input()
z=A+B
if n%z<=A:
    print(int(n/z)*A+n%z)
elif A<=n%z<=z:
    print(int(n/z)*A)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

count = 0
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
count = num // (all_ball)
rest = n % all_ball
print(count * all_ball + min(rest, blue_num))

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
    print((count * blue_num)a + blue_rest)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue_rest = rest
    print((count * blue_num) + blue_rest)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(math.floor(num / all_ball))
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue = rest
    print((count) * blue_num + blue)

Submission status: Runtime Error

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    count = int(num / all_ball)
    rest = int(num - (count * all_ball))
    if rest <= blue_num:
        blue = rest
    print((count) * blue_num + blue)

Submission status: Runtime Error

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
elif red_num == 0:
    print(num)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Submission status: Runtime Error

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if num == 0 or blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Submission status: Runtime Error

Solution code:
# coding: utf-8

num, blue_num, red_num = map(int, input().split())
all_ball = blue_num + red_num
if blue_num == 0:
    print(0)
else:
    rest = int(num % all_ball)
    if rest <= blue_num:
        blue = rest
    count = int(num / all_ball)
    print((count) * blue_num + blue)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

mojiretsu = ''
while len(mojiretsu) < N:
    mojiretsu += 'b' * A
    mojiretsu += 'r' * B

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

Submission status: Runtime Error

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

print(lis[:N%(A+B)].count("b")+A*N//(A+B))

Submission status: Runtime Error

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

L = []
i = 0
k = 0
j = 0
 
for k in range(10**9):
    for i in range(A):
        L.append('b')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif A == 0:
            print(A)
            exit()
        elif A == 1:
            print(N // B)
            exit()
    
    for j in range(B):
        L.append('r')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif B == 0:
            print(N)
            exit()

Submission status: Runtime Error

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

L = []
i = 0
k = 0
j = 0
 
for k in range(10**100):
    for i in range(A):
        L.append('b')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif A == 0:
            print(A)
            exit()
        elif A == 1:
            print(N // B)
            exit()
    
    for j in range(B):
        L.append('r')
        if len(L) >= N:
            L = L[0:N]
            print(L.count('b'))
            exit()
        elif B == 0:
            print(N)
            exit()

Submission status: Runtime Error

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

L = []
i = 0
k = 0
j = 0

for k in range(10**100):
    for i in range(A):
        L.append('b')
        if len(L) >= N:
        L = L[0:N]
        print(L.count('b'))
        break
    
    for j in range(B):
        L.append('r')
    if len(L) >= N:
        L = L[0:N]
        print(L.count('b'))
        break

Submission status: Runtime Error

Solution code:
H,A,B=map(int,input().split())
l=[]
s=0
while True:
    for i in range(A):
        if s==H:
            print(l.count('b'))
            exit()
        s+=1
        list.append('b')
    for j in range(B):
        if s==H:
            print(l.count('b'))
            exit()
        s+=1
        list.append('a')

Submission status: Runtime Error

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

number_turn = N //(A + B)
nokori = N % (A + B)

if nokori <= A: #nokoriが全てAの場合
	print((number_turn * A) + nokori)
else:　#nokoriがAとBの両方の場合
	print((number_turn * A) + A)

Submission status: Runtime Error

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

l=""
while len(l)<=n:
  l+="b"*a
  l+="r"*b
  
print(l[0:8].count("b"))

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
c == n%(a+b)
if c >a:
  print(a*(n//(a+b))+a)
elif c <=a
  print(a*(n//(a+b))+c)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

l = (A*"b"+B*"r")*(-(-N//(A+B)))

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

Submission status: Runtime Error

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

l = (A*"b"+B*"r")*N

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

Submission status: Runtime Error

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


def count_blue(N, blue, red):
  
  if blue == 0:
    return 0
  elif N <= blue:
    return N
  elif N <= blue + red:
    return blue
  else:
    return (N // (blue + red) * blue) + count_blue(N // (blue + red), blue, red)
  
  
print(count_blue(N, blue, red))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
balls = []
while len(balls)<N:
    balls.append('b'*A)
    balls.append('a'*B)
s = ''.join(balls)
sn = s[:N].count('b')
print(sn)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
balls = []
for i in range(10**100):
    balls.append('b'*A)
    balls.append('a'*B)
    if len(balls) >= N:
        break
s = ''.join(balls)
sn = s[:N].count('b')
print(sn)

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'r'*B)*10**7
if B <= N:
    print(ball.count('b',0,N))
else:
    print(N)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b = map(int, input().split())
w = ("b"*a + "r"*b)*(n//(a+b))
if n%(a+b) <= a:
    w += "b"*(n%(a+b))
else:
    w += "b"*a + "r"*((n%(a+b))-a)
print(w.count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
c='b'*A+'a'*B
import math
for i in range(math.ceil(N/(A+B))+1):
    d=i*c
print(d.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
c='b'*A+'a'*B
for i in range(N):
    d=i*c
print(d.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
c=N//(A+B)
ball=('b'*A+'a'*B)*(c+1)
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
import math
c=math.ceil(N/(A+B))
ball=('b'*A+'a'*B)*c
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10**18
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10**9
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10**7
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*100
print(ball.count('b',0,N))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*100
print(ball[0:N].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10
print(ball[0:N].count('b'))

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10000
print(ball[0:N].count('b'))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*10000
print(ball[0:N].count('b'))N,A,B=map(int,input().split())
ball=('b'*A+'a'*B)*N
print(ball[0:N].count('b'))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x = int(n / (a + b))
y = n - ((a + b) / x)
if y >= a:
    z = a
else:
    z = y
print(int(a * x + z))

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split()]
ans = []
flag = False

while flag is False:
    ans += [1]*a
    ans += [0]*b
    if len(ans) > n:
        flag = True
        #print(ans)
print(sum(ans[:n]))

Submission status: Runtime Error

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

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

s = N // (A+B)
p = (N%(A+B))
if p//A == 0:
    ans = s*A+p
elif p//A == 1:
    ans = s*A+A
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

while len(s) < n:
  s = s + "b"*a
  s = s + "r"*b

print(s[0:n].count("b"))

Submission status: Runtime Error

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

Balls = ABalls + BBalls
AB = A + B
NumBBalls = 0

NumBBalls = N//AB * A
M = N%AB

for m in range(M):
  if Balls[m] == "B":
    NumBBalls += 1
  else:
    break

print(NumBBalls)

Submission status: Runtime Error

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

num=n//(a+b)+1

line=("b"*a+"r"*b)*num

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

Submission status: Runtime Error

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

if A == 0:
    print(0)
else:
    s = 'b' * A + 'r' * B
    i = N // (A + B)
    j = N % (A + B)
    a = s[:j].count('b')
    count = A * i + a
    print(count)

Submission status: Runtime Error

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

s = 'b' * A + 'r' * B
while N > len(s):
    s += s
a = s[:N].count('b')
print(a)

Submission status: Runtime Error

Solution code:
    N,A,B = map(int,input().split())
    #Aが青
    #Bが赤
    i = N // (A+B)
    b = i*A
    t = N % (A+B)

    if t > A:
        t = A

    print(b+t)

Submission status: Runtime Error

Solution code:
N, A, B = map(int,input().split())
ans = 0
x = 0
y = 0
Ball1 = ['b']
Ball2 = ['r']
Ball = Ball1 * A + Ball2 * B
while x < N :
    x = x + A + B
    y += 1
Ball = Ball * y
Ball = Ball[0:N]
ans = Ball.count('b')
print(ans)

Submission status: Runtime Error

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

if not ( 1 <= N <= 10**18 and 0 <= A and 0 <= B and 0 < A + B <= 10**18 ): sys.exit()
if not ( isinstance(N,int) and isinstance(A,int) and isinstance(B,int) ): sys.exit()

count = 0
while N >= 0:
    if N <= A:
        remind = N
        break
    N -= A+B
    count += 1
print(count * A + remind)

Submission status: Runtime Error

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

blue_num = A * (N // (A + B)) + (N % (A + B) % A)
print(blue_num)

Submission status: Runtime Error

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

blue_num = A * (N // (A + B)) + (N % (A + B) % A)
print(blue_num)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def append():
    for i in range(a):
        l.append("b")
        if len(l)==n:
            return
    for k in range(b):
        l.append("r")
        if len(l)==n:
            return
    if len(l)<n:
        append()
    return
append()

#print(l)
print(l.count('b'))

Submission status: Runtime Error

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

sum = ""
k = (n//(a+b)+1)
blue = "b"*a
red = "r"*b
sum = (blue + red) * k
ans = sum[:n].count("b")
print(ans)

Submission status: Runtime Error

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

sum = ""
k = (n//(a+b)+1)
for i in range(k):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    print(ans)
    exit()
    

print(sum.count("b"))

Submission status: Runtime Error

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

sum = ""
for i in range(10**18):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    print(ans)
    exit()
    

print(sum.count("b"))

Submission status: Runtime Error

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

sum = ""
for i in range(10**100):
  blue = "b"*a
  red = "r"*b
  sum = sum + blue + red
  if len(sum) >= n:
    ans = sum[:n].count("b")
    break
    
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
list = [0] * n
idx = 0
while True :
    if a < list.count(0) :
        for i in range(idx,idx+a) :
            list[i] = "b"
        idx += a
    elif a == list.count(0) :
        for i in range(idx,idx+a) :
            list[i] = "b"
        break
    else :
        for i in range(idx,idx+list.count(0)) :
            list[i] = "b"
        break

    if b < list.count(0) :
        for i in range(idx,idx+b) :
            list[i] = "a"
        idx += b
    elif b == list.count(0) :
        for i in range(idx,idx+b) :
            list[i] = "a"
        break
    else :
        for i in range(idx,idx+list.count(0)) :
            list[i] = "a"
        break
print(list.count("b"))

Submission status: Runtime Error

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

if a + b == 0:
  print(0)
else:
  c, r = n // (a + b), n % (a + b)
  nblue = c * a + min(a, r)
  print(nblue)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
t = ""
for _ in range(10000):
    t = t + ("b" * a)
    t = t + ("r" * b)
    if len(t) >= n:
        print(t.count("b", 0, n))
        break

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
t = ""
for _ in range(10000):
    t = t + ("1" * a)  #赤
    t = t + ("2" * b)  #青
    if len(t) >= n:
        print(t.count("1", 0, n))
        break

Submission status: Runtime Error

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

al = [1]*a
bl = [0]*b
cl =[]
d = a + b
e = n//d + 2

for i in range(e):
    cl = cl + al + bl

print(sum(cl[:n]))

Submission status: Runtime Error

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

al = [1]*a
bl = [0]*b
cl =[]

for i in range(20):
    cl = cl + al + bl

print(sum(cl[:n]))

Submission status: Runtime Error

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

al = [1]*a
bl = [0]*b
cl =[]

for i in range(n+1):
    cl = cl + al + bl

print(sum(cl[:n]))

Submission status: Runtime Error

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

balls_list = []
while len(balls_list) <= n:
    balls_list.append(['r'] * a)
    balls_list.append(['b'] * b)

new_list = balls_list[ :n]

from collections import Counter

count = Counter(new_list)

x = count['b']

print(x)

Submission status: Runtime Error

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

red = [0] * a
blue = [1] * b
l = []

while len(l) < n:
    l += red
    l += blue
m = l[:n]
print(m.count(0))

Submission status: Runtime Error

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

if a != 0:
  answer = n // (a+b)
  remainder = n % (a+b)
  print(answer*a) + min(a, remainder)
else:
  print(0)

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())
ans=n/(a+b)
 if n%(a+b)>=a:
    ans+=a
 else:
    ans+=n%(a+b)
print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
lis=""
ans=0
for i in range(n):
 for b in range(a):
  ans+=1
 for r in range(b+1):
print(ans)

Submission status: Runtime Error

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

s_b = ['b']*b
s_r = ['r']*r
l = []
for i in range(1000):
  l+=(s_b + s_r)

print(l[0:n].count('b'))

Submission status: Runtime Error

Solution code:
def resolve():
    N,A,B = map(int,input().split())
    div,mod = divmod(N,A+B)
    pattern = "b"*A+"r"*B
    array = ''
    array+= pattern*div + pattern[:mod]
    print(array.count("b"))
resolve()

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
blue = 'b'*a
red = 'r'*b
lst = (blue+red)*n

cnt = 0
for i in range(n):
    if lst[i] == 'b':
        cnt += 1
print(cnt)

Submission status: Runtime Error

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

cnt_blue = 0

# try:
pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
print(cnt_blue)
# except:
#     print(0)

Submission status: Runtime Error

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

cnt_blue = 0

# try:
pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
# print(cnt_blue)
# except:
#     print(0)

Submission status: Runtime Error

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A
print(cnt_blue)

Submission status: Runtime Error

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

cnt_blue = 0

pre_loop_cnt = N // (A+B)
totol_pre_A = sum([A] * pre_loop_cnt)
totol_pre_B = sum([B] * pre_loop_cnt)

total_tmp = totol_pre_A + totol_pre_B
total_tmp += A
if N <= total_tmp:
    cnt_blue = N -  totol_pre_B
else:
    cnt_blue = totol_pre_A + A

Submission status: Runtime Error

Solution code:
import math
n,a,b = map(int,input().split())
r = math.ceil(n/(a+b))
retukaioh = ""
for i in range(r):
  retukaioh = retukaioh + "b"*a + "r"*b
print(retukaioh[0:n].count("b"))

Submission status: Runtime Error

Solution code:
import math
n,a,b = map(int,input().split())
r = math.ceil(n/(a+b))
retukaioh = ""
for i in range(r):
  retukaioh = retukaioh + "b"*a + "r"*b
print(retukaioh[0:n].count("b"))
print(retukaioh)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x="b"*a+"r"*b
x= x*(10**5)
strx = x[0:n]
def split(w):
    return [all for all in w]
def countX(lst, x): 
    return lst.count(x) 
listx = split(strx)
print(countX(listx, "b"))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x="b"*a+"r"*b
x= x*(10**5)
strx = x[0:n]
def split(w):
    return [all for all in w]
def countX(lst, x): 
    return lst.count(x) 
listx = split(strx)
print(countX(listx))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
x="b"*a+"r"*b
x= x*(10**100)
strx = x[0:n]
def split(w):
    return [all for all in w]
def countX(lst, x): 
    return lst.count(x) 
listx = split(strx)
print(countX(listx))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
color = []
if(A==0):
    print(0)
else:
    while len(color)<N:
        color.extend([1]*A)
        color.extend([0]*B)
    print(color[:N].count(1))

Submission status: Runtime Error

Solution code:
# 158 B

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

while len(s) < n:
    s += a * "b"
    if len(s) >= n:
        break
    s += b * "r"
    if len(s) >= n:
        break

s = s[:n]
print(s.count("b"))

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
x=n//(a+b)
y=n - C1*(a+b)
if y >= a:
  y=a
print(a*x+y)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# 159 B

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

while len(s) < n:
    s += a * "b"
    if len(s) >= n:
        break
    s += b * "r"

s = s[:n]
print(s.count("b"))

Submission status: Runtime Error

Solution code:
# 159 B

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

while len(s) <= n:
    s += a * "b"
    s += b * "r"

s = s[:n]
print(s.count("b"))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

x = [0] * n
cnt = 0
flag = True
while cnt < n:
    if flag:
        for j in range(a):
            if cnt + j >= n:
                break
            x[cnt + j] = 1
        cnt += a
        flag = False
    else:
        for j in range(b):
            if cnt + j >= n:
                break
            x[cnt + j] = 0
        cnt += b
        flag = True

cnt = 0
for i in range(n):
    if x[i] == 1:
        cnt += 1

print(cnt)

Submission status: Runtime Error

Solution code:
#include <iostream>
using namespace std;

int main() {
    int n, a, b;
    cin>>n>>a>>b;
    int d=a*b;
    cout << d%n;
	return 0;
}

Submission status: Runtime Error

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

if __name__ == "__main__":
    main()