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 = input()
P = map(int,raw_input().split())
P.sort()
print P[n/2]-P[n/2-1]

Submission status: Accepted

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

sns = sorted(ns)
print(sns[n//2] - sns[n//2 - 1])

Submission status: Accepted

Solution code:
#高橋君は、 N 個の競技プログラミング用の問題をつくりました。 
#それぞれの問題には 1 から N の番号がついており、問題 i の難易度は整数 di で表されます(大きいほど難しいです)。
#高橋君はある整数 K を決めることで、難易度が K 以上ならば「 ARC 用の問題」難易度が K 未満ならば「 ABC 用の問題」という風に、
#これらの問題を二種類に分類しようとしています。
#「ARC 用の問題」と「ABC 用の問題」が同じ数になるような整数 K の選び方は何通りあるでしょうか。
n = int(input())
d = sorted(map(int, input().split()))
m = n//2
print(d[m]-d[m-1])

Submission status: Accepted

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

d.sort()
h_b = d[int(n/2)-1: int(n/2)]
h_a = d[int(n/2): int(n/2)+1]
print(len(range(h_b[0], h_a[0])))

Submission status: Accepted

Solution code:
import bisect
import sys

verbose = False

def test(d, k):
    sd = sorted(d)
    uniq_d = []
    pop_d = {}
    for num in sd:
        if num in pop_d:
            pop_d[num] += 1
        else:
            pop_d[num] = 1
            uniq_d.append(num)
    uniq_d = sorted(uniq_d)
    pop_uniq_d = []
    cum_pop_uniq_d = []
    prev_pop = 0
    for num in uniq_d:
        pop = pop_d[num]
        pop_uniq_d.append(pop)
        prev_pop += pop
        cum_pop_uniq_d.append(prev_pop)
    if prev_pop % 2 == 1:
        return 0
    if verbose:
        print("total pop =", prev_pop)
    target = prev_pop // 2
    if verbose:
        print("target = ", target)
    target_off = bisect.bisect_right(cum_pop_uniq_d, target)
    if verbose:
        print("target_off = ", target_off)
    if target_off == 0:
        return 0
    if verbose:
        print( "uniq_d = ", uniq_d)
        print( "cum_pop = ", cum_pop_uniq_d)
        print( "uniq_d[target_off] = ", uniq_d[target_off])
        print( "cum_pop_uniq_d[target_off] = ", cum_pop_uniq_d[target_off])
    if cum_pop_uniq_d[target_off-1] != target:
        return 0
    ans = uniq_d[target_off] - uniq_d[target_off-1]
    return ans


def main():
    rv = 0
    #with sys.stdin as input:
    input = sys.stdin
    Nline = input.readline()
    N = int(Nline)
    args = input.readline()
    vargs = args.split()
    d = [int(arg) for arg in vargs]
    rv = test(d, N)
    print(rv)

def mock():
    rv = test( [9, 1, 4, 4, 6, 7], 6)
    print(rv)
    rv = test([9, 1, 14, 5, 5, 4, 4, 14], 8)
    print(rv)
    rv = test([99592, 10342, 29105, 78532, 83018, 11639, 92015, 77204, 30914, 21912, 34519, 80835, 100000, 1], 14)
    print(rv)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    D =[int(i) for i in input().split()]
    #count = 0
    D.sort()
    D.reverse()
    center = D[int(N/2)]
    print(D[int((N/2))-1]-center)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
ds=sorted(d)
n=int(N/2)
cnt=0
if ds[n]!=ds[n-1]:
    for i in range(ds[n-1],ds[n]):
        cnt+=1
print(cnt)

Submission status: Accepted

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

i=int(N/2)
dif=d[i]-d[i-1]

print(dif)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

d_li.sort()

hn = N//2 - 1
hp = N//2 

dis = d_li[hp] - d_li[hn]

if dis == 0:
    print(0)
elif dis > 0:
    print(dis )

Submission status: Accepted

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

sorted_list = sorted(input_list)
half = int(n/2)
answer = sorted_list[half] - sorted_list[half-1]

print(answer)

Submission status: Accepted

Solution code:
cnt = int(input())
l = list(map(int, input().split()))
a = sorted(l)

s = a[(len(l)//2)] - a[(len(l)//2)-1]
print(s)

Submission status: Accepted

Solution code:
num_test = int(input())

difficulties = [int(s) for s in input().split(' ')]

difficulties.sort()

center = num_test // 2
must_abc = difficulties[center-1]
must_arc = difficulties[center]

if must_abc == must_arc:
    print("0")
    exit(0)

print(must_arc - must_abc)
exit(0)

Submission status: Accepted

Solution code:
import numpy  as np

N = int(input().rstrip())
d = np.array(list(map(int, input().rstrip().split())))
d = np.sort(d)
print(d[N/2] - d[N/2-1])

Submission status: Accepted

Solution code:
# ABC132C - Divide the Problems
def main():
    n = int(input())
    D = sorted(map(int, input().rstrip().split()))
    h, l = D[n // 2], D[n // 2 - 1]
    print(h - l)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())

difficulty=list(map(int, input().split()))
  
difficulty.sort()
print(difficulty[int((N/2))]-difficulty[int(N/2)-1])

Submission status: Accepted

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

if l[int(N/2-1)] == l[int(N/2)]:
  print(0)

else:
  print(l[int(N/2)] - l[int(N/2-1)])

Submission status: Accepted

Solution code:
from heapq import nsmallest

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

m = int(-(n/2))
s = int(n/2)

m2 = sorted(p)[m]
s2 = nsmallest(s, p)[-1]

print(m2-s2)

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:
#C問題
N = int(input())
d = input().split()
d = [int(i) for i in d]
d = sorted(d)
ans = d[N//2] - d[N//2-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = list(map(int,input().split()))
    diff = d.sort()
    if len(d) % 2 == 0:
        takai = len(d)//2
        hikui = takai - 1
        ans = d[takai] - d[hikui]
        print(ans)

    else:
        print(0)

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import re
from collections import Counter

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()))
sort_d = sorted(d)
h = int(n/2)
ks = sort_d[h-1]
ke = sort_d[h]
ans = ke - ks
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
str=input()
p_str=str.split(" ")
p=[int(tmp) for tmp in p_str]

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

Submission status: Accepted

Solution code:
n = int(input())
numbers = sorted([int(num) for num in input().split()])

middle = int(n / 2)

numbers1 = numbers[0:middle][-1]
numbers2 = numbers[middle:][0]

if numbers1 == numbers2:
	print("0")
else:
	print(str(numbers2 - numbers1))

Submission status: Accepted

Solution code:
N=int(input())
dlist = input().split()
dl_int = [int(n) for n in dlist]
dl_int.sort()
A =dl_int[int(N/2)]-dl_int[int(N/2)-1]
print(A)

Submission status: Accepted

Solution code:
import statistics
import math
import numpy as np

def getNearestValue(numbers, num):
    idx = np.abs(np.asarray(numbers) - num).argmin()
    for i in range(N):
        near_number= numbers[np.argsort(np.abs(np.asarray(numbers) - num))[i]]
        if near_number >= midian_number:
            near_up_number = near_number
            break
        else:
            continue
    for j in range(N):
        near_number= numbers[np.argsort(np.abs(np.asarray(numbers) - num))[j]]
        if near_number <= midian_number:
            near_under_number = near_number
            break
        else:
            continue
    return near_up_number, near_under_number
        
            


N = int(input())
numbers = [list(map(int, input().split()))]
numbers = numbers[0]

midian_number = statistics.median(numbers)

near_up_number, near_under_number = getNearestValue(numbers, midian_number)



aaa = near_up_number - midian_number
bbb = midian_number - near_under_number
print(int(aaa + bbb))

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline())
p = [int(x) for x in stdin.readline().rstrip().split()]
p.sort()

res = p[n//2] - p[n//2-1]

print(res)

Submission status: Accepted

Solution code:
n = input()
d = list(map(int,input().split()))
d_sort = sorted(d)
sa = (d_sort[int(len(d_sort) / 2)]) - (d_sort[int(len(d_sort) / 2) - 1])
arc =d_sort[int(len(d_sort) / 2):]
abc = d_sort[0:(int(len(d_sort) / 2))]
if len(arc) == len(abc):
    print(sa)
else:
    print(0)

Submission status: Accepted

Solution code:
import os, sys, re, math

N = int(input())
score = [int(s) for s in input().split(' ')]

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

Submission status: Accepted

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


from sys import stdin

N = int(stdin.readline())
P = [int(x) for x in stdin.readline().rstrip().split()]


P.sort()
center = int(N/2)
routes = P[center] - P[center - 1]
print(routes)

Submission status: Accepted

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

else:
    print(y-x)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N = int(input())
d = list(map(int,input().split()))
ABC = []
ARC = []
d.sort()
pivot = (len(d)-1) / 2
left = math.floor(pivot)
right = math.ceil(pivot)
if d[left] == d[right]:
    K = d[left]

elif d[left] !=  d[right]:
    lists = list(range(d[left]+1,d[right]+1))
    K = lists[0]
for i in range(len(d)):
    if K <= d[i]:
        ARC.append(d[i])
    elif K > d[i]:
        ABC.append(d[i])
if len(ABC) == len(ARC):
    print(len(lists))
else:
    print("0")

Submission status: Accepted

Solution code:
# coding: utf-8
# C - Divide the Problems

n = int(input())
a = list(map(int, input().split()))
a.sort()

mina = a[0]
maxa = a[-1]
l = a[:len(a)//2]
r = a[len(a)//2:]

print(r[0]-l[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__=="__main__":
    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:
N = int(input())
dd = list(map(int, input().split(" ")))
dd.sort()

K = int(N / 2 - 1)
if dd[K] == dd[K + 1]:
    print(0)
    exit()

res = int(dd[K + 1]) - int(dd[K])
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
line = list(map(int,input().split()))
#print(str(line)+"■")
line.sort()
#print(str(line)+"■")

hil = line[(n//2) - 1]
hir = line[(n//2)]
#print(str(hil)+"■")

print(hir - hil)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

Submission status: Accepted

Solution code:

n = int(input())
d = input().split()

d_int = [int(s) for s in d]


d_int.sort()


half = int(n/2)

print(int(d_int[half])-int(d_int[half-1]))

Submission status: Accepted

Solution code:
# C - Divide the Problems
import math
def main():
	N = int(input())
	d = list(map(int,input().split()))
	d.sort()
	K = list(range(d[math.floor(N/2) - 1] + 1, d[math.floor(N/2)] + 1))
	print(len(K))

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=0
a=[]
i=1
ii=1
l=0
tasu=0
rk=[]
bk=[]
n=int(input())
for x in input().split(" "):
    a.append(int(x))

a.sort()

print(a[int(len(a)/2)]-a[int(len(a)/2)-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import mean
import sys
N = int(input())
d = list(map(int,input().split()))

d.sort()

d1 = [d[i] for i in range(N//2) if i <= N]
d2 = [d[i] for i in range(N//2,N)]

a = d2[0] - d1[-1]

if len(d1) == len(d2):
    print(a)
    sys.exit()
print(0)

Submission status: Accepted

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

D.sort()

center = N//2

if (D[center] > D[center-1]):
    print(D[center] - D[center-1])
else:
    print(0)

Submission status: Accepted

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

l.sort()
if l[hn-1] == l[hn]:
    print(0)
else:
    print(l[hn]-l[hn-1])

Submission status: Accepted

Solution code:
N = int(input())
d_list = list(map(int,input().split()))
d_list = sorted(d_list)
ln = int(N/2-1)
l = d_list[ln]
rn = int(N/2)
r = d_list[rn]
K = r - l 
print(K)

Submission status: Accepted

Solution code:
cnt = int(input())
in_str = [int(i) for i in input().split()]
in_str.sort()
#print("in_str[cnt // 2-1]",in_str[cnt // 2-1])
#print("in_str[cnt//2]",in_str[cnt//2])
print(in_str[cnt//2] - in_str[cnt // 2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = [input().split() for i in range(2)]
lis = [int(i) for i in a[-1]]
n = int(a[0][0])
lis_s = sorted(lis)

ans = abs(lis_s[n//2] - lis_s[n//2 - 1])
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = sorted(list(map(int, input().split())))
mid = int(n / 2 - 1)
print(d[mid + 1] - d[mid])

Submission status: Accepted

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

ds = sorted(da)

mm = ds[N//2-1]
ma = ds[N//2]

print(ma - mm)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = [int(x) for x in input().split()]
count=0
S.sort()

if S[int(N/2)] == S[int(N/2-1)]:
  print(count)
else:
  print(S[int(N/2)] - S[int(N/2-1)])

Submission status: Accepted

Solution code:
n = input().strip()
n = int(n)
i = list(map(int, input().split()))
i.sort()
bef = i[int((n/2) -1)]
af = i[int(n/2)]
ans = 0
min = af - bef
while(min != 0):
    ans += 1
    min -= 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
dn = input().split()
dn = [int(s) for s in dn]
dn = sorted(dn, key=int)

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)

Submission status: Accepted

Solution code:
half = 0
ans = 0

N = int(input())
d = input().split(" ")
l = [int(s) for s in d]
l.sort()

half = N // 2
ans = l[half] - l[half-1]

print(ans)

Submission status: Accepted

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

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

if d[int((n/2)-1)] == d[int(n/2)]:
    print(0)
else:
    while k < d[int(n/2)]:
        count += 1
        k += 1
    print(count)

Submission status: Accepted

Solution code:
n = int(input())
p = list(map(int, input().strip().split()))
p.sort()
max = int(n/2)
min = int(n/2-1)
result = p[max]-p[min]
print(result)

Submission status: Accepted

Solution code:
from sys import stdin

if __name__ == '__main__':

    n = int(stdin.readline())
    d = [int(x) for x in stdin.readline().rstrip().split()]

    d.sort()

    i = n // 2

    print(d[i] - d[i-1])

Submission status: Accepted

Solution code:
n=int(input())
d=input().split(' ')
list=[]

list3=[]
for i in d:
  list.append(int(i))
list.sort()
if(list[int(n/2)-1]==list[int(n/2)]):
   print(0)
else :
  print(list[int(n/2)]-list[int(n/2)-1])

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
i=len(d)//2
d.sort()
a=d[i]-d[-(i+1)]
if a==0:
   print(0)
else:
   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())
problems = list(map(int,input().split()))
problems = sorted(problems)
print(problems[n//2]-problems[n//2-1])

Submission status: Accepted

Solution code:
n = input()

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

if len(d) % 2:
    print(0)
else:
    h = int(len(d) / 2)
    d.sort()
    count = d[h] - d[h-1]
    print(count)

Submission status: Accepted

Solution code:
N = int(input())
input_line = [input() for i in range(1)]
d = list(map(int,input_line[0].split()))
d.sort()
half = int(len(d) / 2)
K = list(range(d[half-1]+1, d[half]+1))
print(len(K))

Submission status: Accepted

Solution code:
n = int(input())
p = [int(i) for i in input().split()]
p.sort()
if n %2 == 1:
    print(0)
else:
    abc = p[:int(n/2)]
    arc = p[int(n/2):]
print(arc[0] - abc[-1])

Submission status: Accepted

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

Data.sort()

Answer = Data[int(n/2)] - Data[int(n/2-1)]

print(Answer)

Submission status: Accepted

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

A.sort()
count=0
a=int(len(A)/2)

if(A[a-1]==A[a]):
  print(count)
else:
  count=A[a]-A[a-1]
  print(count)

Submission status: Accepted

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

l = len(D)
m = int(l/2)
D.sort()
ans = D[m] - D[m-1]
print(ans)

Submission status: Accepted

Solution code:
import collections
N = int(input())
d = list(map(int, input().split()))
d.sort()
mysum = sum(d)

mytuple = sorted(collections.Counter(d).most_common(), key = lambda k:k[0])

mysum2 = 0 
cnt = 0
for i in mytuple:
  mynum = i[1]
  if mynum + mysum2 < N/2:
  	mysum2 += mynum
  	cnt += 1
  elif mynum + mysum2 == N/2:
    break
  elif  mynum + mysum2 > N/2:
    cnt = -999
    break

if cnt == -999:
  print(0)
else:
  print(mytuple[cnt+1][0] - mytuple[cnt][0])

Submission status: Accepted

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

d.sort()

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

print(b-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_num = int(input())

input_line = input().split(" ")
number_line = []
for i in range(0, input_num):
	number_line.append(int(input_line[i]))

number_line.sort()

temp = int(input_num/2)

print(int(number_line[temp]) - int(number_line[temp - 1]))

Submission status: Accepted

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

divide = 0

medium = int((len(dif)) / 2)


if (len(dif)) %2 != 0:
    print(divide)
else:
    divide = dif[medium] - dif[medium-1]
    print(divide)

Submission status: Accepted

Solution code:
n=int(input())

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

nums=sorted(nums)

#print(nums)

center=int((n/2)+1)
ans=center-1
#print(nums[ans])
cnt=(nums[ans]-nums[ans-1]-1)
#print(cnt)

if nums[ans]==nums[ans-1]:
    print("0")
else:
    print(cnt+1)

Submission status: Accepted

Solution code:
#coding:utf-8
N = int(input())
D = list(map(int,input().split()))
D = sorted(D)
#print (D)
a = D[int(len(D)/2)-1:int(len(D)/2)+1]
print (a[1]-a[0])

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
cnt=0
p.sort()

if n%2==0:
    mid1=n/2
    mid2=n/2
    mid1=int(mid1-1)
    mid2=int(mid2)
    cnt=p[mid2]-p[mid1]
else:
    cnt=0

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())
p = sorted(list(map(int, input().split())))
print(p[n//2]-p[n//2-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n % 2 == 0:
  d.sort()
  cnt = d[int(n/2)] - d[int(n/2)-1]

print(cnt)

Submission status: Accepted

Solution code:
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

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


if is_even(n):
    print(a[int(n/2)]-a[int(n/2)-1])
else:
    print(1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if D[N/2-1] != D[N/2]:
  print D[N/2]-D[N/2-1]
else:
  print (0)

Submission status: Accepted

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

res = 0
for x in range(1,10**5+1):
    k = bisect.bisect_left(d,x)
    if n//2 == k:
        res += 1
print(res)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(e) for e in input().split()]
d.sort()
sum = 0
if d[n//2] == d[n//2-1]:
    print(0)
    exit()
else:
    for i in range(d[n//2]-d[n//2-1]):
        #print(d[n//2-1]+i+1)
        sum+=1

print(sum)

Submission status: Accepted

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

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())
List = [int(i) for i in input().split()]

List_sort =sorted(List)
#print(List_sort)

j=0
if List_sort[int(n/2)-1]==List_sort[int(n/2)]:
    j=0
else:
    j=List_sort[int(n/2)]-List_sort[int(n/2)-1]
    
print(j)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
d = list(map(int, input().split()))
d = np.array(d)
d_sorted = np.sort(d)

half = int(n/2)
if d_sorted[half] == d_sorted[half-1]:
    cnt = 0
else:
    cnt = (d_sorted[half]) - (d_sorted[half-1])
#print(half, d_sorted)

print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
d = sorted([int(x) for x in input().split()])
l = d[n//2-1]
r = d[n//2]
print(0 if l == r else len([x for x in range(l,r)]))

Submission status: Accepted

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

ans = 0

li.sort()
n = int((n - 1) / 2)
ans = abs(li[n] - li[n + 1])
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

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

if N%2 == 0:
    N_half = N//2
    arr = np.sort(np.array(l))
    arr_low = arr[:N_half]
    arr_high = arr[N_half:]
    if arr_low[N_half-1] != arr_high[0]:
        print(arr_high[0]-arr_low[N_half-1])
    else:
        print(0)
else:
    print(0)

Submission status: Accepted

Solution code:

n = int(input())
d_a = input().split()

d = []
for i in range(n):
    d.append(int(d_a[i]))

ds = sorted(d)

mid = int(n/2) -1

if ds[mid] == ds[mid+1]:
    print(0)
    

else:
    num = ds[mid+1] -ds[mid]
    print(num)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
start = d_list[int(n / 2 - 1)]
end = d_list[int(n / 2)]

while(start < end):
    count += 1
    start += 1


print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
 
D = sorted(D)
max_ = max(D)
min_ = min(D)

middle_idx = len(D)//2
 
diff = D[middle_idx] - D[middle_idx-1]
print(diff)

Submission status: Accepted

Solution code:
import sys
from sys import stdin
import numpy as np

def main():
    #pass
    n = int(stdin.readline())
    if n%2!=0:
        print("0")
        return
    m = int(n/2)
    #print(m)
    d = np.array([int(x) for x in stdin.readline().rstrip().split()])
    d = np.sort(d)
    #print(n,d)
    k = int(d[m])-int(d[m-1])
    print(k)
    return
    
    

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
d_list = [int(i) for i in input().rstrip().split(' ')]
d_list.sort()

a = int(n/2) -1
b = int(n/2)

if d_list[a] == d_list[b]:
  print(0)
else:
  print(d_list[b] - d_list[a])

Submission status: Accepted

Solution code:
N = int(input())
ls= list(map(int, input().split()))
import statistics
l = statistics.median_low(ls)
h = statistics.median_high(ls)
print(h-l)

Submission status: Accepted

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

Submission status: Accepted

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

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())
dlist = list(map(int,input().split()))

dlist.sort()

mannaka = dlist[N//2-1] + 1
tugi = dlist[N//2]

#print(dlist)                                                                  

#print(mannaka,tugi)                                                           
print(tugi - mannaka + 1)

Submission status: Accepted

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

mid1 = d[n//2-1]
mid2 = d[n//2]

mid_num = mid2 - mid1
res = mid_num
mid1c = d.count(mid1)
mid2c = d.count(mid2)

if mid1 == mid2:
    res = 0
print(max(0, res))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
ds = sorted([int(x) for x in input().split()])
print(ds[N//2]-ds[N//2-1])

Submission status: Accepted

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

if n % 2:
  print(0)
  
else:
  pivot = int(n/2)
  if d[pivot -1] == d[pivot]:
    print(0)
    
  else:
    print(d[pivot]-d[pivot-1])

Submission status: Accepted

Solution code:
s=input()
t=list(map(int,input().split()))
t.sort()
u=int(s)
v=int(u/2)
w=t[v]-t[v-1]
print(w)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
n = input()
d_list= list(map(int, input().split()))
cou=sorted(Counter(d_list).most_common())
total=len(d_list)
# print(n)
# print(cou)
# print(total)
index=0
before=0
after=0
first=True
t=0
for c in cou:
#     print(c)
    if first:
        before = c
        first=False
    else:
        before = cou[index-1]
    after = c
    t+=c[1]
    if t > total/2:
        break
    index+=1
# print(before)
# print(after)
# print(len(cou[index:]))
if not(sum(n for _, n in cou[index:]) == sum(n for _, n in cou[:index])):
    print(0)
else:
    print(after[0]-before[0])

Submission status: Accepted

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

nums.sort()
if n % 2 == 1:
	print(0)
else:
	m = nums[n // 2 - 1]
	l = nums[n // 2]
	print(l - m)

Submission status: Accepted

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

num = int(n/2)
p.sort()
med = p[num]
#print(med)

ans1 = list(filter(lambda x:x>=med,p))
ans2 = list(filter(lambda x:x<med,p))
#print(ans1)
#print(ans2)
cnt = 0
if len(ans1) != len(ans2):
    print(0)
else:
    for i in range(max(ans2)+1,min(ans1)+1):
        #print(i)
        cnt+=1
    print(cnt)