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 sys
import copy


def solve(N: int, X: "List[int]"):
    XS =  copy.deepcopy(X)
    XS.sort()

    mi = (len(XS)+1)//2

    for x in X:
        if x < XS[mi]:
            print(XS[mi])
        else:
            print(XS[max(mi-1,0)])

    return



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

n = int(input())
num_list = [ int(v) for v in input().split() ]
num_list2 = sorted(num_list)



a, b = num_list2[n//2-1], num_list2[n//2]

if a == b:
	for i in range(n):
		print(a)
else:
	for i in num_list:
		if i < b:
			print(b)
		else:
			print(a)

Solution (Python):
N = int(raw_input())
X = map(int, raw_input().split())
indexX = []
for i in range(0, N):
	indexX.append([i, X[i]])
indexX.sort(key=lambda val:val[1])
medlist = []
for i in range(0, N):
	if i < N/2: medlist.append([indexX[i][0], indexX[N/2][1]])
	else: medlist.append([indexX[i][0], indexX[N/2-1][1]])
medlist.sort(key=lambda val:val[0])
for i in range(0, N):
	print medlist[i][1]

Solution (Python):

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

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

high,low = Xs[N//2], Xs[N//2 - 1]

if high == low:
    for i in range(N):    print(high)
else:
    for i in range(N):
        if X[i] >= high:    print(low)
        else:   print(high)

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

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

Solution (Python):
N, *X = map(int, open(0).read().split())
mid_l = sorted(X)[(N + 1) // 2 - 1]
mid_r = sorted(X)[(N + 1) // 2]
print(*[mid_l if v > mid_l else mid_r for v in X], sep='\n')

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

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

a = sorted(lst)
center_m = a[N//2 - 1]
center_p = a[N//2]



for i in lst:
    if i <= center_m:
        print (center_p)
    else:
        print (center_m)

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,*x=map(int,open(0).read().split())
y=sorted(x)
a,b=y[n//2],y[n//2-1]
for i in x:print(a*(i<=b)or b)

Solution (Python):

import sys


def solve(N: int, X: "List[int]"):
    x = sorted(X)
    l = x[N // 2 - 1]
    r = x[N // 2]
    for a in X:
        if a <= l:
            print(r)
        else:
            print(l)
    return


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

Solution (Python):
from copy import deepcopy
N=int(input())
a=list(map(int,input().split()))
b=deepcopy(a)
b.sort()
B1=b[N//2-1]
B2=b[N//2]
for i in a:
    if i<=B1:
        print(B2)
    else:
        print(B1)

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
sl=sorted(l)
def bin_srch(x):
	
	low=0
	high=n-1
	mid=n//2
	while sl[mid]!=x:
		if sl[mid]>x:
			high=mid-1
		else:
			low=mid+1
		mid=(low+high)//2
	return mid
m1,m2=sl[n//2-1],sl[n//2]
for i in l:
	pos=bin_srch(i)
	print(m1 if pos>=n//2 else m2)

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

sorted_x = sorted(X)
low_mid = sorted_x[N//2-1]
high_mid = sorted_x[N//2]

for x in X:
    if x < high_mid:
        print(high_mid)
    else:
        print(low_mid)

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)





def main():
    n = intin()
    xlist = intina()

    xxlist = sorted(xlist)
    lxx = len(xxlist)
    c1 = xxlist[lxx//2-1]
    c2 = xxlist[lxx//2]

    for x in xlist:
        if x <= c1:
            print(c2)
        else:
            print(c1)


if __name__ == '__main__':
    main()

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

for i in X:
    if i <= medi_candi[0]:
        print(medi_candi[1])
    elif i >= medi_candi[1]:
        print(medi_candi[0])

Solution (Python):

def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
X=IL()
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())
a = list(map(int, input().split()))
med_l, med_r = sorted(a)[n // 2 - 1: n // 2 + 1]
for i in a:
    if i <= med_l:
        print(med_r)
    else:
        print(med_l)

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *


readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
p = readl()
pp = []
for i in range(n):
    pp.append((p[i], i))
t = n // 2
pp.sort()
q = defaultdict(int)
for i in range(n):
    if t > i:
        q[pp[i][1]] = pp[t][0]
    else:
        q[pp[i][1]] = pp[t - 1][0]
for i in range(n):
    print(q[i])

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    G()

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

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
Y = X.copy()
Y.sort()
y1 = Y[N//2-1]
y2 = Y[N//2]

for i in X:
  if i <= y1:
    print(y2)
  else:
    print(y1)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
x_sort = sorted(x)
def median(L):
    
    n = len(L)
    m = int(n/2)
    if n % 2 == 0:
        return (L[m - 1] + L[m]) / 2
    else:
        return L[(n - 1) // 2]
x_median = median(x_sort)
l = median(x_sort[:-1])
r = median(x_sort[1:])
for i in range(n):
    if x[i] > x_median:
        print(l)
    else:
        print(r)

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
def median(L):
    L = sorted(L)
    n = len(L)
    m = int(n/2)
    if n % 2 == 0:
        return (L[m - 1] + L[m]) / 2
    else:
        return L[(n - 1) // 2]
x_median = median(x)
l = median(sorted(x)[:-1])
r = median(sorted(x)[1:])
for i in range(n):
    if x[i] > x_median:
        print(l)
    else:
        print(r)

Solution (Python):
n=int(input())
x_list=[int(i) for i in input().split()]
x_sorted=sorted(x_list)
left=x_sorted[n//2-1]
right=x_sorted[n//2]

for i in x_list:
    if i<=left:
        print(right)
    elif right<=i:
        print(left)

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

c = N // 2
x = sorted(X)
for v in X:
	if v < x[c]:
		print(x[c])
	else:
		print(x[c - 1])

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

x_sorted = sorted([[i, X[i]] for i in range(N)], key=lambda x: x[1])
mid = (x_sorted[N//2-1][1] + x_sorted[N//2][1]) / 2
for i in range(N):
    if X[i] >= mid:
        print(x_sorted[N//2-1][1])
    else:
        print(x_sorted[N//2][1])

Solution (Python):
from bisect import bisect_left

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

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

Solution (Python):

def main():
    num = int(input())
    data = list(map(int, input().split()))
    data_kari = data.copy()
    data_kari.sort()
    
    min_chuou = data_kari[(num // 2) - 1]
    max_chuou = data_kari[num // 2]

    

    

    for i in range(num):
        if data[i] <= min_chuou:
            print(max_chuou)
        elif data[i] >= max_chuou:
            print(min_chuou)






if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
 
N = int(stdin.readline().rstrip())
 
A = [int(x) for x in stdin.readline().rstrip().split()]

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    x = f()

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

solve()

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

A = sorted(X)

m_r = A[N//2]
m_l = A[N//2-1]

for i in range(N):
    if X[i] >= m_r:
        print(m_l)
    else:
        print(m_r)

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

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

import numpy as np

xidx = np.argsort(X)
xidx = sorted(range(len(xidx)),key = lambda k:xidx[k])
Y = X
Y.sort()
Med1 = Y[N//2]
Med2 = Y[(N-2)//2]
for i in xidx:
    
    if i < N//2:
        print(Med1)
    else:
        print(Med2)

Solution (Python):
from copy import deepcopy

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

Y = X.copy()
Y.sort()

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

Solution (Python):
import itertools
import copy
N = int(input())
Xs = list(map(int,input().split(" ")))
XsOrigin = copy.deepcopy(Xs)
Xs.sort()
l = int(len(Xs)/2)
left = Xs[l-1]
right =Xs[l]
for i in XsOrigin:
    if i <=left:
        print(right)
    else:
        print(left)

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

sorted_X = sorted(X)
left, right = sorted_X[N // 2 - 1], sorted_X[N // 2]

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

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

sorted_X = sorted(X)
left = sorted_X[N // 2 - 1]
right = sorted_X[N // 2]

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

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

import numpy as np
b = np.argsort(a)
idx = np.argsort(b)
for i in range(n):
    if idx[i] < n / 2:
        print(a[b[int(n / 2)]])
    else:
        print(a[b[int(n / 2) - 1]])

Solution (Python):
N = int(input())
x_list = list(map(int,input().split()))
sorted_list = sorted(x_list)
median_idx = N//2 -1
for x in x_list:
    if x>sorted_list[median_idx]:
        print(sorted_list[median_idx])
    else:
        print(sorted_list[median_idx+1])

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

L = sorted(X)
MS, ML = L[(N//2)-1], L[(N//2)]

if MS == ML:
    for _ in range(N):
        print(MS)
else:
    for i in range(N):
        if X[i] >= ML:
            print(MS)
        else:
            print(ML)

Solution (Python):
N = int(input())
xs = list(map(int, input().split()))
xs2 = sorted(xs)
M1 = xs2[len(xs)//2]
M2 = xs2[len(xs)//2 -1]
for x in xs:
    if x >= M1:
        print(M2)
    else:
        print(M1)

Solution (Python):


def read_input():
    n = int(input())
    xlist = list(map(int, input().split()))
    return n, xlist


def get_median(s, ignore):
    l = len(s)
    if ignore < l/2:
        return s[int((l+1)/2)]
    else:
        return s[int((l-1)/2)]

def submit():
    n, xlist = read_input()

    xlist = [(x, i) for i, x in enumerate(xlist)]
    xlist.sort(key=lambda x: x[0])

    pos_dic = {}
    for i, x in enumerate(xlist):
        pos_dic[x[1]] = i

    for i in range(n):
        target = pos_dic[i]
        print(get_median(xlist, target)[0])




if __name__ == '__main__':
    submit()

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
X0 = X[::]
X.sort()
num = int(N / 2 - 1)  
ans0, ans1 = X[num], X[num + 1]
for i in range(N):
    if X0[i] > ans0:
        print(ans0)
    else:
        print(ans1)

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

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

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

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

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

Solution (Python):
N = int(input())
X = list(map(int,input().split(' ')))
Y = []
for i,j in enumerate(X):
  Y.append((i,j))
Z = sorted(Y,key=lambda x:x[1])
First_half = Z[int(N/2-1)][1]
Last_half = Z[int(N/2)][1]

for i,j in enumerate(X):
  if j <= First_half:
    print(Last_half)
  else:
    print(First_half)

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

Xs = list(map(int,input().split()))
sort_xs = sorted(Xs)
l = sort_xs[N // 2 - 1]
r = sort_xs[N // 2]

for i in range(N):
    print(r if Xs[i] <= l else l)

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

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

m1 = sx[len(sx) // 2 - 1]
m2 = sx[len(sx) // 2]

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

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y = x.copy()
y.sort()
y_e = y[n//2]
y_o = y[n//2 - 1]
for xx in x:
    if xx >= y_e:
        print(y_o)
    else:
        print(y_e)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = []
for i in range(N):
  Y.append(X[i])
Y.sort()
m = (Y[N//2-1] + Y[N//2]) / 2

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

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):
n = int(input())
a = list(map(int,input().split()))
b = tuple(a)
a.sort()
A1 = a[n//2-1]
A2 = a[n//2]
med = (A1+A2)/2
for i in range(n):
    if b[i] <= med:
        print(A2)
    else:
        print(A1)

Solution (Python):
def main():
	N = int(input())
	X = list(map(int, input().split()))
	x = list(X)
	x.sort()
	mid = x[N//2]
	if N % 2 == 1:
		mid = (x[N//2]+x[N//2 + 1])/2
	for i in range(N):
		if X[i] < mid:
			if N % 2 == 0:
				print(x[N//2])
			else:
				print((x[N//2]+x[(N//2)+1])/2)
		elif X[i] == mid and N % 2 == 1:
			print((x[(N//2) - 1] + x[(N//2) + 1])/2)
		else:
			if N % 2 == 0:
				print(x[(N//2)-1])
			else:
				print((x[N//2]+x[(N//2)-1])/2)


if __name__ == '__main__':
    main()

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

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

ans1 = a[int(n/2-1)]
ans2 = a[int(n/2)]

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

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

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

y = sorted(x)

median = int((x[int(n/2 - 1)] + x[int(n/2)]) / 2)

a = y[int(n/2)]
b = y[int(n/2 - 1)]

for i in range(n):

    if x[i] < a:
        print(a)
    else:
        print(b)

Solution (Python):
import statistics as sta

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

sort_X = sorted(X)
a = sta.median_low(sort_X)
b = sta.median_high(sort_X)

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()))
ac=a[:]
ac.sort()
al=ac[n//2-1]
ar=ac[n//2]
for i in a:
    if i<=al:print(ar)
    else:print(al)

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


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

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

else:
  piv = n//2

  b = x_sorted[piv]
  a = x_sorted[piv-1]
  for i in range(n):

    if x[i] < x_sorted[piv]:
      print(b)
    else:
      print(a)

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
x = []
for i in range(N):
    x.append([X[i], i])
x.sort()
B = []

for i in range(N):
    if i < N // 2:
        B.append([x[N//2][0], x[i][1]])
    else:
        B.append([x[(N-1)//2][0], x[i][1]])

B.sort(key=lambda x: x[1])

for i in range(N):
    print(B[i][0])

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

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

X2 = sorted(X)

small = X2[N//2 - 1]
big = X2[N//2]

for x in X:
    if x <= small:
        print(big)
    else:
        print(small)

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

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

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

r=N//2
l=r-1

Xs=sorted(X)
m=(Xs[r]+Xs[l])/2

for x in X:
	print(Xs[l if x > m else r])

Solution (Python):
N = int(input())
XX = [int(i) for i in input().split()]
X = sorted(XX)
ans = {}
value = N//2 - 1
for i in range(N):
    if i <= value:
        ans[X[i]] = X[value+1]
    else:
        ans[X[i]] = X[value]

for i in XX:
    print(ans[i])

Solution (Python):
N = int(input())
XX = [int(i) for i in input().split()]
X = XX.copy()
X.sort()
ans = {}
value = N//2 - 1
for i in range(N):
    if i <= value:
        ans[X[i]] = X[value+1]
    else:
        ans[X[i]] = X[value]

for i in XX:
    print(ans[i])

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

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 range(n):
  if x[i] <= left:
    print(right)
  else:
    print(left)

Solution (Python):
import sys


fin = sys.stdin.readline
N = int(fin())
X_list = [int(elem) for elem in fin().split()]
sorted_indices = sorted(range(N), key=lambda i: X_list[i])
org_pos_to_sorted = {org_p: sorted_p for sorted_p, org_p in enumerate(sorted_indices)}

left_mid = X_list[sorted_indices[N // 2 - 1]]
right_mid = X_list[sorted_indices[N // 2]]
result = []
for i in range(N):
    sorted_pos = org_pos_to_sorted[i]
    if sorted_pos >= N // 2:
        result.append(left_mid)
    else:
        result.append(right_mid)

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

Solution (Python):
import sys


fin = sys.stdin.readline
N = int(fin())
X_list = [int(elem) for elem in fin().split()]
sorted_indices = sorted(range(N), key=lambda i: X_list[i])
org_pos_to_sorted = {org_p: sorted_p for sorted_p, org_p in enumerate(sorted_indices)}

left_mid = X_list[sorted_indices[N // 2 - 1]]
right_mid = X_list[sorted_indices[N // 2]]
result = []
for i in range(N):
    sorted_pos = org_pos_to_sorted[i]
    if sorted_pos >= N // 2:
        result.append(left_mid)
    else:
        result.append(right_mid)

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

Solution (Python):
import bisect

def func(s):
    return []

N=int(input())
a=list(map(int,input().split()))
b=sorted(a)
p=b[N//2-1]
q=b[N//2]

for i in range(N):
    print(q if a[i]<q else p )

Solution (Python):
def calculate_median(lst):
    lst.sort()
    median_right = lst[int(len(lst)/2)]
    median_left = lst[int(len(lst)/2)-1]
    return median_right, median_left


N = int(input())
X = list(map(int, input().split()))
X_copy = X.copy()
median_right, median_left = calculate_median(X)
for i in range(N):
    if X_copy[i] >= median_right:
        print(median_left)
    elif X_copy[i] < median_right:
        print(median_right)

Solution (Python):

import sys
import bisect


def solve(N: int, X: "List[int]"):
    S = sorted(X)
    later = S[N//2-1]
    earlier = S[N//2]
    for i in range(N):
        cur = X[i]
        index = bisect.bisect_left(S, cur)
        if index >= N//2:
            print(later)
        else:
            print(earlier)
    return



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):
N = int(input())
X = tuple(map(int, input().split()))

Y = list(X)
Y.sort()

greater_median = Y[N//2]
smaller_median = Y[N//2-1]
average = (greater_median + smaller_median)/2

for x in X:
    if x <= average:
        print(greater_median)
    else:
        print(smaller_median)

Solution (Python):
import math
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
x = LI()
sort_x = sorted(x)
left = sort_x[math.floor(n/2-0.1)]
right= sort_x[math.floor(n/2+0.1)]
for num in x:
    if num < (left+right)/2:
        print(right)
    else:
        print(left)

Solution (Python):
n = int(input())
s = [ int(i) for i in input().split() ]
t = sorted(s)
med = (t[n//2-1] + t[n//2])/2

for i in s:
    if i < med:
        print(t[n//2])
    else:
        print(t[n//2-1])

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

Temp.sort()
temp = int((Temp[int(n/2)-1]+Temp[int(n/2)])/2)
for x in X:
    if x == Temp[int(n/2)-1]:
        print(Temp[int(n/2)])
    elif x == Temp[int(n/2)]:
        print(Temp[int(n/2)-1])
    elif x < temp:
        print(Temp[int(n/2)])
    else:
        print(Temp[int(n/2)-1])

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
x = [int(_) for _ in stdin.readline().rstrip().split()]
xc = x.copy()
xc.sort()
ans = [xc[(len(xc)-1)//2], xc[len(xc)//2]]
for i in range(n):
    if x[i] < ans[1]:
        print(ans[1])
    elif x[i] >= ans[1]:
        print(ans[0])

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

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

X2 = sorted(X)
m1 = X2[(N//2)-1]
m2 = X2[N//2]

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

Solution (Python):
import copy

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

X2 = copy.deepcopy(X)
X.sort()

l = X[N // 2 - 1]
r = X[N // 2]

for i in X2:
  if i > l:
    print(l)
  else:
    print(r)

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

sorted_lst = sorted(lst)
median_big = sorted_lst[N//2]
median_small = sorted_lst[(N//2)-1]
for i in lst:
    print(median_big) if i < median_big else print(median_small)

Solution (Python):
N=int(input())
X=[int(x) for x in input().split()]
Y=[[i,X[i],0] for i in range(N)]
Y.sort(key=lambda x: x[1])
B=Y[N//2][1]
for i in range(N):
  if Y[i][1]==B:
    B=Y[N//2-1][1]
  Y[i][2]=B
Y.sort(key=lambda x : x[0])
for i in range(N):
  print(Y[i][2])

Solution (Python):



from collections import defaultdict

N = int(input())
X = list(map(int, input().rstrip().split(' ')))
sorted_X = sorted(X)

x2med = defaultdict(lambda: -1)

med_index = (len(X) - 1) // 2
for i, x in enumerate(sorted_X):
    if i <= med_index:
        x2med[x] = sorted_X[med_index + 1]
    else:
        x2med[x] = sorted_X[med_index]
        
for i, x in enumerate(X):
    print(x2med[x])

Solution (Python):
import statistics


n = int(input())
x = list(map(int, input().split()))
m_low = statistics.median_low(x)
m_high = statistics.median_high(x)
for i in range(n):
    if x[i] > m_low:
        print(m_low)
    elif x[i] <= m_high:
        print(m_high)

Solution (Python):
from bisect import bisect_left

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

Solution (Python):
import copy
N = int(input())
L = list(map(int,input().split()))
C = copy.deepcopy(L)
C.sort()
P,Q = C[N//2-1],C[N//2]
for i in range(N):
  if L[i] <= P:
    print(Q)
  else:
    print(P)

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

sXn = sorted(Xn)
m1 = sXn[N//2-1]
m2 = sXn[N//2]
m = (m1+m2) / 2

for X in Xn:
    print(m1 if X > m else m2)

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

l.sort()

m = (l[N//2 - 1] + l[N//2])/2

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

Solution (Python):
n=int(input())
l=list(map(int,input().split()))
sl=l[:]
sl.sort()
a=sl[n//2-1]
b=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()))
X0 = X.copy()
X.sort()

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