Problem p02954 (python)

Fixed submission:
s = input()

import sys
sys.setrecursionlimit(1000000)
list1 = [0]*len(s)


def r_search(start,index,count):
    if s[index] == "L":
        count -= 1 #RLで計算が始まる為
        if count == 0: #LRLの要な場合
            list1[index-1] += 1
            list1[index] += 1
            return index+1
        elif count %2 != 0: #奇数
            list1[index-1] += count//2 + 1 #このへんの+1は元々のRLの分
            list1[index] += count//2 +1 + 1
            return index+1
        else: #偶数
            list1[index-1] += count//2 + 1
            list1[index] += count//2 + 1
            return index+1
    else:
        return r_search(start,index+1,count+1)
        



def l_search(start,index,count): #start-1がL,-2がRで有ることが決まっている
    if index >= len(s) or s[index] == "R":
        if count %2 != 0: #奇数の場合逆側に１多く入る
            list1[start-2] += count//2+1
            list1[start-1] += count//2
            return index
        else:
            list1[start-2] += count//2
            list1[start-1] += count//2
            return index

    else:
        return l_search(start,index+1,count+1)
i = 0
while True:
    if i >= len(s):
        break
    elif s[i] == "R":
        i = r_search(i,i,0)
    else:
        i = l_search(i,i,0)
print(" ".join(map(str,list1)))

Buggy submission (verdict: Runtime Error):
s = input()

list1 = [0]*len(s)


def r_search(start,index,count):
    if s[index] == "L":
        count -= 1 #RLで計算が始まる為
        if count == 0: #LRLの要な場合
            list1[index-1] += 1
            list1[index] += 1
            return index+1
        elif count %2 != 0: #奇数
            list1[index-1] += count//2 + 1 #このへんの+1は元々のRLの分
            list1[index] += count//2 +1 + 1
            return index+1
        else: #偶数
            list1[index-1] += count//2 + 1
            list1[index] += count//2 + 1
            return index+1
    else:
        return r_search(start,index+1,count+1)
        



def l_search(start,index,count): #start-1がL,-2がRで有ることが決まっている
    if index >= len(s) or s[index] == "R":
        if count %2 != 0: #奇数の場合逆側に１多く入る
            list1[start-2] += count//2+1
            list1[start-1] += count//2
            return index
        else:
            list1[start-2] += count//2
            list1[start-1] += count//2
            return index

    else:
        return l_search(start,index+1,count+1)
i = 0
while True:
    if i >= len(s):
        break
    elif s[i] == "R":
        i = r_search(i,i,0)
    else:
        i = l_search(i,i,0)
print(" ".join(map(str,list1)))

Buggy submission (verdict: Runtime Error):
S = input()
list1 = list(S)

list2 = [0 for i in range(len(list1))]

t = 0 #現在地
coutR = 0
coutL = 0
RLsindex = 0

def countLnum(t,coutL):
        if t+2 >= len(list1):
                return int(coutL)
        elif list1[t+2] == "R" :
                return int(coutL)
        else:
                coutL = countLnum(t+1,coutL+1)
                return coutL


def RLstart(t,coutL):
        list2[t] +=1
        list2[t+1] +=1 #RL部分の初期値はそのままループし続ける
        if coutR %2 ==0:
                list2[t] += int(coutR/2)
                list2[t+1] += int(coutR/2)
        else:
                list2[t] += int(coutR/2 -0.5)
                list2[t+1] += int(coutR/2 +0.5)
        if coutL %2 == 0 :
                list2[t] += int(coutL/2)
                list2[t+1] += int(coutL/2)
        else:
                list2[t] += int(coutL/2 +0.5)
                list2[t+1] += int(coutL/2 -0.5)


while t < len(list1):
        if list1[t] == "R":
                if list1[t+1] == "R":
                        coutR += 1
                        t += 1
                elif list1[t+1] == "L":
                        coutL = countLnum(t,0)
                        RLstart(t,coutL)
                        t+=2 + coutL
                        coutR,coutL = 0,0
s = ""
for i in range(len(list2)):
        s += str(list2[i]) + " "
print(s)

Buggy submission (verdict: Runtime Error):
S = input()
list1 = list(S)

list2 = [0 for i in range(len(list1))]

t = 0 #現在地
coutR = 0
coutL = 0
RLsindex = 0

def countLnum(t,coutL):
        if t+2 >= len(list1):
                return coutL
        elif list1[t+2] == "R" :
                return int(coutL)
        else:
                coutL = countLnum(t+1,coutL+1)
                return coutL


def RLstart(t,coutL):
        list2[t] +=1
        list2[t+1] +=1 #RL部分の初期値はそのままループし続ける
        if coutR %2 ==0:
                list2[t] += int(coutR/2)
                list2[t+1] += int(coutR/2)
        else:
                list2[t] += int(coutR/2 -0.5)
                list2[t+1] += int(coutR/2 +0.5)
        if coutL %2 == 0 :
                list2[t] += int(coutL/2)
                list2[t+1] += int(coutL/2)
        else:
                list2[t] += int(coutL/2 +0.5)
                list2[t+1] += int(coutL/2 -0.5)


while t < len(list1):
        if list1[t] == "R":
                if list1[t+1] == "R":
                        coutR += 1
                        t += 1
                elif list1[t+1] == "L":
                        coutL = countLnum(t,0)
                        RLstart(t,coutL)
                        t+=2 + coutL
                        coutR,coutL = 0,0
s = ""
for i in range(len(list2)):
        s += str(list2[i]) + " "
print(s)