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: Wrong Answer

Solution code:
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2-1]
med2 = Y[N//2]
##print("med1:",med1,"med2",med2)
for i in range(N):
    if X[i] == med2:
        print(med1)
    else:
        print(med2)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2]
med2 = Y[N//2-1]
##print("med1:",med1,"med2",med2)
for i in range(N):
    if i  == N//2 -1 or i == N//2:
        print(med2)
    else:
        print(med1)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

N = int(input())
X = list(map(int,input().split()))
Y = deepcopy(X)
Y.sort()
med1 = Y[N//2]
med2 = Y[N//2-1]
print("med1:",med1,"med2",med2)
for i in range(N):
    if i  == N//2 -1 or i == N//2:
        print(med2)
    else:
        print(med1)

Submission status: Wrong Answer

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

S = sorted(X)
print(S)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
X = list(map(int, input().split()))
X_mid = sorted(X)[n//2 - 1: n//2 + 1]
print(X_mid)
for i in X:
    print(X_mid[i <= X_mid[0]])  # Falseなら1、Trueなら0

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
m=n//2
x=sorted(map(int,input().split()))

for i in range(m):
    print(x[m-1])
for i in range(m,n):
    print(x[m])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if i <= (N / 2) - 1:
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Submission status: Wrong Answer

Solution code:
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if i < (N / 2) - 1:
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Submission status: Wrong Answer

Solution code:
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if li[i] <= m:
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Submission status: Wrong Answer

Solution code:
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if li[i] < m:
    print(new[math.floor(N/2)])
  else:
    print(new[math.floor(N/2) - 1])

Submission status: Wrong Answer

Solution code:
import math

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

m = sum(li) / N

new = sorted(li)

for i in range(N):
  if li[i] < m:
    print(new[math.floor(N/2+1) - 1])
  else:
    print(new[math.floor(N/2-1)])

Submission status: Wrong Answer

Solution code:
N = input()
problemList = input().split()
currentList = []

for i in range(int(N)):
  for n in range(int(N)):
    currentList.append(problemList[n])
  del currentList[i]
  sortedList = sorted(currentList, reverse = True)
  CentralNumber = int(int(N) / 2) - 1
  print(sortedList[CentralNumber])
  currentList = []

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
x = list(map(int,input().split()))
a = sorted(x)
base = a[n//2]
for i in range(n):
    if x[i] > a[n//2-1] or (x[i] == a[n//2-1] and a.count(x[i]) > 1): print(a[n//2-1])
    else: print(a[n//2])

Submission status: Wrong Answer

Solution code:
import statistics
from collections import deque

d = deque()

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

print(d)

for i in range(a):
  b = d.pop(0)
  print(statistics.median(d))
  d.append(b)
#  print(d)

Submission status: Wrong Answer

Solution code:
import copy

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

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

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Xs = list(map(int, input().split()))
sXs = sorted(Xs)
m1 = sXs[N//2]     # 前半のメジアン (i<=m1)
m2 = sXs[N//2 - 1] # 後半のメジアン
print(m1,m2)
if m1 == m2:
    for i in range(N):
        print(m1)
else:
    for x in Xs:
        if x <= m2:
            print(m1)
        else:
            print(m2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

    for idx in sortedIdx:
        if sortedIdx[idx] <= midlIdx:
            print(midrVal)
        else:
            print(midlVal)
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# Median calculation is executed fist time only
import sys

sys_input = sys.stdin.readline

N = input()
XXX = list(map(int, sys_input().split()))

XXX_sorted = sorted(XXX)
init_median = XXX_sorted[1:][len(XXX) // 2 - 1]
print(init_median)

last_median = init_median
last_X = XXX[0]
last_cursor = len(XXX) // 2 - 1 if last_median < XXX[0] else len(XXX) // 2
for X in XXX[1:]:
    flg1 = last_X > last_median >= X
    flg2 = last_X < last_median <= X
    if flg1:
        last_cursor += 1
        last_median = XXX_sorted[last_cursor]
    if flg2:
        last_cursor -= 1
        last_median = XXX_sorted[last_cursor]
    print(last_median)
    last_X = X

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#many medians
n=int(input())
B=list(map(int,input().split()))
C=B.copy()
B=sorted(B)
median1=B[n//2]
median2=B[n//2-1]
if median1==median2:
    for _ in range(n):
        print(median1)
elif median1<median2:
    for i in range(n):
        if i>=n//2-1:
            print(median1)
        elif i<n//2-1:
            print(median2)

Submission status: Wrong Answer

Solution code:
#many medians
n=int(input())
B=list(map(int,input().split()))
C=B.copy()
B=sorted(B)
median1=B[n//2]
median2=B[n//2-1]
if median1==median2:
    for _ in range(n):
        print(median1)
elif median1<median2:
    for i in range(n):
        if i>=n//2:
            print(median1)
        elif i<n//2:
            print(median2)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()
X=many_int()

sort_X=sorted(X)

med_min1 = sort_X[(len(sort_X)//2)-1]
med_plus1 = sort_X[(len(sort_X)//2)]


for i in X:
    if i >= med_plus1:
        print(med_min1)
    elif i < med_min1:
        print(med_plus1)

Submission status: Wrong Answer

Solution code:
import copy

import numpy as np


def main():
    N = int(input())
    X = np.array(list(map(int, input().split())))
    m = np.median(X)

    XX = copy.deepcopy(X)
    mm = np.argmin(X)
    XX = np.delete(XX, mm)
    m0 = np.median(XX)

    XX = copy.deepcopy(X)
    mm = np.argmax(X)
    XX = np.delete(XX, mm)
    m1 = np.median(XX)

    for x in X:
        if x <= m:
            print(m0)
        else:
            print(m1)


main()

Submission status: Wrong Answer

Solution code:
import itertools
import statistics
import math

n = int(input())
x = list(map(int,input().split()))
b = []
for i in itertools.combinations(x,int(n-1)):
    tmp = statistics.median(i)
    b.append(tmp)
for i in b:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [0] + list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Xlist = list(map(int, input().split()))
a, mean = sorted(Xlist)[N // 2 - 1:N // 2 + 1]
from collections import Counter
c = Counter(Xlist)
for X in Xlist:
    if X == mean and c[X] >= 1:
        print(a)
    else:
        print(mean)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#094c
import copy
N = int(input())
X_list = [int(e) for e in input().split()]

#l が奇数のとき，l 個の数 a1,a2,...,al の中央値とは，a1,a2,...,al の中で (l+1)/2番目に大きい値のことを言います．
#N個の数 X1,X2,...,XN が与えられます．ここで，N は偶数です． 
#i=1,2,...,N に対して，X1,X2,...,XN から Xi のみを除いたもの，すなわち X1,X2,...,Xi−1,Xi+1,...,XN の中央値を Biとします．
#i=1,2,...,Nに対して，Bi を求めてください．

#listのコピーはcopy使わないと、元のものまで変わってしまうので注意
X_list_sorted = copy.copy(X_list)

#初期状態での中央値(仮)を求める。偶数なので2通り出る。
X_list_sorted.sort(reverse = False)
bigger_B = X_list_sorted[N//2]
smaller_B = X_list_sorted[N//2 - 1]

print(X_list_sorted)
print(smaller_B,bigger_B)

for i in range(N):
    excluded_value = X_list[i]
    if excluded_value <= smaller_B:
        print(bigger_B)
    else:
        print(smaller_B)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(list(map(int,input().split())))
for i in range(1,n):
  tmp=x[:i-1]+x[i:]
  #print(tmp)
  print(tmp[(len(tmp)-1)//2])

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
for i in range(1,n):
  tmp=x[:i-1]+x[i:]
  #print(tmp)
  print(tmp[(len(tmp)-1)//2])

Submission status: Wrong Answer

Solution code:
from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
print(median(X))

Submission status: Wrong Answer

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

sorted_X = sorted(X)

left_med = sorted_X[N//2 -1]
X_left = sorted_X[0 : N//2]
right_mid = sorted_X[N//2]
X_right = sorted_X[N//2 : N]

for i in range(N):
    if X[i] in X_left:
        print(left_med)
    else:
        print(right_mid)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline

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

x_sorted=sorted(x)
c = (x_sorted[n//2-1]+x_sorted[n//2])/2
print(x_sorted)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
list_x = list(map(int, input().split()))
sub_list = sorted(list_x)

for one_x in list_x:
  idx = sub_list.index(one_x)
  if idx < n / 2:
    print(sub_list[int(n/2)-1])
  else:
    print(sub_list[int(n/2)])

Submission status: Wrong Answer

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

x_sorted = sorted(x)
l = x_sorted[n//2]
s = x_sorted[n//2-1]

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

Submission status: Wrong Answer

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

X_sort=sorted(X)

if X_sort[N//2-1]==X_sort[N//2]:
    for n in range(N):
        print(X_sort[N//2])
else:
    if X_sort.count(X_sort[N//2-1])==1:
        for n in range(N):
            if X[n]>X_sort[N//2-1]:
                print(X_sort[N//2-1])
            elif X[n]==X_sort[N//2-1]:
                print(X_sort[N//2-2])
            else:
                print(X_sort[N//2])
    else:
        for n in range(N):
            print(X_sort[N//2-1])

Submission status: Wrong Answer

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

X_sort=sorted(X)

if X_sort[N//2-1]==X_sort[N//2]:
    for n in range(N):
        print(X_sort[N//2])
else:
    if X_sort.count(X_sort[N//2-1])==1:
        for n in range(N):
            if X[n]>X_sort[N//2-1]:
                print(X_sort[N//2-1])
            else:
                print(X_sort[N//2])
    else:
        for n in range(N):
            print(X_sort[N//2-1])

Submission status: Wrong Answer

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

def getMedian(a):
    a = sorted(a)
    idx = (len(a)+1)//2-1
    return idx, a[idx]

idx, m = getMedian(x)



for i in range(n):
    if x[i] > m:
        print(m)
    elif x[i] == m:
        print(x[idx+1])
    else:
        print(x[idx+1])

Submission status: Wrong Answer

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

def getMedian(a):
    a = sorted(a)
    idx = (len(a)+1)//2-1
    return idx, a[idx]

idx, m = getMedian(x)

print(idx, m)

for i in range(n):
    if x[i] > m:
        print(m)
    elif x[i] == m:
        print(x[idx+1])
    else:
        print(x[idx+1])

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n==2:
    print(l[1],l[0])
    exit()
m=max(l)
k=m//2
if m%2==1:
    k+=1
i=bisect.bisect_left(l,k)
if abs(l[i]-k)<=abs(l[i+1]-k):
    print(m,l[i])
else:
    print(m,l[i+1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
X = list(map(int, input().split()))
X_sort = sorted(X)
med = X_sort[N//2]
for x in X:
    if x == med:
        print(X_sort[N//2-1])
    else:
        print(med)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[[a[i],i] for i in range(N)]
b.sort()
ans=[b[N//2][0],b[(N//2) -1][0]]

for i in range(N):
  if a[i] >= ans[1]:
    print(ans[0])
  else:
    print(ans[1])

Submission status: Wrong Answer

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

X.sort()
median1=X[n//2-1]
median2=X[n//2]
for i in range(n):
  if X[i]<=median1:
    print(median2)
  else:
    print(median1)

Submission status: Wrong Answer

Solution code:
#094c
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]

#l が奇数のとき，l 個の数 a1,a2,...,al の中央値とは，a1,a2,...,al の中で (l+1)/2番目に大きい値のことを言います．
#N個の数 X1,X2,...,XN が与えられます．ここで，N は偶数です． 
#i=1,2,...,N に対して，X1,X2,...,XN から Xi のみを除いたもの，すなわち X1,X2,...,Xi−1,Xi+1,...,XN の中央値を Biとします．
#i=1,2,...,Nに対して，Bi を求めてください．

X_list.sort(reverse=False)

Bi_smaller = X_list[int(len(X_list)/2-1)]
Bi_bigger = X_list[int(len(X_list)/2)]

for i in range(int(N/2)):
    print(Bi_bigger)
    
for i in range(int(N/2),N):
    print(Bi_smaller)

Submission status: Wrong Answer

Solution code:
#094c
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]

sorted_X_list = sorted(X_list)
Bi_bigger = sorted_X_list[int(len(X_list)/2)]
sorted_X_list.pop(int(len(X_list)/2))
#print(sorted_X_list)
Bi_smaller = sorted_X_list[int(len(X_list)/2)-1]

for i in range(N):
    if X_list[i] == Bi_bigger:
        print(Bi_smaller)
    else:
        print(Bi_bigger)

Submission status: Wrong Answer

Solution code:
#094c
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]

#l が奇数のとき，l 個の数 a1,a2,...,al の中央値とは，a1,a2,...,al の中で (l+1)/2番目に大きい値のことを言います．
#N個の数 X1,X2,...,XN が与えられます．ここで，N は偶数です． 
#i=1,2,...,N に対して，X1,X2,...,XN から Xi のみを除いたもの，すなわち X1,X2,...,Xi−1,Xi+1,...,XN の中央値を Biとします．
#i=1,2,...,Nに対して，Bi を求めてください．

sorted_X_list = sorted(X_list)

Bi_smaller = sorted_X_list[int(len(X_list)/2-1)]
Bi_bigger = sorted_X_list[int(len(X_list)/2)]

for i in range(N):
    if X_list[i] == Bi_bigger:
        print(Bi_smaller)
    else:
        print(Bi_bigger)

Submission status: Wrong Answer

Solution code:
#094c
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]

#l が奇数のとき，l 個の数 a1,a2,...,al の中央値とは，a1,a2,...,al の中で (l+1)/2番目に大きい値のことを言います．
#N個の数 X1,X2,...,XN が与えられます．ここで，N は偶数です． 
#i=1,2,...,N に対して，X1,X2,...,XN から Xi のみを除いたもの，すなわち X1,X2,...,Xi−1,Xi+1,...,XN の中央値を Biとします．
#i=1,2,...,Nに対して，Bi を求めてください．

X_list.sort(reverse=False)

Bi_smaller = X_list[int(len(X_list)/2-1)]
Bi_bigger = X_list[int(len(X_list)/2)]

for i in range(int(N/2)):
    #for j in range(N):
    #    if j!=i:
    #        print(X_list[j],end="")
    print(Bi_bigger)
    
for i in range(int(N/2),N):
    #for j in range(N):
    #    if j!=i:
    #        print(X_list[j],end="")
    print(Bi_smaller)

Submission status: Wrong Answer

Solution code:
# AC
# 入力
n = int(input())
org_nums = list(map(int, input().split()))
# ソートは一回だけして、取り去る順番を明確にしてから１つずつ取り去り計算を行いたい
sorted_nums = sorted(org_nums) # 入力数列のソート
sorted_index = sorted(range(len(org_nums)), key=lambda k: org_nums[k]) #ソートされたリストから取り去る順番がわかる
extract_index = sorted(range(len(sorted_index)), key=lambda k: sorted_index[k]) #ソートされたリストから取り出すインデックスを取り出す順に並べる
print(extract_index)
for i in extract_index:
    if i+1 <= n // 2:
        print(sorted_nums[n//2])
    else:
        print(sorted_nums[n//2-1])

Submission status: Wrong Answer

Solution code:
n = int(input()) # n is even
x = [int(i) for i in input().split()]
medPlus = sorted(x)[n // 2]
medMinus = sorted(x)[n // 2 - 1]
print(sorted(x))
print(medPlus, medMinus)
for i in range(n):
    print(str(medPlus) if x[i] <= medMinus else str(medMinus))

Submission status: Wrong Answer

Solution code:
n = int(input()) # n is even
x = input().split()
medPlus = sorted(x)[n // 2]
medMinus = sorted(x)[n // 2 - 1]
for i in range(n):
    print(str(medPlus) if x[i] <= medMinus else str(medMinus))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    x_arr=sorted(X)
    x_arr.pop(i)
    print(x_arr[(N-1)//2])

Submission status: Wrong Answer

Solution code:
n = int(input())
xn = list(map(int, input().split()))
xsort = sorted(xn)
a, b = xsort[n//2-1:n//2+1]
if a == b:
  for _ in range(n):
    print(n)
else:
  for x in xn:
    if x <= a:
      print(b)
    else:
      print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
an = list(map(int, input().split()))
an.sort()
a, b = an[n//2-1:n//2+1]
if a == b:
  for _ in range(n):
    print(n)
else:
  for ai in an:
    if ai <= a:
      print(b)
    else:
      print(a)

Submission status: Wrong Answer

Solution code:
n,*x=map(int, open(0).read().split())
xc=sorted(x);medmed=xc[n//2-1]+xc[n//2]
for i in x:print((medmed+(i<medmed/2))//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
  x[i] = [x[i],i]
x.sort()
z = [0]*n
m = x[int(n/2)-1][0]
M = x[int(n/2)][0]
for i in range(int(n/2)):
  z[i] = M
for i in range(int(n/2),n):
  z[i] = m
for i in z:
  print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
X=[int(i) for i in input().split()]
X.sort()
MidL=X[N//2-1]#ちっちゃいほう(変化なしの場合)
MidR=X[N//2]#でかいほう(下が減った場合)
if N>=MidR:print(MidL)
else:print(MidR)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

sorted_A = sorted(A)

left_med = sorted_A[(N-1)//2]
right_med = sorted_A[(N+1)//2]

for i in range(N):
  if A[i] < N//2:
    print(right_med)
  else:
    print(left_med)

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

sorted_A = sorted(A)

left_med = sorted_A[(N-1)//2]
right_med = sorted_A[(N+1)//2]

for i in range(N):
  if i < N//2:
    print(right_med)
  else:
    print(left_med)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    X = list(map(int, input().split()))
    Y = X.copy()
    Y.sort()
    m1 = Y[N//2-1]
    m2 = Y[N//2]
    for x in X:
        if x <= m1:
            print(m2)
        if x >= m2:
            print(m1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

lmid = sorted_x[n // 2 - 1]
rmid = sorted_x[n // 2]

for xi in x:
    if xi > rmid:
        print(lmid)
    else:
        print(rmid)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 = []

X2 = copy.copy(X)
X2.sort(reverse=True)
Xm_1 = X2[N//2]
Xm_2 = X2[(N//2)-1]
print(Xm_1,Xm_2)

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

Submission status: Wrong Answer

Solution code:
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 = []

X2 = copy.copy(X)
X2.sort(reverse=True)
Xm_1 = X2[N//2]
Xm_2 = X[(N//2)-1]

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

Submission status: Wrong Answer

Solution code:
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 =[]
ans = []
for i in range(N):
    B = 0
    X2 = copy.copy(X)
    X2.pop(i)
    X2.sort(reverse=True)
    B = X2[(N//2)-1]
    ans.append(B)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)

left=b[int(n/2)-1]
right=b[int(n/2)]
print(left, right)
for i in a:
    pos=bisect.bisect_left(b, i)+1
    if 2*pos<=n:
        print(right)
    else:
        print(left)

Submission status: Wrong Answer

Solution code:

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

mid_1 = sort_x[n//2-1]
mid_2 = sort_x[n//2]

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
xs = sorted(x, reverse = True)
med1 = xs[n//2 - 1]
med2 = xs[n//2]
for i in range(n):
    if x[i] != med1:
        print(med1)
    else:
        print(med2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())

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

c_lst = copy.copy(lst)
sorted_lst = sorted(c_lst)
idx = (N-1) // 2
for i in range(N):
  s_lst = copy.copy(sorted_lst)
  s_lst.remove(lst[i])
  median = s_lst[idx]
  if lst[i] != median:
    print(median)
  else:
    print(s_lst[idx+1])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[]

if N==2:
    print(A[1])
    print(A[0])
    exit(0)

for i in range(N):
    B.append(A[i])

B.sort()

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[]

if N==2:
    print(A[1])
    print(A[0])
    exit(0)

for i in range(N):
    B.append(A[i])

B.sort()
print(A)
print(B)
for i in range(N):
    if A[i]<B[N//2+1]:
        print(B[N//2])
    else:
        print(B[N//2-1])

Submission status: Wrong Answer

Solution code:
N = int(input())

input_list = list(map(int,input().split()))
sorted_list = sorted(input_list)

median_min = sorted_list[int(N/2)-1]
median_max = sorted_list[int(N/2+1)-1]
	

for i in input_list:
  if i <= median_max:
    print(median_max)
  else:
    print(median_min)

Submission status: Wrong Answer

Solution code:
N = int(input())

input_list = list(map(int,input().split()))
sorted_list = sorted(input_list)

median_min = sorted_list[int(N/2)-1]
median_max = sorted_list[int(N/2+1)-1]


for i in input_list:
  if sorted_list.index(i) -1  <= int(N / 2):
    print(median_max)
  else:
    print(median_min)

Submission status: Wrong Answer

Solution code:
N = int(input())

input_list = list(map(int,input().split()))
sorted_list = sorted(input_list)

median_min = sorted_list[int(N/2)-1]
median_max = sorted_list[int(N/2+1)-1]


for i in input_list:
  if sorted_list.index(i) <= int(N / 2):
    print(median_max)
  else:
    print(median_min)

Submission status: Wrong Answer

Solution code:
N = int(input())

input_list = list(map(int,input().split()))
sorted_list = sorted(input_list)

median_min = sorted_list[int(N/2)-1]
median_max = sorted_list[int(N/2+1)-1]


for i in input_list:
  if i != median_max:
    print(median_max)
  else:
    print(median_min)

Submission status: Wrong Answer

Solution code:
N = int(input())

input_list = list(map(int,input().split()))
sorted_list = sorted(input_list)

median_min = sorted_list[int(N/2)-1]
median_max = sorted_list[int(N/2+1)-1]


for i in input_list:
  if i != median_max:
    print(median_max)
  else:
    print(median_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    b = x[:i] + x[i + 1:]
    b.sort()
    m.append(b[n // 2 - 1])

print(m[i] for i in range(n))

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int, input().split()))
mid_id = (len(li)//2)-1
temp = li.copy()
mid1 = temp[mid_id-1]
mid2 = temp[mid_id]
for i in li:
    if i <= mid1:
        print(mid2)
    else:
        print(mid1)

Submission status: Wrong Answer

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

B = A.copy()

B.sort()

for num in A:
  if B[N//2] >= num:
    print(B[N//2])
  else:
    print(B[N//2-1])

Submission status: Wrong Answer

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