Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math  
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans = ans + math.gcd(math.gcd(a,b),c)
print(ans)        

Fixed submission:
K = int(input())
from math import gcd
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans = ans + gcd(gcd(a,b),c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math  
from functools import reduce
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans = ans + reduce(math.gcd,[a,b,c]) 
print(ans)        

Fixed submission:
K = int(input())
from math import gcd
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            ans = ans + gcd(gcd(a,b),c)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
    l[i-1] += 1
    
al = 0
for i in l:
    al += i*(i-1)//2

for k in range(n):
    print(al - (l[a[k]] - 1))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
for i in a:
    l[i-1] += 1
    
al = 0
for i in l:
    al += i*(i-1)//2

for k in range(n):
    print(al - (l[a[k]-1] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    l = list(input().split())
    if l[0] == '1':
        s = s[::-1]
    else:
        if l[1] == '2':
            s = s + l[2]
        else:
            s = s[::-1] + l[2]
            s = s[::-1]
print(s)

Fixed submission:
from collections import deque
s = input()
q = int(input())
right_side = deque()
left_side = deque()
is_reversed = False
for i in range(q):
    l = list(input().split())
    if l[0] == '1':
        is_reversed = not is_reversed
    else:
        if l[1] == '2':
            if is_reversed == False:
                right_side.append(l[2])
            else:
                left_side.appendleft(l[2])
        else:
            if is_reversed == False:
                left_side.appendleft(l[2])
            else:
                right_side.append(l[2])
ans = ''.join([''.join(left_side),s ,''.join(right_side)])
if is_reversed :
    ans = ans[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [list(input().split()) for i in range(m)]
for num in range(1000):
    if m == 0:
        if n == 1:
            print(0)
            exit()
        else:
            print(10**(n-1))
            exit()    
    for i in range(m):
        if len(str(num)) < n:
            break
        if str(num)[int(l[i][0])-1] != l[i][1]:
            break
    else:
        print(num)
        exit()
print(-1)

Fixed submission:
import math
n = int(input())
print(math.ceil(n/2))
Buggy python submission (verdict: Runtime Error):
#B
from collections import deque
s = deque(list(input()))
cnt = 0
while 1 <= len(s):
    r = s.pop()
    l = s.popleft()
    if r != l:
        cnt += 1
print(cnt)

Fixed submission:
#B
from collections import deque
s = deque(list(input()))
cnt = 0
while 1 < len(s):
    r = s.pop()
    l = s.popleft()
    if r != l:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#B
s = input()
n = len(s)
for i in range(n):
    for j in range(i,n):
        if all('ACGT'.count(c) == 1 for c in s[i:j+1]):
            ans = max(ans, j - i + 1)
print(ans)

Fixed submission:
#B
s = input()
n = len(s)
ans = 0
for i in range(n):
    for j in range(i,n):
        if all('ACGT'.count(c) == 1 for c in s[i:j+1]):
            ans = max(ans, j - i + 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [map(int, input().split())]
count = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            break
            
    else:
        count += 1
        continue
        
    break

print(count)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
while True:
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] = A[i] // 2
        else:
            break
            
    else:
        count += 1
        continue
        
    break
    
print(count)
Buggy python submission (verdict: Runtime Error):
A, B, H, M = map(float, input().split())

import math
PI = math.pi
radA = (2.0 * PI * (H + M / 60.0)) / 12.0
radB = (2.0 * PI * M) / 60.0
print(math.hypot(A * math.cos(radA) - B * math.cos(radB),
                 A * math.sin(radA) - B * math.sin(radB))

Fixed submission:
import math

A, B, H, M = map(int, input().split())

degA = H * 30 + M * 0.5
degB = M * 6
deg = math.radians(degA-degB)
print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(deg)))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
for _ in range(N):
    p = A[p]
    if p in points:
        break
    points.append(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])

Fixed submission:
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
visited = set([p])

for _ in range(N):
    p = A[p]
    if p in visited:
        break
    points.append(p)
    visited.add(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
for _ in range(N):
    p = A[p]
    if p in points:
        break
    points.append(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

head = points[:idx]
cycle = points[idx:]

print(cycle[(K - len(head)) % len(cycle)])

Fixed submission:
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
visited = set([p])

for _ in range(N):
    p = A[p]
    if p in visited:
        break
    points.append(p)
    visited.add(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
for _ in range(N):
    p = A[p]
    if p in points:
        break
    points.append(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

head = len(points[:idx])
cycle = len(points[idx:])

for _ in range((K - head) % cycle):
    p = A[p]

print(p)

Fixed submission:
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
visited = set([p])

for _ in range(N):
    p = A[p]
    if p in visited:
        break
    points.append(p)
    visited.add(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
for _ in range(K):
    p = A[p]
    if p in points:
        break
    points.append(p)

head = len(points[:points.index(p)])
cycle = len(points[points.index(p):])

for _ in range((K - head) % cycle):
    p = A[p]

print(p)

Fixed submission:
N, K = map(int, input().split())
A = [1] + list(map(int, input().split()))

p = 1
points = [p]
visited = set([p])

for _ in range(N):
    p = A[p]
    if p in visited:
        break
    points.append(p)
    visited.add(p)

idx = points.index(p)

if idx > K:
    print(points[K])
    exit()

cycle = points[idx:]

print(cycle[(K - idx) % len(cycle)])
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import itertools

N, M = map(int, input().split())
a = []
for i in range(N):
    a.append(list(map(int, input().split())))

all_list = [i for i in range(N)]
target_list = list(itertools.combinations(all_list, M))

max_total = 0
for indices in target_list:
    kirei = 0
    oishi = 0
    ninki = 0
    for index in indices:
        tmp = a[index]
        kirei += tmp[0]
        oishi += tmp[1]
        ninki += tmp[2]
    tmp_max = abs(kirei) + abs(oishi) + abs(ninki)
    if max_total < tmp_max:
        max_total = tmp_max

print(max_total)



Fixed submission:
# -*- coding: utf-8 -*-
import itertools
import numpy as np

N, M = map(int, input().split())
input_list = []
for i in range(N):
    input_list.append(list(map(int, input().split())))

converted_list = np.empty((0, 8), int)
for i in input_list:
    tmp_list = []
    for k_i in [1, -1]:
        for o_i in [1, -1]:
            for n_i in [1, -1]:
                tmp_list.append(i[0] * k_i + i[1] * o_i + i[2] * n_i)
    converted_list = np.append(converted_list, np.array([tmp_list]), axis=0)

max_total = 0
for i in range(8):
    tmp_total = 0
    indices = np.argsort(converted_list[:, i])[::-1][:M]
    for ii in indices:
        tmp_total += converted_list[:, i][ii]
    if max_total < tmp_total:
        max_total = tmp_total
print(max_total)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
cnt = 1
while True:
    if n ==1:
        break
    n = n // k
    cnt += 1
    if n//k ==1:
        cnt +=1
        break
print(cnt)

Fixed submission:
n, k = map(int, input().split())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


ans = Base_10_to_n(n, k)
print( len(ans) )
Buggy python submission (verdict: Runtime Error):
N = int(input())
list = [map(int, input().split())]
if max(list) < sum(list) - max(list):
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
deta = list(map(int,input().split()))

if max(deta) < sum(deta) - max(deta):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
import math
c = math.ceil(a/0.08)
d = round(b/ (0.1))
e = math.floor((a+1)/0.08)
f = round((b+1)/0.1)-1
i = c
j = -1
for i in range(c,e+1):
    if d <= i <= f:
        j = i
        break
    else:
        i = i+1
print(j

Fixed submission:
a,b = map(int,input().split())
import math
c = math.ceil(a/0.08)
d = round(b/ (0.1))
e = math.ceil((a+1)/0.08)-1
f = round((b+1)/0.1)-1
i = c
j = -1
for i in range(c,e+1):
    if d <= i <= f:
        j = i
        break
    else:
        i = i+1
print(j)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
List = [list(map(int,input().split())) for i in range (a)]
newList = []
for i in range(0,a):
    n = 0
    for j in range (0,3):
        n = n + List[i][j]
    newList.append(n)
x = sorted(newList,reverse =True)
m = 0
for i in range (0,b):
    m = m + x[i]
print(m)    

Fixed submission:
a,b = map(int,input().split())
if a <= 8 and b <=8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
K=int(input(""))
S=input("")
lenS=len(S)
if lenS<=K:
  print(S)
else:
  print(S[:K]+"...")

Fixed submission:

N=int(input(""))
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or x==6 or x==8:
  print("pon")
else:
  print("hon")

Buggy python submission (verdict: Runtime Error):
N=int(input())
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or X==6 or x==8:
  print("pon")
else:
  print("hon")

Fixed submission:

N=int(input(""))
x=N%10
if x==3:
  print("bon")
elif x==0 or x==1 or x==6 or x==8:
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Runtime Error):
K=int(intput(""))
S=input("")
lens=len(s)
if lens<=K:
  print(S)
else:
  S2=S[:K-1]
  print(S2)
  

Fixed submission:
K=int(input(""))
S=input("")
lenS=len(S)
if lenS<=K:
  print(S)
else:
  print(S[:K]+"...")
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())

for i in range(k):
  if a > 0:
  	a -= 1
  else:
    b -= 1
print(a,b)


Fixed submission:
s,t = map(str,input().split())
print(t+s)
Buggy python submission (verdict: Runtime Error):
import math

A, B = map(int, input().split)
min1 = math.gcd(A, B)

max1 = max(A, B)

for i in range(100000000):
  s = min1 * i
  if max1 < s:
    break
    
print(s)

Fixed submission:
A, B = map(int,input().split())

def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  
  if x % y == 0:
    return y
  
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z
      
def lcm(m, n):
  return int(m * n / gcd(m, n))

print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
an = list(map(int,input().split()))

c = 1
cp = 0

for i in N:
  ai = an[i]
  if ai != c:
    cp += 1
    
  elif ai == c:
    c += 1
    
print(cp)

Fixed submission:
N = int(input())
an = list(map(int,input().split()))

c = 1
cp = 0

for i in range(N):
  ai = an[i]
  if ai != c:
    cp += 1
    
  elif ai == c:
    c += 1
    
if N == cp:
    cp = -1

print(cp)
Buggy python submission (verdict: Runtime Error):
s = input()

l = len(s)
sen = l // 2
c = 0

for i in range(sen):
  s1 = s[i]
  s2 = s[l-i]
  
  if s1 != s2:
    c += 1
print(c)

Fixed submission:
s = input()

l = len(s)
sen = l // 2
c = 0

for i in range(sen):
  s1 = s[i]
  s2 = s[l-i-1]
  
  if s1 != s2:
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
h,n = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A, reversed = True)

for a in A[:n] :
    h -= a

if h <= 0 :
    print("Yes")
else :
    print("No")



Fixed submission:
h,n = map(int,input().split())
A = list(map(int,input().split()))
A = sorted(A, reverse = True)

for a in A[:n] :
    h -= a

if h <= 0 :
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
print(S+T)


Fixed submission:
S,T = input().split()
print(T+S)

Buggy python submission (verdict: Runtime Error):
print(input()+input())


Fixed submission:
S,T = input().split()
print(T+S)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = set()
S = input()
res = 0
for i in range(n-2) :
    for j in range(i+1,n-1) :
        for k in range(j+1,n) :
            t = S[i]+S[j]+S[k]
            if t not in A :
                A.add(t)
                res += 1
print(res)


Fixed submission:
n = int(input())
S = input()
res = 0
for i in range(1000) :
    T = str(i).zfill(3)
    a = 0
    b = 0
    f1 = 0
    f2 = 0
    f = 0
    for j,t in enumerate(T) :
        if f :
            break
        for k,s in enumerate(S) :
            if t == s :
                if not f1 :
                    f1 = 1
                    a = k
                    break
                elif f1 and not f2 and a < k :
                    f2 = 1
                    b = k
                    break
                elif f1 and f2 and b < k :
                    res += 1
                    f = 1
                    break
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = set()
S = input()
res = 0
for i in range(n-2) :
    for j in range(i+1,n-1) :
        for k in range(j+1,n) :
            t = S[i]+S[j]+S[k]
            if t not in A :
                A.add(t)
                res += 1
print(res)


Fixed submission:
n = int(input())
S = input()
res = 0
for i in range(1000) :
    T = str(i).zfill(3)
    a = 0
    b = 0
    f1 = 0
    f2 = 0
    f = 0
    for j,t in enumerate(T) :
        if f :
            break
        for k,s in enumerate(S) :
            if t == s :
                if not f1 :
                    f1 = 1
                    a = k
                    break
                elif f1 and not f2 and a < k :
                    f2 = 1
                    b = k
                    break
                elif f1 and f2 and b < k :
                    res += 1
                    f = 1
                    break
print(res)
Buggy python submission (verdict: Runtime Error):
n = input(); n = int(n)
A = list(map(int,input().split()))

MOD = 998244353
L = [0]*(n+1)

for a in A : L[a] += 1

if A[0] == 1 :
  print(0)
  exit()

zerofirst = L.find(0)
for i in range(n-1,-1,-1) :
  if L[i] != 0 :
    nonzerolast = i
    break

if zerofirst < nonzerolast :
  print(0)
  exit()

ans = 1
for a in A[:nonzerolast+1] :
  ans *= a

print(ans)



Fixed submission:
n = input(); n = int(n)
A = list(map(int,input().split()))

if A[0] != 0 :
  print(0)
  exit()

MOD = 998244353
L = [0]*(n+1)

for a in A : L[a] += 1
#print(L)

if L[0] != 1 :
  print(0)
  exit()

zerofirst = L.index(0)
for i in range(n-1,-1,-1) :
  if L[i] != 0 :
    nonzerolast = i
    break

if zerofirst < nonzerolast :
  print(0)
  exit()

ans = 1
for i in range(1,nonzerolast+1) :
  ans *= (L[i-1]) ** (L[i])
  ans %= MOD

print(ans)

#print(zerofirst, nonzerolast)
Buggy python submission (verdict: Runtime Error):
from copy import deepcopy
H,W,A,B = map(int,input().split())
L = []
line = ["0" for j in range(W)]
for i in range(H) :
    tmp = deepcopy(line)
    for j in range(i,i+A) :
        tmp[j] = "1"
    L.append(tmp)
#print(L)
for j in range(W) :
    zero = 0
    one = 0
    for i in range(H) :
        if L[i][j] == "1" :
            one += 1
        else :
            zero += 1
    
    if min(one, zero) != B :
        print("No")
        break
else :
    for i in range(H) :
        print("".join(L[i]))


Fixed submission:
H,W,A,B = map(int,input().split())

if (A >= W//2 + 1) or (B >= H//2 + 1) :
    print("No")
else :

    L = [["0"]*W for i in range(H)]

    for i in range(H) :
        for j in range(W) :
            if ((i < H-B) and (j < W-A)) or ((i >= H-B) and (j >= W-A)) :
                L[i][j] = "1"


    for j in range(W) :
        zero = 0
        one = 0
        for i in range(H) :
            if L[i][j] == "0" :
                zero += 1
            else :
                one += 1
        if min(zero,one) != B :
            print("No")
            break
    else :
        for i in range(H) :
            print("".join(L[i]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 0
for i in range(1,N) :
    ans += i
print(ans)



Fixed submission:
N = int(input())

ans = (N-1)*N//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = [""]*N
for i in range(N) :
    L[i] = "".join(sorted(list(input())))

ans = 0

for i in range(N-1) :
    a = L[i]
    for j in range(i+1,N) :
        b = L[j]
        if a == b :
            ans += 1
print(ans)


Fixed submission:
N = int(input())
L = ["".join(sorted(list(input()))) for i in range(N)]
D = {}
for s in L :
    if s not in D :
        D[s] = 1
    else :
        D[s] +=  1
ans = 0
for k in D :
    n = D[k]
    ans += n*(n-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]
ans = 0
A = []

L = sorted(L, key=lambda x: x[1],reverse=True)
L = sorted(L, key=lambda x: x[0],reverse=True)

cnt = 0

for i in range(N) :
    if i >= 1 and L[i][0] != L[i-1][0] :
        cnt = 0
    
    if (M-L[i][0]+1)-cnt <= 0 :
        continue
    if i < M :
        heapq.heappush(A,L[i][1])
        cnt += 1
    else :
        minv = heapq.heappop(A)
        if minv >= L[i][1] :
            heapq.heappush(A, minv)
        else :
            heapq.heappush(A,L[i][1])
            cnt += 1

print(sum(A))


Fixed submission:
import heapq

N, M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

D = {}
for i in range(N) :
    k,v = L[i]
    if k not in D :
        D[k] = [v]
    else :
        D[k].append(v)

class Heapq :
    def __init__(self, arr, desc=False) :
        if desc :
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
    
    def pop(self) :
        return heapq.heappop(self.hq) * self.sign
    
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
 
    def size(self):
        return len(self.hq)

q = Heapq([], True)
ans = 0
for k in range(1, M+1) :
    if k in D :
        for v in D[k] :
            q.push(v)
    if q.size() :
        ans += q.pop()
print(ans)

Buggy python submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]
ans = 0
A = []

L = sorted(L, key=lambda x: x[1],reverse=True)
L = sorted(L, key=lambda x: x[0],reverse=True)

minv = float("inf")
cnt = 0

for i in range(N) :
    if i >= 1 and L[i][0] != L[i-1][0] :
        cnt = 0
    
    if (M-L[i][0]+1)-cnt <= 0 :
        continue
    if i < M :
        heapq.heappush(A,L[i][1])
        cnt += 1
    else :
        minv = heapq.heappop(A)
        heapq.heappush(A,max(L[i][1], minv))
        cnt += 1

print(sum(A))


Fixed submission:
import heapq

N, M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(N)]

D = {}
for i in range(N) :
    k,v = L[i]
    if k not in D :
        D[k] = [v]
    else :
        D[k].append(v)

class Heapq :
    def __init__(self, arr, desc=False) :
        if desc :
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)
    
    def pop(self) :
        return heapq.heappop(self.hq) * self.sign
    
    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)
 
    def top(self):
        return self.hq[0] * self.sign
 
    def size(self):
        return len(self.hq)

q = Heapq([], True)
ans = 0
for k in range(1, M+1) :
    if k in D :
        for v in D[k] :
            q.push(v)
    if q.size() :
        ans += q.pop()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

N = len(S)

ans = [0]*N

for i in range(N) :
    if S[i] == "R" :
        j = S[i:].find("L")
        if j % 2 == 0 :
            ans[i+j] += 1
        else :
            ans[i+j-1] += 1
    else :
        j = S[:i+1][::-1].find("R")
        if j % 2 == 0 :
            ans[i-j] += 1
        else :
            ans[i-j+1] += 1
print(*ans)
            
        


Fixed submission:
S = input()
N = len(S)
ans = [0]*N

cnt = 0
for i in range(N) :
    if S[i] == "R" :
        cnt += 1

    elif cnt % 2 == 0 :
        ans[i] += cnt//2
        ans[i-1] += cnt//2
        cnt = 0
    else :
        ans[i] += cnt//2
        ans[i-1] += cnt//2 + 1
        cnt = 0
cnt = 0
for i in range(N-1,-1,-1) :
    if S[i] == "L" :
        cnt += 1
    
    elif cnt % 2 == 0 :
        ans[i] += cnt//2
        ans[i+1] += cnt//2
        cnt = 0
    else :
        ans[i] += cnt//2
        ans[i+1] += cnt//2 + 1
        cnt = 0
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()

N = len(S)

ans = [0]*N

for i in range(N) :
    if S[i] == "R" :
        j = S[i:].find("L")
        if j % 2 == 0 :
            ans[i+j] += 1
        else :
            ans[i+j-1] += 1
    else :
        j = S[:i+1][::-1].find("R")
        if j % 2 == 0 :
            ans[i-j] += 1
        else :
            ans[i-j+1] += 1
print(*ans)
            
        


Fixed submission:
S = input()
N = len(S)
ans = [0]*N

cnt = 0
for i in range(N) :
    if S[i] == "R" :
        cnt += 1

    elif cnt % 2 == 0 :
        ans[i] += cnt//2
        ans[i-1] += cnt//2
        cnt = 0
    else :
        ans[i] += cnt//2
        ans[i-1] += cnt//2 + 1
        cnt = 0
cnt = 0
for i in range(N-1,-1,-1) :
    if S[i] == "L" :
        cnt += 1
    
    elif cnt % 2 == 0 :
        ans[i] += cnt//2
        ans[i+1] += cnt//2
        cnt = 0
    else :
        ans[i] += cnt//2
        ans[i+1] += cnt//2 + 1
        cnt = 0
print(*ans)