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

def main():
    h,w=map(int,input().split())
    a=[list(input()) for i in range(h)]
    for i in range(h):
        for j in range(w):
            if a[i][j]==".":
                a[i][j]=99999
    ans=0
    import collections
    from copy import deepcopy
    direction=[[0,1],[0,-1],[1,0],[-1,0]]
    for sh in range(h):
        for sw in range(w):
            tmp=0
            if a[sh][sw]==99999:
                field=deepcopy(a)
                field[sh][sw]=0
                completed=[]
                next_list=collections.deque([[sh,sw]])
                while next_list:
                    n=next_list.popleft()
                    completed.append(n)
                    for dx,dy in direction:
                        ny,nx=n[0]+dy,n[1]+dx
                        if 0<=ny<=h-1 and 0<=nx<=w-1 and field[ny][nx]!="#" and [ny,nx] not in completed:
                            field[ny][nx]=min(field[n[0]][n[1]]+1,field[ny][nx])
                            next_list.append([ny,nx])
                for i in range(h):
                    for j in range(w):
                        if field[i][j]!="#":
                            tmp=max(tmp,field[i][j])
                ans=max(ans,tmp)
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

h,w=map(int,input().split())
field=[list(input())for i in range(h)]

import copy
dp=[[1000 for i in range(w)]for i in range(h)]
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j=="#":
            dp[y][x]=9999

dydx=[[-1,0],[1,0],[0,-1],[0,1]]
#print(dp)
maxi=0
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j==".":
            ndp=copy.deepcopy(dp)
            ndp[y][x]=0
            cnt=0
            queue=[]
            queue.append([y,x])
            while queue:
                ny,nx=queue.pop(0)
                for dy,dx in dydx:
                    nny,nnx=ny+dy,nx+dx
                    if 0<=nny<=h-1 and 0<=nnx<=w-1 and field[nny][nnx]!="#" and ndp[nny][nnx]==1000:
                        ndp[nny][nnx]=ndp[ny][nx]+1
                        queue.append([nny,nnx])
                        if ndp[nny][nnx]>maxi:
                            maxi=ndp[nny][nnx]
            #print(ndp)
print(maxi)
### BUGGY CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under



x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
else:
  a=int((2*x-y)/3)
  b=int((2*y-x)/3)
  if a>=0 and b>=0:
    print(cmb(a+b,b)%(10**9+7))
  else:
    print(0)

### FIXED 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

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

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 )



x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
else:
  a=int((2*x-y)/3)
  b=int((2*y-x)/3)
  if a>=0 and b>=0:
    print(cmb(a+b,b,mod))
  else:
    print(0)
### BUGGY CODE ###

import bisect

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
ｓ.insert(0, -f_inf)
t.insert(0, -f_inf)
ｓ.append(f_inf)
t.append(f_inf)

for i in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), max(abs(x-s[s_index-1]), abs(x-t[t_index-1])), 2*abs(x-s[s_index-1])+abs(x-t[t_index]), 2*abs(x-s[s_index])+abs(x-t[t_index-1]), abs(x-s[s_index-1])+2*abs(x-t[t_index]), abs(x-s[s_index])+2*abs(x-t[t_index-1])))


### FIXED CODE ###

import bisect

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
ｓ.insert(0, -f_inf)
t.insert(0, -f_inf)
ｓ.append(f_inf)
t.append(f_inf)

for i in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), max(abs(x-s[s_index-1]), abs(x-t[t_index-1])), 2*abs(x-s[s_index-1])+abs(x-t[t_index]), 2*abs(x-s[s_index])+abs(x-t[t_index-1]), abs(x-s[s_index-1])+2*abs(x-t[t_index]), abs(x-s[s_index])+2*abs(x-t[t_index-1])))
### BUGGY CODE ###

import sys
from collections import Counter
import copy

n = int(sys.stdin.readline())
ct = Counter()
a_ls = dict()
for i in range(n):
    inp = [int(i) - 1 for i in sys.stdin.readline().split()]
    a_ls[i] = inp
cnt = 0
candidate = list(range(n))
rest = n * (n - 1) / 2
combis = set()
while rest:
    no_ls = []
    next_candidate = []
    flg = False
    for i in candidate:
        if len(a_ls[i]) == 0:
            no_ls.append(i)
            continue
        target = a_ls[i][0]
        if (i, target) in combis or (target, i) in combis:
            next_candidate.append(i)
            next_candidate.append(target)
            rest -= 1
            if len(a_ls[i]) > 0:
                a_ls[i].pop(0)
            if len(a_ls[target]) > 0:
                a_ls[target].pop(0)
            flg = True
        else:
            combis.add((i, target))
    candidate = copy.deepcopy(next_candidate)
    if not flg:
        cnt = -1
        break
    cnt += 1
print(cnt)

### FIXED CODE ###

import sys
from collections import Counter
import copy

n = int(sys.stdin.readline())
ct = Counter()
a_ls = dict()
for i in range(n):
    inp = [int(i) - 1 for i in sys.stdin.readline().split()]
    a_ls[i] = inp
cnt = 0
candidate = list(range(n))
rest = n * (n - 1) / 2
combis = set()
while rest:
    no_ls = []
    next_candidate = []
    flg = False
    for i in candidate:
        if len(a_ls[i]) == 0:
            continue
        target = a_ls[i][0]
        if (i, target) in combis or (target, i) in combis:
            next_candidate.append(i)
            next_candidate.append(target)
            rest -= 1
            if len(a_ls[i]) > 0:
                a_ls[i].pop(0)
            if len(a_ls[target]) > 0:
                a_ls[target].pop(0)
            flg = True
        else:
            combis.add((i, target))
    candidate = next_candidate
    if not flg:
        cnt = -1
        break
    cnt += 1
print(cnt)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10000000)

n,q=map(int,input().split())
G=[[] for i in range(n)] #隣接配列
P=[0]*n #親のポイント
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)
for i in range(q):
    p,x=map(int,input().split())
    p-=1
    P[p]+=x
    

def dfs(s,p=-1):        
    for i in G[s]:
        if i!=p:
            P[i]+=P[s]
            dfs(i,s)

dfs(0)
print(*P)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque

def main():
    n,q=map(int,input().split())
    G=[[] for i in range(n)] #隣接配列
    P=[0]*n #親のポイント
    for i in range(n-1):
        a,b=map(int,input().split())
        a-=1
        b-=1
        G[a].append(b)
        G[b].append(a)
    for i in range(q):
        p,x=map(int,input().split())
        p-=1
        P[p]+=x
    
    Chk=[0]*n #訪問済みチェック
    q=deque([0])
    while q: #qが空になるまで(BFS:幅優先探索)
        now=q.popleft() #取り出す
        Chk[now]=1 #訪問済みにする
        for i in G[now]: #子に対し
            if Chk[i]==0: #未訪問のとき
                P[i]+=P[now] #ポイント加算
                q.append(i) #親としてqに入れる

    print(*P)

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

n=int(input())
ans=0
for i in range(1,n+1):
    x,y=i,(n//i)*i
    ans+=((n//i)*(x+y)//2)
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1, n + 1):
    x, y = i, (n // i) * i
    #等差数列の和は(1/2)*(項数(今回はn//i))*(初項＋末項)
    ans += ((n // i) * (x + y) // 2)
print(ans)
### BUGGY CODE ###

N = int(input())
a = [int(x) for x in input().split()]


for i in range(1,N+1):
    answer = 0
    for j in range(len(a)):
        if i == a[j]:
            answer += 1
    
    print(answer)

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
answer = [0] * N
for i in range(1,N):
    x = a[i-1]
    answer[x-1] +=1

for i in range(N):
    print(answer[i])
### BUGGY CODE ###

from sys import stdin


def cmb_prepare(n, p=10**9+7):
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n + 1):
        fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        factinv.append((factinv[-1] * inv[-1]) % p)
    return fact, factinv


def cmb(n, r, fact, factinv, p=10**9+7):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


# not AC
def get_result(data):
    n, a, b = data[0]
    fact, factinv = cmb_prepare(n)
    mod = 10**9 + 7
    out = ((2 ** n - 1) % mod - cmb(n, a, fact, factinv) - cmb(n, b, fact, factinv)) % mod
    return out

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


### FIXED CODE ###

from sys import stdin
from functools import reduce


def comb_mod(n, a, mod=10**9+7):
    # https://img.atcoder.jp/abc156/editorial.pdf
    # nCk は, k回の積で計算できる
    num = reduce(lambda x, y: x * y % mod, range(n, n - a, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, a + 1))
    # nCk mod = X/Y mod = X * Y^(10**9+7-2) mod
    return num * pow(den, mod - 2, mod) % mod


def get_result(data):
    n, a, b = data[0]
    mod = 10**9+7
    out = pow(2, n, mod) - comb_mod(n, a, mod) - comb_mod(n, b, mod) - 1 
    out %= mod
    return out

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)
### BUGGY CODE ###

N,M = map(int,input().split())
PY = [[int(i) for i in input().split()]for i in range(M)]
l = [[] for i in range(N+1)]
for p,y in PY:
    l[p].append(y)
for i in range(N+1):
    l[i].sort()
for p,y in PY:
    print(str(p).zfill(6),end="")
    print(str(l[p].index(y)+1).zfill(6))

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
ans = [[0,0]for i in range(M)]
cityes = [[]for i in range(N)]
for i in range(M):
    p,y = map(int,input().split())
    heapq.heappush(cityes[p-1],[y,i])
for i in range(N):
    j = 0
    while cityes[i] != []:
        j += 1
        y,n = heapq.heappop(cityes[i])
        ans[n] = [i+1,j]
for a,b in ans:
    out = str(1000000+a)[1:] + str(1000000+b)[1:]
    print(out)
### BUGGY CODE ###

n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
a = []
b = 0
for j in range(m):
  if li[j][1] == "AC":
    a.append(int(li[j][0]))
  elif li[j][1] == "WA" and int(li[j][0]) not in a:
    b += 1
for k in range(m):
  if int(li[k][0]) not in a:
    b -= 1
c = str(len(set(a)))
print(c + " " + str(b))

### FIXED CODE ###

n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])-1] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])-1] == 0:
    a += 1
    b += li_b[int(li[j][0])-1]
    li_a[int(li[j][0])-1] += 1
print(a, b)
### BUGGY CODE ###

# input
N, Q = map(int, input().split())
S = input()

index = []
i_append = index.append
for i in range(Q):
    l, r = map(int, input().split())
    i_append((l - 1, r))

# check
for l, r in index:
    check_substr = S[l:r]
    substr_len = len(check_substr)
    AC_cnt = sum(
        [
            1
            for i in range(0, substr_len - 1)
            if check_substr[i:i + 2] == "AC"
        ]
    )

    print(AC_cnt)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

a = [0] * N
c = [False] * N
for i in range(1, N):
    if S[i - 1:i + 1] == "AC":
        a[i] = a[i - 1] + 1
        c[i] = True
    else:
        a[i] = a[i - 1]

for i in range(Q):
    l, r = map(int, input().split())
    if l - 1 == 0:
        print(a[r - 1])
    elif c[l - 1] is True:
        print(a[r - 1] - a[l - 1])
    else:
        print(a[r - 1] - a[l - 1])
### BUGGY CODE ###

def main():
  
  h,n=map(int,input().split())
  AB=sorted([list(map(int,input().split()))for _ in range(n)])
  
  DP=[float("inf") for _ in range(h+2)]
  DP[0]=0
  for i in range(1,h+2):
    for a,b in AB:
      if i<=a:
        DP[i]=min(DP[i],b)
      else:
        DP[i]=min(DP[i],DP[i-a]+b)
        
  print(DP[h])
  
if __name__=="__main__":
  main()

### FIXED CODE ###

def main():
  
  h,n=map(int,input().split())
  AB=tuple([list(map(int,input().split()))for _ in range(n)])
  
  DP=[float("inf") for _ in range(h+2)]
  DP[0]=0
  for i in range(1,h+2):
    for a,b in AB:
      if i<=a:
        DP[i]=min(DP[i],b)
      else:
        DP[i]=min(DP[i],DP[i-a]+b)
        
  print(DP[h])
  
if __name__=="__main__":
  main()
### BUGGY CODE ###

from sys import setrecursionlimit
setrecursionlimit(1<<30)
mod=pow(10,9)+7
def f(x,p,c):
  if z[x][c]==-1:
    z[x][c]=1
    for y in v[x]:
      if y!=p:
      	z[x][c]*=(f(y,x,1)+c*f(y,x,0))%mod
  return z[x][c]
n=input()
v=[[] for _ in xrange(n)]
for x,y in [map(int,raw_input().split()) for _ in xrange(n-1)]:
  v[x-1].append(y-1)
  v[y-1].append(x-1)
z=[[-1,-1] for _ in xrange(n)]
print (f(0,-1,0)+f(0,-1,1))%mod

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(1<<30)
mod=pow(10,9)+7
def f(x,p):
  if z[x][0]==-1:
    z[x][0]=z[x][1]=1
    for y in v[x]:
      if y!=p:
        f(y,x)
      	z[x][0]=(z[x][0]*z[y][1])%mod
        z[x][1]=(z[x][1]*(z[y][0]+z[y][1]))%mod
n=int(input())
v=[[] for _ in range(n)]
for x,y in [map(int,raw_input().split()) for _ in range(n-1)]:
  v[x-1].append(y-1)
  v[y-1].append(x-1)
z=[[-1,-1] for _ in range(n)]
f(0,-1)
print sum(z[0])%mod
### BUGGY CODE ###

N = int(input())
S = list(input())
Q = []
for i in range(N) :
    if i not in range(1,N) :
        Q.append(S.count("E"))
    else :
        A = S[0:i]
        B = S[i+1:N+1]
        Q.append(A.count("W")+B.count("E"))
print(min(Q))



### FIXED CODE ###

N = int(input())
S = list(input())
ANS = []
ans = 0
for i in range(0,N) :
    if i == 0 :
        ans += S[1:].count("E")
        ANS.append(ans)
    elif S[i-1] == "E" and S[i] == "E" :
        ans -= 1
        ANS.append(ans)
    elif S[i-1] == "W" and S[i] == "W" :
        ans += 1
        ANS.append(ans)
print(min(ANS))
### BUGGY CODE ###

import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

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

I = np.array(read().split(), np.int64)
X = I[::2]
H = I[1::2]

sort_ind = np.argsort(X)
X = X[sort_ind]
H = H[sort_ind]

atack = np.zeros(N+1)
cover = np.searchsorted(X, X + (2 * D), side = 'right')

ans = 0
cnt = 0
for i in range(N):
	cnt += atack[i]
	H[i] -= cnt
	if H[i] > 0:
		tmp = -(-H[i]//A)
		ans += tmp
		cnt += tmp * A
		atack[cover[i]] -= tmp * A

print(ans)

### FIXED CODE ###

import numpy as np
import sys
N, D, A = map(int, input().split())
L = 2 * D
I = np.array(sys.stdin.read().split(), np.int64)
X = I[::2]
H = I[1::2]
sort_ind = np.argsort(X)
X = X[sort_ind]
H = H[sort_ind]
S = np.zeros(N+1, np.int64)
ind = np.searchsorted(X,X+L+1,side = 'left')

atack = 0
ans = 0
for i in range(N):
	atack += S[i]
	H[i] -= atack
	if H[i] > 0:
		atack_cnt = -(-H[i]//A)
		ans += atack_cnt
		tmp = atack_cnt * A
		S[i+1] += tmp
		S[ind[i]] -= tmp

print(ans)
### BUGGY CODE ###

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

def calc_exp(n):
    exp=1+(n-1)*0.5
    return exp

mx=0
for i in range(n-k+1):
    tmp=sum(p[i:i+k])
    if mx<tmp:
        ind=i
        mx=tmp
        
ans=0
for i in range(k):
    ans+=1+(p[ind+i]-1)*0.5
    
print(ans)

### FIXED CODE ###

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

def calc_exp(n):
    exp=1+(n-1)*0.5
    return exp

tmp=sum(p[:k])
mx=tmp
ind=0
for i in range(1,n-k+1):
    # tmp=sum(p[i:i+k])
    tmp-=p[i-1]
    tmp+=p[i+k-1]
    if mx<tmp:
        ind=i
        mx=tmp
        
ans=0
for i in range(k):
    ans+=1+(p[ind+i]-1)*0.5
    
print(ans)
### BUGGY CODE ###

import collections

N = int(input())
stuff = list(map(int, input().split()))

stuff_lis = collections.Counter(stuff)
st = list(stuff_lis.keys())
num = list(stuff_lis.values())

for i in range(N):
    if i+1 in st:
        print(num[st.index(i+1)])
    else:
        print(0)


### FIXED CODE ###

N = int(input())
A = list(input().split())
A = [int(A[i]) for i in range(N-1)]
ans = [0 for i in range(N)]

for i in range(N-1):
    ans[A[i] - 1] += 1

for i in range(N):
    print(ans[i])
### BUGGY CODE ###

def main():
    H, N = map(int, input().split())
    dp = [10 ** 18] * (H + 1)

    dp[0] = 0

    for i in range(N):
        a, b = map(int, input().split())
        for j in range(H):
            nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
            dp[nj] = min(dp[nj], dp[j] + b)

    print(dp[H])


main()


### FIXED CODE ###

H, N = map(int, input().split())
dp = [10 ** 18] * (H + 1)

dp[0] = 0

for i in range(N):
    a, b = map(int, input().split())
    for j in range(H):
        nj = min(j + a, H)  # nj: 次のjのindex, 配列外参照しないようにminをとる
        dp[nj] = min(dp[nj], dp[j] + b)

print(dp[H])
### BUGGY CODE ###

#!/usr/bin/env python3
import math
import sys

input = sys.stdin.readline
n = int(input())
A = list(map(int,input().split()))
ans = 1
for i in range(n):
    ans = ans * A[i]
if ans > 10**18 :
    print(-1)
else:
    print(ans)

### FIXED CODE ###


n = int(input())
A = list(map(int,input().split()))
ans =1
for i in range(n):
    ans = ans * A[i]
    if ans  > 10**18:
        ans =-1
        break 
if 0 in A:
  print(0)
else:
  print(ans)
### BUGGY CODE ###

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = []
n = N
for i in range(2 ** n):
    cost,value = 0,0
    for i1 in range(n):
        if ((i >> i1) & 1):
             cost += C[i1]
             value += V[i1]
    ans.append(value-cost)

print(max(ans))


### FIXED CODE ###

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
cost = []
ans = 0
for i in range(N):
    cost.append(V[i] - C[i])

for i in cost:
    if i > 0:
        ans += i

print(ans)
### BUGGY CODE ###

N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

sum0 =sum(A_n)
for i in range(Q):
    count =A_n.count(B_n[i])
    sum0 += (C_n[i]-B_n[i])*count
    A_n  =list(filter(lambda x: x != B_n[i] ,A_n))
    A_n.extend([C_n[i] for j in range(count)])
    print(sum0)

### FIXED CODE ###

from collections import Counter

N =int(input())
A_n =list(map(int,input().split()))
Q =int(input())
B_n ,C_n=[],[]
for i in range(Q):
    B,C =map(int,input().split())
    B_n.append(B)
    C_n.append(C)

dic =Counter(A_n)

sum0 =sum(A_n)
for i in range(Q):
    count = dic[B_n[i]]
    sum0 += (C_n[i]-B_n[i])*count
    dic[B_n[i]] = 0
    dic[C_n[i]] += count
    print(sum0)
### BUGGY CODE ###

import numpy as np

s = input()

li_1 = np.ones(len(s))

for i in range(1000):
    li_2 = np.zeros(len(s))
    for j in range(len(s)):
        if s[j] == 'R':
            li_2[j+1] += li_1[j]
        elif s[j] == 'L':
            li_2[j-1] += li_1[j]
    li_1 = li_2

for i in li_1:
    print(int(i), end=' ')


### FIXED CODE ###

from math import ceil
from math import floor
import itertools

s = input()
n = len(s)
t = []

def output(r_cnt, l_cnt):
    global t
    r_num = ceil(r_cnt/2) + floor(l_cnt/2)
    l_num = ceil(l_cnt/2) + floor(r_cnt/2)
    x = [0 for _ in range(r_cnt + l_cnt)]
    x[r_cnt-1] = r_num
    x[r_cnt] = l_num
    t.append(x)


r_cnt = 0
l_cnt = 0
for i in range(n-1):
    if s[i] == 'R':
        r_cnt += 1
    elif s[i] == 'L':
        l_cnt += 1
    if s[i] == 'L' and s[i+1] =='R' or i == n-2:
        if i == n-2:
            l_cnt += 1
        output(r_cnt, l_cnt)
        r_cnt = 0
        l_cnt = 0


t = list(itertools.chain.from_iterable(t))
for i in t:
    print(i, end=' ')
### BUGGY CODE ###

a = int (input ())
b = 2
number = 1

while number % a != 0 or number % b != 0:
    number += 1

print (number)

### FIXED CODE ###

#jiaofhaosfhao
n=int(input())
if(n%2==1):
	n*=2
print(n)
### BUGGY CODE ###

import numpy as np

def solve(A, F, K):
    lo = 0
    hi = 10 ** 12
    while lo < hi:
        mid = (lo + hi) // 2
        total_train = 0
        for i in range(A.shape[0]):
            need = A[i] - mid // F[i]
            total_train += need if need > 0 else 0
        if total_train <= K:
            hi = mid
        else:
            lo = mid + 1
    return lo

stdin = np.fromstring(open(0).read(), dtype=np.int64, sep=' ')
N, K = stdin[:2]
A = stdin[2: 2 + N]
F = stdin[2 + N:]
print(solve(np.sort(A)[::-1], np.sort(F), K))

### FIXED CODE ###

import numpy as np
i8 = np.int64
i4 = np.int32


def solve(A, F, K):
    min_ = 0
    max_ = 10 ** 12
    while min_ < max_:
        mid = (min_ + max_) // 2
        count = A - mid // F
        sum_ = count[count > 0].sum()
        if sum_ <= K:
            max_ = mid
        else:
            min_ = mid + 1
    return min_

def main():
    stdin = open('/dev/stdin', 'rb')
    pin = np.fromstring(stdin.read(), i8, sep=' ')
    N, K = pin[:2]
    A = pin[2: N + 2]
    F = pin[N + 2: 2 * N + 2]
    A = np.sort(A)[::-1]
    F.sort()
    ans = solve(A, F, K)
    print(ans)

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

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = inpl()
    dp = [{} for _ in range(N + 1)]
    dp[0][0] = 1
    for i, a in enumerate(A):
        for j in range(i, -1, -1):
            for k, v in dp[j].items():
                if k + a > S:
                    continue
                if k + a not in dp[j + 1]:
                    dp[j + 1][k + a] = v
                else:
                    dp[j + 1][k + a] = v + dp[j + 1][k + a]
    # print(dp)

    p2 = [0] * (N + 1)
    p2[0] = 1
    for i in range(1, N + 1):
        p2[i] = (p2[i - 1] * 2) % MOD

    ans = 0
    for i in range(1, N + 1):
        if S in dp[i]:
            ans = (ans + dp[i][S] * p2[N - i]) % MOD
    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import OrderedDict
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def main():
    MOD = 998244353
    N, S = inpl()
    A = sorted(inpl())
    dp = {}
    dp[0] = 1
    for i, a in enumerate(A):
        # print(i, dp)
        ks = sorted(dp.keys())
        for k in ks[::-1]:
            # print(k)
            if k + a <= S:
                if k + a in dp:
                    dp[k + a] = (dp[k] + dp[k + a]) % MOD
                else:
                    dp[k + a] = dp[k]
            dp[k] = (dp[k] * 2) % MOD
    # print(dp)
    print(0 if S not in dp else dp[S])
    return


if __name__ == '__main__':
    main()