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:
import statistics
n = int(input())
X = list(map(int, input().split()))
med = sorted(X)[n//2-1]
X_ = sorted(X)
X_.remove(med)
for i in range(n-1):
    if X_[i]>=med:
        med_2 = X_[i]
        break
for i in range(n):
    if X[i]>med:
        print(med)
    elif X[i]==med:
        print(med_2)
    else:
        print(med_2)

Submission status: Wrong Answer

Solution code:
import bisect

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

sorted_x = sorted(X)

print(sorted_x)

l, r = sorted_x[n//2-1], sorted_x[n//2]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
z = set(x)
t1 = y[n//2-1]
t2 = y[n//2]
idx = dict([])
idx[y[0]] = 0
l = y[0]
cnt = 0
for i in y:
    if i == l:
        continue
    else:
        idx[i] = cnt
        l = i
    cnt += 1

for i in x:
    t = idx[i]
    if t<n//2:
        print(t2)
    else:
        print(t1)

Submission status: Wrong Answer

Solution code:
import copy
N=int(input())
a=input().split(' ')
suji = []
for j in range(len(a)):
    suji.append(int(a[j]))
#for i in range(len(a)):
  #suji.append(int(a[i]))
for i in range(N):
    c = copy.copy(suji)
    if c.count(i > 0):
        c.remove(i)
        
   
    aiueo = (len(c) + 1) // 2-1
    print(sorted(c)[(len(c) + 1) // 2-1])

Submission status: Wrong Answer

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

a = x[len(x)//2]
b = x[(len(x)//2) - 1]
for _ in range(len(x)//2):
    print(a)
for _ in range(len(x)//2):
    print(b)

Submission status: Wrong Answer

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

def median(l):
    i = ((len(l)+1)//2) - 1
    return l[i]

for i in range(len(x)):
    print(median(x[:i] + x[i+1:]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

res1 = x[n//2]
res2 = x[n//2 -1]

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
from statistics import median

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
a,b = y[n//2],y[n//2-1]

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

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:
N = int(input())
X = list(map(int,input().split()))

sor = sorted(X)
l = sor[N//2-1]
r = sor[N//2]

print(l,r)
for i in range(0,N,1):
    print(l if X[i]>=r else r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    if x[i] <= X[n//2-1]:
        print(X[n//2]) 
    elif x[i] >= x[n//2]:
        print(X[n//2-1])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
X = LI()

X_sort = sorted(X)
# X.sort()

mid = X[N // 2]

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

Submission status: Wrong Answer

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

X.sort()
center = len(X) // 2

med_l = X[center - 1]
med_r = X[center]

for n in range(N):
  if n <= center - 1:
    print(med_r)
  else:
    print(med_l)

Submission status: Wrong Answer

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

total = sum(x)
for i in range(n):
  avg = (total - x[i])/(n-1)
  ans = 10**9
  for j in range(n):
    if i == j: continue
    if abs(avg - x[j]) < abs(avg - ans): ans = x[j]
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# check
l, r = N // 2 - 1, N // 2
sort_x = sorted(X)
lx, rx = sort_x[l], sort_x[r]
for ind in range(N):
    target = X[ind]
    if target <= lx:
        print(rx)
    if target >= rx:
        print(lx)

Submission status: Wrong Answer

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

# check
l, r = N // 2 - 1, N // 2
X.sort()
lx, rx = X[l], X[r]
for ind in range(N):
    if ind <= l:
        print(rx)
    else:
        print(lx)

Submission status: Wrong Answer

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

# check
l, r = N // 2 - 1, N // 2
X.sort()
for ind in range(N):
    if ind <= l:
        print(r)
    else:
        print(l)

Submission status: Wrong Answer

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

# check
center = N // 2 - 1
for ind in range(N):
    if ind == 0:
        target = X[1:]
    elif ind == N - 1:
        target = X[:ind]
    else:
        target = X[:ind] + X[ind + 1:]
    
    print(target[center])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def partition(lst, pivot):
    """Modifired partition algorithm in section 7.1"""
    pivot_idx = None
    for idx, value in enumerate(lst):
        if value == pivot:
            pivot_idx = idx
    if pivot_idx is None:
        raise Exception
    lst[pivot_idx], lst[-1] = lst[-1], lst[pivot_idx]
    pivot = lst[-1]
    i = -1
    for j, val in enumerate(lst[:-1]):
        if val <= pivot:
            i += 1
            lst[i], lst[j] = lst[j], lst[i]
    lst[i + 1], lst[-1] = lst[-1], lst[i + 1]
    return i + 1
 
def select(lst, i):
    """Selection in linear time"""
    if len(lst) == 1:
        return lst[0]
    split_lists = [lst[i * 5: (i + 1) * 5] for i in range((len(lst) + 4) // 5)]
    split_list_medians = [
        sorted(split_list)[(len(split_list) - 1) // 2]
        for split_list in split_lists
    ]
    x = select(split_list_medians, (len(split_list_medians) - 1) // 2)
    k = partition(lst, x)
    if i == k:
        return x
    elif i < k:
        return select(lst[:k], i)
    else:
        return select(lst[k + 1:], i - (k + 1))
 
def median_linear(lst):
    """Calculate median by selection algorithm"""
    return select(lst, (len(lst) - 1) // 2)

N = [input().split() for l in range(2)]
length = int(N[0][0])

array = []
for i in range(length):
  tmp = []
  for j in range(length):
    if i != j:
      tmp.extend(N[1][j])
  array.append(sorted(tmp))

#print(array)
for line in array:
  print(median_linear(line))
  #print(line[math.floor(len(line)/2)])

Submission status: Wrong Answer

Solution code:
N = [input().split() for l in range(2)]

length = int(N[0][0])

array = []
for i in range(length):
  tmp = []
  for j in range(length):
    if i != j:
      tmp.extend(N[1][j])
  array.append(sorted(tmp))

#print(array)
for line in array:
  print(line[int(len(line)/2)])

Submission status: Wrong Answer

Solution code:
N = [input().split() for l in range(2)]
#print(N)

length = int(N[0][0])
sum = 0

array = []

for i in range(length):
  tmp = []
  for j in range(length):
    if i != j:
      tmp.extend(N[1][j])
  array.append(sorted(tmp))

#print(array)
for line in array:
  print(line[int(len(line)/2)+1-1])

Submission status: Wrong Answer

Solution code:
import copy

n = int(input())
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1
ans = copy.copy(l)
ans.sort()

for i in l:
    if i >= l[p1]:
        print(ans[p2])
    else:
        print(ans[p1])

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1
l.sort()

for i in range(n):
    if i < p1:
        print(l[p1])
    else:
        print(l[p2])

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
p1 = n//2
p2 = n//2-1

for i in range(n):
    if i < p1:
        print(l[p1])
    else:
        print(l[p2])

Submission status: Wrong Answer

Solution code:
n = int(input())
import numpy as np
argList = np.array(list(map(int, input().split())))
flagList = [True]*n 

for i in range(n):
    flagList[i] = False
    print(int(np.median(argList[flagList])))
    flagList[i] = True

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=l[n//2-1]
b=l[n//2]
for i in range(n//2):
  print(b)
for j in range(n//2,n):
  print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

for i in range(a):
  print(X[a])
for i in range(a):
  print(X[b])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

arr=np.sort(np.array(l))
med=np.median(arr)

med_max=int(np.median(np.delete(arr,0)))
med_min=int(np.median(np.delete(arr,n-1)))


if n%2==0:
    p=(n+1)//2
    for i in range(n):
        if l[i]<arr[p-1]:
            print(med_max)
        else:
            print(med_min)

Submission status: Wrong Answer

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

arr=np.sort(np.array(l))
med=np.median(arr)

med_max=np.median(np.delete(arr,0))
med_min=np.median(np.delete(arr,n-1))

if n%2==1:
    p=(n-1)//2
    med_midmin=np.median(np.delete(arr,p+1))
    med_mid=np.median(np.delete(arr,p))
    med_midmax=np.median(np.delete(arr,p-1))

    for i in range(n):
        if l[i]<arr[p-1]:
            print(med_max)
        elif l[i]==arr[p-1]:
            print(med_midmax)
        elif l[i]==arr[p]:
            print(med_mid)
        elif l[i]==arr[p+1]:
            print(med_midmin)
        else:
            print(med_min)

if n%2==0:
    p=(n+1)//2
    med_midmin=np.median(np.delete(arr,p))
    med_midmax=np.median(np.delete(arr,p-1))
    for i in range(n):
        if l[i]<arr[p-1]:
            print(med_max)
        elif l[i]==arr[p-1]:
            print(med_midmax)
        elif l[i]==arr[p]:
            print(med_midmin)
        else:
            print(med_min)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
X = LI()
sort_X = sorted(X)
ans1,ans2 = sort_X[(N-1)//2],sort_X[N//2]
for x in X:
    if x==ans2:
        print(ans1)
    else:
        print(ans2)

Submission status: Wrong Answer

Solution code:
import copy
N=int(input())  #数値入力 「N」だけの入力のとき
X=[int(i) for i in input().split()]

N = N - 1 + N % 2

X.sort()

for i in X:
    a = copy.copy(X)
    a.remove(i)
    print(a[N//2])

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-1])
  else:
    print(X[N//2])

Submission status: Wrong Answer

Solution code:
N = int(input())
X = 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:
N = int(input())
A = list(map(int,input().split()))
X = sorted(A,reverse=False)
print(X)
for i in range(N):
    if A[i] < X[N//2 ]:
        print(X[N//2 ])
    else:
        print(X[N//2 - 1])

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

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

max_value = max(X)
min_value = min(X)

tmp_list = copy.deepcopy(X)
tmp_list.remove(max_value)
max_med = np.median(tmp_list)

tmp_list = copy.deepcopy(X)
tmp_list.remove(min_value)
min_med = np.median(tmp_list)

for i in range(N):
    if X[i] <= max_med:
        print(int(max_med))
    else:
        print(int(min_med))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(0, N):
    tmp_list = []
    if i==0:
        tmp_list = []
    else:
        tmp_list = X[:i]
    tmp_list.extend(X[i+1:])
    med = np.median(tmp_list)
    print(med)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

sort_x = sorted(x)

b1 = sort_x[n//2]
b2 = sort_x[n//2-1]

for i in range(n):
    if x[i]==b1:
        print(b2)
    else:
        print(b1)

Submission status: Wrong Answer

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

XX = sorted(X)
before = XX[N//2 -1]
after = XX[N//2]

print(X)
for i in X:
    if i <= before:
        print(after)
    else:
        print(before)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
x = list(map(int, readline().split()))
check = sorted(x)[n // 2 - 1:n // 2 + 1]
for xx in x:
    print(check[0] if xx == check[1] else check[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
sortx = sorted(X)
bef = sortx[N//2-1]
aft = sortx[N//2]
for i in range(N):
        print(aft if i <= bef else bef)

Submission status: Wrong Answer

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 xi in x:
  print(l if xi <= l else r)

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
X.sort()
bef = int(length/2)
aft = bef+1
for i in range(bef):
    print(X[bef-1])
for i in range(length-bef):
    print(X[aft-1])

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
X.sort()
bef = int(length/2)-1
aft = bef
for i in range(N):
    if(i<=bef-1):
        print(X[bef])
    else:
        print(X[aft])

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
X = list(map(int,input().split()))
length = len(X)
X.sort()
bef = int(length/2)-1
aft = bef
for i in range(N):
    if(i<=bef):
        print(X[bef])
    else:
        print(X[aft])

Submission status: Wrong Answer

Solution code:
import sys

# import math
# import bisect

# import copy
# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7

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


# ===CODE===


def main():
    n = ni()
    d = na()
    d.sort()
    for i in range(n):
        tmp_d = d[:i] + d[i + 1:]
        print(tmp_d[n // 2 - 1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [(i, j) for i, j in enumerate(input().split())]
x.sort(key=lambda x:x[1])
l = x[n//2-1][1]
r = x[n//2][1]
ans = [None]*n
for ind, (i, j) in enumerate(x):
    if ind<n//2:
        ans[i] = r
    else:
        ans[i] = l

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
A = sorted(X)
mid = A[N//2]

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

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def main():
    n = int(input())
    x = list(map(int, input().split()))
    y = deepcopy(x)
    y.sort()
    median = y[n // 2]
    next_median = y[n // 2 - 1]
    for xx in x:
        if xx <= median:
            print(next_median)
        else:
            print(median)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def main():
    n = int(input())
    x = list(map(int, input().split()))
    y = deepcopy(x)
    y.sort()
    median = y[n // 2]
    next_median = y[n // 2 - 1]
    for xx in x:
        if xx == median:
            print(next_median)
        else:
            print(median)


if __name__ == '__main__':
    main()

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:
N=int(input())
X=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:
N=int(input())
X=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:
n = int(input())
x = list(map(int,input().split()))
m = []
for i in range(n):
  m.append(x[i])
m.sort()
k = m[n//2-1]
l = m[(n-2)//2-1]
for i in range(n):
  if(x[i]>l):
    print(l)
  else:
    print(k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def myAnswer(N:int,X:list) -> None:
   tmp = X[:]
   tmp.sort()
   B1 = tmp[(N+1)//2]
   B2 = tmp[(N+1)//2 - 1]
   for x in X:
      if(B1 == x):
         print(B2)
      else:
         print(B1)


def modelAnswer():
   return
def main():
   N = int(input())
   X = list(map(int,input().split()))
   myAnswer(N,X)
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr0=limii()
arr=sorted(arr0)

#print(arr)

cenleft=arr[n//2 -1]
cenright=arr[n//2]
for i in range(n):
    if arr0[i]==cenleft:
        print(cenright)
    elif arr0[i]==cenright:
        print(cenleft)
    elif i < n//2:
        print(cenright)
    else:
        print(cenleft)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
lee = len(li)
sorted_li = sorted(li)
mid = sorted_li[lee//2]
mid_next = sorted_li[lee//2-1]
for l in li:
    if l != mid:
        print(mid)
    else:
        print(mid_next)

Submission status: Wrong Answer

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

X.sort()
L = X[N//2 - 1]
R = X[N//2]

for x in X:
  if x >= R:
    print(L)
  else:
    print(R)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input())
  X = [int(_) for _ in input().split()]
  Y = sorted(X)
  mid = (Y[(N-1)//2] + Y[N//2]) / 2
  for i in range(N):
    print(Y[N//2] if X[i] <= mid else print(Y[(N-1)//2]))
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

As.sort()

left = As[n//2 - 1]
right = As[n//2]

for x in As:
  if x <= left:
    print(right)
  else:
    print(left)

Submission status: Wrong Answer

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(b)
    else:
        print(a)

Submission status: Wrong Answer

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

d = N // 2
dn = X[d]

for i in range(N):
    if X[i] < dn:
        print(Xc[d])
    else:
        print(Xc[d-1])

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
Listx = list(map(int,input().split()))

for i in range(N):
    Copy_Listx = copy.deepcopy(Listx)
    Copy_Listx.remove(Listx[i])
    print(Copy_Listx[N//2-1])

Submission status: Wrong Answer

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

# print(X_sort)

middle_left = X_sort[N//2-1]
middle_right = X_sort[N//2]
# print(middle_left, middle_right)

for idx, x in enumerate(X):
    if idx <= N//2-1:
        if middle_right != x:
            print(middle_right)
        else:
            print(middle_left)
    else:
        if middle_left != x:
            print(middle_left)
        else:
            print(middle_right)

Submission status: Wrong Answer

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

    X_sorted = list(X)
    X_sorted.sort()
    middle = X_sorted[(n+1)//2]
    middle_l = X_sorted[(n+1)//2-1]


    for i in range(n):
        if middle_l==middle:
            print(middle)
        else:
            if X[i]==middle:
                print(middle_l)
            else:
                print(middle)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import statistics
n=int(input())
x=list(map(int,input().split()))
x.sort()
for i in range(n):
    a=x[:i]+x[i+1:]
    print(a[n//2-1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

x = np.array(x)

med = int(np.median(x))

y = np.sort(x)

#print(np.count_nonzero(x == med))
#cnt = np.count_nonzero(x == med1)
#if cnt == 1:med2 = int(np.median(x[x != np.max(x)]))
#else: med2 = 
#print(med1)

med1 = np.median(y[1:])
med2 = np.median(y[:n-1])
#
#print(med1,med2)
cnt = np.count_nonzero(x == med2)
#print(y[1:])
#print(y[:n-1])

if cnt == 1:
    flag = x <= med2
else:
    flag = x < med2

for i in range(n):
    if flag[i] :
        print(int(med1))
    else:
        print(int(med2))

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[[int(x),i] for i,x in enumerate(input().split())]
ans=[0]*n
x.sort(key=lambda x: x[0])
print(x)
for i,val in enumerate(x):
    #n-1 is odd pos=(n-1+1)//2
    pos=(n-1)//2
    if i>pos:
        ans[val[1]]=x[pos][0]
    else:
        ans[val[1]]=x[pos+1][0]
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
x = list(map(int, input().split()))
xx = sorted(x)
middle = (xx[n//2]+xx[n//2-1])/2
for i in x:
    if i < middle:
        print(math.ceil(middle))
    else:
        print(int(middle))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(str,input().split()))
for x in X:
  X_ = sorted(X)
  X_.remove(x)
  print(X_[(N)//2-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(str,input().split()))
for x in X:
  X_ = sorted(X)
  X_.remove(x)
  print(X_[(N+1)//2-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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:
n=int(input())
n//=2
l=list(map(int,input().split()))
sl=sorted(l)
m,h=sl[n-1],l[n]
print(*[h if i<=sl[n-1] else m for i in l],sep="\n")

Submission status: Wrong Answer

Solution code:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n==2:
    print(x[1])
    print(x[0])
    exit()

x_sort = sorted(x)

med1_ix = n//2-1
med2_ix = n//2

med1 = x_sort[med1_ix]
med2 = x_sort[med2_ix]

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