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








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

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

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

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

for num in x:
    if num <= target:
        print(x_sorted[n // 2])
    else:
        print(x_sorted[n // 2 - 1])

Solution (Python):
n=int(input())
a=[int(i) for i in input().split()]
b=a.copy()
b.sort()

m1=b[int(n/2)-1]
m2=b[int(n/2)]
mm=(m1+m2)/2
for i in a:
  if i<=mm:
    print(m2)
  else:
    print(m1)

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

for i in range(n):
    if x[i]<y2:
        print(y2)
    else:
        print(y1)

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

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

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

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

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

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

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

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

small_median = sorted_numbers[N//2 - 1]
big_median = sorted_numbers[N//2]

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

Solution (Python):
from statistics import median

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

X_sorted = sorted(X)
X_med = median(X)
for i in range(N):
  if X[i] < X_med:
    res = X_sorted[N // 2]
  elif X_med < X[i]:
    res = X_sorted[N // 2 - 1]
  else:
    res = X[i]

  print(res)

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

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

Solution (Python):
n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

[print(c_xs[center+1] if x <= c_xs[center] else c_xs[center]) for x in xs]

Solution (Python):
n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

for x in xs:
    print(c_xs[center+1] if x <= c_xs[center] else c_xs[center])

Solution (Python):
n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

for x in xs:
    print(c_xs[center+1] if x <= c_xs[center] else c_xs[center])

Solution (Python):
n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

[print(c_xs[center+1] if x <= c_xs[center] else c_xs[center]) for x in xs]

Solution (Python):
def main():
    """
    N=2*10^5
    毎回sortは無理
    sort済みにして計算量を落とす

    元が偶数個なので中央値を考えてsortしたとき
    中央付近には2つ,sort済み値が存在する m1<=m2
    1つ除外したとき
        除外したものがm1以下: 小さい方にずれるのでm2
        除外したものがm2以上: 大きい方にずれるのでm1
    """
    N = int(input())
    *X, = map(int, input().split())

    X_sorted = sorted(X)
    mid = N // 2
    m1 = X_sorted[mid-1]
    m2 = X_sorted[mid]
    for i in range(N):
        if X[i] <= m1:
            ans = m2
        else:
            ans = m1

        print(ans)


if __name__ == '__main__':
    main()

Solution (Python):

"""
C - Many Medians
https://beta.atcoder.jp/contests/abc094/tasks/arc095_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, numbers):
    tmp = numbers[:]
    tmp.sort()
    s = tmp[(N-1)//2]
    l = tmp[N//2]

    ans = []
    for n in numbers:
        if n > s:
            ans.append(s)
        else:
            ans.append(l)
    return ans


def main(args):
    N = int(input())
    numbers = [int(x) for x in input().split()]
    ans = solve(N, numbers)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])

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

for bb in b:
    if bb <= a[l]:
        print(a[r])
    else:
        print(a[l])

Solution (Python):


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

    nums = sorted(X)
    center = len(nums)//2

    dic = {}
    for i,x in enumerate(nums):
        if x not in dic:
            dic[x] = i

    if len(nums)%2 == 0:
        is_even = True
    else:
        is_even = False

    for x in X:
        i = dic[x]
        if is_even:
            if i < center:
                print(nums[center])
            else:
                print(nums[center-1])
        else:
            print(nums[center+1])


if __name__ == '__main__':
    main()

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

l=[x[i] for i in range(n)]

l.sort()

small=l[n//2-1]
large=l[n//2]

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

Solution (Python):
def main():
    c = int(input()) // 2
    elem = list(map(int, input().split()))
    left, right = sorted(elem)[c - 1:c + 1]
    for val in elem:
        print((left, right)[val <= left])


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    c = int(input()) // 2
    elem = list(map(int, input().split()))
    right, left = sorted(elem)[c - 1:c + 1]
    for val in elem:
        print(median(val, right, left))


def median(val, right, left):
    if val <= right:
        return left
    else:
        return right


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    c = int(input()) // 2
    elem = list(map(int, input().split()))
    right, left = sorted(elem)[c - 1:c + 1]
    for val in elem:
        print(median(val, right, left))


def median(val, right, left):
    if right == left:
        return right
    elif val <= right:
        return left
    else:
        return right


if __name__ == '__main__':
    main()

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

Solution (Python):
n =  int(input())
ls = list(map(int, input().split()))
sorted_ls = ls.copy()
sorted_ls.sort()
f = sorted_ls[int(n/2)]
b = sorted_ls[int(n/2)-1]

for i in ls:
    if i < f:
        print(f)
    else:
        print(b)

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

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

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

Solution (Python):
n=int(input())
arr=[int(x) for x in input().split()]
sorted_arr = sorted(arr)
l = sorted_arr[n//2 -1]
r = sorted_arr[n//2]
for x in arr:
    if x >= r:
        print(l)
    else:
        print(r)

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

Solution (Python):
n = int(input())
x = map(int, input().split())
temp = sorted(zip(x, range(n)))
ans = [None] * n
for i in range(n):
    idx = n//2
    if i >= idx:
        idx -= 1
    ans[temp[i][1]] = temp[idx][0]
for item in ans:
    print(item)

Solution (Python):
n = int(input())
x = map(int, input().split())
temp = sorted(zip(x, range(n)))
ans = [None] * n
for i in range(n):
    idx = n//2
    if i >= idx:
        idx -= 1
    ans[temp[i][1]] = temp[idx][0]
for item in ans:
    print(item)

Solution (Python):


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

Solution (Python):

if __name__ == "__main__":
    n = int(input())
    x = [ (number, index) for number, index in zip(list(map(int, input().split())),range(n)) ]
    x.sort(key=lambda tmp:tmp[0])
    indexDic = { index[1]: xindex for index, xindex in zip(x,range(n)) }
    center = int(n/2)
    for tmp in range(n):
        ignoreIndex = indexDic[tmp]
        if ignoreIndex+1 <= center:
            print(x[center][0])
        else:
            print(x[center-1][0])

Solution (Python):
def medians(nums, n):
    median_left = nums[(n + 1)//2]
    median_right = nums[(n + 1)//2 - 1]
    return median_left, median_right


if __name__ == '__main__':
    n = int(input())
    nums = list(map(int, input().split()))
    median_left, median_right = medians(sorted(nums), n)
    for i in nums:
        print(median_left) if i < median_left else print(median_right)

Solution (Python):
N = int(input())
X_list = list(map(int, input().split()))
X_list_copy = X_list.copy()
X_list_copy.sort()

median_idx = int(N / 2)
left_num = X_list_copy[median_idx - 1]
right_num = X_list_copy[median_idx]

for x in X_list:
    if x < right_num:
        print(right_num)
    else:
        print(left_num)

Solution (Python):



n = int(input())


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


xs_sorted = sorted(xs)


l = len(xs_sorted)
l_mid = int(l / 2)


xs_mid_1 = xs_sorted[l_mid - 1]
xs_mid_2 = xs_sorted[l_mid]


for x in xs:
    if x < xs_mid_2:
        print("{}".format(xs_mid_2))
    else:
        print("{}".format(xs_mid_1))

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
Y = [[X[k],k] for k in range(N)]

Y.sort()

A = [0] * N
for k in range(N):
	if k >= N // 2:
		A[Y[k][1]] = Y[N//2-1][0]
	else:
		A[Y[k][1]] = Y[N//2][0]

for x in A:
	print(x)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = [[X[k],k] for k in range(N)]
Y.sort()
A = [0 for k in range(N)]

for k in range(N):
    if k >= N//2:
        A[Y[k][1]] = Y[N//2-1][0]
    else:
        A[Y[k][1]] = Y[N//2][0]

for x in A:
    print(x)

Solution (Python):
import copy

n = int(input())
x = list(map(int, input().split()))
x_sort = copy.deepcopy(x)
x_sort.sort()

center_a = x_sort[int(n / 2) - 1]
center_b = x_sort[int(n / 2)]

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

Solution (Python):
def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    
    sorted_X = sorted(X)
    median_1 = sorted_X[int(N/2)-1]
    median_2 = sorted_X[int(N/2)]
    
    for i in range(N):
        remove_num = X[i]
        if(remove_num > median_1):
            print(median_1)
        else:
            print(median_2)
    
if __name__=="__main__":
    main()

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

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

sorted_x = sorted(x)
b1,b2 = sorted_x[n//2-1], sorted_x[n//2]
for item in x:
    if item <= b1:
        print(b2)
    else:
        print(b1)

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

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

Solution (Python):
import sys
import numpy as np

N=int(input())

X=np.array(list(map(int,input().split())))
temp=X
temp=np.sort(temp,kind="quicksort")
med=temp[int(N/2)]
for i in range(N):
	if X[i]<med:
		print(med)
	else:
		print(temp[int(N/2)-1])

Solution (Python):
N = int(input().strip())
X = list(map(int,input().strip().split(' ')))
sorted_X = sorted(X)
med_l=sorted_X[int(N/2-1)]
med_r=sorted_X[int(N/2)]
for iX in X:
    if iX <= med_l:
        print(med_r)
    elif med_r <= iX:
        print(med_l)

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

min_mid = sx[int(n/2-1)]
max_mid = sx[int(n/2)]

for i in x:
    if i <= min_mid:    
        print(max_mid)
    else:               
        print(min_mid)

Solution (Python):


length = int(raw_input())
li = list(map(int,raw_input().split()))
li_sort = sorted(li)
if li_sort[length/2] == li_sort[length/2-1]:
    for i in range(length):
        print li_sort[length/2]
else:
    for i in li:
        if i <= li_sort[length/2-1]:
            print li_sort[length/2]
        else:
            print li_sort[length/2-1]

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

Solution (Python):

n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

center = (len(xs) - 1)//2

c_xs = xs[:]
c_xs.sort()

if c_xs[center] == c_xs[center+1]:
    for x in xs:
        print(c_xs[center])
else:
    for x in xs:
        if x <= c_xs[center]:
            print(c_xs[center+1])
        else:
            print(c_xs[center])

Solution (Python):

n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

for x in xs:
    print(c_xs[center+1] if x <= c_xs[center] else c_xs[center])

Solution (Python):

n = int(input())
x_str = input().split()
xs = [int(c) for c in x_str]

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = xs[:]
c_xs.sort()

for x in xs:
    if x <= c_xs[center]:
        print(c_xs[center+1])
    else:
        print(c_xs[center])

Solution (Python):

import numpy as np

n = int(input())
x_str = input().split()
xs = np.array([int(c) for c in x_str])

xs_len = len(xs)
center = (xs_len - 1)//2

c_xs = np.sort(xs)

for x in xs:
    if x <= c_xs[center]:
        print(c_xs[center+1])
    else:
        print(c_xs[center])

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    x = sorted(X[:])
    min_median = x[int(N/2-1)]
    max_median = x[int(N/2)]
    for i in range(N):
        if X[i] <= min_median:
            print(max_median)
        else:
            print(min_median)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
y = []
for i in range(n):
	y.append([x[i],i+1])
y.sort()
a,b = y[n//2][0],y[(n-2)//2][0]
for i in range(len(y)//2):
	y[i][0],y[i][1] = y[i][1],a
for i in range(len(y)//2,n):
	y[i][0],y[i][1] = y[i][1],b
y.sort()
for i in y:
	print(i[1])

Solution (Python):

import math                                       
                                                  
N = int(input())                                  
original_list = [int(i) for i in input().split()] 
sorted_list = sorted(original_list)               
min_midian = sorted_list[int(N / 2) - 1]          
max_midian = sorted_list[int(N / 2)]              
                                                  
for i in range(N):                                
  if min_midian >= original_list[i]:              
    print(max_midian)                             
  else:                                           
    print(min_midian)

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

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

candidates = sorted(x)[n//2-1:n//2+1]

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

Solution (Python):
def c_many_medians(N, X):
    Y = sorted(X)
    ans = []
    for xi in X:  
        
        
        
        
        
        pos = N // 2 if xi < Y[N // 2] else (N // 2) - 1
        ans.append(str(Y[pos]))
    return '\n'.join(ans)

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

Solution (Python):


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

lis = sorted(a)
high_med = lis[int(n/2)]
low_med = lis[int(n/2-1)]
if high_med == low_med:
    for _ in range(n):
        print(high_med)
else:
    for v in a:
        if v < high_med:
            print(high_med)
        else:
            print(low_med)

Solution (Python):
N=int(input())
X=[int(i) for i in input().split()]
x=X.copy()
x.sort()
mina=x[N//2-1]
minb=x[N//2]
for i in range(N):
  if mina<X[i]:
    print(mina)
  else :
    print(minb)

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
sortedx = sorted(x)
r = sortedx[n//2]
l = sortedx[n//2-1]

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

Solution (Python):


n = int(input())

number_list = list(map(int,input().split()))
tmp_list = sorted(number_list)


for number in number_list:
    if number < tmp_list[n//2]:
        print(tmp_list[n//2])
    else :
        print(tmp_list[n//2-1])

Solution (Python):
import bisect

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

for i in X:
    index = bisect.bisect_left(X_sorted, i)
    
    if index <= N / 2 - 1:
        print(X_sorted[int(N / 2)])
    else:
        print(X_sorted[int(N / 2) - 1])

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

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

sort_x = X.copy()
sort_x.sort()

nn = N//2
low_ = sort_x[nn-1]
high_ = sort_x[nn]

for x in X:
	if x < high_:
		print(high_)
	else:
		print(low_)

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

nn=n//2
y=x[:]
x.sort()
low_median=x[nn-1]
high_median=x[nn]

[print(high_median) if y[i]<high_median  else print(low_median)  for i in range(n) ] 

"""
for i in range(n):
  if y[i]<high_median:
    print(high_median)
  else:
    print(low_median)
"""

Solution (Python):
n=int(input())
nn=n//2
x=[int(i) for i in input().split()]
y=x[:]
x.sort()
 
low_median=x[nn-1]
high_median=x[nn]
 
for i in range(n):
  if y[i]<high_median:
    print(high_median)
  else:
    print(low_median)

Solution (Python):





if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    sorted_x = sorted(x)

    low = sorted_x[(n // 2) - 1]
    high = sorted_x[(n // 2)]

    for i in range(n):
        if x[i] < high:
            print(high)
        else:
            print(low)

Solution (Python):
def m():
    N = int(input())
    X = [int(x) for x in input().split()]
    XX = [x for x in X]
    XX.sort()
    first = XX[N//2]
    second = XX[N//2 -1]
    for x in range(N):
        if X[x] <= second:
            print(first)
        else:
            print(second)


m()

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

Solution (Python):
N = int(input())
X = [int(i) for i in input().split()]
Y = sorted(X)
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):
n = int(input())
x = list(map(int, input().split()))

sortedx = x[:]
sortedx.sort()

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

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

Solution (Python):
N=int(input())
X=list(map(int, input().split()))
 
import copy
X_sort=copy.deepcopy(X)
X_sort.sort()
X_sort
 
median_control=(X_sort[N//2-1]+X_sort[N//2])/2
for i in range (N):
    if X[i]>median_control:
        print (X_sort[N//2-1])
    if X[i]<=median_control:
        print (X_sort[N//2])

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

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

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

y = sorted(x)

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

Solution (Python):
from statistics import median, median_low, median_high


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
median = median(X)

"""
F = X[:]
F.sort()

median1 = int(N/2 - 1)
median2 = int(N/2) 

if median.is_integer():
    median1 = median
    median2 = median
else:
    median1 = median - 0.5
    median2 = median + 0.5
"""
median1 = median_low(X)
median2 = median_high(X)
   
for i in range(N):
    
    
    if X[i] < median:
        ans = median2
    else:
        ans = median1
    print(int(ans))

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

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

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

med1 = Y[N // 2 - 1]
med2 = Y[N // 2]

for x in X:
    if x < med2:
        print(med2)
    else:
        print(med1)

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

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

Solution (Python):


list_size = int(input())
num_list = [int(i) for i in input().split()]

num_list2 = sorted(num_list)

center_left = num_list2[int(list_size / 2) - 1]
center_right = num_list2[int(list_size / 2)]

for i in range(list_size):
	
	if num_list[i] <= center_left:
		print(center_right)
	else:
		print(center_left)

Solution (Python):
def c_many_medians(N, X):
    
    Y = sorted(X)
    ans = ['' for _ in range(N)]
    pos = N // 2
    for k, xi in enumerate(X):
        if xi < Y[pos]:
            ans[k] = str(Y[pos])
        else:
            ans[k] = str(Y[pos - 1])
    return '\n'.join(ans)

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

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

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

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

Solution (Python):
N = int(input())
x = [int(x) for x in input().split()]
y = sorted(x)
l = y[len(x)//2-1]
r = y[len(x)//2]

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

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

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

soredx = sorted(x)

migi = soredx[int(n/2-1)]
hidari = soredx[int(n/2)]

for i in range(n):
    if(migi<x[i]):
        print(migi)
    else:
        print(hidari)

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

Solution (Python):
import copy

n = int(input())
x = [int(i) for i in input().split()]
sortedx = copy.copy(x)
sortedx.sort()

m = sortedx[int((n+1)/2)]

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

Solution (Python):
N = input()
N = int(N)
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

sortedarray = sorted(array)

be = sortedarray[(N//2-1)]
af = sortedarray[N//2]
for flag in array:
    if flag <= be:
        print(af)
    else: print(be)

Solution (Python):
import copy

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

X = sorted(X)
for i in range(N):
    ans1 = X[int(len(X)/2)]
    ans2 = X[int(len(X)/2)-1]
    if tmp[i] < ans1:
        print(ans1)
    else:
        print(ans2)

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

Solution (Python):
N = int(raw_input())
nums = map(int, raw_input().split())
num_tmp = []
for a in nums:
    num_tmp.append(a)
nums.sort()
med_1 = nums[N/2 - 1]
med_2 = nums[N/2]
for i in range(N):
    if num_tmp[i] <= med_1:
        print(med_2)
    elif num_tmp[i] >= med_2:
        print(med_1)

Solution (Python):
def main():
    n=int(input())
    x = [int(i) for i in input().split()]
    x_t = tuple(x)
    x.sort()
    l = x[int((len(x)/2 - 1))]
    u = x[int((len(x)/2))]
    for i in range(len(x_t)):
        if (x_t[i]<=l):
            print(u)
        else:
            print(l)
            
main()

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
sX = sorted(X)
mid = N // 2 - 1

for x in X:
    if sX[mid] >= x:
        print(sX[mid + 1])
    else:
        print(sX[mid])

Solution (Python):
n = int(input())
x =[int(i) for i in input().split()]
c = n//2 - 1
y = x.copy()
y.sort()

for i in range(0,n):
    if y[c] >= x[i]:
        print(y[c+1])
    else:
        print(y[c])

Solution (Python):
import numpy as np

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

a=np.sort(X)
n=len(X)//2

an_1=a[n-1]
an=a[n]

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

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

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

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

save = X[:]

save.sort()

midL = save[int(N / 2 - 1)]
midR = save[int(N / 2)]

for i in X:
    if i <= midL:
        print(midR)
    else:
        print(midL)

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

y = copy.copy(x)
x.sort()
l = len(x)
m0 = x[int(l/2 - 1)]
m1 = x[int(l/2)]


for i in y:
    if i <= m0:
        print(m1)
    else:
        print(m0)

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

y = sorted(x, reverse=True)
me1 = y[(n+1) // 2 - 1]
me2 = y[(n+1) // 2]
for i in range(n):
    if x[i] <= me2:
        print(me1)
    else:
        print(me2)

Solution (Python):
n = int(input())
x = input().split()
for i in range(n):
    x[i] = int(x[i])
xs = sorted(x)
ml = xs[n//2-1]
mr = xs[n//2]

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

Solution (Python):
def solve(N, A):
    c = int(N / 2)
    left = sorted(A)[c - 1]
    right = sorted(A)[c]
    if left == right:
        for x in range(N):
            print(left)
        return;
    for x in range(N):
        if A[x] <= left:
            print(right)
        if A[x] >= right:
            print(left)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)

Solution (Python):
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Xi = [(i, int(x)) for i, x in enumerate(stdin.readline().rstrip().split())]
    Xi = sorted(Xi, key=lambda x: x[1], reverse=True)
    result = list(range(N))
    index = N // 2 - 1
    for i in range(N):
        idx = index
        if i <= index:
            idx += 1
        result[Xi[i][0]] = Xi[idx][1]

    for x in result:
        print(x)


if __name__ == '__main__':
    main()

Solution (Python):


N = int(raw_input())

X = map(int, raw_input().split())
Y = sorted(X)

median_idx = ((1 + N) / 2) - 1
median = Y[median_idx]

small_counter = 0
same_counter = 0
for i in X:
    if i < median:
        small_counter += 1
    elif i == median:
        same_counter += 1

tmp = median_idx - small_counter
if tmp == 0:
    small_num = 0
    big_num = same_counter - 1
else:
    small_num = tmp
    big_num = same_counter - small_num - 1


for i in X:
    c_s_num = 0
    if median < i:
        if (N % 2) == 0:
            new_median_idx = median_idx
        else:
            new_median_idx = median_idx - 1
    elif median > i:
        if (N % 2) == 0:
            new_median_idx = median_idx + 1
        else:
            new_median_idx = median_idx
    elif median == i:
        if c_s_num <= small_num:
            c_s_num += 1
            if (N % 2) == 0:
                new_median_idx = median_idx + 1
            else:
                new_median_idx = median_idx
        else:
            if (N % 2) == 0:
                new_median_idx = median_idx
            else:
                new_median_idx = median_idx - 1
    print Y[new_median_idx]

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

list_X = [int(X) for X in input().split(' ')]
list_X_sorted = sorted(list_X)
mid_right = int(N / 2)
mid_left = mid_right - 1

for i in range(N):
    if list_X[i] < list_X_sorted[mid_right]:
        print(list_X_sorted[mid_right])
    else:
        print(list_X_sorted[mid_left])