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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

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
#print median

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]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
List=list(map(int,input().split()))
AList=List[:]
List.sort()
div=List[N//2]
backdiv=List[N//2-1]
for indexnum in AList:
    if div > indexnum:
        print(div)
    else:
        print(backdiv)

Submission status: Accepted

Solution code:
n=int(input())
x=[int(i) for i in input().split()]
y=sorted(x)
m=y[n//2]
l=y[(n//2)-1]
for i in x:
    print(m if i < m else l)

Submission status: Accepted

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

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

Submission status: Accepted

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

le = len(x)
m_idx = le // 2 - 1
m0 = (x_s[m_idx]+x_s[m_idx+1]) / 2

for i in range(len(x)):
    if x[i] == m0:
        print(x[i])

    elif x[i] < m0:
        print(x_s[m_idx+1])

    elif x[i] > m0:
        print(x_s[m_idx])

Submission status: Accepted

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

sX = sorted(X)
d = N // 2
a = sX[d]
b = sX[d - 1]

for c in X:
    print(a if c < a else b)

Submission status: Accepted

Solution code:
n=int(input())
x=list(map(int, input().split()))
xs=sorted(x)
n1=int(n/2)-1
n2=n1+1

for xi in x:
    if xi<=xs[n1]:
        print(xs[n2])
    else:
        print(xs[n1])

Submission status: Accepted

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

Xsort = sorted(X)
lmedian = Xsort[int(N/2) - 1]
rmedian = Xsort[int(N/2)]

for x in X:
	print (rmedian if x <= lmedian else lmedian)

Submission status: Accepted

Solution code:
import copy

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

x_original_order = copy.deepcopy(x)

x.sort()
large = x[int(n/2)]
small = x[int(n/2)-1]

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

Submission status: Accepted

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

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

# solve
X_sorted = sorted(X)
n0 = X_sorted[int(len(X_sorted)/2-1)]
n1 = X_sorted[int(len(X_sorted)/2)]
for i in range(len(X)):
    if (n1 > X[i]):
        print(n1)
    elif (n0 <= X[i]):
        print(n0)

Submission status: Accepted

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

a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]

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

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int,input().split()))
L = sorted(X)
for i,j in enumerate(X):
    if L[N//2]>j:
        print(L[N//2])
    else:
        print(L[N//2-1])

Submission status: Accepted

Solution code:
N=input()
X=map(int, raw_input().split())
S=[]
for idx,i in enumerate(X):
	S.append( (i,idx) )

a=sorted(S, key=lambda x: x[0], reverse=True)


ans=[ 0 for i in range(N)]
for i in range(N):

	val=a[i][0]
	pntr=a[i][1]

	l=i-0
	if (N+1)/2-l>0:
		diff=(N+1)/2-l
	else:
		diff=(N+1)/2-l-1

	ans[pntr]=a[i+diff][0]

for i in ans:
	print i

Submission status: Accepted

Solution code:
n = int(input())
array = [int(x) for x in input().split()]
sort_array = sorted(array)

tmp = n//2

tmp_array = sort_array[tmp-1:tmp+1]

for i in array:
    if i <= tmp_array[0]:
        print(tmp_array[1])
    else:
        print(tmp_array[0])

Submission status: Accepted

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

X_sort = sorted(X)
t = X_sort[len(X)//2]

for i in X:
    if i < t:
        print(X_sort[len(X)//2])
    else: print(X_sort[len(X)//2-1])

Submission status: Accepted

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

# 2.check half- and half+
x_copy = sorted(x, reverse=False)
half = int(n/2)
half_minus = x_copy[half-1]
half_plus = x_copy[half]


# 3. judge
#    if removed number is smaller than or equal to half- -> half+
#    else -> half-
for xi in x:
    if xi <= half_minus:
        print(half_plus)
    else:
        print(half_minus)

Submission status: Accepted

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

a = len(x)
b = sorted(x)
fa = b[int((a/2)-1)]
se = b[int(a/2)]

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

Submission status: Accepted

Solution code:
N = int(input())
array = list(map(int, input().split()))
test = list(array)
test.sort()
wow = test[int(N / 2) - 1: int(N / 2) + 1]
for i in range(0, N):
    if array[i] > wow[0]:
        print(wow[0])
    else:
        print(wow[1])

Submission status: Accepted

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

Submission status: Accepted

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

y = sorted(x, reverse=True)
mid = int(n / 2) - 1

for i in x:
    if(i >= y[mid]):
        if(mid + 1 != n):
            print(y[mid+1])
        else:
            print(y[mid])
    else:
        print(y[mid])

Submission status: Accepted

Solution code:
import copy
n = int(input())
nums = list(map(int,input().split()))
tmp = copy.deepcopy(nums)
tmp.sort()
cand1 = tmp[n//2]
cand2 = tmp[(n//2)-1]
for i in range(n):
    if nums[i] < cand1:
        print(cand1)
    else:
        print(cand2)

Submission status: Accepted

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

import copy

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

    t = copy.deepcopy(x)
    t.remove(min(x))
    t.sort()
    m1 = t[int(n / 2 - 1)]
    t = copy.deepcopy(x)
    t.remove(max(x))
    t.sort()
    m2 = t[int(n / 2 - 1)]
    for i in range(n):
        print(m1 if x[i] < m1 else m2)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import median


N = int(input())
X = list(map(int, input().split()))
medi_X = median(X)
sort_X = sorted(X)

for x in X:
    if x < medi_X:
        print(sort_X[int((N + 1) / 2)])
    else:
        print(sort_X[int(((N + 1) / 2) - 1)])

Submission status: Accepted

Solution code:
N = int(input())
n = int(N/2)

li = list(map(int,input().split()))
li_s = sorted(li)

A = li_s[n-1]
B = li_s[n]

for i in range(N):
    if li[i] <=A:
        print(B)
    else:
        print(A)

Submission status: Accepted

Solution code:
import bisect


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N = get_next_int()
    X = get_next_ints()

    x_sorted = sorted(X)
    med_index = int((N-1)/2)
    # print(med_index, x_sorted)
    for num in X:
        index = bisect.bisect(x_sorted, num)-1
        if index > med_index:
            print(x_sorted[med_index])
        else:
            print(x_sorted[med_index+1])



solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def medians(nums):
    n = len(nums)
    num_orig_pos = list(zip(nums, range(n)))
    nums_sorted = sorted(num_orig_pos)
    medians = []
    med_left = nums_sorted[(n + 1)//2][0]
    med_right = nums_sorted[(n + 1)//2 - 1][0]
    for i in range((n + 1)//2):
        medians.append((med_left, nums_sorted[i][1]))
    for i in range((n + 1)//2, n):
        medians.append((med_right, nums_sorted[i][1]))
    return map(lambda x: x[0], sorted(medians, key=lambda x: x[1]))


if __name__ == '__main__':
    _ = input()
    nums = list(map(int, input().split()))
    for i in medians(nums):
        print(i)

Submission status: Accepted

Solution code:
import copy

n = int(input())
x = list(map(int,input().split()))
lst = copy.deepcopy(x)
lst.sort()
med_l = lst[n//2-1]
med_r = lst[n//2]

for i in range(len(x)):
    if x[i]<=med_l: print(med_r)
    else: print(med_l)

Submission status: Accepted

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

b=sorted(x)[int(n/2)]
s=sorted(x)[int(n/2-1)]

for i in x:
    if i<b:
        print(b)
    else:
        print(s)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	n = int(input())
	x = [int(x) for x in input().split(' ')]

	sx = sorted(x)
	med = sx[int(n/2)]
	medl = sx[int(n/2-1)]

	for i in range(n):
		if x[i] < med:
			print(med)
		else:
			print(medl)

Submission status: Accepted

Solution code:
size =  int(input().strip())
nums  = list(map(int, input().strip().split(' ')))
sortedNums = sorted(nums)
x1 = sortedNums[int(size/2-1)]
x2 = sortedNums[int(size/2)]
for i in nums:
    if(x1 == x2):
        print(x1)
    elif (i>=x2):
        print(x1)
    else:
        print(x2)

Submission status: Accepted

Solution code:
def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        tf = nums[0] >= x[i]
        print(nums[tf])


abc094C()

Submission status: Accepted

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

X_sort = sorted(X)
small, big = X_sort[N//2-1], X_sort[N//2]

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

Submission status: Accepted

Solution code:
N = int(input())

li = list(map(int,input().split()))
copiedListForSort = li.copy()
copiedListForSort.sort()

firstMedian = copiedListForSort[N//2 - 1]
secondMedian = copiedListForSort[N//2]
for i in range(N):
    if li[i] >= secondMedian:
        print(firstMedian)
    else:
        print(secondMedian)

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
X = list(map(int, input().split()))

X_sort = sorted(X)
small, big = X_sort[N//2-1], X_sort[N//2]

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

Submission status: Accepted

Solution code:
import copy

N = int(input())
num = list(map(int,input().split()))
memo = copy.deepcopy(num)
num.sort()

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

Submission status: Accepted

Solution code:
N = int(input())
X = tuple(int(x) for x in input().split())
length = len(X)
med = sorted(X)[length//2-1:length//2+1]
for x in X:
 print(med[1] if x < sum(med)/2 else med[0])

Submission status: Accepted

Solution code:
N = int(input())
numList = list(map(int, input().split()))
sortedList = sorted(numList)
center = N // 2
left_median = sortedList[center - 1]
right_median = sortedList[center]

answer = [str(left_median) if i >= right_median else str(right_median) for i in numList]
print("\n".join(answer))

Submission status: Accepted

Solution code:
# coding=utf-8


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

X_list2 = X_list[:]
X_list2.sort()
smaller = X_list2[N//2 -1]
larger = X_list2[N//2]

for element in X_list:
    if element <= smaller:
        print(larger)
    else:
        print(smaller)

Submission status: Accepted

Solution code:
N = int(input())
INPUT = input()
X_list = list(map(int, INPUT.split()))
X_sorted = sorted(X_list)
criterion = X_sorted[int(N / 2 - 1)]

for i in range(N):
    if X_list[i] > criterion:
        print(criterion)
    else:
        print(X_sorted[int(N / 2)])

Submission status: Accepted

Solution code:
import copy

N=int(input())
X=list(map(int,input().split(" ")))
Y=copy.deepcopy(X)
Y.sort()
a=Y[N//2]
b=Y[N//2-1]
for i in X:
  if i<=b:
    print(a)
  else:
    print(b)

Submission status: Accepted

Solution code:
import math
n = int(input())
lis = list(map(int,input().split()))
li = sorted(lis)
ans2 = li[math.ceil((n-1)/2)]
cou2 = lis.count(ans2)
ans1 = li[math.floor((n-1)/2)]
cou1 = lis.count(ans1)
for i in range(n):
	if lis[i] >= ans2:
		print(ans1)
	else:
		print(ans2)

Submission status: Accepted

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

mid_left = sortx[(n//2)-1]
mid_right = sortx[(n//2)]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = [i for i in map(int ,input().split())]
mid = N // 2
tmp = x[:]
tmp.sort()
for i in range(N):
    if tmp[mid] <= x[i]:
        print(tmp[mid-1])
    else:
        print(tmp[mid])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    X = tuple(map(int, input().split()))

    x2 = sorted(X)
    mid1 = x2[N//2 - 1]
    mid2 = x2[N//2]
    for i in X:
        if i < mid2:
            print(mid2)
        else:
            print(mid1)

main()

Submission status: Accepted

Solution code:
import sys
if __name__ == "__main__":
    N = int(input())
    X = list(map(int, (input().split(' '))))
    buf = sorted(X)
    for i in range(N):
#        buf = list(X)
#        buf.pop(i)
#        buf = sorted(buf)
#        print(X[i])
#        print(buf[int(N/2)])
        if X[i] < buf[int(N/2)]:
            print(buf[int(N/2)])
        else:
            print(buf[int(N/2)-1])

Submission status: Accepted

Solution code:
n= int(input())
m = int(n//2)
data = [int(i) for i in input().split()]

sdata = sorted(data)


for i in range(n):
    if data[i] < sdata[m]:
        print(sdata[m])
    else:
        print(sdata[m-1])

Submission status: Accepted

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

sort=sorted(X)

a=int(N/2-1)
b=int(N/2)

A=sort[a]
B=sort[b]

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = X[:]
Y.sort()
p = int(N/2)

if Y[p-1] == Y[p]:
    flag = 1
else:
    flag = 0



for i in range(N):
    if flag == 1:
        print(Y[p])
    else:
        if X[i]<=Y[p-1]:
            print(Y[p])
        else:
            print(Y[p-1])

Submission status: Accepted

Solution code:

N = int(input())
X = [0]*N
X = list(map(int, input().split()))
Y = X[:]
hoge = 0

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

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
s = sorted(X)
midu = s[int(N/2)]
midd = s[int(N/2 - 1)]

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

Submission status: Accepted

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

xs_arranged = sorted(xs)
l = int(n/2 - 1)
a1,a2 = xs_arranged[l],xs_arranged[l+1]
base = (a1+a2)/2
    
for i in xs:
    if i < base:
        print(a2)
    else:
        print(a1)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int, input().split()))
d = dict(zip(range(0,n), x))
x.sort()
for i in range(0, n):
    if d[i] <= x[n//2-1] :
        print(x[n//2])
    else :
        print(x[n//2-1])

Submission status: Accepted

Solution code:
import numpy as np

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

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

for x in X:
    if x <= a:
        print(b)
    else:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())
x = list(map(int,input().split()))
import numpy as np
import copy
md = np.median(x)
x_c = copy.copy(x)
x_c.sort()
a = x_c[int(n/2 - 1)]
b = x_c[int(n/2)]
for i in range(n):
    if x[i] < md:
        print(b)
    else:
        print(a)

Submission status: Accepted

Solution code:
import sys
import numpy as np

N = int(sys.stdin.readline().strip())
s = int(N / 2)
x = np.array(list(map(lambda x: int(x), sys.stdin.readline().strip().split(" "))))
index_list = np.argsort(x)

array_x = sorted(x)

a = array_x[s]

for i in range(N):
    if x[i] < a:
        print(array_x[s])
    else:
        print(array_x[s-1])

Submission status: Accepted

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

x_sorted = sorted(x)
length = len(x) - 1
center_min = x_sorted[(length - 1) // 2]
center_max = x_sorted[(length + 1) // 2]
for elem in x:
    if elem <= center_min:
        print(center_max)
    else:
        print(center_min)

Submission status: Accepted

Solution code:
n = int(input())
x=[int(i) for i in input().split()]
sorted_x = sorted(x)
min = sorted_x[int((n/2)-1)]
max = sorted_x[int(n/2)] 

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

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int, input().split()))
tmp = X[:]
tmp.sort()
left, right = (tmp[N // 2 - 1], tmp[N // 2])
for i in range(N):
    if X[i] > left:
        print(left)
    else:
        print(right)

Submission status: Accepted

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

n = int(input())

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

sorted_x = sorted(x)

before_half = sorted_x[n//2 - 1]
after_half = sorted_x[n//2]

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

Submission status: Accepted

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

Submission status: Accepted

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

xx = sorted(X)
a = xx[N//2-1]
b = xx[N//2]

for i in X:
   if i <= a:
      print(b)
   else:
      print(a)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
x = na()
xx = sorted(x, reverse=True)
mid = n // 2 - 1
ans = xx[mid]
for i in range(n):
    if x[i] >= ans:
        print(xx[mid+1])
    else:
        print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Xs = sorted(X)
median1 = Xs[int(N/2)-1]
median2 = Xs[int(N/2)]

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

Submission status: Accepted

Solution code:
n = int(input())
x = [int(x) for x in input().split()]
x_sorted = sorted(x)

m_large = x_sorted[n // 2]
m_small = x_sorted[n // 2 - 1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import statistics

n=int(input())
li= list(map(int,input().split()))
lmedi=statistics.median_low(li)
hmedi=statistics.median_high(li)
for xn in li:
    if xn<=lmedi:
        print(hmedi)
    else:
        print(lmedi)

Submission status: Accepted

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

N = int(input())
Xs = list(map(int, input().split(' ')))
sortX = sorted(Xs)
B1 = sortX[int(N / 2 - 1)]
B2 = sortX[int(N / 2)]


for X in Xs:
    if X <= B1:
        print(B2)
    else:
        print(B1)

Submission status: Accepted

Solution code:
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))
    sorted_A = sorted(A)

    l_left = N/2
    l_right = N/2 + 1
    for i in range(1, N + 1):
        if A[i - 1] <= sorted_A[l_left - 1]:
            print sorted_A[l_right - 1]
        else:
            print sorted_A[l_left - 1]


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
X = list(map(int,input().split()))
B = [i for i in X]
B.sort()
mid_s = B[int(N/2)-1]
mid_l = B[int(N/2)]
for i in range(N):
    if X[i] <= mid_s:
        print(mid_l)
    elif X[i] >= mid_l:
        print(mid_s)

Submission status: Accepted

Solution code:
from bisect import *
from operator import *
from statistics import *

n = int(input())
x = list(map(int, input().split()))
med_low = median_low(x)
med_high = median_high(x)
x_sorted = sorted(x)

for i in range(n):
    if bisect_left(x_sorted, x[i]) < n/2:
        print(med_high)
    else:
        print(med_low)

Submission status: Accepted

Solution code:
n = input()
x = map(int, raw_input().split())
x2 = sorted(x)
mid1 = x2[(n/2)-1]
mid2 = x2[n/2]
if mid1 == mid2:
    for i in xrange(n):
        print mid1
else:
    for i in xrange(n):
        if x[i] <= mid1:
            print mid2
        else:
            print mid1

Submission status: Accepted

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

Ami=Ans[N//2-1]
Ama=Ans[N//2]

for i in range(N):
  if A[i]<=Ami:
    print(Ama)
  else:
    print(Ami)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
n=int(input())
nn=n//2
x=[int(i) for i in input().split()]
y=x[:]
x.sort()

low_median=median(x[:n-1])
high_median=median(x[1:])

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

Submission status: Accepted

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

Submission status: Accepted

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

X_s = sorted(X)

m1 = X_s[N//2 - 1]
m2 = X_s[N//2]

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    X_sorted = sorted(X)

    median_candidates = X_sorted[(N // 2 - 1)], X_sorted[N // 2]
    for X_i in X:
        if X_i < median_candidates[1]:
            print(median_candidates[1])
        else:
            print(median_candidates[0])

Submission status: Accepted

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

A = x.copy()
A.sort()
a1 = A[int(len(x)/2)]
a2 = A[int(len(x)/2)-1]
for i in range(n):
    if x[i] < a1:
        print(a1)
    else:
        print(a2)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    X_sorted = sorted(X)

    cand1 = X_sorted[N // 2 - 1]
    cand2 = X_sorted[N // 2]

    for target in X:
        if cand1 >= target:
            print(cand2)
        else:
            print(cand1)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input().rstrip())
X=list(map(int, input().rstrip().split())) #input parameters
work=[]
for i in range(N):
    work.append(X[i])
work.sort()
m=int(N/2)
for i in range(N):
    if X[i]<=work[m-1]:
        print(work[m])
    else:
        print(work[m-1])

Submission status: Accepted

Solution code:
N = int(input())
X_LIST = list(map(int, input().split()))

mid = sorted(X_LIST)[int(N / 2) - 1]
next_mid = sorted(X_LIST)[int(N / 2)]

for x in X_LIST:
    if x <= mid:
        print(next_mid)
    else:
        print(mid)

Submission status: Accepted

Solution code:
# coding : utf-8

import numpy as np

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

Xed = sorted(X)

t1 = Xed[int(N/2)-1]
t2 = Xed[int(N/2)]

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

Submission status: Accepted

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

Submission status: Accepted

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

sx = sorted(X)
a = sx[N // 2 - 1]
b = sx[N // 2]

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

Submission status: Accepted

Solution code:
n=int(input())
lst1=list(map(int,input().split()))
lst2=sorted(lst1)
left=lst2[int(n/2)-1]
right=lst2[int(n/2)]
for num in lst1:
    if num<=left:
        print(right)
    else:
        print(left)

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))
N = int(input())
X = inpl()


sX = sorted(X)
a, b = sX[N//2-1], sX[N//2]
for i in X:
    if i==a and i==b:
        print(a)
    elif i<=a:
        print(b)
    else:
        print(a)

Submission status: Accepted

Solution code:
n = int(input())
xlst = list(map(int,input().split()))
lst2 = [i for i in xlst]
xlst.sort()
l = xlst[n//2 - 1]
r = xlst[n//2]
for i in range(n):
  if lst2[i] <= l:
    print(r)
  else:
    print(l)

Submission status: Accepted

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

Y = sorted(X)
right_center = Y[N // 2]
left_center = Y[N // 2 - 1]
for i in X:
    if i < right_center:
        print(right_center)
    elif i > left_center:
        print(left_center)
    # 中央値がどちらも同じだった場合
    elif i == right_center:
        print(right_center)

Submission status: Accepted

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

Submission status: Accepted

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