qyliang/CodeNanoFix huggingface dataset:
Buggy code:
s = input()
n = len(s)
ans_list = [0] * n

cnt_odd = 0
cnt_even = 0

for i in range(n):
    if i == n-1:
        break
    if s[i] ==  'R' and s[i+1]=='R' and i%2==0:
        cnt_odd +=1
    elif s[i] ==  'R' and s[i+1]=='R' and i%2==1:
        cnt_even +=1
    elif s[i] =='R' and i%2==0:
        ans_list[i] += cnt_even +1
        ans_list[i+1] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[i] =='R' and i%2==1:
        ans_list[i] += cnt_odd +1
        ans_list[i+1] += cnt_even
        cnt_even = 0
        cnt_odd = 0

cnt_odd = 0
cnt_even = 0
for i in range(n):
    if i ==n-1:
        break
    if s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==0:
        cnt_odd +=1
    elif s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==1:
        cnt_even +=1
    elif s[-i-1] =='L' and i%2==0:
        ans_list[-i-1] += cnt_even +1
        ans_list[-i-2] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[-i-1] =='L' and i%2==1:
        ans_list[-i-1] += cnt_odd +1 
        ans_list[-i-2] += cnt_even
        cnt_even = 0
        cnt_odd = 0

print(' '.join(map(str,ans_list)))

Fixed code:
s = input()
n = len(s)
ans_list = [0] * n

cnt_odd = 0
cnt_even = 0

for i in range(n):
    if i == n-1:
        break
    if s[i] ==  'R' and s[i+1]=='R' and i%2==1:
        cnt_odd +=1
    elif s[i] ==  'R' and s[i+1]=='R' and i%2==0:
        cnt_even +=1
    elif s[i] =='R' and i%2==0:
        ans_list[i] += cnt_even +1
        ans_list[i+1] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[i] =='R' and i%2==1:
        ans_list[i] += cnt_odd +1
        ans_list[i+1] += cnt_even
        cnt_even = 0
        cnt_odd = 0

cnt_odd = 0
cnt_even = 0
for i in range(n):
    if i ==n-1:
        break
    if s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==1:
        cnt_odd +=1
    elif s[-i-1] ==  'L' and s[-i-2]=='L' and i%2==0:
        cnt_even +=1
    elif s[-i-1] =='L' and i%2==0:
        ans_list[-i-1] += cnt_even +1
        ans_list[-i-2] += cnt_odd
        cnt_even = 0
        cnt_odd = 0
    elif s[-i-1] =='L' and i%2==1:
        ans_list[-i-1] += cnt_odd +1 
        ans_list[-i-2] += cnt_even
        cnt_even = 0
        cnt_odd = 0

print(' '.join(map(str,ans_list)))
Buggy code:
def resolve():
    s = input()
    ans = [0]*len(s)
    start = -1
    center = -1
    end = -1
    for i in range(len(s)):

        if i == 0:
            start = i
        elif s[i-1] == "L" and s[i] == "R":
            start = i
        if s[i] == "R" and s[i+1] == "L":
            center = i
        if i == len(s)-1:
            end = i
        elif s[i] == "L" and s[i+1] == "R":
            end = i

        if 0 <= start <= center <= end:
            if (end-start) % 2 == 1:
                ans[center] = (end-start+1) // 2
                ans[center+1] = (end-start+1) // 2
            else:
                if (end-center) > (center-start+1):
                    if (end-center) % 2 == 1:
                        ans[center] = center-start+1
                        ans[center+1] = end-center
                    else:
                        ans[center+1] = center-start+1
                        ans[center] = end-center
                else:
                    if (center-start+1)%2 == 0:
                        ans[center] = end-center
                        ans[center+1] = center-start+1
                    else:
                        ans[center+1] = end-center
                        ans[center] = center-start+1

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

Fixed code:
def resolve():
    s = input()
    ans = [0]*len(s)
    start = -1
    center = -1
    end = -1
    for i in range(len(s)):
        if i == 0:
            start = i
        elif s[i-1] == "L" and s[i] == "R":
            start = i
        if s[i] == "R" and s[i+1] == "L":
            center = i
        if i == len(s)-1:
            end = i
        elif s[i] == "L" and s[i+1] == "R":
            end = i

        if 0 <= start <= center <= end:
            if (end-start) % 2 == 1:
                ans[center] = (end-start+1) // 2
                ans[center+1] = (end-start+1) // 2
            else:
                total = end-start+1
                if (end-center) > (center-start+1):
                    if (end-center) % 2 == 1:

                        ans[center] = (total-1)//2
                        ans[center+1] = (total+1)//2
                    else:
                        ans[center+1] = (total-1)//2
                        ans[center] = (total+1)//2
                else:
                    if (center-start+1)%2 == 0:
                        ans[center] = (total-1)//2
                        ans[center+1] = (total+1)//2
                    else:
                        ans[center+1] = (total-1)//2
                        ans[center] = (total+1)//2

    print(" ".join(map(str, ans)))
resolve()
Buggy code:
S = input()
S = list(S)
N = [1 for i in range(len(S))]


pre = ""
tmp_r = 0
tmp_l = 0
Ri = 0
Li = 0

for i in range(len(S)):
    if pre == "":
        pre = S[i]
    elif i == len(S)-1:
        tmp_l += 1
        N[i] = 0
        N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
        N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
    elif pre == "R":
        if S[i] == "R":
            tmp_r += 1
            N[i-1] = 0
        elif S[i] == "L":
            Ri = i - 1
            Li = i
            pre = S[i]
    elif pre == "L":
        if S[i] == "L":
            tmp_l += 1
            N[i] = 0
        elif S[i] == "R":
            pre = S[i]
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
            tmp_l = 0
            tmp_r = 0
            Ri = 0
            Li = 0

for i in range(len(N)):
    if i == len(N)-1:
        print(N[i])
    else:
        print(N[i], end=" ")


Fixed code:
S = input()
S = list(S)
N = [1 for i in range(len(S))]


pre = ""
tmp_r = 0
tmp_l = 0
Ri = 0
Li = 0

for i in range(len(S)):
    if pre == "":
        pre = S[i]
    elif i == len(S)-1:
        if pre == "L":
            tmp_l += 1
            N[i] = 0
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
        elif pre == "R":
            Ri = i - 1
            Li = i
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
    elif pre == "R":
        if S[i] == "R":
            tmp_r += 1
            N[i-1] = 0
        elif S[i] == "L":
            Ri = i - 1
            Li = i
            pre = S[i]
    elif pre == "L":
        if S[i] == "L":
            tmp_l += 1
            N[i] = 0
        elif S[i] == "R":
            pre = S[i]
            N[Ri] += (tmp_r // 2) + (tmp_l // 2 + tmp_l % 2)
            N[Li] += (tmp_r // 2 + tmp_r % 2) + (tmp_l // 2)
            tmp_l = 0
            tmp_r = 0
            Ri = 0
            Li = 0

for i in range(len(N)):
    if i == len(N)-1:
        print(N[i])
    else:
        print(N[i], end=" ")
Buggy code:
s=input()+'R'
l=len(s)
ans=[0]*(l-1)
rcnt=0
lcnt=0
rpos=0
lpos=0
flag=0
for i in range(l):
  if s[i]=='R':
    if flag==1:
      if rcnt%2==0:
        ans[rpos]+=rcnt//2+1
        ans[lpos]+=rcnt//2
      else:
        ans[rpos]+=rcnt//2
        ans[lpos]+=rcnt//2
      if lcnt%2==0:
        ans[rpos]+=lcnt//2
        ans[lpos]+=lcnt//2
      else:
        ans[rpos]+=lcnt//2
        ans[lpos]+=lcnt//2+1
      rcnt=0
      lcnt=0
    flag=0
    rcnt+=1
    rpos=i
  elif s[i]=='L':
    if flag==0:
      lpos=i
    lcnt+=1
    flag=1
print(*ans)

Fixed code:
s=input()+'R'
l=len(s)
ans=[0]*(l-1)
rcnt=0
lcnt=0
rpos=0
lpos=0
flag=0
for i in range(l):
  if s[i]=='R':
    if flag==1:
      if rcnt%2==0:
        ans[lpos]+=rcnt//2
        ans[rpos]+=rcnt//2
      else:
        ans[lpos]+=rcnt//2
        ans[rpos]+=1+rcnt//2
      if lcnt%2==0:
        ans[lpos]+=lcnt//2
        ans[rpos]+=lcnt//2
      else:
        ans[lpos]+=1+lcnt//2
        ans[rpos]+=lcnt//2
      rcnt=0
      lcnt=0
    flag=0
    rcnt+=1
    rpos=i
  elif s[i]=='L':
    if flag==0:
      lpos=i
    lcnt+=1
    flag=1
print(*ans)
Buggy code:
s=input()
ans=[0]*len(s)
import itertools
i=0
for key,g in itertools.groupby(s):
  num=len(list(g))
  if key=="R":
    i+=num
    ans[num-1]+=num//2
    ans[num]+=(num//2+(num%2>0))
  elif key=="L":
    ans[num-1]+=(num//2+(num%2>0))
    ans[num]+=num//2
    i+=num
  if num>=len(ans):
    break
print(*ans)


Fixed code:
s=input()
ans=[0]*len(s)
import itertools
i=0
for key,g in itertools.groupby(s):
  num=len(list(g))
  if key=="R":
    i+=num
    ans[i-1]+=(num//2+(num%2>0))
    ans[i]+=num//2
  elif key=="L":
    ans[i-1]+=num//2
    ans[i]+=(num//2+(num%2>0))
    i+=num
  if i>=len(ans):
    break
print(*ans)
Buggy code:
import re
RL_list = input()
RL_list = re.findall(r'R*L*',RL_list)
buf = []

for lis in RL_list:
    if len(lis)==2:
        buf.extend([1,1])
    if len(lis)>2:
        r_cnt = lis.count('R')
        if r_cnt % 2 == 1:
            r = len(lis) // 2
        else:
            r = int(len(lis) / 2)
            
        l = len(lis) - r
        
        buf.extend([0]*(r_cnt-1))
        buf.extend([r,l])
        buf.extend([0]*(len(lis)-r_cnt-1))
        
print(" ".join(map(str,buf)))

Fixed code:
import re
RL_list = input()
RL_list = re.findall(r'R*L*',RL_list)
buf = []

for lis in RL_list:
    if len(lis)==2:
        buf.extend([1,1])
    if len(lis)>2:
        r_cnt = lis.count('R')
        l = len(lis) - r_cnt
        if (len(lis) % 2 == 1) & (r_cnt % 2 == 1):
            r = len(lis) // 2 + 1
        #elif (len(lis) % 2 == 1) & (r_cnt % 2 == 0):
        else:
            r = int(len(lis) / 2)
        
        buf.extend([0]*(r_cnt-1))
        buf.extend([r,len(lis)-r])
        buf.extend([0]*(len(lis)-r_cnt-1))
        
print(" ".join(map(str,buf)))
Buggy code:
s = list(input())
ans = [1] * len(s)

for i in range(len(s)):
    if s[i] == 'R':
        ans[i] = ans[i] - 1
        ans[i + 1] = ans[i + 1] + 1
    else:
        ans[i] = ans[i] - 1
        ans[i - 1] = ans[i - 1] + 1

for i in range(len(s)):
    if s[i] == 'R' and s[i + 1] == 'L':
        for j in reversed(range(i)):
            if s[j] != 'R':
                break
            if (i - j) % 2 == 1:
                ans[i] += ans[j]
                ans[j] = 0
            else:
                ans[i + 1] += ans[j]
                ans[j] = 0

        for k in range(i + 2, len(s)):
            if s[k] != 'L':
                break
            if (k - i) % 2 == 1:
                ans[i] += ans[k]
                ans[k] = 0
            else:
                ans[i + 1] += ans[k]
                ans[k] = 0
print(ans)


Fixed code:
s = list(input())
ans = [1] * len(s)

for i in range(len(s)):
    if s[i] == 'R' and s[i + 1] == 'L':
        for j in reversed(range(i)):
            if s[j] != 'R':
                break
            if (i - j) % 2 == 1:
                ans[i] += ans[j]
                ans[j] = 0
            else:
                ans[i + 1] += ans[j]
                ans[j] = 0

        for k in range(i + 2, len(s)):
            if s[k] != 'L':
                break
            if (k - i) % 2 == 1:
                ans[i] += ans[k]
                ans[k] = 0
            else:
                ans[i + 1] += ans[k]
                ans[k] = 0

for i in range(len(s)):
    if s[i] == 'R' and s[i + 1] == 'L':
        temp = ans[i]
        ans[i] = ans[i + 1]
        ans[i + 1] = temp

print(*ans)
Buggy code:
s = input()
cons = 0
ans = [0]*(len(s))
left = 0
right = 0
check1 = True
check2 = False
for i in range(len(s)):
    if check1 == True and s[i] == "L":
        cons = i
        check1 = False
        check2 = True
    if check2 == True and (s[i] == "R" or i == len(s)-1):
        right = i-1
        if i == len(s)-1:
            right += 1
        dum = s[left:right+1]
        dum_index = dum.index("L")
        dum_len = len(dum)
        div,mod = divmod(dum_len,2)
        if dum_index%2 == 0:
            ans[cons] = div+mod
            ans[cons-1] = div
        else:
            ans[cons] = div
            ans[cons-1] = div+mod

        check1 = True
        check2 = False
        left = right+1
print(ans)

Fixed code:
s = input()
cons = 0
ans = [0]*(len(s))
left = 0
right = 0
check1 = True
check2 = False
for i in range(len(s)):
    if check1 == True and s[i] == "L":
        cons = i
        check1 = False
        check2 = True
    if check2 == True and (s[i] == "R" or i == len(s)-1):
        right = i-1
        if i == len(s)-1:
            right += 1
        dum = s[left:right+1]
        dum_index = dum.index("L")
        dum_len = len(dum)
        div,mod = divmod(dum_len,2)
        if dum_index%2 == 0:
            ans[cons] = div+mod
            ans[cons-1] = div
        else:
            ans[cons] = div
            ans[cons-1] = div+mod

        check1 = True
        check2 = False
        left = right+1
print(" ".join(map(str,ans)))
Buggy code:
s = input()

l = []
tmp = 0
d = 'R'
for x in s:
    if x == d:
        tmp += 1
    else:
        l.append(tmp)
        tmp = 1
        d = x
else:
    l.append(tmp)
res = []
for i in range(0, len(l), 2):
    a, b = l[i:i+2]
    c = a + b
    if c % 2 == 0:
        p = q = c // 2
    else:
        p, q = c // 2 + 1, c // 2
        if (a > b and a % 2 == 0) or (a < b and b % 1 == 0):
            p, q = q, p

    res += [0] * (a-1) + [p] + [q] + [0] * (b-1)

print(*res)


Fixed code:
s = input()

l = []
tmp = 0
d = 'R'
for x in s:
    if x == d:
        tmp += 1
    else:
        l.append(tmp)
        tmp = 1
        d = x
else:
    l.append(tmp)
res = []
for i in range(0, len(l), 2):
    a, b = l[i:i+2]
    c = a + b
    if c % 2 == 0:
        p = q = c // 2
    else:
        p, q = c // 2 + 1, c // 2
        if (a > b and a % 2 == 0) or (a < b and b % 2 == 1):
            p, q = q, p

    res += [0] * (a-1) + [p] + [q] + [0] * (b-1)

print(*res)
Buggy code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)

masu = []
char = ""
for i, s in enumerate(S):
    if char == "":
        char += s
        continue
    if char[-1] == s:
        char += s
        continue
    if char[-1] != s:
        masu.append(len(char))
        char = s
        continue
if char:
    masu.append(len(char))

import math

ans = []
for l, r in zip(*[iter(masu)]*2):
    n = len(ans)
    pos_l = n + l
    pos_r = pos_l + 1
    l_num = math.ceil(l / 2) + r // 2
    r_num = l // 2 + math.ceil(r / 2)
    for _ in range(l-1):
        ans.append(0)
    ans.append(l_num)
    ans.append(r_num)
    for _ in range(r-1):
        ans.append(0)

print(ans)


    





Fixed code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = list(input())
N = len(S)

masu = []
char = ""
for i, s in enumerate(S):
    if char == "":
        char += s
        continue
    if char[-1] == s:
        char += s
        continue
    if char[-1] != s:
        masu.append(len(char))
        char = s
        continue
if char:
    masu.append(len(char))

import math

ans = []
for l, r in zip(*[iter(masu)]*2):
    n = len(ans)
    pos_l = n + l
    pos_r = pos_l + 1
    l_num = math.ceil(l / 2) + r // 2
    r_num = l // 2 + math.ceil(r / 2)
    for _ in range(l-1):
        ans.append(0)
    ans.append(l_num)
    ans.append(r_num)
    for _ in range(r-1):
        ans.append(0)

print(*ans)
Buggy code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
aa = []
for i,t in enumerate(s):
    if i == 0:
        tmp = t
        cnt = 1
        continue
    if tmp != t:
        aa.append(cnt)
        cnt = 1
        tmp = t
    else:
        cnt += 1
aa.append(cnt)
# print(aa)
res = [0] * n
cnt = 0
for i in range(len(aa))[::2]:
    l = aa[i]; r = aa[i+1]
    av = (l+r)//2
    if (l%2 and r%2) or (l%2==0 and r%2):
        res[cnt+l-1] = av
        res[cnt+l] = av
    else:
        if l%2:
            res[cnt+l-1] = av+1
            res[cnt+l] = av
        else:
            res[cnt+l-1] = av
            res[cnt+l] = av+1
    cnt += l+r
print(*res)

Fixed code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
aa = []
for i,t in enumerate(s):
    if i == 0:
        tmp = t
        cnt = 1
        continue
    if tmp != t:
        aa.append(cnt)
        cnt = 1
        tmp = t
    else:
        cnt += 1
aa.append(cnt)
# print(aa)
res = [0] * n
cnt = 0
for i in range(len(aa))[::2]:
    l = aa[i]; r = aa[i+1]
    av = (l+r)//2
    if (l%2 and r%2) or (l%2==0 and r%2==0):
        res[cnt+l-1] = av
        res[cnt+l] = av
    else:
        if l%2:
            res[cnt+l-1] = av+1
            res[cnt+l] = av
        else:
            res[cnt+l-1] = av
            res[cnt+l] = av+1
    cnt += l+r
print(*res)
Buggy code:
import sys,fractions
a = input()
n = len(a)
t = []
ans = [0] * n
cnt = 0
tmp = a[0]
for i in range(n):
    if a[i] == tmp:
       cnt += 1 
    else:
        t.append(cnt)
        tmp = a[i]
        cnt = 1
t.append(cnt)
print(t)
N = len(t)
len = 0
for i in range(N)[::2]:
    tmp_len = t[i] + t[i+1]
    #R
    ans[len + t[i] - 1] += int((t[i]+1)/2)
    ans[len + t[i]] += int(t[i]/2)
    #L
    ans[len + t[i] - 1] += int(t[i+1]/2)
    ans[len + t[i]] += int((t[i+1]+1)/2)
    len += tmp_len
L = [str(i) for i in ans]
print(" ".join(L))

Fixed code:
import sys,fractions
a = input()
n = len(a)
t = []
ans = [0] * n
cnt = 0
tmp = a[0]
for i in range(n):
    if a[i] == tmp:
       cnt += 1 
    else:
        t.append(cnt)
        tmp = a[i]
        cnt = 1
t.append(cnt)
N = len(t)
len = 0
for i in range(N)[::2]:
    tmp_len = t[i] + t[i+1]
    #R
    ans[len + t[i] - 1] += int((t[i]+1)/2)
    ans[len + t[i]] += int(t[i]/2)
    #L
    ans[len + t[i] - 1] += int(t[i+1]/2)
    ans[len + t[i]] += int((t[i+1]+1)/2)
    len += tmp_len
L = [str(i) for i in ans]
print(" ".join(L))
Buggy code:
s = input() + "R"
v = [0 for i in range(len(s)-1)]

even = 0
odd = 0
lrpos = 0
lr = "R"

for i in range(len(s)):
    if lr != s[i]:
        if lr == "R":
            if even == odd:
                v[i-1] += even
                v[i] += odd
            else:
                v[i] += even
                v[i-1] += odd
        else:
            if even == odd:
                v[lrpos] += even
                v[lrpos-1] += odd
            else:
                v[lrpos-1] += even
                v[lrpos] += odd
        
        odd = 0
        even = 0
        lr = s[i]
        lrpos = i

    if even < odd:
        even += 1
    else:
        odd += 1
    
ans = " ".join(v)
print(ans)


Fixed code:
s = input() + "R"
v = [0 for i in range(len(s)-1)]

even = 0
odd = 0
lrpos = 0
lr = "R"

for i in range(len(s)):
    if lr != s[i]:
        if lr == "R":
            if even == odd:
                v[i-1] += even
                v[i] += odd
            else:
                v[i] += even
                v[i-1] += odd
        else:
            if even == odd:
                v[lrpos] += even
                v[lrpos-1] += odd
            else:
                v[lrpos-1] += even
                v[lrpos] += odd
        
        odd = 0
        even = 0
        lr = s[i]
        lrpos = i

    if even < odd:
        even += 1
    else:
        odd += 1
    
ans = " ".join(map(str,v))
print(ans)
Buggy code:
import math
S = list(input())
r = [0] * len(S)
r_count = 1
l_count = 0
pre_s = "R"
for i,s in enumerate(S[1:len(S)]):
    print(i,s)
    if s == "R":
        if l_count > 0:
            # calc
            r[i-l_count+1] = r_count/2 + math.ceil(l_count/2)
            r[i-l_count] = math.ceil(r_count/2) + l_count/2
            r_count = 1
            l_count = 0
        else:
            r_count = r_count + 1
    else:
        l_count = l_count + 1
    #

i = len(S)-1
#calc
r[i-l_count+1] = math.floor(r_count/2) + math.ceil(l_count/2)
r[i-l_count] = math.ceil(r_count/2) + math.floor(l_count/2)
#print
print(r[0],end="")
for i in r[1:len(r)]:
    print(" ",end="")
    print(int(i),end="")
print()

Fixed code:
import math
S = list(input())
r = [0] * len(S)
r_count = 1
l_count = 0
pre_s = "R"
for i,s in enumerate(S[1:len(S)]):
    #print(i,s)
    if s == "R":
        if l_count > 0:
            # calc
            r[i-l_count+1] = math.floor(r_count/2) + math.ceil(l_count/2)
            r[i-l_count] = math.ceil(r_count/2) + math.floor(l_count/2)
            r_count = 1
            l_count = 0
        else:
            r_count = r_count + 1
    else:
        l_count = l_count + 1
    #

i = len(S)-1
#calc
r[i-l_count+1] = math.floor(r_count/2) + math.ceil(l_count/2)
r[i-l_count] = math.ceil(r_count/2) + math.floor(l_count/2)
#print
print(int(r[0]),end="")
for i in r[1:len(r)]:
    print(" ",end="")
    print(int(i),end="")
print()
Buggy code:
s = input()
n = len(s)
s = s.replace('RL','xy')

rls = []
curr_s = 'R'
cnt = 1
ind = 0
for i in range(1,n):
    if s[i] == 'y':
        curr_s = 'y'
        cnt += 1
    elif curr_s == s[i]:
        cnt += 1
    else:
        rls.append((curr_s,cnt,ind))
        ind += cnt
        cnt = 1
        curr_s = s[i]

# if s[-1] != 'y':
rls.append((curr_s,cnt, ind))

print(s)
print(rls)

ans = [0]*n
curr_i = 0
for i in range(len(rls)):
    rl_r = 1
    rl_l = 1
    if rls[i][0] == 'y':
        if rls[i-1][0] == 'R':
            rl_r += rls[i-1][1]//2
            rl_l += (rls[i-1][1]+1)//2
        if i+1 < len(rls) and rls[i+1][0] == 'L':
            rl_l += rls[i+1][1]//2
            rl_r += (rls[i+1][1]+1)//2
        ind = rls[i][2]
        ans[ind] = rl_r
        ans[ind+1] = rl_l


print(*ans)

Fixed code:
s = input()
n = len(s)
s = s.replace('RL','xy')

rls = []
curr_s = 'R'
cnt = 1
ind = 0
for i in range(1,n):
    if s[i] == 'y':
        curr_s = 'y'
        cnt += 1
    elif curr_s == s[i]:
        cnt += 1
    else:
        rls.append((curr_s,cnt,ind))
        ind += cnt
        cnt = 1
        curr_s = s[i]

# if s[-1] != 'y':
rls.append((curr_s,cnt, ind))

# print(s)
# print(rls)

ans = [0]*n
curr_i = 0
for i in range(len(rls)):
    rl_r = 1
    rl_l = 1
    if rls[i][0] == 'y':
        if rls[i-1][0] == 'R':
            rl_r += rls[i-1][1]//2
            rl_l += (rls[i-1][1]+1)//2
        if i+1 < len(rls) and rls[i+1][0] == 'L':
            rl_l += rls[i+1][1]//2
            rl_r += (rls[i+1][1]+1)//2
        ind = rls[i][2]
        ans[ind] = rl_r
        ans[ind+1] = rl_l


print(*ans)