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:
N = int(input())
X = [int(_) for _ in input().split()]

one = N // 2 - 1
two = N // 2

for n in range(N // 2):
    print(X[two])
for n in range(N // 2, N):
    print(X[one])

Submission status: Wrong Answer

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

middle = int(n/2) - 1
next_middle = middle + 1

for i in range(n):
  if x[i] <= sort_x[middle]:
    print(sort_x[middle])
  elif x[i] >= next_middle:
    print(sort_x[next_middle])

Submission status: Wrong Answer

Solution code:
n = int(input())
lst_x = list(map(int, input().split()))
lst_x.sort()
b1 = lst_x[n//2 - 1]
b2 = lst_x[n//2]


for x in lst_x:
    if x <= b1:
        ans = b2
    else:
        ans = b1
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

N = int(input())

X = list(input().split())

X_c = X.copy()

X_c.sort()

bh = X_c[N//2-1]
fr = X_c[N//2]


for i in X:

    if i < fr:
        print (fr)
    else:
        print (bh)

Submission status: Wrong Answer

Solution code:

N = int(input())

X = list(input().split())


for i in range(N):

    X_c = X.copy()

    del X_c[i]

    X_c.sort()

    print (X_c[N//2-1])

Submission status: Wrong Answer

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

h = int((len(x) - 1) / 2)

for i in range(len(x)):
    s = sorted(x[:i] + x[i+1:])
    if len(s) == 1:
        print(s[0])
    else:
        print(int((s[h] + s[h+1]) / 2))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [int(x) for x in input().split()]
X_nm = []
for n in range(N):
  X_nm.append([n, X[n]])
X_nm.sort(key=lambda x:x[1])

for n in range(N):
  idx = X_nm.index([n, X[n]])
  if idx+1 <= N//2:
    ans = X_nm[N//2][1]
    print(ans)
  else:
    ans = X_nm[N//2-1][0]
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(lambda x, y: [int(y), x], range(1, N+1), input().split()))
 
m = N // 2
am = a[m][0]
amp = a[m-1][0]

a = sorted(zip(a, range(N)), key=lambda x:x[0][1])
for _, i in a:
  print(amp if i < m else am)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(lambda x, y: [int(y), x], range(1, N+1), input().split()))
 
m = N // 2
am = a[m][0]
amp = a[m-1][0]
a = sorted(zip(a, range(N)), key=lambda x:x[0][1])
print(a)
for _, i in a:
  print(am if i < m else amp)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(lambda x, y: [y, x], range(1, N+1), input().split()))
 
m = N // 2
am = a[m][0]
amp = a[m-1][0]
for _, i in sorted(zip(a, range(N)), key=lambda x:x[0][1]):
  print(am if i < m else amp)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = sorted(map(int, input().split()))
 
m = N // 2
 
for x in (a[m], a[m-1]):
  for i in range(m):
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n = int(input())
x = list(map(int, input().split()))
sort_x = sorted(x)
check = sort_x[n//2]
for i in range(n):
    if check == x[i]:
        ans = sort_x[n//2-1]
    else:
        ans = check
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

high,low = Xs[N//2], Xs[N//2 - 1]

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

Submission status: Wrong Answer

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

high,low = Xs[N//2], Xs[N//2 - 1]

if high == low:
    for i in range(N):    print(high)
else:
    pre = X[0]
    Xs1 = sorted(X[1:])
    med = Xs1[N//2 - 1]
    print(med)

    for i in range(1,N):
        pre,nex = X[i-1],X[i]
        if med > pre and med <= nex:
            med = low
        elif med < pre and med >= nex:
            med = high
        print(med)

Submission status: Wrong Answer

Solution code:
N, *X = map(int, open(0).read().split())
mid_l = sorted(X)[(N + 1) // 2 - 1]
mid_r = sorted(X)[(N + 1) // 2]
print([mid_l if v > mid_l else mid_r for v in X])

Submission status: Wrong Answer

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

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:
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]
NL = L.copy()
NL.sort()

for i in range(N):
    t = L[i]
    if t == NL[N // 2]:
        print(NL[N // 2 - 1])
    else:
        print(NL[N // 2])

Submission status: Wrong Answer

Solution code:
n=int(input())
pos=n//2-1
arr=list(map(int,input().split()))
for i in range(n):
  arr[i]=[arr[i],i]
arr=sorted(arr,key=lambda x:x[0])
ans=[0]*n
for i in range(n):
  if arr[i][1]<=pos:
    ans[arr[i][1]]=arr[pos+1][0]
  else:
    ans[arr[i][1]]=arr[pos][0]
for i in range(n):
  print(ans[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
x_list = [int(i) for i in input().split()]
y_list = sorted(x_list,reverse=True)
y1=y_list[N//2]
y2=y_list[N//2-1]

for i in range(N):
	if x_list[i]<=y1:
		print(y1)
	else:
		print(y2)

Submission status: Wrong Answer

Solution code:
n = int(input())
input_num = input().split(" ")

sort_list = sorted(input_num)

center = int(n/2) - 1

for num in input_num:
    new_list = sort_list[0:]
    new_list.remove(num)
    print(new_list[center])

Submission status: Wrong Answer

Solution code:
total = int(input())
num_list = input().split()
center = []
for num in range(1, total + 1):
    for k, i in zip(num_list, range(1, len(num_list) + 1)):
        if i  == num:
            continue
        else:
            center.append(k)
    center.sort()
    cen = int(total / 2) - 1
    print(center[cen])
    center = []

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    extracts = set([x[j] for j in range(n) if i != j])
    idx = int((len(extracts)) / 2)
    print(list(extracts)[idx])

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 i in range(N//2):
    print(a)
for i in range(N//2, N):
    print(b)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N = I()
X = LI()

#  N = 200000
#  X = [i*10 for i in range(1,N+1)]

"""
まずは偶数時の中央値のidxを求める
偶数時の中央値より小さいものが抜かれたときは、そのまま、
大きいものが抜かれたときはidx-1が中央値となる
"""
#見つかったメディアンを保存
found = {}
sorted_X = sorted(X)
median = sorted_X[int(len(X)/2)]
for x in X:
    #  print('x', x)
    #  print('found', found)
    if x < median:
        if found.get('small',None):
            print(found['small'])
        else:
            print(median)
            found['small'] = median
    elif x > median:
        if not found.get('big', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            #奇数長になっている
            m = tmp[int(len(tmp)//2+1)]
            print(m)
            found['big'] = m
        else:
            print(found['big'])
    else:
        if not found.get('equal', None):
            tmp = [i for i in sorted_X]
            tmp.remove(x)
            m = tmp[int(len(tmp)//2)]
            print(m)
            found['equal'] = m
        else:
            print(found['equal'])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[int(i) for i in input().split()]
L.sort()
a=L[N//2]
b=L[N//2-1]

for i in range(N):
  if i<N//2:
    print(a)
  else:
    print(b)

Submission status: Wrong Answer

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

for i in range(N):
  Lcopy=L[:]
  del Lcopy[i]
  print(Lcopy[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()
xsort = sorted(x)
center = xsort[n//2]
for i in range(n):
    if center == x[i]:
        print(xsort[n//2 - 1])
    else:
        print(center)

Submission status: Wrong Answer

Solution code:
A = list(map(int, input().split()))
if (max(A)-sum(A)) % 2:
    print((3 * (max(A) + 1) - sum(A)) // 2)
else:
    print((3 * max(A) - sum(A)) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l, r = X[N//2-1], X[N//2]
for x in X:
  if(x <= l):
    print(r)
  elif(x >= r):
    print(l)

Submission status: Wrong Answer

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

l, r = X[N//2], X[N//2-1]
for x in X:
  if(x <= l):
    print(r)
  elif(x >= r):
    print(l)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N):
    if i < N/2:
        print(X[int(N/2)])
    else:
        print(X[int(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):
    print((X[:i] + X[i+1:])[(N-1)//2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N//2) :
    if (X[i] in mapper) :
        continue
    mapper[X[i]] = X[len(X)//2]

for i in range(N//2,N) :
    if (X[i] in mapper) :
        continue
    mapper[X[i]] = X[(len(X)//2) - 1]

for x in X :
    print(mapper[x])

Submission status: Wrong Answer

Solution code:
import copy
def main():
    n = int(input())
    x = list(map(int,input().split()))
    print(x)
    a = copy.deepcopy(x)
    a.sort()
    a1 = a[(n-1)//2]
    a2 = a[(n+1)//2]

    for i in range(0,n):
        if x[i]<=a1:
            print(a2)
        else:
            print(a1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
xarray = list(map(int,input().split()))
newArray = xarray[:]
newArray.sort()

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


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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = input().split()
Y = sorted([[_, X[_]] for _ in range(N)], key=lambda x: x[1])
B = [0] * N
for i in range(N):
    B[Y[i][0]] = [_[1] for _ in Y[0:i] + Y[i+1:]][(N - 1) // 2]
print('\n'.join(B))

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
X.sort()
s = N // 2
for _ in range(s):
    print(X[s - 1])
for _ in range(s, N):
    print(X[s])

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int, input().split()))
s = N // 2
for _ in range(s):
    print(X[s - 1])
for _ in range(s, N):
    print(X[s])

Submission status: Wrong Answer

Solution code:
iN = int(input())
aX = [int(_) for _ in input().split()]

aXs = sorted(aX)

iMu  = iN//2
iMd  = iN//2 -1

iMuV = aX[iMu]
iMdV = aX[iMd]

if iMuV == iMdV:
    print("\n".join([str(iMuV)]*iN))
else:
    print("\n".join(map(str,map(lambda x: iMuV if x < iMuV else iMdV ,aX))))

Submission status: Wrong Answer

Solution code:
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
#N = 5
#a = [3, 2, 2, 4, 1]
idx = range(N)
aa = [[idx[i], a[i]] for i in range(N)]
aaa = sorted(aa, key=lambda x: x[1])
ret = []
for i,j in enumerate(aaa):
    ans_idx = aaa[i][0]  # true index
    if i < int(N/2):
        med = aaa[int(N/2)][1]
    else:
        med = aaa[int(N/2)-1][1]
    ret.append([ans_idx,med])
rett = sorted(ret, key=lambda x:x[0])
for i in ret:
    print(i[1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
a = np.array(a)
ret = []
for i in range(N):
    ind = np.ones(N, dtype=bool)
    ind[i] = False
    tmp = a[ind]
    ret.append(int(np.median(tmp)))
print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
xn = list(map(int, input().split()))
xn_sorted = sorted(xn)

xn_tmp = list(xn_sorted)

for xi in xn:
    # xn_tmp = list(xn_sorted)
    # xn_tmp.remove(xi)
    print(xn_tmp[(len(xn_tmp)+1)//2 -1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
xn = list(map(int, input().split()))
xn_sorted = sorted(xn)

for xi in xn:
    xn_tmp = list(xn_sorted)
    # xn_tmp.remove(xi)
    print(xn_tmp[(len(xn_tmp)+1)//2 -1])

Submission status: Wrong Answer

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

for i in range(len(nums)):
  tmp_nums = nums[:i]+nums[i+1:]
  print(tmp_nums[len(tmp_nums)//2])

Submission status: Wrong Answer

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

def  median(a):
  mid = len(a)//2
  return a[mid]

for i in range(len(nums)):
  tmp_nums = nums[:i]+nums[i+1:]
  print(median(tmp_nums))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(raw_input())
X=np.array(map(int,raw_input().split()))

sorted_X=np.sort(X)

arg_X=np.argsort(X)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def median(_list):
	return _list[(len(_list)+1)//2-1]

for i in range(N):
	if i != N-1:
		ans += '{0}\n'.format(median(X[:i]+X[i+1:]))
	else:
		ans += '{0}'.format(median(X[:-1]))
print(ans)

Submission status: Wrong Answer

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

def solver():
    # mr.zehnpaard
    from statistics import median_low, median_high

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

    m1, m2 = median_low(xs), median_high(xs)

    medians = (str(m2 if x < m2 else m1) for x in xs)
    print('\n'.join(medians))

def main():
    from statistics import median_low, median_high

    N = int(input())
    Xs = list(map(int, input().split()))
    m_low, m_high = median_low(Xs), median_high(Xs)

    for n in range(N):
        ans = m_high if n <= m_low else m_low
        print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A1 = []
for nums in A:
  A1.append(nums)
A.sort()
m1 = A[N//2-1]
m2 = A[N//2]
if m1 != m2:
  for nums in A1:
    print(nums)
    if nums <= m1:
      print(m2)
    else:
      print(m1)

else:
  for nums in A1:
    print(m1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = A
B.sort()
m1 = B[N//2-1]
m2 = B[N//2]
if m1 != m2:
  for nums in A:
    if nums <= m1:
      print(m2)
    else:
      print(m1)

else:
  for nums in A:
    print(m1)

Submission status: Wrong Answer

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

m1 = X[int(N/2) - 1]
m2 = X[int(N/2)]

for i in range(N):
    if i < N/2:
        print(m2)
    else:
        print(m1)

Submission status: Wrong Answer

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

AB = sorted(A)
C = int(N//2)
for i in range(N):
    if AB[i] <= AB[C-1]:
        print(AB[C])
    else:
        print(AB[C-1])

Submission status: Wrong Answer

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

AB = sorted(A)
C = int(N/2)
for i in range(N):
    if AB[i] <= AB[C]:
        print(AB[C])
    else:
        print(AB[C-1])

Submission status: Wrong Answer

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

AB = sorted(A)
C = int(N/2)
for i in range(N):
    if i <= AB[C-1]:
        print(AB[C])
    else:
        print(AB[C-1])

Submission status: Wrong Answer

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

AB = sorted(A)
C = int(N/2)
for i in range(N):
    if AB[i] <= AB[C-1]:
        print(AB[C])
    else:
        print(AB[C-1])

Submission status: Wrong Answer

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

x_sorted = sorted(x)
samples = [x_sorted[n//2-1], x_sorted[n//2]]
for x_i in x:
	print(samples[x_sorted.index(x_i)//(n//2)])

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int,input().split()))
b = sorted(a)
c = b.copy()
Mave = max(c)/2
del b[n-1]

hantei =[]
for i in b:
    hantei.append(abs(Mave-i))

print(str(max(c))+' '+str(b[hantei.index(min(hantei))]))

Submission status: Wrong Answer

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

def main():
    N = int(input())
    x_list = list(map(int, input().split()))
    x_sort = x_list[:]
    x_sort.sort()
    med_dict = {}

    med = (N // 2) -1

    for i in range(N):
        if x_list[i] in med_dict:
            print(med_dict[x_list[i]])
        elif i > med:
            #print(x_sort)
            print(x_sort[med+1])
        else:
            removed_x_list = x_list[:]
            removed_x_list.remove(x_list[i])
            removed_x_list.sort()
            median = removed_x_list[med]
            med_dict[x_list[i]] = median
            print(median)
    #print(med_dict)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(1,1+n):
    li.sort()
    a =  li[i]
    b = li[int((n+1)/2)]
    print(b)
    li.append(a)

Submission status: Wrong Answer

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

hoge = math.floor(N/2)

x.sort()
A = x[hoge]
B = x[hoge-1]

for i in range(hoge):
	print(A)
for i in range(hoge):
	print(B)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = input().split()
arr.sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = input().split()
arr.sort()

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

Submission status: Wrong Answer

Solution code:
l = int(input())
li = input().split()
for i in range(len(li)):
    lis = sorted(li[0:i] + li[i+1:l])
    print(lis[int((l-1)/2)])

Submission status: Wrong Answer

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

smaller_index = int((N - 1) / 2)
larger_index = smaller_index + 1
avg = (Y[smaller_index] + Y[larger_index]) / 2
for i in range(N):
    if (X[i] < avg and i != smaller_index) or X[i] == Y[smaller_index]:
        print(Y[larger_index])
    else:
        print(Y[smaller_index])

Submission status: Wrong Answer

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

Y = X + [0]
Z = X + [10*9+1]

ymed = median(Y)
zmed = median(Z)

if ymed == zmed:
  for _ in range(N):
    print(ymed)
else:
  for i in X:
    if i <= ymed:
      print(zmed)
    else:
      print(ymed)

Submission status: Wrong Answer

Solution code:
n = int(input())
n_l = [n for n in range(n)]
x = map(int, input().split())
x = [int(a) for a in x]
print(type(x))
a = 0
list = []

while True:
    for i in range(len(x)):
        if i == a:
            pass
        else:
            list.append(x[i])

    list.sort()
    print(list)

    print(list[(n - 2)//2])

    a += 1
    list = []

    if a == n:
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

X.sort()

#2つの値しか出力されない
B = X[int(N/2-1)]
B_te = X[int(N/2)]

for i in range(N):
    if B < X[i]:
        print(B)
    else:
        print(B_te)

Submission status: Wrong Answer

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

a = sorted(a)
m1 = a[n // 2]
m2 = a[n // 2 - 1]

for num in a:
    print(m1 if num < m1 else m2)

Submission status: Wrong Answer

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

a = sorted(a)
m1 = a[n // 2]
m2 = a[(n // 2) - 1]

for num in a:
    if(num < m1):
        print(m1)
    else:
        print(m2)

Submission status: Wrong Answer

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

a = sorted(a)
m1 = a[n // 2]
m2 = a[n // 2 - 1]

for num in a:
    if(num < m1):
        print(m1)
    else:
        print(m2)

Submission status: Wrong Answer

Solution code:
a = input()
a = int(a)
b = input()
b= b.rstrip().split(" ")

#print(b)
for j in range(len(b)):
    b1=[]
    for i in range(len(b)):
        if j ==i:
            i +=1
        else:
            b1.append(int(b[i]))
            i +=1
    print(b1[int(a/2)-1])
        
    j+=1

Submission status: Wrong Answer

Solution code:
N = int(input())
import numpy as np
l = np.array(list(map(int,input().split())))
for i in range(N):
    print(np.median(np.delete(l,i)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
list = input().split(" ")
# print(N)
# print(sorted(list))
# print(list)
for i in range(N):
    list_copy = list[:]
    del list_copy[i]
    #print(list_copy)
    list_copy.sort()
    #print(list_copy)
    print(list_copy[ N // 2 - 1])

Submission status: Wrong Answer

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

for i in range(N):
    y = x[:]
    del y[i]
    y.sort()
    print(y,y[int(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)
args = np.argsort(x, kind="quicksort")

mid = n//2
l = x[args[mid-1]]
r = x[args[mid]]

for i in range(n):
	# if (x[i] == r) and (l!=r):
	# 	print(l)
	# elif (x[i] == l) and (l!=r):
	# 	print(r)
	# else:
	if (args[i]<mid):
		print(r)
	else:
		print(l)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

x = np.array(x)
args = np.argsort(x, kind="quicksort")

mid = n//2
l = x[args[mid-1]]
r = x[args[mid]]

for i in range(n):
	if (x[i] == r) and (l!=r):
		print(l)
	elif (x[i] == l) and (l!=r):
		print(r)
	else:
		if (args[i]<mid):
			print(r)
		else:
			print(l)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

x = np.array(x)
args = np.argsort(x, kind="quicksort")

mid = int(n/2)
l, r = x[args][mid-1:mid+1]

for i in range(n):
	if (x[i] == r) and (l!=r):
		print(l)
	elif (x[i] == l) and (l!=r):
		print(r)
	else:
		if (args[i]<mid):
			print(r)
		else:
			print(l)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

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

x = np.array(x)
args = np.argsort(x, kind="quicksort")

mid = int(n/2)
l, r = x[args][mid-1:mid+1]

for i in range(n):
	if (x[i] == r) and (l!=r):
		print(l)
	elif (x[i] == l) and (l!=r):
		print(r)
	else:
		if (args[i]<mid):
			print(r);
		else:
			print(l);

Submission status: Wrong Answer

Solution code:
n=int(input());a=sorted(list(map(int,input().split())));print('\n'.join([str(a[n//2-i//(n//2)])for i in range(n)]))

Submission status: Wrong Answer

Solution code:
n=int(input());a=sorted(list(map(int,input().split())));print(' '.join([str(a[n//2-i//(n//2)])for i in range(n)]))

Submission status: Wrong Answer

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

for i in range(0,N):
	numListCopy = copy.deepcopy(numList)
	numListCopy.pop(i)
	medIndex = int(len(numListCopy)/2)
	print(numListCopy[medIndex])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC 094 Many Medians

numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)

median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]

print('median1:', median1)
print('median2:', median2)

for i in list_num:
    if sorted_list.index(i) <= numbers/2-1:
        print(median2)
    else:
        print(median1)

Submission status: Wrong Answer

Solution code:
# N = 4
N = int(input())
# X = [2, 4, 4, 3]
X = list(map(int, input().split(' ')))

target = int((N-1)/2)
first_m = int(N/2)
second_m = first_m - 1
X = sorted(X)
for i in range(N):
    if X[i] <= X[second_m]: print(X[first_m])
    else: print(X[second_m])

Submission status: Wrong Answer

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

for i in range(N):
    current_list = X_list[:i] + X_list[i+1:]
    median = current_list[-(N//2)]
    print(median)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

n = int(input())
xs = list(map(int,input().split()))
sort_xs = sorted(xs)

for x in xs:
    ind = sort_xs.index(x)
    new_sort_xs = copy.deepcopy(sort_xs)
    del new_sort_xs[ind]
    if ind > (n/2) + 1:
        print(new_sort_xs[int(n/2)])
    else:
        print(new_sort_xs[int(n/2)-1])