qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import itertools
s = input()
n = len(s)
keep = []
num = 0
ans = [0] * len(s)
gr = itertools.groupby(s)
for key, group in gr:
    keep.append([key, len(list(group))])
print(keep)
ans_num = 0
for i in range(len(keep)):
    if keep[i][0] == "R":
        if ans_num + keep[i][1] == n:
            ans[n - 1] += keep[i][1]
        else:
            ans[ans_num + keep[i][1] - 1] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num + keep[i][1]] += keep[i][1] // 2

    else:
        if ans_num == 0:
            ans[0] += keep[i][1]
        else:
            ans[ans_num] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num - 1] += keep[i][1] // 2
    ans_num += keep[i][1]

re_ans = str(ans[0])
for i in range(1, n):
    re_ans = re_ans + " " + str(ans[i])


print(re_ans)


Fixed code:
import itertools
s = input()
n = len(s)
keep = []
num = 0
ans = [0] * len(s)
gr = itertools.groupby(s)
for key, group in gr:
    keep.append([key, len(list(group))])
ans_num = 0
for i in range(len(keep)):
    if keep[i][0] == "R":
        if ans_num + keep[i][1] == n:
            ans[n - 1] += keep[i][1]
        else:
            ans[ans_num + keep[i][1] - 1] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num + keep[i][1]] += keep[i][1] // 2

    else:
        if ans_num == 0:
            ans[0] += keep[i][1]
        else:
            ans[ans_num] += (keep[i][1] - 1) // 2 + 1
            ans[ans_num - 1] += keep[i][1] // 2
    ans_num += keep[i][1]

re_ans = str(ans[0])
for i in range(1, n):
    re_ans = re_ans + " " + str(ans[i])


print(re_ans)
Buggy code:
s=input()
n=len(s)
l=[]
r=[]
for i in range(1,n):
    if s[i]=="L" and s[i-1]=="R":
        l.append(i)
for i in range(n-1):
    if s[i]=="R" and s[i+1]=="L":
        r.append(i)
r=sorted(r,reverse=True)
r_dis=[]
l_dis=[]
lcnt=0
rcnt=0
for i in range(n):
    if s[i]=="R" and i<l[lcnt]:
        r_dis.append([i,l[lcnt]-i])
    if s[i]=="R" and i==l[lcnt]-1:
        lcnt+=1
for i in range(n-1,0,-1):
    if s[i]=="L" and i>r[rcnt]:
        l_dis.append([i,i-r[rcnt]])
    if s[i]=="L" and i==r[rcnt]+1:
        rcnt+=1
ans=[0]*n
for i in range(len(r_dis)):
    if r_dis[i][1]%2==0:
        ans[r_dis[i][0]+r_dis[i][1]]+=1
    else:
        ans[r_dis[i][0]+r_dis[i][1]-1]+=1
for i in range(len(l_dis)):
    if l_dis[i][1]%2==0:
        ans[l_dis[i][0]-l_dis[i][1]]+=1
    else:
        ans[l_dis[i][0]-l_dis[i][1]+1]+=1
print(ans)


Fixed code:
s=input()
n=len(s)
l=[]
r=[]
for i in range(1,n):
    if s[i]=="L" and s[i-1]=="R":
        l.append(i)
for i in range(n-1):
    if s[i]=="R" and s[i+1]=="L":
        r.append(i)
r=sorted(r,reverse=True)
r_dis=[]
l_dis=[]
lcnt=0
rcnt=0
for i in range(n):
    if s[i]=="R" and i<l[lcnt]:
        r_dis.append([i,l[lcnt]-i])
    if s[i]=="R" and i==l[lcnt]-1:
        lcnt+=1
for i in range(n-1,0,-1):
    if s[i]=="L" and i>r[rcnt]:
        l_dis.append([i,i-r[rcnt]])
    if s[i]=="L" and i==r[rcnt]+1:
        rcnt+=1
ans=[0]*n
for i in range(len(r_dis)):
    if r_dis[i][1]%2==0:
        ans[r_dis[i][0]+r_dis[i][1]]+=1
    else:
        ans[r_dis[i][0]+r_dis[i][1]-1]+=1
for i in range(len(l_dis)):
    if l_dis[i][1]%2==0:
        ans[l_dis[i][0]-l_dis[i][1]]+=1
    else:
        ans[l_dis[i][0]-l_dis[i][1]+1]+=1
ans2=[]
for j in range(n):
    ans2.append(str(ans[j]))
print(" ".join(ans2))
Buggy code:
S = list(input())
ans = [0] * len(S)

count = 0
for i, s in enumerate(S):
    if S[i] == 'R':
        if S[i+1] == 'L':
            ans[i] += count//2 + 1
            ans[i+1] += count//2 + count%2 + 1
            count = 0
            continue
        count += 1

S.reverse()
ans.reverse()

count = 0
for i, s in enumerate(S):
    if S[i] == 'L':
        if S[i+1] == 'R':
            ans[i] += count//2
            ans[i+1] += count//2 + count%2
            count = 0
            continue
        count += 1

ans.reverse()
print(''.join(map(str, ans)))


Fixed code:
S = list(input())
ans = [0] * len(S)

count = 0
for i, s in enumerate(S):
    if S[i] == 'R':
        if S[i+1] == 'L':
            ans[i] += count//2 + 1
            ans[i+1] += count//2 + count%2 + 1
            count = 0
            continue
        count += 1

S.reverse()
ans.reverse()

count = 0
for i, s in enumerate(S):
    if S[i] == 'L':
        if S[i+1] == 'R':
            ans[i] += count//2
            ans[i+1] += count//2 + count%2
            count = 0
            continue
        count += 1

ans.reverse()
print(' '.join(map(str, ans)))
Buggy code:
from sys import exit, stdin

S = list(stdin.readline().rstrip())
ls = len(S)

candidates = []
for i in range(ls-1):
    if S[i] == 'R' and S[i+1] == 'L':
        candidates.append(i)
lc = len(candidates)

ans = [0 for _ in S]

for i in range(lc):
    l_index, r_index = candidates[i], candidates[i]+1

    while l_index > 0 and S[l_index - 1] == 'R':
        l_index -= 1
    while r_index + 1 < ls and S[r_index + 1] == 'L':
        r_index += 1

    even, odd = 0, 0
    idx = candidates[i]

    for j in range(l_index, idx):
        if (idx-j) % 2 == 0:
            even += 1
        else:
            odd += 1
    print(even, odd)
    for j in range(idx, r_index+1):
        if (j-idx) % 2 == 0:
            even += 1
        else:
            odd += 1
    print(even, odd)
    
    ans[idx] += even
    ans[idx+1] += odd

print(*ans)

Fixed code:
from sys import exit, stdin

S = list(stdin.readline().rstrip())
ls = len(S)

candidates = []
for i in range(ls-1):
    if S[i] == 'R' and S[i+1] == 'L':
        candidates.append(i)
lc = len(candidates)

ans = [0 for _ in S]

for i in range(lc):
    l_index, r_index = candidates[i], candidates[i]+1

    while l_index > 0 and S[l_index - 1] == 'R':
        l_index -= 1
    while r_index + 1 < ls and S[r_index + 1] == 'L':
        r_index += 1

    even, odd = 0, 0
    idx = candidates[i]

    for j in range(l_index, idx):
        if (idx-j) % 2 == 0:
            even += 1
        else:
            odd += 1
    for j in range(idx, r_index+1):
        if (j-idx) % 2 == 0:
            even += 1
        else:
            odd += 1
    
    ans[idx] += even
    ans[idx+1] += odd

print(*ans)
Buggy code:
s = input() + 'R'


t = []
b = 0
for i in range(1, len(s)):
    if s[i - 1] + s[i] == 'LR':
        t.append(s[b:i])
        b = i

ans = []


for ss in t:
    nR = ss.find('L')
    nL = len(ss) - nR

    R = nR // 2 + (nR % 2) + nL // 2
    L = nL // 2 + (nL % 2) + nR // 2
    ans = ans + [0 for _ in range(nR - 1)]+[R] + \
        [L] + [0 for _ in range(nL - 1)]

for i in range(len(ans)):
    if i != 0:
        print(' ', end='')
    print(ans[i])

Fixed code:
s = input() + 'R'


t = []
b = 0
for i in range(1, len(s)):
    if s[i - 1] + s[i] == 'LR':
        t.append(s[b:i])
        b = i

ans = []


for ss in t:
    nR = ss.find('L')
    nL = len(ss) - nR

    R = nR // 2 + (nR % 2) + nL // 2
    L = nL // 2 + (nL % 2) + nR // 2

    ans += [0 for _ in range(nR - 1)]+[R, L] + [0 for _ in range(nL - 1)]

for i in range(len(ans)):
    if i != 0:
        print(' ', end='')
    print(ans[i],end='')
Buggy code:
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    s = input()
    children = [0] * len(s)
    s += "E"
    start = 0
    now = 0
    while now < len(s)-1:
        r = 0
        l = 0
        while s[now] == "R":
            r += 1
            now += 1
        er = now - 1
        sl = now
        while s[now] == "L":
            l += 1
            now += 1
        count = now - start
        if count % 2 == 0:
            children[er] = count // 2
            children[sl] = count // 2
        else:
            if r % 2 == 1:
                children[er] = count // 2 + 1
                children[sl] = count // 2
            else:
                children[er] = count // 2
                children[sl] = count // 2 + 1
        start = now

    print(*children)

    return

main()


Fixed code:
import sys
from operator import itemgetter

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    s = input().rstrip()
    len_s = int(len(s))
    children = [0] * len_s
    s += "E"
    start = 0
    now = 0
    while now < len_s-1:
        r = 0
        l = 0
        while s[now] == "R":
            r += 1
            now += 1
        er = now - 1
        sl = now
        while s[now] == "L":
            l += 1
            now += 1
        count = now - start
        if count % 2 == 0:
            children[er] = count // 2
            children[sl] = count // 2
        else:
            if r % 2 == 1:
                children[er] = count // 2 + 1
                children[sl] = count // 2
            else:
                children[er] = count // 2
                children[sl] = count // 2 + 1
        start = now

    print(*children)

    return

main()
Buggy code:
import sys
import math
import itertools
def input(): return sys.stdin.readline().rstrip()

def main():
    s = list(input())
    g = itertools.groupby(s)
    ans = []
    for key, group in g:
        if key == 'R':
            r = len(tuple(group))
            continue
        l = len(tuple(group))

        ans += [0] * (r-1) + [math.ceil(r/2) + math.floor(l/2)]
        ans += [math.floor(r/2) + math.ceil(l/2)] + [0] * (l-1)
    print(ans)

if __name__ == '__main__':
    main()

Fixed code:
import sys
import math
import itertools
def input(): return sys.stdin.readline().rstrip()

def main():
    s = list(input())
    g = itertools.groupby(s)
    ans = []
    for key, group in g:
        if key == 'R':
            r = len(tuple(group))
            continue
        l = len(tuple(group))

        ans += [0] * (r-1) + [math.ceil(r/2) + math.floor(l/2)]
        ans += [math.floor(r/2) + math.ceil(l/2)] + [0] * (l-1)
    print(*ans)

if __name__ == '__main__':
    main()
Buggy code:
s = input()

idx = 0
ans = [0 for _ in range(len(s))]

if s.find('R') == -1:
    ans[0] = len(s)
elif s.find('L') == -1:
    ans[len(s)-1] = len(s)
else:
    while(idx<len(s)-1):
        lr_idx = idx
        if s[idx] == 'R':
            lr_idx = s.find('L', idx)
        elif s[idx] == 'L':
            lr_idx = s.find('R', idx)
        
        num = 0
        if lr_idx == -1:
            lr_idx = len(s) -1
            num += 1
        
        num += lr_idx - idx

        if s[idx] == 'R':
            ans[lr_idx] += num//2
            ans[lr_idx-1] += num//2
            if num%2 == 1:
                ans[lr_idx-1] += 1
        elif s[idx] == 'L':
            ans[idx] += num//2
            ans[idx-1] += num//2
            if num%2 == 1:
                ans[idx] += 1

        idx = lr_idx

for i in ans:
    print(i, end=' ')


Fixed code:
s = input()

idx = 0
ans = [0 for _ in range(len(s))]

if s.find('R') == -1:
    ans[0] = len(s)
elif s.find('L') == -1:
    ans[len(s)-1] = len(s)
else:
    while(idx<=len(s)-1):
        lr_idx = idx
        if s[idx] == 'R':
            lr_idx = s.find('L', idx)
        elif s[idx] == 'L':
            lr_idx = s.find('R', idx)

        
        num = lr_idx - idx

        if s[idx] == 'R':
            if lr_idx == -1:
                ans[len(s)-1] += len(s) - idx
            else:
                ans[lr_idx] += num//2
                ans[lr_idx-1] += num//2
                if num%2 == 1:
                    ans[lr_idx-1] += 1

        elif s[idx] == 'L':
            if lr_idx == -1:
                num = len(s) - idx
            if idx>0:
                ans[idx] += num//2
                ans[idx-1] += num//2
                if num%2 == 1:
                    ans[idx] += 1
            else:
                ans[0] += num
                
        idx = lr_idx
        if lr_idx == -1:
            break

for i in ans:
    print(i, end=' ')
Buggy code:
s = input().rstrip("\n")

mode = 'R'

import re
pattern = "(R+)(L+)"

result = len(s) * ["0"]
index = 0
for r, l in re.findall(pattern, s):
    r_len = len(r)
    l_len = len(l)
    r_len_half,r_len_mod = divmod(r_len, 2)
    l_len_half,l_len_mod = divmod(l_len, 2)
    
    
    r_left = r_len_half + r_len_mod
    r_right = r_len_half
    l_left = l_len_half
    l_right = l_len_half + l_len_mod
    
    result[index + r_len - 1] = str(r_left + l_left)
    result[index + r_len] = str(r_right + l_right)
    index += (r_len + l_len)
    
" ".join(result)
    

Fixed code:
s = input().rstrip("\n")

mode = 'R'

import re
pattern = "(R+)(L+)"

result = len(s) * ["0"]
index = 0
for r, l in re.findall(pattern, s):
    r_len = len(r)
    l_len = len(l)
    r_len_half,r_len_mod = divmod(r_len, 2)
    l_len_half,l_len_mod = divmod(l_len, 2)
    
    
    r_left = r_len_half + r_len_mod
    r_right = r_len_half
    l_left = l_len_half
    l_right = l_len_half + l_len_mod
    
    result[index + r_len - 1] = str(r_left + l_left)
    result[index + r_len] = str(r_right + l_right)
    index += (r_len + l_len)
    
print(" ".join(result))
Buggy code:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

S = input()
N = len(S)
i = 0

ANS = []
while i < N - 1:
    # print(S[i:i + 2])

    if S[i:i + 2] == 'RL':
        li = i
        while li > 0 and S[li] == 'R':
            li -= 1
        if li != 0:
            li += 1

        ri = i + 1
        while ri < N and S[ri] == 'L':
            ri += 1
        ri -= 1
        # print([li, i, ri])
        cnt = ri - li + 1
        if cnt % 2 == 0:
            ANS.append(cnt // 2)
            ANS.append(cnt // 2)
        else:
            if ri % 2 == i % 2:
                ANS.append(cnt // 2 + 1)
                ANS.append(cnt // 2)
            else:
                ANS.append(cnt // 2)
                ANS.append(cnt // 2 + 1)
        i += 2
    else:
        ANS.append(0)
        i += 1

print(" ".join([str(s) for s in ANS]))


Fixed code:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

S = input()
N = len(S)
i = 0

ANS = []
while i < N :
    # print(S[i:i + 2])

    if S[i:i + 2] == 'RL':
        li = i
        while li > 0 and S[li] == 'R':
            li -= 1
        if li != 0:
            li += 1

        ri = i + 1
        while ri < N and S[ri] == 'L':
            ri += 1
        ri -= 1
        # print([li, i, ri])
        cnt = ri - li + 1
        if cnt % 2 == 0:
            ANS.append(cnt // 2)
            ANS.append(cnt // 2)
        else:
            if ri % 2 == i % 2:
                ANS.append(cnt // 2 + 1)
                ANS.append(cnt // 2)
            else:
                ANS.append(cnt // 2)
                ANS.append(cnt // 2 + 1)
        i += 2
    else:
        ANS.append(0)
        i += 1

print(" ".join([str(s) for s in ANS]))
Buggy code:
from collections import Counter

S=input()
n=len(S)
dp=[[0]*n for _ in range(20)]

for i,s in enumerate(S):
    dp[0][i]=i-1 if s =='L' else i+1

for k in range(19):
    for i in range(n):
        dp[k+1][i]=dp[k][dp[k][i]]

C=Counter(dp[-1])
print(dp[-1])
print(C)
print(*[C[i] for i in range(n)])

Fixed code:
from collections import Counter

S=input()
n=len(S)
dp=[[0]*n for _ in range(20)]

for i,s in enumerate(S):
    dp[0][i]=i-1 if s =='L' else i+1

for k in range(19):
    for i in range(n):
        dp[k+1][i]=dp[k][dp[k][i]]

C=Counter(dp[-1])

print(*[C[i] for i in range(n)])
Buggy code:
s = list(input())
output = [0 for i in s]
ruiseki = 0
for p in range(len(s)):
    if s[p] == "R":
        if s[p+1] == "R":
            ruiseki+=1
        else:
            ruiseki+=1
            output[p] += ruiseki//2 + ruiseki%2
            output[p+1] += ruiseki//2
            ruiseki=0
    print(ruiseki)
ruiseki = 0
for q in range(len(s)-1, -1, -1):
    if s[q] == "L":
        if s[q-1]=="L":
            ruiseki+=1
        else:
            ruiseki+=1
            output[q] += ruiseki//2 + ruiseki%2
            output[q-1] += ruiseki//2
            ruiseki=0
print(" ".join(map(str,output)))
       

Fixed code:
s = list(input())
output = [0 for i in s]
ruiseki = 0
for p in range(len(s)):
    if s[p] == "R":
        if s[p+1] == "R":
            ruiseki+=1
        else:
            ruiseki+=1
            output[p] += ruiseki//2 + ruiseki%2
            output[p+1] += ruiseki//2
            ruiseki=0
    
ruiseki = 0
for q in range(len(s)-1, -1, -1):
    if s[q] == "L":
        if s[q-1]=="L":
            ruiseki+=1
        else:
            ruiseki+=1
            output[q] += ruiseki//2 + ruiseki%2
            output[q-1] += ruiseki//2
            ruiseki=0
print(" ".join(map(str,output)))
Buggy code:
import copy
S = input()
# S="R"*(10**5-1)+"L"

pairs = []
index = 0
R_ren = []
L_ren = []
start = 0
tugi_L_sagasu = True
while True:
    if tugi_L_sagasu:
        index = S.find("L", start)
        R_ren.append((start, index-1))
        start = index
        tugi_L_sagasu = False
    else:
        index = S.find("R", start)
        L_ren.append((start, index-1))
        start = index
        tugi_L_sagasu = True

    if index == -1:
        break

# print(R_ren)
# print(L_ren)

ans = [0]*len(S)
for a, b in R_ren:
    if b == -2:
        b = len(S)-1
    people = b - a+1
    ans[b] += people//2
    ans[b+1] += people-people//2

for a, b in L_ren:
    if b == -2:
        b = len(S) - 1
    people = b - a+1
    ans[a] += people//2
    ans[a-1] += people-people//2

strans=""
# print(ans)
for s in ans:
    strans += str(s) + " "

print(strans[:-1])


Fixed code:
import copy
S = input()
# S="R"*(10**5-1)+"L"

pairs = []
index = 0
R_ren = []
L_ren = []
start = 0
tugi_L_sagasu = True
while True:
    if tugi_L_sagasu:
        index = S.find("L", start)
        R_ren.append((start, index-1))
        start = index
        tugi_L_sagasu = False
    else:
        index = S.find("R", start)
        L_ren.append((start, index-1))
        start = index
        tugi_L_sagasu = True

    if index == -1:
        break

# print(R_ren)
# print(L_ren)

ans = [0]*len(S)
for a, b in R_ren:
    if b == -2:
        b = len(S)-1
    people = b - a+1
    ans[b+1] += people//2
    ans[b] += people-people//2

for a, b in L_ren:
    if b == -2:
        b = len(S) - 1
    people = b - a+1
    ans[a] += people-people//2
    ans[a-1] += people//2

strans=""
# print(ans)
for s in ans:
    strans += str(s) + " "

print(strans[:-1])
Buggy code:
a=input()
b=[]
last="R"
cnt=1
for i in range(1,len(a)):
    if last!=a[i]:
        b.append(cnt)
        cnt=1
        last=a[i]
    else:
        cnt+=1
b.append(cnt)


for i in range(0,len(b),2):
    c=b[i]//2
    d=b[i+1]//2
    b[i]=b[i]-c+d
    b[i+1]=b[i+1]+c-d


my_bool=True
cnt=0
c=[0 for i in range(len(a))]
c[0]=0
for i in range(1,len(a)):
    if my_bool:
        if a[i-2]=="R" and a[i-1]=="L" and a[i]=="R":
            c[i-2]=b[cnt]
            cnt+=1
            c[i-1]=b[cnt]
            cnt+=1
            c[i]=0
        elif a[i]=="L":
            c[i-1]=b[cnt]
            cnt+=1
            c[i]=b[cnt]
            cnt+=1
            my_bool=False
        else:
            c[i]=0
    else:
        if a[i-1]=="R" and a[i]=="L":
            my_bool=True
        c[i]=0

if cnt!=len(b) and a[-2]=="R" and a[-1]=="L":
    c[-2]=b[cnt]
    c[-1]=b[cnt+1]

print(*c)

Fixed code:
a=input()
b=[]
last="R"
cnt=1
for i in range(1,len(a)):
    if last!=a[i]:
        b.append(cnt)
        cnt=1
        last=a[i]
    else:
        cnt+=1
b.append(cnt)


for i in range(0,len(b),2):
    c=b[i]//2
    d=b[i+1]//2
    b[i]=b[i]-c+d
    b[i+1]=b[i+1]+c-d


my_bool=True
cnt=0
c=[0 for i in range(len(a))]
c[0]=0
for i in range(1,len(a)):
    if my_bool:
        if a[i]=="L":
            c[i-1]=b[cnt]
            cnt+=1
            c[i]=b[cnt]
            cnt+=1
            my_bool=False
        else:
            c[i]=0
    else:
        if a[i-1]=="L" and a[i]=="R":
            my_bool=True
            my_bool_2=True
        c[i]=0

if cnt!=len(b) and a[-2]=="R" and a[-1]=="L":
    c[-2]=b[cnt]
    c[-1]=b[cnt+1]

#print(*a)
print(*c)
Buggy code:
# -*- coding: utf-8 -*-
s = input()
s = 'RRRLLRLLRRRLLLLL'
li = []
r_cnt = 0
l_cnt = 0
for n, a in enumerate(s):
  if a == 'R':
    if l_cnt > 0:
      li.append([r_cnt, l_cnt])
      r_cnt = 1
      l_cnt = 0
    else:
      r_cnt += 1
  else:
    l_cnt += 1
    if n + 1 == len(s):
      li.append([r_cnt, l_cnt])

ans = ''
for l in li:
  b = int(l[0] / 2) + (l[0] % 2) + int(l[1] / 2)
  c = int(l[1] / 2) + (l[1] % 2) + int(l[0] / 2)
  ans += '0 ' * (l[0]- 1) + str(b) + ' ' + str(c) + ' ' + '0 ' * (l[1]- 1)
  
ans = ans[:-1]
print(ans)

Fixed code:
# -*- coding: utf-8 -*-
s = input()
li = []
r_cnt = 0
l_cnt = 0
for n, a in enumerate(s):
  if a == 'R':
    if l_cnt > 0:
      li.append([r_cnt, l_cnt])
      r_cnt = 1
      l_cnt = 0
    else:
      r_cnt += 1
  else:
    l_cnt += 1
    if n + 1 == len(s):
      li.append([r_cnt, l_cnt])

ans = ''
for l in li:
  b = int(l[0] / 2) + (l[0] % 2) + int(l[1] / 2)
  c = int(l[1] / 2) + (l[1] % 2) + int(l[0] / 2)
  ans += '0 ' * (l[0]- 1) + str(b) + ' ' + str(c) + ' ' + '0 ' * (l[1]- 1)
  
ans = ans[:-1]
print(ans)
Buggy code:
s = input()
n = len(s)
S=[0 for i in range(n)]
for i in range(n):
    if s[i]=="R":
        S[i]=1


ANS =[0 for i in range(n)]
tame =[0,0]
k=0
for i in range(n):
    if S[i] == 1:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i-1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
tame =[0,0]
k=0
for i in range(n-1,-1,-1):
    if S[i] == 0:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i+1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
#print(ANS)
# ans=""
# for i in range(n):
#     ans += str(ANS[i])
#     ans += " "
# print(ans)
#print(n)

Fixed code:
s = input()
n = len(s)
S=[0 for i in range(n)]
for i in range(n):
    if s[i]=="R":
        S[i]=1


ANS =[0 for i in range(n)]
tame =[0,0]
k=0
for i in range(n):
    if S[i] == 1:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i-1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
tame =[0,0]
k=0
for i in range(n-1,-1,-1):
    if S[i] == 0:
        tame[k]+=1
        k = (k+1)%2
    elif tame[0]>0:
        ANS[i+1] += tame[0]
        ANS[i] += tame[1]
        tame=[0,0]
        k=0
#print(ANS)
ans=""
for i in range(n):
    ans += str(ANS[i])
    ans += " "
print(ans)
#print(n)