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:
def main():
    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])

        
if __name__ == '__main__':
    main()

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[:i]+x[i+1:]))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

read = sys.stdin.buffer.read

n,*x = list(map(int, read().split()))


for i in range(0,n):
  temp = []
  try:
    temp = x[:i]
  except:
    pass
  try:
    temp += x[i+1:]
  except:
    pass
  temp.sort()
  print(temp[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):
    copy_X = sort_X.copy()
    copy_X.remove(X[i])
    
    print(copy_X[(N-1)//2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


c = int(N/2)

for i in range(N):
    Y = copy.deepcopy(X)
    Y[i:i+1] = []
    Y = sorted(Y, key= lambda x: -x)
    print(Y[c-1])

Submission status: Time Limit Exceeded

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

N = N - 1 + N % 2

XX = copy.copy(X)
X.sort()

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

Submission status: Time Limit Exceeded

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

N = N - 1 + N % 2

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

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

for i in range(N):
  xs = X[:i] + X[i+1:]
  print(statistics.median(xs))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = list(map(int, input().split()))
xs = sorted(X)
x0, x1 = xs[n // 2 - 1:n // 2 + 1]
[print(x1) if xs.index(x) <= n // 2 - 1 else print(x0) for x in 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[(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(0, N):
    tmp_list = []
    if i==0:
        tmp_list = []
    else:
        tmp_list = X[:i]
    tmp_list.extend(X[i+1:])
    med = np.median(tmp_list)
    print(int(med))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def C(m):
    if xsort[m] > x[i]: 
        return True
    return False
 
 
n = int(input())
x = list(map(int, input().split()))

xsort = sorted(x)

for i in range(n):
    mb = 0
    lb = n
    m = (mb+lb) // 2
    for j in range(100):
        if C(m):
            lb = m
        else: 
            mb = m
    if mb < n//2:
        print(xsort[n//2])
    else:
        print(xsort[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
def C(m):
    if xsort[m] > x[i]: 
        return True
    return False


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

for i in range(n):
    mb = 0
    lb = n
    m = (mb+lb) // 2
    xsort = sorted(x)
    for j in range(100):
        if C(m):
            lb = m
        else: 
            mb = m
    if mb < n//2:
        print(xsort[n//2])
    else:
        print(xsort[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
def C(m):
    if xsort[m] > x[i]: 
        return True
    return False


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

for i in range(n):
    mb = 0
    lb = n
    m = (mb+lb) // 2
    xsort = sorted(x)
    for j in range(1000):
        if C(m):
            lb = m
        else: 
            mb = m
    if mb < n//2:
        print(xsort[n//2])
    else:
        print(xsort[n//2-1])

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[i+1:]
    xi.sort()
    print(xi[n//2-1])

Submission status: Time Limit Exceeded

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

cs = x_sorted[n // 2 - 1]
cb = x_sorted[n // 2]

for i, v in enumerate(x):
    if x_sorted.index(v) < n // 2:
        print(cb)
    else:
        print(cs)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    X_s = sorted(X)

    medi = defaultdict(int)

    for i in range(len(X)):
        if X[i] in medi.keys():
            print(medi[X[i]])
        else:
            dummy = X_s[:]
            dummy.remove(X[i])
            m = dummy[len(dummy) // 2]
            print(m)
            medi[X[i]] = m

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from collections import Counter

N = int(input())
X = list(map(int, input().split()))
Xs = sorted(X)
c1 = np.median(Xs[1:]).astype(int)
c2 = np.median(Xs[:-1]).astype(int)

for i in range(N):
    if Xs.index(X[i]) < N // 2:
        print(c1)
    else:
        print(c2)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
from collections import Counter

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

for i in range(N):
    print(np.median(X[:i] + X[i+1:]).astype(int))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from copy import deepcopy

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

Submission status: Time Limit Exceeded

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

mid = (N - 1) // 2
for i in range(N):
    copy_num = copy.deepcopy(numbers)
    index_num = copy_num.pop(i)
    copy_num = sorted(copy_num)
    print(copy_num[mid])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import statistics
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N = int(readline())
    X = list(map(int, readline().split()))
    sort_X = sorted(X)
    for i in range(N):
        median = statistics.median(X[:i]+X[i+1:])
        print(median)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N,*X = map(int,open(0).read().split())
chu = N//2
for i in range(N):
    copy_X = X[:]
    copy_X.sort()
    copy_X.reverse()
    copy_X.remove(X[i])
    print(copy_X[chu - 1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
 
 
def readstr():
    return input().strip()
 
 
def readint():
    return int(input())
 
 
def readnums():
    return map(int, input().split())
 
 
def readstrs():
    return input().split()
 
 
def main():
    N = readint()
    X = list(readnums())
    xs = sorted(X)
    for i in X:
        d = xs.index(i)
        if d >= N // 2:
            print(xs[N // 2 - 1])
        else:
            print(xs[N // 2])
 
 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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


for i in range(N):
    x = copy.copy(X) 
    x.pop(i)
    x.sort()
    print(x[int(length/2)-1])
    # print(x,X)

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter
import collections
N = int(input())

X = list(map(int, input().split()))
d = {} 
for x in X:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
    
keys = sorted(d.keys(), reverse = True)

for x in X:
  idx = N//2
  d[x] -= 1
  for k in keys:
    idx -= d[k]
    if idx <= 0:
      print(k)
      break
  d[x] += 1

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter
import collections
N = int(input())

X = list(map(int, input().split()))
d = {} 
for x in X:
  if x in d:
    d[x] += 1
  else:
    d[x] = 1
    
for x in X:
  idx = N//2
  d[x] -= 1
  for k in sorted(d.keys(), reverse = True):
    idx -= d[k]
    if idx <= 0:
      print(k)
      break
  d[x] += 1

Submission status: Time Limit Exceeded

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    X = list(readnums())
    xs = sorted(X)
    for i in X:
        d = xs.index(i)
        if d >= N // 2:
            print(xs[N // 2 - 1])
        else:
            print(xs[N // 2])


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

A = X.copy()

A.sort()

for i in range(len(X)):
    for j in range(len(X)):
        if X[i] == A[j]:
            if j <= N/2-1:
                print(A[int(N/2)])
                break
            else:
                print(A[int(N/2)-1])
                break

Submission status: Time Limit Exceeded

Solution code:
import sys

# import math
# import bisect

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

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

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


# ===CODE===


def main():
    n = ni()
    d = na()

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
from statistics import median_low,median_high,median
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrX = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)

for i in range(N):
    lis = arrX[:i] + arrX[i+1:]
    lis.sort()
    print(median(lis))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

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-1)])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
  if i==0:
    Y=X[i+1:]
    Y=sorted(Y)
    print(Y[(N//2-1)])
  else:
    Y=X[0:i]+X[i+1:]
    Y=sorted(Y)
    print(Y[(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[:i]+x[i+1:]
    y_new = sorted(y)
    print(y_new[n//2-1])

Submission status: Time Limit Exceeded

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

sorted_x = sorted(x_ls)
bigger = sorted_x[n//2]
smaller = sorted_x[n//2 - 1]
for i in range(n):
    target_ind = sorted_x.index(x_ls[i])
    if target_ind <= n // 2 - 1:
        ans = bigger
    else:
        ans = smaller
    print(ans)

Submission status: Time Limit Exceeded

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

argsort = [[x, i] for i, x in enumerate(X)]
argsort.sort()
argsort = [[i, j] for j, [_, i], in enumerate(argsort)]
argsort.sort()
ranks = [j + 1 for _, j in argsort]

indices = [[x, i] for i, x in enumerate(X)]
indices.sort()
indices = {(i + 1): x for i, (x, _) in enumerate(indices)}


median = N // 2
for i in range(0, N):
    r = ranks[i]
    if r <= median:
        print(indices[median + 1])
    else:
        print(indices[median])

Submission status: Time Limit Exceeded

Solution code:
import copy

n = int(input())
x = list(map(int,input().split()))
base = copy.deepcopy(x)
base_1 = copy.deepcopy(x)
base.sort()
base_1.sort()

for i in range(n):
  a_l = base.index(x[i])
  a_u = base_1.index(x[i])
  
  if a_l == (n-1)-a_u:
    if n//2 > a_l:
      ans = base[n//2]
    elif n//2 <= a_l:
      ans = base[n//2-1]
      
  else:
    if (a_l <= n//2-1) and (n//2 <= a_u):
      ans = base[a_l]
    elif a_u <= n//2 - 1:
      ans = base[n//2]
    elif n//2 <= a_l:
      ans = base[n//2 - 1]
      
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import copy

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    X = readInts()

    import statistics

    for i in range(n):
        A = (X[:i] + X[i+1:] if i+1 < n else X[:i])
        print(statistics.median(A))




if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:

url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    Xs_dic = {i: Xs[i] for i in range(len(Xs))}
    for i in range(len(Xs)):
        tmp = Xs_dic.copy()
        tmp.pop(i)
        tmp = sorted(list(tmp.values()))
        print(tmp[(len(tmp)) // 2])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

url = "https://atcoder.jp//contests/abc094/tasks/arc095_a"

def main():
    N = int(input())
    Xs = list(map(int, input().split()))
    all_num = sum(Xs)
    for i in range(len(Xs)):
        tmp = Xs[::]
        tmp.pop(i)
        tmp.sort()
        print(tmp[(len(tmp)) // 2])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if n==2:
  print(x[1])
  print(x[0])
  
else:
  for i in range(n):
    sub=x[i]
    x[i]=0
    print(sorted(x)[-num])
    x[i]=sub

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
xs = [int(elem) for elem in input().split()]

for i in range(n):
  print(sorted(xs[:i] + xs[i+1:])[(n//2 - 1)])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

X = []
for i in range(n):
    X.append([x[i],i])

X.sort(reverse=True)
ans = []
for i in range(n):
    sub = X.pop(i)
    ans.append([X[(n // 2) - 1][0],sub[1]])
    X.insert(i, sub)

ans.sort(key = lambda x: x[1])

for i in range(n):
    print(ans[i][0])

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

x = np.array(x)

for i in range(0,n):
    print(int(np.median(np.r_[x[:i],x[i+1:]])))
   # print(x[:i])
   # print(x[i+1:])

Submission status: Time Limit Exceeded

Solution code:
import copy

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    center = (n+1)//2
    x_s = list(map(int,input().split()))
    sorted_x_s = sorted(x_s)

    for i in x_s:
        if sorted_x_s.index(i) < center:
            print(sorted_x_s[center])
        else:
            print(sorted_x_s[center-1])






if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

    num_list_copy = num_list[:]

    num_list.sort()

    s_num_list = num_list[:]

    for i in range(n):
        num_list.remove(num_list_copy[i])
        print(num_list[(n-2)//2])
        num_list = s_num_list[:]

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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






resolve()

Submission status: Time Limit Exceeded

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

    for i in range(N):
        print(Z[Y.index(X[i])])




resolve()

Submission status: Time Limit Exceeded

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
#import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

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

    for i in range(N):
        print(Z[Y.index(X[i])])




resolve()

Submission status: Time Limit Exceeded

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
#import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    X=list(map(int,input().split()))
    Z=[np.median(X[:i]+X[i+1:]) for i in range(N)]

    for i in range(N):
        print(int(Z[i]))



resolve()

Submission status: Time Limit Exceeded

Solution code:
# import bisect
# from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
#import math
import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(input())
    X=list(map(int,input().split()))
    Y=sorted(X)

    Z=[np.median(Y[:i]+Y[i+1:]) for i in range(N)]

    for i in range(N):
        print(int(Z[Y.index(X[i])]))



resolve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy

def Many_Medians(n , xl):

    ans = []
    ap = n // 2 - 1

    for i in range(n):
        outi = copy.copy(xl)
        outi.pop(i)
        outi.sort()
        ans.append(outi[ap])

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    ans = Many_Medians(n, xl)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=tuple(Y)
for a in range(N):
    b=Z[a]
    answer=list(Z)
    answer.remove(b)
    answer=sorted(answer)
    print(answer[int(N/2-1)])

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics
N=int(input())
X=input().split()
Y=[int(a) for a in X]
Z=tuple(Y)
for a in range(N):
    b=Z[a]
    answer=list(Z)
    answer.remove(b)
    print(statistics.median(answer))

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):
    tmp = np.array(X[:i]+X[i+1:])
    med = np.median(tmp)
    print(int(med))

Submission status: Time Limit Exceeded

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

sorted_list = sorted(list)
for i in range(len(list)):
  copy_list = list.copy()
  copy_list.pop(i)
  copy_list.sort()
  print(copy_list[int(((n-1)/2))])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

#m = (n // 2) - 1
for i in range(n):
    l = x[:i] + x[i+1:]
#    l.sort()
    print(statistics.median(l))
    #print(l[m])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n = int(input())
    x = list(map(int, input().split()))
    x2 = sorted(x)
    med = x2[(n+1)//2-1]
    for i in range(n):
        x3 = sorted(x[:i] + x[i+1:])
        print(x3[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(N):
    sort=sorted(X[:i]+X[i+1:])
    print(sort[N//2-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

mid_n = len(a)//2
for i in range(n):
    if a.index(x[i]) < mid_n:
        print(a[mid_n])
    else:
        print(a[mid_n-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
    popX = X.pop(i)
    Xsort = sorted(X)
    print(Xsort[(N-1)//2])
    X.insert(i,popX)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = list(map(int, input().split()))
for i in range(n):
    if i !=0 and i != n-1:
        l = X[:i] + X[i+1:]
    elif i == 0:
        l = X[1:]
    else:
        l = X[:n-1]
    l.sort()
    print(l[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):
    print(sorted((x[:i] + x[i+1:]))[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#094
n=int(input())
x=list(map(int,input().split()))
x.insert(0,0) #x[0]に0を挿入
sorted_x = sorted(x[:])

for i in range(1,n+1):
    idx = sorted_x.index(x[i])
    print(sorted_x[n//2+1] if idx<=n//2 else sorted_x[n//2])

Submission status: Time Limit Exceeded

Solution code:
import math
import itertools
import statistics
#n = int(input())
#n, d = list(input().split())
N = int(input())
X = list(map(int, input().split()))
tmp = 0

for i in range(N):
    tmp = X[i]
    X[i]=0
    print(statistics.median_high(X))
    X[i]=tmp