Problem:
 Score : 300 points    Problem Statement When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2}) -th largest value among a_1, a_2, ..., a_l .  You are given N numbers X_1, X_2, ..., X_N , where N is an even number.
For each i = 1, 2, ..., N , let the median of X_1, X_2, ..., X_N excluding X_i , that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i .  Find B_i for each i = 1, 2, ..., N .      Constraints  2 \leq N \leq 200000  N is even.  1 \leq X_i \leq 10^9  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  X_1  X_2 ... X_N       Output Print N lines.
The i -th line should contain B_i .        Sample Input 1 4
2 4 4 3      Sample Output 1 4
3
3
4   Since the median of X_2, X_3, X_4 is 4 , B_1 = 4 .  Since the median of X_1, X_3, X_4 is 3 , B_2 = 3 .  Since the median of X_1, X_2, X_4 is 3 , B_3 = 3 .  Since the median of X_1, X_2, X_3 is 4 , B_4 = 4 .        Sample Input 2 2
1 2      Sample Output 2 2
1       Sample Input 3 6
5 5 4 4 3 3      Sample Output 3 4
4
4
4
4
4

Solution (Python):
import bisect
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


n = I()
x = LI()
sx = [(i, x[i]) for i in range(n)]
sx = sorted(sx, key=lambda a: a[1])
mid_l = sx[n // 2 - 1][1]
mid_r = sx[n // 2][1]

sx = [(sx[i][0], i, sx[i][1]) for i in range(n)]
sx = sorted(sx, key=lambda a: a[0])

for _, sort_i, elem in sx:
    if sort_i < n // 2:
        print(mid_r)
    else:
        print(mid_l)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = sorted(a)
mi = b[n//2-1]
ma = b[n//2]
for x in a:
    print(ma if x <= mi else mi)

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
sort_x = sorted(X)

smaller = sort_x[n//2-1]
bigger = sort_x[n//2]

for x in X:
    if x <= smaller:
        print(bigger)
    else:
        print(smaller)

Solution (Python):
import sys



from bisect import bisect_left, bisect_right





input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 1000000007

def solve():
    n = getN()
    nums = getList()
    
    b1, b2 = sorted(nums)[n//2 - 1], sorted(nums)[n//2]
    for i, num in enumerate(nums):
        if num <= b1:
            print(b2)
        else:
            print(b1)
def main():
    n = getN()
    for _ in range(n):
        solve()
if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Xs = list(mapint())
cX = Xs[:]
cX.sort()

lm = cX[N//2-1]
rm = cX[N//2]

for x in Xs:
    if x<=lm:
        print(rm)
    else:
        print(lm)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X[:])
Y1 = Y[N//2-1]
Y2 = Y[N//2]
for i in range(N):
    if X[i]>Y1:
        print(Y1)
    else:
        print(Y2)

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
x = sorted(X)
l = x[n//2-1]
r = x[n//2]
for i in range(n):
    if X[i] <= l:
        print(r)
    else:
        print(l)

Solution (Python):
n = int(input())
*x, = map(int, input().split())
y = sorted(x)
for i in x:
    if i < y[n//2]:
        print(y[n//2])
    else:
        print(y[n//2-1])

Solution (Python):
N,*X=map(int,open(0).read().split())
M=sorted(X)[N//2-1:N//2+1]
for x in X:
    print(M[x<M[1]])

Solution (Python):
N=int(input())
*X,=map(int,input().split())
Y=sorted(X)

mr=Y[N//2]
ml=Y[N//2-1]

for x in X:
    if mr<=x:
        print(ml)
    else:
        print(mr)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
a = sorted(x)
front = a[n//2-1]
rear = a[n//2]
for i in x:
    if i <= front:
        print(rear)
    else:
        print(front)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
B = [[A[i],i] for i in range(N)]
d = {}
B.sort()
for i in range(N):
    d[B[i][1]] = i
for i in range(N):
    if d[i] <N//2:
        print(B[N//2][0])
    else:
        print(B[-1+(N//2)][0])

Solution (Python):
import math
n = int(input())

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

nlis = sorted(lis)

med1 = nlis[n//2-1]
med2 = nlis[n//2]

for i in lis:
    if i <= med1:
        print(med2)
    else:
        print(med1)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
X = l()
x = sorted(X)
l = x[N//2-1]
u = x[N//2]
for i in range(N):
    if X[i] >= u:
        print(l)
    else:
        print(u)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
L = sorted(X[::])


len_X_first = len(X) // 2 - 1
len_X_second = len(X) // 2

for i in X:
    if (L[len_X_first] >= i):
        print(L[len_X_second])
    elif (L[len_X_second] <= i):
        print(L[len_X_first])

Solution (Python):
import copy
N=int(input())
X=list(map(int,input().split()))
B=[]
P=copy.copy(X)
X.sort()
a=X[N//2-1]
b=X[N//2]
for i in range(N):
  if P[i]<=a:
    B.append(b)
  else:
    B.append(a)
for j in range(N):
  print(B[j])

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]

Y = sorted(X)
for i in range(N):
    if X[i] < Y[N // 2]:
        print(Y[N // 2])
    else:
        print(Y[N // 2 - 1])

Solution (Python):
N = int(input())
X = [int(x) for x in input().split()]

ind = [i for i in range(N)]

ind = sorted(ind, key = lambda i : X[i])
ans = [0] * N
for i in range(N // 2):
    ans[ind[i]] = X[ind[N // 2]]
for i in range(N // 2, N):
    ans[ind[i]] = X[ind[N // 2 - 1]]

for i in range(N):
    print(ans[i])

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
for i in range(n):
	if x[i] <= y[n//2-1]:
		print(y[n//2])
	else:
		print(y[n//2-1])

Solution (Python):
n=int(input())
L=list(map(int, input().split()))

M=sorted(L)
a=M[n//2]
b=M[n//2-1]

for i in range(n):
	if L[i]>=a:
		print(b)
	else:
		print(a)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))

Y = sorted(X)
m = Y[N//2 - 1]
M = Y[N//2]

for i in X:
  if i <= m:
    print(M)
  else:
    print(m)

Solution (Python):
import statistics

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

small = statistics.median_low(xl)
big = statistics.median_high(xl)

for i in range(N):
    if xl[i] <= small:
        print(big)
    else:
        print(small)

Solution (Python):
n=int(input())
N=list(map(int,input().split()))
N2 = sorted(N)

nl=N2[int(n/2)-1]
nr=N2[int(n/2)]
for i in N:
  if i<=nl:
    print(nr)
  else:
    print(nl)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *x = map(int, read().split())

x2=sorted(x)
mid_left = x2[n // 2 - 1]
mid_right = x2[n // 2]

for v in x:
    if v <= mid_left:
        print(mid_right)
    else:
        print(mid_left)

Solution (Python):
import copy
n=int(input())
x=list(map(int,input().split()))

y=copy.copy(x)
y.sort()

left=y[n//2-1]
right=y[n//2]

for i in range(n):
    if x[i]<=left:
        print(right)
    else:
        print(left)

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
X = sorted(x)
a = X[n//2]
b = X[n//2 -1]

for i in range(n):
     if x[i] >= a:
         print(b)
     elif x[i] <= b:
         print(a)

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

A=sorted(a)

m1=A[n//2 -1]
m2=A[n//2]
for i in range(n):
    if a[i]<=m1:
        print(m2)
    else:
        print(m1)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
y = x
y = sorted(y)
a = y[n // 2 -1]
b = y[n // 2]
for i in range(n):
  if x[i] <= a:
    print(b)
  elif x[i] >= b:
    print(a)

Solution (Python):

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


l, r = N // 2 - 1, N // 2
sort_x = sorted(X)
lx, rx = sort_x[l], sort_x[r]

if lx == rx:
    for i in range(N):
        print(lx)
else:
    for ind in range(N):
        target = X[ind]
        if target <= lx:
            print(rx)
        if target >= rx:
            print(lx)

Solution (Python):
import copy

N = int(input())

x = list(map(int,input().split()))
sort_x = copy.copy(x)
sort_x.sort()

center_num = (N-1) // 2

for l in x:
    if l <= sort_x[center_num]:
        print(sort_x[center_num+1])
    else:
        print(sort_x[center_num])

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    X = il()
    S = sorted(X)
    l = S[N // 2 - 1]
    r = S[N // 2]
    for x in X:
        if x <= l:
            print(r)
        else:
            print(l)


if __name__ == '__main__':
    main()

Solution (Python):
import copy

n = int(input())
x = list(map(int, input().split()))
num = 0

y = copy.copy(x)
x.sort()
num1 = x[n//2-1]
num2 = x[n//2]

for i in y:
  if i <= num1:
    print(num2)
  else:
    print(num1)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
x=b[n//2-1]
y=b[n//2]
for i in a:
    if i<=x:
      print(y)
    else:
      print(x)

Solution (Python):


def main():
    numbers=[]
    n = int(input())
    numbers=list(map(int,input().split()))
    sort_numbers=sorted(numbers)

    left=sort_numbers[n//2-1]
    right=sort_numbers[n//2]

    for i in numbers:
        if i > left:
            print(left)
        else:
            print(right)

if __name__=="__main__":
    main()

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y = sorted(x)
a , b = y[n//2-1], y[n//2]
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

Solution (Python):
n=int(input())

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

l2d=[]
for i in range(n):
    l2d.append([i,xl[i]])

xlsort=sorted(xl)
v1=xlsort[n//2-1]
v2=xlsort[n//2]

l2d.sort(key=lambda x: x[1])
dic={}
for i in range(n):
    dic[l2d[i][0]]=i
thre=n//2
for i in range(n):
    if dic[i]<thre:
        print(v2)
    else:
        print(v1)

Solution (Python):
n=int(input())

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

l2d=[]
for i in range(n):
    l2d.append([i,xl[i]])

xlsort=sorted(xl)
v1=xlsort[n//2-1]
v2=xlsort[n//2]

l2d.sort(key=lambda x: x[1])
dic={}
for i in range(n):
    dic[l2d[i][0]]=i
thre=n//2
for i in range(n):
    if dic[i]<thre:
        print(v2)
    else:
        print(v1)

Solution (Python):
import sys
input = sys.stdin.readline



def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    sorted_x = sorted(X_list)

    left = sorted_x[(N // 2)-1]
    right = sorted_x[N // 2]
    for x in X_list:
        if x <= left:
            print(right)
        else:
            print(left)


if __name__ == "__main__":
    main()

Solution (Python):
from statistics import median
from operator import itemgetter
N = int(input())
x = list(map(int, input().split()))
x_ = sorted(x)
m0 = median(x_[1:])
m1 = median(x_[:-1])
for i in x:
    if m1 >= i:
        print(m0)
    else:
        print(m1)

Solution (Python):
n = int(input())
X = list(map(int, input().split()))

Y = X[::]
Y.sort()

m = n // 2
median = (Y[m] + Y[m - 1]) / 2

for x in X:
    if x < median:
        print(Y[m])
    else:
        print(Y[m-1])

Solution (Python):
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
x=list(map(int,input().split()))
tmp=sorted(x)

if n%2==0:
    heikin=(tmp[n//2]+tmp[n//2-1])/2
    for i in range(n):
        if heikin<x[i]:
            print(tmp[n//2-1])
        else:
            print(tmp[n//2])

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
order = {}
for idx, x in enumerate(X):
    order[idx] = x

X.sort()
m = N // 2
l = X[m - 1]
r = X[m]

for idx in range(N):
    x = order[idx]
    if x <= l:
        print(r)
    else:
        print(l)

Solution (Python):
N=int(input())
X=list(map(int, input().split()))
Y=sorted(X)
mae=Y[N//2-1]
ato=Y[N//2]

for x in X:
  if x<=mae:
    print(ato)
  elif x>=ato:
    print(mae)

Solution (Python):
import copy

n = int(input())
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1
ans = copy.copy(l)
ans.sort()

for i in l:
    if i >= ans[p1]:
        print(ans[p2])
    else:
        print(ans[p1])

Solution (Python):
N = int(input())
x_list = list(map(int, input().split()))
sorted_x = sorted(x_list)

medi = N//2
l = sorted_x[medi-1]
r = sorted_x[medi]
for x in x_list:
    if x < r:
        print(r)
    else:
        print(l)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
B = A.copy()
A.sort()

ans_ato = A[n//2]
ans_mae = A[n//2-1]

for b in B:
    if b < ans_ato:
        print(ans_ato)
    else:
        print(ans_mae)

Solution (Python):
import bisect

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

Ss = sorted(Xs)

for i in range(N):
  j = bisect.bisect_left(Ss, Xs[i])
  if j < N//2:
    print(Ss[N//2])
  else:
    print(Ss[N//2-1])

Solution (Python):
N = int(input())
*X, = map(int, input().split())
Y = sorted(X)
m1 = Y[N//2-1]
m2 = Y[N//2]
for x in X:
    if x < m2:
        print(m2)
    else:
        print(m1)

Solution (Python):
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n=ni()
x=nl()

sx = sorted(x)[::-1]

c = n//2

for i in range(n):
  if x[i] > sx[c]:
    print(sx[c])
  else:
    print(sx[c-1])

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
sorted_A = sorted(A)
mid = N // 2 - 1
left = sorted_A[mid]
right = sorted_A[mid+1]
answer = [left if a > left else right for a in A]
print('\n'.join(map(str, answer)))

Solution (Python):
n = int(input())
X = list(map(int, input().split()))
XX = sorted(X)
m = n // 2
l = XX[m - 1]
g = XX[m]
for x in X:
	if x <= l:
		print(g)
	else:
		print(l)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
num=sorted(x)
num1=num[n//2-1]
num2=num[n//2]
for i in range(n):
    if x[i]<=num1:
        print(num2)
    else:
        print(num1)

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

Y = [(i, x) for i, x in enu(X)]
sY = sorted(Y, key=lambda x: x[1])
ssY = [(i,) + y for i, y in enu(sY)]
sssY = sorted(ssY, key=lambda x: x[1])





for i in range(N):
    tup = sssY[i]
    sor_ind, ini_ind, val = tup
    
    if sor_ind < N//2:
        print(sY[N//2][1])
    else:
        print(sY[N//2-1][1])

Solution (Python):
n = int(input())
x_l = list(map(int,input().split()))
s_x_l = sorted(x_l)

med_idx = n//2
med_l = s_x_l[med_idx-1]
med_r = s_x_l[med_idx]

for i in range(n):
    if  x_l[i] <= med_l:
        print(med_r)
    else:
        print(med_l)

Solution (Python):
n = int(input())

argList = list(map(int, input().split()))
argList2 = argList.copy()
argList2.sort()

med_before = argList2[int(len(argList2)/2)-2]
med = argList2[int(len(argList2)/2)-1]
med_after = argList2[int(len(argList2)/2)]

for a in argList:
    if( a <= med):
        print(med_after)
    else:
        print(med)

Solution (Python):
n = int(input())
l = list(map(int, input().split()))

ls = sorted(l)
k = (ls[n//2-1] + ls[n//2])/2

for i in range(n):
    if l[i] < k:
        print(ls[n//2])
    else:
        print(ls[n//2-1])

Solution (Python):
def mi():
    return map(int, input().split())

def main():
    N = int(input())
    X = list(mi())
    Y = sorted(X)
    for i in range(N):
        if X[i] <= Y[N//2-1]:
            print(Y[N//2])
        else:
            print(Y[N//2-1])


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
n = int(input())
X = list(map(int, input().split()))
c = Counter(X)
Xsort = sorted(X)

for i in range(n):
    if X[i]<Xsort[n//2]:
        print(Xsort[n//2])
    else:
        print(Xsort[n//2-1])

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
nx = [X[i] for i in range(N)]
nx.sort()
ans2 = (nx[N//2])
ans3 = (nx[N//2-1])

for i in range(N):
    if X[i] <= nx[N//2-1]:
        print(ans2)
    elif X[i] >= nx[N//2]:
        print(ans3)

Solution (Python):
n=int(input())
import copy
l=list(map(int,input().split()))
m=copy.copy(l)
l.sort()
a=l[n//2-1]
b=l[n//2]
for i in range(n):
  if m[i]<=a:
    print(b)
  else:
    print(a)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
sx = sorted(x)
m = n//2
l = sx[m - 1: m + 1]

for i in x:
    if i < l[1]:
        print(l[1])
    else:
        print(l[0])

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
sx = sorted(x)
m = n//2
l = sx[m - 1: m + 1]

for i in range(n):
    if x[i] < l[1]:
        print(l[1])
    else:
        print(l[0])

Solution (Python):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    for i in range(n):
        if a[i] <=  b[n // 2 - 1]:
            print(b[n // 2])
        elif a[i] >  b[n // 2 - 1]:
            print(b[n // 2 - 1])
        
        
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
sort_x = sorted(x)
m1 = n // 2 - 1
m2 = n // 2
for i in range(n):
    if x[i] <= sort_x[m1]:
        print(sort_x[m2])
    elif x[i] >= sort_x[m2]:
        print(sort_x[m1])

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
med1, med2 = sorted(x)[n // 2 - 1 : n // 2 + 1]
ans = [med2 if i <= med1 else med1 for i in x]
print('\n'.join(map(str, ans)))

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
x=sorted(l)
m=(x[n//2]+x[n//2-1])/2
for y in l:
  if y<m:
    print(x[n//2])
  else:
    print(x[n//2-1])

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    X = list(map(int, input().split()))
    for i in range(n):
        x = X[i]
        X[i] = [i, x]
    X_s = sorted(X, key=lambda x: x[1])

    res = [0] * n
    for i in range(n):
        idx, _ = X_s[i]
        if i < n // 2:
            res[idx] = X_s[n // 2][1]
        else:
            res[idx] = X_s[n // 2 - 1][1]

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


if __name__ == '__main__':
    resolve()

Solution (Python):



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

sortedX = sorted(X)

l = sortedX[n // 2 - 1]
r = sortedX[n // 2]

for x in X:
  if x <= l:
    print(r)
  else:
    print(l)

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

B = sorted(A)
X = B[N//2-1]
Y = B[N//2]

for i in range(N):
    if A[i] <= X:
        print(Y)
    else:
        print(X)

Solution (Python):






from collections import defaultdict











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
X = readInts()
nya = sorted(X)
m1 = nya[n//2-1];m2 = nya[n//2]


for x in X:
    if x <= m1:
        print(m2)
    else:
        print(m1)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
y=sorted(x[:])
l=y[n//2-1]
r=y[n//2]
for xx in x:
  print(l if xx>=r else r)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
A = sorted(X[:])
B = A[N//2-1]
for i in range(N):
    if X[i]>B:
        print(B)
    else:
        print(A[N//2])

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
X = list(map(int, input().split()))
l = [(i, X[i]) for i in range(N)]
l.sort(key=lambda t: t[1])
ans = [-1]*N

for i in range(N):
    if i<N//2:
        ans[l[i][0]] = l[N//2][1]
    else:
        ans[l[i][0]] = l[N//2-1][1]

for ans_i in ans:
    print(ans_i)

Solution (Python):
N = int(input())
x = list(map(int, input().split()))
import copy
a = copy.copy(x)
a.sort()
m = a[N//2-1]
for i in range(N):
  if x[i] <= m:
    print(a[N//2])
  else:
    print(m)

Solution (Python):
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    X = [int(x) for x in input().split()]
    Xsub = sorted(X)
    midl, midr = Xsub[(N - 1) // 2], Xsub[N // 2]
    ans = [0] * N
    for i, x in enumerate(X):
        if x <= midl: ans[i] = midr
        else: ans[i] = midl
    print(*ans, sep="\n")

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from bisect import *

n=int(input())
x=list(map(int,input().split()))
x_s=sorted(x)

ans1=x_s[n//2]
ans2=x_s[n//2-1]

for i in range(n):
  inx=bisect_right(x_s,x[i])
  if inx<=n//2:
    print(ans1)
  else:
    print(ans2)

Solution (Python):
n = int(input())
x = list(enumerate(map(int, input().split())))
x.sort(key=lambda x:x[1])
ans = [""]*n
for i in range(n):
  if (n+1)//2 >= i+1: ans[x[i][0]] = x[(n+1)//2][1]
  else: ans[x[i][0]] = x[(n+1)//2-1][1]

print("\n".join(map(str, ans)))

Solution (Python):
n = int(input())
X = list(map(int,input().split()))
h = int(n/2)
Xs = sorted(X)
m1 = Xs[h-1]
m2 = Xs[h]

for i in range(n):
  if X[i] <= m1:
    print(m2)
  else:
    print(m1)

Solution (Python):
N = int(input())
x = list(input().split())
num = [int(x[i]) for i in range(N)]
num_sorted = sorted(num)
min_center = num_sorted[N // 2 - 1]
max_center = num_sorted[N // 2]

for i in range(N):
    if num[i] <= min_center:
        print(max_center)
    else:
        print(min_center)

Solution (Python):
N = int(input())
X = list(map(int,(input().split())))
xs = sorted(X)

a = int(N/2)
b = a-1

aa = xs[a]
bb= xs[b]

A = aa
B = bb


for i in X:
  if i >= A:
    print(B)
  else:
    print(A)

Solution (Python):
import sys

read = sys.stdin.buffer.read

n,*x = list(map(int, read().split()))
x_sort = sorted(x)

mean_left = x_sort[n//2-1]
mean_right = x_sort[n//2]


for i in range(n):
  if x[i] <= mean_left:
    print(mean_right)
  elif x[i] >= mean_right:
    print(mean_left)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
l=sorted(x)
a,b=l[n//2-1],l[n//2]
for i in x:
 if (a+b)/2<=i:print(a)
 else:print(b)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
sx = sorted(x)
s1, s2 = sx[n//2-1], sx[n//2]
m = (s1 + s2) / 2
for i in x:
    if m > i: print(s2)
    else: print(s1)

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

if __name__ == "__main__":
    n = int(input())
    x = list(map(int,input().split()))
    y = x[:]
    y.sort()
    L = y[n//2-1]
    R = y[n//2]
    for i in range(n):
        if x[i] <= L:
            print(R)
        else:
            print(L)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
L=y[n//2-1]
R=y[n//2]
for i in range(n):
    if x[i]<=L:
        print(R)
    else:
        print(L)

Solution (Python):
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    Xs = sorted(X)

    for i in range(len(X)):
        if  Xs[len(Xs)//2] > X[i]:
            print(Xs[len(Xs)//2])
        else:
            print(Xs[len(Xs)//2 - 1])

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
t = sorted(x)
m = t[n // 2]
p = t[n // 2 - 1]
for y in x:
    if y >= m:
        print(p)
    else:
        print(m)

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
sX = sorted(X)

mid = N // 2 - 1
l = sX[mid]
r = sX[mid+1]
for i in range(N):
    if X[i] <= l:
        print(r)
    else:
        print(l)

Solution (Python):
n = int(input())
xs = [(i, int(v)) for i, v in enumerate(input().split())]

tmp = sorted(xs, key=lambda x: x[1])

a = tmp[n // 2 - 1][1]
b = tmp[n // 2][1]

ans = [0]*n

for i,v in tmp[:n//2]:
    ans[i] = b
    
for i, v in tmp[n//2:]:
    ans[i] = a

for i in ans:
    print(i)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
sort_X = sorted(X)
a = sort_X[N//2-1]
b = sort_X[N//2]
for i in range(N):
    if X[i] < b:
        print(b)
    else:
        print(a)

Solution (Python):
n = int(input())
x = list(map(int , input().split()))
y = sorted(x)
ms = y[(n-1)//2]
ml = y[n//2]

for xi in x:
    if xi < ml:
        print(ml)
    else:
        print(ms)

Solution (Python):
import statistics
n = int(input())
a_li = list(map(int,input().split()))
median_low = statistics.median_low(a_li)
median_high = statistics.median_high(a_li)
for i in range(n):
    if a_li[i] <= median_low:
        print(median_high)
    else:
        print(median_low)

Solution (Python):
import copy
n = int(input())
X = [0]+[int(i) for i in input().split()]
Copy = copy.deepcopy(X)

X.sort()
index_right = int(n/2+1)
index_left = index_right-1
key_r = X[index_right]
key_l = X[index_left]

for i in range(1,n+1):
    if Copy[i] <= key_l:
        print(key_r)
    else:
        print(key_l)

Solution (Python):
import numpy as np
n=int(input())
l=list(map(int,input().split()))

arr=np.sort(np.array(l))
med=np.median(arr)

med_max=int(np.median(np.delete(arr,0)))
med_min=int(np.median(np.delete(arr,n-1)))


p=(n+1)//2
for i in range(n):
    if l[i]<=arr[p-1]:
        print(med_max)
    else:
        print(med_min)

Solution (Python):
import numpy as np
n=int(input())
l=list(map(int,input().split()))

arr=np.sort(np.array(l))
med=np.median(arr)

med_max=int(np.median(np.delete(arr,0)))
med_min=int(np.median(np.delete(arr,n-1)))

if n%2==1:
    p=(n-1)//2
    med_midmin=int(np.median(np.delete(arr,p+1)))
    med_mid=int(np.median(np.delete(arr,p)))
    med_midmax=int(np.median(np.delete(arr,p-1)))

    for i in range(n):
        if l[i]<arr[p-1]:
            print(med_max)
        elif l[i]==arr[p-1]:
            print(med_midmax)
        elif l[i]==arr[p]:
            print(med_mid)
        elif l[i]==arr[p+1]:
            print(med_midmin)
        else:
            print(med_min)

if n%2==0:
    p=(n+1)//2
    med_midmin=int(np.median(np.delete(arr,p)))
    med_midmax=int(np.median(np.delete(arr,p-1)))
    for i in range(n):
        if l[i]<arr[p-1]:
            print(med_max)
        elif l[i]==arr[p-1]:
            print(med_midmax)
        elif l[i]==arr[p]:
            print(med_midmin)
        else:
            print(med_min)

Solution (Python):
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))

sA = sorted(A)
l = sA[N//2 - 1]
r = sA[N//2]

median = defaultdict(int)
m = N // 2 - 1
for i,a in enumerate(sA):
  if i <= m and not median[a]:
    median[a] = sA[m+1]
  elif m < i and not median[a]:
    median[a] = sA[m]

ans = []
for a in A:
  ans.append(median[a])
  
print("\n".join(map(str,ans)))

Solution (Python):
n = int(input())
x = list(map(int,input().split()))
a = x[:]
a.sort()
kijun = a[n//2]
a1 = a[n//2]
a2 = a[n//2-1]
for i in x:
	if i < kijun:
		print(a1)
	else:
		print(a2)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
xt=sorted(x)
for i in range(n):
  if x[i]<=xt[n//2-1]:
    print(xt[n//2])
  else:
    print(xt[n//2-1])

Solution (Python):
n = int(input())
X = tuple(map(int, input().split()))
Xs = sorted(X)

ml = Xs[n//2-1]
mr = Xs[n//2]

for i in range(n):
    if X[i] <= ml:
        print(mr)
    else:
        print(ml)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)


left = b[int(n/2)-1]
right = b[int(n/2)]
if left == right:
  for i in range(n):
    print(right)
else:
  for i in range(n):
    if a[i] <= left:
      print(right)
    else:
      print(left)

Solution (Python):
N = int(input())
XS = list(map(int, input().split()))
mid_low = sorted(XS)[len(XS) // 2 - 1]
mid_high = sorted(XS)[len(XS) // 2]
for x in XS:
    if x <= mid_low:
        print(mid_high)
    else:
        print(mid_low)

Solution (Python):
n = int(input())
X = tuple(map(int, input().split()))
Xs = sorted(X)

ml = Xs[n//2-1]
mr = Xs[n//2]

for i in range(n):
    if X[i] <= ml:
        print(mr)
    else:
        print(ml)

Solution (Python):
import copy
N = int(input())
X = [int(i) for i in input().split()]
Y = copy.deepcopy(X)
Y = sorted(Y, key= lambda x: -x)

c = int(N/2)

for i in range(N):
    a = X[i]
    if a >= Y[c-1]:
        print(Y[c])
    else:
        print(Y[c-1])

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]








n=l()[0]
X=l()
A=sorted(X)
d={}
z=n//2
for i in range(n):
    if(A[i] in d):
        continue
    if(i<z):
        d[A[i]]=A[z]
    else:
        d[A[i]]=A[z-1]
for i in range(n):
    print(d[X[i]])

Solution (Python):
import sys
readline = sys.stdin.readline

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

S = sorted(X)
mM = S[N // 2 - 1]
lM = S[N // 2]

for i in range(N):
  if X[i] <= mM:
    print(lM)
  else:
    print(mM)