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

Submission status: Accepted

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n,m = ips()
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!

n = ip()
a = iprow()
a.sort()
if a[n//2-1] == a[n//2]:
    print(0)
else:
    print(a[n//2]-a[n//2-1])

Submission status: Accepted

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


d.sort()

idx1 = n//2 - 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n
# a, b
# s = input()


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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
# input関係の定義
# fin = open('in_3.txt', 'r')
# sys.stdin = fin
#
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


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


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    D = get_li()
    D.sort()
    a, b = D[len(D) // 2 - 1], D[len(D) // 2]
    print(b - a)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

if n%2==1:
    print(0)
    sys.exit()



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

Submission status: Accepted

Solution code:


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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())
listD = list(map(int, input().split()))
listD.sort()
length = len(listD)//2

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

Submission status: Accepted

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

ans = 0
for i in range(10**5+5):
    j = bisect(D, i)
    if j==N//2:
        ans += 1
    elif j>N//2:
        break
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#!/usr/bin/env pypy3

from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)

    input = sys.stdin.readline

    #import numpy as np
    #import scipy as sp

    # Python 3 modules: https://docs.python.org/3/library/

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    # Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
    # Before Python 3.5.  Import from math after it.
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')

    def lcm(a, b):
        return a * b // gcd(a,b)

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    ############################################################################


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

    D.sort()
    p1 = D[N // 2 - 1]
    p2 = D[N // 2]
    dprint(D, p1, p2)
    print(p2 - p1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

sorted_d = sorted(d)

half = N // 2 - 1

pre_half = sorted_d[half]
rea_half = sorted_d[half + 1]

print(rea_half - pre_half)

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:
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:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import random
import collections
import math
import itertools
import bisect

def real_main():
    n = read_int()
    nums = read_int_array()
    nums.sort()
    m1, m2 = n // 2 - 1, n // 2
    if nums[m1] == nums[m2]:
        print(0)
    else:
        print(nums[m2] - nums[m1])


def solve():
    pass


def main():
    if False and 'PYCHARM_HOSTED' in os.environ:
        main_pycharm()
    else:
        real_main()


from copy import deepcopy
def main_pycharm():
    solution = solve

    test_inputs = None
    test_outputs = None
    judge = None
    slow_solution = None
    if solution is not None:
        if test_outputs is not None:
            test_with_answers(solution, test_inputs, test_outputs)
        if judge is not None:
            test_with_judge(solution, test_inputs, judge)
        if slow_solution is not None:
            test_with_slow_solution(solution, test_inputs, slow_solution)


def test_with_answers(solution, inputs, answers):
    total, wrong = 0, 0
    for args, test_ans in zip(inputs, answers):
        ans = solution(*deepcopy(args))
        if ans != test_ans:
            print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))
            wrong += 1
        else:
            print('GOOD')
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_judge(solution, inputs_gen, judge):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        if not judge(deepcopy(ans), *deepcopy(args)):
            print('WRONG! ans=%s, args=%s' % (ans, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_slow_solution(solution, inputs_gen, solution_slow):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        slow = solution_slow(*deepcopy(args))
        if ans != slow:
            print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))

def generate_nums(n, min, max, check_if_good=None):
    while True:
        nums = [random.randint(min, max) for _ in range(n)]
        if check_if_good is None or check_if_good(nums):
            return nums

# This mergesort can be like 7 times faster than build in sort
# (for stupid reasons)
def mergesort(A, key=lambda x: x, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if key(C[A[i]]) > key(C[A[i ^ 1]]):
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if key(C[A[i]]) > key(C[A[j]]):
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A

def mergesort_simple(A, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if C[A[i]] > C[A[i ^ 1]]:
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if C[A[i]] > C[A[j]]:
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

def read():
    return input()

def read_int():
    return int(input())

def read_array(sep=None, maxsplit=-1):
    return input().split(sep, maxsplit)

def read_int_array():
    return [int(a) for a in read_array()]

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]

if N % 2 == 1:
    print(0)
else:
    X = [0] * 100100
    for i in range(N):
        X[A[i]] += 1
    Y = [0] * 100101
    for i in range(len(X)):
        Y[i+1] = Y[i] + X[i]
    ans = 0
    for i in range(len(Y)):
        if Y[i] == N//2:
            ans += 1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
d = sorted(map(int, raw_input().split()))
print d[N / 2] - d[N / 2 - 1]

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    D = LI()
    D.sort()
    print(D[N//2] - D[N//2 -1])
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

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

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

N = int(sys.stdin.readline())
D = list(map(int, sys.stdin.readline().split()))

D.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#coding:utf-8



def main():
    from sys import stdin

    input = stdin.readline
    N = int(input())
    D = list(map(int,input().split()))
    D.sort()
    lower = D[N//2-1]
    upper = D[N//2]
    print(upper-lower)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    m1 = d[n//2 - 1]
    m2 = d[n//2]
    # print('{} {}'.format(m1, m2))
    if m1 == m2:
        print(0)
    else:
        ans = m2 - m1
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == '__main__':
  main()

Submission status: Accepted

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

N = n()
D = sorted(nl())

before = D[N // 2 -1]
after = D[N // 2]

print(after - before)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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:
#!/usr/bin/env python3
import sys
INF = float("inf")


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

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
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(sorted(map(int, input().split())))

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

Submission status: Accepted

Solution code:
A = [0]*100010
N = int(input())
for i in input().split(" "):
	A[int(i)] += 1
total = 0
ans = 0
isOver = False
for i in range(100010):
	total += A[i]
	if total == N/2:
		ans += 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
*D, = map(int, input().split())
D.sort()
*P, = D[:N//2]
*Q, = D[N//2:]
print(Q[0] - P[-1])

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        k = p[i-1:i+2]
        k.sort()
        if k[1] == p[i]:
            ans += 1
    print(ans)
    return

#C
def C():
    n = I()
    d = LI()
    d.sort()
    print(d[n//2]-d[n//2-1])
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    C()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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

n = ni()
d = na()
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 = sorted(d)
a,b = d[n//2 - 1], d[n//2]
if a == b:
    print(0)
    exit()

print(b - a)

Submission status: Accepted

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

cnt = len(D) // 2 - 1

res = D[cnt + 1] - D[cnt]
print(res)

Submission status: Accepted

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = inp()
dd = inpl()
dd.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
from collections import defaultdict
import math


def main():
    num = int(input())
    data = list(map(int, input().split()))
    data.sort()
    a, b = data[(num - 1) // 2], data[num // 2]
    print(b- a)






if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

n = int(input())
ddd = list(map(int, input().split()))
ddd.sort()
# print(ddd)

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

Submission status: Runtime Error

Solution code:
#ABC132 C

N = int(input())
D = list(map(int,input().split()))
count = 0
for K in range(N):
    A = []
    B = []
    if D[i] >= K:
        A.append(D[i])
    else:
        B.append(D[i])
    if len(A) == len(B):
        count += 1
    
print(count)

Submission status: Runtime Error

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

if arr[n//2-1] == arr[n//2]:
  print(0)
  return
print(arr[n//2]-arr[n//2-1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

ans = 0
for K in range(1, 10**5+1):
  if np.sum(d[d>=K]) == np.sum(d[d<K]): ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8

def main():
    N = int(input())
    d = sorted(list(map(int, input().split())))
    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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

if D[M] == D[M-1] or (D[M] == D[M+1] and D[M-1] == D[M-2] and D[M] == D[M-1]+1):
  ans = 0

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, k = map(int, input().split())
mod = 10**9+7

def nCr(N, R, mod):
  R = min(R, N-R)
  numer = denom = 1
  for i in range(1, R+1):
    numer = numer * (N+1-i) % mod
    denom = denom * i % mod
  res = numer * pow(denom, mod-2, mod) % mod
  return res

for i in range(1,k+1):
  if n-k+1<i:
    print (0)
    continue
  y = nCr(n-k+1,i,mod)
  y *= nCr(k-1,i-1, mod)
  print (y%mod)

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(int,input().split()))
l.sort()
a=n/2
s=l.index(a-1)
t=l.index(a)
if s==t:
  print("0")
else:
  ans=t-s
  print(ans)

Submission status: Runtime Error

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

print(y)