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:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    x = LI()
    for i in range(n):
        xb = x[::1]
        del xb[i]
        xb.sort()
        print(xb[n//2-1])
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Time Limit Exceeded

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

for i in range(n):
    if s.index(t[i]) <= n / 2 - 1:
        print(s[int((n/2))])
    else:
        print(s[int(n/2)-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    t.pop(i)
    t.sort()
    print(t[int((n/2)-1)])
    t = s[:]

Submission status: Time Limit Exceeded

Solution code:
import copy

input = open(0).read

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


def main():
    a = copy.copy(X)
    a.sort()

    for i in range(N):
        print(a[N // 2] if a.index(X[i]) < N // 2 else a[N // 2 - 1])

    return


main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
X=rl()
Xs = sorted(X)
Xsl = Xs[:N//2]
Xsr = Xs[N//2:]

for x in X:
    if x in Xsl:
            print(Xsr[0])
    else:
            print(Xsl[-1])

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    l=copy.deepcopy(a)
    l.pop(i)
    l.sort()
    ans=l[n//2-1]
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    l=copy.deepcopy(a)
    l.pop(i)
    median=statistics.median(l)
    print(median)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

X=list(map(int,input().split()))
sort_X=sorted(X)
for i in range(n):
    if sort_X.index(X[i])<int(n/2):
        print(sort_X[int(n/2)])
    else:
        print(sort_X[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):
    S=X[:i]+X[i+1:]
    S.sort()
    print(S[int(n/2)-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a

import itertools
import collections
import bisect
import copy

def main():
    N = int(input())
    X = list(map(int, input().split()))
    for i in range(N):
        temp_X = copy.copy(X)
        del temp_X[i]
        temp_X.sort()
        # print(temp_X)
        print(temp_X[(len(temp_X)+1)//2 - 1])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
L=[int(i) for i in input().split()]
L1=sorted(L)
a=L[N//2]
b=L[N//2-1]
 
for i in range(N):
  L2=L1[:]
  L2.remove(L[i])
  print(L2[N//2-1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N = int(input())
X = np.array([int(n) for n in input().split()])
iX = np.argsort(X)
sX = X[iX]

A = [0] * N

for i in range(N):
    L = np.concatenate([sX[:i], sX[i+1:]])
    A[iX[i]] = L[(N-2)//2]

for a in A:
    print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=[int(i) for i in input().split()]
for i in range(n):
    A=x[0:i]+x[i+1:]
    A.sort()
    half=n//2
    print(A[n-half-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

import statistics
for i in range(len(x)):
    print(statistics.median(x[0:i] + x[i+1:len(x)]))

Submission status: Time Limit Exceeded

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

for i in range(N):
  x = sorted(X[:i]+X[i+1:])
  print(x[len(x)//2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in X:
    news_X=X.copy()
    news_X.remove(i)
    print(sorted(news_X)[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
def median(n, lst):
    n=n-1
    if n < 1:
        return None
    if n % 2 == 1:
        return sorted(lst)[n//2]
    else:
        return sum(sorted(lst)[n//2-1:n//2+1])/2.0


n = int(input())
X=[i for i in map(int,input().split())]

for i in X:
    news_X=X.copy()
    news_X.remove(i)
    # print(news_X)
    print(median(n,news_X))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
N = int(input())
x = list(map(int, input().split()))
half = N//2

idx = np.argsort(x)

nums = [x[idx[half-1]], x[idx[half]]]
mask = idx[:half]

for i in range(N):
    if i in mask:
        print(nums[1])
    else:
        print(nums[0])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
A = []
for i in range(N):
    j = Y.index(X[i])
    A.append((Y[:j] + Y[j+1:])[(N-1)//2])
print('\n'.join(map(str, A)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(sorted(X[:i] + X[i+1:])[(N-1)//2])
print('\n'.join(map(str, A)))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
from copy import copy

N = int(input())
X = list(map(int,input().split()))
for num in range(N):
    subX = X.copy()
    del subX[num]
    print(median(subX))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
X = list(map(int,input().split()))
for num in range(N):
    print(median([X[i] for i in range(N) if i != num]))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
x = list(map(int, input().split()))
k = list(x)
p = list(x)
for i in range(a):
    del k[i]
    #print(k)
    k.sort()
    #print(k)
    if a%2==0:
        print(k[a//2-1])
    else:
        print((k[a//2]+k[a//2-1])/2)
    k = list(p)

Submission status: Time Limit Exceeded

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

for i in range(n):
    A2 = A.copy()
    A2.pop(i)
    A2.sort()
    print(A2[(n // 2) - 1])

Submission status: Time Limit Exceeded

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

left = x[math.floor((n-1)/2)]
right = x[math.ceil((n-1)/2)]

for a in X:
    i = x.index(a)
    if i < (n-1)/2:
        print(right)
    else:
        print(left)

Submission status: Time Limit Exceeded

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

sorted_inputs = inputs[:]
sorted_inputs.sort()
left = sorted_inputs[N//2-1]
right = sorted_inputs[N//2]

for item in inputs:
    index = sorted_inputs.index(item)
    if index <= N // 2 - 1:
        print(right)
    else:
        print(left)

Submission status: Time Limit Exceeded

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

sorted_inputs = inputs[:]
sorted_inputs.sort()

for item in inputs:
    index = sorted_inputs.index(item)
    if index <= N // 2 - 1:
        print(sorted_inputs[N//2])
    else:
        print(sorted_inputs[N//2-1])

Submission status: Time Limit Exceeded

Solution code:
from statistics import mean,median

n=int(input())
a=[int(i) for i in input().split()]

med=median(a)

a1=[i for i in a if i <= med]
a2=[i for i in a if i >= med]
#print(a1)
#print(a2)

for i in range(n):
  if a[i]<min(a2):
    print(min(a2))
  else:
    print(max(a1))

#if a[0] < median(a)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

n=int(input())
a=[int(i) for i in input().split()]

for j in range(n):
  b=[int(i) for i in range(n)]
  b.pop(j)
  c=[a[k] for k in b] 
  print(median(c))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

X1 = map(int, input().split())

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

Submission status: Time Limit Exceeded

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

sorted_l = sorted(l)

for i in range(n):
    tmp = sorted_l.copy()
    tmp.remove(l[i])
    med = tmp[(n-1)//2]
    print(med)

Submission status: Time Limit Exceeded

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


def median(l):
    #l is odd
    l.sort()
    n = len(l)
    return l[n//2]


for i in range(n):
    tmp = l.copy()
    tmp.remove(tmp[i])
    print(median(tmp))

Submission status: Time Limit Exceeded

Solution code:
import collections as cl

def get_median(arr) :
	
	idx = len(arr) + 1
	idx = int(idx / 2) - 1
	return arr[idx]

N = int(input())
X = [int(i) for i in input().split()]
X2 = X[:]
X2.sort(reverse=True)
dic = {}

for i in range(len(X)) :
	l = X2[:]
	key = l.pop(i)
	if (key not in dic) :
		dic[key] = get_median(l)

for i in X :
	print(dic[i])

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
for i in range(a):
    for j,r in enumerate(ar):
        if j != i:
            br.append(r)
    br.sort()
    print(br[a//2-1])
    br.clear()

Submission status: Time Limit Exceeded

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

    a = x[1:]
    a.sort()
    print(a[n//2-1])

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

    a = x[:n-1]
    a.sort()
    print(a[n//2-1])

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


for item in xarray:
    if newArray.index(item)<=int(n/2-1):
        print(newArray[int(n/2)])
    else:
        print(newArray[int(n/2)-1])

Submission status: Time Limit Exceeded

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


for item in xarray:
    if newArray.index(item)<=int(n/2-1):
        print(newArray[int(n/2)])
    else:
        print(newArray[int(n/2)-1])

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):
    x2 = x.copy()
    x2.pop(i)
    print(int(np.median(x2)))

Submission status: Time Limit Exceeded

Solution code:
import collections as cl

def get_median(arr) :
	arr.sort(reverse=True)
	
	idx = len(arr) + 1
	idx = int(idx / 2) - 1
	return arr[idx]

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

for i in range(len(X)) :
	l = X[:]
	l.pop(i)
	print(get_median(l))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    tarr = list(arr)
    tarr.remove(tarr[i])
    tarr.sort()
    print(tarr[(len(tarr) + 1) // 2 - 1])

Submission status: Time Limit Exceeded

Solution code:
from copy import copy

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

x_sorted = sorted(x)

for i in range(n):
    l = x_sorted.copy()
    l.remove(x[i])
    print(l[int(n/2)-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:
    i_index = x_sort.index(i)
    x_sort.pop(i_index)
    print(x_sort[(n-2) // 2])
    x_sort.insert(i_index, i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
x_sort = sorted(x)
for i in x:
    i_index = x_sort.index(i)
    x_sort.remove(i)
    print(x_sort[(n-2) // 2])
    x_sort.insert(i_index, i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

for i in range(N):
    if X2.index(X[i]) < N // 2:
        print(r)
    else:
        print(l)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
#N = 5
#a = [3, 2, 2, 4, 1]


a = np.array(a, dtype=int)
for i in range(N):
    ind = np.ones(N, dtype=bool)
    ind[i] = False
    tmp = a[ind]
    print(int(np.median(tmp)))

Submission status: Time Limit Exceeded

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

a = (N/2)-1

for i in range(N):
    tmp_x = X_list[:i] + X_list[i+1:]
    tmp_x.sort()
    print tmp_x[a]

Submission status: Time Limit Exceeded

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]
    print(int(np.median(tmp)))

Submission status: Time Limit Exceeded

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(np.median(tmp))
for rett in ret:
  print(int(rett))

Submission status: Time Limit Exceeded

Solution code:
import copy
import statistics
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)

for i in range(n):
  x.pop(i)
  print(statistics.median(x))
  x.insert(i, z[i])

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)

for i in range(n):
  x.pop(i)
  x.sort()
  print(x[int((n - 1) / 2)])
  del x[:]
  x.extend(z)

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
x = [int(y) for y in input().split()]
z = copy.deepcopy(x)

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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 = sorted(y)
  print(y[int( n/2-1 )])

Submission status: Time Limit Exceeded

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

c = (n - 1) // 2

for i in range(len(x)):
    x2 = x.copy()
    x2.pop(i)
    x2.sort()
    print(x2[c])

Submission status: Time Limit Exceeded

Solution code:
def median(L) :
    L = sorted(L)
    return L[len(L)//2]

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

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy
N = int(input())
X = list(map(int,input().split(" ")))
Y = copy.deepcopy(X)
Y.sort()
for i in range(N):
    Z = copy.deepcopy(Y)
    Z.remove(X[i])
    print(Z[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(N):
    Y = copy.deepcopy(X)
    Y[i] = 0
    Y.remove(0)
    print(statistics.median(Y))

Submission status: Time Limit Exceeded

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

Solution code:
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    y=[]
    for j in range(n):
        if j!=i:
            y.append(x[j])
    y.sort(reverse=True)
    print(y[n//2-1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import copy

e = [[int(i) for i in input().split()] for i in range(2)]

for i in range(e[0][0]):
    tmp = copy.deepcopy(e[1])
    tmp.pop(i)
    tmp.sort()
    a = int(e[0][0])/2
    print(tmp[int(a)-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
arrayX = input().split()
listX = list(map(int, arrayX))
listX2 = list(map(int, arrayX))
listX2.sort()

listForAnswer =[]
index=0
number = len(listX)//2
if number ==1:
    print(listX[1])
    print(listX[0])
else:
    while index<len(listX):
        skipped =0
        count =0
        index2 =0
        while index2<len(listX):
            if count == number:
                listForAnswer.append(listX2[index2-1])
                break
            elif (listX2[index2]==listX[index] and skipped ==0):
                skipped =1
                index2+=1    
            else:
                count+=1
                index2+=1
        index+=1

    for ans in listForAnswer:
        print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def median(_list):
	_list.sort()
	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: Time Limit Exceeded

Solution code:
import numpy as np

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
input=input()
listX=list(map(int, input.split()))
index=0
while index< len(listX):
    listS=list(map(int, input.split()))
    key = listX[index]
    listS.sort()
    if key<listS[len(listX)//2-1] or key==listS[len(listX)//2-1]:
        print(listS[len(listX)//2])
    else:
        print(listS[len(listX)//2-1])
    index+=1

Submission status: Time Limit Exceeded

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

if __name__ == "__main__":
    N = int(input())
    Xs = list(map(int, input().split()))
    Xs_ = Xs[::]
    Xs_.sort()

    for i in range(N):
        Xs__ = Xs_[::]
        Xs__.remove(Xs[i])
        print(Xs__[int(N/2)-1])

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

print(statistics.median(x[1:]))

for i in range(1,n-1):
    print(statistics.median(x[0:i]+x[i+1:]))

print(statistics.median(x[0:n-1]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int,input().split()))
med = N//2

for i in range(N):
    ans = a[:i]+a[i+1:]
    print(sorted(ans)[med-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i, x in enumerate(x_list):
    tmp = x_list.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[(len(tmp))//2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int, input().split()))
x_=[]
for i in range(n):
    x_=x[0:len(x)]
    del x_[i]
    x_1=[]
    x_1=x_.sort()
    print(x_[int(n/2)-1])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int, input().split()))
x_=[]
for i in range(n):
    x_=x[0:len(x)]
    del x_[i]
    x_1=[]
    x_1=x_.sort()
    b=[]
    #b[i]=x_[int(n/2)-1]
    #print(b[i])
    print(x_[int(n/2)-1])

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
x_tmp = input().split()
x = []
for _ in x_tmp:
    x.append(int(_))
num = n//2
for i in range(n):
    tmp_x = copy.copy(x)  # listを普通に代入すると、ディープコピーになる
    tmp_x.pop(i)  # pop(index)の出力は、削除した要素の値
    # その上で、popするとリスト自体も改変される
    # print(tmp_x)
    tmp_x = sorted(tmp_x, reverse=True)
    # print(tmp_x)
    print(tmp_x[num-1])

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(N // 2 + 1):
    for j in range(N - 1 - i):
        if(S_X[j] > S_X[j + 1]):
            tmp = S_X[j + 1]
            S_X[j + 1] = S_X[j]
            S_X[j] = tmp
# s_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(a <= miX):
        print(mi1X)
    else:
        print(miX)

Submission status: Time Limit Exceeded

Solution code:
import copy

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

for i in range(N // 2 + 1):
    for j in range(N - 1 - i):
        if(S_X[j] > S_X[j + 1]):
            tmp = S_X[j + 1]
            S_X[j + 1] = S_X[j]
            S_X[j] = tmp
# s_X = sorted(X)
miX = S_X[N // 2 - 1]
mi1X = S_X[N // 2]
# print(S_X, X)
# print(miX, mi1X)

# print(miX, mi1X)
# print(X)
for a in X:
    if(S_X.index(a) <= N // 2 - 1):
        print(mi1X)
    else:
        print(miX)

Submission status: Time Limit Exceeded

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

s_X = sorted(X)
miX = s_X[N // 2 - 1]
mi1X = s_X[N // 2]

# print(miX, mi1X)
# print(X)
for a in X:
    if(s_X.index(a) <= N // 2 - 1):
        print(mi1X)
    else:
        print(miX)

Submission status: Time Limit Exceeded

Solution code:
from numpy import median
import copy

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

sorted_x = sorted(x)
sorted_ind = list(np.argsort(x))
half_n = int(n / 2)

# print(x)
# print(half_n)
# print(sorted_ind)
# print(sorted_x)

for i in range(n):
    # print("==========")
    ind = sorted_ind.index(i)
    # print("ind: {}".format(ind))
    if ind <= half_n - 1:
        print(sorted_x[half_n - 1 + 1])
    else:
        print(sorted_x[half_n - 1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    tmp = x[:i]+x[i+1:]
#     print(tmp)
    print(sorted(tmp)[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if s_x.index(i)<n//2:
        print(med_2)
    else:
        print(med_1)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    N = int(input())
    X = li_input()

    sX = sorted(X)

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


main()

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    N = int(input())
    X = li_input()

    sX = sorted(X)

    for x in X:
        idx = sX.index(x)
        sX.pop(idx)
        print(sX[len(sX) // 2])
        sX.insert(idx, x)


main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = list(int(i) for i in input().split())
b = list([] for i in range(N))
for i in range(N):
    for j in range(N):
        if j != i:
            b[i].append(x[j])
    b[i].sort()
    print(b[i][int(N/2-1)])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

a = list(map(int,input().split()))
b = a.copy()
ans =[]

for i in range(N):
    del b[i]
    c = sorted(b)
    ans.append(c[int(N/2-1)])
    b.insert(i,a[i])
for i in ans:
    print(i)