Problem:


Score : 300 points

Problem Statement

When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.

You are given N numbers X_1, X_2, ..., X_N, where N is an even number.
For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.

Find B_i for each i = 1, 2, ..., N.

Constraints

2 \leq N \leq 200000

N is even.

1 \leq X_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print N lines.
The i-th line should contain B_i.

Sample Input 1

4
2 4 4 3

Sample Output 1

4
3
3
4

Since the median of X_2, X_3, X_4 is 4, B_1 = 4.

Since the median of X_1, X_3, X_4 is 3, B_2 = 3.

Since the median of X_1, X_2, X_4 is 3, B_3 = 3.

Since the median of X_1, X_2, X_3 is 4, B_4 = 4.

Sample Input 2

2
1 2

Sample Output 2

2
1

Sample Input 3

6
5 5 4 4 3 3

Sample Output 3

4
4
4
4
4
4



Sample input:
4
2 4 4 3


Sample output:
4
3
3
4

Submission status: Wrong Answer

Solution code:
n= int(input())
m = int(n//2)
data = [int(i) for i in input().split()]

data.sort()

for i in range(m):
    print(data[m])
for i in range(m):
    print(data[m-1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = sorted(map(int, input().split()))
m = (N-1)//2

for i in range(N):
    x = X.copy()
    x.pop(i)
    print(x[m])

Submission status: Wrong Answer

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

d = N // 2
a = X[d]
b = X[d - 1]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [int(i) for i in input().split()]
Y = sorted(X)
a = Y[-1 + N // 2]
b = Y[N // 2]
print(a, b)
for Xi in X:
    if Xi <= a:
        print(b)
    else:
        print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
a=[int(k) for k in raw_input().split(" ")]

sa=sorted(a)
mn,mx=sa[n/2-1],sa[n/2]

for k in a:
    if a<=mn:
        print mx
    else:
        print mn

Submission status: Wrong Answer

Solution code:
n=int(raw_input())
a=[int(k) for k in raw_input().split(" ")]

sa=sorted(a)
mn,mx=a[n/2-1],a[n/2]

for k in a:
    if a<=mn:
        print mx
    else:
        print mn

Submission status: Time Limit Exceeded

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

def main():
    n = int(input())
    x = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n):
        fix = x[0:i] + x[i + 1:n]
        fix.sort()
        ans[i] = fix[n // 2 - 1]
    print(*ans, sep='\n')


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

for e in l:
    lc.remove(e)
    lc.sort()
    print(lc[len(lc) // 2])
    lc = l.copy()

Submission status: Time Limit Exceeded

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

for i in range(N):
    tmp = X_list.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[int(N/2)-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

#ans = []
for i in x:
    keylist = lis[:lis.index(i)]+lis[lis.index(i)+1:]
    #print(keylist)
    ans = keylist[n//2-1]
    print(ans)

Submission status: Time Limit Exceeded

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

sorted_x = sorted(X)

l, r = sorted_x[n//2], sorted_x[n//2-1]
for x in X:
    if sorted_x.index(x) < n // 2:
        print(l)
    else:
        print(r)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
z = set(x)
t1 = y[n//2-1]
t2 = y[n//2]
idx = dict([])
for i in z:
    idx[i] = y.index(i)
for i in x:
    t = idx[i]
    if t<n//2:
        print(t2)
    else:
        print(t1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
t1 = y[n//2-1]
t2 = y[n//2]
y = tuple(y)
for i in x:
    t = y.index(i)
    if t<n//2:
        print(t2)
    else:
        print(t1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = x.copy()
y.sort()
t1 = y[n//2-1]
t2 = y[n//2]
for i in x:
    t = y.index(i)
    if t<n//2:
        print(t2)
    else:
        print(t1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
N=int(input())
suji=list(map(int,input().split()))
for i in range(N):
    c = copy.copy(suji)
    c.remove(suji[i])
    c.sort()
    print(c[(len(c) + 1) // 2-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=input().split(' ')
suji = []
for j in range(len(a)):
    suji.append(int(a[j]))
#for i in range(len(a)):
  #suji.append(int(a[i]))
for i in range(N):
    c=[]
    c.extend(suji[0:i] + suji[i + 1:len(suji)])
    aiueo = (len(c) + 1) // 2-1
    print(sorted(c)[(len(c) + 1) // 2-1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=input().split(' ')
suji=[]
#for i in range(len(a)):
  #suji.append(int(a[i]))
for i in range(N):
    suji.clear()
    for j in range(len(a)):
        suji.append(int(a[j]))

    c=[]
    c.extend(suji[0:i] + suji[i + 1:len(suji)])
    aiueo = (len(c) + 1) // 2-1

    print(sorted(c)[aiueo])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  yy = xx[:i] + xx[i+1:]
  zz = sorted(yy)
  print(zz[(n-1)//2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

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

def naive(x):
    return [median(x[:i] + x[i+1:]) for i in range(len(x))]

for i in naive(x):
    print(i)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

test = [0, 1, 2, 3, 4, 5]

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import copy


def center(lst):
    lst.sort()
    value = lst[(len(lst) - 1) // 2]
    return value


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

    ans_lst = []
    for i in range(n):
        lst = copy.deepcopy(x_lst)
        del lst[i]
        ans_lst.append(center(lst))

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)

ans = []
for x in X:
    Xc = Xsrt.copy()
    Xc.remove(x)
    B = Xc[len(Xc)//2]
    ans.append(B)

for i in ans:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import copy
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  Y=sorted(X)
  for i in range(N):
    T=copy.copy(Y)
    T.remove(X[i])
    print(T[t-1])
  return 

main()

Submission status: Time Limit Exceeded

Solution code:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import statistics
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  t=(N+1)//2
  for i in range(N-1):
    print(sorted((X[:i]+X[i+1:]))[t-1])
  print(sorted(X[:N-1])[t-1])
  return 

main()

Submission status: Time Limit Exceeded

Solution code:
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import statistics
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  X=list(map(int,pin().split()))
  for i in range(N):
    try:
      print(statistics.median(X[:i]+X[i+1:]))
    except:
      pass
  return 

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
import statistics

n=int(input())
x=list(map(int,input().split()))
y=copy.copy(x)
s=0
for i in range(n):
    s=x[i]
    y.remove(s)
    print(statistics.median(y))
    y.append(s)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    x = [int(xn) for xn in input().split()]
    x_sorted = sorted(x)
    idx_median = (n - 1) // 2
    for xn in x:
        target = [*x_sorted]
        target.remove(xn)
        print(target[idx_median])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in x:
    I = X.index(i)
    l,r = I, n-I
    if I+1 <= n//2:
       print(X[I+n//2-l])
    else:
        print(X[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

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

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
x = RI()

for i in range(n):
    t = x[i]
    x.pop(i)
    ans = median(x)
    x.insert(i,t)
    print(ans)
exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

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

Submission status: Time Limit Exceeded

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


import statistics

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

Submission status: Time Limit Exceeded

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

for i in X:
  x = sorted(X)
  p = x.index(i)
  x.pop(p)
  print(x[n//2- 1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
import sys 
import copy
input = sys.stdin.readline

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

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

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
N=int(input())
X=list(map(int,input().split()))
res=[0]*N
for i in range(N) :
  temp=X[i]
  X.remove(temp)
  print(median(X))
  X.insert(i,temp)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N=int(input())
X=list(map(int,input().split()))
res=[0]*N
for i in range(N) :
  temp=X[i]
  X.remove(temp)
  res[i]=median(X)
  X.insert(i,temp)
  print(res[i])

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import copy


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    X = nl()
    X_s = sorted(X)
    for i in range(n):
        X_s_c = copy.copy(X_s)
        X_s_c.remove(X[i])
        print(X_s_c[(n - 1) // 2])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    X = nl()
    for i in range(n):
        print(sorted((X[:i] + X[i + 1:]))[(n - 1) // 2])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in range(n):
    L = s[:i]
    L.extend(s[i+1:])
    L.sort()
    a = len(L) // 2

    if len(L)%2 == 0:
        print((L[a]+L[a-1])/2)
    else:
        print(L[a])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

first_harf = Y[:int(N/2)]
second_harf = Y[int(N/2):]

for i in range(N):
    if X[i] in first_harf:
        print(second_harf[0])
    else:
        print(first_harf[-1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = sorted(X)
Y1 = Y[:N//2]
Y2 = Y[N//2:]
ans1 = Y1[-1]
ans2 = Y2[0]
for i in range(N):
  if X[i] in Y1:
    print(ans2)
  else:
    print(ans1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x_sort = sorted(x[:])

for i in range(n):
    x_sort_temp = x_sort[:]
    x_sort_temp.remove(x[i])
    #print("x_sort_removed",x_sort_temp)
    print(x_sort_temp[(n-1)//2])

Submission status: Time Limit Exceeded

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

idx = [i for i in range(n)]
c = zip(x, idx)
c = sorted(c,key=itemgetter(0))
x, idx = zip(*c)

medi1 = x[len(x)//2]
medi2 = x[len(x)//2-1]

for i in range(len(x)):
    if idx.index(i)<len(x)//2:
        print(medi1)
    else:
        print(medi2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
import statistics
n = int(input())
x = list(map(int,input().split()))
l = len(x)-1
for i in range(n):
	l2 = copy.copy(x)
	l2.pop(i)
	print(statistics.median(l2))

Submission status: Time Limit Exceeded

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

# In[2]:


import copy


# In[10]:


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


# In[11]:


for i in range(N):
    x_copy = copy.deepcopy(X)
    del x_copy[i]
    ans = sorted(x_copy)[N//2-1]
    print(ans)


# In[ ]:

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

from statistics import median 
for i in range(len(A)):
    tmp = A.pop(0)
    print(median(A))
    A.append(tmp)

Submission status: Time Limit Exceeded

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

m = (n-1)//2
l = sorted(x)
for i in x:
  if l.index(i) > m: print(l[m])
  else: print(l[m+1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
n = int(input())

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

nlis = sorted(lis)

a = math.floor((n-1)/2)

for i in range(n):
    nlis = sorted(nlis)
    tmp = lis[i]
    nlis.remove(lis[i])
    print(nlis[a])
    nlis.append(tmp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

x = list(map(int,input().split()))
sort_x = x.copy()
sort_x.sort()

cnt = 0
center_num = (N-1) // 2

for l in x:
    if sort_x.index(l) <= center_num:
        print(sort_x[center_num+1])
    else:
        print(sort_x[center_num])

Submission status: Time Limit Exceeded

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

# check
center = N // 2 - 1
for ind in range(N):
    if ind == 0:
        target = X[1:]
    elif ind == N - 1:
        target = X[:ind]
    else:
        target = X[:ind] + X[ind + 1:]
    target.sort()

    print(target[center])

Submission status: Time Limit Exceeded

Solution code:
import collections

N = int(input())

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

num_count = collections.Counter(x)

key_list = list(set(x))
key_list.sort()

cnt = 0
flg = True
n = 0
center_num = N // 2

for i in x:
    j = 0
    while cnt < center_num:
        n = key_list[j]
        if flg and i == n:
            cnt += num_count[n]-1
            flg = False
        else:
            cnt += num_count[n]
        j += 1
    print(n)
    cnt = 0
    flg = True

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

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

c = N // 2 - 1

for i in range(N):
  xp = x.copy()
  st = xp.pop(i)
  xp.sort()
  print(xp[c])

Submission status: Time Limit Exceeded

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    X = il()
    S = sorted(X)
    for x in X:
        idx = S.index(x)
        if idx < N // 2:
            print(S[N // 2])
        else:
            print(S[N // 2 - 1])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

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

from heapq import heappush
from heapq import heappop

def linked_heap_sort(lst):
    heap = []
    while lst:
        heappush(heap, lst.pop())
    while heap:
        lst.append(heappop(heap))
    return lst

y = copy.copy(x)
x = linked_heap_sort(x)

for i in range(n):
  num = x.index(y[i])
  if num >= n/2:
    print(x[int(n/2)-1])
  else:
    print(x[int(n/2)])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

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

y = copy.copy(x)
x.sort()

for i in range(n):
  num = x.index(y[i])
  if num >= n/2:
    print(x[int(n/2)-1])
  else:
    print(x[int(n/2)])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

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

"""
def median_cal(data):
    num = len(data)
    # データを昇順ソート
    data.sort()
    # データ数が偶数の場合
    median = int((num + 1) / 2 - 1)
    median = data[median]
    return median"""
  
for i in range(n):
  list1 = copy.copy(x)
  list1.pop(i)
  list1 = np.array(list1)
  median = np.median(list1)
  print(int(median))

Submission status: Time Limit Exceeded

Solution code:
import copy

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

def median_cal(data):
    num = len(data)
    # データを昇順ソート
    data.sort()
    # データ数が偶数の場合
    median = int((num + 1) / 2 - 1)
    median = data[median]
    return median
  
for i in range(n):
  list1 = copy.copy(x)
  list1.pop(i)
  print(median_cal(list1))

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.sort()
    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.sort()
    print(y[n//2-1])

Submission status: Time Limit Exceeded

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

import statistics
import copy

def median(tmp_numbers):
    return statistics.median(tmp_numbers)

def main():
    numbers=[]
    n = int(input())
    numbers=list(map(int,input().split()))

    for i in range(n):
        tmp_numbers=copy.deepcopy(numbers)
        tmp_numbers.pop(i)
        ans = median(tmp_numbers)
        print(ans)

if __name__=="__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def median(l):
    l = sorted(l)
    if len(l) % 2 == 1:
        return l[len(l) // 2]
    else:
        return (l[len(l)//2] + l[(len(l)//2)-1])//2


def main():
    N = int(input().strip())
    X_list = [int(i) for i in input().strip().split()]
    num = 0

    for i in range(N):
        if i < N-1:
            print(median(X_list[:i]+X_list[i+1:]))

        else:
            print(median(X_list[:i]))


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
from operator import itemgetter
N = int(input())
x = list(map(int, input().split()))
y = [x for x in range(N)]
z = list(zip(x, y))
z.sort()
x_, y = zip(*z)
val = N//2

for i in range(N):
    if list(y).index(i) < val:
        print(x_[val])
    else:
        print(x_[val-1])

Submission status: Time Limit Exceeded

Solution code:
import copy

n = int(input())
l = list(map(int,input().split()))
p = n//2

for i in range(n):
    tmp = copy.copy(l)
    tmp[i] = 0
    tmp.sort()
    print(tmp[p])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
num =int(((n-1) + 1) / 2) 
ans =  []
l = 0
for i in range(n):
    med = []
    for m in range(n):
        if (i != m):
            med.append(x[m])
    med.sort()
    ans.append(med[num-1])
    # l = l + 1
[print(i) for i in ans]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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


for i in range(len(argList)):
    argList2 = argList.copy()
    argList2.pop(i)
    argList2.sort()
    print(argList2[int(len(argList2)/2)])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x_l = list(map(int,input().split()))
s_x_l = [ (i, j) for i,j in enumerate(x_l) ]
s_x_l = sorted(s_x_l, key=lambda x: x[1])
size = len(s_x_l)
med_idx = int((size-1+1)/2)-1

ans = []
for i in range(n):
    left = s_x_l[:i]
    right = s_x_l[i+1:]
    idx = s_x_l[i][0]
    merge = left+right
    med = merge[med_idx][1]
    ans.append([idx, med])

ans = sorted(ans, key=lambda x:x[0])
for i in ans:
    print(i[1])

Submission status: Time Limit Exceeded

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

for i in range(n):
  X = list(A)
  X.pop(i)
  print(median(X))

Submission status: Time Limit Exceeded

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

for i in range(n):
  X = list(A)
  X.pop(i)
  X.sort()
  X.reverse()
  print(X[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):
  Xcopy = X.copy()
  Xcopy[i] = 0
  Xcopy.sort()
  print(Xcopy[int(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):
  Xcopy = X.copy()
  Xcopy[i] = 0
  Xcopy.sort()
  print(statistics.median(Xcopy[1:]))

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    
    def seach(x):
        l = 0
        r = n - 1
        while True:
            i = (l + r) // 2
            if r - l <= 1:
                if b[r] == x:
                    return r
                else:
                    return l
            if b[i] < x:
                l = i
            elif b[i] > x:
                r = i
            else: 
                return i
    
    for i in range(n):
        j = seach(a[i])
        c = b[:j] + b[j+1:]
        print(c[n // 2 - 1])

        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = sorted(a)
    for i in range(n):
        j = bisect.bisect_left(b, a[i])
        c = b[:j] + b[j+1:]
        print(c[n // 2 - 1])

        
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

        
if __name__ == '__main__':
    main()