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:
def calc(ds) -> int:
  ds = sorted(ds)
  half = len(ds) // 2
  lower_d = ds[half - 1]
  higher_d = ds[half]
  
  return higher_d - lower_d

_ = input()
numbers_str = input()
result = calc([int(n) for n in numbers_str.split(' ')])
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def prob_c():
    n = int(input())
    d_list = [int(a) for a in input().split()]
    d_list.sort()
    return d_list[int(n/2 + 0.1)] - d_list[int(n/2 + 0.1) - 1]


b = prob_c()
print(str(b))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

N = int(input())

c = Counter(list(map(int, input().split())))
D = sorted(list(c.keys()))

x = 0
s = 0
a = 0
b = N
for k in D:
    a += c[k]
    b = N - a
    if a == b:
        x = k
    elif a > b and x > 0:
        s = k - x
        break

print(s)

Submission status: Accepted

Solution code:
#Coding: utf-8

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 = list(map(int, input().split()))
D.sort()
M = int(N/2)

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

Submission status: Accepted

Solution code:
from sys import stdin

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

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
d_array = [int(x) for x in input().split()]
d_counter = Counter(d_array)

max_d = max(d_array)
tmp = 0
cnt = 0
for i in range(max_d):
    tmp += d_counter[i]
    if tmp == n//2:
        cnt += 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = sorted(LI())
    i = n // 2 - 1

    return a[i+1] - a[i]


print(main())

Submission status: Accepted

Solution code:
from collections import Counter
from sys import exit
N, = list(map(int,input().split()))
d = list(map(int,input().split()))
c = Counter(d)
ks = list(c.keys())
ks.sort()
s = 0
for i,k in enumerate(ks[:N-1]):
  s += c[k]
  if s==N//2:
    print(ks[i+1]-k)
    exit(0)
print(0)

Submission status: Accepted

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

d.sort()
#print(d)
#d[n//2]
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:
N = int(input())
d = [int(_) for _ in input().split()]
ans = 0
d = sorted(d)

if d[N//2-1] != d[N//2]:
    ans = d[N//2] - d[N//2 - 1] 

print(ans)

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:
# using main() makes code faster from the point of view of "access to variables in global name-space"
# def main():

""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
"""

import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
# accumulate() returns iterator! to get list: list(accumulate())
from math import factorial, ceil, floor
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    # TODO: How should I do when n - r is negative?
    if n < 0 or r < 0:
        raise Exception('combinations_count(n, r) not defined when n or r is negative')
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combinations_with_replacement_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    if n < 0 or r < 0:
        raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
    elif n == 0:
        return 1
    else:
        return combinations_count(n + r - 1, r)
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from operator import itemgetter
# ex1: List.sort(key=itemgetter(1))
# ex2: sorted(tuples, key=itemgetter(1,2))
from functools import reduce
def chmin(x, y):
    """change minimum
    if x > y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current minimum value
        y (long): potential minimum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x > y:
        x = y
        return (x, True)
    else:
        return (x, False)
def chmax(x, y):
    """change maximum
    if x < y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current maximum value
        y (long): potential maximum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x < y:
        x = y
        return (x, True)
    else:
        return (x, False)

from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)

# first create factorial_list
# fac_list = mod_factorial_list(n)
INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
def modinv(a, p = MOD):
    # evaluate reciprocal using Fermat's little theorem:
    # a**(p-1) is identical to 1 (mod p) when a and p is coprime
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    # fac_list = modfactorial_list(100)
    # print(modcomb(100, 5, modfactorial_list(100)))
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))

""" initialize variables and set inputs
# initialize variables
    # to initialize list, use [0] * n
    # to initialize two dimentional array, use [[0] * N for _ in range(N)]
# set inputs
    # open(0).read() is a convenient method:
    # ex) n, m, *x = map(int, open(0).read().split())
    #     min(x[::2]) - max(x[1::2])
    # ex2) *x, = map(int, open(0).read().split())
    #     don't forget to add comma after *x if only one variable is used
# preprocessing
    # transpose = [x for x in zip(*data)]
    # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
    # flat = [flatten for inner in data for flatten in inner]
    # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
# calculate and output
    # output pattern
    # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
"""

# functions used
r = lambda: sys.stdin.readline().strip()
r_int = lambda: int(r())
R = lambda: list(map(int, r().split()))
Rfloat = lambda: list(map(float, r().split()))
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())

""" how to treat input
# single int: int(r())
# single string: r()
# single float: float(r())
# line int: R()
# line string: r().split()
# line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
# lines int: [R() for _ in range(n)]
"""


# ----------------------------------
# main
N = int(r())
D = R()
D.sort()

mid_left = N // 2 - 1
mid_right = mid_left + 1
print(D[mid_right] - D[mid_left])

# end of main
# ----------------------------------

"""memo: how to use defaultdict of list
# initialize
Dic = defaultdict(list)
# append / extend
Dic[x].append(y)
# for
for k, v in Dic.items():
"""

# if __name__ == '__main__':
#     main()

Submission status: Accepted

Solution code:
n = int(raw_input())
a = sorted(map(int,raw_input().split()))
x = a[n/2]
y = a[n/2-1]
print x-y

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
D = list(map(int, input().split()))
D.sort()
n1 = n // 2
n0 = n1 - 1

if D[n0] == D[n1]:
    print(0)
else:
    print(-(D[n0] - D[n1]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
#print(d)
a = n // 2
#print(a,d[a-1],d[a])
print(d[a] - d[a-1])

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i in input().split()]
cnt = 0
Ds = sorted(D)
dl = len(Ds)
ans = Ds[round(dl/2)] - Ds[round(dl/2) - 1]
print(ans)

Submission status: Accepted

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


def solve(N: int, d: "List[int]"):
    d.sort()
    print(d[N//2] - d[N//2-1])

    return


# Generated by 1.1.4 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:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    D = sorted(LIST())
    print(D[N//2] - D[N//2-1])

if __name__ == '__main__':
    main()

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:
input1 =int(input())
L = list(map(int, input().split()))
L.sort()
low = L[int(input1/2 -1)]
high = L[int(input1/2)]
number = high - low
print(number)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(int,input().split()))
p.sort()
n1=int(n/2)
if p[n1-1]==p[n1]:
    print (0)
else:
    start=p[n1-1]
    end=p[n1]
    ans=end-start
    print(ans)

Submission status: Accepted

Solution code:
# -*- encoding: UTF-8 -*-
n = int(input())
ds = list(map(int, input().split()))

ds.sort()
#print(ds)
i_min = int(n / 2) -1
i_max = int(n / 2)


k_min = ds[i_min]
k_max = ds[i_max]

ks = range(k_min, k_max)

print(len(ks))

Submission status: Accepted

Solution code:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n,*a=map(int,open(0).read().split())
    p=sorted(a)
    print(p[n//2]-p[n//2-1])

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
pre = [int(i) for i in input().split()]
pre.sort()
xx = pre[int(n / 2 - 1)]
yy = pre[int(n / 2)]
ans = 0
for i in range(xx + 1, yy + 1) :
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
n=int(input())
d=sorted(map(int,input().split()))
print(d[n//2]-d[n//2-1])

Submission status: Accepted

Solution code:
from bisect import bisect_right
N = int(input())
D = sorted(list(map(int, input().split())))

ans = 0
for k in range(10 ** 5 + 1):
    ri = bisect_right(D, k)
    if ri == N // 2:
        ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

D.sort()
M = N//2
print(D[M] - D[M-1])

Submission status: Accepted

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

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

if n % 2 != 0:
    ans = 0
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] if n % 2 == 0 else 0)

Submission status: Accepted

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

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

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:
n,*l=map(int,open(0).read().split());l.sort();print(l[n//2]-l[n//2-1])

Submission status: Accepted

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

dif.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

ds.sort()

K_small = ds[N//2-1]
K_big = ds[N//2]

print(K_big - K_small)

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

if len([i for i in d if d[n // 2 - 1] >= i]) == n // 2:
    print(d[n // 2] - d[n // 2 - 1])
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
items = sorted(list(map(int, input().split(' '))))
print(items[int(n / 2)] - items[int(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:
N = int(input())
ds = sorted([int(i) for i in input().split()])

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
d =[int(i)for i in input().split()]
d.sort()
a,b = d[N//2-1:N//2 +1]
print(max(0,b-a))

Submission status: Accepted

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

ans=0
new_d = sorted(d)
hanbun =int(N/2)
K=0
K=new_d[hanbun]
ans=K-new_d[hanbun-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

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

"""
for k in range(d[n // 2], d[(n // 2) + 1]):
    if bisect.bisect_left(d, k) == n // 2:
        ans += 1
"""

Submission status: Accepted

Solution code:
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr

    # データの状態に左右されないためにrandom.choice()を用いることもある。
    # ref = random.choice(arr)
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right
n=int(input())
S=list(map(int,input().split()))
S=quick_sort(S)
word=n//int(2)
s=int(S[word])-int(S[word-1])
s2=int(S[word])-int(S[word-1])
print(s)

Submission status: Accepted

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

Submission status: Accepted

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

D.sort()

result = D[N//2] - D[N//2-1]

print(result)

Submission status: Accepted

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

me=int(len(p)/2)

print(p[me]-p[me-1])

Submission status: Accepted

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

half = int((N / 2) -1)
#print(N, d, half)
K_under =  d[half]
K_over = d[half + 1]

K_num = K_over - K_under
print(K_num)

Submission status: Accepted

Solution code:
def c_divide_the_problems(N, D):
    D.sort()
    abc_max, arc_min = D[N // 2 - 1], D[N // 2]  # [abc_max + 1, arc_min] が整数の区間
    return arc_min - abc_max if arc_min > abc_max else 0

N = int(input())
D = [int(i) for i in input().split()]
print(c_divide_the_problems(N, D))

Submission status: Accepted

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


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


# Generated by 1.1.4 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:
import heapq

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

q = []
for x in s:
  heapq.heappush(q, x)

for i in range(n//2):
  abc_max = heapq.heappop(q)
arc_min = heapq.heappop(q)
print(arc_min - abc_max)

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 = input()
_difs = input().split(' ')
difs = [int(item) for item in _difs]
difs.sort()
pos=int(float((len(difs)+1))/float(2))
m = difs[pos]
print(difs[pos] - difs[pos-1])

Submission status: Accepted

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

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

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(abs(d[(N//2)-1]-d[(N//2)]))

Submission status: Accepted

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

N = int(input())
d = li()
d.sort()
n = N//2
print(d[n]-d[n-1])

Submission status: Accepted

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

d_i.sort()
i = len(d_i) // 2
print(d_i[i] - d_i[i - 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())
p=list(map(int,input().split()))
p.sort()
c_b=p[int(len(p)/2)]-p[int(len(p)/2-1)]
print(c_b)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    N = int(input())

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

    d.sort()

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



if __name__ == "__main__":
    main()

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:
x = int(input())
y = input().split()
for u in range(len(y)):
    y[u] = int(y[u])
y = sorted(y)
count = y[int(len(y) / 2)] - y[int((len(y) / 2)) - 1]
print(count)

Submission status: Accepted

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

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())
L = list(int(i) for i in input().split()) 
n = N//2
data = sorted(L)
data1 = data[:n]
data2 = data[n:]
print(min(data2) - max(data1))

Submission status: Accepted

Solution code:
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        p.sort()
        print(p[1]-p[0])
else:
    if p[(n//2)] == p[(n//2)-1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])

Submission status: Accepted

Solution code:
N = int(input())
l = list(map(int, input().split()))
l.sort()
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()

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

Submission status: Accepted

Solution code:
total = int(input())
element = [int(s) for s in input().split()]

element.sort()

if len(element) % 2 == 1:
  print(0)
print(element[int(len(element)/2)] - element[int(len(element)/2-1)])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
from bisect import bisect_left
ans = 0
for i in range(max(d)+1):
    n = bisect_left(d,i)
    if n == N//2:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
p = [int(x) for x in input().split()]
p.sort()
ans = 0
half = n//2

ans = p[half] - p[half-1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n=input()
S=[]
for i in input().split():
    S.append(int(i))
S=np.array(S)
word=int(int(n)/2)
asa=S.argsort()
s=int(S[asa[word]])-int(S[asa[word-1]])
print(s)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++

def main():
	n = int(input())
	ll=list(map(int, input().split()))
	
	ll.sort()
	#print(ll)
	h=n//2
	
	return ll[h]-ll[h-1]

	

if __name__ == "__main__":
	print(main())

Submission status: Accepted

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

li.sort()

ind=int(n//2)-1

count=0

for k in range(li[ind]+1,li[ind+1]+1):
  count+=1
  
print(count)