Problem:


Score : 300 points

Problem Statement

Takahashi made N problems for competitive programming.
The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).

He is dividing the problems into two categories by choosing an integer K, as follows:

A problem with difficulty K or higher will be for ARCs.

A problem with difficulty lower than K will be for ABCs.

How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Problem Statement

2 \leq N \leq 10^5

N is an even number.

1 \leq d_i \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 1

6
9 1 4 4 6 7

Sample Output 1

2

If we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.
Thus, the answer is 2.

Sample Input 2

8
9 1 14 5 5 4 4 14

Sample Output 2

0

There may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 3

14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

Sample Output 3

42685



Sample input:
6
9 1 4 4 6 7


Sample output:
2

Submission status: Accepted

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

if len(d) % 2 == 1:
    print(0)
else:
    d = sorted(d)
    left = d[len(d) // 2 - 1]
    right = d[len(d) // 2]
    print(max(0, right - left))

Submission status: Accepted

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

d.sort()
x = int(N / 2)

print(d[x] - d[x - 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:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()

arr = inlist()
arr = sorted(arr)
n = int(n/2)
kl = int(arr[n-1])
kh = int(arr[n])
print(max(0, kh-kl))

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

Submission status: Accepted

Solution code:
import math
from collections import deque
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
d = readInts()

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

    
resolve()

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

Submission status: Accepted

Solution code:
N=int(input())
ls=[int(s) for s in input().split()]
ls.sort()
print(ls[N//2]-ls[N//2-1])

Submission status: Accepted

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

# check
sort_d = sorted(d)
c = N // 2
print(len(list(range(sort_d[c - 1], sort_d[c]))))

Submission status: Accepted

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

dlist.sort()

half = len(dlist)//2

print(dlist[half]-dlist[half-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()
a = d[n // 2 - 1]
b = d[n // 2]
print(b - a)

Submission status: Accepted

Solution code:
N = int(input())
D = [int(i) for i 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()

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

print(ans)

Submission status: Accepted

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

    if (N % 2 != 0):
        print(0)
        return

    A.sort()

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

    print(ans)


resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    q_list = list(map(int, input().split()))
    num = len(q_list)

    q_list.sort()

    ans = q_list[int(num / 2)] - q_list[int(num / 2 - 1)]
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect

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

ans=0
for i in range(1,d[-1]+1):
    if bisect.bisect_left(d,i)==n-bisect.bisect_left(d,i):
        ans+=1

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)
print(d[len(d)//2]-d[len(d)//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())
di = list(map(int,input().split()))
di.sort()
center = n//2
left = di[center-1]
right = di[center]
ans = right-left
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())
P = list(map(int, input().split()))
P.sort()
#print(P)
A = P[int(N/2)-1]
B = P[int(N/2)]
#print(A,B)
print(B-A)

Submission status: Accepted

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

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

if c!=d:
	print(d-c)
else:
	print(0)

Submission status: Accepted

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

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:
import sys
import math
import bisect

def solve(A):
    n = len(A)
    A.sort()
    l = (n - 1) // 2
    r = l + 1
    return A[r] - A[l]

def main():
    n = int(input())
    A = list(map(int, input().split()))
    print(solve(A))

if __name__ == "__main__":
    main()

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()))
list.sort(d)
n = N // 2

a = d[n]
b = d[n-1]

print(a - b)

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy

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

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

nh1 = n//2 - 1
nh2 = nh1 + 1

if a[nh1] == a[nh2]:
    print(0)
    sys.exit()
else:
    for i in range(a[nh1]+1,a[nh2]+1):
        ans.append(i)

print(len(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n, *lst = map(int, sys.stdin.read().split())
lst.sort()
l, r = lst[n//2 - 1], lst[n//2]
print(r - l)

Submission status: Accepted

Solution code:
def divide_the_problems(n, dli):

    dli.sort()

    n = int(n/2)
    ans = dli[n] - dli[n-1]

    return ans

def main():
    n = int(input())
    dli = list(map(int, input().split()))
    print(divide_the_problems(n, dli))

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:
    ans=d[N//2]-d[N//2 -1]
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N%2 !=0:
    print(0)
    exit()

print(abs(arr[int((N/2)-1)]-arr[int(N/2)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [int(j) for j in input().split()]
import bisect
cnt = 0
mi = min(D)
ma = max(D)
D = sorted(D)
for i in range(mi,ma+1):
    if bisect.bisect_left(D,i) == N/2:
        cnt+=1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[len(d)//2] - d[(len(d)//2)-1])

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
d = LI()
d.sort()

if N % 2 != 0:
  print(0)
  exit()

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 = sorted(d)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
import math
def py():
    print("Yes")
def pn():
    print("No")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

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

neko = int(n/2 - 1)
nuko = neko + 1
if d[neko] != d[nuko]:
    for i in range(d[nuko]-d[neko]):
        nya = nya + 1
    
print(nya)

Submission status: Accepted

Solution code:
N = int(input().rstrip())
line = input().rstrip()
l = [int(v) for v in line.split()]
l.sort()
uniq_list = sorted(list(set(l)))
result = 0
start_at = 0
for i in range(len(uniq_list)):
    for j in range(start_at, len(l)):
        if uniq_list[i] == l[j]:
            if (N / 2) == j:
                result = uniq_list[i] - uniq_list[i - 1]
            else:
                start_at = j + 1
            
            break

print(result)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = 0
for i in range(d[n//2-1]+1, d[n//2]+1):
    ans += 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 = [int(n) for n in input().split()]
d.sort()
left = d[int(N/2)-1]
right = d[int(N/2)]
print(right-left)

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

#なお、任意の整数 M に対して M の −2 進数表現が一意に定まることが証明できます。
#2桁ごとに見るとよかった（もう実験したよ）
def resolve():
    n,=pin()
    D=lispin()
    D.sort()
    #print(D)
    print(D[(n//2)]-D[n//2-1])            
    
#%%submit!
resolve()

Submission status: Accepted

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

sd = sorted(d)
sd.insert(0,0)

m=n//2

if sd[m] != sd[m+1]:
    print(sd[m+1]-sd[m])
else:
    print(0)

Submission status: Accepted

Solution code:
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n = ii()
    d = li()
    d = sorted(d)
    print(d[n//2]-d[n//2-1])


main()

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
q = n//2

print(0) if a[q-1] == a[q] else print(a[q] - a[q-1])

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))
q = n // 2

if a[q-1] == a[q]:
    print(0)
else: 
    print(a[q] - a[q-1])

Submission status: Accepted

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

a.sort()
q = n // 2

if a[q-1] == a[q]:
    print(0)
else: print(a[q] - a[q-1])

Submission status: Accepted

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

Submission status: Accepted

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

d = sorted(D)
a = d[N // 2 - 1]
b = d[N // 2]
ans = 0
for i in range(a, b):
    ans += 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

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

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

upper = d_ls[n // 2]
lower = d_ls[n // 2 - 1]
print(upper - lower)

Submission status: Accepted

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

p = sorted(p)

c_left = p[int(n/2)-1]
c_right = p[int(n/2)]

print(c_right-c_left)

Submission status: Accepted

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


solve()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    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:
import sys
import collections as c

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    g = d[n//2]
    items_count = c.Counter(d)
    gc = items_count[g]
    if gc == 1 or d[n//2-1] != g:
        ans += g - d[n//2-1]
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

d.sort()
length = len(d)
left = d[length//2-1]
right = d[length//2]

if left==right:
    print(0)
else:
    print(right - left)

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:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
D = LI()
D.sort()
a = D[int(n/2)-1]
b = D[int(n/2)]
print(b-a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n  = int(input())
li = list(map(int,input().split()))
c  = len(li)//2

li.sort()

diff = li[c]-li[c-1]

if diff<=0:
  print(0)
else:
  print(diff)

Submission status: Accepted

Solution code:
# ABC132C

n = int(input())
d = list(map(int, input().split()))
n = len(d) // 2
x = sorted(d)
if x[n-1] != x[n]:
    print(x[n] - x[n - 1])
else:
    print(0)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

Solution code:
# C - Divide the Problems

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

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

Submission status: Accepted

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

a = sorted(a)

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

Submission status: Accepted

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

abc_right = d_list[len(d_list) // 2 - 1]
agc_left = d_list[len(d_list) // 2]

print(agc_left - abc_right)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################
 
N=II()
d=LI()

d.sort()

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

Submission status: Accepted

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

n = N//2

d = sorted(D)

if d[n-1] == d[n]:
  print(0)
  
else:
  print(d[n]-d[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:
N=int(input())
L=list(map(int,input().split()))
l=sorted(L)
if N%2==0:
  n=int(N/2)
  a=l[n-1]
  b=l[n]
  if a==b:
    print('0')
  else:
    print(b-a)
    
else:
  print('0')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

d.sort()

middle = int(len(d)/2)

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

Submission status: Accepted

Solution code:
k = int(input())
seqS=input().split(" ")
num=[]
for q in seqS:
    num.append(int(q))
contador,abc,arc=0,0,0
num.sort() #ORGANIZA
#num do meio
print(num[int(len(num)/2)]- num[int(len(num)/2)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    dif = [int(x) for x in input().split()]
    dif.sort()
    meio = n//2
    dif1 = dif[:meio]
    dif2 = dif[meio:]
    print(dif2[0] - dif1[-1])

main()

Submission status: Accepted

Solution code:
n=int(input())
v=[int(i) for i in input().split()]
v=sorted(v)
j=int((n/2))
k=int((n/2)-1)
if v[j]!=v[k]:
    print(v[j]-v[k])
else:
    print("0")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

N = int(input())
P = list(map(int, input().split()))
P.sort()
print(P[N//2] - P[N//2 - 1] if P[N//2] != P[N//2 - 1] and N % 2 ==0 else 0)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

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

num = N // 2
arc = 0
for _ in range(N):
    arc_first = D.pop()
    arc += 1
    if arc == num:
        break
abc_last = D.pop()

if abc_last == arc_first:
    # 同じ数にできない
    ans = 0
else:
    ans = arc_first - abc_last

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    d = sorted([int(i) for i in input().split()])
    half = int(len(d) / 2)
    abc = d[:half]
    arc = d[half:]

    if abc[-1] == arc[0]:
        print(0)
    else:
        print(arc[0] - abc[-1])

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

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:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
D = list(map(int,input().split()))

D.sort()

abc_max = D[N//2-1]
arc_min = D[N//2]

print(max(0,arc_min - abc_max))

Submission status: Accepted

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

half =int(len(d)/2) -1
left = d[half]
right = d[half+1]

print(right-left)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # 

"""

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

d_inv=sorted(d)

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

Submission status: Accepted

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

s = d[len(d)//2-1]
e = d[len(d)//2]
print(len([i for i in range(s+1,e+1)]))

Submission status: Accepted

Solution code:
from collections import deque


def main():
    N = int(input())
    d = list(map(int, input().split(' ')))
    d.sort()
    d = deque(d)
    threshold_min, threshold_max = 0, 0
    for _ in range(N // 2):
        threshold_min = d.popleft()
        threshold_max = d.pop()
    print(threshold_max - threshold_min)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(int(input()) / 2)
d = list(map(int, input().strip().split()))
d.sort()
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)
num = n//2

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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