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



Sample input:
4
2 4 4 3


Sample output:
4
3
3
4

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: UTF-8
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
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

#A
def A():
    return

#B
def B():
    return

#C
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

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
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

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

#B
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)

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

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

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

#F
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])

#G
def G():
    return

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Accepted

Solution code:
N=int(input())
X=map(int,input().split())
X2 = [(x,i) for i,x in enumerate(X)]
X2.sort()
# 1 2 3 4 5 6
#     3 * * *
# * * * 4    
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])

Submission status: Accepted

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

Submission status: Accepted

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

idx = N // 2
center1 = Si[idx - 1] #N>=2なのでoutofboundsにはならない
center2 = Si[idx]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/16
@author: shinjisu
"""


# ABC 095 C Half and Half
#import math
#import numpy as np

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

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

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 # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((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:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
N = int(input())
X  = list(map(int,input().split()))
X2 = copy.copy(X)
X2.sort()
#print(X2)
mp =  X2[- (N ) // 2]
mp2 =  X2[- (N + 2) // 2]
for Xi in X:
    if Xi >= mp:
        print(mp2)
    else:
        print(mp)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# encoding:utf-8
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])

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC095C
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]) #ascending
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]) #input oder
for i in range(N):
	if A[i][2]>=N//2:
		print(x)
	else:
		print(y)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from statistics import median_low, median_high
# ----------------------------------------------------------------
# Use Solve Function

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 !!
#
solve(lines)

Submission status: Accepted

Solution code:
# C

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)

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math
import numpy as np

#### START
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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]

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
L = list(map(int, input().split()))
M = sorted(L)
medi1 = M[N//2-1]
medi2 = M[N//2]
#print(medi1,medi2)
for x in L:
    if x <= medi1:
        ans = medi2
    else:
        ans = medi1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)
        # A.append(r)
    else:
        print(l)
        # A.append(l)
# print('\n'.join(map(str, A)))

Submission status: Accepted

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

Submission status: Accepted

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

sort_x=sorted(x)

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

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)
med = sortA[n // 2]

for i in range(n):
    if A[i] < med:
        print(med)
    else:
        print(sortA[n // 2 - 1])

Submission status: Accepted

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

Y = sorted(X)

Bright = Y[N//2]
Bleft = Y[N//2-1]

for i in X:
    if i<=Bleft:
        print(Bright)
    else:
        print(Bleft)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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

    Y = sorted(X)
    m0, m1 = Y[int(N / 2) - 1], Y[int(N / 2)]

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)

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

Submission status: Accepted

Solution code:
N = int(input())
x = {}
ans = {}
y = []
k = 1
l = 1
for i in list(map(int,input().split())):
    x[k] = i
    y.append(i)
    k += 1

y.sort()
m_1 = y[int(N/2)]
m_2 = y[int(N/2)-1]

for i,j in sorted(x.items(),key = lambda x: x[1]):
    if (int(N/2) >= l):
        ans[i] = m_1
        l+=1
    else:
        ans[i] = m_2
        l+=1

for i,j in sorted(ans.items()):
    print(j)

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]
sortA = sorted(A)

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

Submission status: Accepted

Solution code:
N = int(input())
X = [int(i) for i in input().split()]
x = sorted(X)
num1 = x[N//2]
num2 = x[N//2 - 1]
ans = []
for i in X:
    if i <= num2:
        ans.append(num1)
    else:
        ans.append(num2)
for i in ans:
    print(i)

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int,input().split()))
import copy
Y = copy.deepcopy(X)
Y.sort()
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)

Submission status: Accepted

Solution code:
n = int(input())
X = [int(i) for i in input().split()]
sortX = sorted(X, reverse=True)
m1 = sortX[n // 2 - 1]
m2 = sortX[n // 2]

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

Submission status: Accepted

Solution code:
import statistics
N = list(map(int,input().split()))
l = list(map(int,input().split()))

a = statistics.median_low(l)
b = statistics.median_high(l)

for i in l:
  if i <= a:
    print(b)
  elif i >= b:
    print(a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

aN2 = sorted(aN)

if aN2[N//2-1] == aN2[N//2]:
	for i in range(N):
		print(aN2[N//2])
else:
	for i in range(N):
		if aN[i] < aN2[N//2]:
			print(aN2[N//2])
		else:
			print(aN2[N//2-1])

Submission status: Accepted

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

sortA = sorted(A)
mid = sortA[n//2 - 1]
midnext = sortA[n//2]

for i in range(n):
    if A[i] <= mid:
        print(midnext)
    else:
        print(mid)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
y = list(x)
y.sort()
if n % 2 != 0:
    a,b,c = y[n//2-1],y[n//2],y[n//2+1]
    m = b
else:
    a,b = y[n//2-1],y[n//2]    
    m = (a+b)/2
for i in range(n):
    if i == n//2:
        if n%2==0:
            tm = a
        else:
            tm = (a+c)/2
    if x[i] < m :
        if n%2==0:
            tm = b
        else:
            tm = (b+c)/2
    else:
        if n%2==0:
            tm = a
        else:
            tm = (a+b)/2
    print(int(tm))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
sortA = sorted(A)

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

Submission status: Accepted

Solution code:
import math
n = int(input())
X = list(map(int,input().split()))
x = sorted(X)

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

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

Submission status: Accepted

Solution code:
N = int(input())
inputs = [int(i) for i in input().split()]

sorted_inputs = inputs[:]
sorted_inputs.sort()
left = sorted_inputs[N//2-1]
right = sorted_inputs[N//2]

for item in inputs:
    if item <= left:
        print(right)
    else:
        print(left)

Submission status: Accepted

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

b=sorted(a)

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