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: Time Limit Exceeded

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

for i in range(N):
    C = sorted([x for index, x in enumerate(X) if index != i])
    print(C[len(C)//2])

Submission status: Time Limit Exceeded

Solution code:
import copy
n=int(input())
box=list(map(int,input().split()))
box_sort=sorted(box)
for i in box:
    ano_box=copy.copy(box_sort)
    ano_box.remove(i)
    print(ano_box[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n=int(input())
x=np.array([int(item) for item in input().split()])
x_sorted=np.sort(x)

for i in range(n):
  ind=np.ones(n,dtype=bool)
  ind[np.searchsorted(x_sorted,x[i])]=False
  #print(x_sorted[ind])
  print(x_sorted[ind][n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import collections
import numpy as np

n=int(input())
x=np.array([int(item) for item in input().split()])

c = collections.Counter(x)
x_sorted=np.sort(x)

for i in range(n):
  if c[x[i]]>1:
    print(x_sorted[n//2-1])
  else:
    ind=np.ones(n,dtype=bool)
    ind[np.searchsorted(x_sorted,x[i])]=False
    print(x_sorted[ind][n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
x=np.array([int(item) for item in input().split()])

for i in range(n):
  ind = np.ones(n, dtype=bool)
  ind[i] = False
  
  print(int(np.median(x[ind])))

Submission status: Time Limit Exceeded

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

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

for i in range(N):
  c_lst = copy.copy(lst)
  c_lst.pop(i)
  idx = len(c_lst) // 2
  sorted_lst = sorted(c_lst)
  print(sorted_lst[idx])

Submission status: Time Limit Exceeded

Solution code:
import copy
import statistics

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

for i in range(n):
    tmp = copy.copy(x)
    tmp.pop(i)
    print(statistics.median(tmp))

Submission status: Time Limit Exceeded

Solution code:

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ls = [x for x in map(int, input().split(' '))]
for x in range(0, n):
    dam = ls.copy()
    del dam[x]
    dam = sorted(dam)
    print(dam[int(len(dam)/ 2)])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    b = a.copy()
    b.remove(a[i])
    c = median(b)
    print(c)

Submission status: Time Limit Exceeded

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

A = []
for i in range(N):
    bisect.insort(A, X[i])

leftB = A[N//2 - 1]
rightB = A[N//2]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
lst = [int(i) for i in input().split()]
for i in range(n):
    local_lst = lst[:i] + lst[i+1:]
    lst_sort = sorted(local_lst)
    print(lst_sort[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = list(map(int, input().split()))
mid = (len(li)//2)-1

for i in range(n):
    temp = li[:i] + li[i+1:]
    temp.sort()
    print(temp[mid])

Submission status: Time Limit Exceeded

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

for i in range(N):
	Xwithout = X[:i]+X[i+1:]
	Xwithout.sort()
	print(Xwithout[N//2-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    li2 = li[:i]
    li2.extend(li[i+1:])
    li1.append(li2)

for i in range(n):
    li1[i].sort()
    print(li1[i][(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
import copy
n=int(input())
m=0
x=list(map(int,input().split()))
for i in range(n):
    y=copy.deepcopy(x)
    y.pop(i)
    if n%2==0:
        m=n//2
        y.sort()
        print(y[m-1])
    else:
        m=n//2
        y.sort()
        print((y[m]-y[m-1])/2)

Submission status: Time Limit Exceeded

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

num=[i+1 for i in range(N)]
l=zip(num,X)
l=sorted(l,key=lambda x:x[1])
indexlist=[]
for i in range(N):
    indexlist.append(l[i][0])
for i in range(N):
    x=indexlist.index(i+1)
    if x<=N//2-1:
        ans=l[N//2][1]
    else:
        ans=l[N//2-1][1]
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    print(statistics.median(X[0:i]+X[i+1:N]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from copy import deepcopy
n = int(input())
x = list(map(int,input().split()))

for i in range(n):
    y = deepcopy(x)
    y.remove(y[i])
    y.sort()
    print(y[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = int(input())
	A = input().split(" ")
	A = [int(s) for s in A]
	
	ans = []
	
	for i in range(len(A)):
		tmp = copy.deepcopy(A)
		tmp.pop(i)
		tmp.sort()
		
		a = (len(tmp) + 1) / 2
		
		#print(tmp)
		#print(int(a)-1)
		
		ans.append(tmp[int(a)-1])
		
	for i in ans:
		print(i)
			
	
if __name__ == "__main__":
	main()

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    print(median(num_lis[:i] + num_lis[i + 1:]))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    del tmp[i]
    print(median(tmp))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
from itertools import combinations

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    del tmp[i]
    print(median(tmp))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
from itertools import combinations

N = int(input())
num_lis = [int(_) for _ in input().split()]

for i in range(N):
    tmp = num_lis.copy()
    tmp.pop(i)
    print(median(tmp))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import math
import copy
def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    X = list(int(_) for _ in input().split())
    X_tmp = copy.deepcopy(X)
    X_tmp.sort()
    for i in range(N):
        if X_tmp.index(X[i]) >= N/2:
            print(X_tmp[(N//2)-1])
        else:
            print(X_tmp[(N//2)])
            
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    X = list(int(_) for _ in input().split())
    for i in range(N):
        X_tmp = [X[_] for _ in range(N) if _ != i]
        X_tmp.sort()        
        print(X_tmp[(N-2)//2])
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
num = (n // 2) - 1

for i in range(n):
    l = x[:]
    l.pop(i)
    l.sort()
    print(l[num])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
num = (n // 2) - 1

for i in range(n):
    l = x[:]
    l.pop(i)
    l.sort(reverse=True)
    print(l[num])

Submission status: Time Limit Exceeded

Solution code:
def resolve():
	n=int(input())
	x=list(map(int,input().split()))
	for i in x:
		s=sorted(x)
		s.remove(i)
		print(s[(n-2)//2])
	
resolve()

Submission status: Time Limit Exceeded

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

middle = int(n/2) - 1
for i in range(n):
  copy_list = copy.copy(x)
  elm = copy_list.pop(i)
  print(sorted(copy_list).pop(middle))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
sortedx = sorted(x)
dict = {k:sortedx[:i]+sortedx[i+1:] for i,k in enumerate(sortedx)}
med = (n-1)//2
for i in x:
    print(dict[i][med])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
n = int(input())
x = [int(i) for i in input().split()]
sortedx = sorted(x)
med = (n-1)//2
for i in x:
    tmp = sortedx[:]
    tmp.remove(i)
    print(tmp[med])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
n = int(input())
x = [int(i) for i in input().split()]
#med = (n-1)//2
#print(med)
for i in range(n):
    tmp = x[:i]+x[i+1:]
    print(median(tmp))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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 in l:
    print(u[0])
  else:
    print(l[-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy


if __name__ == '__main__':
    N = int(input())
    X_list = list(map(int, input().split()))

    answer = -1
    for i in range(0, N):
        tmp_X_list = copy.deepcopy(X_list)
        del(tmp_X_list[i])
        tmp_X_list = sorted(tmp_X_list)
        answer = tmp_X_list[N//2-1]
        print(answer)

Submission status: Time Limit Exceeded

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][1]
    print(ans)

Submission status: Time Limit Exceeded

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

y = [[x[i], i] for i in range(n)]
y.sort()

z = [0 for i in range(n)]
for i in range(n):
    z[y[i][1]] = (y[:i]+y[i+1:])[(n+1)//2-1][0]

for i in range(n):
    print(z[i])

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
    xi = copy.deepcopy(x)
    xi.pop(i)
    xi = sorted(xi,reverse=True)
    print(xi[(n-2)//2])

Submission status: Time Limit Exceeded

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

ans = []
for i in range(N):
    lst = [i for i in X]
    temp,lst[i] = lst[i] , 0
    lst.sort()
    ans.append(lst[int((N+1)/2)])

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

ans = []
for i in range(N):
    lst = []
    for j in range(N):
        if i != j:
            lst.append(X[j])
        else:
            continue
    lst.sort()
    ans.append(lst[int((N-1)/2)])

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

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

for i in range(n):
    ls = x[:(i)] + x[(i+1):]
    ls.sort()
    print(ls[int(n/2-1)])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    X_copy = copy.copy(X)
    del X_copy[i]
    print(list(sorted(X_copy))[(N-1)//2])

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

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

for i in range(N):
    temp_med = X.copy()
    temp_med.pop(i)
    print(statistics.median(temp_med))

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

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

for i in range(N):
    temp_med = X.copy()
    temp_med.pop(i)
    med.append(statistics.median(temp_med))

for i in range(len(med)):
    print(med[i])

Submission status: Time Limit Exceeded

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

#sort X
sortedX = sorted(X)


for i in range(N):
    tmpsortedX = copy.copy(sortedX)
    tmpsortedX.remove(X[i])
    #print(tmpsortedX)
    print(tmpsortedX[int(N/2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
def median(L):
    #L = sorted(L)
    n = len(L)
    m = int(n/2)
    if n % 2 == 0:
        return (L[m - 1] + L[m]) / 2
    else:
        return L[(n - 1) // 2]
x_sort = sorted(x)
for i in range(n):
    b = x_sort.copy()
    b.remove(x[i])
    print(median(b))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
def median(list):
    L = sorted(list)
    n = len(L)
    m = int(n/2)
    if n % 2 == 0:
        return (L[m - 1] + L[m]) / 2
    else:
        return L[(n - 1) // 2]
for i in range(n):
    b = x[:i] + x[i+1:]
    print(median(b))

Submission status: Time Limit Exceeded

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

c = N // 2
x = sorted(X)
for v in X:
	if x.index(v) < c:
		print(x[c])
	else:
		print(x[c - 1])

Submission status: Time Limit Exceeded

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

x = sorted(X)
for v in X:
	i = x.index(v)
	x.pop(i)
	print(x[(N - 1) // 2])
	x.insert(i, v)

Submission status: Time Limit Exceeded

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

for n in range(N):
	x = X.copy()
	x.pop(n)
	#print(sorted(x))
	print(sorted(x)[(N - 1) // 2])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
 
N = int(stdin.readline().rstrip())
 
A = [int(x) for x in stdin.readline().rstrip().split()]
 
for a in range(N):  
  B = sorted([elem for idx,elem in enumerate(A) if idx != a])
  print(B[(N-1)//2])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

N = int(stdin.readline().rstrip())

A = [int(x) for x in stdin.readline().rstrip().split()]

a = 0
while a < N:  
  B = [elem for idx,elem in enumerate(A) if idx != a]
  B.sort()
  a += 1
  print(B[(N-1)//2])

Submission status: Time Limit Exceeded

Solution code:
import statistics

N = int(input())

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

a = 0
while a < N:  
  B = [elem for idx,elem in enumerate(A) if idx != a]
  a += 1
  print(statistics.median(B))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

a = 0
while a < N:  
  B = [elem for idx,elem in enumerate(A) if idx != a]
  B.sort()
  a += 1
  print(B[(N-1)//2])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

a = 0
while a < N:  
  B = sorted(A[:a]+A[a+1:])
  a += 1
  print(B[(N-1)//2])

Submission status: Time Limit Exceeded

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

m_r = N//2
m_l = m_r-1

A = sorted(X)

for i in range(N):
    if A.index(X[i]) >= m_r:
        print(A[m_l])
    else:
        print(A[m_r])

Submission status: Time Limit Exceeded

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):
  tmp=arr[:i]+arr[i+1:]
  ans[arr[i][1]]=tmp[pos][0]
for i in range(n):
  print(ans[i])

Submission status: Time Limit Exceeded

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

Y = X.copy()
Y.sort()

for x in X:
    Y.remove(x)
    print(Y[N//2-1])
    Y.append(x)
    Y.sort()

Submission status: Time Limit Exceeded

Solution code:


def read_input():
    n = int(input())
    xlist = list(map(int, input().split()))
    return n, xlist


def get_median(s):
    l = len(s)
    return s[int((l-1)/2)]


def submit():
    n, xlist = read_input()

    xlist = [(x, i) for i, x in enumerate(xlist)]
    xlist.sort(key=lambda x: x[0])

    pos_dic = {}
    for i, x in enumerate(xlist):
        pos_dic[x[1]] = i

    for i in range(n):
        target = pos_dic[i]
        p = xlist.pop(target)
        print(get_median(xlist)[0])
        xlist.insert(target, p)




if __name__ == '__main__':
    submit()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

for i in range(N):
    index= sort_xs.index(Xs[i])
    mid = 0
    if index < N // 2:
        mid = N // 2
    else:
        mid = N // 2 - 1

    print(sort_xs[mid])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
#x = {i: int(j) for i, j in enumerate(input().split())}
#y = list(x.values())
x = [int(i) for i in input().split()]
y = x.copy()
y.sort()
e = y[n//2 - 1]
o = y[n//2]
for xx in x:
    if y.index(xx) >= n//2:
        print(e)
    else:
        print(o)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
y = x.copy()
y.sort()
for xx in x:
    if y.index(xx) >= n//2:
        print(y[n//2 - 1])
    else:
        print(y[n//2])

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter

N = int(input())
X = [(int(x),ind) for ind,x in enumerate(input().split())]
X.sort(key=itemgetter(0))
B = [0]*N
for i in range(N):
    B[X[i][1]] = (X[:i]+X[i+1:])[(N-2)//2]
for i in B:
    print(i[0])

Submission status: Time Limit Exceeded

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

for i in range(N):
	temp_list = x_list[:]
	del temp_list[i]
	print(sorted(temp_list,reverse=True)[(N//2)-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
for i in range(n):
    y = x.copy()
    del y[i]
    y.sort()
    print(y[n//2 - 1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
s = sorted(x)
for i in x:
    cp = s.copy()
    del cp[cp.index(i)]
    print(cp[n//2-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

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

for i in range(len(X)):
    A = copy.deepcopy(X)
    del A[i]
    print(statistics.median(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

for i in range(N):
    B = X.copy()
    B.pop(i)
    print(int(np.median(B)))

Submission status: Time Limit Exceeded

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

for i in range(N):
    l = X[:i]
    r = X[i+1:]
    B = []
    B.extend(l)
    B.extend(r)
    B.sort()
    print(B[int((len(B)-1)/2)])

Submission status: Time Limit Exceeded

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

for i in range(N):
    B = []
    for j in range(N):
        if i != j:
            B.append(X[j])
    B.sort()
    print(B[int((len(B)-1)/2)])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
Xs = list(map(int,input().split()))
Ys = sorted(Xs)
num = (len(Xs)-1)//2
for i in range(N):
    Yscopy=copy.deepcopy(Ys)
    Yscopy.remove(Xs[i])
    print(Yscopy[num])

Submission status: Time Limit Exceeded

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

def ind(l :list):
    return int((len(l)+1)/2)-1

for i in l:
    t = sl.copy()
    t.pop(sl.index(i))
    print(t[int((N/2)-1)])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
input_num = input().split(" ")
center = int(n/2)
for num in input_num:
    num_list = []
    status = 0
    for i in range(n):
        int_num = int(input_num[i])
        if input_num[i] == num and status == 0:
            status = 1
            continue
        num_list.append(int_num)
    num_list.sort()
    print(num_list[center-1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
l=list(map(int, input().split()))
for i in range(N):
    tmp = l[0:i] + l[i+1:]
    tmp.sort()
    print(tmp[int((len(tmp)+1)/2)-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
    Y = list(X)
    del Y[i]
    Y.sort()
    print(Y[N//2-1])

Submission status: Time Limit Exceeded

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

import statistics

for i in range(N):
    tempX = list(X)
    del tempX[i]
    print(statistics.median(tempX))

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
X = list(map(int, input().split()))
B = []
for i in range(N):
    X_sub = X[:i] + X[i+1:]
    B.append(statistics.median(X_sub))
for i in range(N):
    print(B[i])

Submission status: Time Limit Exceeded

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

import statistics

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

for i in range(n):
    xc = x[:]
    del xc[i]
    print(statistics.median_high(xc))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N = int(input())
X = [int(i) for i in input().split()]
ans = []
for i in range(N):
    num = X.pop(i)
    a = X[:]
    a.sort()
    ans.append(a[(N-1)//2])
    X.insert(i, num)
print(*ans, sep='\n')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
a = x.copy()
x.sort()
for i in a:
    if x.index(i) < n//2:
        print(x[int(n//2)])
    else:
        print(x[int(n//2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
a = x.copy()
x.sort()
for i in a:
    num = x.index(i)
    if num < n//2:
        print(x[int(n//2)])
    else:
        print(x[int(n//2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
a = x.copy()
x.sort()
n_dict = {i: x.index(a[i]) for i in range(n)}
for num in n_dict.values():
    if num < n//2:
        print(x[int(n//2)])
    else:
        print(x[int(n//2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x_dict = {i:j for i,j in enumerate(x)}
x.sort()
n_dict = {i:x.index(x_dict[i]) for i in range(n)}
for i in range(n):
    num = n_dict[i]
    if num < n//2:
        print(x[int(n//2)])
    else:
        print(x[int(n//2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
x_dict = {i:j for i,j in enumerate(x)}
x.sort()
for i in range(n):
    num = x_dict[i]
    a = x.copy()
    a.remove(num)
    print(a[int(n/2)-1])

Submission status: Time Limit Exceeded

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


for i in range(N):
    Y = copy.copy(X)
    del Y[i]
    Y.sort()
    print(Y[N//2-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    l = [x[j] for j in range(n) if i != j]
    l.sort()
    print(l[int(len(l)/2)])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
L = list(map(int,input().split()))
for i in range(N):
    Li = L[0:i] + L [i+1::]
    k = statistics.median(Li)
    print(k)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
x=list(map(int,input().split()))
l=[]       
for i in range(N):
    temp=[]
    for j in range(N):
        if i!=j:
            temp.append(x[j])
    l.append(temp)
length=N-1

for i in range(N):
    l[i]=sorted(l[i])
    print(l[i][(length+1)//2-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
    Z=X[:i]+X[i+1:]
    print(int(np.median(Z)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy

n = int(input())
x = [int(num) for num in input().split()]
xx = sorted(x)

for i in range(n):
    x_ =copy.copy(xx) 
    x_.remove(x[i])
    b = x_[n//2 - 1]
    print(b)

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(n):
    xs_ = copy.copy(xs)
    xs_.remove(x[i])
    
    b = xs_[(n//2 - 1)]
    print(b)

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(n):
    x_ = copy.copy(x)
    del x_[i]

    x_ = sorted(x_)
    b = x_[(n//2 - 1)]
    print(b)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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