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())
X_list = list(map(int, input().split()))

X_list_min = sorted(X_list)

for i in range(N):
    if X_list_min[N//2-1] >= X_list[i]:
        print(X_list_min[N//2])
    else:
        print(X_list_min[N//2-1])

Solution (Python):
def main():
    N = int(input())
    B = [(b, i) for i, b in enumerate(map(int,input().split()))]
    B.sort()
    m2 = B[N//2][0]
    m1 = B[N//2-1][0]
    if m1 == m2:
        for i in range(N):
            print(m1)
        return

    ans = [0] * N
    for b, i in B:
        if b <= m1:
            ans[i] = m2
        else:
            ans[i] = m1
    print('\n'.join(map(str,ans)))
    


main()

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
newX = []
for i in range(N):
  newX.append((X[i],i))
newX.sort()
ans = [0]*N
f = N//2-1
l = N//2
for i in range(N):
  num, ind = newX[i]
  if i < l:
    ans[ind] = newX[l][0]
  else:
    ans[ind] = newX[f][0]
for j in ans:
  print(j)

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

Solution (Python):
N = int(input())
Xlist = list(map(int,input().split()))
Xcopy = Xlist.copy()
Xcopy.sort()
Xsm = Xcopy[N//2-1]
Xla = Xcopy[N//2]
if Xsm == Xla:
    for _ in range(len(Xlist)):
        print(Xsm)
else:
    for i in range(len(Xlist)):
        Tar = Xlist[i]
        if Tar <= Xsm:
            print(Xla)
        else:
            print(Xsm)

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

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return 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)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    X = LI()

    Y = sorted(X)
    n = (N + 1) // 2
    l = Y[n-1]
    r = Y[n]

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

if __name__ == '__main__':
    solve()

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

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

Solution (Python):
from copy import deepcopy
N = int(input())
X = [int(i) for i in input().split()]
x = deepcopy(X)
X.sort()
if N%2 == 0:
    for i in x:
        if i <= X[N//2 - 1]:
            print(X[N//2])
        else:
            print(X[N//2 - 1])
else:
    for i in x:
        if i < X[N//2]:
            print((X[N//2] + X[N//2 + 1])/2)
        elif i == X[N//2 -1]:
            print((X[N//2 - 1] + X[N//2 + 1])/2)
        else:
            print((X[N//2 - 1] + X[N//2])/2)

Solution (Python):
import statistics
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
a,b = statistics.median_low(Y),statistics.median_high(Y)
for i in X:
    Z = bisect_left(Y,i)
    if Z<N//2:
        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 x in X:
  if m == M:
    print(m)
  elif x <= m:
    print(M)
  else:
    print(m)

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

Solution (Python):
N = int(input())
lista = list(map(int, input().split()))
newlista = sorted(lista)

lowermedian = newlista[int(len(lista)/ 2- 1)]
highermedian = newlista[int(len(lista)/2)]

for i in range(N):
  if(lista[i] <= lowermedian):
    print(highermedian)
  else:
    print(lowermedian)

Solution (Python):
n, *lst = map(int, open(0).read().split())
a, b = sorted(lst)[n // 2 - 1:n // 2 + 1]
if a == b:
  print(*[a for _ in range(n)], sep='\n')
else:
  print(*[b if i <= a else a for i in lst], sep='\n')

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





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



t_sorted = sorted(t)
m = t_sorted[n//2-1]
m2 = t_sorted[n//2]
for i in range(n):
    if t[i] <= m:
        print(m2)
    else:
        print(m)

Solution (Python):
from statistics import median_high, median_low

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

a, b = median_low(l), median_high(l)
for i in l:
    if i <= a:
        print(b)
    else:
        print(a)

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())
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()))

x1 = sorted(x)
tmp1 = n // 2
tmp2 = (n // 2) - 1
val1 = x1[tmp1]
val2 = x1[tmp2]

for i in range(len(x)):
    if x[i] < val1:
        print(val1)
    else:
        print(val2)

Solution (Python):
from copy import copy
N = int(input())
X = list(map(int,input().split()))
sortX = copy(X)
sortX.sort(reverse = True)
median1 = sortX[N // 2 - 1]
median2 = sortX[N // 2]
for i in X:
  if i >= median1: print(median2)
  else: print(median1)

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

X_sort=sorted(X)

med_n=X_sort[N//2-1]
med_p=X_sort[N//2]

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

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):
N=int(input())
temp=list(map(int,input().split()))
temp_s=sorted(temp)
min_median=temp_s[N//2-1]
max_median=temp_s[N//2]
if max_median==min_median:
   for i in range(N):
      print(max_median)
   exit()
for i in temp:
   if i <= min_median:
      print(max_median)
   else:
      print(min_median)

Solution (Python):


N = int(input())
X = list(map(int, input().split()))
D = {}
for i in range(N):
    D[i] = X[i]

X = sorted(X)
ans = [X[N//2-1], X[N//2]]
A = {}

cnt = 0
for i, v in sorted(D.items(), key=lambda x:x[1]):
    if cnt < N // 2:
        A[i] = ans[1]
    else:
        A[i] = ans[0]
    cnt += 1

for i, v in sorted(A.items(), key=lambda x:x[0]):
    print(v)

Solution (Python):

import collections
import itertools as it
import math

 
n  = int(input())

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





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

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

Solution (Python):
import bisect
n = int(input())
X = tuple(map(int,input().split()))
Xs = list(X)
Xs.sort()
for x in X:
    a = bisect.bisect_left(Xs,x)
    if a >= n/2:
        print(Xs[int(n/2)-1])
    else:
        print(Xs[int(n/2)])

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
L = [0 for _ in range(N)]
for i in range(N):
  X[i] = X[i] * N + i
X.sort()
d = N // 2
for i in range(N):
  if i < d:
    L[X[i]%N] = X[d] // N
  else:
    L[X[i]%N] = X[d-1] // N
for i in range(N):
  print(L[i])

Solution (Python):
N=int(input())
X=list(map(int, input().split()))
sortX=sorted(X)
small=sortX[int(N/2)-1]
big=sortX[int(N/2)]
if small==big:
    for i in range(0,N):
        print(small)
    exit()

for i in range(0,N):
    if X[i]>small:
        print(small)
    else:
        print(big)

Solution (Python):
n = int(input())
x= list(map(int, input().split()))
sx=sorted(x)
center=sum(sx[n//2-1:n//2+1])/2
under=sx[n//2-1]
over=sx[n//2]
for i in x:
    if i>=center:
        print(under)
    else:
        print(over)

Solution (Python):



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


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


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
from bisect import bisect, bisect_left, bisect_right

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

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

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

y = []

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

y.sort()

ans = [-1 for i in range(n)]

for i in range(n // 2):
    ans[y[i][1]] = y[n // 2][0]

for i in range(n // 2, n):
    ans[y[i][1]] = y[n // 2 - 1][0]

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

Solution (Python):
n, *X = map(int, open(0).read().split())
Y = sorted(X)
m = (n-1) // 2

for x in X:
    med = Y[m]
    if med >= x:
        med = Y[m+1]
    print(med)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
l = sa[N // 2 - 1]
r = sa[N // 2]
for i in range(N):
  if a[i] <= l: print(r)
  else: print(l)

Solution (Python):
import os
import sys

import numpy as np

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

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



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

sorted = np.msort(X)
I = np.searchsorted(sorted, X)
if N % 2 == 1:
    ans = np.zeros(N, dtype=int)
    ans[I <= N // 2] = sorted[N // 2 + 1]
    ans[I > N // 2] = sorted[N // 2]
else:
    ans = np.zeros(N, dtype=int)
    ans[I < N // 2] = sorted[N // 2]
    ans[I >= N // 2] = sorted[N // 2 - 1]
print(*ans, sep='\n')

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    
    N = Scanner.int()
    A = Scanner.map_int()
    B = sorted(A)
    m1 = B[N // 2 - 1]
    m2 = B[N // 2]

    for i in range(N):
        if A[i] < m2:
            print(m2)
        else:
            print(m1)
    return


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
x = list(map(int, input().split( )))
x2 = [x[i] for i in range(n)]

x2.sort()

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

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

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

A = sorted(X)
f = N // 2 - 1
b = f + 1
C1 = A[f]
C2 = A[b]

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

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

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

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

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

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

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

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

Solution (Python):

import sys


def solve(N, X):
    Y = sorted(list(zip(X, range(N))))
    n = N // 2
    d = dict()
    for i in range(N):
        m = n - (i >= n)
        d[Y[i][1]] = Y[m][0]
    for k, v in (sorted(d.items(), key=lambda x: x[0])):
        print(v)


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)]  
    solve(N, X)

if __name__ == '__main__':
    main()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n = int(input())
    xx = list(map(int, input().split()))
    cxx = sorted(xx)
    m0 = cxx[n // 2 - 1]
    m1 = cxx[n // 2]
    for x in xx:
        if x <= m0:
            print(m1)
        else:
            print(m0)

main()

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 < m2:
            print(m2)
        else:
            print(m1)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007




n = I()
L = LI()
left = sorted(L)[n // 2 - 1]
right = sorted(L)[n // 2]
for i in range(n):
    if L[i] <= left:
        print(right)
    else:
        print(left)

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


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

x = X[:]
x.sort()
m1 = x[N//2 - 1]
m2 = x[N//2]

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
sorted_X = sorted(X)
median_index = N//2
ans1 = sorted_X[median_index]
ans2 = sorted_X[median_index-1]

for x in X:
  if ans1 > x:
    print(ans1)
  else:
    print(ans2)

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

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2 - 1])
        else:
            ret.append(sorted_x[n // 2])
for i in ret:
    print(i)

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 X:
    if l >= i:
        print(r)
    else:
        print(l)

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

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

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

X_sorted = sorted(X)
first_half_median = X_sorted[N // 2 - 1]
last_half_median = X_sorted[N // 2]

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

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
B.sort()
a = B[N//2-1]
b = B[N//2]

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

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
S = X[:]
S.sort()
C1 = S[(N//2)-1]
C2 = S[N//2]
for x in X:
    if x >= C2:
        print(C1)
    else:
        print(C2)

Solution (Python):
a = int(input())
b = list(map(int, input().split()))
e = b.copy()
b.sort()
c = b[a // 2 - 1]
d = b[a // 2]
for i in e:
    if i <= c:
        print(b[a // 2])
    else:
        print(b[a // 2 - 1])

Solution (Python):
def find(A):
    X=[(A[i],i) for i in range(len(A))]
    X=sorted(X)
    ans=[0]*len(X)
    p1=(len(A)-1)//2
    p2=len(A)//2
    
    for i in range(len(X)):
        a,b=X[i]
        if i<p2:
            ans[b]=X[p2][0]
        else:
            ans[b]=X[p1][0]
    return ans
input()
A=[str(x) for x in find(list(map(int,input().strip().split(" "))))]
print("\n".join(A))

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
Y = sorted(X)
left = Y[N//2 -1]
right = Y[N//2 ]
for x in X:
    if x<=left:
        print(right)
    else:print(left)

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

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

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

Solution (Python):

def main():
    n = int(input())
    x = tuple(map(int, input().rstrip().split()))
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    for i in x:
        print(h if i <= l else l)

if __name__ == "__main__":
    main()

Solution (Python):

def main():
    n = int(input())
    x = tuple(map(int, input().rstrip().split()))
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    for i in x:
        if i <= l:
            print(h)
        else:
            print(l)


if __name__ == "__main__":
    main()

Solution (Python):

def main():
    n = int(input())
    x = list(map(int, input().rstrip().split()))
    l, h = sorted(x)[n // 2 - 1 : n // 2 + 1]
    for i in x:
        if i <= l:
            print(h)
        else:
            print(l)


if __name__ == "__main__":
    main()

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

S = sorted(X)

med_left = S[N//2 - 1]
med_right = S[N//2]

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

Solution (Python):
N = int(input())
li = [ int(it) for it in input().split() ]
go = [ (li[i],i) for i in range(N)]
go.sort( key= lambda x:x[0])
po = [0]*N
for i in range(N):
  if (i < N//2):
    po[go[i][1]] = (go[N//2][0])
  else:
    po[go[i][1]] = (go[N//2-1][0])
for i in range(N):
  print ( po[i] )

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,*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())
X = list(map(int, input().split()))
P = []
for i in range(N):
    P.append((X[i], i))

P = sorted(P)
med = [P[N // 2 - 1][0], P[N // 2][0]]
ans = [0] * N
for i in range(N):
    if P[i][0] <= med[0]:
        ans[P[i][1]] = P[N // 2][0]
    else:
        ans[P[i][1]] = P[N // 2 - 1][0]

for i in ans:
    print(i)

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

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

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

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

SX = [[i, X[i]] for i in range(len(X))]
SX = sorted(SX, key=lambda x:x[1])

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

res = [0] * N
for i in range(len(SX)):
    if i < N // 2:
        res[SX[i][0]] = rm
    else:
        res[SX[i][0]] = lm


for r in res:
    print(r)

Solution (Python):
n = int(input())
xs = list(map(int, input().split()))
ds = sorted(xs)
m = n // 2 - 1

bs = [ds[m] if xs[i] > ds[m] else ds[m+1] for i in range(n)]

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

Solution (Python):
N = int(input())
x = list(map(int, input().split()))
x_s = sorted(x)
m_l, m_r = x_s[N // 2 - 1], x_s[N // 2]
d = dict()
for i, s in enumerate(x_s):
    if i < N // 2:
        d[s] = m_r
    else:
        d[s] = m_l
for i in x:
    print(d[i])

Solution (Python):
n,*a=map(int,open(0).read().split())
d=0
l=[]
a=sorted(enumerate(a),key=lambda x:x[1])
b=a[n//2][1]
c=a[n//2-1][1]
for(k,v)in a:
    d+=1
    if d<n//2+1:
        l.append((k,b))
    else:
        l.append((k,c))

for(k,v)in sorted(l,key=lambda x:x[0]):
    print(v)

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

Y = sorted(X)
a1 = Y[N//2 - 1]
a2 = Y[N//2]

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

Solution (Python):
from math import *

n = int(input())

a = [int(x) for x in input().split()]

a_sort = sorted(a)

median_right = a_sort[floor(len(a_sort) / 2)]
median_left = a_sort[floor(len(a_sort) / 2) - 1]

for i in range(len(a)):
	if a[i] > median_left:
		print(median_left)
	else:
		print(median_right)

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

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

b=sorted(a)

a1=b[(N-1)//2]
a2=b[(N-1)//2+1]

for i in a:
    if(i<=a1):
        print(a2)
    else:
        print(a1)

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

Solution (Python):
def solve(N, Xs):
    sorted_Xs = sorted(Xs)
    left = sorted_Xs[N // 2 - 1]
    right = sorted_Xs[N // 2]
    ans = []
    for x in Xs:
        if x <= left:
            ans.append(right)
        else:
            ans.append(left)
    return "\n".join(str(i) for i in ans)

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

Solution (Python):
N = input()
X = map(int, raw_input().split())
med = sorted(X)[N / 2 - 1:N / 2 + 1]
for v in X:
    if v <= med[0]:
        print med[1]
    else:
        print med[0]

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

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

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

Solution (Python):
def main():
    n = int(input())
    x = [int(i) for i in input().split()]
    newx = sorted(x)
    ans = dict()
    for i,xx in enumerate(newx):
        if i+1 <= n//2:
            ans[xx] = newx[n//2]
        else:
            ans[xx] = newx[n//2-1]
    for xx in x:
        print(ans[xx])

if __name__ == '__main__':
    main()

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

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

use = x[::]
use.sort()

l = use[n//2-1]
r = use[n//2]
for i in x:
    if i <= l:
        print(r)
    else:
        print(l)

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

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

sorted_a = sorted(a)

for i in range(N):
    if a[i] < sorted_a[int(N/2)]:
        print(sorted_a[int(N/2)])
    else:
        print(sorted_a[int(N/2)-1])

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

x=sorted(y)
xl=len(x)
for i in y:
    if i<(x[xl//2]):
        print(x[(xl//2)])
    else:
        print(x[(xl//2)-1])

Solution (Python):
import bisect

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

X2 = sorted(X)

for i in range(0, N):
    
    idx = bisect.bisect_left(X2, X[i])
    if idx < N // 2:
        print(X2[N // 2])
    else:
        print(X2[N // 2 - 1])

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

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

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

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

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):

n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
for a_i in a:
    if a_i <= b[n // 2 - 1]:
        c = b[n // 2]
    else:
        c = b[n // 2 - 1]
    print(c)

Solution (Python):

n = int(input())
x = [int(i) for i in input().split()]
xx = sorted(x)
mid = n//2-1

d = {}
for i in range(n):
    if i<=mid:
        d[xx[i]] = xx[mid+1]
    else:
        d[xx[i]] = xx[mid]

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

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):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
m = (y[n//2-1]+y[n//2])/2
for i in x:
    if i<m:
        print(y[n//2])
    else:
        print(y[n//2-1])

Solution (Python):
N = int(input())
X_list = list(map(int, input().split()))
median = N//2

med = sorted(X_list)[median-1:median+1]
for i in range(N):
    if X_list[i] < med[1]:
        print(med[1])
    else:
        print(med[0])

Solution (Python):
from bisect import *

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
X = reads()
sX = sorted(X)

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

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