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

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

Submission status: Accepted

Solution code:
import bisect
n = int(input())
li = list(map(int,input().split()))
li.sort()
#print(li)
count = 0
for i in range(1, max(li)+1):
    index = bisect.bisect_left(li, i)
    #print(n,index,n//2)
    if index == n//2:
        #print(index)
        count += 1
print(count)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int, input().split()))
d.sort()
left=d[N//2 -1]
right=d[N//2]
cnt=0
for i in range(left+1, right+1): #left+1<= i <=right
    cnt+=1

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

print(d[div + 1] - d[div])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

ABC, ARC = d[:len(d)//2], d[len(d)//2:]


print(ARC[0] - ABC[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left
n = int(input())
d = sorted([int(x) for x in input().split()])
res = 0
for x in range(d[0], d[-1]+1):
  y = bisect_left(d, x) 
  if 2 * y == n:
    res += 1
print(res)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(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()))
d.sort()
print(d[N//2]-d[N//2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	d = LI()
	d.sort()
	print(d[n//2]-d[n//2-1])


if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

N = intinp()
d = list(mapint_inp())

sorted_d = sorted(d)

m = N//2
if sorted_d[m-1] == sorted_d[m]:
    print(0)
else:
    print(sorted_d[m]-sorted_d[m-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline #文字列をsplit()しない場合s=s[:-2]が必要

    n=int(input())
    D=[int(_) for _ in input().split()]
    D.sort()
    print(D[n//2]-D[n//2-1])

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    n=int(input())
    D=[int(_) for _ in input().split()]
    D.sort()
    print(D[n//2]-D[n//2-1])

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def myAnswer(N:int, D:list) -> int:
   index = N//2
   D.sort()
   if( D[index - 1] == D[index]): return 0
   return D[index] - D[index - 1]

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   D = list(map(int,input().split()))
   print(myAnswer(N,D))

if __name__ == '__main__':
   main()

Submission status: Accepted

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

D = sorted(d)
n = N//2

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

Submission status: Accepted

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

n1, n2 = N // 2 - 1, N // 2
D = sorted(D)
print(D[n2] - D[n1])

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
d = list(map(int, input().split()))

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

Submission status: Accepted

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

diff = sorted(diff)
l = diff[int(n/2)-1]
r = diff[int(n/2)]
print(r-l)

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(0)
else:
    print(d[n//2]-d[n//2-1])

Submission status: Accepted

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

m = N // 2

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

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
ans = max(0, d[N//2] - d[N//2-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=list(map(int,input().split()))
d.sort()
if d[N//2]==d[N//2-1]:
	print(0)
else:
	print(d[N//2]-d[N//2-1])

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()))
d.sort() #値を返さないNone
#print(d)
print(d[N//2] - d[N//2 -1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n=I()
ds=LI()
s=sorted(ds)
ans=s[n//2]-s[n//2-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
l = list(map(int, input().split()))
length = len(l)
l = sorted(l)
 
if length%2==1:
	print(0)
else:
	print(l[a//2]-l[a//2-1])

Submission status: Accepted

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

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())) 

D.sort()

A = D[:int(N/2)]
B = D[int(N/2):]

if A[-1] == B[0]:
    print(0)
else:
    print(B[0] - A[-1])

Submission status: Accepted

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

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

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(0)
else:
  print(b-a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    q3()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
ns = list(map(int, input().split()))
sort_ns = sorted(ns)
a = sort_ns[n//2-1]
b = sort_ns[n//2]
print(len([i for i in range(a+1, b+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())
problems = list(map(int, input().split()))
problems = sorted(problems)

middle = problems[N // 2] - problems[(N // 2) - 1]
if middle == 0:
    print(0)
else:
    print(middle)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
if N % 2 == 1:
    ans = 0
else:
    D.sort()
    x = D[N // 2 - 1]
    y = D[N // 2]
    ans = y - x
print(ans)

Submission status: Accepted

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


print(sd[len(d)//2]  -  sd[len(d)//2-1])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
# 1, 3, 5, 7
low = d[n//2-1]
high = d[n//2]
# low+1 ~ high
if low == high:
    print(0)
else:
    print(high-low)

Submission status: Accepted

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

sorted_s = sorted(s)
print(sorted_s[(N//2)] - sorted_s[(N//2-1)])

Submission status: Accepted

Solution code:
import bisect
n=int(input())
if n%2==1:
    print(0)
    exit()
d=list(map(int,input().split()))
d=sorted(d)
cnt=0
for i in range(1,max(d)+1):
    a=bisect.bisect_left(d,i)
    if a==n//2:
        cnt+=1
print(cnt)

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()))

d.sort()

if n%2 == 0:
  ans = d[n//2] - d[n//2 - 1]
elif n%2 == 1:
  ans = d[n//2 + 1] - d[n//2 - 1]
  
print(ans)

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7

def main():
  n = int(readline())
  d = list(map(int, readline().split()))
  d.sort()
  mid = n//2
  print(d[mid]-d[mid-1])
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
d = LIST()
d.sort()
mid = n // 2
print(d[mid] - d[mid - 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:
# -*- coding: utf-8 -*-
n = int(input())
d = [int(i) for i in input().split()]

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    n=II()
    aa=LI()
    aa.sort()
    print(aa[n//2]-aa[n//2-1])

main()

Submission status: Accepted

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

Submission status: Accepted

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

if length%2==1:
	print(0)
else:
	print(l[a//2]-l[a//2-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:
#!/usr/bin/env python3
n, *d = map(int, open(0).read().split())
d.sort()
print(d[n//2]-d[n//2-1])

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

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

Submission status: Accepted

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

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 main():
    N = int(input())
    D = [int(i) for i in input().split()]
    D.sort()
    print(D[N//2] - D[N//2 - 1])


if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = sorted(inpl())
print(a[n//2] - a[n//2-1])

Submission status: Accepted

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

a = sorted(a)
print(a[n // 2] - a[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:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
D = sorted(iil())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

X = list(map(int, input().split()))
x = sorted(X)
small = x[N//2-1]
big = x[N//2]
if small != big:
    print(big-small)
else:
    print(0)

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    n = int(input())
    d = input_nums()
    d.sort()
    m = len(d)//2
    abc_val = d[m-1]+1
    arc_val = d[m]
    if arc_val - abc_val >= 0:
        print(arc_val - abc_val + 1)
    else:
        print(0)

if __name__ == '__main__':
    main()

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()

check = d[n//2] - d[(n//2)-1]

print(check)

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 main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
import heapq
big_list = list(map(int,input().split()))
small_list = []
heapq.heapify(big_list)
heapq.heapify(small_list)
while len(big_list) > n//2:
  heapq.heappush(small_list,heapq.heappop(big_list)*(-1))

b = heapq.heappop(big_list)
s = heapq.heappop(small_list)
if b == -s:
  print(0)
elif b + s > 0:
  print(b+s)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
if N % 2 == 0:
    # even case 
    res = d[N // 2] - d[N // 2 - 1]
else:
    # odd case
    res = 0
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

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

N = inp()
dd = inp_list()

dd_sorted = sorted(dd)

border_l = dd_sorted[N // 2 - 1]
border_r = dd_sorted[N // 2]
if border_l == border_r:
    print(0)
else:
    print(border_r - border_l)

Submission status: Accepted

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
d = load_list()

l = 1
r = int(math.pow(10, 5))

def check(k):
    abc = []
    arc = []
    for e in d:
        if e >= k:
            arc.append(e)
        else:
            abc.append(e)
    if len(arc) > len(abc):
        return 1
    elif len(abc) > len(arc):
        return -1
    else:
        return 0


ans1 = -1
while l < r:
    mid = int((l + r) / 2)
    c = check(mid)
    if c == 0:
        ans1 = mid
        break
    elif c == 1:
        l = mid + 1
    elif c == -1:
        r = mid - 1
    

if ans1 == -1:
    print(0)
    exit()
tmp = ans1
cnt = 1


l = ans1
r = int(math.pow(10, 5))

ans2 = ans1
while l <= r:
    mid = int((l + r) / 2)
    c1 = check(mid)
    c2 = check(mid+1)
    if c1 != 0:
        r = mid -1
    elif c1 == 0 and c2 == 0:
        l = mid + 1
    elif c1 == 0 and c2 != 0:
        ans2 = mid
        break

l = 1
r = ans1

ans3 = ans1
while l <= r:
    mid = int((l + r) / 2)
    c1 = check(mid)
    c2 = check(mid-1)
    if c1 != 0:
        l = mid + 1
    elif c1 == 0 and c2 == 0:
        r = mid - 1
    elif c1 == 0 and c2 != 0:
        ans3 = mid
        break

cnt += (ans2 - ans1)
cnt += (ans1 - ans3)


print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))
cnt = Counter(d)
cnt = sorted(cnt.items(), key=lambda x:x[0])
val = 0
for idx, (i, v) in enumerate(cnt):
    val += v
    if val == n // 2:
        print(cnt[idx+1][0] - cnt[idx][0])
        exit()
    elif val > n // 2:
        print(0)
        exit()
    else:
        continue

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

Submission status: Accepted

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

Submission status: Accepted

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

k = 0 #以上ならARC 未満はABC

x = (n // 2) -1 # 配列のスタート

start = d[x] + 1
end = d[x+1] + 1

result = list(range(start,end))
print(len(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
freq=[0]*(10**5+3)
for i in d:
    freq[i]+=1
ans=0
su=0
for i in range(1,10**5+1):
    su+=freq[i]
    if 2*su==n:
        ans+=1
print(ans)

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

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

Submission status: Accepted

Solution code:
#C
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 = sorted(list(map(int, input().split())))

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

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    sd = sorted(d)
    print(sd[N//2] - sd[N//2-1])
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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:
def main():
    n = int(input())
    d = [int(x) for x in input().split()]
    d.sort()
    print(d[int(n/2)] - d[int(n/2-1)])

main()

Submission status: Accepted

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

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

Submission status: Accepted

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

a=y[len(y)//2]
b=y[(len(y)//2)-1]

if a==b:
	print(0)
else :
	print(a-b)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d_list = sorted(list(map(int, input().split())))
if n % 2 != 0:
    print(0)
    exit()
print(d_list[n // 2] - d_list[n // 2 - 1])

Submission status: Accepted

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

M = N//2

x,y = D[M-1:M+1]
ans = y - x
print(ans)

Submission status: Accepted

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

lim = len(d) // 2 - 1
res = sorted(d)

print(res[lim+1] - res[lim])

Submission status: Accepted

Solution code:

n =int(input())
d = list(map(int,input().split()))
d.sort()
L = int(len(d) / 2) - 1
R = L + 1
ans = []

for i in range(d[L]+1,d[R]+1):
    ans.append(i)
print(len(ans))

Submission status: Accepted

Solution code:
import bisect

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

if N % 2 == 1:
    print(0)
else:
    half = N // 2
    cnt = 0
    for k in range(0, 100005):
        if bisect.bisect_left(D, k) == half:
            cnt += 1
    print(cnt)