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):
N = int(input())
sorted_X = sorted([(v, i) for i, v in enumerate(map(int, input().split()))])
med_former = sorted_X[N // 2][0]
med_latter = sorted_X[N // 2 - 1][0]
ans = [-1] * N
for j, (v, i) in enumerate(sorted_X):
    if j < N // 2:
        ans[i] = med_former
    else:
        ans[i] = med_latter
print("\n".join(map(str, ans)))

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
X = LI()
sort_X = sorted(X)
ans1,ans2 = sort_X[(N-1)//2],sort_X[N//2]
for x in X:
    if x>=ans2:
        print(ans1)
    else:
        print(ans2)

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

y = sorted(x)

from bisect import bisect_left
border=n//2-1

if n==2:
    print(x[1])
    print(x[0])
    exit(0)


for i in range(n):
    index = bisect_left(y,x[i])

    if index<=border:
        print(y[border+1])
    else:
        print(y[border])

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

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

Solution (Python):
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis_sort = sorted(inlis)

    low = inlis_sort[int(n/2)-1]
    high = inlis_sort[int(n/2)]
    ave = (low + high) / 2

    for i in inlis:
        if i >= ave:
            print(low)
        else:
            print(high)

    
    

if __name__ == "__main__":
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7


N = INT()
X = LIST()
Y = []

for i, x in enumerate(X):
	Y.append([i, x])
Y.sort(key = lambda x: x[1])

M1 = Y[N//2][1]
M2 = Y[N//2-1][1]

for i in range(N):
	if i >= N//2:
		Y[i][1] = M2
	else:
		Y[i][1] = M1

Y.sort(key = lambda x: x[0])

print(*[x[1] for x in Y], sep="\n")

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

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

y = sorted(x)

for i in x:
    if y[(n+1)//2-1] >= i:
        print(y[(n+1)//2])
    else:
        print(y[(n+1)//2-1])

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

Y=copy.copy(X)
Y.sort()
center = N//2
right = Y[center]
left = Y[center-1]
center_line = (right+left)/2

for i in range(N):
  if X[i] > center_line:
    print(left)
  else:
    print(right)

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

sl = sorted(l)
a, b = sl[n // 2 - 1], sl[n // 2]
for i in l:
    if i <= a:
        print(b)
    else:
        print(a)

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)])
  elif x[i] >= y[(n//2)]:
    print(y[(n//2) - 1])

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

import numpy as np
ary = np.array(x)
ranks = ary.argsort()
rank_dict = {index:rank for rank,index in enumerate(ranks, start=1)}

MID=n//2
upper = x[ranks[MID]]
lower = x[ranks[MID-1]]
for i in range(n):
    rank = rank_dict[i]
    if rank <= MID:
        print(upper)
    else:
        print(lower)

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

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

x_sort = sorted(x)
ans_1 = x_sort[int(n / 2)-1]
ans_2 = x_sort[int(n / 2)]

for xi in x:
    if xi <= ans_1:
        print(ans_2)
    else:
        print(ans_1)

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

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

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

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()


def resolve():
    n = int(input())
    l = list(map(int, input().split()))
    lsort = sorted(l)
    left = lsort[n // 2 - 1]
    right = lsort[n // 2]
    for i in l:
        if i <= left:
            print(right)
        else:
            print(left)
resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    l2=sorted(l)
    x=l2[n//2-1]
    y=l2[n//2]
    if x==y:
        for i in range(n):
            print(x)
    else:
        setx=set(l2[:n//2])
        sety=set(l2[n//2:])
        for i in l:
            if i in setx:
                print(y)
            else:
                print(x)
resolve()

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
A_copy = A.copy()
n = N//2
A.sort()
avg = (A[n]+A[n-1])/2
for i in A_copy:
    if i < avg:
        print(A[n])
    else:
        print(A[n-1])

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

Solution (Python):
n = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
left = Y[n//2-1]
right = Y[n//2]

for i in X:
    if i <= left:
        print(right)
        
    else:
        print(left)

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

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

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

for c in x:
    if c <= a:
        print(b)
    else:
        print(a)

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    sorted_l = sorted(L)
    left_pivot = sorted_l[n//2 - 1]
    right_pivot = sorted_l[n//2]

    if left_pivot == right_pivot:
        for _ in range(n):
            print(left_pivot)
    else:
        for elm in L:
            print(right_pivot) if elm <= left_pivot else print(left_pivot)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
import copy

N = int(input())
X = [int(i) for i in input().split()]

max_value = max(X)
min_value = min(X)

tmp_list = copy.deepcopy(X)
tmp_list.sort()
all_med = tmp_list[int((len(tmp_list)+1) / 2) - 1]

tmp_list.remove(max_value)
min_med = tmp_list[int((len(tmp_list)+1) / 2) - 1]

tmp_list = copy.deepcopy(X)
tmp_list.remove(min_value)
tmp_list.sort()
max_med = tmp_list[int((len(tmp_list)+1) / 2) - 1]

for i in range(N):
    if X[i] <= all_med:
        print(int(max_med))
    else:
        print(int(min_med))

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

m = a[int(n/2)-1]
M = a[int(n/2)]
median = (m+M)/2

for i in s:
    if i > median:
        print(m)
    else:
        print(M)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






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






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1





N = I()
X = IL()

Y = X[:]
Y.sort()

A,B = Y[N//2-1],Y[N//2],

for x in X:
  if x > A:
    P(A)
  else:
    P(B)

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

for i in range(n):
    if a[i]>(l+s)/2:
        print(s)
    else:
        print(l)

Solution (Python):
n = int(input())
x_list = [int(x) for x in input().split()]
temp_list = sorted(x_list)
temp = n // 2
l = temp_list[temp - 1]
r = temp_list[temp]
for x in x_list:
    print(r if x <= l else l)

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

x = sorted(X)
ans_1 = x[N // 2 - 1]
ans_2 = x[N // 2]

ans = []
for i in range(N):
    if X[i] <= ans_1:
        ans.append(ans_2)
    else:
        ans.append(ans_1)

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
xsort = sorted(x)

for i in range(n):
    if xsort[n//2] > x[i]:
        print(xsort[n//2])
    else:
        print(xsort[n//2-1])

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

Solution (Python):

N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
m1 = Y[N//2]
m2 = Y[N//2-1]

for i in range(N):
    if m1 > X[i]:
        print(m1)  
    else:
        print(m2)

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
B = sorted(A)
med = B[n//2-1:n//2+1]

for a in A:
  if a  <= med[0]:
    print(med[1])
  else:
    print(med[0])

Solution (Python):

import sys
input = sys.stdin.readline









N = int(input())
X = list(map(int,input().split()))
 
l  = sorted(X)[N//2-1]
r = sorted(X)[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()))

sort_x = sorted(x)

for i in range(n):
    if x[i]<=sort_x[n//2-1]:
        print(sort_x[n//2])
    else:
        print(sort_x[n//2-1])

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,cos,radians,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
u=sorted(lis)
medl=u[n//2-1]
medu=u[n//2]
for i in range(n):
    if lis[i]>=medu:
        ans=medl
        print(ans)
    elif lis[i]<=medl:
        ans=medu
        print(ans)

Solution (Python):
def main():
    N = int(input())
    assert N % 2 == 0
    X = list(map(int, input().split(' ')))
    Y = X.copy()
    Y.sort()
    left, right = Y[N//2-1], Y[N//2]
    for x in X:
        if x <= left:
            print(right)
        else:
            print(left)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
x_sorted = sorted(x)

cs = x_sorted[n // 2 - 1]
cb = x_sorted[n // 2]

for i, v in enumerate(x):
    if v <= cs:
        print(cb)
    else:
        print(cs)

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

Solution (Python):
n = int(input())
xx = list(map(int, input().split()))
x=sorted(xx)

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

Solution (Python):
def main():
    n = int(input())
    x = list(map(int,input().split()))
    s = sorted(x)
    m1 = s[n//2-1]
    m2 = s[n//2]

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

if __name__ == '__main__':
    main()

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

sort_x = sorted(x)

b1 = sort_x[n//2]
b2 = sort_x[n//2-1]

for i in range(n):
    if x[i]>=b1:
        print(b2)
    else:
        print(b1)

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

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

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

for i in s:
    if i <= a:
        print(b)
    else:
        print(a)

Solution (Python):
import collections
import numpy as np
import sys
import copy
N=int(input())

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

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

xs=sorted(x)
xm1 = xs[n//2-1]
xp1 = xs[n//2]
for i in x:
    if i <= xm1:
        print(xp1)
    else:
        print(xm1)

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

lst = sorted(x)
small_med = lst[n // 2 - 1]
big_med = lst[n // 2]

for num in x:
    if num > small_med:
        print(small_med)
    else:
        print(big_med)

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
X = iil()
r = sorted(X)
smed = r[n//2-1]
lmed = r[n//2]

for i in X:
    if i <= smed:
        print(lmed)
    else:
        print(smed)

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

Y = sorted(X)
Y1 = Y[N//2]
Y2 = Y[N//2 - 1]

for x in X:
    if x < Y1:
        print(Y1)
    else:
        print(Y2)

Solution (Python):
import numpy as np

N = int(input())
X = np.array(list(map(int, input().split())))
s = np.sort(X)
m1 = s[N//2-1]
m2 = s[N//2]
for x in X:
    if x <= m1:
        print(m2)
    else:
        print(m1)

Solution (Python):
def resolve():
	n = int(input())
	seq = list(map(int, input().split()))
	s_seq = sorted(seq)
	med = s_seq[(n+1)//2]
	for i in range(n):
		if seq[i] >= med:
			print(s_seq[(n+1)//2-1])
		else:
			print(med)
resolve()

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
sorted_x = sorted(x)
k = (n - 1) // 2
mid = sorted_x[k]
for i in x:
    print(sorted_x[k]) if i > mid else print(sorted_x[k + 1])

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

x_s = sorted(x)

lst = [x_s[(n-1)//2], x_s[n//2]]

for i in x:
    print(lst[0] if i >= lst[1] else lst[1])

Solution (Python):
N = int(input())
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number <= med_low:
        print(med_high)
    else:
        print(med_low)

Solution (Python):
N = int(input())
numbers_r = tuple(map(int, input().split(' ')))
numbers_s = sorted(numbers_r)

med_high = numbers_s[N // 2]
med_low = numbers_s[N // 2 - 1]

for number in numbers_r:
    if number == med_low:
        print(med_high)
    elif number == med_high:
        print(med_low)
    elif number < med_low:
        print(med_high)
    elif number > med_high:
        print(med_low)

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

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

Solution (Python):

from copy import deepcopy
n = int(input())
nums = [int(i) for i in input().split()]
c = deepcopy(nums)
c.sort()
left = c[n // 2 - 1]
right = c[n // 2]

for num in nums:
    if num <= left:
        print(right)
    else:
        print(left)

Solution (Python):
n = int(input())
x = [int(x) for x in input().split()]
nums = []

for i in range(n):
    nums.append([x[i], i])

nums.sort()

for i in range(n):
    nums[i].append(i)
right = nums[n // 2][0]
left = nums[n // 2 - 1][0]
nums.sort(key=lambda x: x[1])

for i in range(n):
    if nums[i][2] < n // 2:
        print(right)
    else:
        print(left)

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

x_ = sorted(X)
m0 = x_[N // 2 - 1]
m1 = x_[N // 2]

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

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

XX = sorted(X)
before = XX[N//2 -1]
after = XX[N//2]

for i in X:
    if i <= before:
        print(after)
    else:
        print(before)

Solution (Python):
import numpy as np

N = int(input())
X = list(map(int, input().split()))
Xs = sorted(X)
c1 = np.median(Xs[1:]).astype(int)
c2 = np.median(Xs[:-1]).astype(int)

for i in range(N):
    if X[i] < c1:
        print(c1)
    else:
        print(c2)

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

for i in X:
    if i <= a:
        print(b)
    else:
        print(a)

Solution (Python):
import sys
import copy
import numpy as np
n = int(input())
x = np.array(list(map(int, sys.stdin.readline().split())))
y = sorted(x)
for i in x:
    if y[n//2] > i:
        print(y[n//2])
    else:
        print(y[n//2-1])

Solution (Python):
import sys
import copy
n = int(input())
x = list(map(int, sys.stdin.readline().split()))
y = sorted(x)
for i in x:
    if y[n//2] > i:
        print(y[n//2])
    else:
        print(y[n//2-1])

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

sX = sorted(X)
small_median = sX[N//2-1]
large_median = sX[N//2]

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

Solution (Python):
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()))
memo = sorted(x)
dx = memo[n // 2]
for xx in x:
    print(memo[n // 2 - 1] if dx <= xx else dx)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
x_ = sorted(x)
c = x_[n//2 - 1]
c_ = x_[n//2]

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

Solution (Python):
n = int(input())
X = [int(_) for _ in input().split()]
med0 = sorted(X)[int(n/2)]
med1 = sorted(X)[int(n/2-1)]
for i in X:
  if i<med0:
    print(med0)
  else:
    print(med1)

Solution (Python):
n = int(input())
X = [int(_) for _ in input().split()]
med0 = sorted(X)[int(n/2)]
med1 = sorted(X)[int(n/2-1)]
for i in X:
  if i<med0:
    print(med0)
  else:
    print(med1)

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

half = N // 2

Y_n21 = half
Y_n20 = half - 1

for x in X:
    if x < Y[Y_n21]:
        print(Y[Y_n21])
    else:
        print(Y[Y_n20])

Solution (Python):

"""
Created on Mon May 11 16:14:32 2020

@author: shinba
"""


n = int(input())

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

A = sorted(X)

a = A[n//2-1]
b = A[n//2]
med = (a+b)/2

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

Solution (Python):
import copy
N = int(input())
numbers = [int(i) for i in input().split()]
copy_num = sorted(copy.deepcopy(numbers))

mid = N // 2
mid_num = copy_num[mid]

for i in range(N):
    if numbers[i] >= mid_num:
        print(copy_num[mid-1])
    else :
        print(mid_num)

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

xs = sorted(X)
median1 = xs[N//2-1]
median2 = xs[N//2]

for i in range(N):
    if X[i] == median1:
        print(median2)
    elif X[i] == median2:
        print(median1)
    elif X[i] < median1:
        print(median2)
    elif X[i] > median2:
        print(median1)

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

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

Solution (Python):

import sys


def solve_iter(N: int, X: "List[int]"):
    Y = sorted(X)
    m = sum(Y[N//2-1:N//2+1]) / 2
    for x in X:
        if x < m:
            yield Y[N//2]
        else:
            yield Y[N//2-1]


def solve(N: int, X: "List[int]"):
    if N == 2:
        return X[::-1]
    return list(solve_iter(N, X))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    X = [int(next(tokens)) for _ in range(N)]  
    print(*solve(N, X), sep='\n')

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    
    main()

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

Solution (Python):
import sys

input = sys.stdin.readline


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

    A, B = sorted(X)[N // 2 - 1: N // 2 + 1]
    ans = [B if x <= A else A for x in X]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


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

    A, B = sorted(X)[N // 2 - 1: N // 2 + 1]
    for x in X:
        if x <= A:
            print(B)
        else:
            print(A)


if __name__ == "__main__":
    main()

Solution (Python):
import sys

input = sys.stdin.readline


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

    Y = sorted(X)
    A, B = Y[N // 2 - 1: N // 2 + 1]
    for x in X:
        if x <= A:
            print(B)
        else:
            print(A)


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = [int(x) for x in input().split()]
x = sorted(a)
m1 = x[n // 2]
m2 = x[n // 2 - 1]
for i in range(n):
    if a[i] < m1: print(m1)
    else: print(m2)

Solution (Python):
def main():
    n, *x = map(int, open(0).read().split())
    y = sorted(x)
    a, b = y[n // 2 - 1], y[n // 2]
    ans = ""
    f = lambda i: str(b) if i <= a else str(a)
    *c, = map(f, x)
    ans = '\n'.join(c)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *x = map(int, open(0).read().split())
    y = sorted(x)
    a, b = y[n // 2 - 1], y[n // 2]
    ans = ""
    for i in x:
        if i <= a:
            ans += str(b) + "\n"
        else:
            ans += str(a) + "\n"

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, *x = map(int, open(0).read().split())
    y = sorted(x)
    a, b = y[n // 2 - 1], y[n // 2]
    d = dict()
    for i, j in enumerate(y, 1):
        if i <= n // 2:
            d[j] = b
        else:
            d[j] = a

    for i in x:
        print(d[i])


if __name__ == '__main__':
    main()

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    sort_X = sorted(X)
    if N%2==0:
        med_l = sort_X[N//2-1]
        med_r = sort_X[N//2]
        for i in range(N):
            if X[i]<=med_l:
                print(med_r)
            else:
                print(med_l)
    else:
        l = sort_X[N//2-1]
        m = sort_X[N//2]
        r = sort_X[N//2+1]
        for i in range(N):
            if X[i]<=l:
                print((m+r)/2)
            elif X[i]==m:
                print((l+r)/2)
            else:
                print((l+m)/2)


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
nums = list(map(int, input().split()))
sorted_nums = sorted(nums)
center = sorted_nums[n // 2 - 1]
for num in nums:
    if num <= center:
        print(sorted_nums[n // 2])
    else:
        print(center)

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

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

check = li.copy()
check.sort()
low = check[n//2 -1]
high = check[n//2]

for i in li:
    if i <= low:
        print(high)
    else:
        print(low)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
sx = sorted(x, reverse=True)
med1, med2 = sx[n//2 - 1], sx[n//2]
for xi in x:
    print(med1 if xi <= (med1 + med2) / 2 else med2)

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

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

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

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

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

sort_x = sorted(x)
l = sort_x[n//2 - 1]
r = sort_x[n//2]

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

Solution (Python):
N,*X = map(int,open(0).read().split())
chu = N//2 - 1
nums = sorted(X,reverse=True)
num, num_right = nums[chu], nums[chu + 1]
for x in X:
    print(num if x < num else num_right)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
xx=sorted(x)

for i in x:
  if i<xx[n//2]:
    print(xx[n//2])
  else:
    print(xx[n//2-1])

Solution (Python):
import sys
import bisect
input = sys.stdin.readline
 
 
def readstr():
    return input().strip()
 
 
def readint():
    return int(input())
 
 
def readnums():
    return map(int, input().split())
 
 
def readstrs():
    return input().split()
 
 
def main():
    N = readint()
    X = list(readnums())
    xs = sorted(X)
    for i in X:
        d = bisect.bisect_left(xs, i)
        if d >= N // 2:
            print(xs[N // 2 - 1])
        else:
            print(xs[N // 2])
 
 
if __name__ == "__main__":
    main()