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:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrA = list(map(int,input().split()))
arrA.sort()

breakpoint1 = len(arrA)//2 -1
breakpoint2 = breakpoint1+1

ans = arrA[breakpoint2] - arrA[breakpoint1]
print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

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)
# print(d)

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(d)

ans = d[N/2] - d[N/2-1]

print ans

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    a.sort()

    # a[n//2-1] < k <=  a[n//2:n]
    print(a[n//2] - a[n//2-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

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:
n = int(input())

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

d_sorted = sorted(d_list)

if n % 2 == 0:
    ans = d_sorted[n//2] - d_sorted[n//2-1]
    print(ans)
else:
    print(0)

Submission status: Accepted

Solution code:
import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

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

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

resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,*l=map(int,open(0).read().split());n//=2;l.sort();print(l[n]-l[~n])

Submission status: Accepted

Solution code:
m=int(input())//2;l=sorted(map(int,input().split()));print(l[m]-l[~m])

Submission status: Accepted

Solution code:
# C
n = int(input())
d = list(map(int, input().split()))
d.sort()
if n%2 == 1:
    print(0)
else:
    mi = n//2-1
    ml = d[mi]
    mr = d[mi+1]
    print(mr-ml)

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:
import sys
import os


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

    N = int(sys.stdin.buffer.readline().rstrip())
    D = list(map(int, sys.stdin.buffer.readline().split()))
    D.sort()
    print(D[N//2]-D[N//2-1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = na()
d.sort()
l = d[n//2-1]
r = d[n//2]
if l != r:
    print(r-(l+1)+1)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if lend % 2 == 1:
    ans = 0
else:
    lend2 = lend//2
    a1 = d[lend2-1]
    a2 = d[lend2]
    ans = a2 - a1

print(ans)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    m = N//2
    return A[m]-A[m-1]

print(solve())

Submission status: Accepted

Solution code:
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
D = nl()
# D = nl()
D.sort()

s1 = D[N//2 -1 ]
s2 = D[N//2]

print(s2 - s1)

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
D = lr()
D.sort()
border = N // 2 -1
left = D[border]
right = D[border+1]
answer = right - left
print(answer)
    
# 33

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

D1 = D[int(N / 2) -1]
D2 = D[int(N / 2)]

count = 0

for i in range(D1, D2, 1):
	count+=1

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

half = d[N // 2 - 1]
nxt = d[N // 2]

if nxt == half:
    print(0)
else:
    print(nxt - (half + 1) + 1)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main(n, d):
    d.sort()

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


if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))

    main(n, d)

Submission status: Accepted

Solution code:
N = int(input())
if N%2!=0:
    print(0)
else:
    List = sorted([int(i) for i in input().split(" ")])
    n = List[N//2-1]
    m = List[N//2]
    print(m-n)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


d = sorted(d)
count = 0
if len(d)%2 == 0:
	if d[len(d)//2-1] == d[len(d)//2]:
		print(0)
	else:
		temp = d[len(d)//2]- d[len(d)//2-1]
		count += temp
		print(count)
else:
	print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list_score.sort()

ans = 0

if n%2 == 0:
    ans = list_score[n//2] - list_score[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()

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

Submission status: Accepted

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

if len(d) % 2 == 1:
  print(0)
else:
  d.sort()
  a = d[N // 2 - 1]
  b = d[N // 2]
  print(b - a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem C - Divide the Problem

# input process
N = int(input())
d_nums = map(int, input().split())

# initialization
d_nums = sorted(d_nums)
d_len = len(d_nums)
median_1 = d_nums[d_len//2-1]
median_2 = d_nums[d_len//2]

# process
if d_len%2==0:
    ans = median_2 - median_1
    print(ans)
else:
    print(0)

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()))
arc = []
abc = []
cnt = 0
d.sort()
pivot = n//2
k = d[pivot]
for i in range(n):
    if d[i] >= k:
        arc.append(d[i])
    elif d[i] < k:
        abc.append(d[i])
if len(arc) == len(abc):
    cnt = d[pivot] - d[pivot-1]
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    n = int(input())
    d = list(map(int, input().split()))

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

    print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
d = [int(i) for i in input().split()] 

d.sort()
ans = d[n // 2] - d[n // 2 - 1]
print(max(ans, 0))

Submission status: Accepted

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

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

print(len(range(a+1,b+1)))

Submission status: Accepted

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

if N&1:
    print(0)
    exit()
D.sort()
print(D[N//2]-D[N//2-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    d.sort()

    ans = d[n//2] - d[n//2-1]

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
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(max(0, a[n//2]-a[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
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 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()))

sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

Submission status: Accepted

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

left = n//2 -1
right = n//2

diff = d[right] -d[left]
print(diff)

Submission status: Accepted

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

#print(D)
B = N // 2 -1
#print(B)
ans = D[B+1] -D[B]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

s, t = N//2-1, N//2

ans = d[t] - d[s]
print(ans)

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

data = sorted(list(map(int, input().split())))
median = int(N / 2)
#print(data)
print(data[median] - data[median - 1])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
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:
from sys import stdin

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

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

if a == b:
    print(0)
else:
    c = [i for i in range(a+1, b+1)]
    print(len(c))

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    N = int(input())
    D = list(map(int, input().split()))

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#132_C
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())
s=list(map(int,input().split()))
s.sort()
print(s[(n-1)//2+1]-s[(n-1)//2])

Submission status: Accepted

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

for i in range(d[n//2 -1] + 1,d[n//2] + 1):
    ans.append(i)
 
        
print(len(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 = [int(s) for s in input().split()]

d_list = sorted(d_list)

if len(d_list) % 2 != 0:
  print(0)
  sys.exit()
  
upper = len(d_list) // 2
lower = upper - 1

print(d_list[upper] - d_list[lower])

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([int(i) for i in input().split()])
idx_p = int(len(d) / 2) - 1
idx_a = int(len(d) / 2)
if d[idx_p] != d[idx_a]:
	print (d[idx_a] - d[idx_p])
else:
	print (0)

Submission status: Accepted

Solution code:
import os, sys, re, math

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

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

Submission status: Accepted

Solution code:
n = int(input())
D = [int(s) for s in input().split(' ')]
D.sort()
lower = D[n//2 - 1]
upper = D[n//2]
ret = upper - lower
print(ret)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split(' ')))
d = {}  # key: index, val: count
for i in l:
    d[i] = d.get(i, 0) + 1
sums = 0
ans = 0
sorted_kv = sorted(d.items())
for i in range(len(sorted_kv)):
    key, val = sorted_kv[i]
    sums += val
    if sums == n // 2:
        ans = sorted_kv[i+1][0] - key
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    d = list(map(int,ipti().split()))
    d.sort()
    sita = d[len(d)//2 - 1]
    ue = d[len(d)//2]

    print(ue-sita)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

d_ls.sort()
small = d_ls[len(d_ls)//2-1]
big = d_ls[len(d_ls)//2]
print(big - small)

Submission status: Accepted

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

lst2 = sorted(lst)
print(lst2[n//2]-lst2[n//2-1])

Submission status: Accepted

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

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

lst2 = quick_sort(lst)
print(lst2[n//2]-lst2[n//2-1])

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

p = sorted(d)
x,y = p[len(p)//2-1], p[len(p)//2]
#print(x,y)

print(y - x)

Submission status: Accepted

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

d.sort()

print(max(0, d[n//2] - d[n//2 - 1]))

Submission status: Accepted

Solution code:
from collections import Counter

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

minD = min(d)
maxD = max(d)
c = Counter(d)

abc = 0
arc = n
ans = 0

for i in range(minD, maxD+1):
    abc += c[i-1]
    arc -= c[i-1]
    
    if abc == arc:
        ans += 1

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

D.sort()

prob = N // 2

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

Submission status: Accepted

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

Submission status: Accepted

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

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

if __name__=='__main__':
  main()

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
div = len(d)//2 
if d[div-1] == d[div]:
    ans = 0
else:
    ans = d[div] - d[div-1]
print(ans)

Submission status: Accepted

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *d = map(int, read().split())
d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
a = d[N // 2 - 1]
b = d[N // 2]

print(b - a)

Submission status: Accepted

Solution code:
n = int(input())
m = list(map(int, input().split()))
ms = sorted(m)
m_mid = ms[len(ms) // 2]
m_1mid = ms[len(ms) // 2 - 1]
if m_mid == m_1mid:
    print(0)
else:
    print(m_mid - m_1mid)

Submission status: Accepted

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

m = int(len(d) / 2)
if d[m-1] == d[m]:
    print(0)
else:
    ans = list(range(d[m-1] + 1, d[m] + 1))
    print(len(ans))

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())
A = list(map(int , input().split()))
B = sorted(A)
nagasa = int(len(B)/2)
if B[nagasa] == B[nagasa-1]:
    ans = 0
else:
    ans = B[nagasa] - B[nagasa-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
#a,b=map(int,input().split())
dl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=1
dl.sort()
if n%2==0:
    mid=n//2
    ans=dl[mid]-dl[mid-1]
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

t.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
  import sys
  input=sys.stdin.read
  n,*d=map(int,input().split())
  e=tuple(sorted(d))
  l=len(d)
  s=n//2
  if e[s-1]==e[s]:
    print(0)
  else:
    print(e[s]-e[s-1])
      
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
def main():
  
  n,*d=map(int,open(0).read().split())
  d=tuple(sorted(d))
  l=len(d)
  s=n//2
  if d[s-1]==d[s]:
    print(0)
  else:
    print(d[s]-d[s-1])
      
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
def main():
  
  n,*d=map(int,open(0).read().split())
  d=sorted(list(d))
  l=len(d)
  s=n//2
  if d[s-1]==d[s]:
    print(0)
  else:
    print(d[s]-d[s-1])
      
if __name__=="__main__":
  main()

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
d = LIST()

d = sorted(d)

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

Submission status: Accepted

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

x = d_lst[n//2-1]
y = d_lst[n//2]
answer = y-x
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
half=n//2
group1=d[0:half]
group2=d[half:]
#共通の要素がなければおｋ
if len(set(group1)&set(group2))==0: print(group2[0]-group1[-1])
else: print(0)

Submission status: Accepted

Solution code:
def main():
    import sys
    input=sys.stdin.readline
    N=int(input())
    d=list(map(int,input().split()))
    d.sort()

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n, *d = map(int, sys.stdin.read().split())

def main():
    d.sort()
    h = n // 2
    l = d[h-1]; r = d[h]
    return r - (l + 1) + 1

if __name__ == '__main__':
    ans = main()
    print(ans)

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

abc = 0
arc = 0
count = 0
for i in range(n // 2):
    if dl_s[i] < dl_s[-(i+1)]:
        abc = dl_s[i]
        arc = dl_s[-(i+1)]
        count += 1

if count == n//2:
    print(arc - abc)
else:
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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