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

n,a,b,*v=map(int,open(0).read().split())
l=[]
for t in range(1,2**n):
    c=[(t>>s&1)*v[s]for s in range(n)]
    if a<=sum((i!=0)for i in c)<=b:
        l.append(sum(c)/sum((i!=0)for i in c))
print(max(l))
print(l.count(max(l)))

### FIXED CODE ###

from collections import*
from itertools import*
from bisect import*
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
 
n,a,b,*v=map(int,open(0).read().split())
v=sorted(Counter(v).items(),reverse=1,key=lambda x:x[0])
vindex=[0]+list(accumulate(V for K,V in v))+[float("inf")]
#print(v,vindex)
lower=vindex[bisect_left(vindex,a)-1]
upper=vindex[bisect_left(vindex,a)]
count=0
ans=0
 
if a<=vindex[1]:
    ans=0
    for i in range(a,min(b,vindex[1])+1):
        ans+=cmb(vindex[1],i)
    print(float(v[0][0]))
    print(ans)
 
else:
    for s,t in v:
        count+=t
        if count>lower:
            ans+=s*(a-lower)
            break
        else:
            ans+=s*t
    print(ans/a)
    print(cmb(upper-lower,a-lower))
### BUGGY CODE ###

from sys import stdin
h, n = map(int, input().split())
magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
INF = float('inf')
ans = [INF]*(h+1)
ans[-1] = 0

for i in range(h, 0, -1):
    if ans[i] == float('inf'):
        continue
    else:
        for j in magic:
            if i-j[0] < 0:
                if ans[0] > ans[i]+j[1]:
                    ans[0] = ans[i]+j[1]
            elif ans[i-j[0]] > ans[i]+j[1]:
                ans[i-j[0]] = ans[i]+j[1]
print(ans[0])




### FIXED CODE ###

def num():
    from sys import stdin
    h, n = map(int, input().split())
    magic = [list(map(int, stdin.readline().split())) for _ in range(n)]
    INF = float('inf')
    ans = [INF]*(h+1)
    ans[-1] = 0

    for i in range(h, 0, -1):
        if ans[i] != INF:
            for j, k in magic:
                if i-j < 0:
                    num = ans[i]+k
                    if ans[0] > num:
                        ans[0] = num
                else:
                    num = ans[i]+k
                    if ans[i-j] > num:
                        ans[i-j] = num
    return ans[0]
print(num())
### BUGGY CODE ###

import itertools
N,K=map(int,input().split())
L=[]
for l in range(N):
  L.append(int(input()))
ans=[]
for r in list(itertools.combinations(L,K)):
  ans.append(max(r)-min(r))
print(min(ans))

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
ans=[]
for i in range(len(h)-K+1):
  b=h[K+i-1]-h[i]
  ans.append(b)
print(min(ans))
### BUGGY CODE ###

n,m=map(int,input().split())
L=list(map(int,input().split()))
import bisect
L=list(sorted(L))
for i in range(m):
    x=L.pop()//2
    y=bisect.bisect_left(L,x)
    L.insert(y,x)
print(sum(L))

### FIXED CODE ###

n,m=map(int,input().split())
L=list(map(int,input().split()))
Lh=list(map(lambda x: x*(-1), L))
import heapq
#heapqは置き直さなくてOK
heapq.heapify(Lh)
for _ in range(m):
    x=heapq.heappop(Lh)
    heapq.heappush(Lh,(x+1)//2)#負の数の割り算のため+1
print(sum(Lh)*(-1))
### BUGGY CODE ###

q=int(input())
LR=[[int(i) for i in input().split()] for _ in range(q)]
sosu=[False]*(10**5+1)
question=[0]*(10**5+1)
for i in range(2,10**5+1):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            break
    else:
        sosu[i]=True
for i in range(3,10**5+1):
    if sosu[i] and sosu[(i+1)//2]:
        question[i]=1
for l,r in LR:
    print(sum(question[l:r+1]))

### FIXED CODE ###

q=int(input())
LR=[[int(i) for i in input().split()] for _ in range(q)]
sosu=[False]*(10**5+1)
question=[0]*(10**5+1)
for i in range(2,10**5+1):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            break
    else:
        sosu[i]=True
for i in range(3,10**5+1):
    if sosu[i] and sosu[(i+1)//2]:
        question[i]=1
for i in range(1,10**5+1):
    question[i]+=question[i-1]
for l,r in LR:
    print(question[r]-question[l-1])
### BUGGY CODE ###

n = int(input())
mem={}
def gcd(a,b,c):
    key=tuple(sorted((a,b,c)))
    if key in mem:
        return mem[key]
    ret=1
    for i in range(2, min(a,b,c)+1):
        if a%i==0 and b%i==0 and c%i==0:
            ret=i
    mem[key]=ret
    return ret
        
ans=0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            ans+=gcd(i, j, k)
print(ans)

### FIXED CODE ###

from math import gcd
k = int(input())+1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i,j),l)
print(ans)
### BUGGY CODE ###

h, n = map(int, input().split())
dp = [0] * (h+1)
for i in range(n):
        a, b = map(int, input().split())
        for j in range(1, h+1):
            if i == 0:
                if j - a <= 0:
                    dp[j] = b
                else:
                    dp[j] = dp[j-a] + b
            else:
                if j - a <= 0:
                    dp[j] = min(dp[j], b)
                else:
                    dp[j] = min(dp[j], dp[j-a] + b)
print(dp[-1])


### FIXED CODE ###

h, n = map(int, input().split())
dp = [0] * (h+1)
for i in range(n):
        a, b = map(int, input().split())
        for j in range(1, h+1):
            if i == 0 and j - a <= 0:
                dp[j] = b
            elif i == 0:
                dp[j] = dp[j-a] + b
            elif j - a <= 0:
                dp[j] = min(dp[j], b)
            else:
                dp[j] = min(dp[j], dp[j-a] + b)
print(dp[-1])
### BUGGY CODE ###

n,m = map(int,input().split())
h = [int(x) for x in input().split()]
g = [[0 for j in range(n)] for i in range(n)]

for _ in range(m):
    a, b = map(int,input().split())
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1

count = 0
for i in range(n):
    judge = True
    for j in range(n):
        if g[i][j] == 1:
            if h[i] <= h[j]:
                judge = False
                break
            else:
                judge = True
    if judge ==True:
        count+=1
print(count)


### FIXED CODE ###

n,m = map(int,input().split())
h = [int(x) for x in input().split()]

result = [1]*n

for _ in range(m):
    a, b = map(int,input().split())
    if h[a-1] < h[b-1]:
        result[a-1] = 0
    elif h[a-1] > h[b-1]:
        result[b-1] = 0
    else:
        result[a-1] = 0
        result[b-1] = 0
print(result.count(1))
### BUGGY CODE ###

import fractions
import copy

n = int(input())
a = list(map(int,input().split()))
nlist = []

def calc_gcd(list):
    ans = list[0]
    for i in range(1,n-1):
        ans = fractions.gcd(ans,list[i])
    return ans

#a = [1,2,3,4,5,6,7]

for j in range(n):
    b= copy.copy(a)
    b.pop(j)
    nlist.append(calc_gcd(b))

#print(nlist)
print(max(nlist))
#
# print(calc_gcd([16,100,4000]))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
lgcd = [0]*N
rgcd = [0]*N
from fractions import gcd
#def gcd(a,b):
#    if b == 0:return a
#    else:return gcd(b, a%b)

temp_lgcd = A[0]
for i in range(N):
    temp_lgcd = gcd(temp_lgcd,A[i])
    lgcd[i] = temp_lgcd

temp_rgcd = A[-1]
for i in range(N-1,-1,-1):
    temp_rgcd = gcd(temp_rgcd,A[i])
    rgcd[i] = temp_rgcd

ans = 0
for i in range(N):
    if i == 0:
        calc_gcd = rgcd[1]
    elif i == N-1:
        calc_gcd = lgcd[-2]
    else:
        calc_gcd = gcd(lgcd[i-1],rgcd[i+1])
    ans = max(ans,calc_gcd)
print(ans)
### BUGGY CODE ###

# coding: utf-8
import math
import collections


def main():
    n = int(input())
    inputs = [input() for i in range(n)]
    inputs_list = []
    for s in inputs:
        tmp = s.split(' ')
        if int(tmp[0]) - int(tmp[1]) < 0:
            for i in range(0, int(tmp[0]) + int(tmp[1])):
                inputs_list.append(i)
        else:
            for i in range(int(tmp[0]) - int(tmp[1]), int(tmp[0]) + int(tmp[1])):
                inputs_list.append(i)

    c = collections.Counter(inputs_list)
    print(n - (c.most_common()[0][1] - 1))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding: utf-8
def main():
    n = int(input())
    inputs = [input().split() for i in range(n)]
    inputs_list = []
    for i in inputs:
        if int(i[0]) - int(i[1]) < 0:
            inputs_list.append([0, int(i[0]) + int(i[1])])
        else:
            inputs_list.append([int(i[0]) - int(i[1]), int(i[0]) + int(i[1])])
    sorted_data = sorted(inputs_list, key=lambda x: (x[1]))

    ans = [sorted_data[0]]
    cur = ans[0][1]
    for i in range(len(sorted_data) - 1):
        if cur <= sorted_data[i + 1][0]:
                ans.append(sorted_data[i + 1])
                cur = sorted_data[i + 1][1]
    print(len(ans))


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

def abc082_c():
    _ = int(input())
    a = list(map(int, input().split()))
    ans = 0

    for val in set(a):
        num = a.count(val)
        if num >= val:
            ans += (num-val)
        else:
            ans += num

    print(ans)


abc082_c()

### FIXED CODE ###

def abc082_c():
    from collections import Counter

    _ = int(input())
    a = list(map(int, input().split()))
    ans = 0
    a_count = Counter(a)

    for num in a_count:
        if num <= a_count[num]:
            ans += (a_count[num] - num)
        else:
            ans += a_count[num]

    print(ans)


abc082_c()
### BUGGY CODE ###

N = int(input())

dicts = {}

for _ in range(N):
    S = input()
    if S in dicts:
        dicts[S] += 1
    else:
        dicts[S] = 1

max_list = [kv[0] for kv in dicts.items() if kv[1] == max(dicts.values())]

for s in sorted(max_list):
    print(s)

### FIXED CODE ###

N = int(input())

dicts = {}

for _ in range(N):
    S = input()
    if S in dicts:
        dicts[S] += 1
    else:
        dicts[S] = 1

dicts = sorted(dicts.items(), key=lambda x:x[1], reverse=True)
max_list = []

buf = dicts[0][1]
for k, v in dicts:
    if v == buf:
        max_list.append(k)
    else:
        break

for k in sorted(max_list):
    print(k)
### BUGGY CODE ###

import statistics
from decimal import Decimal,ROUND_HALF_UP

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

for i in range(n):
    a[i] -= i+1
a.sort()

med = Decimal(str(statistics.median(a))).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
print(sum([abs(i-med) for i in a]))

### FIXED CODE ###

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

for i in range(n):
    a[i] -= i+1
a.sort()

ans = 0
for i in range(n):
    ans += abs(a[i] - a[n//2])
print(ans)
### BUGGY CODE ###

R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)


### FIXED CODE ###

R, G, B, N = map(int,input().split())
cnt = 0
for r in range(N//R + 1):
    for g in range((N-R*r)//G + 1):
        x = N - R*r - G*g
        if x >= 0 and x % B == 0:
            cnt += 1
print(cnt)
### BUGGY CODE ###

Num = int(input())
check,check1 = 0,Num

while not 0 < check1 < 1:
    check += Num % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')

### FIXED CODE ###

Num = int(input())
check,check1 = 0,Num

while not 0 <= check1 < 1:
    check += check1 % 10
    check1 = int(check1 / 10 )

if (Num % check) == 0 :
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import sys

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#実際に書き込む
N = ri()
S = [rs() for _ in range(N)]
answer = 0
a = 0
for b in range(N):
    bool = True
    for i in range(N):
        for j in range(i+1, N):
            y1 = i
            x1 = (j+b)%(N)
            y2 = j
            x2 = (i+b)%(N)
            if S[y1][x1] != S[y2][x2]:
                bool = False
                break
        else:
            continue
        break
    else:
        if bool:
            #print(a, b, i, j, y1, x1, y2, x2)
            answer += 1
answer *= N
print(answer)

#16



### FIXED CODE ###

import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces

N = ri()
S = np.array([list(rs()) for _ in range(N)])

S = np.concatenate([S, S], axis=0)
answer = 0
for b in range(N):
    S2 = S[b:b+N]
    if (S2 == S2.T).all():
        answer += N

print(answer)
### BUGGY CODE ###

import itertools
n=int(input())
a=list(map(int, input().split()))
ans=0

for v in itertools.combinations(a, 2):
    ans += v[0]*v[1]
    if ans > (10 ** 9 + 7):
        ans = ans % (10 ** 9 + 7)

print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
ans=0

s=sum(a)

for i in range(1,len(a)+1):
    ans += a[i-1] * (s-a[i-1])
    s = s-a[i-1]
    ans = ans % (10 ** 9 + 7)

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

# -*- coding: utf-8 -*-
import sys 
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M= map(int,readline().split())
h_cnt = [0]*(H+1)
w_cnt = [0]*(W+1)
data = [[False]*(W+1) for i in range(H+1)]

for i in range(M):
    h,w = map(int,readline().split())
    data[h][w] = True
    h_cnt[h] += 1 
    w_cnt[w] += 1
    
max_h = max(h_cnt)
max_w = max(w_cnt)

max_h_ind = []
max_w_ind = []
max_h_cnt = 0
max_w_cnt = 0

for i in range(H+1):
    if max_h == h_cnt[i]:
        max_h_cnt += 1
        max_h_ind.append(i)

for i in range(W+1):
    if max_w == w_cnt[i]:
        max_w_cnt += 1
        max_w_ind.append(i)
max_h_ind = set(max_h_ind)
max_w_ind = set(max_w_ind)

t = list(itertools.product(max_h_ind, max_w_ind))

if max_w_cnt * max_h_cnt > M:
    print(max_h+max_w)
else:
    for h,w in t:
        if data[h][w] == False:
            print(max_h+max_w)
            sys.exit()
    print(max_h+max_w-1)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys 
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H, W, M = map(int,readline().split())
h_cnt = [0]*(H+1)
w_cnt = [0]*(W+1)
bomb = []
 
for i in range(M):
    h,w = map(int,readline().split())
    bomb.append((h,w))
    h_cnt[h] += 1 
    w_cnt[w] += 1
    
maxh = max(h_cnt)
maxw = max(w_cnt)
maxhCnt = h_cnt.count(maxh)
maxwCnt = w_cnt.count(maxw)

total = maxhCnt*maxwCnt
ans = maxh+maxw
cnt = 0
for h,w in bomb:
    if h_cnt[h] == maxh and w_cnt[w] == maxw:
       cnt += 1

print(ans-1 if cnt == total else ans)
### BUGGY CODE ###

import math
n,a,b = map(int, input().split())
#include a b
all_case = 2 ** n - 1
a_case = math.factorial(n)*pow((math.factorial(a)*math.factorial(n-a)),((10**9+7)-2),10**9+7)
b_case = math.factorial(n)*pow((math.factorial(b)*math.factorial(n-b)),((10**9+7)-2),10**9+7)
res = int((all_case-a_case-b_case)%(10**9+7))
print(res)

### FIXED CODE ###

n,a,b = map(int,input().split())
mod = 10**9+7
def combination(N,K):
    bunsi = 1
    bunbo = 1
    for i in range(K):
        bunsi = bunsi*(N-i)%mod
        bunbo = bunbo*(i+1)%mod
    return bunsi*pow(bunbo,mod-2,mod)%mod
all_num = pow(2,n,mod)-1
ans = all_num-combination(n,a)-combination(n,b)
print(ans%mod)
### BUGGY CODE ###

import queue
q = queue.Queue()
n, m = map(int, input().split())
mat = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  mat[a-1].append((a-1,b-1))
  mat[b-1].append((b-1,a-1))

d_list = [(-1,-1)]*n

d_list[0] = (0,0)
while len(mat[0]) > 0:
  q.put(mat[0].pop())

while not q.empty():
  u,v = q.get()

  if d_list[v][1] != -1 and d_list[v][1] <= d_list[u][1]+1:
    pass
  else:
    d_list[v] = (u, d_list[u][1]+1)
    while len(mat[v]) > 0:
      q.put(mat[v].pop())
print("Yes")
for i in range(1,n):
  print(d_list[i][0]+1)

### FIXED CODE ###

import queue
q = queue.Queue()
n, m = map(int, input().split())
mat = [[] for i in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  mat[a-1].append((a-1,b-1))
  mat[b-1].append((b-1,a-1))

d_list = [(-1,-1)]*n

d_list[0] = (0,0)
while len(mat[0]) > 0:
  q.put(mat[0].pop())

while not q.empty():
  u,v = q.get()

  if d_list[v][1] != -1 and d_list[v][1] <= d_list[u][1]+1:
    pass
  else:
    d_list[v] = (u, d_list[u][1]+1)
    while len(mat[v]) > 0:
      q.put(mat[v].pop())
print("Yes")
for i in range(1,n):
  print(d_list[i][0]+1)
### BUGGY CODE ###

import copy
N = int(input())
A = list(map(int, input().split()))
idx = dict()

def find(idx, K):
  res = 0
  idx[K] -= 1
  for key in idx:
    if idx[key] != 0:
      res += int(idx[key] * (idx[key] - 1) / 2)
  return res
  
for i in A:
  if i in idx:
    idx[i] += 1
  else:
    idx[i] = 1
    
for i in range(N):
  print(find(copy.copy(idx), A[i]))



### FIXED CODE ###

import copy
N = int(input())
A = list(map(int, input().split()))
A_sum = 0
A2 = []
idx = dict()

for i in A:
  if i in idx:
    idx[i] += 1
  else:
    idx[i] = 1
    
for key in idx:
  if idx[key] == 1:
    idx[key] = [idx[key], 0]
  else:
    temp = int(idx[key] * (idx[key] - 1)/2)
    A_sum += temp
    temp = temp - int(temp * (idx[key] - 2) / idx[key])
    idx[key] = [idx[key], temp]
  
for i in range(N):
  key = A[i]
  print(A_sum - idx[key][1])
### BUGGY CODE ###

A, B, N = map(int, input().split())
maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


for x in range(N + 1):
    check = floor(A * x / B) - A * floor(x / B)
    maxFloor = max(maxFloor, check)
print(maxFloor)


### FIXED CODE ###

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

maxFloor = 0


def floor(x):
    num = int(x // 1)
    return num


if B - 1 <= N:
    check = floor(A * (B - 1) / B) - A * floor((B - 1) / B)
    print(check)
else:
    check = floor(A * N / B) - A * floor(N / B)
    print(check)
### BUGGY CODE ###

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

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

Swap=["" for i in range(M)]

for i in range(M):
    Swap[i]=set(map(int,input().split()))


Y=[set() for i in range(N)]
Unstacked=list(range(M))

Y[0]=Y[0]|Swap[0]
Unstacked.remove(0)
j=0
k=0

while Unstacked!=[]:
    while j <len(Unstacked):

        if Y[k] & Swap[Unstacked[j]] !=set():

            Y[k]=Y[k]|Swap[Unstacked[j]]
            Unstacked.remove(Unstacked[j])
            #print(Y,j,Unstacked)
            j=0

        else:
            j+=1

    if Unstacked!=[]:
        
        k+=1
        Y[k]=Swap[Unstacked[0]]
        Unstacked.remove(Unstacked[0])


#print(Y,j,k,Unstacked)

Other=set(range(1,N+1))
for l in range(k+1):
    Other=Other - Y[l]
    #print(l,Y,Other)

#print(Other)

Other=list(Other)

count=0

for i in range(k+1):
    for j in list(Y[i]):
        if P[j-1] in Y[i]:
            #print(i,j,P[j-1],Y[i])
            count+=1
        

for m in Other:
    if P[m-1]==m:
        #print(m)
        count+=1

print(count)

### FIXED CODE ###

N, M = map(int,input().split())
P=list(map(int,input().split()))

Group=[i for i in range(N+1)]


Swap=[None]*M
for i in range(M):
    Swap[i]=sorted(map(int,input().split()))

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

for i in range(M):
    if find(Swap[i][1]) != find(Swap[i][0]):
        Group[find(Swap[i][1])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[find(Swap[i][0])]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))
        Group[Swap[i][1]]=min(find(Swap[i][1]),find(Swap[i][0]))

count=0

for i in range(N):
    if find(P[i])==find(i+1):
        count+=1


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

import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000) 
n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
A = [0]*(n)
if k >= n:
    k = n
for i in range(1,k):
    A[i] = abs(l[i]-l[0])
for i in range(k,n):
    tmp = float('Inf')
    for j in range(1,k+1):
        dis = A[i-j] + abs(l[i]-l[i-j])
        tmp = min(tmp,dis)
    A[i] = tmp
print(A[n-1])
### BUGGY CODE ###

import sys
import heapq
from collections import deque
input = sys.stdin.readline

def main():        
    h,w=map(int,input().split())
    s=[[]*w for _ in range(h)]
    for i in range(h):
        s[i]=list(input())
    chk=deque()
    d=[[0,1],[0,-1],[1,0],[-1,0]]

    def bfs(x,y):
        ans,dist=0,0
        a=[[-1]*w for _ in range(h)]
        chk=[(x,y,0)]
        a[x][y]=0
        while chk:
            x,y,dist=chk.pop(0)
            bx,by=x,y
            a[x][y]=dist
            for dx,dy in d:
                x=dx+bx
                y=dy+by
                if x>=0 and y>=0 and x<=h-1 and y<=w-1:
                    if s[x][y]=='.' and a[x][y]==-1:
                        chk.append((x,y,dist+1))
            ans=max(ans,dist)
        return ans
    
    ans=0
    for i in range(h):
        for j in range(w):
            if s[i][j]=='#':
                continue
            ans=max(ans,bfs(i,j))
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import heapq
from collections import deque
input = sys.stdin.readline

def main():        
    h,w=map(int,input().split())
    s=[input() for _ in range(h)]

    def bfs(x,y):
        dist=[[-1]*w  for _ in range(h)]
        seen=[[False]*w for _ in range(h)]
        stk=[(x,y,0)]
        while stk:
            px,py,dst=stk.pop(0)
            if seen[px][py]:
                continue
            seen[px][py]=True
            
            if s[px][py]=='#':
                dist[px][py]=0
                continue
            
            for x,y in [(-1,0),(1,0),(0,-1),(0,1)]:
                if px+x<0 or px+x>=h or py+y<0 or py+y>=w:
                    continue
                else:
                    stk.append((px+x,py+y,dst+1))
            dist[px][py]=dst
        ans=0
    
        for i in range(h):
            ans=max(max(dist[i]),ans)
        return ans
    
    ans=0
    for i in range(h):
        for j in range(w):
            if s[i][j]=='#':
                continue
            ans=max(ans,bfs(i,j))
    print(ans)

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

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
X = N + M
sum_n = 0
sum_m = 0
ans = 0
for i in range(1,X+1):
    for j in range(i+1):
        n = j
        m = i - j
        if(n <= N and m <= M):
            for k in range(n):
                sum_n += A[k]
            for l in range(m):
                sum_m += B[l]
            if((sum_m + sum_n) <= K):
                ans=i
                sum_m = 0
                sum_n = 0
                break
            sum_m = 0
            sum_n = 0
print(ans)

### FIXED CODE ###

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
### BUGGY CODE ###

s=input()
k=int(input())
n=len(s)
a=[]
for i in range(n):
  for j in range(i+1,n+1):
    a=set(a)|set([s[i:j]])
a=sorted(a)
print(a[k-1])

### FIXED CODE ###

s=input()
k=int(input())
n=len(s)
a=set([])
for i in range(n):
  for j in range(1,k+1):
    a.add(s[i:i+j])
a=sorted(a)
print(a[k-1])
### BUGGY CODE ###

n=int(input())
num=[int(i) for i in input().split()]

ch=[set(list(range(1,i+2))) for i in range(n)]
#print(ch)
ans=1
s={num[0]}
st=set()
for i in range(1,n):
  #print(s)
  if ch[num[i]-1] & s == st:
    ans+=1
  s.add(num[i])
#print(set(list(range(8))))
print(ans)

### FIXED CODE ###

n=int(input())
num=[int(i) for i in input().split()]

ans=1
ch=num[0]
for i in range(1,n):
  if  num[i]<=ch:
    ans+=1
  ch=min(ch,num[i])
print(ans)