Problem:


Score : 300 points

Problem Statement

Takahashi made N problems for competitive programming.
The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).

He is dividing the problems into two categories by choosing an integer K, as follows:

A problem with difficulty K or higher will be for ARCs.

A problem with difficulty lower than K will be for ABCs.

How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Problem Statement

2 \leq N \leq 10^5

N is an even number.

1 \leq d_i \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 1

6
9 1 4 4 6 7

Sample Output 1

2

If we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.
Thus, the answer is 2.

Sample Input 2

8
9 1 14 5 5 4 4 14

Sample Output 2

0

There may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 3

14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

Sample Output 3

42685



Sample input:
6
9 1 4 4 6 7


Sample output:
2

Submission status: Accepted

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

d = sorted(d)

print(d[int(n / 2)] - d[int((n / 2) - 1)])

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = list(map(int, input().split()))
D.sort()

k = int(len(D) / 2)

print(D[k] - D[k-1])

Submission status: Accepted

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

d.sort()
cnt = 0
if d[n//2] - d[n//2-1] > 1:
    cnt += d[n//2] - d[n//2-1] - 1
if d[n//2] > d[n//2-1]:
    cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()

d_ma = d[(N//2)]
d_mi = d[(N//2)-1]

cnt = 0
for i in range(d_mi,d_ma):
    cnt += 1

print( cnt )

Submission status: Accepted

Solution code:
#c.py
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
if lis[n//2] == lis[n//2-1]:
    print(0)
else:
    print(lis[n//2] - lis[n//2-1])

Submission status: Accepted

Solution code:
N = int(input())
dList = list(map(int,input().split()))
dList.sort()
mid = (N-1)//2
isEven = N%2 ==0
sa = dList[mid+1] - dList[mid]

print(sa)

Submission status: Accepted

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

d.sort()

len_d = len(d)
print( d[int(len_d/2)] - d[int(len_d/2)-1] )

Submission status: Accepted

Solution code:
N = int(input())
d = input().split()
d = [int(i) for i in d]
d.sort()
if d[int(N/2)-1] == d[int(N/2)]:
    print(0)
else:
    print(d[int(N/2)] - d[int(N/2)-1])

Submission status: Accepted

Solution code:

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

d_list.sort()

sep_l = d_list[(n//2) - 1]
sep_u = d_list[(n//2)]

ans = sep_u - sep_l

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dli = list(map(int,input().split()))
dli.sort()
print(dli[n//2]-dli[(n-1)//2])

Submission status: Accepted

Solution code:

N = int(input())
D = list(map(int, input().split(" ")))

D.sort()

k_1 = D[N//2 - 1]
k_2 = D[N//2]

ans = k_2 - k_1

print(ans)

Submission status: Accepted

Solution code:
import statistics
n= int(input())
d=list(map(int,input().split()))
d.sort()

k=int(d[int(n/2)]-d[int(n/2-1)])

print(k)

Submission status: Accepted

Solution code:
N = int(input())
lst = list(map(int, input().split()))
sorlist = sorted(lst)
A = N//2 - 1
B = N//2
if sorlist[A]!=sorlist[B]:
	ans = sorlist[B]-sorlist[A]
	print(ans)
else:
	print(0)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
h = n // 2
if d[h-1] == d[h]:
  print(0)
else:
  print(d[h]-d[h-1])

Submission status: Accepted

Solution code:
n = int(input())
number = list(map(int,input().split()))
number.sort()
q = number[n//2] -number[n//2-1]
if q == 0:
    print(0)
else:
    print(q)

Submission status: Accepted

Solution code:
# coding:utf-8


def main():
    N = int(input())
    # N, M = map(int, input().split())
    D = list(map(int, input().split()))
    ans = 0

    if N % 2 == 1:
        print(0)
        return
    D.sort()
    if D[N//2] == D[N//2 - 1]:
        print(0)
        return

    # print(D)
    ans = len(range(D[N//2 - 1] + 1, D[N//2]+1))
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

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

st = dlist[N//2 -1]
ed = dlist[N//2]
if st == ed:
    print(0)
    exit()
cnt = 0
for i in range(st+1, ed+1):
    cnt = cnt + 1

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[int(n/2)]-d[int(n/2)-1])

Submission status: Accepted

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

d = sorted(d)
print(d[int(N/2)] - d[int(N/2)-1])

Submission status: Accepted

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

if N % 2 == 1:
  print(0)
else:
  print(P[N//2]-P[N//2-1])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
e = sorted(d)
print(e[int(n/2)] - e[int(n/2)-1])

Submission status: Accepted

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

d.sort()

print(d[N // 2] - d[N // 2 - 1])

Submission status: Accepted

Solution code:
def read():
    n = int(input().strip())
    d = list(map(int, input().strip().split()))
    return n, d


def solve(n, d):
    d = sorted(d)
    median = n//2
    return d[median] - d[median-1]


if __name__ == '__main__':
    inputs = read()
    print('%d' % solve(*inputs))

Submission status: Accepted

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

d.sort()
c = int(n/2)
ans = d[c] - d[c-1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N//2]-d[N//2 -1])

Submission status: Accepted

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

d_s.sort()
mid = len(d_s) // 2
print(d_s[mid] - d_s[mid - 1])

Submission status: Accepted

Solution code:
# coding: utf-8
import time
import re
import math
import fractions

def main():
    global N,A,B,C,D,memo,mx,mn,temp
    N=int(input())
    D=list(map(int,input().split()))
    D.sort()
    print(D[N//2]-D[N//2-1])

start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp

Submission status: Accepted

Solution code:
N = int(input())
s = input().split()
d = []
for i in range(N):
    d.append(int(s[i]))
d.sort()
devide = len(d)//2
num =  d[devide]-d[devide-1]
print(num)

Submission status: Accepted

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

p.sort()
print(p[int(N/2)] - p[int(N/2-1)])

Submission status: Accepted

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

d.sort()

print(d[n//2] - d[n//2-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
#print(d)
sorted_d = sorted(d)
#print(sorted_d)

under_limit = sorted_d[int(N/2)-1]
upper_limit = sorted_d[int(N/2)]
#print(under_limit)
#print(upper_limit)
ans = upper_limit - under_limit
print(ans)

Submission status: Accepted

Solution code:
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

List.sort()

n = int(N / 2)

if List[n-1] == List[n]:
    print(0)
else:
    print(List[n] - List[n-1])

Submission status: Accepted

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

cnt = 0

d.sort()

#print(d)
print(d[int(n/2)] - d[int(n/2-1)])

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
D.sort()
k = int(len(D)/2)
print(D[k]-D[k-1])

Submission status: Accepted

Solution code:

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

a = sorted(d)

n2 = n//2
if a[n2-1] == a[n2]:
    print(0)
else:
    print(a[n2]- a[n2-1])

Submission status: Accepted

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

if X[N//2 - 1] == X[N//2]:
    print(0)
    exit()

print(X[N//2] - X[N//2 - 1])

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
nn=int(n/2)-1
ansd=d[nn]
if d[nn]!=d[nn+1]:
    print(d[nn+1]-d[nn])
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
n_half = int(N / 2)
print(d[n_half:][0] - d[:n_half][-1])

Submission status: Accepted

Solution code:
K = int(input())
d = list(map(int,input().split()))
k_half = K // 2
d.sort()
if d[k_half] == d[k_half - 1]:
  print("0")
else:
  print(d[k_half] - d[k_half - 1])

Submission status: Accepted

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

d = sorted(d)

print(d[N//2] - d[N//2-1])

Submission status: Accepted

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

dl.sort()
ans = 0

if len(dl) % 2 == 1:
    print(0)
else:
    i_mid = len(dl) // 2
    abc_max = dl[i_mid-1]
    arc_min = dl[i_mid]
    print(arc_min - abc_max)

Submission status: Accepted

Solution code:
import statistics
import math
n = int(input())
d = list(map(int,input().split()))
org_d = sorted(d)

median = statistics.median(org_d)

print(org_d[round(n/2)]-org_d[round(n/2-1)])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
ds = sorted(d)
ind = int(n/2)
if ds[ind] == ds[ind-1]:
    print(0)
else:
    print(ds[ind]-ds[ind-1])

Submission status: Accepted

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

    size = len(dd) // 2
    dd.sort()
    ans = 0


    if dd[size] == dd[size - 1]:
        ans = 0
    else:
        ans = dd[size] - dd[size - 1]

    print(ans)
    
resolve()

Submission status: Accepted

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


d.sort()

right = d[N // 2]
left = d[N // 2 - 1]

if left == right :
    print(0)
else :
    print(right - left)

Submission status: Accepted

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

ddd = sorted(ddd)

ddd_mid1 = ddd[N // 2 - 1]
ddd_mid2 = ddd[N // 2]
print(ddd_mid2 - ddd_mid1)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
D.sort()
print(D[int(N/2)]-D[int(N/2)-1])

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
data = sorted(data)
ind_mid = N // 2
ans = 0
if data[ind_mid] == data[ind_mid-1]:
    ans = 0
else:
    ans = data[ind_mid] - data[ind_mid-1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()
c = len(d)

dl = d[c // 2 - 1]
dr = d[c // 2]

ans = dr - dl
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
List = list(map(int, input().split()))
List.sort()
idx = n // 2
ans = List[idx]-List[idx-1]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[n//2]-a[(n//2)-1])

Submission status: Accepted

Solution code:

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

d.sort()

ans = d[N//2] - d[N//2-1]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)
print(d[int(n/2)]-d[int(n/2-1)])

Submission status: Accepted

Solution code:
import numpy as np
import copy


def main():
    # N = int(input())
    # ds = list(map(int, input().split()))
    # ds = np.array(ds, dtype=np.int)
    # ans = 0
    # for K in range(int(np.max(ds))+1):
    #     if np.sum(ds >= K) == N // 2:
    #         ans += 1
    # print(int(ans))

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

    ds = np.sort(ds)

    ans = ds[N//2] - ds[N//2-1]
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
input()
D=list(map(int,input().split()))
D.sort()
hanubn=int(len(D)/2)
print(D[hanubn]-D[hanubn-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
N = int(input())
D = list(map(int, input().split()))
D = sorted(D)
half = N//2
print(D[half] - D[half-1])

Submission status: Accepted

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

d.sort()
K = d[int(N/2)] - d[int(N/2)-1]
print(K)

Submission status: Accepted

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

ls.sort()
print(ls[int(n/2)]-ls[int(n/2)-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[(N+1)//2]-d[((N+1)//2)-1])

Submission status: Accepted

Solution code:
import math
N = int(input())
d = [int(i) for i in input().split()]
d.sort()
middle = (N-1)/2
left = d[math.floor(middle)]
right = d[math.ceil(middle)]
print(right-left)

Submission status: Accepted

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

half = N//2

D = sorted(D)
if D[half-1]==D[half]:
    print(0)
else:
    print(D[half]-D[half-1])

Submission status: Accepted

Solution code:
N=int(input())
D=sorted(list(map(int,input().split())))
K=0

if N%2==0 and D[N//2]!=D[N//2-1]:
    K=D[N//2]-D[N//2-1]

print(K)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
arr = [int(i) for i in input().split(" ")]
arr.sort()
middle = int(n / 2)
l = arr[middle-1]
h = arr[middle]
ans = h - l 
print(ans)

Submission status: Accepted

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

count = 0

d.sort()
avr = int(n/2)
count = d[avr] -d[avr -1] 

print(count)

Submission status: Accepted

Solution code:
N = int(input())
d= list(map(int, input().split()))
d.sort()
num_d = len(d)
thr = num_d//2

if(d[thr-1]==d[thr]):
    print(0)
else:
    print(d[thr]-d[thr-1])

Submission status: Accepted

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

d.sort()
m=int(n/2)
print(d[m]-d[m-1])

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
d = np.array([int(i) for i in input().split()])
d = np.sort(d)
i = int(len(d) / 2)
print(d[i] - d[i-1])

Submission status: Accepted

Solution code:
#while True:     
#  try:         
#    listC.append(list(map(int,input().split())))
#  except:         
#    break; 
#x,y = map(int,input().split())
N = int(input())
d = list(map(int,input().split()))
d.sort()
l = int(0.5*N -1)
r = int(0.5*N)

ans = int(d[r] - d[l])
                        
print(ans)

Submission status: Accepted

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

d0 = d[int(n/2)-1]
d1 = d[int(n/2)]

print(d1 - d0)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().split()))
sp = sorted(p)
mi = sp[int(n/2) - 1]
ma = sp[int(n/2)]
di = ma - mi
print(di)

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    D = [int(d) for d in input().split()]

    D = sorted(D)
    a = D[N//2 - 1]
    b = D[N//2]

    print(b-a)


main()

Submission status: Accepted

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

d.sort()
k=int(N/2)
a=d[k]-d[k-1]
print(a)

Submission status: Accepted

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

d.sort()

print(d[N//2] - d[N//2 - 1])

Submission status: Accepted

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

listd.sort()
s,l = listd[int(n/2)-1],listd[int(n/2)]
print(l-s)

Submission status: Accepted

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

d.sort()
dk = d[N//2-1:N//2+1]

dk_min = d[N//2-1]
dk_max = d[N//2]
ans = dk_max - dk_min
print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    d = list(map(int,input().split()))
    d.sort()
    l = n//2-1
    r = n//2
    ans = d[r]-d[l]
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

m=n//2
l=line[m]-line[m-1]
print(l)

Submission status: Accepted

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

list.sort()

B = int((n/2)-1)
A = int((n/2))

if list[B] == list[A]:
  print("0")
else:
  count = list[A] - list[B] 
  print(count)

Submission status: Accepted

Solution code:
import statistics

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

count = statistics.median_high(D) - statistics.median_low(D)

print(count)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[len(d)//2]-d[len(d)//2-1])

Submission status: Accepted

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

d.sort()
print(d[len(d)//2] - d[len(d)//2 - 1])

Submission status: Accepted

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

info.sort()
ans=info[int(n/2)]-info[int(n/2-1)]
print(ans)

Submission status: Accepted

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

d.sort()
print(d[N//2]-d[N//2 - 1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
left = N//2-1
right = N//2
print(d[right]-d[left])

Submission status: Accepted

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

D.sort()

print(str(D[n//2] - D[(n//2)-1]))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC132 C
import sys
sys.setrecursionlimit(1000000)
from collections import deque

N = int(input())
d = list(map(int,input().split()))
d.sort()
if N % 2 == 0:
    print(d[N//2]-d[N//2-1])
else:
    print(0)

Submission status: Accepted

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

n = N // 2 
ans = para[n] - para[n-1]
print(ans)

Submission status: Accepted

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

a = d[int((n-2)/2)]
b = d[int(n/2)]

print(b-a)

Submission status: Accepted

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
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
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
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print(a*b)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
print(d[int(n/2)]-d[int(n/2)-1])

Submission status: Accepted

Solution code:
import itertools


def solve(n, ds):
    cs = sorted(ds)
    cur_num_items = 0
    k_lb = None
    k_ub = None
    table = [(k, len(tuple(g))) for k, g in itertools.groupby(cs)]
    for k, m in table:
        cur_num_items += m
        if k_lb is not None:
            k_ub = k
            break
        elif cur_num_items == n // 2:
            k_lb = k + 1
        elif cur_num_items > n // 2:
            return 0
    res = k_ub - k_lb + 1
    return res


def main():
    n = int(input())
    ds = [int(d) for d in input().split()]
    res = solve(n, ds)
    print(res)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()
n2 = n//2
a = d[n2-1]
b = d[n2]
cnt = b - a
print(cnt)

Submission status: Accepted

Solution code:
N=int(input())
s=list(map(int,input().split()))
s.sort()
#print(s)
c=int(N/2)
a=s[c-1]
b=s[c]
print(b-a)

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right

def solve(N, D):
    D = sorted(D)
    m = D[N//2]
    l = bisect_left(D, m)  # <
    r = bisect_right(D, m) # <=
    #print("l=%d, D[l]=%d %s"%(l, D[l], D[:l]))
    #print("r=%d, D[r]=%d %s"%(r, D[r], D[:r]))
    if l == N-l:
        return D[l] - D[l-1]
    else:
        return 0



N = int(input())
D = [int(x) for x in input().split()]
print(solve(N, D))

Submission status: Accepted

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

d.sort()
print(d[int(n/2)]-d[int(n/2)-1])

Submission status: Accepted

Solution code:
n = int(input())
d = sorted([int(i) for i in input().split()])
print(d[n//2] - d[n//2-1])

Submission status: Accepted

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

d.sort()

print(d[n//2]-d[n//2-1])

Submission status: Accepted

Solution code:
import fractions

#inp = [int(i) for i in input().split()]
inp_ = int(input())

co =0
inp = [int(i) for i in input().split()]

inp.sort()

f = int(inp_/2) -1

ff = inp[f]
ee = inp[f+1]

dd = ee-ff

print(dd)

Submission status: Accepted

Solution code:
import sys

cin = sys.stdin
N = int(cin.readline())
d = list(map(int, cin.readline().split()))

d.sort()
m = N//2
print(d[m] - d[m-1])

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
data = list(map(int, input().split()))
data.sort()
if data[n // 2] == data[n // 2 - 1]:
    print(0)
else:
    ans = data[n // 2] - data[n // 2 - 1]
    print(ans)

Submission status: Accepted

Solution code:
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n = inn()
d = inl()
d.sort()
k = n//2
if d[k-1]==d[k]:
    print(0)
else:
    print(d[k]-d[k-1])

Submission status: Accepted

Solution code:
n = int(input())

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

l = sorted(l)


print(l[int(n/2)] - l[int(n/2)-1])

Submission status: Accepted

Solution code:
N=int(input())
d=sorted(list(map(int, input().split())))
print(d[int(N/2)]-d[int(N/2)-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = list(map(int, input().split()))
d.sort()

i = n//2

arc = d[i]
abc = d[i-1]

print(arc - abc)

Submission status: Accepted

Solution code:
n = int(input())
nums = sorted(list(map(int, input().split())))
print(nums[int(n/2)]-nums[int(n/2)-1])

Submission status: Accepted

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

center = N // 2
d.sort()
left = d[center - 1]
right = d[center]

print(right - left) if left != right else print(0)

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    D = sorted(map(int, input().split()))
    l = n // 2 - 1
    r = n // 2
    print(D[r] - D[l])
solve()

Submission status: Accepted

Solution code:
# coding: utf-8
#-------------------------------------------------------------------
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5
d = sorted(list( map(int, input().split()) ))	# 1 2 3 4 5 ...(ソート付き)

n=N//2

a=d[:n]
b=d[n:]

p(d)
p(a)
p(b)

ans=max(0, b[0]-a[-1])

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = input().split(" ")
D = [int(i) for i in D]
D = sorted(D)
#print(D)
LEN = int(len(D))
DV = int(int(LEN)/2)
#print(DV)
#print(D[DV-1])
HALF_B = D[DV-1]
HALF_F = D[DV]
DIF = HALF_F - HALF_B
#print(HALF_B,HALF_F,DIF)
print(DIF)

Submission status: Accepted

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

d = sorted(d)

if d[len(d)//2-1] == d[len(d)//2]:
    print(0)
else:
    dif =  d[len(d)//2] - d[len(d)//2-1]
    print(dif)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
print(d[len(d)//2]-d[len(d)//2-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
dn = sorted(d)
ea = dn[N//2-1]
eb = dn[N//2]

print(eb-ea)

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
A = sorted(A)
ans = int(A[int(n/2)] - A[int(n/2)-1])
print(ans)

Submission status: Accepted

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

numlist.sort()

num1 = N // 2
num2 = N // 2 + 1


if numlist[num2-1] == numlist[num1-1]:
    print(0)
else:
    print(numlist[num2-1]-numlist[num1-1])

Submission status: Accepted

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

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

ds = sorted(ds)

mid = N//2-1
print(ds[mid+1]-ds[mid])

Submission status: Accepted

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

cnt = 0
lend = len(d)
d = sorted(d)
left = d[(lend//2)-1]
right = d[(lend//2)]

print(right-left)

Submission status: Accepted

Solution code:
n = int(input())
d_list = list(map(int,input().split()))
d_list.sort()
print(d_list[n//2]-d_list[n//2-1])

Submission status: Accepted

Solution code:
n = int(input())
a = [int(_) for _ in input().split()] 
a.sort()
b = a[n//2]-a[n//2-1]
print(b)

Submission status: Accepted

Solution code:
n = int(input())
lm = list(map(int,input().split()))
if n % 2 != 0:
    print(0)
else:
    lm.sort()
    print(lm[int(1 + (n-1)/2)]-lm[int((n-1)/2)])

Submission status: Accepted

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

r = D[n // 2]
l = D[n // 2 - 1]

if l == r:
    print(0)
    exit()

print(r - l)

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
d = list(map(int, input().split()))
d.sort()
k = 0
m = n // 2
if d[m - 1] != d[m]:
    k = d[m] - d[m - 1]
print(k)

Submission status: Accepted

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

S.sort()

print(abs(S[N//2-1]-S[N//2]))

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
if d[n // 2] != d[n // 2 - 1]:
    print(d[n // 2] - d[n // 2 - 1])
else:
    print(0)

Submission status: Accepted

Solution code:
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))
    d = merge_sort(d)
    l = len(d)
    a = d[l//2-1]
    b = d[l//2]
    print(b-a)

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
A=sorted(A)
print(A[len(A)//2]-A[len(A)//2-1])

Submission status: Accepted

Solution code:
def resolve():

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

    d = sorted(d)

    index_left = int((len(d) / 2) -1)
    index_right = int((len(d) / 2))

    num_left = d[index_left]
    num_right = d[index_right]

    print(num_right - num_left)
    
resolve()

Submission status: Accepted

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

D.sort()
between = D[int(N/2)] - D[int((N/2)-1)]

print(between)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
output = 0
if N%2 != 0:
    output = 0
else:
    d.sort()
    a = d[int(N/2)-1]
    b = d[int(N/2)]
    output = b-a
print(output)

Submission status: Accepted

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

d.sort()
K1 = d[int((n/2))-1]
K2 = d[int(n/2)]
print(K2-K1)

Submission status: Accepted

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

sorted_d_list = sorted(d_list)
d_abc = sorted_d_list[n//2 - 1]
d_arc = sorted_d_list[n//2]

print (d_arc - d_abc)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

import numpy as np
N = int(input())
d = LI()
d.sort()
cnt = 0
ans = d[N//2]-d[N//2-1]
print(ans)

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
import bisect
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    ps = LI()
    if n % 2 != 0:
        print(0)
        return
    sr = sorted(ps)
    print(sr[n//2] - sr[n//2 - 1])





if __name__ == "__main__":
    main()