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

N, M = map(int, input().split())
O =  [0]*N
B = [[0 for i in range(N)] for j in range (N)]
a = list(map(int, input().split()))
for i in range(N):
  O[i] = a[i]

for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1

ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)
      

### FIXED CODE ###

N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
### BUGGY CODE ###

import copy
N = list(input())
nums = len(N)
mass = [1 for _ in range(nums)]

dic = {}
dic2 = {}
for k in range(10**100):
  tmp = copy.deepcopy(mass)
  for i in range(nums):
    if N[i] == "R":
      mass[i+1] += tmp[i]
      mass[i] -= tmp[i]
    if N[i] == "L":
      mass[i-1] += tmp[i]
      mass[i] -=tmp[i]
  if tuple(mass) in dic:
    break
  else:
    dic[tuple(mass)] = k+1
    dic2[k+1] = copy.deepcopy(mass)
if dic[tuple(mass)] == k:
  mass = [str(m) for m in mass]
  print(" ".join(mass))
elif dic[tuple(mass)] == k-1:
  rest = 10**100 -k
  amari = rest % 2
  if amari == 0:
    mass = dic2[k]
    mass = [str(m) for m in mass]
    print(" ".join(mass))
  else:
    mass = dic2[k-1]
    mass = [str(m) for m in mass]
    print(" ".join(mass))

### FIXED CODE ###

import bisect
N = list(input())
nums = len(N)
mass = [1 for _ in range(nums)]

prev = N[0]
dicr = []
dicl = []
all = []
for i in range(1, len(N)):
  if prev == "R" and N[i] == "L":
    dicr.append(i-1)
    dicl.append(i)
    all.append(i)
    all.append(i-1)
  prev = N[i]
all = set(all)
dicr = sorted(dicr)
dicl = sorted(dicl)
for i in range(len(N)):
  if i not in all:
    mass[i] = 0
    if N[i] == "R":
      ind = dicr[bisect.bisect_left(dicr, i)]
      rest = ind-i
      if rest%2 == 0:
        mass[ind] += 1
      else:
        mass[ind+1] += 1
    else:
      ind = dicl[bisect.bisect_left(dicl, i)-1]
      rest = ind-i
      if rest%2 == 0:
        mass[ind] += 1
      else:
        mass[ind-1] += 1
mass = [str(m) for m in mass]
print(' '.join(mass))
### BUGGY CODE ###

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

a_2 = [0 for i in range(max(a))]
al = []
for i in range(a_m):
    a_2[i] += a.count(i+1)
    al.append(int(a_2[i] * (a_2[i]-1) / 2))

al_s = sum(al)

for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(al_s-(al[f-1]-t*(t-1)/2)))
    


### FIXED CODE ###

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

a_2 = [0 for i in range(n)]
for i in range(n):
    a_2[a[i]-1] += 1

al = [0 for i in range(n)]
c = 0
for i in a_2:
    if i > 1:
        al[c] += i * (i-1) / 2
    c += 1

sine = sum(al)
for i in range(n):
    f = a[i]
    t = a_2[f-1] - 1
    print(int(sine-(al[f-1]-t*(t-1)/2)))
### BUGGY CODE ###

K,S = map(int,input().split())
count=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x+y+z==S:
                count=count+1
print(count)


### FIXED CODE ###

a,b=list(map(int,input().split()))
count=0
for x in range(a+1):
    for y in range(a+1):
        if b < x+y:
            break
        if b-x-y <= a:
            count+=1
print(count)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def exp(num):
    return sum(range(1, num+1)) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    for i in range(n):
        E[i] = exp(P[i])
    # print(E)

    _max = -1
    for i in range(n-k+1):
        e = E[i:i+k]
        _sum = sum(e)
        # print(e, _sum, i)
        if _max < _sum:
            _max = _sum

    print(_max)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    # print(E)

    p = E[0]
    mx = E[k-1]
    for j in range(k, n):
        diff = E[j] - E[j-k]
        # print(diff)
        if mx < diff:
            mx = diff
    print(mx)


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

def main():

    from collections import Counter
    import sys
    input = sys.stdin.buffer.readline

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

    c1, c2, c3 = 0, 0, 0
    for aa in a:
        if aa == 1:
            c1 += 1
        elif aa == 2:
            c2 += 1
        else:
            c3 += 1

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

    # メモ化再帰ではpypy3でもTLEするのでforループを使う
    # j==k==0の場合を計算 → k==0の場合を計算 → 一般の場合を計算
    for k in range(c3+1):
        for j in range(c3+c2-k+1):
            for i in range(N-j-k+1):
                if i == j == k == 0:
                    continue
                else:
                    tmp = N
                    if i > 0: # IndexError防止
                        tmp += dp[i-1][j][k]*i
                    if j > 0:
                        tmp += dp[i+1][j-1][k]*j
                    if k > 0:
                        tmp += dp[i][j+1][k-1]*k
                    dp[i][j][k] = tmp/(i+j+k) # 割り算をまとめないとTLE

    print(dp[c1][c2][c3])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    from collections import Counter

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

    dp = [[[0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
    c = Counter(a)

    # メモ化再帰ではpypy3でもTLEするのでforループを使う
    # j==k==0の場合を計算 → k==0の場合を計算 → 一般の場合を計算
    for k in range(c[3]+1):
        for j in range(c[3]+c[2]-k+1):
            for i in range(N-j-k+1):
                if i+j+k == 0:
                    continue
                else:
                    tmp = N
                    if i > 0: # IndexError防止
                        tmp += dp[i-1][j][k]*i
                    if j > 0:
                        tmp += dp[i+1][j-1][k]*j
                    if k > 0:
                        tmp += dp[i][j+1][k-1]*k
                    dp[i][j][k] = tmp/(i+j+k) # 割り算をまとめないとTLE

    print(dp[c[1]][c[2]][c[3]])

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

# 動的計画法
import sys
input=sys.stdin.readline

n=int(input())
s=input()
dp=[[[False]*1000 for j in range(4)] for i in range(n+1)]

dp[0][0][0]=True

for i in range(n):
    for j in range(4):
        for k in range(1000):
            if dp[i][j][k]==False:continue
            dp[i+1][j][k]=True
            if j<=2:
                dp[i+1][j+1][k*10+int(s[i])]=True
cnt=0
for i in range(1000):
    if dp[n][3][i]==1:cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
s=list(map(int,list(input())))
ans=0
for i in range(10):
    try:
        ss=s[s.index(i)+1:]
        for j in range(10):
            try:
                sss=ss[ss.index(j)+1:]
                for k in range(10):
                    if k in sss:ans+=1
            except:pass
    except:pass

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

import sys
sys.setrecursionlimit(10**7)

n,x,y = map(int,input().split())

import queue
# FIFOキューの作成
q = queue.Queue()

dst = [[0 for i in range(n+1)] for j in range(n+1)]

kyori = [0] * (n+1)

#num = 1

for i in range(1,n):
    #num = 1
    q.put([i,0])
    while not q.empty():
        
        kari = q.get()
        tmp = kari[0]
        tmp_dst = kari[1]
        #print(tmp[0])
        #exit()
        if tmp >= n+1:
            continue
        if tmp < 1:
            continue
        if tmp == x:
            if dst[i][y] == 0:
                #kyori[tmp_dst+1] += 1
                dst[i][y] = tmp_dst+1
                q.put([y,tmp_dst+1])
                
        if tmp == y:
            if dst[i][x] == 0:
                #kyori[tmp_dst+1] += 1
                dst[i][x] = tmp_dst+1
                q.put([x,tmp_dst+1])
        if tmp+1 <= n:
            if dst[i][tmp+1] == 0:
                q.put([tmp+1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[i][tmp+1] = tmp_dst+1
        if tmp-1 >= 1:
            if dst[i][tmp-1] == 0:
                q.put([tmp-1,tmp_dst+1])
                #kyori[tmp_dst+1] += 1
                dst[i][tmp-1] = tmp_dst+1
        
        #num += 1
        #print(dst[i])
    #exit()
    #print(dst[i])

#print(kyori)
#print(dst)

kyori = [0] * (n+1)

for i in range(1,n):
    #print(dst[i],i)
    for j in range(i+1,n+1):
        #print(i,j,dst[i][j])
        kyori[dst[i][j]] += 1

#print(kyori)
#exit()

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

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n,x,y = map(int,input().split())

dst = [0] * n

#print(dst)

for i in range(1,n+1):
    for j in range(i+1,n+1):
        kyori = min(j-i,abs(x-i)+abs(y-j)+1)
        dst[kyori] += 1
        #print(i,j,kyori)
        
for i in range(n-1):
    print(dst[i+1])
#print(dst)
### BUGGY CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	ans=0
	for i in range(n-k+1):
		ans+=((comb(k-1+i,k-1,mod)*A[k-1+i])-(comb(k-1+i,k-1,mod)*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


if __name__ == "__main__":
	main()


### FIXED CODE ###

import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


mod=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
#import numpy as np


def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def main():
	n,k=map(int,input().split())
	A=list(map(int,input().split()))
	A.sort()
	
	comb=[1]
	for i in range(n-k):
		comb.append((comb[-1]*(k+i)*pow(i+1,mod-2,mod))%mod)
	ans=0
	
	for i in range(n-k+1):
		ans+=((comb[i]*A[k-1+i])-(comb[i]*A[n-k-i]))%mod
		ans=ans%mod
	print(ans)


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

n=int(input())
a=list(map(int,input().split()))
def factorization(n):
    arr = set()
    temp = n
    for i in range(1, int(-(-n**0.5//1))+1):
        if temp%i==0:
            arr.add(i)
            arr.add(temp//i)
    return arr
from collections import defaultdict
d=defaultdict(int)
for ai in a:
    b=factorization(ai)
    for bi in b:
        d[bi]+=1
ans=0
for k,v in d.items():
    if v>=n-1:
        ans=max(ans,k)
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
from collections import defaultdict
d=defaultdict(int)
op=set(make_divisors(a[0])+make_divisors(a[1]))
next_op=set()
for i in range(n):
    for opi in op:
        if a[i]%opi==0:
            d[opi]+=1
        if d[opi]>=i:
            next_op.add(opi)
    op=next_op
    next_op=set()
print(max(op))
### BUGGY CODE ###

import itertools
import sys


def main():
    readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(input())
    L = tuple(map(int, readline().split()))
    cnt = 0

    ls = tuple(itertools.combinations(L, 3))

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import bisect
import sys

input = sys.stdin.readline

n = int(input())
l = list(map(int, input().split()))
l.sort()
cnt = 0

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)
### BUGGY CODE ###

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

if N%2:
  A = A+ [0]

# 0,0,2,2,4,4  5   (i//2)*2 + 1- N%2 0,2,4
# 1,1,3,3,5,5  6

if all([A.count(i)==2 for i in range(1-N%2, N, 2)]):
  print(2**(N//2))
else:
  print(0)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
mod=int(1e9+7)

memo={i:0 for i in range(n)}
for a in A:
  memo[a]=memo.get(a,0)+1

answer=1
if n%2:
  if memo[0]!=1:
    print(0)
    exit()
  for i in range(1, (n+1)//2):
    if memo[2*i]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
elif not n%2:
  for i in range(n//2):
    if memo[2*i+1]!=2:
      print(0)
      exit()
    else:
      answer = 2*answer %mod
      
print(answer)
### BUGGY CODE ###

# coding: utf-8
import numpy as np


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))

    if n == 0:
        return '1' if A[0] == 1 else '-1'

    ret = 0
    R = np.zeros(n+1, int)
    R[0] = 1-A[0]
    left = 0
    base = 0
    for i in range(1, n+1):
        R[i] = 2*R[i-1]-base

        for _ in range(A[i]):
            if R[i] <= base:
                return '-1'
            base += 1
            ret += 1+i-left
            left = left+np.searchsorted(R[left:i+1], base, side='right')

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


### FIXED CODE ###

# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    A = list(map(int, args[1].split()))

    if 0 < A[0]:
        return '1' if n == 0 and A[0] == 1 else '-1'

    R = [0]*(n+1)
    R[0] = 1
    for i in range(1, n+1):
        R[i] = 2*(R[i-1]-A[i-1])

    prev = 0
    ret = 0
    for i in range(n, -1, -1):
        if R[i] < A[i]:
            ret = -1
            break

        prev = min(R[i], A[i]+prev)
        ret += prev

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
### BUGGY CODE ###

n = int(input())
wordlist = [input() for i in range(n)]
wordlist2 = list(set(wordlist))
ans = []
maxnum = 0
for j in range(len(wordlist2)) :
    countnum = wordlist.count(wordlist2[j])
    if countnum == maxnum :
        ans.append(wordlist2[j])
    if countnum > maxnum :
        maxnum = countnum
        ans = []
        ans.append(wordlist2[j])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

### FIXED CODE ###

n = int(input())
d = {}
for i in range(n) :
    s = input()
    if s not in d :
        d[s] = 1
    else :
        d[s] += 1
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

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

r, g, b, n = map(int, input().split())

a = list()
a.append(r)
a.append(g)
a.append(b)
a.sort(reverse=True)
r, g, b = a


count = 0

for i in range(0, n//r+1):
    for j in range(0, n//g+1):
        if (n - i*r - j*g) % b == 0 and (n - i*r - j*g) >= 0:
            count += 1
            continue

# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1


print(count)


### FIXED CODE ###

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

r, g, b, n = map(int, input().split())

count = 0

for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        if (n - i*r - j*g) % b == 0:
            count += 1

# やってはいけないやつ
# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1

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

def c_takahashi_information(C):
    a = []
    b = []
    for a_0 in range(min(C[0]) + 1):
        for a_1 in range(min(C[1]) + 1):
            for a_2 in range(min(C[2]) + 1):
                tmp1 = [a_0, a_1, a_2]
                tmp2 = [[C[i][j] - tmp1[i]
                         for j in range(3)] for i in range(3)]
                tmp2 = list(map(list,set(map(tuple, tmp2))))
                a.append(tmp1)
                b.append(tmp2)
    for aa, bb in zip(a, b):
        for bbb in bb:
            f = True
            for i in range(3):
                for j in range(3):
                    if aa[i] + bbb[j] != C[i][j]:
                        f = False
                        break
                if not f:
                    break
            if f:
                return 'Yes'
    return 'No'
  
C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))

### FIXED CODE ###

def c_takahashi_information(C):
    a = [min(C[0]), min(C[1]), min(C[2])]
    tmp = [[C[i][j] - a[i] for j in range(3)] for i in range(3)]
    b = list(map(list, set(map(tuple, tmp))))
    for bb in b:
        f = True
        for i in range(3):
            for j in range(3):
                if a[i] + bb[j] != C[i][j]:
                    f = False
                    break
            if not f:
                break
        if f:

            return 'Yes'
    return 'No'
  
C = [[int(i) for i in input().split()] for j in range(3)]
print(c_takahashi_information(C))
### BUGGY CODE ###

n = int(input())
r = 0
for i in range(1, n):
  r += i
print(r)

### FIXED CODE ###

n = int(input())
print(n * (n - 1) // 2)
### BUGGY CODE ###

S = input()
Q = int(input())

for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        S = S[::-1]
    else:
        if Query[1] == '1':
            S = Query[2] + S
        else:
            S = S + Query[2]
print(S)

### FIXED CODE ###

from collections import deque

S = deque(input())
Q = int(input())
Flag = False

for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        if Flag == False:
            Flag = True
        else:Flag = False
    else:
        if Query[1] == '1':
            if Flag == False:S.appendleft(Query[2])
            else:S.append(Query[2])
        else:
            if Flag == False:S.append(Query[2])
            else:S.appendleft(Query[2])
l = list(S)
if Flag:print(''.join(l[::-1]))
else:print(''.join(l))
### BUGGY CODE ###

class BIT:
    def __init__(self,n):
        self.size = n
        self.tree = [0]*(n+1)

    def add(self,i,x):
        while i <= self.size:
            self.tree[i] += x
            i += i&-i

    def sum(self,i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i&-i
        return s

N,Q = map(int,input().split())
C = list(map(int,input().split()))
LR = []
for i in range(Q):
    l,r = map(int,input().split())
    LR.append((l,r,i))
bit = BIT(N)
#color[i] => 色iが最後に登場したインデックス(1-indexed)
color = [0]*(N+1)

ANS = [0]*Q
LR.sort(key=lambda x: x[1])
cur = 1
for l,r,j in LR:
    for i in range(cur,r+1):
        c = C[i-1]
        if color[c] != 0:
            bit.add(color[c],-1)
        color[c] = i
        bit.add(i,1)
    cur = r+1
    ANS[j] = bit.sum(r)-bit.sum(l-1)
for a in ANS:
    print(a)


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    class BIT:
        def __init__(self,n):
            self.tree = [0]*(n+1)
            self.size = n
        
        def add(self,i,x):
            while i <= self.size:
                self.tree[i] += x
                i += i&-i
        
        def sum(self,i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i&-i
            return s

    N,Q = map(int,input().split())
    bit = BIT(N)
    C = list(map(int,input().split()))
    query = []
    for i in range(Q):
        l,r = map(int,input().split())
        query.append([l,r,i])
    query.sort(key=lambda x: x[1])
    ans = [0]*Q
    #良い玉のindexを1-indexで管理する
    colorMemo = [0]*(N+1)
    cur = 1
    for q in query:
        l,r,j = q
        #良い玉の情報を更新する
        for i in range(cur,r+1):
            c = C[i-1]
            if colorMemo[c]:
                bit.add(colorMemo[c],-1)
            bit.add(i,1)
            colorMemo[c] = i
        cur = r + 1
        ans[j]=bit.sum(r)-bit.sum(l-1)

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

from math import log

n = int(input())
s = int(input())
lb, ub = 1, n + 2
while ub - lb > 1:
    b = (lb + ub) // 2
    if s <= (b - 1) * (int(log(n) / log(b)) + 1):
        ub = b
    else:
        lb = b
for b in range(ub, n + 2):
    m = n
    a = 0
    while m:
        a += m % b
        m //= b
    if a == s:
        print(b)
        exit()
print(-1)

### FIXED CODE ###

def divisor(n):
    divisors = []
    i = 1
    while i * i < n:
        if n % i == 0:
            divisors.append(i)
            divisors.append(n // i)
        i += 1
    if i * i == n:
        divisors.append(i)
    divisors.sort()
    return divisors

n = int(input())
s = int(input())
if n == s:
    print(n + 1)
    exit()
if n < s:
    print(-1)
    exit()
sr = int(n ** 0.5)
for b in range(2, sr + 1):
    m = n
    a = 0
    while m:
        a += m % b
        m //= b
    if a == s:
        print(b)
        exit()
for d in divisor(n - s):
    b = d + 1
    if b <= sr:
        continue
    q = (n - s) // d
    r = n % b
    if q + r == s:
        print(b)
        exit()
print(-1)
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
m=2**150-1
n=int(input())
ss=[input()[::-1]for _ in range(n)]
ss.sort(key=len)
d={}
ans=0
for s in ss:
  a=ord(s[-1])-97
  r=1
  h=0
  y=[0]*26
  for t in s[:-1]:
    b=ord(t)-97
    if h in d:
      for i in range(26):y[i]+=d[h][i]
    ans+=y[b]
    y[b]=0
    h=(h*71+b+135)&m
  ans+=y[a]
  if h not in d:d[h]=[0]*26
  d[h][a]+=1
print(ans)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
m=2**150-1
n=int(input())
ss=[input()[::-1]for _ in range(n)]
ss.sort(key=len)
d={}
ans=0
for s in ss:
  a=ord(s[-1])-97
  r=1
  h=0
  y=[0]*26
  for t in s[:-1]:
    b=ord(t)-97
    if h in d:
      for i in range(26):y[i]+=d[h][i]
    ans+=y[b]
    y[b]=0
    h=(h*71+b+135)&m
  ans+=y[a]
  if h not in d:d[h]=[0]*26
  d[h][a]+=1
print(ans)
### BUGGY CODE ###

n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            cnt += 1
    print(cnt)

### FIXED CODE ###

N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

import math
n = int(input())
lis = list(map(int,input().split()))

num = int((n-2)/2)
for i in range(n):
	li = lis
	a = li.pop(i)
	lislis = li
	print(sorted(lislis)[int((n-2)/2)])
	li.insert(i,a)

### FIXED CODE ###

import math
n = int(input())
lis = list(map(int,input().split()))
li = sorted(lis)
ans2 = li[math.ceil((n-1)/2)]
cou2 = lis.count(ans2)
ans1 = li[math.floor((n-1)/2)]
cou1 = lis.count(ans1)
for i in range(n):
	if lis[i] >= ans2:
		print(ans1)
	else:
		print(ans2)