peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from math import ceil
N, K = map(int, input().split())
print(ceil((N - 1) / (K - 1)))
# Judge status: Wrong Answer
from collections import deque
d=deque(map(str,input().split()))
q=int(input())
for _ in range(q):
    ss=input().split()
    if ss[0]==str(1):
        d.reverse()
    else:
        if ss[1]==str(1):
            d.appendleft(ss[2])
        else:
            d.append(ss[2])
for j in d:
    print(j,end='')
# Judge status: Wrong Answer
from collections import OrderedDict

N, K =map(int, input().split())
a = list(map(int, input().split()))
p = OrderedDict()
for i in a:
  if i not in p:
    p[i] = 1
  else:
    p[i] +=1
#print(p)
p_rev = OrderedDict(
    sorted(p.items(), key=lambda x: x[1])
)
#print(p_rev)
#print(len(p_rev))
count = 0
sum = 0
for i in p_rev.values():
  sum += i
  count += 1
  if len(p_rev) - count >= K:
    break
print(sum)
# Judge status: Wrong Answer
def resolve():
	n, m = map(int, input().split())
	if m < n:
		print(m // 2)
	else:
		t = m - (n*2)
		print(n + t//4)
resolve()
# Judge status: Accepted
def main():
    n = int(input())

    print(n if n % 111 == 0 else (n // 111 + 1) * 111)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
s = input()
t = input()
if s == t:
    print(N)
    exit(0)
ans = 2*N
for k in range(1,N+1):
    if s[k:] == t[:-k]:
        ans = min(ans,2*N-len(s[k:]))
print(ans)
# Judge status: Accepted
a=list(map(int,input().split()))
a.sort()
if (a[0]==a[1] and a[1]!=a[2]) or (a[1]==a[2] and a[1]!=a[0]):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())

print('Yes' if a <= c <= b else 'No')
# Judge status: Accepted
# C - Bugged
# https://atcoder.jp/contests/abc063/tasks/arc075_a

n = int(input())
S = [int(input()) for _ in range(n)]

S.sort()

score = sum(S)

if score % 10 != 0:
  print(score)
else:
  for s in S:
    if s % 10 != 0:
      print(score - s)
      exit()
  print(0)
# Judge status: Wrong Answer
a=int(input())
seqS=input().split(" ")
num=[]
for q in seqS:
    num.append(int(q))
contador=0

#primeiro
#if num[0] > num[1]:
    #contador+=1

for i in range(1,len(num)-1):
    if num[i-1] > num[i] and num[i] > num[i+1] or num[i-1] < num[i] and num[i] < num[i+1]:
        contador+=1
        print(num[i-1],num[i],num[i+1])

#ultimo
#if num[-1] > num[-2]:
    #contador+=1
print(contador)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = set(a)
if b == a:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, Y = map(int, input().split())

for i in range(0, N+1):
    for j in range(0, N+1-i):
        k = N-i-j
        if 1000*i+5000*j+10000*k == Y:
            print(k, j, i)
            exit(0)
print(-1, -1, -1)
# Judge status: Accepted
l,r = map(int,input().split())

ans = 2018
if r-l >= 2019:
    ans = 0
else:
    for i in range(l,r):
        for j in range(l+1,r+1):
            ans = min(i * j % 2019,ans)
print(ans)
# Judge status: Wrong Answer
N = int(input())

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

a = 0
b = 0
Money = 1000

for i in range(len(A)):
  if a == 0:
    a = A[i]
    continue
  if b <= A[i]:
    b = A[i]
    continue
  else:
    if a < b:
      Money = Money // a * b + Money % a
    a = b = A[i]
    
if a < b:
      Money = Money // a * b + Money % a
print(Money)
# Judge status: Accepted
# -*- coding: utf-8 -*-
# C - Low Elements
import  sys

def solve152C(N, plist):
	
	count = 1
	maxnumber = plist[0]
	minnumber = plist[0]
	isFound = True
	for i in range(2, N+1):
		p = plist[i-1]
		if p < maxnumber and p < minnumber:
			count += 1
		
		if p > maxnumber:
			maxnumber = p
		if p < minnumber:
			minnumber = p
					
	print(count)


if __name__ == "__main__":
	
	N = int(input())
	plist= list(map(int, input().split()))

	solve152C(N, plist)
# Judge status: Accepted
import sys
import numpy as np
MOD = 10**9+7

n = int(sys.stdin.buffer.readline())
a = np.fromstring(sys.stdin.buffer.readline(), dtype = np.int64, sep = ' ')
ans = 0
for i in range(60):
    s = int((a&1).sum())
    ans += s*(n-s) * 2**i
    ans %= MOD
    a >>= 1
print(ans)
# Judge status: Accepted
from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    PY = [tuple([i] + list(map(int, input().split()))) for i in range(M)]
    result = []
    p_city = defaultdict(int)
    for py in sorted(PY, key = lambda x: x[2]):
        p_city[py[1]] += 1
        code = str(py[1]).zfill(6) + str(p_city[py[1]]).zfill(6)
        result.append((py[0], code))
    print("\n".join([r[1] for r in sorted(result, key = lambda x: x[0])]))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, m = map(int, input().split())
dicts = {i+1:0 for i in range(n)}
for i in range(m):
    a, b = map(int, input().split())
    dicts[a] += 1
    dicts[b] += 1
    
for i in range(n):
    print(dicts[i + 1])
# Judge status: Wrong Answer
A=list(input().split(" "))
B=list(input().split(" "))
C=sorted(B)
D=[]
M=0
for i in range(int(A[1])):
    D.append(int(C[i]))
for j in range(len(D)):
    M=D[j]+M
print(M)
# Judge status: Accepted
# -*- coding: utf-8 -*-
import math

#L, R, d = map(int, input().parse())
L, R, d = map(int, input().split())
start_d = int(math.ceil(L / d))
end_d = int(math.floor(R / d))
print(end_d - start_d +1)
# Judge status: Accepted
a = int(input())

answer = a + a ** 2 + a ** 3

print(answer)
# Judge status: Wrong Answer
n = list(map(int, input().split()))

count = 0
for i in range(1,3):
  if n[0] == n[i]:
    count+=1

if count == 1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math

A, B, H, M = map(int, input().split())
angleH = 360 * ((H + (M / 60)) / 12)
angleM = 360 * (M / 60)
angle = abs(angleH - angleM)
answer = math.sqrt(math.pow(A, 2) + math.pow(B, 2) - (2 * A * B * math.cos(math.radians(angle))))
print(answer)
# Judge status: Accepted
n, k = map(int,input().split())
a = list(map(int,input().split()))

s = [True] * n
c = [1]
now = 0
while s[now]:
    s[now] = False
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1])
loop = c[start_cycle:-1]
cycle = len(loop)

if k < start_cycle:
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])
# Judge status: Wrong Answer
#!/usr/bin/env python3

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

#hunuke

h = S[B-1:D+1].count('##')
m3 = S[B-1:C+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 == 0: print('No')
    else: print('Yes')
# Judge status: Accepted
K = int(input())
print((K//2)*((K+1)//2))
# Judge status: Accepted
words = ["dream", "dreamer", "erase", "eraser"]
            #5      #7          #5      #6
s = input()

while len(s) > 0:
    if s[-5:] in words:
        s = s[:-5]
    elif s[-6:] in words:
        s = s[:-6]
    elif s[-7:] in words:
        s = s[:-7]
    else:
        print("NO")
        exit()

print("YES")
# Judge status: Wrong Answer
def main():
    T = input()
    # ?D -> PD
    # ?P -> DP
    # ?? -> PD 
    # ??? -> PDD

    T = T.replace("??", "DD")
    T = T.replace("?D", "PD")
    T = T.replace("?P", "DP")
    T = T.replace("?", "D")
    print(T)

if __name__=="__main__":
    main()
# Judge status: Wrong Answer
H, n = map(int, input().split())
magics = []
for _ in range(n):
    a, b = map(int, input().split())
    magics.append((a, b))
print(magics)

# 体力をn削るために必要なmpの最小値
dp = [0] * (H+1)
for h in range(1, H+1):
    dp[h] = min([dp[max(h-a, 0)] + b for (a, b) in magics])

print(dp[-1])
# Judge status: Wrong Answer
import numpy as np
from scipy.sparse.csgraph import shortest_path

N, M = map(int, input().split())
l = [[0]*N for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    l[A-1][B-1] = 1
    l[B-1][A-1] = 1
    
a = np.array(l)
aa = shortest_path(a, directed=False)

if float('inf') in aa[0]:
    print('No')
else:
    print('Yes')
    for i in aa[0][1:]:
        print(int(i))
# Judge status: Wrong Answer
A,B,T = map(int,input().split())
count = 0
for i in range(1,T):
    if i*A<=T:
        count += B
print(count)
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
 
from collections import Counter
c = Counter(A)
 
mul = []
for k, v in c.items():
    if v >= 2:
        mul.append(k)
    elif v >= 4:
        mul.append(k)
        mul.append(k)
mul.sort()
if len(mul) < 2:
    print(0)
else:
    print(mul[-1]*mul[-2])
# Judge status: Accepted
n=int(input())
s=str(input())
r=0
g=0
b=0
for x in range (n):
    if s[x]=='R':
        r+=1
    elif s[x]=='G':
        g+=1
    else:
        b+=1
rgb=r*g*b

for i in range (n):
    for j in range (i,n):
        k=j*2-i
        if k<n:
            if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
                rgb=rgb-1
print(rgb)
# Judge status: Accepted
n,k=(int(x) for x in input().split())
i=0
while(n>=k**i):
  i+=1
print(i)
# Judge status: Wrong Answer
n=int(input())
l=sorted(list(map(int,input().split())),reverse=True)
count=0
if n<3:
  print("0")
else:
  for i in range(n-2):
    for j in range(n-2-i):
      for k in range(n-2-i-j):
        if l[i]<l[1+j]+l[2+k] and l[i]!=l[1+j]!=l[2+k]:
          count+=1
print(count)
# Judge status: Wrong Answer
N, M = map(int, input().split())
H = list(map(int, input().split())) 
A = [0]*M
B = [0]*M
for i in range(M):
    A[i], B[i] = map(int, input().split())
    A[i] -= 1
    B[i] -= 1
lis = [0]*M
for i in range(M):
    lis[i] = max(H[A[i]],H[B[i]])
print(len(set(lis)))
# Judge status: Accepted
a, b, c, k = map(int, open(0).read().split())

while a >= b:
    b *= 2
    k -= 1

while b >= c:
    c *= 2
    k -= 1

if k >= 0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, K = map(int, input().split())

if K - A <= 0:
    print(str(A - K) + ' ' + str(B))
else:
    print('0 ' + str(max(0, B - (K - A))))
# Judge status: Accepted
a = int(input())

print((a*800)-(a//15*200))
# Judge status: Accepted
S = input()
for i in range(len(S)):
  if i%2 == 0:
    if S[i] == 'L':
      print('No')
      exit()
  else:
    if S[i] == 'R':
      print('No')
      exit()
print('Yes')
# Judge status: Wrong Answer
import sys
def is_pal(s):
    i,j=0,len(s)-1
    while i<=j:
        if s[i]==s[j]:
            i+=1
            j-=1
        else:
            return False
    return True
s=sys.stdin.readline()[:-1]
n=len(s)
if n%2!=0:
    if is_pal(s[:n//2]) and is_pal(s[n//2+1:]):
        print('Yes')
    else:
        print('No')
else:
    print('No')
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))+[0]
ans=0
for i in range(N):
    eated=max(0,a[i]+a[i-1]-x)
    ans+=eated
    a[i]-=eated
print(ans)
# Judge status: Accepted
n, m = (int(x) for x in input().split())
ans = [None for _ in range(n)]
fail = False
for _ in range(m):
    s,c = (int(x) for x in input().split())
    s -=1
    if ans[s] is None:
        ans[s] = c
    elif ans[s] != c:
        fail = True
        break
if fail or (ans[0] == 0 and n > 1):
    print(-1)
else:
    if ans[0] is None and n > 1:
        ans[0] = 1
    elif ans[0] is None and n == 1:
        ans[0] = 0
    print(''.join((str(i) if i is not None else '0' for i in ans)))
# Judge status: Accepted
N,M = map(int,input().split())
A = []
for i in range(1,M+1):
    if i*i>M:break
    if M%i==0:
        A.append(i)
        A.append(M//i)
A.sort()
for a in A:
    if a>=N:
        print(M//a)
        break
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
a =[[] for i in range(N)]
for i in range(N):
    a[i] =[A[i], i+1]
a.sort()
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = a[i][1]
print(ans)
# Judge status: Accepted
S = input()

rotate = ["Sunny","Cloudy","Rainy"]

print(rotate[(rotate.index(S) + 1) % 3])
# Judge status: Accepted
def solve():
    x, y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]

    if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
S = input()

print('X' * len(S))
# Judge status: Wrong Answer
import numpy as np

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



caa = [np.array(list(map(int, input().split()))) for _ in range(n)]



ans = 1 << 31

for i in range(2**n):
    tmp = np.zeros(len(caa[0]))
    for j in range(n):
        if i % (2**j):
            tmp += caa[j]
        if min(tmp[1:]) >= x:
            ans = min(ans, tmp[0])

if ans != 1<<31:
    print(int(ans))
else:
    print(-1)
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int, input().split())))[::-1]

ans = 0
for i, a in enumerate(A[: - N]):
  if i % 2 == 1:
    ans += a
    
print(ans)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int,input().split()))
a.sort()
c = ((a[-1]-a[0])+1)//2+a[0]

ans = 0
for i in range(N):
    ans += (a[i]-c)**2
print(ans)
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n<=k:
    print(n*x)
else:
    tmp = (n-k) * y + k * x
    print(tmp)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
a, b = map(int,input().split())

if b < 0:
    print("Negative")
elif 0 < a:
    print("Positive")
elif -1 * a == b:
    print("Zero")
# Judge status: Accepted
n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

B = sorted(A, reverse=True)
first = B[0]
second = B[1]

for i in range(n):
    if A[i] != first:
        print(first)
    else:
        print(second)
# Judge status: Accepted
x, a, b = map(int, input().split())
if b-a <= 0:
  print('delicious')
elif b-a <= x:
  print('safe')
else:
  print('dangerous')
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
print((3*a*b)/(t+0.5))
# Judge status: Accepted
a,b,c=map(int,input().split());print(len(bin((e:=a-b|c-b)&-e))-3or~c%-2)
# Judge status: Wrong Answer
n_k = list(map(int,input().split()))
chr_lr = list(input())
cnt_rl = 0
cnt_con = 0

for i in range(n_k[0]-1):
  if(chr_lr[i] == chr_lr[i+1]):
    cnt_con += 1
  elif(chr_lr[i] == 'R' and chr_lr[i+1] == 'L'):
    cnt_rl += 1

if n_k[1] <= cnt_rl:
  sum = cnt_con + (n_k[1]*2)
else:
  sum = cnt_con + (cnt_rl*2) + (n_k[1] - cnt_rl)
  
print(sum)
# Judge status: Wrong Answer
N=int(input())

for i in range(N):
	if round(i*1.08)==N:
		print(i)
		exit()
print(":(")
# Judge status: Wrong Answer
from itertools import product
[N, M, X] = [int(i) for i in input().split()]
bk = [[int(i) for i in input().split()] for _ in range(N)]

ans = 12*10**5
for seq in product(range(2), repeat=N):
    S = [0]*(M+1)
    for i in range(N):
       for j in range(M+1):
           S[j] += seq[i]*bk[i][j]
    print(S, seq)       
    if min(S[1:M+1]) >= X:
        ans = min(ans, S[0]) 

print(ans)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(n)]
CD = [list(map(int, input().split())) for _ in range(m)]
#print(AB)
#print(CD)

for i in range(n):
    dist_list = []
    for j in range(m):
        dist = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
        dist_list.append(dist)
    #print(dist_list)
    print(dist_list.index(min(dist_list))+1)
# Judge status: Accepted
a, b, x = map(int, input().split())

if x >= a and x <= a + b:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
n, k = map(int, input().split())
p = list(map(int, input().split()))

p.sort()

ans = 0
for i in range(k):
  ans += p.pop(0)
# Judge status: Accepted

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

if n % 2 == 1:
    print("No")
else:
    t = s[:int(n/2)]
    if s == t * 2:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans_l = [0]*n
for i in reversed(range(1,n)):
    if sum(ans_l[(i)::(i+1)])%2 != a[i]:
        ans_l[i] += 1
if sum(ans_l)%2 != a[0]:
    ans_l[0] += 1
ans = []
for i in range(n):
    if ans_l[i]==1:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(" ".join(map(str, ans)))
# Judge status: Accepted
a,b=map(int,input().split())
print((b>>(a<13))*(a>5))
# Judge status: Wrong Answer
n,k=map(int,input().split())
hp=list(map(int,input().split()))
hp.sort(reverse=True)
print(sum(hp[-k:]))
# Judge status: Wrong Answer
s,t=input().split()
a,b=map(int,input().split())
u=input().split()
if s==u:
  print(str(a-1)+" "+str(b))
else:
  print(str(a)+" "+str(b-1))
# Judge status: Accepted
import bisect
n,x=map(int,input().split())
L=list(map(int,input().split()))
lst=[0]*(n+1)
for i in range(1, n+1):
  lst[i]=lst[i-1]+L[i-1]
print(bisect.bisect_right(lst,x))
# Judge status: Wrong Answer
N,M=map(int,input().split())
A = list(map(int,input().split()))

cnt=0
dist = 1
width = 2
fstCmm = 0
while dist <= M:
    flag = 1
    for a in A:
        if (dist / a) - int(dist / a) != 0.5:
            flag  = 0
            break
    if flag == 1:
        fstCmm = dist
        break
    dist += width

print((M-dist)//(dist*2) +1)
# Judge status: Wrong Answer
N = int(input())
for x in range(9,0,-1):
  if N % x == 0 and N // x < 10:
    print("yes")
    exit()
print("no")
# Judge status: Accepted
n, a = map(int, [input() for i in range(2)])

if n-500*(n//500) <= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
  n = int(input())
  ans = 0
  SQRT = int(n ** 0.5)
  for m in range(1,SQRT + 1):
    b = int(n/m)
    ans += m * (m + b) * (b + 1 - m)
  ans -= SQRT * (SQRT+1) * (2*SQRT+1) // 6
  print(ans)
main()
# Judge status: Accepted
# -*- coding: utf-8 -*-

C = input()
print(chr(ord(C) + 1))
# Judge status: Accepted
import math
import decimal
xh = 0
yh = 0
xm = 0
ym = 0

a,b,h,m = map(int, input().split())

th = (h*60+m)/720*2*math.pi
tm = (m)/60*2*math.pi

xh = (a)*math.cos(th)
yh = (a)*math.sin(th)
xm = b*math.cos(tm)
th = b*math.sin(tm)

x = abs(xh-xm)
y = abs(yh-th)
ans = math.sqrt(x**2+y**2)
print(format(ans, '.9f'))
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(len(A)):
    A[i] *= -1

import heapq

heapq.heapify(A)


for _ in range(M):
    a = heapq.heappop(A)
    heapq.heappush(A, ((a*(-1))//2)*(-1))


result = -sum(A)
print(result)
# Judge status: Accepted
a, b, n = [int(elem) for elem in input().split()]

if b <= n:
    res = int(a * (b-1) / b) - a * int((b-1) / b)
else:
    res = int(a * n / b) - a * int(n / b)
print(res)
# Judge status: Wrong Answer
A, V = map(int, input().split())
B, W = map(int, input().split())
T    = int(input())

set_position = abs(B-A)
move         = V-W
for i in range(T):
    set_position -= move

    if set_position==0:
        print("YES")
        break
    elif set_position < 0:
        print("NO")
        break
else:
    print("NO")
# Judge status: Accepted
N,M=map(int,input().split())
A=[]
B=[]
for i in range(N):
    A.append(input())
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        f=True
        for k in range(M):
            if A[j+k][i:M+i]==B[k]:continue
            else:
                f=False
                break
        if f:
            print("Yes")
            exit()
print("No")
# Judge status: Wrong Answer
n = int(input())
 
a = [i**5 for i in range(120)]
for i in range(119):
    for j in range(i+1,119):
        if a[j]-a[i] == n:
            print(j,i)
            break
        if a[j]+a[i] == n:
            print(j,-i)
            break
    else: continue
    break
# Judge status: Wrong Answer
import numpy as np

s_ = int(input())
s = np.array(list(map(int, str(s_))))

a01 = np.tile([0,1], len(s)//2+1)
a10 = np.tile([1,0], len(s)//2+1)

if len(s)%2 != 0:
    a01 = np.delete(a01, len(s))
    a10 = np.delete(a10, len(s))
else:
    a01 = np.delete(a01, [len(s)-1,len(s)])
    a10 = np.delete(a10, [len(s)-1,len(s)])

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))
# Judge status: Accepted
money = int(input())

tem_1 = money // 500
money_2 = money % 500
tem_2 = money_2 // 5
ans = 1000*tem_1 + 5*tem_2
print(ans)
# Judge status: Wrong Answer
from bisect import bisect_left

def get_prime_list(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


X = int(input())
primes = get_prime_list(100100)
print(bisect_left(primes, X))
# Judge status: Accepted
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
X = list(map(int, readline().split()))
X_sorted = sorted(X)

# この二つ以外にありえない
small, large = X_sorted[(N-1)//2], X_sorted[(N+1)//2]

for x in X:
    if x <= small:
        print(large)
    else:
        print(small)
# Judge status: Wrong Answer
x,y = input().split(' ')
x = int(x)
y = int(y)

if y == 1:
  print(-1)
else:
  if 0 < x and x <= 1e18:
    print(x)
  else :
    print(-1)
# Judge status: Accepted
n = int(input())
s = input()

add_l = 0
add_r = 0

for e in s:
	if e == "(":
		add_r += 1

	else: # e == ")"
		if add_r == 0:
			add_l += 1
		else:
			add_r -= 1

ans = add_l * "(" + s + ")" * add_r
print(ans)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))

    total = sum(A)
    s = 0
    m = total
    for a in A:
        s += a
        tmp = abs(total- 2*s)
        if tmp < m:
            m = tmp

    print(m)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
abc = list(map(int, input().split()))
k = int(input())

abc.sort()
abc[2] = abc[2] * 2 ** (k-1)

print(sum(abc))
# Judge status: Accepted
def resolve():
    n, k = map(int, input().split())
    Mod = 1000000007
    ans = 0
    for i in range(n - k + 2):
        j = i + k
        start = j * (j - 1) / 2
        final = (n * 2 - j + 1) * j / 2
        add = final - start + 1
        ans = (ans + add) % Mod
    print(int(ans))

resolve()
# Judge status: Wrong Answer
n = int(input())
l = []

for i in range(1,n + 1):
    j = n - i
    x = sum(map(int,list(str(i)))) + sum((map(int,list(str(j)))))
    l.append(x)

print(min(l))
# Judge status: Accepted
from math import gcd
def solve(i,j,k):
    return gcd(gcd(i,j),k)
n = int(input())
ans = 0
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans+=solve(i,j,k)
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ca = 0
cb = 0
for i,j in zip(a,b):
    if i > j:
        cb += i-j
    else:
        ca += j-i
if ca > cb:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
c = [[0 for _ in range(10)] for _ in range(10)]

for i in range(n + 1):
    left = int(str(i)[0])
    right = i % 10
    c[left][right] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += c[i][j] * c[j][i]

print(ans)
# Judge status: Accepted
n = int(input())
cnt = 0
for i in range(n):
  a,b = map(int,input().split())
  if a==b:
    cnt+=1
  else:
    cnt = 0
  if cnt ==3:
    print('Yes')
    exit()
print('No')
# Judge status: Wrong Answer
a,b,c = [int(a) for a in input().split()]
print(a+b)
# Judge status: Accepted
n = int(input())

if n == 0:
    print(0)
    exit()

s = ""

while True:
    if n == 0:
        break
    if n%2 == 0:
        s += "0"
        n = n//(-2)
    else:
        s += "1"
        n = (n-1)//(-2)

print(s[::-1])
# Judge status: Wrong Answer
a,b,n=map(int,input().split())
Alist = list(range(a,min(a+n,b+1),1))
Blist = list(range(max(a,b-n+1),b+1,1))
C = set(Alist)|set(Blist)
for i in list(C):
  print(i)
# Judge status: Accepted
N = int(input())

A = str(N)
check = 0

for i in range(0,3):
  if(A[i] == '7'):
    check = 1
    
if(check == 1):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N_ = int(input())
A_ = int(input())

if N_ % 500 > A_:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
x, a, b = map(int,input().split())

if abs(x-a) > abs(x-b):
    print("B")
else:
    print("A")