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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
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 DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    l = list(map(int,input().split()))
    l = sorted(l)
    m = n // 2 - 1
    if l[m] == l[m+1]:
        print(0)
    if l[m] < l[m+1]:
        print(l[m+1]-l[m])
        
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
def solve():
  N = int(input())
  D = sorted([int(i) for i in input().split()])
  return D[N//2] - D[N//2 - 1]

print(solve())

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

Submission status: Accepted

Solution code:


def do():
    n = int(input())
    ds = list(map(int, input().split(" ")))
    ds.sort()
    sita = ds[n//2-1]
    ue = ds[n//2]
    print(ue-sita)

if __name__ == "__main__":
    do()

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 resolve():
    N = int(input())
    ds = list(map(int, input().split(" ")))
    ds.sort()
    print(ds[int(N/2)] - ds[int(N/2)-1])
    
if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

li.sort()
ind = n//2
min = li[ind-1]
max = li[ind]


print(max-min)

Submission status: Accepted

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


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

Submission status: Accepted

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

d.sort()

if len(d) %2 == 1:
  print(0)
  exit()
le = len(d)
mi = d[int(le/2) - 1]
ma = d[int(le/2)]

print(ma-mi)

Submission status: Accepted

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

l = len(sorted_ds)
i = int(l/2)
print((sorted_ds[i] - sorted_ds[i-1]) if l % 2 == 0 else 0)

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

d.sort()

b = (N+1) // 2
a = b - 1

d1 = d[a]
d2 = d[b]

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

print(d2 - d1)

Submission status: Accepted

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

d = sorted(d)

ABC_max = int((N / 2) - 1)
ARC_min = int(N / 2)

ans = d[ARC_min] - d[ABC_max]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from bisect import bisect_left

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

to_take = N // 2

cnt = 0
for x in range(d[0], d[-1] + 1):
    idx = bisect_left(d, x)
    # ABC用の問題数
    if idx == to_take:
        cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    N = int(input())
    D = [int(c) for c in input().split()]
    sorted_D = sorted(D)
    upper = sorted_D[N//2]
    lower = sorted_D[N//2 - 1]
    print(upper - lower)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

d = sorted(d)

h = int(n/2)

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

Submission status: Accepted

Solution code:
def acinput():
    return list(map(int,input().split(" ")))


N=int(input())
d=acinput()


d=sorted(d)

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
d = sorted(inpl())
if 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 = sorted(d)

m = d[N // 2 - 1]
l = d[N // 2]

print(l-m)

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)
a.sort()

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

Submission status: Accepted

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

maxK = D[N // 2]
minK = D[N // 2 - 1]

print(maxK - minK)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(d) for d 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()
zzz = n//2
z = d[zzz] - d[zzz-1]
print(z)

Submission status: Accepted

Solution code:
n = int(input())
ds = list(map(int, input().split()))
ds.sort()
#print(ds)

abc = ds[:n//2]
arc = ds[n//2:]
#print(abc)
#print(arc)

print(min(arc)-max(abc))

Submission status: Accepted

Solution code:
n = int(input())

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

d.sort()

c = int(n / 2 - 1)

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

Submission status: Accepted

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

ls = sorted(ls)

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = [int(e) for e in input().split(" ")]
    d.sort()
    n2 = int(n/2)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

d = sorted(d)

u = d[N//2]
l = d[N//2 - 1]

print(u - l)

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
s=list(map(int,input().split()))
i=1
ans=0

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

Submission status: Accepted

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

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

print(l-s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    n = int(sys.stdin.readline().strip())
    d = [int(i) for i in sys.stdin.readline().strip().split()]
    d.sort()
    return d[n//2] - d[n//2-1]
    
print(main())

Submission status: Accepted

Solution code:
import bisect
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()
neu = N // 2
nor = neu - 1
ans = d[neu] - d[nor]
print(ans)

Submission status: Accepted

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

D.sort()
minsaigo = D[N//2-1]
maxsaisho = D[N//2]

if minsaigo == maxsaisho:
    print(0)

else:
    K = maxsaisho - minsaigo

    print(K)

Submission status: Accepted

Solution code:
n = int(input())

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

p2 = sorted(p)

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve():
    left = D[N // 2 - 1]
    right = D[N // 2]
    if left == right:
        return 0
    return right - left


print(solve())

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    d = [int(s) for s in input().split()]
    print(solve(d))

def solve(d):
    ds = sorted(d)
    n = len(ds)

    return ds[n // 2] - ds[n // 2 - 1]

main()

Submission status: Accepted

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

sm = d[N//2 - 1]
la = d[N//2]

print(la-sm)

Submission status: Accepted

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

d = sorted(d)

i = N//2 - 1
j = N//2

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
p = [int(x) for x in input().split()]
if n % 2 != 0:
    print(0)
    sys.exit()
p.sort()
a,b = p[n//2 - 1],p[n//2]
print(b-a)

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
c = sorted(b)
print(c[int(0.5*a)]-c[int(0.5*a-1)])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# Submit as pypy2

from __future__ import print_function


try:
    input = raw_input
    range = xrange
except NameError:
    pass


# Test code requires python3
# from hypothesis import given
# from hypothesis import strategies as st

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

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

Submission status: Accepted

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

d_array.sort()

min_K = d_array[N // 2 - 1] + 1
max_K = d_array[N // 2]

print(max(max_K - min_K + 1, 0))

Submission status: Accepted

Solution code:

n = int(input())
num_list = sorted([ int(v) for v in input().split() ])

ans = 0


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

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:


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

    ds.sort()
    mid = N // 2

    print(ds[mid] - ds[mid - 1])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# @author 

import sys

class CDivideTheProblems:
    def solve(self):
        n = int(input())
        d = [int(_) for _ in input().split()]
        d.sort()
        if n % 2 == 0:
            print(d[(n - 1) // 2 + 1] - d[(n - 1) // 2])
        else:
            print(1)

solver = CDivideTheProblems()
input = sys.stdin.readline

solver.solve()

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:
#coding:utf-8

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

mid=n//2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ds = sorted(map(int, input().split(" ")))

    half = N // 2
    if ds[half-1] == ds[half]:
        return 0

    out = ds[half] - ds[half-1]
    return out

out = main()

print(out)

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = onem()
l = l()
if n % 2 == 1:
    print(0)
    exit()
co = 0
l.sort()
ll = [0 for i in range(10**5+1)]

for i in range(n):
    ll[l[i]] += 1

for i in range(1,len(ll)):
    ll[i] += ll[i-1]
    if ll[i] == n//2:
        co += 1
print(co)

Submission status: Accepted

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

if d[l] == d[r]: print(0)
else:
    print(d[r]-d[l])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Problems = D[:]
Problems = sorted(Problems)
#print(Problems)
abc = Problems[N // 2 -1]
arc = Problems[N // 2]

#print(abc, arc)

if abc == arc:
    print(0)
else:
    print(arc-abc)

Submission status: Accepted

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

Submission status: Accepted

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

ds.sort()

half = n // 2 - 1
k_min = ds[half]
k_max = ds[half+1]

print(k_max-k_min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)

N = int(input())
D = [int(x) for x in input().split()]
# L = [[int(x) for x in input().split()] for _ in range(N)]
# N, M = map(int, input().split())
# S = input()

D.sort()

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

Submission status: Accepted

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
lis = Is()
lis = sorted(lis)
print(lis[n//2]-lis[n//2 -1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    #H, W = map(int, input().split())
    N = int(input().strip())
    D = list(map(int, input().split()))

    D = sorted(D)

    middle = N // 2
    lower = D[middle-1]
    higher = D[middle]

    num = higher - lower
    print(num)



if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve():
    N = int(input())
    D = sorted(list(map(int, input().split())))
    mid = N // 2
    return D[mid] - D[mid - 1]
    

def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import deque

readline = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:

N=int(input())
x=list(map(int,input().split()))
n=N//2

X=sorted(x)
#print(X)

#print(X[n-1])
#print(X[n])

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
half = n//2
ans = 0
if n%2 == 0:
    if d[half] == d[half-1]:
        ans = 0
    else:
        ans = d[half]-d[half-1]
else:
    ans = 0
print(ans)

Submission status: Accepted

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

d.sort()

if d[n//2] != d[n//2 - 1]:
    ans = d[n//2] - d[n//2 - 1]
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
x=[0]*(10**5+1)
for d in D:
    x[d]+=1
a=0
for i in range(10**5):
    x[i+1]+=x[i]
    if x[i+1]==N//2:
        a+=1
print(a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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 = 0
if d[N//2] == d[N//2 - 1]:
    ans = 0
else:
    ans = d[N//2] - d[N//2 - 1]

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:
def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    return d[N // 2] - d[N // 2 - 1]

print(main())

Submission status: Accepted

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

Submission status: Accepted

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


d.sort()

ans = 0
for i in range(1, 100100):
    tmp = bisect.bisect_left(d, i)
    if N - tmp == tmp:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
from collections import defaultdict

N = int(input())
A = sorted(list(map(int, input().rstrip().split(' '))))

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
print(lis[n//2]-lis[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:
#!venv/bin/python
#from collections import defaultdict 

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

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

Submission status: Accepted

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

Submission status: Accepted

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

d_list.sort()


print(d_list[int(N/2)] - d_list[int(N/2-1)])

Submission status: Accepted

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
idx=n//2 #真ん中で大きい方
print(l[idx]-l[idx-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(max(right-left, 0))

Submission status: Accepted

Solution code:
N = int(input())
d = [int(_) for _ in input().split()]
d.sort()
c = N // 2

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

M = N // 2

d = sorted(d)

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

Submission status: Accepted

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

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

li.sort()

if n % 2 == 0:
    s = n//2
    ans = li[s] - li[s-1]

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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:
h = int(input()) // 2
S = list(map(int,input().split()))
S.sort()
print(S[h]-S[h-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()

cen = N//2-1

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

Submission status: Accepted

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

Submission status: Accepted

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

d_list.sort()
from bisect import bisect_right
ans = 0

for i in range(1, max(d_list)):
    idx = bisect_right(d_list, i)
    if N //2 == idx:
        ans += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
d = [int(x) for x in 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()
abc = D[int(N/2)-1]
arc = D[int(N/2)]
print(arc -abc)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
k = na()
k = sorted(k)
m = n//2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

D.sort()

m = int(N/2)

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

Submission status: Accepted

Solution code:
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 == 1:
    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()
n_half = int(n/2)
print(d[n_half]-d[n_half-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = sorted(list(map(int, input().split())),reverse=True)
m = n//2

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

d.sort()
lower = n // 2 - 1
upper = n // 2

comb = d[upper] - d[lower]

print(comb)

Submission status: Accepted

Solution code:
def m():
    N = int(input())
    D = [int(i) for i in input().split()]
    D.sort()
    left = D[N // 2 - 1]
    right = D[N // 2]
    if left == right:
        return 0
    return right - left


print(m())

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 sys
#input = sys.stdin.readline
def main():
    N = int( input())
    D = list( map( int, input().split()))
    D.sort()
    ans = 0
    if D[N//2] != D[N//2-1]:
        ans = D[N//2] - D[N//2-1]
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
 
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 main():
    N = I()
    D = LI()
    D.sort()
    half=int(N/2-1)
    print(D[half+1]-D[half])

    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect as b

N = int(input())
P = list(map(int, input().split()))
P.sort()
S = list(set(P))
S.sort()

res = 0
for n, s in enumerate(S):
    i = b.bisect_right(P, s)
    if i == N // 2:
       res = S[n + 1] - s
    elif i > N // 2:
        break

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

d.sort()
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, b = D[N//2-1], D[N//2]

print(b-a)