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

from collections import deque

def bfs(grid, queue, wall):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        cnt,y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([cnt+1,y_,x_])
            grid[y_][x_] = wall
            ans = max(ans, cnt+1)
    return ans

H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for i in range(W+2)]
grid = [edges]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([0,i,j])
    grid.append(S)
grid.append(edges)
print(bfs(grid, queue, wall))


### FIXED CODE ###

from collections import deque

def bfs(grid, queue, wall):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        cnt,y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([cnt+1,y_,x_])
            grid[y_][x_] = wall
            ans = max(ans, cnt+1)
    return ans

H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for i in range(W+2)]
grid = [edges]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([0,i,j])
    grid.append(S)
grid.append(edges)
print(bfs(grid, queue, wall))
### BUGGY CODE ###

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

a = sorted(a)

import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
  
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
  
ans = 0
i = n - 1
tmp0 = a[i] / 2
tmp1 = getNearestValue(a[0:i], tmp0)
tmp2 = cmb(a[i], tmp1)
if tmp2 > ans:
    ans = tmp2
    ans1 = a[i]
    ans2 = tmp1
print(ans1, ans2)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np
 
n = int(input())
a = [int(i) for i in input().split()]
 
#print(a)
a = np.sort(a)
ai = a[n-1]
aj = a[0]
center = ai / 2
diff = ai
i=0
for m in a:
    if diff > abs(m - center) :
        aj = m
        diff = abs(aj - center)
    else:
        break
 
print(ai,aj)
### BUGGY CODE ###

from bisect import bisect,insort
n=int(input())
p=list(map(int,input().split()))
p=[0]+p
q=[0]*(n+1)
for i in range(1,n+1):
    q[p[i]]=i
lst=[0,q[n],n+1]
ans=0
for i in range(1,n):
    k=i
    i=n-i
    num=q[i]
    a=bisect(lst,num)
    if a==1:
        ans+=i*num*(lst[2]-lst[1])
        insort(lst,num)
    elif a==1+k:
        ans+=i*(n+1-num)*(lst[k]-lst[k-1])
        insort(lst,num)
    else:
        b=lst[a-2]
        c=lst[a-1]
        d=lst[a]
        e=lst[a+1]
        ans+=i*(d-num)*(c-b)+i*(num-c)*(e-d)
        insort(lst,num)
print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
f=[0]*(n+1)
for i in range(n):
    f[p[i]]=i+1
l=[0]+[i for i in range(n+1)]
r=[i+1 for i in range(n+1)]+[n+1]
ans=0
for i in range(1,n+1):
    x=f[i]
    l1,r1=l[x],r[x]
    l2,r2=l[l1],r[r1]
    ans+=i*((l1-l2)*(r1-x)+(x-l1)*(r2-r1))
    l[r1],r[l1]=l1,r1
print(ans)
### BUGGY CODE ###

def main():
    n=int(input())
    s=input()
    m=0
    for i in range(1,n):
        d,c=0,0
        for j in range(i,n):
            if s[j-i]==s[j]:c+=1
            else:
                d=max(c,d)
                c=0
        m=min(max(c,d,m),i)
    print(m)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n=int(input())
    s=input()
    m=0
    for i in range(1,n):
        cnt_m=0
        cnt=0
        for j in range(i,n):
            if s[j-i]==s[j]:
                cnt=min(cnt+1,i)
            else:
                cnt_m=max(cnt,cnt_m)
                cnt=0
        m=max(cnt,cnt_m,m)
    print(m)

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

n = int(input())
x=1
a=list(map(int,input().split(" ")))
for i in a:
	x=x*i
if(x<=1000000000000000000):
	print(x)
else:
	print(-1)

### FIXED CODE ###

n = int(input())
x=1
a=list(map(int,input().split(" ")))
if(0 in a):
	print(0)
else:
	for i in a:
		x=x*i
		if(x==0):
			break
		if(x>=1000000000000000000):
			break
	if(x<=1000000000000000000):
		print(x)
	else:
		print(-1)
### BUGGY CODE ###

s = input()
n = int(input())

mode = True
#mode = True : f1->s=c+s,f2->s=s+c
#mode = False : f1->s=s+c,f2->s=c+s

for i in range(n):
    qs = input()
    if len(qs) == 1:
        mode = not mode
    else:
        if mode:
            if int(qs[1:-2]) == 1:
                s = qs[-1] + s
            else:
                s = s + qs[-1]
        else:
            if int(qs[1:-2]) == 1:
                s = s + qs[-1]
            else:
                s = qs[-1] + s
        
#print(mode)
if not mode:
    s = s[::-1]

print(s)

### FIXED CODE ###


#import numpy as np
s = input()
n = int(input())
#qt = np.ones((n),dtype=np.int32)
#qf = np.zeros((n),dtype=np.int64)
#qc = [''] * n

mode = False
#mode = True : f1->s=c+s,f2->s=s+c
#mode = False : f1->s=s+c,f2->s=c+s

front = ''
back = ''
for i in range(n):
    qs = input()
    if len(qs) == 1:
        mode = not mode
        #s = s[::-1]
        #pass
    else:
        #qt[i] = 2
        #qf[i] = int(qs[1:-2])
        #qc[i] = qs[-1]
        if not mode:
            if int(qs[2]) == 1:
                front += qs[4]
                #s = qs[4] + s
            else:
                back += qs[4]
                #s = s + qs[4]
        else:
            if int(qs[2]) == 1:
                back += qs[4]
                #s = s + qs[4]
            else:
                front += qs[4]
                #s = qs[4] + s


#print(mode,front,back)
#hanten
if mode:
    print(back[::-1] + s[::-1] + front)
#no hanten
else:
    print(front[::-1] + s + back)
### BUGGY CODE ###

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
for i in range(count - 1):
    sum = sum * list[i + 1]

if sum > 1000000000000000000:
    sum = -1

print(sum)

### FIXED CODE ###

from functools import reduce
from operator import mul
import sys
input = sys.stdin.readline

count = int(input())
list = list(map(int, input().split()))
sum = list[0]
if 0 in list:
    print(0)
    exit()
else:
    for i in range(count - 1):
        sum = sum * list[i + 1]
        if sum > 1000000000000000000:
            print(-1)
            exit()


    print(sum)
### BUGGY CODE ###




def main():
    data = list(input())
    dp = [[0 for i in range(4)] for i in range(len(data) + 1)]
    dp[len(data)][3] += 1

    dic = {0:'A', 1:'B', 2:'C'}
    for i in range(len(data))[::-1]:
        element = data[i]
        for j in range(4):
            if j == 3:
                if element == '?':
                    dp[i][j] = dp[i + 1][j] * 3
                else:
                    dp[i][j] = dp[i + 1][j]
            else:
                if dic[j] == element or element == '?':
                    dp[i][j] += dp[i + 1][j + 1]

                if element == '?':
                    dp[i][j] += dp[i + 1][j] * 3
                else:
                    dp[i][j] += dp[i + 1][j]

    mod = 10 ** 9 + 7
    print(dp[0][0] % mod)





if __name__ == '__main__':
    main()


### FIXED CODE ###




def main():
    data = list(input())
    # dp = [[0 for i in range(4)] for i in range(len(data) + 1)]
    # dp[len(data)][3] += 1

    dp = [0, 0, 0, 1]
    mod = 10 ** 9 + 7

    dic = {0:'A', 1:'B', 2:'C'}
    for i in range(len(data))[::-1]:
        element = data[i]
        for j in range(4):
            if j == 3:
                if element == '?':
                    dp[j] *= 3
            else:
                if dic[j] == element:
                    dp[j] += dp[j + 1]

                elif element == '?':
                    dp[j] = dp[j] * 3 + dp[j + 1]

            dp[j] %= mod



    print(dp[0] % mod)





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

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

u = UnionFind(n)
for i in range(m):
    x = xy[i][0]
    y = xy[i][1]
    u.union(x, y)

idxs = []
for i in range(1, n+1):
    idxs.append(u.find(i))


idx_dict = dict()
for i in range(n):
    if idxs[i] not in idx_dict.keys():
        idx_dict[idxs[i]] = [i]
    else:
        idx_dict[idxs[i]].append(i)

counter = 0
for k in idx_dict.keys():
    l = idx_dict[k]
    template = []
    for i in range(len(l)):
        template.append(p[l[i]] - 1)

    counter += len(set(l) & set(template))

print(counter)


### FIXED CODE ###

n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

from collections import defaultdict
g = defaultdict(list)
for x, y in xy:
    x, y = x - 1, y - 1
    g[x].append(y)
    g[y].append(x)

visited = [0] * n
ans = 0

for i in range(n):
    if visited[i] == 0:
        q = [i]
        visited[i] = 1
        s = set([i])
        while q:
            cur = q.pop()
            for target in g[cur]:
                if visited[target] == 0:
                    visited[target] = 1
                    q.append(target)
                    s.add(target)

        ps = set()
        for j in s:
            ps.add(p[j] - 1)

        intersect = s & ps
        ans += len(list(intersect))
print(ans)
### BUGGY CODE ###

N = int(input())
lsa = list(map(str,input().split()))
lsb = []
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.insert(0,lsa[i]) 
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.insert(0,lsa[i])

print(' '.join(lsb))

### FIXED CODE ###

import collections
N = int(input())
lsa = list(map(str,input().split()))
lsb = collections.deque()
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])

print(' '.join(lsb))
### BUGGY CODE ###

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

S = [0]
#X = [0]
B = [[] for _ in range(20)]
for a in A:
    S.append(S[-1] + a)
    #X.append(X[-1] ^ a)
    b = 1
    for i in range(20):
        B[i].append((a&b)>>i)
        b <<= 1
#print(B)

BS = [[0] for _ in range(20)]
for i in range(N):
    for j in range(20):
        BS[j].append(BS[j][-1] + B[j][i])

#print(BS)
#print(A)
#print(S)
#print(X)

def xor(s, t):
    b = ''
    for i in range(20):
        if (BS[i][t]-BS[i][s-1])%2==0:
            b = '0' + b
        else:
            b = '1' + b
    return int(b, 2)

ans = N
for i in range(1,N+1):
    for j in range(i+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        if S[j]-S[i-1]==xor(i, j):
            ans += 1
print(ans)


### FIXED CODE ###

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

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

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

def main():
  n=input()
  a=list(map(int,input().split()))
  ap=[i+1 for i in set(a)]
  am=[i-1 for i in set(a)]
  A=set(ap+am+a)
  a=tuple(a)
  count=0
  for i in A:
    x=a.count(i)+a.count(i+1)+a.count(i-1)
    count=x if x>count else count
  print(count)
if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  n=input()
  a=tuple(map(int,input().split()))
  cnt=[0]*(pow(10,5)+2)
  for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
  print(max(set(cnt)))   
if __name__=='__main__':
  main()
### BUGGY CODE ###

def main():
    N = int(input())
    arr = []
    product = 1
    # while i < N:
    arr = list(map(int , input().split(' ')))

    if 0 in arr:
        print(0)
        return

    for i in arr:
        if( int(i) == 0):
            exit
        product = product * int(i)

    if product <= (10**18):
        print(product)
    else:
        print(-1)

main()

### FIXED CODE ###

def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A: 
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod) 

main ()
### BUGGY CODE ###

import math
import sys
N,W = map(int, sys.stdin.readline().split())

items= [ list(map(int, sys.stdin.readline().split()) )for _ in range(N)]


dp = [[0 for _ in range(W+1)] for _ in range(N + 1) ]
#dp[今何個目か][重さ何キロ持つか] = その時の価値の最大値
dp[0][0] = 0

for i in range(W+1): #重さ i のときに得られる価値
    for j in range(N):  # j 個目の荷物で
        w,v = items[j]
        if i >= w: # w > i だと前提が破綻するので
            #遷移 d[j + 1][i] =  (d[j][i - w] + v ) 新しい荷物を選んだ場合
            dp[j + 1 ][i] = dp[j][i - w]  + v  # dp[j][i - w]  + v → j 個持ったところに、更に 価値v のitemが追加されて j+ 1になった
        dp[j + 1][i] =  max(dp[j + 1][i] ,dp[j][i]) #選ばなかった場合

print(dp[N][W])

### FIXED CODE ###

import math
N,W = list(map(int, input().split(" ")))

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


dp = [[0 for _ in range(W+1)] for _ in range(N + 1) ]
for w_sum in range(W + 1):
    for i in range(N):


        w,v = items[i]
        if w_sum - w >= 0:
            dp[i + 1][w_sum]  = dp[i][w_sum - w] + v
        # print(dp[i + 1][w],dp[i][w])
        a,b = dp[i + 1][w_sum],dp[i][w_sum]
        dp[i + 1][w_sum] = max(a,b)

print(dp[-1][-1])
### BUGGY CODE ###

from bisect import*
import sys;input=sys.stdin.readline

class doevent(object):
    def __init__(self):
        self.stop=set([-1])
    def do(self,lis):
        a,b=lis
        if b>=0:
            if self.stop=={-1}:
                self.stop=set()
            self.stop.add(b)
        else:
            if -b in self.stop:
                self.stop.remove(-b)
            if self.stop==set():
               self.stop={-1}
        return min(self.stop)

n,q=map(int,input().split())
event=[]
stop=set([-1])

for i in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x,x))
    event.append((t-x,-x))
event.sort(key=lambda x:x[0])

d=doevent()

minlist=[d.do(i)for i in event] #時間をindexとしたminlist

for i in range(q):
    print(minlist[bisect_right(event,(int(input()),float("inf")))-1])

### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))
    
event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop
        
print('\n'.join(map(str, ans)))
### BUGGY CODE ###

import sys, math, itertools
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
MOD = 998244353
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

def resolve():
    N, M, K = LI()

    ans = 0

    for i in range(K + 1):
        ans += combMod(N - 1, i, MOD) * M * pow(M - 1, N - 1 - i, MOD)
        ans %= MOD

    print(ans)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys, math, itertools
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
MOD = 998244353
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def factorialMod(n, p):
    fact = [0] * (n+1)
    fact[0] = fact[1] = 1
    factinv = [0] * (n+1)
    factinv[0] = factinv[1] = 1
    inv = [0] * (n+1)
    inv[1] = 1
    for i in range(2, n + 1):
        fact[i] = (fact[i-1] * i) % p
        inv[i] = (-inv[p % i] * (p // i)) % p
        factinv[i] = (factinv[i-1] * inv[i]) % p
    return fact, factinv

def combMod(n, r, fact, factinv, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def resolve():
    N, M, K = LI()

    ans = 0
    fact, factinv = factorialMod(N, MOD)

    for i in range(K + 1):
        ans += combMod(N - 1, i, fact, factinv, MOD) * M * pow(M - 1, N - 1 - i, MOD)
        ans %= MOD

    print(ans)

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

from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
V = [-1] * (K)
V[1] = 1
q = deque([1])
i = 1
while V[0] == -1:
    i = q.popleft()
    q.appendleft(E[i][0])
    V[E[i][0]] = V[i]
    if V[E[i][1]] == -1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])

### FIXED CODE ###

from collections import deque
K = int(input())
E = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] がcost 0, E[i][1]がcost 1
INF = K*10
V = [INF] * (K)
V[1] = 1
q = deque([1])
i = 1
while q:
    i = q.popleft()
    if V[E[i][0]] > V[i]:
        q.appendleft(E[i][0])
        V[E[i][0]] = V[i]
    if V[E[i][1]] > V[i]+1:
        q.append(E[i][1])
        V[E[i][1]] = V[i]+1
print(V[0])
### BUGGY CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
  if flg<=1:
    print(i)
    break
  else:
    i-=1

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())))
i=a[1]
while i > 0:
  flg=0
  for j in a:
    if j%i!=0:
      flg+=1
      if flg>1:
        break
  if flg<=1:
    print(i)
    break
  else:
    i-=1
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

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()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = II()
a = LI()

b = []
d = []
for i in range(n+1):
    c = a.count(i)
    b.append(c*(c-1)/2)
    d.append(c)
sumb = sum(b)
for i in a:
    print(int(sumb - (d[i]-1)))

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

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()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n = II()
a = LI()

b = [0]*(n+1)
count = 0
for i in range(n):
    b[a[i]] += 1
for i in range(n+1):
    count += b[i]*(b[i]-1)/2
for i in a:
    print(int(count-b[i]+1))
### BUGGY CODE ###

string=input() #入力文字列
length=len(string) #入力文字列の長さ
mod=[1]+[0]*2018 #出てきたmod値を加算するようの箱
while length > 0: #後ろから頭まで
  s = int(string[length-1:]) 
  mod[s%2019]+=1
  length-=1
answer=0
for i in mod:
  answer+=int(i*(i-1)/2)
print(answer)


### FIXED CODE ###

string=input()
length=len(string)
mod=[1]+[0]*2018
s=0
for i in range(length):
  s=(s+int(string[-1-i])*pow(10,i,2019))%2019
  mod[s]+=1
print(sum([i*(i-1)//2 for i in mod]))
### BUGGY CODE ###

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

dp = {i+1: 0 for i in range(maxa)}
for elem in a:
    t = 2
    while elem * t <= maxa:
        dp[elem * t] = 1
        t += 1

ans = 0
for elem in a:
    if dp[elem] == 0 and a.count(elem) == 1:
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
*A, = map(int, input().split())
maxA = max(A)
# C[a] = A内のaの個数
C = {a: 0 for a in A}
for a in A:
    C[a] += 1
# D[a]=1: Aにaより小さいaの約数が存在する
D = {a: 0 for a in A}
for a in A:
    if C[a] > 0:
        t = 2
        while a * t <= maxA:
            D[a * t] = 1
            t += 1
ans = 0
for a in A:
    if C[a] == 1 and D[a] == 0:
        ans += 1
print(ans)
### BUGGY CODE ###

from collections import deque
from copy import copy, deepcopy
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)


ans = [0]*N
visited = [False]*N
visited[0]=True
ans[0] = 1
vs = deque([0])
LISs = deque([[A[0]]])
while len(vs)>0:
    v = vs.popleft()
    LIS = LISs.popleft()
    for u in edge[v]:
        if visited[u]==False:
            visited[u] = True
            lis = copy(LIS)
            ind = bisect_left(lis,A[u])
            if ind < len(lis):
                lis[ind] = A[u]
            else:
                lis.append(A[u])
            ans[u] = len(lis)
            vs.append(u)
            LISs.append(lis)
print(*ans, sep='\n')

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
edge = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,LIS):
    if len(edge[v])==0:
        return
    for u in edge[v]:
        if visited[u]==False:
            visited[u]=True
            if A[u] > LIS[-1]:
                LIS.append(A[u])
                ans[u] = len(LIS)
                dfs(u,LIS)
                LIS.pop()
            else:
                ind = bisect_left(LIS,A[u])
                stack = LIS[ind]
                LIS[ind] = A[u]
                ans[u] = len(LIS)
                dfs(u,LIS)
                LIS[ind] = stack
    return

ans = [0]*N
visited = [False]*N
visited[0]=True
LIS = [A[0]]
ans[0] = 1
dfs(0,LIS)
print(*ans, sep='\n')
### BUGGY CODE ###

from collections import deque
A=int(input())
n_l=list(map(int,input().split()))
n_l.sort()
n_l_s=deque()
for i in range(A-1):
   n_l_s.append(n_l[i+1]-n_l[i])
ans=1
n_l_s=list(n_l_s)
for i in range(A-1):
   c=0
   n=0
   for j in range(i,A-1):
      c+=n_l_s[j]
      if c < 3:
         n+=1
      else:
         ans=max(ans,n+1)
         break
print(ans)

### FIXED CODE ###

A=int(input())
n_l=list(map(int,input().split()))
import collections
ans=0
n_l=collections.Counter(n_l)
for i in range(0,100001):
   ans=max(ans,n_l[i]+n_l[i+1]+n_l[i+2])
print(ans)