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:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


# See:
# https://qiita.com/suecharo/items/30f5d817da4c948c3be6
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))
    order = list(x)

    for i in range(n):
        tmp = order[i]
        x.remove(tmp)
        x = quick_sort(x)
        print(x[(n // 2) - 1])
        x.append(tmp)

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):
    print(int(np.median(x[:i] + x[(i+1):])))

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
list = list(map(int, input().split()))
i = 0
for i in range(N):
  i = i + 1
  num = int(len(list)/2) - 1
  LIST = copy.deepcopy(list)
  del LIST[i-1]
  LIST.sort()
  print(LIST[num])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import copy
import numpy as np
n = int(input())
x = list(map(int, input().split(' ')))
xx = copy.deepcopy(x)

ind = int(len(x)/2) - 1
for i in range(n):
    xxx = copy.deepcopy(xx)
    xxx.remove(x[i])
    print(int(np.median(xxx)))

Submission status: Time Limit Exceeded

Solution code:
import statistics

N = int(input())
#N = 200000
X_list = list(map(int, input().split()))
#X_list = [i for i in range(N)]

median_idx = int(len(X_list) / 2) - 1

for idx, v in enumerate(X_list):
    X_copy = X_list.copy()
    X_copy.pop(idx)
    # median_idx = int((len(X_copy) + 1) / 2) - 1
    # print(median_idx)
    # X_copy.sort()
    print(int(statistics.median(X_copy)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
x = list(map(int, input().split()))
c = x[:]
for i in x:
    c.remove(i)
    print(int(np.median(c)))
    c = x[:]

Submission status: Time Limit Exceeded

Solution code:
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(1)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def median_without_naive(x, e):
    y = []
    y.extend(x)
    y.remove(e)
    index = len(x) // 2 - 1
    return sorted(y)[index]


def median_without(x, e, mid_left, mid_right):
    if x[mid_left] == x[mid_right]:
        return x[mid_left]
    else:
        if x.index(e) == mid_left:
            return x[mid_right]
        else:
            return x[mid_left]


def solve():
    [n] = IO_for_Contest.read_from_input()
    x = IO_for_Contest.read_n_int(n)
    y = sorted(x)
    threshold = 100000
    if len(y) <= threshold:
        for e in x:
            print(median_without_naive(y, e))
    else:
        buf = ''
        mid_left = len(y) // 2 - 1
        mid_right = len(y) // 2
        for e in x:
            buf += str(median_without(y, e, mid_left, mid_right)) + '\n'
        print(buf)


if __name__ == '__main__':
    # doctest.testmod()
    solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def merge(arr, arr2, l, m, r):
    n1 = m - l + 1
    n2 = r- m
 
    L = [0] * (n1)
    R = [0] * (n2)
    L1 = [0] * (n1)
    L2 = [0] * (n2)
 
    for i in range(0 , n1):
        L[i] = arr[l + i]
        L1[i] = arr2[l+i]
 
    for j in range(0 , n2):
        R[j] = arr[m + 1 + j]
        L2[j] = arr2[m+1+j]
 
    i = 0
    j = 0
    k = l
 
    while i < n1 and j < n2 :
        if L[i] <= R[j]:
            arr[k] = L[i]
            arr2[k] = L1[i]
            i += 1
        else:
            arr[k] = R[j]
            arr2[k] = L2[j]
            j += 1
        k += 1
 
    while i < n1:
        arr[k] = L[i]
        arr2[k] = L1[i]
        i += 1
        k += 1
 
    while j < n2:
        arr[k] = R[j]
        arr2[k] = L2[j]
        j += 1
        k += 1
 
def mergeSort(arr,arr2,l,r):
    if l < r:
 
        m = (l+(r-1))/2
 
        mergeSort(arr, arr2, l, int(m))
        mergeSort(arr, arr2, int(m+1), r)
        merge(arr, arr2, l, int(m), r)
 
 
N=int(input())
R=(N//2)-1
L=list(map(int,input().split()))
Q=list(range(1,N+1))
mergeSort(L,Q,0,N-1)
for I in range(1,N+1):
	E=Q.index(I)
	if E!=0 and E!=(N-1):
		C=L[:E]+L[(E+1):]
		print(C[R])
	elif E==0:
		C=L[1:]
		print(C[R])
	else:
		C=L[:N-1]
		print(C[R])

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


def main():
    N = int(stdin.readline().rstrip())
    Xi = [(i, int(x)) for i, x in enumerate(stdin.readline().rstrip().split())]
    Xi = sorted(Xi, key=lambda x: x[1], reverse=True)
    idx = N // 2 - 1
    result = [False for _ in range(N)]
    for n, item in enumerate(Xi):
        i = item[0]
        xi = Xi[:n] + Xi[n + 1:]
        result[i] = xi[idx][1]
    for x in result:
        print(x)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


for j in range(0,n):
    A=tag_list[0:j]
    test=tag_list[j+1:n]
    A.extend(test)
    A.sort()
    num=int(n/2-1)
    print(A[num])

Submission status: Time Limit Exceeded

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

ind = int(len(x)/2) - 1
for i in range(n):
    xxx = copy.deepcopy(xx)
    xxx.remove(x[i])
    print(xxx[ind])

Submission status: Time Limit Exceeded

Solution code:
def convert_X(x,index):
	if index == 0:
		return x[1:]
	if index == len(x)-1:
		return x[:-1]
	return x[:index] + x[index+1:]

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

for index in range(N):
	d_x = convert_X(X,index)
	d_x.sort()
	print(d_x[int( (len(d_x)+1)/2 ) -1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
for i in range(N):
    sorted_list = a[:i] + a[i+1:]
    sorted_list.sort()
    print(sorted_list[int((N-1)/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_in  = copy.deepcopy(x)
    x_in.pop(i)
    x_in.sort()
    print(x_in[int(n/2 -1)])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = input()
N = int(N)
A = input()
array = A.split()
ind = 0
for n in array:
    array[ind] = int(n)
    ind = ind+1

for i in range(N):
    temp = copy.deepcopy(array)
    temp.pop(i)
    out = sorted(temp)
    ind = (N//2)-1
    print(out[ind])

Submission status: Time Limit Exceeded

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

for i in x:
  y = l[:]
  t = y.remove(i)
  print(y[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(N):
    array_copy=copy.deepcopy(array)
    array_copy.pop(i)
    
    array_copy.sort()
    
    #print(array_copy)
    print(array_copy[int(N/2-1)])

Submission status: Time Limit Exceeded

Solution code:
import statistics
_ = input()
array = {i: int(x) for i, x in enumerate(input().split())}

for number in range(len(array)):
    temp = array.pop(number)
    print(statistics.median([v for k,v in array.items()]))
    array[number] = temp

Submission status: Time Limit Exceeded

Solution code:
import copy
from statistics import median


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
j = int(N/2)

for i in range(N):
    F = copy.deepcopy(X)
    del F[i]
#    F.sort()
    print(median(F))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(1)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def median_without_naive(x, e):
    y = []
    y.extend(x)
    y.remove(e)
    index = len(x) // 2 - 1
    return sorted(y)[index]


def median_without(x, e):
    mid_left = len(x) // 2 - 1
    mid_right = len(x) // 2
    if x[mid_left] == x[mid_right]:
        return x[mid_left]
    else:
        if x.index(e) == mid_left:
            return x[mid_right]
        else:
            return x[mid_left]


def solve():
    [n] = IO_for_Contest.read_from_input()
    x = IO_for_Contest.read_n_int(n)
    y = sorted(x)
    threshold = 100000
    if len(y) <= threshold:
        for e in x:
            print(median_without_naive(y, e))
    else:
        buf = ''
        for e in x:
            buf += str(median_without(y, e)) + '\n'
        print(buf)


if __name__ == '__main__':
    # doctest.testmod()
    solve()

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = [int(x) for x in input().split()]
Y = copy.copy(X)
X.sort()
Z = copy.copy(X)
#print(Y,Z)
center = (N -2) // 2

for i in range(0,N):
    X.remove(Y[i])
    #print(X)
    print(X[center])
    X = copy.copy(Z)
    #print(X)

Submission status: Time Limit Exceeded

Solution code:
# See:
# https://qiita.com/suecharo/items/30f5d817da4c948c3be6
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right


if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))

    for i in range(n):
        mod_x = list(x)
        tmp = mod_x.pop(i)
        mod_x = quick_sort(mod_x)
        print(mod_x[(n // 2) - 1])

Submission status: Time Limit Exceeded

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

sortedx = x[:]
sortedx.sort()

for i in range(n):
    cpsortedx = sortedx[:]
    cpsortedx.remove(x[i])
    #print(x_i)
    print(cpsortedx[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
N = int(raw_input())
nums = map(int, raw_input().split())
for i in range(N):
    nums_tmp = nums[0:i] + nums[i+1:N]
    nums_tmp = np.array(nums_tmp)
    print(int(np.median(nums_tmp)))
sys.exit()
num_t = []
index_t = []
for i,num in enumerate(nums):
    num_t.append([num, i])
num_t = sorted(num_t, key=lambda x: x[0])
for a in num_t:
    index_t.append(a[1])
for i in range(N):
    num_tmp = num_t
    idx = index_t.index(i)
    num_tmp = num_tmp[0:idx] + num_tmp[idx+1:N]
    print(num_tmp[(N/2) - 1][0])

Submission status: Time Limit Exceeded

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

def qsort(l):
  if l == [] or len(l) == 1:
    return l
  pivot = l.pop(0)
  smaller = list(filter(lambda x: x <= pivot, l))
  larger  = list(filter(lambda x: x > pivot,  l))
  return (qsort(smaller) + [pivot] + qsort(larger))

N = int(input())
target = N//2-1
X = [0] + list(map(int, input().split()))

for i in range(1, N+1):
  l = X[1:i] + X[i+1:N+1]
  print(qsort(l)[target])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import copy
N=int(input())
X=list(map(int, input().split()))
 
median=(N//2)-1
for i in range (N):
    X_instant=copy.deepcopy(X)
    X_instant.pop(i)
    X_instant.sort()
    output=X_instant[median]
    print(output)

Submission status: Time Limit Exceeded

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

for i in range(n):
    x_in  = copy.deepcopy(x)
    del x_in[i]
    x_in.sort()
    print(x_in[int(n/2 -1)])
    x_in  = []

Submission status: Time Limit Exceeded

Solution code:
def convert_X(x,index):
	if index == 0:
		return x[1:]
	if index == len(x)-1:
		return x[:-1]
	return x[:index] + x[index+1:]

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

for index in range(N):
	#print(index,convert_X(X,index))
	d_x = convert_X(X,index)
	d_x.sort()
	#print(d_x)
	#print(d_x[center-1])
	print(d_x[int( (len(d_x)+1)/2 ) -1])

Submission status: Time Limit Exceeded

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

for i in range(N):
    del_num = X[i:i + 1]
    X.pop(i)
    list1 = sorted(X)
    print(list1[N // 2-1])
    X.insert(i, int(del_num[0]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

if __name__ == '__main__':
	n = int(input())
	nums = list(map(int, input().split(" ")))
	for i in range(n):
		print(int(median(nums[0:i] + nums[i+1::])))

Submission status: Time Limit Exceeded

Solution code:
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(1)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def median_without_naive(x, e):
    y = []
    y.extend(x)
    y.remove(e)
    index = len(x) // 2 - 1
    return sorted(y)[index]


def median_without(x, e):
    mid_left = len(x) // 2 - 1
    mid_right = len(x) // 2
    if x[mid_left] == x[mid_right]:
        return x[mid_left]
    else:
        if x.index(e) == mid_left:
            return x[mid_right]
        else:
            return x[mid_left]


def solve():
    [n] = IO_for_Contest.read_from_input()
    x = IO_for_Contest.read_n_int(n)
    y = sorted(x)
    threshold = 100000
    if len(y) <= threshold:
        for e in x:
            print(median_without_naive(y, e))
    else:
        for e in x:
            print(median_without(y, e))

if __name__ == '__main__':
    # doctest.testmod()
    solve()

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    for i in range(N):
        sorted_list = sorted(a[:i] + a[i+1:])
        mid = sorted_list[int((N-1)/2)]
        print(mid)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
X_list = list(map(int, input().split()))
def get_median(a_list, i):
    b_list = a_list[:]
    del b_list[i]
    print(median(b_list))
for j in range(N):
    get_median(X_list, j)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = input()
xs = np.array(list(map(int,input().split())))

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

Submission status: Time Limit Exceeded

Solution code:
def m():
    N = int(input())
    X = [int(x) for x in input().split()]
    for x in range(N):
        XX = [x for x in X]
        XX[x] = -1
        XX.sort()
        print(XX[N//2])


m()

Submission status: Time Limit Exceeded

Solution code:

def main():
    N = int(input())
    X = list(map(int,input().split()))
    for i in range(N):
        tmp = []
        for j in range(N):
            if i != j:
                tmp.append(X[j])
        tmp.sort()
        index = int(N/2)
        print(tmp[index-1])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int,input().split()))
for i in range(N):
    a = X[i]
    del X[i]
    test = sorted(X)
    m = int((N-2)/2)
    print(test[m])
    X.insert(i,a)

Submission status: Time Limit Exceeded

Solution code:
import copy
a = int(input())
da = list(map(int,input().split()))
k = a//2
for i in range(a):
  n = copy.deepcopy(da)
  del n[i]
  n.sort()
  print(n[k-1])

Submission status: Time Limit Exceeded

Solution code:
import copy

N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
j = int(N/2)

for i in range(N):
    F = copy.deepcopy(X)
    del F[i]
    F.sort()
    print(F[j-1])

Submission status: Time Limit Exceeded

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

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

# solve
X_sorted = sorted(X)
for i in range(len(X)):
    Y = list(X_sorted)
    Y.remove(X[i])
    print(Y[int((len(Y)+1)/2-1)])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = [int(i) for i in input().split(" ")]
med = (N-1) // 2
tmp = X.copy()
tmp.sort()

for x in X:
    tmp_loop = tmp.copy()
    tmp_loop.remove(x)
    # print(tmp_loop)
    print(tmp_loop[med])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def mid(n):
    return int((n + 1) / 2)

N = int(input())
X = list(map(int, input().split()))
save = X[:]
for i in range(N):
    X = save[:]
    del X[i]
    X.sort()
    print(X[mid(N - 1) - 1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
XX=[int(x) for x in input().split()]   
#print(X)
for i in range (0,N):
    #print(XX)
    k=XX.pop(i)
    X=XX.copy()
    #print(X)
    XX.insert(i,k)
    X.sort()
    Y=X.copy()
    l=int((N-2)/2)
    print(Y[l])

Submission status: Time Limit Exceeded

Solution code:
import copy

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

m = {}
mid = int(n/2)-1

for i in x:
    if i in m:
        print(m[i])
    else:
        temp = copy.copy(sortedx)
        temp.remove(i)
        print(temp[mid])
        m[i] = temp[mid]

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    n = int(input())
    x = list(map(int, input().split()))

    for i in range(n):
        mod_x = list(x)
        tmp = mod_x.pop(i)
        mod_x = sorted(mod_x)
        print(mod_x[(n // 2) - 1])

Submission status: Time Limit Exceeded

Solution code:
import copy

def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    for i in range(N):
        sorted_list = copy.deepcopy(a)
        sorted_list.pop(i)
        sorted_list = sorted(sorted_list)
        mid = sorted_list[int((N-1)/2)]
        print(mid)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def b(nums):
	nums.sort()
	return nums[len(nums)//2]
if __name__ == '__main__':
	n = int(input())
	nums = list(map(int, input().split(" ")))
	for i in range(n):
		print(b(nums[0:i] + nums[i+1::]))

Submission status: Time Limit Exceeded

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

X_sort = sorted(X)

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

Submission status: Time Limit Exceeded

Solution code:
from statistics import median_low

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

for i in range(len(xs)):
    print(median_low(xs[0:i] + xs[i+1:len(xs)]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(N):
    tmp = copy.deepcopy(X)
    del tmp[i]
    tmp = sorted(tmp)
    print(tmp[int((len(tmp)+1)/2)-1])

Submission status: Time Limit Exceeded

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

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

# solve
for i in range(len(X)):
    X_ = list(X)
    X_.pop(i)
    X_ = sorted(X_)
    print(X_[int((len(X_)+1)/2-1)])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())

a = list(map(int,input().split()))
d = int(n/2)+1
for i in range(n):
    b = a[0:i]+a[i+1:n]
    median = np.median(b)
    print(int(median))

Submission status: Time Limit Exceeded

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

for i in range(n):
    x_i = x[:]
    x_i.pop(i)
    x_i.sort()
    #print(x_i)
    print(x_i[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
array = list(map(int, input().split()))
for i in range(0, N):
    konichiwa = list(array)
    konichiwa.pop(i)
    konichiwa.sort()
    print(konichiwa[int(N / 2) - 1])

Submission status: Time Limit Exceeded

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

# 2.delete i-th component
for i in range(n):
    xi_res = x[:i] + x[i+1:]

    # 3.print median
    half = int(n/2)
    print(sorted(xi_res)[half-1])

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
nums = map(int, raw_input().split())
num_t = []
index_t = []
for i,num in enumerate(nums):
    num_t.append([num, i])
num_t = sorted(num_t, key=lambda x: x[0])
for a in num_t:
    index_t.append(a[1])
for i in range(N):
    num_tmp = num_t
    idx = index_t.index(i)
    num_tmp = num_tmp[0:idx] + num_tmp[idx+1:N]
    print(num_tmp[(N/2) - 1][0])

Submission status: Time Limit Exceeded

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

import copy

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

    for i in range(n):
        t = copy.deepcopy(x)
        del t[i]
        t.sort()
        print(t[int(n / 2 - 1)])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(len(x)):
  y = l[:]
  t = y.pop(i)
  X[t] = y[n//2-1]
  
for i in x:
  print(X[i])

Submission status: Time Limit Exceeded

Solution code:
import copy

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

#print N
#print X

index = (N)/2 -1

for i in range(N):
    tmp = []
    tmp = copy.deepcopy(X)
    del tmp[i]
#    print tmp
    tmp.sort()
#    print tmp
#    print "index=", index
    print tmp[index]

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = [int(x) for x in input().split()]
Y = copy.copy(X)
#print(Y)
center = (N -2) // 2

for i in range(0,N):
    X.remove(X[i])
    #print(X,Y)
    X.sort()
    #print(X,Y)
    print(X[center])
    X = copy.copy(Y)

Submission status: Time Limit Exceeded

Solution code:
import copy
a = int(input())
da = list(map(int,input().split()))
k = a//2
for i in range(a):
  n = copy.deepcopy(da)
  del n[i]
  list.sort(n)
  print(n[k-1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X_list = list(map(int, input().split()))
def get_median(a_list, n, i):
    b_list = a_list[:]
    del b_list[i]
    b_list.sort()
    print(b_list[int(n/2)-1])
for j in range(N):
    get_median(X_list, N, j)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
c = int(n/2)-1
y = list(x)
y.sort()
for i in x:
    z=list(y)
    del z[z.index(i)]
    print(z[c])

Submission status: Time Limit Exceeded

Solution code:
import copy

N = int(input())

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

center = N // 2 - 1

for i in range(N):
    B = copy.deepcopy(X)
    B[i] = 0
    #del B[i]

    B.sort(reverse=True)

    print(B[center])

Submission status: Time Limit Exceeded

Solution code:
N = int(raw_input())
nums = map(int, raw_input().split())
num_t = []
for i,num in enumerate(nums):
    num_t.append([num, i])
num_t = sorted(num_t, key=lambda x: x[0])
for i in range(N):
    num_tmp = num_t
    for j, a in enumerate(num_tmp):
        if a[1] == i:
            num_tmp = num_tmp[0:j] + num_tmp[j+1:N]
    print(num_tmp[(N/2) - 1][0])

Submission status: Time Limit Exceeded

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

median_idx = int(len(X_list) / 2) - 1

for idx, v in enumerate(X_list):
    X_copy = X_list.copy()
    X_copy.pop(idx)
    #median_idx = int((len(X_copy) + 1) / 2) - 1
    #print(median_idx)
    X_copy.sort()
    print(X_copy[median_idx])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

def med(a):
    b = sorted(a)
    num = int((len(b)+1)/2)
    return b[num-1]


for i in range(n):
    temp = x[:]
    temp.remove(x[i])
    print(med(temp))

Submission status: Time Limit Exceeded

Solution code:
import statistics
_ = input()
array = [int(x) for x in input().split()]

for index in range(len(array)):
    temp = [x for i, x in enumerate(array) if i != index]
    print(statistics.median(temp))

Submission status: Time Limit Exceeded

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


abc094C()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N):
    Y = X[:]
    Y.pop(i)
    print(int(np.median(Y)))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import copy

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    N = int(input())
    X = [int(i) for i in input().split()]
    
    sorted_X = sorted(X)
    for i in range(N):
        remove_sorted_X = sorted_X[:]
        remove_num = X[i]
        
        remove_sorted_X.remove(remove_num)
        print(remove_sorted_X[int((N-1)/2)])
    
if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

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

for i in range(len(x)):
  y = x[:]
  y.pop(i)
  y = sorted(y)
  print(y[n//2-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
    tmp = X[:i]
    tmp.extend(X[i+1:])
    for j in range(int((N - 1) / 2)):
        tmp.remove(min(tmp))
    print(min(tmp))

Submission status: Time Limit Exceeded

Solution code:
import copy

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

Submission status: Time Limit Exceeded

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