Buggy python submission (verdict: Runtime Error):
N,M = [int(x) for x in input().split()]

dic = {}
for _ in range(N):
    A,B = [int(x) for x in input().split()]
    if A <= M: dic.setdefault(A, []).append(B)

buf = []
for m in sorted(dic.keys(),reverse=True):
     buf.extend(sorted(dic[m],reverse=True)[:M-m+1])
print(sum(sorted(buf,reverse=True)[:M]))

Fixed submission:
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 python submission (verdict: Runtime Error):
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
        if (len(lis) % 2 == 1) & (r_cnt % 2 == 1):
            r = len(lis) // 2 + 1
        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)))


Fixed submission:
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 python submission (verdict: Runtime Error):
import numpy as np
#def replace_RL(RL_str,word):
#    buf = []
#    for s in RL_str:
#        if s == word:
#            buf.append(1)
#        else:
#            buf.append(0)
#    return np.array(buf)

RL_str =np.array(list(input()))
#menber = np.ones(RL_str.size)

R_list = np.where(RL_str=='R',1,0)#replace_RL(RL_str,'R')
L_list = np.where(RL_str=='L',1,0)##replace_RL(RL_str,'L')

for n in range(1000):
    men_R = menber*R_list
    men_L = menber*L_list

    #shift
    men_R = np.roll(men_R, 1)
    men_L = np.roll(men_L, -1)

    menber = men_R + men_L

print(" ".join(menber.astype(int).astype(str).tolist()))

Fixed submission:
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)))