Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

class mint:
    def __init__(self, x):
        self.__x = x % md

    def __repr__(self):
        return str(self.__x)

    def __neg__(self):
        return mint(-self.__x)

    def __add__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x + other)

    def __sub__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x - other)

    def __rsub__(self, other):
        return mint(other - self.__x)

    def __mul__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * other)

    __radd__ = __add__
    __rmul__ = __mul__

    def __truediv__(self, other):
        if isinstance(other, mint): other = other.__x
        return mint(self.__x * pow(other, md - 2, md))

    def __rtruediv__(self, other):
        return mint(other * pow(self.__x, md - 2, md))

    def __pow__(self, power, modulo=None):
        return mint(pow(self.__x, power, md))

md=998244353

def main():
    n,s=MI()
    aa=LI()
    dp=[0]*(s+1)
    dp[0]=mint(1)
    for a in aa:
        for i in range(s,-1,-1):
            pre=dp[i]
            if pre==0:continue
            dp[i]+=pre
            if i+a<=s:dp[i+a]+=pre
    print(dp[s])

main()

### FIXED CODE ###

import sys
from collections import defaultdict

int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    md=998244353
    n,s=MI()
    aa=LI()
    dp=[0]*(s+1)
    dp[0]=1
    inv=pow(2,md-2,md)
    for k,a in enumerate(aa):
        for i in range(s-a,-1,-1):
            dp[i+a]=(dp[i+a]+dp[i]*inv)%md
        #print(k,dp)
    ans=dp[s]*pow(2,n,md)%md
    print(ans)

main()
### BUGGY CODE ###

import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,y = li()

yuki_max = y // 10000
ichi_max = y // 5000

ans_y = -1
ans_i = -1
ans_h = -1

for yukichi in range(yuki_max+1):
    for ichiyo in range(ichi_max+1):
        hideyo = (y - 10000*yukichi - 5000*ichiyo) // 1000
        if hideyo < 0:
            continue
        
        if yukichi + ichiyo + hideyo == n:
            ans_y = yukichi
            ans_i = ichiyo
            ans_h = hideyo
            break

print(ans_y, ans_i, ans_h)

### FIXED CODE ###


N, Y = map(int, input().split())


def greedy(Y):
    res = Y
    yukichi = 0
    ichiyo = 0
    hideyo = 0
    while res >= 10000:
        res -= 10000
        yukichi += 1
        
    while res >= 5000:
        res -= 5000
        ichiyo += 1
        
    while res > 0:
        res -= 1000
        hideyo += 1
        
    return yukichi, ichiyo, hideyo
    

def confirm_N(N,Y,yukichi,ichiyo,hideyo):
    bill = yukichi+ichiyo+hideyo
    if N<bill:
        return [-1,-1,-1]
    elif N == bill:
        return [yukichi, ichiyo, hideyo]
    
    while yukichi >= 0:
        if bill == N:
            return [yukichi, ichiyo, hideyo]
        
        while ichiyo > 0:
            bill += 4
            hideyo += 5
            ichiyo -= 1
            if bill == N:
                return [yukichi, ichiyo, hideyo]
        
        yukichi -= 1
        ichiyo = (Y-yukichi*10000) // 5000
        hideyo = (Y-yukichi*10000-ichiyo*5000) // 1000
        
        bill = yukichi+ichiyo+hideyo
    
    return [-1,-1,-1]

#1.まず貪欲

yukichi, ichiyo, hideyo = greedy(Y)

bill = yukichi+ichiyo+hideyo

ans_lst = confirm_N(N, Y, yukichi, ichiyo, hideyo)

print(*ans_lst)
### BUGGY CODE ###

from collections import Counter

N = int(input())
X = input()

for i in range(N):
    if X[i] == '1':
        tmp = - (1<<(N-i-1))
        n = int(X, 2) + tmp
    else:
        tmp = (1<<(N-i-1))
        n = int(X, 2) + tmp
        
    cnt = 0
    while n != 0:
        n %= Counter(bin(n))['1']
        cnt += 1
    print(cnt)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def pop_cnt(n):
    return bin(n).count('1')


def f(n):
    cnt = 0
    while n != 0:
        n = n % pop_cnt(n)
        cnt += 1
    return cnt
 
n = int(readline())
x2 = list(readline().decode().rstrip())
x10 = int(''.join(x2), 2)

c = x2.count('1')
mod1 = x10 % (c + 1)
mod2 = x10 % (c - 1) if c-1 != 0 else 0

for i in range(n):
    ans = 0
    if x2[i] == '0':
        t = (mod1 + pow(2, n-i-1, c+1)) % (c+1)
    else:
        if c-1 != 0:
            t = (mod2 - pow(2, n-i-1, c-1)) % (c-1)
        else:
            print(0)
            continue
    
    ans = f(t) + 1
    print(ans)
### BUGGY CODE ###

h, w, k = map(int, input().split())
ar = [list(map(int, input())) for _ in range(h)]

ans = None
for i in range(2**(h - 1)):
    t = 0
    to_add = [0]
    for a in range(h - 1):
        if i & (2**a):
            t += 1
        to_add.append(t)
    n_h = t
    n_w = 0
    cnts = [0 for _ in range(n_h + 1)]
    for x in range(w):
        for y in range(h):
            cnts[to_add[y]] += ar[y][x]
        if max(cnts) > k:
            n_w += 1
            for z in range(n_h + 1):
                cnts[z] = 0
            for y in range(h):
                cnts[to_add[y]] += ar[y][x]
            if ans is not None and ans <= n_h + n_w:
                break
    if ans is None or ans > n_h + n_w:
        ans = n_h + n_w
print(ans)


### FIXED CODE ###

h, w, k = map(int, input().split())
ar = [list(map(int, input())) for _ in range(h)]

ans = None
for i in range(2**(h - 1)):
    t = 0
    to_add = [0]
    for a in range(h - 1):
        if i & (2**a):
            t += 1
        to_add.append(t)
    n_h = t
    n_w = 0
    zz = [0 for _ in range(n_h + 1)]
    cnts = zz.copy()
    is_new = True
    is_fail = False
    for x in range(w):
        is_over = False
        for y in range(h):
            z = to_add[y]
            cnts[z] += ar[y][x]
            if cnts[z] > k:
                is_over = True
                break
        if is_over:
            n_w += 1
            if ans is not None and ans <= n_h + n_w:
                break
            cnts = zz.copy()
            for y in range(h):
                z = to_add[y]
                cnts[z] += ar[y][x]
                if cnts[z] > k:
                    is_fail = True
                    break
            if is_fail:
                break
    if not is_fail and (ans is None or ans > n_h + n_w):
        ans = n_h + n_w
print(ans)
### BUGGY CODE ###

import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
# dp[1] = abs(l[1]-l[0])
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
print(dp[n-1])

### FIXED CODE ###

import sys

n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [sys.maxsize]*n
dp[0]=0
for i in range(1,n):
    for j in range(1,k+1):
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))   
print(dp[n-1])
### BUGGY CODE ###

NK = input().split()
N, K = int(NK[0]), int(NK[1])
lis_p = list(map(lambda x: int(x), input().split()))
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp=0
for i in range(N):
    dp = max(sum(lis_exp[i:i+K]), dp)
print(dp)

### FIXED CODE ###

N, K = map(int, input().split())
lis_p = map(int, input().split())
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp= sum(lis_exp[0:K])
cumKsum = sum(lis_exp[0:K])
for i in range(1, N-K+1):
    cumKsum = cumKsum - lis_exp[i-1] + lis_exp[i+K-1]
    dp = max(cumKsum, dp)
print(dp)
### BUGGY CODE ###

import math


def main():
        
    N,D,A = map(int, input().split())

    xh = [list(map(int, input().split())) for _ in range(N)]

    xh.sort()

    ans = 0
    for i in range(N):
        if xh[i][1] <= 0:
            continue
        
        cnt = math.ceil(xh[i][1] / A)
        ans += cnt
        xh[i][1] = 0

        if cnt == 0:
            continue

        for j in range(i+1, N):

            if xh[j][0] > xh[i][0] + 2*D:
                break
            xh[j][1] -= cnt*A

        #print(ans, xh)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import math
from collections import deque

def main():
        
    N,D,A = map(int, input().split())

    xh = [list(map(int, input().split())) for _ in range(N)]

    xh.sort()

    ans = 0
    q = deque()
    dmg = 0
    for i in range(N):
        # 過去に使った爆弾で、現在地点まで攻撃が届かないものは効果切れにする
        while q and q[0][0] < xh[i][0]:
            _, d = q.popleft()
            dmg -= d

        # それまでの攻撃でその地点の敵が死んでいるので、その敵に対しては新たに爆弾を使わない
        if xh[i][1] - dmg <= 0:
            continue

        remaining = xh[i][1] - dmg

        cnt = math.ceil(remaining / A)
        ans += cnt
        dmg += cnt * A
        # その敵に対して爆弾を使ったので、追加
        q.append((xh[i][0] + 2*D, cnt*A))


    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
dict_A = Counter(A)
for a in A:
    ans = 0
    dict_A[a] -= 1
    for v in dict_A.values():
        ans += (v * (v - 1)) / 2
    dict_A[a] += 1
    print(int(ans))


### FIXED CODE ###

from collections import Counter
n = int(input())
A = list(map(int, input().split()))
c = Counter(A)
sum = 0
for v in c.values():
    sum += int(v*(v-1)/2)

for i in A:
    print(sum - (c[i] - 1))
### BUGGY CODE ###

# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    dicts = []
    for i in range(N):
        s = input()
        d = {}
        for moji in s:
            if not moji in d:
                d[moji] = 0
            d[moji] += 1
        dicts.append(d)

    ans = 0    
    for i in range(N):
        d1 = dicts[i]
        for j in range(i+1, N):
            d2 = dicts[j]
            ans += 1 if d1 == d2 else 0

    print(ans)



if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
"""解説PDF
s1 = "abaaa" をソートして "aaaab" を得る。
s2 = "dddcc" をソートして "ccddd" を得る。
s3 = "baaaa" をソートして "aaaab" を得る。これはすでに一回現れているので答えに1を足す。
s4 = "cdddc" をソートして "ccddd" を得る。これはすでに一回現れているので答えに1を足す。
s5 = "aaaab" をソートして "aaaab" を得る。これはすでに二回現れているので答えに2を足す。

というふうにやる。

「これはすでにK回現れているので」は、ハッシュテーブルでやればよい

"""
def solve():
    N = int(input())
    d = {}
    for i in range(N):
        s = "".join(sorted(input()))
        if not s in d:
            d[s] = 0
        d[s] += 1

    ans = 0
    for s, value in d.items():
        if value >= 2:
            # 和の公式で答えにタス
            ans += (value-1+1)*(value-1)/2
    print(int(ans))


if __name__ == "__main__":
    solve()
### BUGGY CODE ###

k, s = list(map(int, input().split()))
r_k = range(k+1)[::-1]
count = int(0)

for x in r_k:
    a = s-x
    if a > k*2:
        break
    for y in r_k:
        b = a - y
        if b > k:
            break
        for z in r_k:
            c = b - z
            if c == 0:
                count += 1
print(count)

### FIXED CODE ###

k, s = list(map(int, input().split()))
count = int(0)

for x in range(k+1)[::-1]:
    yz = s - x
    if yz > k*2:
        break
    for y in range(k+1)[::-1]:
        z = yz - y
        if x >= y >= z >= 0:
            if len({x, y, z}) == 1:
                count += 1
            elif len({x, y, z}) == 2:
                count += 3
            else:
                count += 6

print(count)
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
count = 0
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      count += gcd(i,j,k)
print(count)

### FIXED CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
  
K = int(input())
count = 0
for i in range(1,K-1):
  for j in range(i+1,K):
    for k in range(j+1,K+1):
      count += 6*(gcd(i,j,k))
      
for i in range(1,K):
  for j in range(i+1,K+1):
    count += 6*(gcd(i,j))

for i in range(1,K+1):
  count += i
      
print(count)
### BUGGY CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

ls = []
for i in range(n-k+1):
    ans = []
    for j in range(k):
        ans.append(p[i+j])
    ans.append(sum(ans))
    ls.append(ans)
    

ls = sorted(ls,key=lambda x:x[k])

ans = 0
for i in range(k):
    for j in range(ls[-1][i]):
        ans += (1/ls[-1][i]*(j+1))
    
print(ans)
        

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

ls = []
ans = 0

for i in range(k):
    ans += p[i]
    
max_ans = ans
max_index = 0

for i in range(n-k):
    ans -= p[i]
    ans += p[i+k]
    if max_ans < ans:
        max_ans = ans
        max_index = i+1

ans = 0
for i in range(k):
    pp = p[max_index+i]
    for j in range(pp):
        ans += (1/pp*(j+1))
    
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())

tree = {}
tmp = [list(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]
will_go = [0]
already = []
while will_go:
  now = will_go.pop()
  already.append(now)
  for node in tmp:
    if (now == node[0]) & (node[1] not in already):
      will_go.append(node[1])
      if now not in tree:
        tree[now] = [node[1]]
      else:
        tree[now].append(node[1])
    if (now == node[1]) & (node[0] not in already):
      will_go.append(node[0])
      if now not in tree:
        tree[now] = [node[0]]
      else:
        tree[now].append(node[0])

ans = [0]*n
for _ in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
  
will_go = [0]
for i in range(n):
  while will_go:
    now = will_go.pop()
    tmp = ans[now]
    if now in tree:
      for root in tree[now]:
        ans[root] += tmp
        will_go.append(root)
        
print(*ans)

### FIXED CODE ###

n, q = map(int, input().split())

tree = {}
for _ in range(n-1):
  a , b = map(lambda x:int(x)-1, input().split())
  if a not in tree:
    tree[a] = [b]
  else:
    tree[a].append(b)
  if b not in tree:
    tree[b] = [a]
  else:
    tree[b].append(a)

ans = [0]*n
ald = [True]*n
for _ in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
  
will_go = [0]
ald[0] = False
for i in range(n):
  while will_go:
    now = will_go.pop()
    tmp = ans[now]
    for root in tree[now]:
      if ald[root]:
        ald[root] = False
        ans[root] += tmp
        will_go.append(root)
        
print(*ans)
### BUGGY CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
  
import sys
sys.setrecursionlimit(100000)
from math import factorial


mod = 10**9+7 #出力の制限
N = 10**5+1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
f=[0]*N
f[0]=1
for i in range(1,N):
  f[i]=(f[i-1]*i)%mod

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n=int(input())
x=list(map(int,input().split()))
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    if j!=n-1:
      ans+=(((x[j]-x[i]))*cmb(n-1,j-i+1,mod)*f[n-1-j+i-1]*f[j-i-1]%mod)
    else:
      ans+=(((x[j]-x[i]))*cmb(n-1,j-i,mod)*f[n-1-j+i]*f[j-i-1]%mod)
print(ans%mod)


### FIXED CODE ###

#----------------------------------------------------------
P = 10**9 + 7
N = 100001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
finv = [1] + [1] # 1/x!
fac = [1] + [1] # x!
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
  fac += [(fac[i-1] * i) % P]
  finv += [(finv[i-1] * inv[i]) % P]

def comb(a, b):
    if a<b or a<0 or b<0:
        return 0 # error
    return (fac[a] * ((finv[b] * finv[a-b]) % P)) %P
#----------------------------------------------------------

n=int(input())
x=list(map(int,input().split()))
s = [0] * n
for i in range(n):
    s[i] = x[i] + (s[i-1] if i>0 else 0)
ans=0

for i in range(n-1):
    t = (x[n-1]-x[n-2-i])%P
    t = (t * (fac[n-1]*inv[i+1])%P)%P
    ans=(ans+t)%P
for i in range(1, n-1):
    t = (s[n-2] - s[i-1] - s[n-2-i])%P
    p = (((fac[n-1] * inv[i])%P) * inv[i+1])%P
    ans = (ans + (t*p)%P)%P

print(ans%P)
### BUGGY CODE ###

from heapq import heapify, heappop, heappush
from math import ceil
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
H = [ (-a, 1, a) for a in A]
heapify(H)
for k in range(K):
    _, n, L = heappop(H)
    heappush(H, (-L/(n+1), n+1, L))
ans = int(ceil(-H[0][0]))
print(ans)


### FIXED CODE ###

from heapq import heapify, heappop, heappush
from math import ceil
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
A = inpl()
total = sum(A)
H = []
remnant = K
for a in A:
    n = (K*a)//total
    remnant -= n
    H.append((-a/(n+1), n, a))
heapify(H)
for k in range(remnant):
    L, n, a = heappop(H)
    heappush(H, (-a/(n+2), n+1, a))
ans = int(ceil(-H[0][0]))
print(ans)
### BUGGY CODE ###

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_com = a[0]
comfort = [a[1], a[1]]

for ai in a[2:]:
    sum_com += comfort[0]
    if comfort[0] == ai:
        comfort.append(ai)
    else:
        comfort.pop(0)
        comfort += [ai, ai]

print(sum_com)


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_com = 0
distinct_a = sorted(list(set(a)), reverse=True)
comfort = {i: 0 for i in distinct_a}
comfort[a[0]] = 1
max_com = 0

for ai in a[1:]:
    sum_com += distinct_a[max_com]
    if distinct_a[max_com] == ai:
        comfort[distinct_a[max_com]] += 1
    else:
        comfort[distinct_a[max_com]] -= 1
        comfort[ai] += 2
        if comfort[distinct_a[max_com]] == 0:
            max_com += 1

print(sum_com)
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()
A = LI()

for i in range(M):
    A.sort()
    A[-1] = A[-1]//2

print(sum(A))


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import heapq

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()
A = LI()

pq = []
for a in A:
    heapq.heappush(pq,-a)

for _ in range(M):
    heapq.heappush(pq,-(-heapq.heappop(pq) // 2))
    # print(pq)

print(-sum(pq))
### BUGGY CODE ###

from operator import itemgetter

n = int(input())
sn = []

for i in range(n):
    s = input()
    flg = 0
    for j in sn:
        if(j[0] == s):
            j[1] += 1
            flg = 1
            break
    if(flg == 0):
        sn.append([s,1])
    else:
        continue
        
sn.sort(key=itemgetter(1))
sn.reverse()
#print(sn)

cnt = sn[0][1]
for i in sn:
    if(int(i[1]) == cnt):
        print(i[0])
        continue
    else:
        break



### FIXED CODE ###

from operator import itemgetter
import datetime

n = int(input())
sn = dict()

for i in range(n):
    s = input()
    if(s in sn):
        sn[s] += 1
    else:
        sn[s] = 1

sn = sorted(sn.items(), key=lambda x:(-x[1],x[0]))
#print(sn)

max_val = max(dict(sn).values())

for si in sn:
    if(int(si[1]) == max_val):
        print(si[0])
    else:
        break
### BUGGY CODE ###

s = input()
h = []
for i in range(0,len(s)):
    h.append(0)

for i in range(0,len(s)):
    if s[i] == "R":
        j = s.find("RL", i)
        if (j-i) % 2 == 1:
            h[j+1] += 1
        else:
            h[j] += 1
    elif s[i] == "L":
        j = s.rfind("RL", 0, i+1)
        if (i-j) % 2 == 1:
            h[j+1] += 1
        else:
            h[j] += 1

ans = ""
for x in h:
    ans += str(x) + " "
print(ans)


### FIXED CODE ###

import sys
input=sys.stdin.readline

def runLength(s):
    a = []
    for c in s:
        if len(a)==0 or a[-1][0]!=c:
            a.append([c,1])
        else:
            a[-1][1] += 1
    return a

s = input().strip()
a = runLength(s)

#print(a)
ans = [0]*len(s)
j = 0
for i in range(len(s)-1):
    if s[i] == "R" and s[i+1] == "L":
        ans[i] += a[j][1]//2 + a[j+1][1]//2
        ans[i+1] += a[j][1]//2 + a[j+1][1]//2
        if a[j][1] % 2 != 0:
            ans[i] += 1
        if a[j+1][1] % 2 != 0:
            ans[i+1] += 1
#        print(j, ans)
        j += 2
print(*ans)
### BUGGY CODE ###


def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

len_s=len(s)
len_t=len(t)

dp=[[0]*(len_t+1) for _ in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j]+1)
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

# print(dp)

#reverse
ans = ""
i = len_s
j = len_t
while (i>0  and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1] 
        i -= 1
        j -= 1
print(ans[::-1])

### FIXED CODE ###


def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
t=s0()

len_s=len(s)
len_t=len(t)

dp=[[0]*(len_t+1) for _ in range(len_s+1)]
for i in range(len_s):
    for j in range(len_t):
        if s[i]==t[j]:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1],dp[i][j]+1)
        else:
            dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1])

# print(dp)

#reverse
ans = ""
i = len_s
j = len_t
while (i>0  and j>0):
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans += s[i-1] 
        i -= 1
        j -= 1
print(ans[::-1])