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

from fractions import gcd

inf = float('inf')

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

# dp[i][j][k]: i番目までみてj(g), k(g)となるような最小予算
dp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a,b,c = abc[i]
    for j in range(401):
        for k in range(401):
            if j - a >= 0 and k - b >= 0:
                dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b] + c)
            else:
                dp[i+1][j][k] = dp[i][j][k]

ans = inf

for j in range(1,401):
    for k in range(1,401):
        G = gcd(j,k)
        if (j//G, k//G) == (Ma, Mb):
            ans = min(ans, dp[N][j][k])

if ans == inf:
    ans = -1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

inf = float('inf')

N,Ma,Mb = map(int,input().split())

# dp[i][j][k]: i番目までみてj(g), k(g)となるような最小予算
dp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a,b,c = map(int,input().split())
    for j in range(401):
        for k in range(401):
            dp[i+1][j][k] = dp[i][j][k]
            if j - a >= 0 and k - b >= 0 and dp[i+1][j][k] > dp[i][j-a][k-b] + c:
                dp[i+1][j][k] = dp[i][j-a][k-b] + c

ans = inf

for j in range(1,401):
    for k in range(1,401):
        if j * Mb == Ma * k and ans > dp[N][j][k]:
            ans = dp[N][j][k]

if ans == inf:
    ans = -1
print(ans)
### BUGGY CODE ###

n = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()))]
A.sort(reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
for L in range(n+1):
    for R in range(n+1):
        if n <= L+R-1:
            break
        a, i = A[L+R-1]
        if 0 <= R-1:
            dp[L][R] = max(dp[L][R], dp[L][R-1]+abs((n-R)-i)*a)
        if 0 <= L-1:
            dp[L][R] = max(dp[L][R], dp[L-1][R]+abs(i-(L-1))*a)
        ans = max(ans, dp[L][R])
print(ans)


### FIXED CODE ###

n = int(input())
A = [(a, i) for i, a in enumerate(map(int, input().split()))]
A.sort(reverse=True)
dp = [[0]*(n+1) for _ in range(n+1)]
ans = 0
for L in range(n+1):
    for R in range(n+1):
        if n <= L+R-1:
            continue
        a, i = A[L+R-1]
        if 0 <= R-1:
            dp[L][R] = max(dp[L][R], dp[L][R-1]+abs((n-R)-i)*a)
        if 0 <= L-1:
            dp[L][R] = max(dp[L][R], dp[L-1][R]+abs(i-(L-1))*a)
        ans = max(ans, dp[L][R])
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Jul  6 22:20:31 2018
ABC097A
@author: maezawa
"""

s = input()
k = int(input())

perm = []

n = len(s)
for i in range(1, n+1):
    for j in range(n-i+1):
        perm.append(s[j:j+i])
    
ans_array = sorted(set(perm))
#print(ans_array)
print(ans_array[k-1])
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Jul  6 22:20:31 2018
ABC097A
@author: maezawa
"""

s = input()
k = int(input())

perm = []

n = len(s)
for i in range(1, 6):
    for j in range(n-i+1):
        perm.append(s[j:j+i])
    
ans_array = sorted(set(perm))
#print(ans_array)
print(ans_array[k-1])
### BUGGY CODE ###

x,y=map(int,input().split())
T=x+y
W=x-T//3
D=10**9
#print(T//3)

import sys
if T%3!=0 or y/x<1/2 or y/x>2:
    print(0)
    sys.exit()

if x==y==999999:
    print(151840682)
    sys.exit()

from functools import lru_cache
@lru_cache(maxsize=100000000)
def c(n,k): 
  return 1 if(k<=0 or n<=k) else (c(n-1, k-1) + c(n-1, k))%D

sys.setrecursionlimit(100000000)
print(c(T//3,W))


### FIXED CODE ###

import sys

x,y=map(int,input().split())
T=x+y
MOD=10**9+7

def nCmMOD(A,B,Mod):
    num,den=1,1
    for i in range(B):
        num*=(A-i)
        den*=(i+1)
        num%=Mod
        den%=Mod
    return (num*pow(den,Mod-2,Mod))%Mod

if T%3!=0 or y/x<1/2 or y/x>2:
    print(0)
    sys.exit()
else:
    n=(2*y-x)//3
    m=(2*x-y)//3
    l=min(n,m)
    print(nCmMOD(n+m,l,MOD))
### BUGGY CODE ###

N=int(input())

answer=1
# -*- coding:utf-8 -*-
import math
import numpy as np

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]
    return data


def factorization(n):
    arr = []
    temp = n
    for i in get_sieve_of_eratosthenes(int(N**0.5)):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    number=1

    arr=np.array(arr)

    for a in arr[:,1]:
        number*=(a+1)
    return number



for n in range(2,N+1):
    answer+=n*factorization(n)

print(answer)



### FIXED CODE ###

N = int(input())

ans = 0
for x in range(1, N + 1):
    n = N // x
    ans += n * (2 * x + (n - 1) * x) // 2

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

class SegTree():
    def __init__(self,size,unit,f):
        self.size=size
        self.data=[unit for _ in range(2*size)]
        self.unit=unit
        self.f=f
    def update(self,i,x):
        c,f=self.data,self.f
        i+=self.size
        c[i]=f(c[i],x)
        while i>1:
            i>>=1
            c[i]=f(c[i+i],c[i-~i])
    def query(self,l,r):
        c,f=self.data,self.f
        x,y=self.unit,self.unit
        l+=self.size
        r+=self.size
        while l<r:
            if l&1:
                x=f(x,c[l])
                l+=1
            if r&1:
                r-=1
                y=f(c[r],y)
            l>>=1
            r>>=1
        return f(x,y)
def main():
    n,*a=map(int,open(0).read().split())
    dp=SegTree(n+1,0,lambda a,b:a if a>b else b)
    for h,a in zip(a,a[n:]):dp.update(h,dp.query(0,h)+a)
    print(dp.data[1])
main()

### FIXED CODE ###

class SegTree():
    def __init__(self,size,unit,f):
        self.size=size
        self.data=[unit for _ in range(2*size)]
        self.unit=unit
        self.f=f
    def update(self,i,x):
        c,f=self.data,self.f
        i+=self.size
        c[i]=f(c[i],x)
        while i>1:
            i>>=1
            c[i]=f(c[i+i],c[i-~i])
    def query(self,l,r):
        c,f=self.data,self.f
        x,y=self.unit,self.unit
        l+=self.size
        r+=self.size
        while l<r:
            if l&1:
                x=f(x,c[l])
                l+=1
            if r&1:
                r-=1
                y=f(c[r],y)
            l>>=1
            r>>=1
        return f(x,y)
def main():
    n,*a=map(int,open(0).read().split())
    dp=SegTree(n+1,0,lambda a,b:a if a>b else b)
    for h,a in zip(a,a[n:]):dp.update(h,dp.query(0,h)+a)
    print(dp.data[1])
main()
### BUGGY CODE ###

n = int(input())
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    if i==0:
        print(max(a[1:]))
    elif i==n-1:
        print(max(a[:-1]))
    else:
        b = max(a[:i])
        c = max(a[i+1:])
        print(max(b, c))

### FIXED CODE ###

n = int(input())
#a = list(map(int, input().split()))
#b = list(map(int, input().split()))
a = []
for i in range(n):
    a.append(int(input()))

b = sorted(a)
m = max(b)

for i in range(n):
    if a[i]==m:
        print(b[-2])
    else:
        print(m)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
town=[0]
s=0
while True:
  idx=town[-1]
  if a[idx] in town:
    s=a[idx]
    break
  else:
    town.append(a[idx])

idp=town.index(s)
chain=len(town[:idp])
cycle=len(town[idp:])
if k<=chain:
  print(town[k]+1)
else:
  p=(k-chain)%cycle + chain
  print(town[p]+1)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))
town=[0]
set={0}
i=0
while True:
  idx=town[-1]
  if a[idx] in set:
    s=a[idx]
    i+=1
    break
  else:
    i+=1
    town.append(a[idx])
    set.add(a[idx])
if i!=n:
  idp=town.index(s)
  chain=len(town[:idp])
  cycle=len(town[idp:])
  if k<=chain:
    print(town[k]+1)
  else:
    p=(k-chain)%cycle + chain
    print(town[p]+1)
else:
  print(town[k%n]+1)
### BUGGY CODE ###

k,s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                ans += 1
            elif x+y+z>s:
                break
print(ans)


### FIXED CODE ###

k,s = map(int, input().split())
ans = 0
for x in range(k+1):
    if x>s:
        break
    for y in range(k+1):
        if x+y<=s and s-(x+y)<=k:
            ans += 1
        if x+y>s:
            break
print(ans)
### BUGGY CODE ###

N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * N for _ in range(1 << N)]
DY = [[0] * N for _ in range(1 << N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[k][i] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[k][i] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    PC[i] = PC[i^1] + 1 if i % 2 else PC[i//2]

mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    dxi = DX[i]
    while 1:
        dyj = DY[j]
        ans = 0
        for dxik, dyjk in zip(dxi, dyj):
            ans += min(dxik, dyjk)
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)


print(*ANS, sep = "\n")


### FIXED CODE ###

N = int(input())
X = []
Y = []
P = []
for _ in range(N):
    x, y, p = map(int, input().split())
    X.append(x)
    Y.append(y)
    P.append(p)

DX = [[0] * (1 << N) for _ in range(N)]
DY = [[0] * (1 << N) for _ in range(N)]

for i, x in enumerate(X):
    for k in range(1 << N):
        d = abs(x)
        for j, xx in enumerate(X):
            if k & (1 << j):
                d = min(d, abs(xx - x))
        DX[i][k] = d * P[i]
for i, y in enumerate(Y):
    for k in range(1 << N):
        d = abs(y)
        for j, yy in enumerate(Y):
            if k & (1 << j):
                d = min(d, abs(yy - y))
        DY[i][k] = d * P[i]

ANS = [1 << 100] * (N + 1)
PC = [0] * (1 << N)
for i in range(1, 1 << N):
    j = i ^ (i & (-i))
    PC[i] = PC[j] + 1

RA = []
for i in range(1 << N):
    t = []
    for j in range(N):
        if i & (1 << j):
            t.append(j)
    RA.append(tuple(t))


mm = (1 << N) - 1
for i in range(1 << N):
    m = i ^ mm
    j = m
    while 1:
        ans = 0
        for k in RA[i^j^mm]:
            ans += min(DX[k][i], DY[k][j])
        
        pc = PC[i] + PC[j]
        ANS[pc] = min(ANS[pc], ans)
        
        if not j:
            break
        j = m & (j - 1)

print(*ANS, sep = "\n")
### BUGGY CODE ###

x = int(input())
ans = 1
for i in range(1,1000):
    tmp = 2
    while i**tmp <= x:
        ans = max(ans,i**tmp)
        tmp += 1
print(ans)

### FIXED CODE ###

x = int(input())
ans = 1
for i in range(2,1000):
    tmp = 2
    while i**tmp <= x:
        ans = max(ans,i**tmp)
        tmp += 1
print(ans)
### BUGGY CODE ###

import os
from collections import defaultdict
N = int(input())
A = list(map(int, input().split(" ")))

pow2 = defaultdict(int)

ret = 0
lim = []
for i in range(N+1):
    pow2[i] = 2**i


for i in range(N+1):
    if i == 0:
        r = 2**i - A[i]
    else:
        r = 2*lim[i-1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim.append(r)

for d in reversed(range(N+1)):
    if A[d] > pow2[d]:
        print(-1)
        exit(0)
    if d == N:
        n = min(A[d], pow2[d])
    else:
        n = min(A[d] + min(n, lim[d]), pow2[d])
    ret +=n

print(ret)

### FIXED CODE ###

import os
from collections import defaultdict

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

pow2 = defaultdict(int)

ret = 0
lim = [0] * (N + 1)
# for i in range(N + 1):
#     pow2[i] = 2 ** i

for i in range(N + 1):
    if i == 0:
        r = 1 - A[i]
    else:
        r = 2 * lim[i - 1] - A[i]
    if r < 0:
        print(-1)
        exit(0)
    lim[i] = r

for d in reversed(range(N + 1)):
    # if A[d] > pow2[d]:
    #     print(-1)
    #     exit(0)
    if d == N:
        #n = min(A[d], pow2[d])
        n = A[d]
    else:
        #n = min(A[d] + min(n, lim[d]), pow2[d])
        n = A[d] + min(n, lim[d])
    ret += n

print(ret)
### BUGGY CODE ###

N, Q = [int(nq) for nq in input().split()]
S = input()
for q in range(Q):
    l, r = [int(lr) for lr in input().split()]
    ans = S[l-1:r].count("AC")
    print(ans)

### FIXED CODE ###

N, Q = [int(nq) for nq in input().split()]
S = input()
AC = []
for s in range(len(S)-1):
    if S[s:s+2] == "AC":
        AC.append(1)
    else:
        AC.append(0)
CS = [0]*len(AC)
CS[0] = AC[0]
for i in range(len(AC)-1):
    CS[i+1] = CS[i] + AC[i+1]
for q in range(Q):
    l, r = [int(lr) for lr in input().split()]
    if l == 1:
        print(CS[r-2])
    else:
        print(CS[r-2] - CS[l-2])
### BUGGY CODE ###

N=int(input())

mult=1
array=map(int,input().split())

for i in array:
    mult*=i

if mult>10**18:
    print("-1")
else:
    print(mult)

### FIXED CODE ###

N=int(input())

mult=1
array=map(int,input().split())

array=sorted(array)

for i in array:
    mult*=i
    if mult==0:
        break
    elif mult>10**18:
        mult=-1
        break

print(mult)
### BUGGY CODE ###

def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def search(x,y):
    t = gcd(x,y)
    ans = 1
    memo = [0 for i in range(t+1)]
    memo[1] = 1
    for o in range(2,t+1):
        if memo[o] == 0 and t % o == 0:
            for j in range(1,t//o+1):
                memo[o * j ] = 1
            ans += 1
    return ans
A,B = map(int,input().split())
print(search(A,B))


### FIXED CODE ###

def gcd(x, y):
    if y == 0 :
        return x
    else:
        return gcd(y,x%y)
def prime(x):
    global  ans
    m = x ** (0.5)
    for i in range(2,int(m+1)):
        if x % i == 0 :
            while True:
                if x % i != 0 :
                    break
                else:
                    x = (x//i)
            ans +=1
    if x != 1 :
        ans += 1
    return ans
A,B = map(int,input().split())
t = gcd(A,B)
ans = 1
print(prime(t))
### BUGGY CODE ###

n, m = map(int, input().split())
ans_set = {x for x in range(1, n+1)}

for _ in range(m):
    a, b = map(int, input().split())
    sub_set = {x for x in range(a, b+1)}
    ans_set = ans_set & sub_set
    
ans = len(ans_set)
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
l = [0]*m
r = [0]*m

for i in range(m):
    l[i], r[i] = map(int, input().split())
    

    
ans = min(r) - max(l)
if ans >= 0 :
    print(ans+1)
else:
    print(0)
### BUGGY CODE ###

import collections
h,w = map(int,input().split())
si,sj = map(int,input().split())
gi,gj = map(int,input().split())
si,sj,gi,gj = si-1,sj-1,gi-1,gj-1
grid = []
for _ in range(h):
    grid.append(input())
dist = {(i,j):float("inf") for i in range(h) for j in range(w)}
q = collections.deque([(si,sj)])
dist[si,sj] = 0
while q:
    i,j = q.popleft()
    if (i,j) == (gi,gj):
        print(dist[i,j])
        break
    for ni,nj in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
        if 0 <= ni and ni < h and 0 <= nj and nj < w and grid[ni][nj] == ".":
            if dist[ni,nj] > dist[i,j]:
                dist[ni,nj] = dist[i,j]
                q.appendleft((ni,nj))
    for ni in range(i-2,i+3):
        if not (0 <= ni and ni < h): continue
        for nj in range(j-2,j+3):
            if not (0 <= nj and nj < w): continue
            if (ni,nj) not in [(i,j),(i+1,j),(i-1,j),(i,j+1),(i,j-1)] and grid[ni][nj] == ".":
                if dist[ni,nj] > dist[i,j] + 1:
                    dist[ni,nj] = dist[i,j] + 1
                    q.append((ni,nj))

else:
    print(-1)


### FIXED CODE ###

from sys import stdin
def solve():
    import collections
    readline = stdin.readline
    h,w = map(int,readline().split())
    si,sj = map(int,readline().split())
    gi,gj = map(int,readline().split())
    si,sj,gi,gj = si-1,sj-1,gi-1,gj-1
    grid = []
    for _ in [0]*h:
        grid.append(readline()[:-1])
    INF = float("inf")
    dist = [[INF]*w for _ in range(h)]
    q = collections.deque([(si,sj)])
    dist[si][sj] = 0
    while q:
        i,j = q.popleft()
        if (i,j) == (gi,gj):
            return dist[i][j]
        for ni,nj in [(i+1,j),(i-1,j),(i,j+1),(i,j-1)]:
            if 0 <= ni and ni < h and 0 <= nj and nj < w and grid[ni][nj] == ".":
                if dist[ni][nj] > dist[i][j]:
                    dist[ni][nj] = dist[i][j]
                    q.appendleft((ni,nj))
        listj = range(j-2,j+3)
        for ni in range(i-2,i+3):
            if not (0 <= ni and ni < h): continue
            for nj in listj:
                if not (0 <= nj and nj < w): continue
                if grid[ni][nj] == "." and dist[ni][nj] > dist[i][j] + 1:
                    dist[ni][nj] = dist[i][j] + 1
                    q.append((ni,nj))

    return -1

print(solve())
### BUGGY CODE ###

N,M = map(int,input().split())
X = [list(map(int,input().split())) for n in range(M)]
L = [0]*N

for m in range(M):
  for g in range(X[m][0],X[m][1]+1):
    L[g-1]+=1
    
print(L.count(M))

### FIXED CODE ###

N,T = map(int,input().split())
X = [list(map(int,input().split())) for n in range(T)]
M = N
m = 0

for a,b in X:
  M = min(M,b)
  m = max(m,a)
  
if M<m:
  print(0)
else:
  print(M-m+1)
### BUGGY CODE ###

class UnionFind:
  def __init__(self, size):
    self.table = [-1 for _ in xrange(size)]

  def find(self, x):
    while self.table[x] >= 0: x = self.table[x]
    return x

  def union(self, x, y):
    s1 = self.find(x)
    s2 = self.find(y)
    if s1 != s2:
      if self.table[s1] >= self.table[s2]:
        self.table[s1] += self.table[s2]
        self.table[s2] = s1
      else:
        self.table[s2] += self.table[s1]
        self.table[s1] = s2
      return True
    return False

def hash(n, s, g):
  return n*s+g

def dehash(n, hs):
  return [(hs-hs%n)/n, hs%n]

def kruskal(n, path):
  path = sorted(path.items(), key=lambda x:x[1])
  selected = {}
  union = UnionFind(n)
  for i in xrange(len(path)):
    k,v = path[i]
    s,g = dehash(n, k)
    if union.union(s, g):
      selected[k] = v
  return selected

V,E = map(int, raw_input().split())
path = {}
for _ in xrange(E):
  s,t,w = map(int, raw_input().split())
  path[hash(V, s, t)] = w
result = kruskal(V, path)
sumcost = 0
for v in result.values():
  sumcost += v
print sumcost

### FIXED CODE ###

import heapq

def prim(n, path):
  selected = {}
  paths = []
  hq = []
  selected[0] = True

  if 0 not in path:
    return []

  for s,d,w in path[0]:
    heapq.heappush(hq, (w, [0,d,w]))

  while len(hq) != 0:
    k,root = heapq.heappop(hq)
    if root[1] in selected: continue
    selected[root[1]] = True
    paths.append(root)
    for s,d,w in path[root[1]]:
      heapq.heappush(hq, (w, [s,d,w]))
  return paths

V,E = map(int, raw_input().split())
path = {}
for _ in xrange(E):
  s,t,w = map(int, raw_input().split())
  if s not in path:
    path[s] = []
  path[s].append([s,t,w])
  if t not in path:
    path[t] = []
  path[t].append([t,s,w])
result = prim(V, path)
sumcost = 0
for s,d,v in result:
  sumcost += v
print sumcost
### BUGGY CODE ###

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

tmp_i = 0
max_cnt = 0
while  tmp_i<N-1:
    i = tmp_i
    cnt = 0
    flag = True
    while flag:
        if i+1<N and data[i]>=data[i+1]:
            cnt += 1
            i += 1
        else:
            flag = False
    tmp_i+=1
    max_cnt = max(max_cnt,cnt)

print(max_cnt)


### FIXED CODE ###

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

i = 0
max_cnt = 0
while i<N-1:
    # i = tmp_i
    cnt = 0
    flag = True
    while flag:
        if i+1<N and data[i]>=data[i+1]:
            cnt += 1
            i += 1
        else:
            flag = False
            i += 1
    # tmp_i+=1
    if max_cnt<cnt:
        max_cnt=cnt

print(max_cnt)
### BUGGY CODE ###

import sys
dic = set()
L = sys.stdin.readlines()

for Ins in L[1:]:
    ins, op = Ins.split()
    if ins == 'insert':
        dic = dic | {op}
    if ins == 'find':
        print({True: 'yes', False: 'no'}[op in dic])

### FIXED CODE ###

import sys
dic = set()
L = sys.stdin.readlines()

for Ins in L[1:]:
    ins, op = Ins.split()
    if ins == 'insert':
        dic.add(op)
    if ins == 'find':
        print('yes' if op in dic else 'no')
### BUGGY CODE ###

import networkx as nx

def main():
  N,M=map(int,input().split())
  S = [list(input()) for _ in range(N)]

  if N == M == 1:
    print(0)
    print(S[0][0])
    exit()

  index = lambda i,j: i*M+j

  G=nx.DiGraph()
  G.add_node('source')
  G.add_node('sink')
  dx,dy=(1,0),(0,1)
  for i in range(N):
    for j in range(M):
      if S[i][j]=='#':continue
      if (i+j) %2:
        G.add_edge(index(i,j),'sink',capacity=1)
      else:
        G.add_edge('source',index(i,j),capacity=1)
      for k in range(2):
        v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
        if not (0<=i+dx[k]<N and 0<=j+dy[k]<M):
          continue
        if S[i+dx[k]][j+dy[k]] == '#': continue
        if (i+j) % 2:
          G.add_edge(v2,v1,capacity=1)
        else:
          G.add_edge(v1,v2,capacity=1)

  flow_value, flow_dict = nx.maximum_flow(G, "source", "sink")

  for v1 in flow_dict.keys():
    if v1 in ('sink','source'):continue
    for v2 in flow_dict[v1]:
      if v2 in ('sink','source'):continue
      if flow_dict[v1][v2]:
        i1,j1 = divmod(v1,M)
        i2,j2 = divmod(v2,M)
        (i1,j1),(i2,j2) = sorted([(i1,j1),(i2,j2)])
        if i1 + 1 == i2:
          S[i1][j1] = 'v'
          S[i2][j2] = '^'
        else:
          S[i1][j1] = '>'
          S[i2][j2] = '<'

  print(flow_value)
  for i in range(N):
    print(''.join(S[i]))
    
if __name__ == "__main__":
  main()

### FIXED CODE ###

import networkx as nx

def main():
  N,M=map(int,input().split())
  S = [list(input()) for _ in range(N)]

  if N == M == 1:
    print(0)
    print(S[0][0])
    exit()

  index = lambda i,j: i*M+j

  G=nx.Graph()
  dx,dy=(1,0),(0,1)
  E = []
  n1,n2 = [],[]
  for i in range(N):
    for j in range(M):
      if S[i][j]=='#':continue
      if (i+j)%2:
        n1.append(index(i,j))
      else:
        n2.append(index(i,j))
      for k in range(2):
        v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
        if not (0<=i+dx[k]<N and 0<=j+dy[k]<M):
          continue
        if S[i+dx[k]][j+dy[k]] == '#': continue
        if (i+j) % 2:
          E.append((v2,v1))
        else:
          E.append((v1,v2))
     
  G.add_nodes_from(n1, bipartite=0)
  G.add_nodes_from(n2, bipartite=1)
  G.add_edges_from(E)
  u = [n for n in G.nodes if G.nodes[n]['bipartite'] == 0]
  match = nx.bipartite.maximum_matching(G, top_nodes=u)
  match = {v:match[v] for v in match.keys() if v < match[v]}
 
  for v in match.keys():
    i1,j1 = divmod(v,M)
    i2,j2 = divmod(match[v],M)
    if i1 > i2 or j1 > j2:
      (i1,j1),(i2,j2) = (i2,j2),(i1,j1)
    if i1 < i2:
      S[i1][j1] = 'v'
      S[i2][j2] = '^'
    else:
      S[i1][j1] = '>'
      S[i2][j2] = '<'

  print(len(match))
  for i in range(N):
    print(''.join(S[i]))
    
if __name__ == "__main__":
  main()
### BUGGY CODE ###

import numpy as np

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

r=[]

for _ in a:
    l,m,h=_-1,_,_+1
    _r=[l,m,h]
    r.append(_r)
arr=np.array(r)

ans=0
for i in range (max(a)+2):
    _ans=np.sum(np.count_nonzero(arr==i,axis=1))
    if _ans>ans:
        ans=_ans
print(ans)

### FIXED CODE ###

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

l=[0]*((10**5)+2)

for v in a:
    l[v]+=1
    l[v+1]+=1
    l[v+2]+=1

print(max(l))