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 itertools
import statistics


N = int(input())
X = list(map(int, input().split()))
sortedX = sorted(X)
mid_min = sortedX[N//2-1]
mid_max = sortedX[N//2]

for i in X:
    if i <= mid_min:
        print(mid_max)
    else:
        print(mid_min)

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

if m == n:
    for i in range(k):
        print(m)
        
else:
    for i in a:
        if i <= m:
            print(n)
        else:
            print(m)

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

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

Solution (Python):
import numpy as np
N = int(input())
X = np.array(input().split(), dtype=np.int64)
argsort = X.argsort()
argsort_argsort = argsort.argsort()
X_sorted = X[argsort]
m1, m2 = N // 2 - 1, N // 2
print("\n".join(str(X_sorted[m2]) if idx <= m1 else str(X_sorted[m1]) for idx in argsort_argsort))

Solution (Python):
import numpy as np
N = int(input())
X = np.array(input().split(), dtype=np.int64)
argsort = X.argsort()
argsort_argsort = argsort.argsort()
X_sorted = X[argsort]
m1, m2 = N // 2 - 1, N // 2
for idx in argsort_argsort:
    if idx <= m1:
        print(X_sorted[m2])
    else:
        print(X_sorted[m1])

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

indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: X[i])

for i in range(N):

    if X[i] <= X[sorted_indexes[int(N / 2)-1]]:
        print(X[sorted_indexes[int(N / 2)]])
    else:
        print(X[sorted_indexes[int(N / 2)-1]])

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

l,r=sorted_x[n//2],sorted_x[n//2+1]

for i in range(1,n+1):
    print(r if x[i]<=l else l)

Solution (Python):
n = int(input())
x = list(map(int,input().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()))
S=sorted(X)
l=S[int((N/2)-1)]
r=S[int(N/2)]
d=(l+r)/2
for i in range(N):
    if(X[i]>d):
        print(l)
    elif(X[i]<d):
        print(r)
    else:
        print(X[i])

Solution (Python):
n = int(input())
x = [int(_) for _ in input().split()]
xx = sorted(x)
mid_min = xx[n//2-1]
mid_max = xx[n//2]
for i in x:
    if i <= mid_min:
        print(mid_max)
    else:
        print(mid_min)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
x1=sorted(x)
mid=n//2

if n>2:
    for i in range(n):
        if x[i] < x1[mid]:print(x1[mid])
        else:print(x1[mid-1])
else:
    for i in range(n):
        x2=x.copy()
        x2.pop(i)
        print(x2[0])

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

Solution (Python):
import itertools
import math
import sys
from collections import Counter
from fractions import gcd
from functools import reduce

n = int(input())
x = list(map(int, input().split()))
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())
A=list(map(int,input().split()))
B=sorted(A)
hanbun=n//2
left_B=B[hanbun-1]
right_B=B[hanbun]
for a in A:
    if a <= left_B:
        print(right_B)
    else:
        print(left_B)

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

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

y_list = x_list.copy()
y_list.sort()

m1 = y_list[n//2-1]
m2 = y_list[n//2]

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

Solution (Python):
import copy

N=int(input())
X1=list(map(int,input().split()))
X=copy.deepcopy(X1)
X.sort()
ma=X[N//2-1]
mb=X[N//2]


for i in range(N):
    if X1[i]<=ma:
        print(mb)
    else:
        print(ma)

Solution (Python):
input()
x=list(map(int,input().split()))
z=sorted(x)[(len(x))//2-1:]
for c in x:print(z[c<=z[0]])

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter


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

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

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
index = []
for i, v in enumerate(x):
    index.append((i, v))
index.sort(key=lambda x: x[1])
ans = [0] * n
for i, w in enumerate(index):
    if i <= n//2 - 1:
        ans[w[0]] = index[n//2][1]
    else:
        ans[w[0]] = index[n//2 - 1][1]

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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
x1 = []
for i, xi in enumerate(x):
    x1.append([i, xi])

x_sort = sorted(x1, key=lambda x: x[1])
t = int(n / 2)
lxt = []
for i in range(n):
    if i < t:
        x[x_sort[i][0]] = x_sort[t][1]
    else:
        x[x_sort[i][0]] = x_sort[t - 1][1]

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

Solution (Python):

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

Solution (Python):
def main():
    N = int(input())
    numbers = list(map(int, input().split(" ")))
    sorted_numbers = sorted(numbers)
    medians = [sorted_numbers[N // 2], sorted_numbers[N // 2 - 1]]
    for number in numbers:
        if number <= medians[1]:
            print(medians[0])
        else:
            print(medians[1])


if __name__ == '__main__':
    main()

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

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

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
xsort = sorted(x)
l1 = xsort[n // 2 - 1]
l2 = xsort[n // 2]
for i in range(n):
    print(l1 if x[i] >= l2 else l2)

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

A_sort=sorted(A[:])
A_median_1=A_sort[N//2]
A_median_2=A_sort[N//2-1]

ans=0
for a in A:
    if a<A_median_1:
        ans=A_median_1
    else:
        ans=A_median_2
    print(ans)

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

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

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

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

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

x=list(map(int,input().split()))
b=copy.copy(x)
x.sort()
med=(x[n//2-1]+x[n//2])/2
for i in range(n):
    if b[i]<med:
        print(x[n//2])
    else:
        print(x[n//2-1])

Solution (Python):
n = int(input())
l = list(map(int,input().split()))
lsort = sorted(l)
l1 = lsort[n//2-1]
l2 = lsort[n//2]
for i in l:
    print(l1 if i>=l2 else l2)

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

Solution (Python):
N = int(input())
Xlist = list(map(int, input().split()))
X_sort = sorted(Xlist)
left_med = X_sort[N//2-1]
right_med = X_sort[N//2]
for i in range(N):
    if Xlist[i] <= left_med:
        print(right_med)
    else:
        print(left_med)

Solution (Python):
import copy

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

left = X_copy[len(X)//2-1]
right = X_copy[len(X)//2]



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

Solution (Python):
n = int(input())
x = list(map(int, input().split()))
val = sorted(x)
first = 0
second = 0
ival = 0
for i in range(n):
    if i == n//2:
        first = val[i-1]
        second = val[i]
        ival = i-1



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

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

Solution (Python):
N, *X = map(int, open(0).read().split())
Y = [(i, x) for (i, x) in enumerate(X)]
Y = sorted(Y, key=lambda x:x[1])
ans = []
for i in range(N//2):
  ans.append((Y[i][0], Y[N//2][1]))
for i in range(N//2, N):
  ans.append((Y[i][0], Y[N//2-1][1]))
ans = sorted(ans)
for a in ans:
  print(a[1])

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


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

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

B = []
l = N // 2
r = (N//2)+1
Y = copy.copy(X)
Y.sort()
chu = Y[N//2-1]
tyu = Y[N//2]

for i in range(N):
    if X[i]<=chu:
        B.append(tyu)
    else:
        B.append(chu)

for i in range(len(B)):
    print(B[i])

Solution (Python):

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

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

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

Median_1_i=N//2-1
Median_2_i=N//2

X_=X[:]
X_.sort(reverse=True)
Median_1=X_[Median_1_i]
Median_2=X_[Median_2_i]

for x in X:
    if x<Median_1:
        print(Median_1)
    else:
        print(Median_2)

Solution (Python):
N = int(input())
lst = [int(x) for x in input().split()]
tmp = sorted(lst)
a = tmp[(N // 2 - 1)]
b = tmp[N // 2]

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

Solution (Python):
import copy

a = int(input())
l = list(map(int, input().split()))
l2 = sorted(copy.deepcopy(l))



for i in l:
  if i < l2[a//2]:
    print(l2[a//2])
  else:
    print(l2[a//2 - 1])

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
xx=[]
for i in range(n):
    xx.append([x[i],i,""])
xx2=sorted(xx)
for i in range(n):
    if i<=(n//2-1):
        xx2[i][2]="l"
    else:
        xx2[i][2]="r"
l_num,r_num=xx2[n//2-1][0],xx2[n//2][0]
xx3=sorted(xx2,key=lambda x:x[1]) 
for i in range(n):
    if xx3[i][2]=="l":
        print(r_num)
    else:
        print(l_num)

Solution (Python):
def solve(n, X):
    l, r = sorted(X)[n // 2 - 1:n // 2 + 1]
    return [r if x <= l else l for x in X]

_n = int(input())
_X = list(map(int, input().split()))
print(*solve(_n, _X), sep='\n')

Solution (Python):
from copy import deepcopy

n = int(input().strip())
x = list(map(int, input().split()))
y = deepcopy(x)
y.sort()
m1 = y[n // 2 - 1]
m2 = y[(n // 2)]

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

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

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

y = sorted(x)

median1 = y[n // 2 - 1]
median2 = y[n // 2]



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

Solution (Python):
n = int(input())
x = tuple(map(int,input().split()))
x_sort = sorted(x,reverse=True)
x_median = x_sort[n//2-1]
x_median2 = x_sort[n//2]
for i in range(n):
    print(x_median2 if x[i] > x_median2 else x_median)

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

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

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

Solution (Python):
import copy

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

xx= sorted(x)
L_x = xx[n//2 - 1]
R_x = xx[n//2]

for arr in x:
  print(L_x if R_x <= arr else R_x)

Solution (Python):
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1: N // 2 + 1]
    ans = [r if x <= l else l for x in X]
    print("\n".join(map(str, ans)))
    return


main()

Solution (Python):
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1:N // 2 + 1]
    print("\n".join(map(str, [r if x <= l else l for x in X])))
    return


main()

Solution (Python):
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1: N // 2 + 1]
    ans = [r if x < r else l for x in X]
    print("\n".join(map(str, ans)))
    return


main()

Solution (Python):
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1:N // 2 + 1]
    print("\n".join(map(str, [r if x < r else l for x in X])))
    return


main()

Solution (Python):
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1:N // 2 + 1]
    print("\n".join([str(r) if x < r else str(l) for x in X]))
    return


main()

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

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

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

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

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

Solution (Python):

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

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

ans = [-1]*n

ind = n//2
for i in range(n):
    if i <= n//2-1:
        ans[x[i][1]] = x[n//2][0]
    else:
        ans[x[i][1]] = x[n//2-1][0]
print(*ans, sep='\n')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(len(a)):
  b.append([a[i], i, 0])
b.sort()
for i in range(len(b)):
  if i < len(b)/2:
    b[i][2] = b[len(b)//2][0]
  else:
    b[i][2] = b[len(b)//2-1][0]
b.sort(key=lambda x: x[1])
for i in range(len(b)):
  print(b[i][2])

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

Solution (Python):
n = int(input())
nums = [int(i) for i in input().split()]
sorted_nums = sorted(nums)
median_idx = n // 2
low = sorted_nums[median_idx-1]
high = sorted_nums[median_idx]
tmp = (low + high) / 2

for num in nums:
    if num < tmp:
        print(high)
    else:
        print(low)

Solution (Python):
import sys

input = sys.stdin.readline


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

    X_sorted = sorted(X)
    a = X_sorted[N // 2]
    b = X_sorted[(N // 2) - 1]
    for i in range(N):
        if X[i] >= a:
            print(b)
        else:
            print(a)



if __name__ == '__main__':
    main()

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

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

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

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

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

for i in range(N):
    if X[i] <= med_options[0]:
        print(med_options[1])
    elif med_options[1] <= X[i]:
        print(med_options[0])

Solution (Python):
from operator import itemgetter
N = int(input())
X = list(map(int,input().split()))
X_ = sorted(enumerate(X),key=itemgetter(1))
lesser_med = X_[(N//2)-1]
greater_med = X_[N//2]
for x in X:
    if x <= lesser_med[1]:
        print(greater_med[1])
    else:
        print(lesser_med[1])

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
y=x.copy()
y.sort()
cr=y[n//2]
cl=y[n//2-1]

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

Solution (Python):



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

B = sorted(A)
L = B[N//2-1]
R = B[N//2]

for a in A:
  print(L if a >= R else R)

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

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

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

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

li = sorted(a)
memo = li[n//2-1]

for i in range(n):
    if a[i] > memo:
        print(li[(n//2)-1]) 
    else:
        print(li[(n//2)])

Solution (Python):
n = int(input())
l = [int(i) for i in input().split()]
l2 = sorted(l)

ans_list = [l2[(n//2)-1],l2[n//2]]

for i in l:
    if i > ans_list[0]:
        print(ans_list[0])
    else:
        print(ans_list[1])

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

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

Solution (Python):
import copy
n = int(input())
lst1 = list(map(int,input().split()))
lst2 = []
c = copy.deepcopy(lst1)

c.sort()

Kth = c[n//2] 

med_low = Kth
med_high = c[n//2-1]

for i in range(n):
    if lst1[i] < Kth:
        print(med_low)
    else:
        print(med_high)

Solution (Python):


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

X2=sorted(X)

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

Solution (Python):

N=int(input())
X=list(map(int,input().split()))
X_=sorted(X)
M=X_[(len(X)-1)//2]
for x in X:
    if x<=M:
        print(X_[(len(X)-1)//2+1])
    else:
        print(M)

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

ls_s = sorted(ls)
md = (ls_s[int(n/2) - 1] + ls_s[int(n/2)]) / 2

for i in range(n):
    if ls[i] <= md:
        print(ls_s[int(n/2)])
    elif ls[i] > md:
        print(ls_s[int(n/2) - 1])

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

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

m1 = xx[n//2-1]
m2 = xx[n//2]



for i in range(len(x)):
    if x[i] < m1:
        print(m1)
    elif x[i] >= m1:
        print(m2)

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

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

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

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

Solution (Python):
N = int(input())
X = [[-1*float("inf"),0]] + [[int(inp),i] for inp,i in zip(input().split(), range(1,N + 1))]

from operator import itemgetter

def main():
    X.sort(key = itemgetter(0))
    med = N // 2
    Ans = [-1]*(N+1)
    for XX,i in zip(X[1:],range(1,N+1)):
        index = XX[1]
        if i <= med:
            Ans[index] = X[med + 1][0]
        else:
            Ans[index] = X[med][0]
    print(*Ans[1:],sep="\n")


if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

Solution (Python):

import sys


def solve(N: int, X: "List[int]"):
    Y = sorted(X)
    me1 = Y[N//2]
    me2 = Y[N//2-1]

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

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

import sys


def solve(N: int, X: "List[int]"):
    Y = sorted(X)
    me1 = Y[N//2]
    me2 = Y[N//2-1]

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

    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())
A = [int(x) for x in input().split()]
B = sorted(A)

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

for a in A:
  if a<r:
    print(r)
  else:
    print(l)

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

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

for a in A:
  if a<=l:
    print(r)
  else:
    print(l)

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

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

nx = sorted(x)
a = nx[n//2]
b = nx[n//2-1]

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

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

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

for i in range(n):
    ans = x[n//2][1] if i < n//2 else x[n//2-1][1]
    x[i].append(ans)

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

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

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

xs=sorted(x)
a=xs[n//2]
b=xs[(n//2)-1]

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

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
xs = sorted(x)
d = dict()
for i in range(n):
  if xs[i] not in d:
    d[xs[i]] = i
for i in range(n):
  print(xs[n // 2 - int(d[x[i]] >= n // 2)])

Solution (Python):
import sys

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

def main():
    y = sorted(x)
    r = y[n // 2]
    l = y[n // 2 - 1]
    
    for i in range(n):
        if x[i] <= l:
            yield r
        else:
            yield l

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

x2 = sorted(x)
m1 = x2[n // 2 - 1]
m2 = x2[n // 2]

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

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

Asort = sorted(A)

min_ans = Asort[n//2-1]
max_ans = Asort[n//2]

if (min_ans == max_ans):
    for a in A:
        print(min_ans)
else:
    for a in A:
        if (min_ans >= a):
            print(max_ans)
        else:
            print(min_ans)

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

    sortedIdx = sorted(list(range(N)), key=lambda k: X[k])

    midrIdx = N // 2
    midrVal = X[sortedIdx[midrIdx]]
    midlIdx = N // 2 - 1
    midlVal = X[sortedIdx[midlIdx]]

    ans = [-1] * N
    for i in range(N):
        if i <= midlIdx:
            ans[sortedIdx[i]] = midrVal
        else:
            ans[sortedIdx[i]] = midlVal
    
    print(*ans, sep="\n")
if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    X = LI()
    ans = [0] * N
    sorted_X = sorted([(x, i) for i, x in enumerate(X)], key=lambda x: x[0])
    l = sorted_X[N//2 - 1][0]
    r = sorted_X[N//2][0]
    for i, (x, org_ix) in enumerate(sorted_X):
        if i < N//2:
            _ans = r
        else:
            _ans = l
        ans[org_ix] = _ans
    for a in ans:
        print(a)
main()

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

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

Solution (Python):
import sys
from collections import Counter
from itertools import accumulate
n = int(input())
x_ls = [int(i) for i in sys.stdin.readline().split()]
sorted_x_ls = sorted(x_ls)
ct = Counter(x_ls)
acc = dict()
_sum = 0
for k, v in sorted(ct.items(), key=lambda x:x[0]):
    _sum += v
    acc[k] = _sum

for i, x in enumerate(x_ls):
    if acc[x] <= n // 2:
        print(sorted_x_ls[n // 2])
    else:
        print(sorted_x_ls[n // 2 - 1])

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

a = sorted(X)
mid = N // 2 - 1

for i in range(N):
    if X[i] <= a[mid]:
        ans = a[mid + 1]
    else:
        ans = a[mid]
    print(ans)