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

N = int(input())
S = []
for i in range(N):
  S.append(input())

letter = []
num_letter = []

letter.append(S[0])
num_letter.append(1)
max_num_letter = 1
for i in range(1,N):
  flag = 0
  for j in range(len(letter)):
    if letter[j] == S[i]:
      num_letter[j]+=1
      if num_letter[j] > max_num_letter:
        max_num_letter = num_letter[j]
      flag = 1
      break
  if flag == 0:
    letter.append(S[i])
    num_letter.append(1)

max_letter = []
for i in range(len(letter)):
  if num_letter[i] == max_num_letter:
    max_letter.append(letter[i])
max_letter = sorted(max_letter)
for i in range(len(max_letter)):
  print(max_letter[i])


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
  S.append(input())
S = sorted(S)
#print(S)

max_letter = []
max_count = 0
tmp_S = S[0]
count = 0

for i in range(len(S)):
  if i == 0:
    count=1
    max_letter.append(S[i])
    tmp_S = S[i]
  elif tmp_S != S[i]:
    if max_count < count:
      max_count = count
      max_letter = []
      max_letter.append(tmp_S)
    elif max_count == count:
      max_letter.append(tmp_S)
    tmp_S = S[i]
    count=1
  else:
    count+=1
if max_count < count:
  max_letter = list([tmp_S])
elif max_count == count:
  max_letter.append(tmp_S)
  
for i in range(len(max_letter)):
  print(max_letter[i])
### BUGGY CODE ###

inf = 10**9+5
n,k = map(int,input().split())
h = list( map(int,input().split()))

dp = [inf]*n
dp[0] = 0
for i in range(n):
    for j in range(i+1,i+k+1):
        if j<n:
            dp[j] = min(dp[j],dp[i]+abs(h[i]-h[j]))
print(dp[-1])


### FIXED CODE ###

def main():
    
    n,k =map(int,input().split())
    x = list(map(int, input().split()))
    a = [0]*n
    for i in range (1,n):
        a[i]=(min([abs(x[i]-x[j])+a[j] for j in range(max(0,i-k),i)]))
    print (a[-1])
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np

n=int(input())

a=[]

a= list(map(int,input().split()))

ans=0
for i in range(n-1):
    for k in range(i,n):
        tmp=a[i]^a[k]
        #print(tmp)
        ans=(ans+tmp)%1000000007

print(ans)
    


### FIXED CODE ###

import numpy as np

n=int(input())



a= list(map(int,input().split()))
a=np.array(a,np.int64)


max=60
mod=10**9+7
ans=0
cnt1=0
cnt0=0


for i in range(max):
    new_a=(a>>i & 1)

    cnt1=np.count_nonzero(new_a)
    cnt0=n-cnt1
    ans=(ans+cnt1*cnt0*(2**i))%mod
    cnt1=0
    cnt0=0
print(ans)
### BUGGY CODE ###

a,b,k = map(int,input().split())
taka = a
aoki = b
recur = k
if (taka+aoki)<=k:
  print("0 0")
  exit()
for i in range(k):
  if taka == 0 and aoki == 0:
    break
  if taka >= 1:
    taka -=1
  elif taka == 0 and aoki >= 1:
    aoki -= 1
  
  
print("{} {}".format(taka,aoki))

### FIXED CODE ###

a,b,k = map(int,input().split())
taka = a
aoki = b
recur = k
if taka>=k:
  print("{} {}".format(taka-k,aoki))
elif k>=taka and (aoki+taka)>=k:
  print("{} {}".format(0,aoki-(k-taka)))
elif (aoki+ taka)<=k:
  print("0 0")
### BUGGY CODE ###

N,M=map(int, input().split())
P=[]
S=[]
for i in range(M):
    p,s=input().split()
    P.append(p)
    S.append(s)


import numpy as np
P=np.array(P)
S=np.array(S)

if M>0:
    ans=np.unique(P[S=="AC"])

    wa=0
    for j in ans:
        for i in S[P==j]:
            if i=="WA":
                wa+=1
            else:
                break

    print(len(ans),wa)
else:
    print(0,0)



### FIXED CODE ###

N,M=map(int,input().split())
AC={}
WA={}
for i in range(M):
    a,b=input().split()
    if not(a in AC.keys()):
        if b=="AC":
            AC[a]=1
        else:
            if a in WA.keys():
                WA[a]+=1
            else:
                WA[a]=1
y=0
for i in AC.keys():
    if i in WA.keys():
        y+=WA[i]
print(sum(AC.values()),y)
### BUGGY CODE ###

s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')


### FIXED CODE ###

s = input()

al = [chr(ord('a') + i) for i in range(26)]
c = dict()
for _al in al:
    c[_al] = [0]

for i in range(len(s)):
    for _al in al:
        if _al == s[i]:
            c[_al].append(c[_al][-1] + 1)
        else:
            c[_al].append(c[_al][-1])

f = False
for _al in al:
    tmp = []
    curmin = []
    for i in range(len(c[_al])):
        cur = c[_al][i] * 2 - i

        tmp.append(cur)
        if i == 0:
            curmin.append(cur)
        else:
            curmin.append(min(cur, curmin[-1]))

        if i >= 2 and tmp[-1] > curmin[-3]:
            y = i
            f = True
            break

    if f:
        break

if f:
    for j in range(len(tmp)):
        if tmp[j] == curmin[-3]:
            x = j + 1
            break
    print(' '.join([str(x), str(y)]))
else:
    print('-1 -1')
### BUGGY CODE ###

_ = input()
a = [x for x in input().split()]
b = []
for i in a:
    b.append(i)
    b.reverse()
else:
    print(" ".join(b))

### FIXED CODE ###

from collections import deque

n = int(input())
a = input().split()
b = deque()

for i in range(n):
    if i % 2 != n % 2:
        b.appendleft(a[i])
    else:
        b.append(a[i])
else:
    print(*b)
### BUGGY CODE ###

from collections import deque

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())

c = [input().rstrip() for _ in range(H)]

d = deque([(0, x1-1, y1-1)])
dp = [[False] * W for _ in range(H)]

while d:
    step, x, y = d.popleft()
    if x == x2-1 and y == y2-1:
        print(step)
        break

    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for i in range(1, K+1):
            nx = x + dx * i
            ny = y + dy * i
            if 0 <= nx < H and 0 <= ny < W:
                if c[nx][ny] == '@':
                    break

                if not dp[nx][ny]:
                    dp[nx][ny] = True
                    d.append((step + 1, nx, ny))
            else:
                break
else:
    print(-1)


### FIXED CODE ###

from collections import deque

H, W, K = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())

c = [input().rstrip() for _ in range(H)]

d = deque([(x1-1, y1-1)])

dp = [[-1] * W for _ in range(H)]
dp[x1-1][y1-1] = 0

while d:
    x, y = d.popleft()
    if x == x2-1 and y == y2-1:
        print(dp[x][y])
        break

    for dx, dy in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        for i in range(1, K+1):
            nx = x + dx * i
            ny = y + dy * i

            if 0 > nx or nx >= H or 0 > ny or ny >= W or c[nx][ny] == '@':
                break

            if dp[nx][ny] == -1:
                dp[nx][ny] = dp[x][y] + 1
                d.append((nx, ny))
            elif dp[nx][ny] <= dp[x][y]:
                break
else:
    print(-1)
### BUGGY CODE ###

from queue import Queue

H, W = [int(i) for i in input().split()]
C = [list(input()) for i in range(H)]

dcount = -1
for h in range(H):
    for w in range(W):
        if C[h][w] == '.':
            dcount += 1

INF = 10 ** 6
D = [[INF] * W for i in range(H)]
D[0][0] = 0
q = Queue()
q.put((0, 0))

while q.qsize() > 0:
    h, w = q.get()
    if (h, w) == (H-1, W-1):
        break
    C[h][w] = '#'
    for dh, dw in zip((-1, 1, 0, 0), (0, 0, -1, 1)):
        if 0 <= h+dh < H and 0 <= w+dw < W and C[h+dh][w+dw] == '.':
            D[h+dh][w+dw] = D[h][w] + 1
            q.put((h+dh, w+dw))

print(dcount - D[H-1][W-1] if D[H-1][W-1] != INF else -1)

### FIXED CODE ###

from queue import Queue

H, W = [int(i) for i in input().split()]
C = [list(input()) for i in range(H)]

dcount = -1
for h in range(H):
    for w in range(W):
        if C[h][w] == '.':
            dcount += 1

INF = 10 ** 6
D = [[INF] * W for i in range(H)]
D[0][0] = 0
q = Queue()
q.put((0, 0))

while q.qsize() > 0:
    h, w = q.get()
    if (h, w) == (H-1, W-1):
        break
    for dh, dw in zip((-1, 1, 0, 0), (0, 0, -1, 1)):
        if 0 <= h+dh < H and 0 <= w+dw < W and C[h+dh][w+dw] == '.' and D[h+dh][w+dw] == INF:
            D[h+dh][w+dw] = D[h][w] + 1
            q.put((h+dh, w+dw))

print(dcount - D[H-1][W-1] if D[H-1][W-1] != INF else -1)
### BUGGY CODE ###

#!/usr/bin/env python3

import numpy as np

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = np.array([1, 10, 9, 12, 3, 4], dtype=np.int)

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = np.zeros(13, dtype=np.int)
    priv[0] = 1
    s = S[::-1]
    for i in range(0, len(s)):
        cur = np.zeros(13, dtype=np.int)
        d = s[i]
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] = (cur[(j+m) % 13] + priv[j]) % P_MOD
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        priv = cur
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)


### FIXED CODE ###


P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

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

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

from itertools import product
ans = 2000

for idx,cond in enumerate(product((True,False),repeat=h-1)):
    div = sum(cond)
    spl = [arr[0][:]]
    for i in range(h-1):
        if cond[i]:
            spl.append(arr[i+1][:])
        else:
            spl[-1] = [spl[-1][j] + arr[i+1][j] for j in range(w)]
    num = len(spl)
    cnt = [0]*num
    
    for v in range(w):
        tmp = [spl[i][v] for i in range(num)]
        if max(tmp) > k:
            break
        if max([cnt[i] + tmp[i] for i in range(num)]) > k:
            div += 1
            cnt = tmp[:]
        else:
            cnt  = [cnt[i] + tmp[i] for i in range(num)]
    else:    
        ans = min(ans,div)
            
print(ans)

### FIXED CODE ###

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

from itertools import product
ans = 2000

for idx,cond in enumerate(product((True,False),repeat=h-1)):
    div = sum(cond)
    spl = [arr[0][:]]
    for i in range(h-1):
        if cond[i]:
            spl.append(arr[i+1][:])
        else:
            spl[-1] = [spl[-1][j] + arr[i+1][j] for j in range(w)]
    num = len(spl)
    cnt = [0]*num
    
    for v in range(w):
        tmp = [spl[i][v] for i in range(num)]
        if max(tmp) > k:
            break
        if max([cnt[i] + tmp[i] for i in range(num)]) > k:
            div += 1
            cnt = tmp[:]
        else:
            cnt  = [cnt[i] + tmp[i] for i in range(num)]
    else:    
        ans = min(ans,div)
            
print(ans)
### BUGGY CODE ###

import itertools
K, N = map(int, input().split())
A = list(map(int, input().split()))

A_list = list(itertools.permutations(A, N))
ans = 10**8
for i in A_list:
    tmp = 0
    
    if (i[0] == min(A) and i[2] == max(A)) or  (i[0] == max(A) and i[2] == min(A)):
        for j in range(N-1):
            if abs((i[j+1]) - (i[j])) <= abs(K-i[j+1]):
                tmp = tmp +  abs((i[j+1]) - (i[j]))
            else:
                tmp = tmp + abs(K-i[j+1])
        
        if tmp <= ans:
            ans = tmp
    else:
        pass
print(ans)

### FIXED CODE ###

K,N = map(int, input().split())
A = [int(a) for a in input().split()]

ans = A[-1]-A[0]
for i in range(N-1):
    ans = min(ans, K-A[i+1]+A[i])
print(ans)
### BUGGY CODE ###

N=int(input())
S=input()
max=0

for f in range(len(S)-1):
    #print("roop "+str(f))
    i = f+1
    A = [0] * (len(S)-f+i)
    A[0]=len(S)
    while(i<len(S)):
        j=0
        #print("i=" + str(i) + " j=" + str(j))
        while(i+j<len(S) and S[f+j]==S[i+j] and j<i):
            j+=1
            #print(S[f+j]+" "+S[i+j])
        A[i]=j
        if(j>max):
            max=j
            #print("update max ="+str(max))

        if(j==0):
            i+=1
            continue
        k=1
        while(k+i<len(S) and k+A[k]<j):
            A[i+k]=A[k]
            k+=1
        i+=k



#print(A)
print(max)

### FIXED CODE ###

N=int(input())
S=input()

max = 0
index = 0
for i in range(1,len(S)-1):
    s1=S[index:i]
    s2=S[i:]
    if s1 in s2:
        max=len(s1)
    else:
        index+=1
        
print(max)
### BUGGY CODE ###

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

for i in range(N):
    X_1 = X[:i] + X[i+1:]
    X_1.sort()
    print(X_1[N//2-1])

### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)

a = Y[(N-1)//2]
b = Y[(N+1)//2]

for i in X:
    if i > a:
        print(a)
    else:
        print(b)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A_i = [int(input()) for _ in range(Q)]

# print(N, K, Q, A_i)

scores = [K] * N
for i in range(Q):
    for j in range(N):
        if A_i[i] != j + 1:
            scores[j] -= 1

for j in range(N):
    print('No' if scores[j] <= 0 else 'Yes')


### FIXED CODE ###

from collections import Counter

N, K, Q = map(int, input().split())
A_i = [int(input()) for _ in range(Q)]

counter = Counter()

for i in range(Q):
    counter[A_i[i]] += 1

for j in range(N):
    print('Yes' if Q - counter[j+1] < K else 'No')
### BUGGY CODE ###

def prime(a):
	if a==1:
		return 0
	n=2
	while n<a:
		if a%n==0:
			return 0
		n+=1
	return 1

N=int(input())

count=0
for i in range(N):
	a=int(input())
	count+=prime(a)
print(count)

### FIXED CODE ###

import math

def prime(a):
	if a==1:
		return 0
	n=2
	while n<=math.sqrt(a):
		if a%n==0:
			return 0
		n+=1
	return 1

N=int(input())

count=0
for i in range(N):
	a=int(input())
	count+=prime(a)
print(count)
### BUGGY CODE ###

import copy

N=int(input())

A=list(map(int,input().split()))

#print(A)


for i in range(N):
    AA=copy.deepcopy(A)
    del AA[i]
    #print(AA)

    Aset=set(AA)
    count=0
    for i in Aset:
        aa=AA.count(i)
        #print(i,aa)
        count+=int((aa*(aa-1))/2)
    print(count)


### FIXED CODE ###

from collections import Counter
N=int(input())
A=list(map(int,input().split()))

parent=dict()
An=set(A)
parecou=0
aaa=Counter(A)
for i in aaa.values():
    parecou+=int((i*(i-1)/2))
"""
for i in An:
    f=A.count(i)
    parent[i]=f
    parecou+=int((f*(f-1)/2))
"""


#print(parecou)
for i in range(N):
    anko=aaa[A[i]]
    print(parecou-int((anko*(anko-1)/2))+int(((anko-2)*(anko-1)/2)))
    #print(parecou-anko+1)
### BUGGY CODE ###

s=input()
k=int(input())
l=len(s)
a={s[i:j] for i in range(l) for j in range(i+1,l+1)}
b=list(a)
b.sort()
print(b[k-1])

### FIXED CODE ###

s=input()
k=int(input())
l=len(s)
a={s[i:i+j+1] for i in range(l) for j in range(k+1)}
a=list(a)
a.sort()
print(a[k-1])
### BUGGY CODE ###

h, w, m = map(int, input().split())
HW = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]
for i in range(m):
    h,w = HW[i]
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

h_num_ix = {}
for num,ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)

w_num_ix = {}
for num,ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

# print(h_num_ix)
# print(w_num_ix)
# print(max_h_num)
# print(max_w_num)
# print('====')

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        if [h_ix, w_ix] in HW: continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)


### FIXED CODE ###

h, w, m = map(int, input().split())
HW = [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]

sum_h = [[0,0] for _ in range(h)] # [sum, index]
sum_w = [[0,0] for _ in range(w)]
for i in range(m):
    h,w = HW[i]
    sum_h[h][0] += 1
    sum_w[w][0] += 1
    sum_h[h][1] = h
    sum_w[w][1] = w

h_num_ix = {}
for num,ix in sum_h:
    if not num in h_num_ix:
        h_num_ix[num] = set()
    h_num_ix[num].add(ix)

w_num_ix = {}
for num,ix in sum_w:
    if not num in w_num_ix:
        w_num_ix[num] = set()
    w_num_ix[num].add(ix)

max_h_num = max(h_num_ix)
max_w_num = max(w_num_ix)

# print(sorted(HW))
# print('---')
# print(h_num_ix)
# print(w_num_ix)
# print(max_h_num)
# print(max_w_num)
# print('====')

SHW = set()
for h,w in HW:
    SHW.add((h,w))
# print(SHW)

max_num = max_h_num + max_w_num - 1
for h_ix in h_num_ix[max_h_num]:
    for w_ix in w_num_ix[max_w_num]:
        num = max_h_num + max_w_num
        # if [h_ix, w_ix] in HW: continue
        if (h_ix, w_ix) in SHW: continue
        max_num += 1
        print(max_num)
        exit()
print(max_num)
### BUGGY CODE ###

def main():
    n,q = map(int,input().split())
    node = [[]for _ in range(n)]
    looked = [1 for _ in range(n)]
    for i in range(n-1):
        a,b = map(int,input().split())
        node[b-1].append(a-1)
        node[a-1].append(b-1)
    counter = [0 for _ in range(n)]
    for i in range(q):
        p,x = map(int,input().split())
        counter[p-1] += x
    queue = [0]
    looked[0] = 0
    while(queue):
        now = queue.pop(0)
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)
main()

### FIXED CODE ###

from collections import deque
def main():
    n,q = map(int,input().split())
    node = [[]for _ in range(n)]
    looked = [1]*n
    for i in range(n-1):
        a,b = map(int,input().split())
        node[b-1].append(a-1)
        node[a-1].append(b-1)
    counter = [0]*n
    for i in range(q):
        p,x = map(int,input().split())
        counter[p-1] += x
    queue = deque([0])
    looked[0] = 0
    while(queue):
        now = queue.pop()
        for i in node[now]:
            if looked[i]:
                queue.append(i)
                counter[i] += counter[now]
                looked[i] = 0
    print(*counter)
main()
### BUGGY CODE ###

S=raw_input()
l=len(S)

dp=[ [ 0 for j in range(13)] for i in range(l+1) ]
dp[0][0]=1

mod=10**9+7


for i in range(1,l+1):
	for j in range(13):
		if dp[i-1][j]!=0:
			if S[i-1]=="?":
				for k in range(10):
					dp[i][ (k*pow(10,l-i,13)+j)%13 ]+=dp[i-1][j]
					dp[i][ (k*pow(10,l-i,13)+j)%13 ]%=mod
			else:
				k=int(S[i-1])
				dp[i][ (k*pow(10,l-i,13)+j)%13 ]+=dp[i-1][j]
				dp[i][ (k*pow(10,l-i,13)+j)%13 ]%=mod

print dp[-1][5]


### FIXED CODE ###

S=raw_input()
S=S[::-1]
l=len(S)

dp=[ 0 for j in range(13) ]
dp[0]=1

mod=10**9+7

dp2=[ 0 for _ in range(13) ]

keta=1

for i in range(1,l+1):
	dp2=[0]*13
	for j in range(13):
		if dp[j]!=0:
			if S[i-1]=="?":
				for k in range(10):
					next=(k*keta+j)%13 
					dp2[next]+=dp[j]
					dp2[next]%=mod
			else:
				k=int(S[i-1])
				next=(k*keta+j)%13
				dp2[next]+=dp[j]
				dp2[next]%=mod

	dp=dp2
	keta=(keta*10)%13

print dp[5]
### BUGGY CODE ###

from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            cnt = 0
            q = deque([(i, j, cnt)])
            v = set()
            while q:
                ii, jj, cnt = q.popleft()
                v.add((ii, jj))
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
    return ret


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            v = set()
            q = deque([(i, j, 0)])
            v.add((i, j))
            while q:
                ii, jj, cnt = q.popleft()
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                    v.add((ii + 1, jj))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                    v.add((ii, jj + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                    v.add((ii - 1, jj))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
                    v.add((ii, jj - 1))
    return ret


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

def f_knapsack_for_all_subsets(MOD=998244353):
    N, S = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    # dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数
    dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
    dp[0][0] = 1  # インデックスの集合が空のとき、和は 0
    for i, a in enumerate(A):
        for j in range(S + 1):
            # editorial でいうところの選択肢 2, 3 に相当するので、2 倍
            dp[i + 1][j] += 2 * dp[i][j]
            dp[i + 1][j] %= MOD
            if j + a <= S:  # 選択肢 1
                dp[i + 1][j + a] += dp[i][j]
                dp[i + 1][j + a] %= MOD
    return dp[N][S]

print(f_knapsack_for_all_subsets())

### FIXED CODE ###

def f_knapsack_for_all_subsets(MOD=998244353):
    N, S = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    # dp[i][j]: i 番目の要素を見たとき、和が j であるような場合の数
    dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
    dp[0][0] = 1  # インデックスの集合が空のとき、和は 0 の 1 通り
    for i, a in enumerate(A):
        for j in range(S + 1):
            # editorial でいうところの選択肢 2, 3 に相当するので、2 倍
            dp[i + 1][j] += 2 * dp[i][j]
            dp[i + 1][j] %= MOD
            if j + a <= S:  # 選択肢 1
                dp[i + 1][j + a] += dp[i][j]
                dp[i + 1][j + a] %= MOD
    return dp[N][S]

print(f_knapsack_for_all_subsets())