Problem p02954 (python)

Fixed submission:
def resolve():
    line = input()
    result = [0] * len(line)

    r_odd = 0
    r_even = 0
    for i in range(len(line)):
        if line[i] == 'L':
            if i % 2 == 0:
                result[i] += r_even
                result[i-1] += r_odd
            else:
                result[i] += r_odd
                result[i-1] += r_even
            r_odd = 0
            r_even = 0
        elif line[i] == 'R':
            if i % 2 == 0:
                r_even += 1
            else:
                r_odd += 1
    l_odd = 0
    l_even = 0
    for i in range(len(line)-1, -1, -1):
        if line[i] == 'R':
            if i % 2 == 0:
                result[i] += l_even
                result[i+1] += l_odd
            else:
                result[i] += l_odd
                result[i+1] += l_even
            l_odd = 0
            l_even = 0
        elif line[i] == 'L':
            if i % 2 == 0:
                l_even += 1
            else:
                l_odd += 1

    print(*result)
    
resolve()

Buggy submission (verdict: Runtime Error):
import numpy as np


class Okojo:
    def __init__(self, line):
        self.line = line
        self.bool = np.array([], dtype=bool)
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.bool = np.append(self.bool, True)
            else:
                self.bool = np.append(self.bool, False)

    def get_l(self):
        return self.bool

    def get_r(self):
        return np.logical_not(self.bool)

    def get_next(self, state):
        l = state.copy()
        r = state.copy()
        l[self.get_r()] = 0.
        r[self.get_l()] = 0.
        l = np.roll(l, -1)
        r = np.roll(r, 1)
        return l + r


def resolve():
    line = input()

    okojo = Okojo(line)

    now = np.ones(len(line), dtype=int)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if np.all(before1 == now):
            break
        elif np.all(before2 == now):
            if i % 2 == 0:
                now = before1
            break

    li = now.tolist()
    print(*li)


resolve()

Buggy submission (verdict: Runtime Error):
import sys

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


def resolve():
    line = sys.stdin.readline()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)


resolve()

Buggy submission (verdict: Runtime Error):
import sys
from io import StringIO
import unittest

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


def resolve():
    input = sys.stdin.readline
    line = input()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)
    
resolve()

Buggy submission (verdict: Runtime Error):
import sys

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


def resolve():
    input = sys.stdin.readline
    line = input()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)
resolve()

Buggy submission (verdict: Runtime Error):
import sys

class Okojo:
    def __init__(self, line):
        self.line = line
        self.l = []
        self.r = []
        self.get_lr()

    def get_lr(self):
        for i in range(len(self.line)):
            if self.line[i] == 'L':
                self.l.append(i)
            else:
                self.r.append(i)

    def get_next(self, state):
        nex = [0] * len(self.line)
        for i in range(len(self.l)):
            nex[self.l[i] - 1] += state[self.l[i]]
        for i in range(len(self.r)):
            nex[self.r[i] + 1] += state[self.r[i]]
        return nex


    input = sys.stdin.readline
    line = input()

    okojo = Okojo(line)

    now = [1] * len(line)
    before1 = now
    for i in range(10 ** 100):
        before2 = before1
        before1 = now
        now = okojo.get_next(before1)
        if before1 == now:
            break
        elif before2 == now:
            if i % 2 == 0:
                now = before1
            break

    print(*now)