Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    #A, B, C = map(int, input().split())
    #N = int(input())
    #Hs = list(map(int, input().split()))

    S = input().strip()
    result = [0] * len(S)

    nearest_R = -1
    nearest_L = len(S) + 1
    for i in range(len(S)):
        if S[i] == 'R':
            if nearest_R > i:
                j = nearest_R
            else:
                for j in range(i+1, len(S)):
                    if S[j] == 'L':
                        break
            dist = j - i
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j-1] += 1
        else:
            # S[i] == 'L'
            if nearest_L < i:
                j = nearest_L
            else:
                for k in range(1, i+1):
                    j = i - k
                    if S[j] == 'R':
                        break
            dist = i - j
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j+1] += 1

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


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re
import bisect

BIGNUM = 10 ** 9 + 7

def main():
    #A, B, C = map(int, input().split())
    #N = int(input())
    #Hs = list(map(int, input().split()))

    S = input().strip()
    result = [0] * len(S)

    L_list, R_list = {}, {}
    prev_L, prev_R = [], []
    for i in range(len(S)):
        if S[i] == 'L':
            for j in prev_L:
                L_list[j] = i
            prev_L = []
        else:
            prev_L.append(i)
    for i in range(len(S)):
        i = len(S) - 1 - i
        if S[i] == 'R':
            for j in prev_R:
                R_list[j] = i
            prev_R = []
        else:
            prev_R.append(i)

    for i in range(len(S)):
        if S[i] == 'R':
            j = L_list[i]
            dist = j - i
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j-1] += 1
        else:
            # S[i] == 'L'
            j = R_list[i]
            dist = i - j
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j+1] += 1

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


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    #A, B, C = map(int, input().split())
    #N = int(input())
    #Hs = list(map(int, input().split()))

    S = input().strip()
    result = [0] * len(S)

    for i in range(len(S)):
        if S[i] == 'R':
            for j in range(i+1, len(S)):
                if S[j] == 'L':
                    break
            dist = j - i
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j-1] += 1
        else:
            # S[i] == 'L'
            for k in range(1, i+1):
                j = i - k
                if S[j] == 'R':
                    break
            dist = k
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j+1] += 1

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


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re
import bisect

BIGNUM = 10 ** 9 + 7

def main():
    #A, B, C = map(int, input().split())
    #N = int(input())
    #Hs = list(map(int, input().split()))

    S = input().strip()
    result = [0] * len(S)

    L_list, R_list = {}, {}
    prev_L, prev_R = [], []
    for i in range(len(S)):
        if S[i] == 'L':
            for j in prev_L:
                L_list[j] = i
            prev_L = []
        else:
            prev_L.append(i)
    for i in range(len(S)):
        i = len(S) - 1 - i
        if S[i] == 'R':
            for j in prev_R:
                R_list[j] = i
            prev_R = []
        else:
            prev_R.append(i)

    for i in range(len(S)):
        if S[i] == 'R':
            j = L_list[i]
            dist = j - i
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j-1] += 1
        else:
            # S[i] == 'L'
            j = R_list[i]
            dist = i - j
            if dist % 2 == 0:
                result[j] += 1
            else:
                result[j+1] += 1

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


if __name__ == '__main__':
    main()