Harryxun/stf_run huggingface dataset:
import math
import sys
n = int(input())
s = int(input())

def f(b, n):
    if n == 0:
        return 0
    return f(b, n//b) + n % b

if s == 1:
    print(n)
    sys.exit(0)

sn = math.ceil(math.sqrt(n))
for i in range(2, sn):
    if f(i, n) == s:
        print(i)
        sys.exit(0)

for i in range(1, sn):
    if (n - s) % i == 0:
        b = (n-s)//i + 1
        if b + n % b == s:
            print(b)
            sys.exit(0)
print(-1)


### FIXED CODE ###

import math
import sys

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

def f(b, n):
    if n == 0:
        return 0
    return f(b, n//b) + n % b

if s > n:
    print(-1)
    sys.exit(0)

sn = math.ceil(math.sqrt(n))
for i in range(2, sn+1):
    if f(i, n) == s:
        print(i)
        sys.exit(0)

ans = n + 1
for i in range(1, sn+1):
    if (n - s) % i == 0:
        b = (n-s)//i + 1
        if b >= 2 and f(b, b * i + n%b) == s:
            ans = min((ans, b))
if s == n:
    print(n+1)
elif ans < n + 1:
    print(ans)
else:
    print(-1)
r=int(input())
import math
pi=round(math.pi,7)
length=str(round(r*2*pi,6))
area=str(round(r**2*pi,6))
print("{} {}".format(length,area))


### FIXED CODE ###

import math
pi=math.pi
r=float(input())
print("{:.5f} {:.5f}".format(r*r*pi,2*r*pi))
from functools import reduce
from operator import add

n, m = map(int, input().split())
alist = list(map(int, input().split()))
alist.sort(reverse=True)

for i in range(m):
    alist[0] //= 2
    if alist[0] < alist[1]:
        alist[0], alist[1] = alist[1], alist[0]

print(reduce(add, alist))


### FIXED CODE ###

import heapq
from functools import reduce

n, m = map(int, input().split())
h = list(map(lambda a: -int(a), input().split()))
heapq.heapify(h)  # input().split()))

for i in range(m):
    mx = -(-heapq.heappop(h) // 2)
    heapq.heappush(h, mx)

print(-reduce(lambda a, b: a+b, h))
K = int(input())
S = input()
if len(s)>K:
    s = s[:k] + "..."

print(s)

### FIXED CODE ###

K = int(input())
S = input()
if len(S)>K:
   print( S[:K] + "...")
else:
    print(S)
# -*- coding:utf-8 -*-


H, W = int(raw_input()).split()

for i in range(H):
    for j in range(W):
        row = raw_input()
        print(row)
        print(row)


### FIXED CODE ###

# -*- coding:utf-8 -*-


H, W = list(map(int,input().split()))

for i in range(H):
    row = input()
    print(row)
    print(row)
from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()

    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)

    ans = 0
    minIndex = 0
    isFinished = False

    for b,c in bcs:

        for _ in range(b):
            if cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break

    if len(cards) > minIndex:
        ans += sum(cards[minIndex:])

    print(ans)
    
if __name__=='__main__':
    main()

### FIXED CODE ###

from sys import stdin

def main():
    n,m = [int(x) for x in stdin.readline().split()]
    cards = [int(x) for x in stdin.readline().split()]
    cards.sort()

    bcs = [tuple(map(int,x.split())) for x in stdin.readlines()]
    bcs.sort(key=lambda x:x[1], reverse=True)

    ans = 0
    minIndex = 0
    isFinished = False

    for b,c in bcs:

        for _ in range(b):
            if minIndex < n and cards[minIndex] < c:
                ans += c
                minIndex += 1
            else:
                isFinished = True
                break
        
        if isFinished:
            break

    if minIndex < n:
        ans += sum(cards[minIndex:])

    print(ans)
    
if __name__=='__main__':
    main()
import math

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // math.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)

### FIXED CODE ###

import fractions

A, B, C, D = map(int, input().split())

count = B - A + 1
lcd_of_CD = C * D // fractions.gcd(C, D)

count -= B // C
count += (A - 1) // C
count -= B // D
count += (A - 1) // D
count += B // lcd_of_CD
count -= (A - 1) // lcd_of_CD

print(count)
from collections import deque
N,M=map(int,input().strip().split())
l=list()
dp=[list() for _ in range(N)]
id=[-1 for _ in range(N)] #友人グループid 友人のいない者に-1をつける
for _ in range(M):
    a,b=map(int,input().strip().split())
    l.append((a,b))
    dp[a-1].append(b)
    dp[b-1].append(a)
    id[a-1]=0
    id[b-1]=0

i=1
c=[]
for n in range(1,N+1):
    cnt=0
    if id[n-1]==0:
        q=deque([n])
        cnt+=1
        while q:
            tmp=q.popleft()
            id[tmp-1]=i
            for e in dp[tmp-1]:
                if id[e-1]==0:
                    id[e-1]=i
                    q.append(e)
                    cnt+=1
                else:
                    continue
        i+=1
        c.append(cnt)
    else:
        continue
print(max(c))

### FIXED CODE ###

from collections import deque
N,M=map(int,input().strip().split())
l=list()
dp=[list() for _ in range(N)]
id=[-1 for _ in range(N)] #友人グループid 友人のいない者に-1をつける
for _ in range(M):
    a,b=map(int,input().strip().split())
    l.append((a,b))
    dp[a-1].append(b)
    dp[b-1].append(a)
    id[a-1]=0
    id[b-1]=0

i=1
c=[]
for n in range(1,N+1):
    cnt=0
    if id[n-1]==0:
        q=deque([n])
        while q:
            tmp=q.popleft()
            cnt+=1
            id[tmp-1]=i
            for e in dp[tmp-1]:
                if id[e-1]==0:
                    id[e-1]=i
                    q.append(e)
                else:
                    continue
        i+=1
        c.append(cnt)
    else:
        continue
if c:
    print(max(c))
else:
    print(1)
a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a s.count("-")==1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b=map(int,input().split())
s=input()
if len(s)==a+b+1 and "-" in s and s.index("-")==a and s.count("-")==1:
    print("Yes")
else:
    print("No")
from sys import stdin
def main():
  from itertools import repeat
  from builtins import range
  readline = stdin.readline
  h, w = map(int, readline().split())
  s = [readline().rstrip('\r\n') + '#' for _ in range(h)]
  s.append('#' * w)
  yoko = [[0] * w for _ in range(h)]
  for i in range(h):
    start = -1
    si = s[i]
    yokoi = yoko[i]
    for j in range(w + 1):
      if si[j] == '#':
        if start != -1:
          yokoi[start:j + 1] = repeat(t)
          start = -1
      else:
        if start == -1:
          start = j
  result = 0
  for i in range(w):
    start = -1
    for j in range(h + 1):
      if s[j][i] == '#':
        if start != -1:
          t = yoko_max + j - start - 1
          if t > result:
            result = t
          start = -1
      else:
        yji = yoko[j][i]
        if start == -1:
          start = j
          yoko_max = yji
        else:
          if yji > yoko_max:
            yoko_max = yji
  print(result)
main()

### FIXED CODE ###

h, w = map(int, input().split())
s = [input() + '#' for _ in range(h)]
s.append('#' * w)

yoko = [[0] * w for _ in range(h)]
for i in range(h):
  if s[i][0] == '.':
    start = 0
  else:
    start = -1
  for j in range(1, w + 1):
    if s[i][j] == '#':
      if start != -1:
        for k in range(start, j):
          yoko[i][k] = j - start
        start = -1
    else:
      if start == -1:
        start = j

tate = [[0] * w for _ in range(h)]
for i in range(w):
  if s[0][i] == '.':
    start = 0
  else:
    start = -1
  for j in range(1, h + 1):
    if s[j][i] == '#':
      if start != -1:
        for k in range(start, j):
          tate[k][i] = j - start
        start = -1
    else:
      if start == -1:
        start = j
result = 0
for i in range(h):
  for j in range(w):
    t = yoko[i][j] + tate[i][j] - 1
    if t > result:
      result = t

print(result)
n = int(input())
max_cnt = 0
num_list = [] 
for i in range(n):
  num_list.append(int(input()))

for num in num_list:
  num_cnt = 0
  while True:
    if num % 2 == 1:
      if num_cnt > max_cnt: max_cnt = num_cnt
      break
    else:
      num = num / 2
      num_cnt += 1
print(max_cnt)
 

### FIXED CODE ###

input()
num_list = list(map(int, input().split()))
min_cnt = 999
for num in num_list:
  num_cnt = 0
  while True:
    if num % 2 == 1:
      if num_cnt < min_cnt: min_cnt = num_cnt
      break
    else:
      num = num / 2
      num_cnt += 1
print(min_cnt)
N = input()
a = [int(int(i)/400) for i in input().split()]
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i,v in enumerate(a):
    if v > 7:
        score8 += 1
    else:
        scores[i] = 1
score1to7 = sum(scores)
saidai = min(score1to7 + score8, 8)
saisho = min(max(score1to7, score8), 8)
print(str(saisho) + " " + str(saidai))

### FIXED CODE ###

N = input()
a = input().split()
scores = [0,0,0,0,0,0,0,0]
score8 = 0
for i in a:
    check = int(int(i) / 400)
    if check > 7:
        score8 += 1
    else:
        scores[check] = 1
score1to7 = sum(scores)
saidai = score1to7 + score8
if score1to7 < 1:
    saisho = 1
else:
    saisho = score1to7
print(str(saisho) + " " + str(saidai))
n = int(input())
items = []
for i in range(n):
  items.append(int(input())
print(sum(items)-max(items)/2)

### FIXED CODE ###

n = int(input())
items = []
for i in range(n):
  items.append(int(input()))
result = str(sum(items)-max(items)/2)
print(result[:len(result)-2])
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import log10,ceil
def main():
    k = int(input())
    k2 = ceil(k / 10)
    def getlun(n):
        lunluns.append(n)
        ns = str(n)
        print(lunluns)
        if len(ns) > k2:
            pass
        else:
            ns1 = int(ns[0])
            if ns1 != 0:
                l1 = ns[0] + ns
                getlun(int(l1))
            if ns1 > 1:
                l2 = str(ns1 - 1) + ns
                getlun(int(l2))
            if ns1 < 9:
                l3 = str(ns1 + 1) + ns
                getlun(int(l3))
    lunluns = []
    for i1 in range(0, 10):
        getlun(i1)
    lunluns.sort()
    print(lunluns[k])

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from copy import deepcopy

def main():
    k = int(input())
    l = []
    ll = [1,2,3,4,5,6,7,8,9]

    def dfs(num, keta):
        #print(num,len(num),keta)

        if len(num) == keta:
            ll.append(int(num))
            #print(len(l))

        else:
            if num[-1] == '0':
                dfs(num + '0', keta)
                dfs(num + '1', keta)
            elif num[-1] == '9':
                dfs(num + '9', keta)
                dfs(num + '8', keta)
            else:
                dfs(num + str(int(num[-1]) + 1), keta)
                dfs(num + str(int(num[-1])), keta)
                dfs(num + str(int(num[-1]) - 1), keta)
    for i in range(2,10000):
        l = l + ll
        if len(l) > k:
            l.sort()
            print(l[k-1])
            break
        else:
            tmp_ll = deepcopy(ll)
            ll = []
            for el in tmp_ll:
                dfs(str(el), i)



if __name__ == '__main__':
    main()
def main():
    mod = 998244353
    s, k = input().split()
    k, n, one, cnt, z, zero_list = int(k), len(s), s.count("1")+1, 0, 0, []
    for i in range(n):
        if s[i] == "0":
            zero_list.append(cnt)
            cnt = 0
        else:
            cnt += 1
    mm = min(one-1, k)

    dp = [[0]*(mm+1) for _ in [0]*one]
    dp[0][0] = 1

    for i in zero_list:
        dp2 = [[0]*(mm+1) for _ in [0]*one]
        for jl in range(z+i, one):
            for x in range(min(one, jl+1, mm+i+1)):
                dp2[jl][x-i] = (dp2[jl][x-i]+sum([dp[jl-x+p][p]
                                                  for p in range(min(one, x-i+1))])) % mod
            for p in range(min(one, mm+1)):
                dp2[jl][p] = (dp2[jl][p]+sum([dp[jl-l][p]
                                              for l in range(min(one, i, jl-p+1))])) % mod
        z += i
        dp = dp2
    print(sum([sum(i) for i in dp]) % mod)


main()


### FIXED CODE ###

def main():
    mod = 998244353
    s, k = input().split()
    k = int(k)
    n = len(s)

    one = s.count("1")

    cnt = 0
    zero_list = []
    for i in range(n):
        if s[i] == "0":
            zero_list.append(cnt)
            cnt = 0
        else:
            cnt += 1

    z = 0
    mm = min(one, k)

    dp = [[0]*(one+1) for _ in [0]*(one+1)]
    dp[0][0] = 1

    for i in range(len(zero_list)):
        dp2 = [[0]*(mm+1) for _ in [0]*(one+1)]
        base = zero_list[i]
        # j:何個今までに入れたか
        for j in range(one+1):
            # l:何個入れるか
            for l in range(one+1-j):
                if l < z+base-j:
                    continue
                ml = max(l-base, 0)
                # p:これまでのペナルティ
                for p in range(min(one, k)+1):
                    q = p+ml
                    if q <= mm:
                        dp2[j+l][q] = (dp2[j+l][q]+dp[j][p]) % mod
                    else:
                        break
        z += base
        dp = dp2
    print(sum([sum(i) for i in dp]) % mod)


main()
x = int(input())
if x = 1:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
  print(ans)


### FIXED CODE ###

x = int(input())
if x < 4:
  print(1)
else:
  ans = 2
  for i in range(2, x):
    for j in range(2, x):
      if i ** j <= x:
        ans = max(ans, i ** j)
      else:
        break
  print(ans)
n = input()
a = map(int, raw_input().split())
for i in range(len(a)-1,-1,-1):
    print a[i],
    

### FIXED CODE ###

input()
xs=reversed(input().split())
print(" ".join(xs))
#!/usr/bin/env python
a, b = map(int, input().split())
if a < b:
    print("a < b")
elif a > b:
    print("a > b")
else:
    print("a == b")

### FIXED CODE ###

#!/usr/bin/env python3
for x in range(1, 10):
    for y in range(1, 10):
        print("{0}x{1}={2}".format(x, y, x * y))
import sys

X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

comp = 101
for i in range(1, 101):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)


### FIXED CODE ###

import sys

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

if N == 0:
    print(X)
    sys.exit()

comp = 101
for i in range(102):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)
N=int(input())
S=str(N)
A=len(S)
M=0
for i in range(N):
  M=M+int(S[i])
if M%9==0:  
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N=int(input())
if N%9==0:
  print("Yes")
else:
  print("No")
N, Y = map(int, input().split())
result = False
count_10000 = 0
count_5000 = 0
count_1000 = 0

for count_10000 in range(0, N+1):
    if count_10000 * 10000 > Y:
        break
    for count_5000 in range(0, N+1):
        if count_5000 * 5000 > Y:
            break
        for count_1000 in range(0, N+1):
            total = count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000
            count = count_10000 + count_5000 + count_1000
            if total == Y and count == N:
                result = True
                break
        else:
            continue
        break
    else:
        continue
    break

if result:
    print(f"{count_10000} {count_5000} {count_1000}")
else:
    print("-1 -1 -1")


### FIXED CODE ###

input_data = input()
N, Y = map(int, input_data.split())
result = False
count_10000 = 0
count_5000 = 0
count_1000 = 0

for count_10000 in range(0, N + 1):
    for count_5000 in range(0, N + 1 - count_10000):
        count_1000 = N - count_10000 - count_5000
        total = count_10000 * 10000 + count_5000 * 5000 + count_1000 * 1000
        count = count_10000 + count_5000 + count_1000
        if total == Y and count == N:
            result = True
            break
    else:
        continue
    break

if result:
    print("{} {} {}".format(count_10000, count_5000, count_1000))
else:
    print("-1 -1 -1")
A=input().split()
N=int(A[0])
del A[0]
B=[]
for i in range(N):
    B.append(0)
for i in range(N-1):
    B[int(A[i])-1]+=1
for i in range(N):
    print(B[i])

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
a=[]
for i in range(n):
  a.append(0)
for i in range(n-1):
  a[l[i]-1]+=1
for i in range(n):
  print(a[i])
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
insert_index = bisect.bisect_left(A,0)
if insert_index == 0:
    print(sum(A) - A[0]*2)
if insert_index == len(A):
    print(Ans = -1*sum(A) + A[-1]*2)
if len(A[:insert_index]) % 2 == 0:
    print(-1*sum(A[:insert_index])+sum(A[insert_index:]))
else:
    tmp = -1*sum(A[:insert_index])+sum(A[insert_index:])
    print(max(tmp-A[insert_index]*2, tmp+A[insert_index-1]*2))

### FIXED CODE ###

import bisect
total = 0
N = int(input())
A = list(map(int, input().split()))
hu = [i for i in A if i < 0]
sei = [i for i in A if i >= 0]
hu.sort()
sei.sort()
if len(hu) % 2 == 0:
    print(sum(sei)+sum(hu)*-1)
else:
    if sei:
        print(sum(sei)+sum(hu)*-1 - min(-1*hu[-1], sei[0])*2)
    else:
        print(sum(sei)+sum(hu)*-1 + 1*hu[-1]*2)
can=[0]
for i in range(1,101):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-100,q-100)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")



### FIXED CODE ###

can=[0]
for i in range(1,151):
    can.append(pow(i,5))
    can.append(-pow(i,5))
can.sort()

x=int(input())

end=False
for i in range(len(can)):
    for q in range(len(can)):
        if can[i]-can[q]==x:
            
            print(i-150,q-150)
            end=True
            break
    if end:
        break
else:
    raise ValueError("xx")
import sys
input = sys.stdin.readline
n, a, b, c = map(int, input().split())
S = [input().rstrip() for _ in range(n)]
D = ["AB", "BC", "CA"]
X = [a+b, b+c, c+a]
L = []
for i, s in enumerate(S):
  if s == "AC":
    s = "CA"
  k = D.index(s)
  if X[k] == 0:
    print("No")
    exit()
  if X[(k+1)%3] == 1 and X[(k+2)%3] == 1 and i < n-1:
    l = D.index(S[i+1])
    if l == (k+1)%3:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
  else:
    if X[(k+1)%3] < X[(k+2)%3]:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
print("Yes")
print(*L, sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline
n, a, b, c = map(int, input().split())
S = [input().rstrip().replace("AC", "CA") for _ in range(n)]
D = ["AB", "BC", "CA"]
X = [a+b, b+c, c+a]
L = []
for i, s in enumerate(S):
  k = D.index(s)
  if X[k] == 0:
    print("No")
    exit()
  if X[(k+1)%3] == 1 and X[(k+2)%3] == 1 and i < n-1:
    l = D.index(S[i+1])
    if l == (k+1)%3:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
  else:
    if X[(k+1)%3] < X[(k+2)%3]:
      X[(k+1)%3] += 1
      X[(k+2)%3] -= 1
      L.append(s[1])
    else:
      X[(k+2)%3] += 1
      X[(k+1)%3] -= 1
      L.append(s[0])
print("Yes")
print(*L, sep="\n")
# In peace, in love, in war, everything is the same

import math

deg = [0] * 100005
n=int(input())
ar = list(map(int, input().split()))

for i in range(n-1):
    deg[ar[i]] = deg[ar[i]] + 1

for i in range(1, n+1, 1):
    print(deg[i])

### FIXED CODE ###

# In peace, in love, in war, everything is the same

import math

deg = [0] * 200005
n=int(input())
ar = list(map(int, input().split()))

for i in range(n-1):
    deg[ar[i]] = deg[ar[i]] + 1

for i in range(1, n+1, 1):
    print(deg[i])
from functools import reduce
from math import gcd
input()
Ai = list(map(int, input().split()))
print(reduce(gcd, Ai))

### FIXED CODE ###

from functools import reduce
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
input()
Ai = list(map(int, input().split()))
print(reduce(gcd, Ai))
N,X=map(int,input().split())
L=list(map(int,input().split()))
D[0]=0
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)

### FIXED CODE ###

N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D.append(0)
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)
str alpha=input()
if (alpha.isupper()){
  print(A)
}else{
  print(a)
}


### FIXED CODE ###

alpha=input()
if (alpha.isupper()):
  print('A')
else:
  print('a')
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    idx=[[] for _ in range(max(A)+1)]
    for i,a in enumerate(A):
        idx[a].append(i)
    perm=[None]*n
    for I in idx:
        s=len(I)
        for i in range(s):
            if(i!=s-1): perm[I[i]]=(I[i+1]+1)%n
            else: perm[I[i]]=(I[0]+1)%n

    # perm の 先頭要素をサイクル分解する
    cycle=[0]
    v=perm[0]
    while(v):
        cycle.append(v)
        v=perm[v]

    # 元に戻るまで何周したか -> まずは k をこれで割る
    cycle.append(0)
    cnt=0
    for i in range(len(cycle)-1):
        if(cycle[i+1]<cycle[i] or cycle[i]+1==cycle[i+1]):
            cnt+=1
    k%=cnt

    # k が 0 になるまで消費する
    for i in range(len(cycle)-1):
        s=(cycle[i+1]<cycle[i] or cycle[i]+1==cycle[i+1])
        if(k-s<=0):
            break
        else:
            k-=s

    # cycle[i] 以降の数列について、実際に構成すればよい
    ans=[]
    i=cycle[i]
    while(i!=0 and i!=n):
        if(i==n-1):
            ans.append(A[i])
            i+=1
        elif(perm[i]==0):
            i=n
        elif(perm[i]==i+1 or perm[i]<i):
            ans.append(A[i])
            i+=1
        else:
            i=perm[i]
    print(*ans)
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    idx=[[] for _ in range(max(A)+1)]
    for i,a in enumerate(A):
        idx[a].append(i)

    # いくつ先に移動するかを求める
    next=[None]*n
    for I in idx:
        if(not I): continue
        s=len(I)
        I.append(I[0]+n)
        for i in range(s):
            next[I[i]]=I[i+1]-I[i]+1

    # doubling
    M=10**18 # n*k より大きな数で抑えておく
    nexts=[next]
    for _ in range(60):
        next=nexts[-1]
        nnext=[min(M,next[i]+next[(i+next[i])%n]) for i in range(n)]
        nexts.append(nnext)

    now=0
    for next in nexts[::-1]:
        if(now+next[now%n]<=n*k):
            now+=next[now%n]
    if(now==n*k):
        return

    # A[now%n:] に対してシミュレーションする
    ans=[]
    have=[0]*(max(A)+1)
    for a in A[now%n:]:
        if(not have[a]):
            ans.append(a)
            have[a]=1
        else:
            while(1):
                x=ans.pop()
                have[x]=0
                if(x==a): break

    print(*ans)
resolve()
import sys
N = int(input())
a = sorted(list(map(int, input().split())))

X = 0
c = 1
i = 0
while True:
    if i == N - 1:
        X = max(X, c)
        break
    a_0 = a[i]
    a_1 = a[i] - 1
    a_2 = a[i] + 1
    while True:
        b_0 = a[i + 1]
        b_1 = a[i + 1] - 1
        b_2 = a[i + 1] + 1
        b = [b_0, b_1, b_2]
        if a_0 in b or a_1 in b or a_2 in b:
            c += 1
            i += 1
        else:
            X = max(X, c)
            c = 1
            i += 1
            break
print(X)

### FIXED CODE ###

import collections
N = int(input())
a = (list(map(int, input().split())))
for i in range(N):
    a.append(a[i] - 1)
    a.append(a[i] + 1)
c = collections.Counter(a)
print(c.most_common()[0][1])