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 = [int(i) for i in input().split()]
a = X[:]
a.sort()
l = a[N//2-1]
r = a[N//2]
if l == r:
    for i in range(N):
        print(l)
else:
    for i in range(N):
        if X[i] <= l:
            print(r)
        elif X[i] >= r:
            print(l)

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')



N = 0
X = []


def set_inputs():
    global N, X
    N = get_int()
    X = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    
    ix = list(sorted(enumerate(X), key=operator.itemgetter(1)))
    l, r = ix[N // 2 - 1][1], ix[N // 2][1]
    ans = [0] * N
    for j, (i, x) in enumerate(ix):
        if j < N // 2:
            ans[i] = r
        else:
            ans[i] = l
    for a in ans:
        print(a)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = [int(item) for item in input().split()]
a_s = sorted(a)

low_med = a_s[n//2 - 1]
high_med = a_s[n//2]

for item in a:
  if low_med == high_med:
    print(low_med)
  elif item <= low_med:
    print(high_med)
  elif item >= high_med:
    print(low_med)

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

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

temp = X[:]

X.sort()
mi = X[len(X)//2-1]
ma = X[len(X)//2]

for x in temp:
    if x <= mi:
        print(ma)
    else:
        print(mi)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
Y = sorted(X)
m1= Y[N//2-1]
m2 = Y[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()))
X.append(0)
Y = sorted(X)

d = Y[len(X) // 2]
e = Y[len(X) // 2 + 1]

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

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

x = zip(x, [i for i in range(0, n)])
x = sorted(x, key=lambda k: k[0])
r = [0] * n

for i in range(0, n):
    if i < n // 2:
        r[x[i][1]] = x[n // 2][0]
    else:
        r[x[i][1]] = x[n // 2 - 1][0]

for i in r:
    print(i)

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
a, b = Y[N//2], Y[N//2-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()))
X_sorted = sorted(X)

L = X_sorted[N//2 -1]
U = X_sorted[N//2]

for x in X:
  if x<=L:
    print(U)
  else:
    print(L)

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
work = X.copy()
work.sort()
dict = {}
left = N // 2
right = left - 1
for i in range(N):
    if i < N // 2:
        dict[work[i]] = work[left]
    else:
        dict[work[i]] = work[right]
for i in range(N):
    print(str(dict[X[i]]))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    l, r = sorted(x)[mid - 1:mid + 1]
    return "\n".join([str(r) if _x < r else str(l) for _x in x])


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    l, r = sorted(x)[mid - 1:mid + 1]
    return "\n".join([str(r) if _x < r else str(l) for _x in x])


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    x = [(i, _x) for i, _x in enumerate(x)]
    x = sorted(x, key=lambda x: x[1])
    ans = [[] for _ in range(n)]
    for i, _x in enumerate(x):
        ans[_x[0]] = str(x[mid][1]) if i < mid else str(x[mid - 1][1])
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    x = [(i, _x) for i, _x in enumerate(x)]
    x = sorted(x, key=lambda x: x[1])
    ans = [[] for _ in range(n)]
    for i, _x in enumerate(x):
        ans[_x[0]] = str(x[mid][1]) if i < mid else str(x[mid - 1][1])
    return "\n".join(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    x = [(i, _x) for i, _x in enumerate(x)]
    x = sorted(x, key=lambda x: x[1])
    ans = [(_x[0], x[mid][1]) if i < mid else (_x[0], x[mid - 1][1]) for i, _x in enumerate(x)]
    ans = sorted(ans, key=lambda x: x[0])
    return "\n".join([str(_x) for i, _x in ans])


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
def solve(string):
    n, *x = map(int, string.split())
    mid = n // 2
    x = [(i, _x) for i, _x in enumerate(x)]
    x = sorted(x, key=lambda x: x[1])
    ans = [(_x[0], x[mid][1]) if i < mid else (_x[0], x[mid - 1][1]) for i, _x in enumerate(x)]
    ans = sorted(ans, key=lambda x: x[0])
    return "\n".join([str(_x) for i, _x in ans])


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 pf(s): return print(s, flush=True)

N = I()
X = LI()




"""
まずは偶数時の中央値のidxを求める
偶数時の中央値より小さいものが抜かれたときは、そのまま、
大きいものが抜かれたときはidx-1が中央値となる
"""

found = {}
sorted_X = sorted(X)
median = sorted_X[int(len(X)/2)]
for x in X:
    
    
    if x < median:
        if found.get('small',None):
            print(found['small'])
        else:
            print(median)
            found['small'] = median
    elif x > median:
        if not found.get('big', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            
            m = tmp[int(len(tmp)//2)]
            print(m)
            found['big'] = m
        else:
            print(found['big'])
    else:
        if not found.get('equal', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            m = tmp[int(len(tmp)//2)]
            print(m)
            found['equal'] = m
        else:
            print(found['equal'])

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

small = L[N//2-1]
large = L[N//2]

for i in X:
    if i <= small:
        print(large)
    else:
        print(small)

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

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

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

Solution (Python):

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

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

for l in L:
    if l<=sortedL[(N//2)-1]:
        print(sortedL[N//2])
    else:
        print(sortedL[N//2-1])

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

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

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

mid_l = xx[n//2 -1]
mid_r = xx[n//2]

for _ in x:
    if _ <= mid_l:
        print(mid_r)
    else:
        print(mid_l)

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

l = x.copy()
l.sort()
M_L = l[N//2-1]
M_R = l[N//2]
for item in x:
    if item <= M_L:
        print(M_R)
    else:
        print(M_L)

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

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    return


def B():
    return


def C():
    n = II()
    x = LI()
    xb = x[::1]
    xb.sort()
    a = xb[n // 2 - 1]
    b = xb[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif x[i] >= b:
            print(a)
        
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

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] = SR()
    return l
mod = 1000000007


def A():
    n = I()
    print(n*800-200*(n//15))


def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)


def C():
    x,t = LI()
    print(max(0,x-t))


def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)


def E():
    x,y,s,t = LI()
    return


def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])


def G():
    return


def H():
    return

def J():
    return

def K():
    return


if __name__ == "__main__":
    F()

Solution (Python):
N=int(input())
X=map(int,input().split())
X2 = [(x,i) for i,x in enumerate(X)]
X2.sort()



ans=[0 for i in range(N)]
m1,i1=X2[N//2-1]
m2,i2=X2[N//2]
for j in range(N//2):
    x,i=X2[j]
    ans[i]=m2
for j in range(N//2,N):
    x,i=X2[j]
    ans[i]=m1
for i in range(N):
    print(ans[i])

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:
    print(right if x <= left else left)

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

idx = N // 2
center1 = Si[idx - 1] 
center2 = Si[idx]

for x in Xi:
    if x == center1 and x == center2:
        print(x)
    elif x <= center1:
        print(center2)
    else:
        print(center1)

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

Solution (Python):


import sys


n = int(sys.stdin.readline().rstrip())
Xn = list(map(int, sys.stdin.readline().rstrip().split()))
Xn_s = sorted(Xn)
c_l = Xn_s[n//2-1]
c_r = Xn_s[n//2]
for x in Xn:
  if x <= c_l:
    print(c_r)
  elif x>= c_r:
    print(c_l)

Solution (Python):
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
m=y[n//2-1]
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()))
y = list(x)
y.sort()

med1 = y[(n//2)-1]
med2 = y[(n//2)]

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

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

Solution (Python):


"""
Created on 2019/3/16
Solved on 2019/3/16
@author: shinjisu
"""






def getInt(): return int(input())

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


def zeros(n): return [0]*n


def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n 

def getIntMat(n, m):  
    
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N = getInt()
    X = getIntList()
    d.dmp((N),'N')
    d.dmp(X, 'X')
    x = sorted(X)
    d.dmp(X, 'X')
    d.dmp(x, 'x')
    b1 = x[N//2-1]
    b2 = x[N//2]
    d.dmp((b1,b2),'b1,b2')
    for b in X:
        if b <= b1:
            print(b2)
        else:
            print(b1)
    return None


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Solution (Python):
N=int(input())
a=list(input().split())
for i in range(N):
    a[i]=int(a[i])
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):
input = open(0).read

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


def main():
    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):
import copy

input = open(0).read

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


def main():
    a = copy.copy(X)
    l, r = sorted(a)[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 = list(map(int, input().split()))

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())
X = [int(i) for i in input().split()]
X_s = sorted(X)

x1 = X_s[(n//2)-1]
x2 = X_s[n//2]

for x in X:
    if x <= x1:
        print(x2)
    else:
        print(x1)

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

mp =  X2[- (N ) // 2]
mp2 =  X2[- (N + 2) // 2]
for Xi in X:
    if Xi >= mp:
        print(mp2)
    else:
        print(mp)

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

Solution (Python):
def many_medians(N: int, X: list) -> list:
    """必要なのはXをソート(降順)したとき N/2 番目と
    N/2 + 1 番目(ともに 1-indexed)の値。
    N/2 番目の値を x 、N/2 + 1 番目の値を y とする。
    xi >= x の時は y、xi < x の時は x が答え。
    """
    x, y = sorted(X, key=lambda a: -a)[N//2-1:N//2+1]
    return [x if xi < x else y for xi in X]


if __name__ == "__main__":
    N = int(input())
    X = list(map(int, input().split()))
    ans = many_medians(N, X)
    for b in ans:
        print(b)

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
mid = N // 2 - 1
low = tmp[mid]
high = tmp[mid + 1]
all = sum(tmp)
for a in X:
    if a <= low:
        print(high)
    else:
        print(low)

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

Solution (Python):
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
X=rl()
Xs = sorted(X)
Xsl = Xs[:N//2]
Xsr = Xs[N//2:]
r = Xsr[0]
l = Xsl[-1]

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

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

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

a.sort()

mm = a[n//2-1][0]
m = a[n//2][0]
for i in range(n):
    a[i].append(i)
a.sort(key = lambda x:x[1])

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

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


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):


import itertools
import collections
import bisect
import copy

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys

def main():
  input = sys.stdin.readline
  N = int(input())
  X = list(map(int, input().split()))
  Y = sorted(X)
  Ml, Mr = Y[N//2-1], Y[N//2]
  for i in range(N):
    if X[i] <= Ml:
      print(Mr)
    else:
      print(Ml)


if __name__ == '__main__':
  main()

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

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

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

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

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

Solution (Python):

import copy
import numpy as np
import random

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

x_sorted = sorted(x)

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

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

for x in X:
    if x < center:
        print(ans[1])
    else:
        print(ans[0])

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

Solution (Python):
import numpy as np

N = int(input())
X = np.array([int(n) for n in input().split()])
iX = np.argsort(X)
sX = X[iX]

A = [0] * N

for i in range(N):
    if i < N // 2:
        ans = sX[N//2]
    else:
        ans = sX[(N-2)//2]
    A[iX[i]] = ans

for a in A:
    print(a)

Solution (Python):
n = int(input())
xlist = list(map(int, input().split()))
xsort = [x for x in sorted(xlist)]
xml, xmr = xsort[n // 2 - 1], xsort[n // 2]

for x in xlist:
  if x <= xml:
    print(xmr)
  else:
    print(xml)

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

X2=X[:]
X2.sort()
a=X2[n//2-1]
b=X2[n//2]

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

Solution (Python):

N=int(input())
A=list(map(int,input().split()))
A=[[A[i],i] for i in range(N)]
A.sort(key=lambda x:x[0]) 
x=A[N//2-1][0]
y=A[N//2][0]
A=[[A[i][0],A[i][1],i] for i in range(N)]
A.sort(key=lambda x:x[1]) 
for i in range(N):
	if A[i][2]>=N//2:
		print(x)
	else:
		print(y)

Solution (Python):

import sys
from statistics import median_low, median_high



def solve(lines):
    N = int(lines.pop(0))
    X = list(map(int, lines.pop(0).split(' ')))
    low = median_low(X)
    high = median_high(X)
    for i in X:
        if i <= low:
            print(high)
        else:
            print(low)

lines = [x.strip() for x in sys.stdin.readlines()]




solve(lines)

Solution (Python):


import copy
n = int(input())
x = list(map(int, input().split()))
if n == 2:
    print(x[1])
    print(x[0])
else:
    temp = copy.copy(x)
    temp.sort()

    m = temp[int(n/2)-1]

    for i in range(n):
        if x[i] <= m:
            print(temp[int(n/2)])
        else:
            print(m)

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

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

Solution (Python):
N = int(input())
X = list(map(int,input().split()))
sort_X = sorted(X)
l, r = sort_X[N//2-1], sort_X[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()))
Y = sorted(X)
a = Y[int(N/2-1)]
b = Y[int(N/2)]
for i in range(N):
    if X[i] <= a:
        print(b)
    else:
        print(a)

Solution (Python):


















import collections
import math
import numpy as np


n = int(input())
li = list(map(int,input().split()))
s_li = sorted(li)
left_num = s_li[n//2-1]
right_num = s_li[n//2]
for i in li:
    if i>left_num:
        print(left_num)
    else:
        print(right_num)

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

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

Solution (Python):
import numpy as np


n = input()
n = int(n)

class abc:
    def __init__(self, index, number):
        self.index = index
        self.number = number

ls = []

temp_input = input().split()

for i in range(n):
    temp = temp_input[i]
    temp = int(temp)
    ls += [abc(i, temp)]

ls.sort(key = lambda abc:abc.number)
a = n // 2
output = []

for i in range(n):
    if(i < a):
        number = ls[a].number
        index = ls[i].index
    else:
        number = ls[a - 1].number
        index = ls[i].index
    output += [abc(index, number)]

output.sort(key = lambda abc:abc.index)

for i in range(n):
    print(output[i].number)

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

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

Solution (Python):
n = int(input())
x = [int(i) for i in input().split()]
 
 
import statistics
a = statistics.median(sorted(x)[0:len(x)-1])
b = statistics.median(sorted(x)[1:len(x)])
for i in x:
    if i > a:
        print(a)
    else:
        print(b)

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

Solution (Python):
def main():
    N = int(input())
    X = list(map(int, input().split()))
    sx = sorted(X)
    left = sx[N // 2 - 1]
    right = sx[N // 2]
    for x in X:
        if right > x:
            print(right)
        else:
            print(left)


main()

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

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

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
Y.append(0)
midg = Y[(N + 1) // 2]
midl = Y[(N + 1) // 2 - 1]
for i in range(N):
    if X[i] < midg:
        print(midg)
    elif X[i] >= midl:
        print(midl)

Solution (Python):
N = input()

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

data = []
for i in X:
    data.append(i)

data.sort()

for i in X:
    if i < data[N/2]:
        print data[N/2]
    else:
        print data[N/2-1]

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

D = {}
for x in X:
    if x in D.keys():
        D[x] += 1
    else:
        D[x] = 1

l = [[0,0]]
for i,d in enumerate(sorted(D.items())):
    l.append([d[0],l[i][1]+d[1]])
    if l[i][1]+d[1] >= N/2+1:
        break
m2 = l[-1][0]
if l[-2][1] == N/2:
    m1 = l[-2][0]
else:
    m1 = m2

b = (m1+m2)/2
for x in X:
    if x <= b:
        print(m2)
    else:
        print(m1)

Solution (Python):
import bisect
n = int(input())
a = list(int(i) for i in input().split())
a2 = sorted(a)
median1 = a2[n//2-1]
median2 = a2[n//2]
for i in a:
  if i <= median1:
    print(median2)
  else:
    print(median1)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
M = sorted(L)
medi1 = M[N//2-1]
medi2 = M[N//2]

for x in L:
    if x <= medi1:
        ans = medi2
    else:
        ans = medi1
    print(ans)

Solution (Python):
N = int(input())
L = list(map(int, input().split()))
M = sorted(L)
medi1 = M[N//2-1]
medi2 = M[N//2]

for x in L:
    if x <= medi1:
        ans = medi2
    else:
        ans = medi1
    print(ans)

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

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

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

Solution (Python):
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
l, r = Y[N//2-1], Y[N//2]
A = []
for i in range(N):
    if X[i] <= l:
        A.append(r)
    else:
        A.append(l)
print('\n'.join(map(str, A)))