qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
s = s.replace("LR", "L R").split()
print(s)

ans = []
for ss in s:
    a = b = 0
    c = d = 0
    for i in range(len(ss)):
        if ss[i] == 'R':
            a += 1
        else:
            b += 1

    if a % 2 == 0:
        c += a // 2
        d += a // 2
    else:
        c += (a + 1) // 2
        d += (a - 1) // 2

    if b % 2 == 0:
        c += b // 2
        d += b // 2
    else:
        c += (b - 1) // 2
        d += (b + 1) // 2

    ans += [0]*(a-1) + [c, d] + [0]*(b-1)

print(' '.join([str(ai) for ai in ans]))


Fixed code:
s = input()
s = s.replace("LR", "L R").split()

ans = []
for ss in s:
    a = b = 0
    c = d = 0
    for i in range(len(ss)):
        if ss[i] == 'R':
            a += 1
        else:
            b += 1

    if a % 2 == 0:
        c += a // 2
        d += a // 2
    else:
        c += (a + 1) // 2
        d += (a - 1) // 2

    if b % 2 == 0:
        c += b // 2
        d += b // 2
    else:
        c += (b - 1) // 2
        d += (b + 1) // 2

    ans += [0]*(a-1) + [c, d] + [0]*(b-1)

print(' '.join([str(ai) for ai in ans]))
Buggy code:
s = str(input())
lis = [1 for i in range(len(s))]
n = len(s)
li = []
l = []
key = 0
num = 0
for i in range(n-1):
    l.append(s[i])
    if s[i] == "L":
        key = 1
    if s[i+1] == "R" and key == 1:
        li.append(l)
        l = []
        key = 0
l.append("L")
li.append(l)

ans = ""

for ss in li:
    if len(ss) % 2 == 0:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2)+" ") * 2 + "0 " * (ss.count("L")-1)
    else:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2 + ss.count("R")%2)+" ") + (str(len(ss)//2 + ss.count("R")%2-1)+" ")  + "0 " * (ss.count("L")-1)
print(ans)

Fixed code:
s = str(input())
lis = [1 for i in range(len(s))]
n = len(s)
li = []
l = []
key = 0
num = 0
for i in range(n-1):
    l.append(s[i])
    if s[i] == "L":
        key = 1
    if s[i+1] == "R" and key == 1:
        li.append(l)
        l = []
        key = 0
l.append("L")
li.append(l)

ans = ""

for ss in li:
    if len(ss) % 2 == 0:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2)+" ") * 2 + "0 " * (ss.count("L")-1)
    else:
        ans += "0 " * (ss.count("R")-1) + (str(len(ss)//2 + ss.count("R")%2)+" ") + (str(len(ss)//2 + ss.count("L")%2)+" ")  + "0 " * (ss.count("L")-1)
print(ans)
Buggy code:
s = input()
li = [0]*len(s)
n = 0
m = 0
num = 0

for i in range(len(s)):
    if s[i] == "R":
        if num%2 == 0:
            n += 1
        else:
            m += 1
        num += 1
    else:
        if num>0:
            if num % 2 == 0:
                li[i] += n
                li[i - 1] += m
            else:
                li[i] += m
                li[i - 1] += n
        n = 0
        m = 0
        num = 0

sle = s[::-1]
n = 0
m = 0
num = 0

for i in range(len(s)):
    if sle[i] == "L":
        if num%2 == 0:
            n += 1
        else:
            m += 1
        num += 1
    else:
        if num%2 == 0:
            li[-(i+1)] += n
            li[-i] += m
        else:
            li[-(i+1)] += m
            li[-i] += n
        n = 0
        m = 0
        num = 0

print(li)

Fixed code:
s = input()
li = [0]*len(s)
n = 0
m = 0
num = 0

for i in range(len(s)):
    if s[i] == "R":
        if num%2 == 0:
            n += 1
        else:
            m += 1
        num += 1
    else:
        if num>0:
            if num % 2 == 0:
                li[i] += n
                li[i - 1] += m
            else:
                li[i] += m
                li[i - 1] += n
        n = 0
        m = 0
        num = 0

sle = s[::-1]
n = 0
m = 0
num = 0

for i in range(len(s)):
    if sle[i] == "L":
        if num%2 == 0:
            n += 1
        else:
            m += 1
        num += 1
    else:
        if num%2 == 0:
            li[-(i+1)] += n
            li[-i] += m
        else:
            li[-(i+1)] += m
            li[-i] += n
        n = 0
        m = 0
        num = 0

for i in li:
    print(i, end=" ")
Buggy code:
S=input()
ans = [0] * len(S)
last_R=[0] * len(S)
tmp = 0
for i in range(len(S)):
    if S[i] == "R":
        tmp = i
    last_R[i] = tmp
first_L=[0] * len(S)
tmp = 0
for i in reversed(range(len(S))):
    if S[i] == "L":
        tmp = i
    first_L[i] = tmp
print(last_R)
print(first_L)
for i in range(len(S)):
    if S[i] == "L":
        R_index = last_R[i]
        if i - R_index % 2 == 1:
            ans[R_index+1] += 1
        else:
            ans[R_index] += 1
    if S[i] == "R":
        L_index = first_L[i]
        if L_index - i %2 == 1:
            ans[L_index-1] += 1
        else:
            ans[L_index] += 1
    print(i, ans)
ans = map(str, ans)
print(" ".join(ans))

Fixed code:
S=input()
ans = [0] * len(S)
last_R=[0] * len(S)
tmp = 0
for i in range(len(S)):
    if S[i] == "R":
        tmp = i
    last_R[i] = tmp
first_L=[0] * len(S)
tmp = 0
for i in reversed(range(len(S))):
    if S[i] == "L":
        tmp = i
    first_L[i] = tmp
for i in range(len(S)):
    if S[i] == "L":
        R_index = last_R[i]
        if (i - R_index) % 2 == 1:
            ans[R_index+1] += 1
        else:
            ans[R_index] += 1
    if S[i] == "R":
        L_index = first_L[i]
        if (L_index - i) %2 == 1:
            ans[L_index-1] += 1
        else:
            ans[L_index] += 1
ans = map(str, ans)
print(" ".join(ans))
Buggy code:
import re

s = input()

ans = [0] * len(s) 

t = -1

while len(s) > 0:
    r = re.search('R*', s)

    r_e = r.end()

    s = s[r_e:]

    l = re.search('L*', s)

    l_e = l.end()

    s = s[l_e:]

    r_ind = r_e + t

    l_ind = r_ind + 1

    ans[r_ind] = (r_e + 1) // 2 + l_e // 2
    ans[l_ind] = r_e // 2 + (l_e + 1)// 2

    t += r_e + l_e 

Fixed code:
import re

s = input()

ans = [0] * len(s) 

t = -1

while len(s) > 0:
    r = re.search('R*', s)

    r_e = r.end()

    s = s[r_e:]

    l = re.search('L*', s)

    l_e = l.end()

    s = s[l_e:]

    r_ind = r_e + t

    l_ind = r_ind + 1

    ans[r_ind] = (r_e + 1) // 2 + l_e // 2
    ans[l_ind] = r_e // 2 + (l_e + 1)// 2

    t += r_e + l_e 

print(*ans)
Buggy code:
def main():
    S = list(input())
    num_r = 0
    num_l = 0
    agg = []
    pos = [0 for _ in range(len(S))]
    for i in range(len(S)-1):

        if S[i] == "R":
            num_r += 1

        elif S[i] == "L":
            num_l += 1

        if S[i] == "R" and S[i+1] == "L":
            agg.append((i, num_r))
            num_r = 0
        elif S[i] == "L" and S[i+1] == "R":
            agg.append((i, num_l))
            num_l = 0

        if i == len(S) - 2:
            num_l += 1
            agg.append((i, num_l))
            num_l = 0

    # length of agg is always even number
    for i in range(0, len(agg)-1, 2):
        idx = agg[i][0]
        r_num = agg[i][1] // 2 + 1 + agg[i+1][1] // 2
        l_num = agg[i][1] - agg[i][1] // 2 - 1 + agg[i+1][1] - agg[i+1][1] // 2
        pos[idx] = r_num
        pos[idx+1] = l_num
    print(*pos)


if __name__ == '__main__':
    main()

Fixed code:
from math import ceil

def main():
    S = list(input())
    num_r = 0
    num_l = 0
    agg = []
    pos = [0 for _ in range(len(S))]
    for i in range(len(S)-1):

        if S[i] == "R":
            num_r += 1

        elif S[i] == "L":
            num_l += 1

        if S[i] == "R" and S[i+1] == "L":
            agg.append((i, num_r))
            num_r = 0
        elif S[i] == "L" and S[i+1] == "R":
            agg.append((i, num_l))
            num_l = 0

        if i == len(S) - 2:
            num_l += 1
            agg.append((i, num_l))
            num_l = 0

    # length of agg is always even number
    for i in range(0, len(agg)-1, 2):
        idx = agg[i][0]
        r_num = ceil(agg[i][1] / 2) + agg[i+1][1] // 2
        l_num = agg[i][1] - ceil(agg[i][1] / 2) + agg[i+1][1] - agg[i+1][1] // 2
        pos[idx] = r_num
        pos[idx+1] = l_num
    print(*pos)


if __name__ == '__main__':
    main()
Buggy code:
s = str(input())
n = len(s)
ans = [0] * n
tmp = -1
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    a=i-tmp    
    if i==n-2:
      a+=1
    tmp=i
    ans[i]+=-(-a//2)
    ans[i+1]+=a//2
  elif s[i]=='L' and s[i+1]=='R':
    a=i-tmp
    ans[tmp]+= a//2
    ans[tmp+1]+= -(-a//2)
    tmp=i
  elif i==n-2:
    a=n-tmp-1
    ans[tmp]+= a//2
    ans[tmp+1]+= -(-a//2)
print(ans)

Fixed code:
s = str(input())
n = len(s)
ans = [0] * n
tmp = -1
for i in range(n-1):
  if s[i]=='R' and s[i+1]=='L':
    a=i-tmp    
    if i==n-2:
      ans[i+1]+=1
    tmp=i
    ans[i]+=-(-a//2)
    ans[i+1]+=a//2
  elif s[i]=='L' and s[i+1]=='R':
    a=i-tmp
    ans[tmp]+= a//2
    ans[tmp+1]+= -(-a//2)
    tmp=i
  elif i==n-2:
    a=n-tmp-1
    ans[tmp]+= a//2
    ans[tmp+1]+= -(-a//2)
print(*ans)
Buggy code:
s = input()
res = [0] * len(s)
cnt = 0
for i in range(len(s)):
    if s[i] == "R":
        cnt += 1
    else:
        res[i-1] += (cnt+1)//2
        res[i] += cnt//2
        cnt = 0
cnt = 0
for i in range(1, len(s)+1):
    if s[-i] == "L":
        cnt += 1
    else:
        res[i] += cnt//2
        res[-i+1] += (cnt+1)//2
        cnt = 0
print(*res)

Fixed code:
s = input()
res = [0] * len(s)
cnt = 0
for i in range(len(s)):
    if s[i] == "R":
        cnt += 1
    else:
        res[i-1] += (cnt+1)//2
        res[i] += cnt//2
        cnt = 0
cnt = 0
for i in range(1, len(s)+1):
    if s[-i] == "L":
        cnt += 1
    else:
        res[-i] += cnt//2
        res[-i+1] += (cnt+1)//2
        cnt = 0
print(*res)
Buggy code:
# -*- coding: utf-8 -*-
S=input()
switch=0
temp=[0]
j=0
ans=[0]*(len(S))
for i in range(len(S)):
    if S[i]=="L" and switch==0:
        switch=1
        temp.append(i)
        j=j+1
        ans[i-1]=ans[i-1]+(i-1-temp[j-1])//2+1
        ans[i]=ans[i]+(i-temp[j-1])//2+1
    elif S[i]=="R" and switch==1:
        switch=0
        temp.append(i)
        j=j+1
        ans[temp[j-1]-1]=ans[temp[j-1]-1]+(i-1-(temp[j-1]-1))//2
        ans[temp[j-1]]=ans[temp[j-1]]+(i-1-temp[j-1])//2
if temp[j]!=len(S)-1:
    if (len(S)-1-temp[j])%2!=0:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2+1
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
    else:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
print(ans)

Fixed code:
# -*- coding: utf-8 -*-
S=input()
switch=0
temp=[0]
j=0
ans=[0]*(len(S))
for i in range(len(S)):
    if S[i]=="L" and switch==0:
        switch=1
        temp.append(i)
        j=j+1
        ans[i-1]=ans[i-1]+(i-1-temp[j-1])//2+1
        ans[i]=ans[i]+(i-temp[j-1])//2+1
    elif S[i]=="R" and switch==1:
        switch=0
        temp.append(i)
        j=j+1
        ans[temp[j-1]-1]=ans[temp[j-1]-1]+(i-1-(temp[j-1]-1))//2
        ans[temp[j-1]]=ans[temp[j-1]]+(i-1-temp[j-1])//2
if temp[j]!=len(S)-1:
    if (len(S)-1-temp[j])%2!=0:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2+1
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
    else:
        ans[temp[j]-1]=ans[temp[j]-1]+(len(S)-1-temp[j])//2
        ans[temp[j]]=ans[temp[j]]+(len(S)-1-temp[j])//2
print(" ".join([str(i) for i in ans]))
Buggy code:
# ABC136d
import sys
import re
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()
l = re.findall("R+L+", s)
ans = []

# print(l)

for i in l:
    R = math.ceil((i.count("R")-1)/2) + math.ceil(i.count("L")/2)
    L = math.ceil(i.count("R")/2) + math.ceil((i.count("L")-1)/2)
    #print(i, R, L)
    for j in range(len(i)):
        if (i[j] == "R" and i[j + 1] == "L"):
            ans.append(L)
            ans.append(R)
            j += 1
        elif(not(i[j] == "L" and i[j - 1] == "R")):
            ans.append(0)
print(ans)

Fixed code:
# ABC136d
import sys
import re
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = input()
l = re.findall("R+L+", s)
ans = []

# print(l)

for i in l:
    R = math.ceil((i.count("R")-1)/2) + math.ceil(i.count("L")/2)
    L = math.ceil(i.count("R")/2) + math.ceil((i.count("L")-1)/2)
    #print(i, R, L)
    for j in range(len(i)):
        if (i[j] == "R" and i[j + 1] == "L"):
            ans.append(L)
            ans.append(R)
            j += 1
        elif(not(i[j] == "L" and i[j - 1] == "R")):
            ans.append(0)
print(*ans)
Buggy code:
S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 2:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))

Fixed code:
S = input()

s_list = S.split("LR")
all_list = []

for idx, s in enumerate(s_list):
    if len(s_list) > 1:
        if idx != 0 and idx != len(s_list)-1:
            s = "R" + s + "L"
        elif idx == 0:
            s = s + "L"
        elif idx == len(s_list)-1:
            s = "R" + s
    s_len = len(s)
    R_count = s.count('R')
    L_count = s.count('L')
    R_list = [0 for _ in range(R_count)]
    L_list = [0 for _ in range(L_count)]

    if s_len % 2 == 0:
        R_list[R_count - 1] = s_len // 2
        L_list[0] = s_len // 2

    else:
        if R_count % 2 == 1:
            R_list[R_count - 1] = s_len - (s_len // 2)
            L_list[0] = s_len // 2
        else:
            R_list[R_count - 1] = s_len // 2
            L_list[0] = s_len - (s_len // 2)

    all_list.extend(R_list)
    all_list.extend(L_list)

print(" ".join(map(str, all_list)))
Buggy code:
li = list(input())

n = len(li)

ans = [0 for _ in range(n)]

rcnt = 0
lcnt = 0
ridx = 0
lidx = 0

for i in range(1,n):
    if li[i-1]=='R':
        rcnt += 1
        if li[i]=='L':
            ridx = i-1
            lidx = i
    if li[i-1]=='L':
        lcnt += 1
        if li[i]=='R' or i==n-1:
            if i==n-1:
                lcnt += 1
            ans[ridx] = (rcnt+1)//2 + lcnt//2
            ans[lidx] = (lcnt+1)//2 + rcnt//2
            rcnt = 0
            lcnt = 0

print(ans)

Fixed code:
li = list(input())

n = len(li)

ans = [0 for _ in range(n)]

rcnt = 0
lcnt = 0
ridx = 0
lidx = 0

for i in range(1,n):
    if li[i-1]=='R':
        rcnt += 1
        if li[i]=='L':
            ridx = i-1
            lidx = i
            if i==n-1:
                lcnt += 1
                ans[ridx] = (rcnt+1)//2 + lcnt//2
                ans[lidx] = (lcnt+1)//2 + rcnt//2
                rcnt = 0
                lcnt = 0
    if li[i-1]=='L':
        lcnt += 1
        if li[i]=='R' or i==n-1:
            if i==n-1:
                lcnt += 1
            ans[ridx] = (rcnt+1)//2 + lcnt//2
            ans[lidx] = (lcnt+1)//2 + rcnt//2
            rcnt = 0
            lcnt = 0

print(*ans)
Buggy code:
S = input()
l = [0]*len(S)

left,right,bol = 0,0,0
for i in range(len(S)):
    if bol == 0:
        if S[i] == "R":
            left += 1
        else:
            bol = 1
            right += 1
            j = i
    else:
        if S[i] == "L":
            right += 1
        else:
            l[j-1] = -(-left//2) + right//2
            l[j] = left//2 + -(-right//2)
            left,right,bol = 0,1,0

l[j-1] = -(-left//2) + right//2
l[j] = left//2 + -(-right//2)
print(*l)

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

left,right,bol = 0,0,0
for i in range(len(S)):
    if bol == 0:
        if S[i] == "R":
            left += 1
        else:
            bol = 1
            right += 1
            j = i
    else:
        if S[i] == "L":
            right += 1
        else:
            l[j-1] = -(-left//2) + right//2
            l[j] = left//2 + -(-right//2)
            left,right,bol = 1,0,0

l[j-1] = -(-left//2) + right//2
l[j] = left//2 + -(-right//2)
print(*l)
Buggy code:
# AtCoder
S = input()
N = len(S)

ans = [1]*N

for i in range(N-2):
    if S[i:i+2] == "RR":
        ans[i+2] += ans[i]
        ans[i] = 0

for i in reversed(range(1, len(ans)-1)):
    if S[i-1:i+1] == "LL":
        ans[i-2] += ans[i]
        ans[i] = 0

print(" ".join(map(str, ans)))


Fixed code:
# AtCoder
S = input()
N = len(S)

ans = [1]*N
ans_n = len(ans)

for i in range(N-2):
    if S[i:i+2] == "RR":
        ans[i+2] += ans[i]
        ans[i] = 0

for i in range(ans_n-1, 1, -1):
    if S[i-1:i+1] == "LL":
        ans[i-2] += ans[i]
        ans[i] = 0

print(" ".join(map(str, ans)))
Buggy code:
def solve(string):
    n = len(string)
    ans = [0] * n

    def op(string, ans, forward=True):
        count = 0
        check = "R" if forward else "L"
        for i, a in enumerate(string[::2 * forward - 1]):
            if a == check:
                count += 1
                continue
            if count > 0:
                print("%d %s %d" % (i, a, count))
                if forward:
                    ans[i] += count // 2
                    ans[i - 1] += (count + 1) // 2
                else:
                    ans[n - i - 1] += count // 2
                    ans[n - i] += (count + 1) // 2
                count = 0
        return ans

    ans = op(string, ans, True)
    return " ".join([str(a) for a in op(string, ans, False)])


if __name__ == '__main__':
    print(solve(input()))


Fixed code:
def solve(string):
    n = len(string)
    ans = [0] * n

    def op(string, ans, forward=True):
        count = 0
        check = "R" if forward else "L"
        for i, a in enumerate(string[::2 * forward - 1]):
            if a == check:
                count += 1
                continue
            if count > 0:
                if forward:
                    ans[i] += count // 2
                    ans[i - 1] += (count + 1) // 2
                else:
                    ans[n - i - 1] += count // 2
                    ans[n - i] += (count + 1) // 2
                count = 0
        return ans

    ans = op(string, ans, True)
    return " ".join([str(a) for a in op(string, ans, False)])


if __name__ == '__main__':
    print(solve(input()))
Buggy code:
S = list(input())
pair = []
cnt = 0
now = S[0]
s, t = 0, 0
for i in range(1, len(S)-1):
  
  if now == 'R' and S[i+1] == 'L':
    pair += [[i, i+1]]
    now = 'L'
  if now == 'L' and S[i+1] == 'R':
    pair[-1] += [t+1-s+1]
    now = 'R'
    s = t+2
  t += 1

pair[-1] += [t+1-s+1]
result = [0]*len(S)
for a, b, p in pair:
  if p % 2 == 0:
    result[a] = p // 2
    result[b] = p // 2
  else:
    result[a] = p // 2 + 1
    result[b] = p // 2
result = list(map(str, result))
print(" ".join(result))

Fixed code:
S = list(input())
pair = []
cnt = 0
now = S[0]
if len(S) == 2:
  print(1, 1)
  exit()
s, t = 0, 0
for i in range(len(S)-1):
  if now == 'R' and S[i+1] == 'L':
    pair += [[i, i+1]]
    now = 'L'
  if now == 'L' and S[i+1] == 'R':
    pair[-1] += [s, t]
    now = 'R'
    s = t+1
  t += 1


pair[-1] += [s, t]
result = [0]*len(S)
for a, b, s, t in pair:
  p = t - s + 1
  if p % 2 == 0:
    result[a] = p // 2
    result[b] = p // 2
  else:
    a_even = (a-s)//2 + (t-a)//2 + 1
    b_even = p-a_even
    result[a] = a_even
    result[b] = b_even
result = list(map(str, result))
print(" ".join(result))
Buggy code:
strr = input().strip()
n = len(strr)

last_pair = -1
count = [0, 0]
ans = [0]*n

cur ="R"

for i in range(n):
	if strr[i]==cur:
		count[i%2] += 1
	else:
		if strr[i]=="L":
			last_pair = i - 1
			ans[last_pair] += count[last_pair%2]
			ans[last_pair+1] += count[(last_pair+1)%2]
		else:
			ans[last_pair] += count[last_pair%2]
			ans[last_pair+1] += count[(last_pair+1)%2]
		count = [0, 0]
		count[i%2] += 1
		cur = strr[i]
print(*ans)

Fixed code:
strr = input().strip()
n = len(strr)

last_pair = -1
count = [0, 0]
ans = [0]*n

cur ="R"

for i in range(n):
	if strr[i]==cur:
		count[i%2] += 1
	else:
		if strr[i]=="L":
			last_pair = i - 1
			ans[last_pair] += count[last_pair%2]
			ans[last_pair+1] += count[(last_pair+1)%2]
		else:
			ans[last_pair] += count[last_pair%2]
			ans[last_pair+1] += count[(last_pair+1)%2]
		count = [0, 0]
		count[i%2] += 1
		cur = strr[i]
ans[last_pair] += count[last_pair%2]
ans[last_pair+1] += count[(last_pair+1)%2]
print(*ans)
Buggy code:
s = [i for i in  list(input())]
x = 0
i = 0
a = []
result = []
while x < len(s)-1:
    while s[x] == s[i]:
        i += 1
        if i > len(s)-1:
            break
    a.append([s[x],int(i-x)])
    x = i
    print(a)

for p in range(len(a)):
    if a[p][0] == 'R':
        n = 0
        n = [0 for q in range(a[p][1]+1)]
        result.extend(n)
        result[len(result)-2] += a[p][1]//2+a[p][1]%2
        result[len(result)-1] += a[p][1]//2
    elif a[p][0] == 'L':
        result[len(result)-2] += a[p][1]//2
        result[len(result)-1] += a[p][1]%2+a[p][1]//2
        n = 0
        n = [0 for q in range(a[p][1]-1)]
        result.extend(n)
print(' '.join(map(str, result)))

Fixed code:
s = [i for i in  list(input())]
x = 0
i = 0
a = []
result = []
while x < len(s)-1:
    while s[x] == s[i]:
        i += 1
        if i > len(s)-1:
            break
    a.append([s[x],int(i-x)])
    x = i
if a[-1][0] != 'L':
    a.append(['L',1])
for p in range(len(a)):
    if a[p][0] == 'R':
        result.extend([0]*(a[p][1]+1))
        result[len(result)-2] += a[p][1]//2+a[p][1]%2
        result[len(result)-1] += a[p][1]//2
    elif a[p][0] == 'L':
        result[len(result)-2] += a[p][1]//2
        result[len(result)-1] += a[p][1]%2+a[p][1]//2
        result.extend([0]*(a[p][1]-1))
print(' '.join(map(str, result)))
Buggy code:
pattern = input()

temp = [0] * len(pattern)
ans = []

while "LR" in pattern:
    pR = pattern.find("RL")
    pL = pattern.find("LR")
    temp = [0] * (pL+1)
    for i in range(pR-1):
        temp[i] = 0
    if (pL+1)%2 == 0:
        temp[pR] = int((pL+1)/2) 
        temp[pR+1] = int((pL+1)/2)
    else:
        if pR%2 == 0:
            temp[pR] = int(pL/2+1) 
            temp[pR+1] = int(pL/2)
        else:
            temp[pR+1] = int(pL/2) 
            temp[pR] = int(pL/2 + 1)
    ans += temp
    pattern = pattern[pattern.find("LR")+1:len(pattern)]

pR = pattern.find("RL")
pL = len(pattern)-1
temp = [0] * (pL+1)
for i in range(pR-1):
    temp[i] = 0
if (pL+1)%2 == 0:
    temp[pR] = int((pL+1)/2) 
    temp[pR+1] = int((pL+1)/2)
else:
    if pR%2 == 0:
        temp[pR] = int(pL/2+1) 
        temp[pR+1] = int(pL/2)
    else:
        temp[pR+1] = int(pL/2) 
        temp[pR] = int(pL/2 + 1)
ans += temp

print(" ".join(map(str,ans)))

Fixed code:
pattern = input()

temp = [0] * len(pattern)
ans = []

while "LR" in pattern:
    pR = pattern.find("RL")
    pL = pattern.find("LR")
    temp = [0] * (pL+1)
    for i in range(pR-1):
        temp[i] = 0
    if (pL+1)%2 == 0:
        temp[pR] = int((pL+1)/2) 
        temp[pR+1] = int((pL+1)/2)
    else:
        if pR%2 == 0:
            temp[pR] = int(pL/2+1) 
            temp[pR+1] = int(pL/2)
        else:
            temp[pR+1] = int(pL/2+1) 
            temp[pR] = int(pL/2)
    ans += temp
    pattern = pattern[pattern.find("LR")+1:len(pattern)]

pR = pattern.find("RL")
pL = len(pattern)-1
temp = [0] * (pL+1)
for i in range(pR-1):
    temp[i] = 0
if (pL+1)%2 == 0:
    temp[pR] = int((pL+1)/2) 
    temp[pR+1] = int((pL+1)/2)
else:
    if pR%2 == 0:
        temp[pR] = int(pL/2+1) 
        temp[pR+1] = int(pL/2)
    else:
        temp[pR+1] = int(pL/2+1) 
        temp[pR] = int(pL/2)
ans += temp

print(" ".join(map(str,ans)))