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: Runtime Error

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

print(y)

Submission status: Runtime Error

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

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

  
left = dl[(n//2)-1]
right = dl[(n//2)]

print(right-left)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

L[N//2]-L[N//2-1]

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

d.sort()

if d[int((N-1)/2)] == d[int(N/2)]:
    result = 0
else:
    result = d[int(N/2)]-d[int((N-1)/2)]

print(result)

Submission status: Runtime Error

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

d.sort()

if d[int((N-1)/2)] == d[int(N/2)]:
    result = 0
else:
    result = d[int(N/2)]-d[int((N-1)/2)]

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: map(str, sys.stdin.buffer.readline().split())
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
a = rl()
a.sort()
i = n//2
print(a[i+1] - a[i])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

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

Submission status: Runtime Error

Solution code:
# ans

import sys
input = sys.stdin.readline
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:
n=input()
l=list(map(int,input().split()))
ans=0
for i in range(n-2):
    a=l[i:i+3]
    b=a[1]
    c=sorted(a)
    if b==c[1]:
        ans+=1
print(ans)

Submission status: Runtime Error

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


left = d[tar]
right = d[tar + 1]
p#rint(left, right)
diff = right - left
if (diff == 0):
    ans = 0
else:
    ans = diff

print(ans)

Submission status: Runtime Error

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

D = sorted(D)
left = D[N//2]
right = D[N//2+1]

print(right-left)

Submission status: Runtime Error

Solution code:
difficulties = sorted(d)
l = len(difficulties)//2 - 1
r = len(difficulties)//2
print(difficulties[r] - difficulties[l])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

List.sort()

a = List[N/2-1]
b = List[N/2]

print(int(b-a))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = []
mod = 10**9+7
d = [0 for i in range(n+1)]
d[0] = 1
d[1] = 1
if n >1 :
    d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
d.append(0)
if m != 0:
    for i in range(m):
        b = int(input())
        a.append(b)
    ans = 1
    if a[0] == 1:
        ans = 1
    else:
        ans = ans*d[a[0]-1]%mod
    for i in range(m-1):
        ans = ans*d[a[i+1]-a[i]-2]%mod
    ans = ans*d[n-a[m-1]-1]%mod
else:
    ans = d[n]
print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = []
mod = 10**9+7
for i in range(m):
    b = int(input())
    a.append(b)
d = [0 for i in range(n+1)]
d[0] = 0
d[1] = 1
d[2] = 2
for i in range(3,n+1):
    d[i] = d[i-1] + d[i-2]
ans = 1
if a[0] == 1:
    ans = 1
else:
    ans = ans*d[a[0]-1]%mod
for i in range(m-1):
    ans = ans*d[a[i+1]-a[i]-2]%mod
ans = ans*d[n-a[m-1]-1]%mod
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

a = sorted(a)

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

Submission status: Runtime Error

Solution code:
N=int(input())
L=list(map(int,input().split())
M=list[]
m=list[]
for i in range(N):
  for x in range(N):
    if L[x]<i:
      L[x].append(M)
    else:
      L[x].append(m)
  if len(M)=len(m):
    ans+=1

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
S = sum(d)
if not d[N/2 - 1] < S/N <= d[N/2 + 1]:
  print(0)
elif:
  A = 0
  for i in range(d[N/2 + 1]-d[N/2 - 1]):
    d[N/2 - 1] + i+1 <= d[N/2 + 1]
    A += 1
  print(A)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = d[a]-d[a-1]

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 0 if table[di] is None else table[di] + 1

# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

Submission status: Runtime Error

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 0 if table[di] is None else table[di] += 1

# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

d.sort()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
N = int(input())
d = np.array(list(map(int, input().split())))
d.sort()

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

cnt = 0
for i in range(d[s],d[t+1]):
    if np.count_nonzero(d>=i)==t:
        cnt += 1
print(cnt)

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]

Submission status: Runtime Error

Solution code:
import sys
import itertools
import numpy as np

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

N = readline().decode().strip()
K = int(readline())
cnt = 0
ans = 0
for i in N:
    if len(N) == 1:
        ans = N[0]
        break
    if i == '1':
        cnt += 1
        continue
    else:
        if int(i) * 5000 * 10 ** 12 + cnt >= K:
            ans = i
            break
        else:
            ans = N[N.find(i) + 1]
            break

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())

array = list(map(int, input().split())).sort()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())
d = input().split(" ")
d_sort = sorted(d)

if d_sort[n/2] == d_sort[n/2+1]:
    print(0)
else:
    print(d_sort[n/2+1-n/2])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef long long ll;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d.at(i);
  sort(d.begin(), d.end());
  int ans = 0;
  ans = d.at(n / 2) - d.at(n / 2 - 1);
  cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = 0
B = 0
C = 0
D = 0


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


def f(n):
    return n - n // C - n // D + n // lcm(C, D)


def main():
    global A, B, C, D
    A, B, C, D = map(int, input().split())
    print(f(B) - f(A - 1))
    return


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    ans = 0
    if d[n//2] == d[n//2 + 1]:
        print('0')
        exit()
    ans = d[n//2] - d[n//2 - 1]
    print(ans)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N=int(input())
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): #Kはj
  i,s=0
  while D[i]<j and s<N//2:
    i+=1
    s+=1
  if s==N//2:
    point+=1
print(point)

Submission status: Runtime Error

Solution code:
N=int(input())
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi,ma+1): #Kはj
  i=0
  while a[i]<j and i+1<N//2+1:
    i+=1
  if i==N//2:
    point+=1
print(point)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

arr = sorted(arr_input)

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

if ans == 0:
    print(0)
else:
    print(ans)

Submission status: Runtime Error

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

print(d[2//n+3]-d[2//n+2])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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


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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

dd=sorted(d)

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

Submission status: Runtime Error

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

d=sorted(d)

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

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int, input().split())

import fractions

def lcm(x,y):
	return (x*y)//fractions.gcd(x,y)

lcmcd=lcm(c,d)
divc=b//c-(a-1)//c
divd=b//d-(a-1)//c
divcd=b//lcmcd-(a-1)//lcmcd

print(b-a+1-divc-divd+divcd)

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:
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:
def main():
  n = int(input())
  ks = sorted(list(map(int, input().split())))
  a, b = ks[n/2-1:n/2]
  if a == b:
    print(0)
  else:
    print(b-a)
  
  
if __name__ == '__main__':
  main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
use=[0]
ans=1
for i in range(m):
    use.append(int(input()))
use.append(n)

if n>=2:        
    lists=[1,2]

    for i in range(n-2):
        lists.append((lists[-1]+lists[-2])%1000000007)

    
    for i in range(m+1):
    
        if use[i+1]-use[i]==1 and i>=1:
            ans=0
            break
        else:
            ans=(ans*lists[int(use[i+1]-use[i]-2)])%1000000007
            
            
    print(ans)
elif n==1:
    print(1)

Submission status: Runtime Error

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

changed=sorted(s,reverse=True)


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

Submission status: Runtime Error

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

def sort(L):
  if len(L) < 2:
    return(L)
  p = L[0]
  X,Y = divide(p,L[1:])
  return sort(X) + [p] + sort(Y)

def divide(p,L):
  if len(L) < 1:
    return([],[])
  X,Y = divide(p,L[1:])
  l = L[0]
  if l < p:
    return([l] + X,Y)
  else:
    return(X,[l]+Y)
  
L = sort(L)
cut = L[int(N/2)] - L[int((N/2))-1]
print(cut)

Submission status: Runtime Error

Solution code:
import statistics
 
n = int(input())
d = list(map(int, input().split()))
 
if n % 2 == 1:
  print(0)
  exit()

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

Submission status: Runtime Error

Solution code:
import statistics

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

if n % 2 == 1:
  print(0)
  exit()
cnt = 0
index = 0
for _, num in enumerate(d):
  item = [j for j in d if j >= num]
  if len(item) == (len(d) / 2):
    cnt = num
    index = _

d = list(set(sorted(d)))
ans = cnt - d[d.index(cnt) - 1]
print(ans)

Submission status: Runtime Error

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

print(b-a)

Submission status: Runtime Error

Solution code:
import sys

n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0] + 1, dic[i+1][0])
        break
    elif i == len(dic) - 2:
        print(0)
        sys.exit()

print(ans[1] - ans[0] + 1)

Submission status: Runtime Error

Solution code:
n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0] + 1, dic[i+1][0])
        break
    elif i == len(dic) - 2:
        ans = (1, 0)
        break

print(ans[1] - ans[0] + 1)

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:
N = int(input())
lst = list(map(int, input().split()))
mid = N/2 - 1
lst = sorted(lst)
if lst[mid] == lst[mid+1]:
    print(0)
elif lst[mid] < lst[mid+1]:
    print(lst[mid+1]-lst[mid]+1)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-((b//c) + (b//d)- (b//e))
aa = a-1-(((a-1)//c)+((a-1)//d)-((a-1)//e))
z = bb-aa
print(int(z))

Submission status: Runtime Error

Solution code:
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(int(z))

Submission status: Runtime Error

Solution code:
n=int(input())
readints = lambda: map(int,input().split(' '))
a=list(readints())
a.sort()
mid = n//2
x=a[mid]
y=a[mid+1]
print(y-x)

Submission status: Runtime Error

Solution code:
n=int(input())
readints = lambda: list(map(int,input().split(' ')))
a=readints()
a.sort()
mid = n//2
x=a[mid]
y=a[mid+1]
print(y-x)

Submission status: Runtime Error

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

d.sort()

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if b[(n/2)-1]=b[(n/2)+1]:
  print(0)
else:
  c=b[(n/2)-1]
  d=b[(n/2)+1]
  e=count(range(c,d))
  print(e+1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

ds = list(map(int, input().split()))
ds.sort()

max_abc = ds[n/2 - 1]
min_arc = ds[n_2]

print(max_abc - min_arc)

Submission status: Runtime Error

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
#print(d)
c = [0] * N 
i = 0
tmp = d[0]
count = 1

for j in range(1,N):
    if tmp == d[j]:
        #print("yes",j)
        count += 1
    else:
        #print("no",j)
        tmp = d[j]   
        c[i] = count
        count = 1
        i += 1
#print(c)

hantei = 0
for j in range(N):
    hantei += c[j]
    if len(d) / 2 == hantei:
        hantei1 = 1
        break
    elif len(d) / 2 < hantei:
        hantei1 = 0
        break

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

Submission status: Runtime Error

Solution code:
n = input()
d = [int(i) for i in input().split()]
if len(d) % 2 == 1:
  ans = 0
else:
  d.sort()
  if d[len(d)-1] == d[len(d)]:
    ans = 0
  else:
    ans = d[len(d)] - d[len(d)]
    
print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sd = sorted(d)

if n %2 != 0:
  print(0)

else:

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

Submission status: Runtime Error

Solution code:
N = input()

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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


print(d)

Submission status: Runtime Error

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

d=L[int(n/2)+1]-L[int(n/2)]


print(d)

Submission status: Runtime Error

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

d=L[n/2+1]-L[n/2]


print(d)

Submission status: Runtime Error

Solution code:
N=int(input())
temp=input().split()
d=[int(temp[i]) for i in range(N)]
d.sort()
  
a=dd[int(N/2-1)]
b=dd[int(N/2)]
print(int(b-a))

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

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

def cmb(n,r,mod):
  if r==0 or n==r:return 1
  r = min(n-r,r)
  ue = reduce(mul, range(n, n-r, -1))
  shita = reduce(mul, range(1,r+1))
  return (ue//shita)%mod

for i in range(1,k+1):
  try:print(cmb(n-k+1,i,mod)*cmb(k-1,k-i,mod)%mod)
  except:print(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

sorted_d = sorted(d)
half = n/2

a = sorted_d[half]
b = sorted_d[half+1]

print(b-a)

Submission status: Runtime Error

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

sorted_d = sorted(d)
half = n/2 

sorted_d[half] = a 
sorted_d[half+1] = b 

print(b-a)

Submission status: Runtime Error

Solution code:
n = int(input())
lis = list(map(int, input().split()))
lis2 = sorted(lis)
m1 = lis2[n/2-1]
m2 = lis2[n/2]

c = 0
for i in range((m1+1), (m2+1)):
    c += 1
print(c)

Submission status: Runtime Error

Solution code:
n = int(input())

i = [int(input()) for d in range(n)]

i.sort()

l = i[n//2]
k = i[n//2-1]

print(l-k)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict as dd
from collections import deque
from copy import deepcopy as dc
N, M = map(int, input().split())
e = dd(list)
inf = 10 ** 9
for _ in range(M):
  u, v = map(int, input().split())
  e[u].append(v)
S, T = map(int, input().split())

stopped = [inf] * (N + 1)
Q = deque()
Q.append(S)
stopped[S] = 0
saw2 = {i: 0 for i in range(1, N + 1)}
saw3 = {i: 0 for i in range(1, N + 1)}
while len(Q) != 0:
  s2 = dc(saw2)
  s3 = dc(saw3)
  p = Q.popleft()
  if stopped[p] >= stopped[T]:
    break
  for q in e[p]:
    for r in e[q]:
      if s2[r] == 1:
        continue
      else:
        s2[r] = 1
      for s in e[r]:
        if s3[s] == 1:
          continue
        else:
          s3[s] = 1
        if stopped[s] > stopped[p] + 1:
          Q.append(s)
          stopped[s] = stopped[p] + 1
if stopped[T] == inf:
  print(-1)
else:
  print(stopped[T])

Submission status: Runtime Error

Solution code:
from collections import deque
n, m = map(int, input().split())

g = [[] for i in range(n)]

for i in range(m):
  u, v = map(int, input().split())
  u, v = u-1, v-1
  g[u].append(v)
# print(g)

s, t = map(int, input().split())
s, t = s-1, t-1

visited = [[-1]*3 for j in range(n)]

l = 0
queue = deque([[s, l]])
visited[s][l] = 0
while queue:
  x, l = queue.popleft()
  if [x, l] == [t, 0]:
    print(visited[x][l]//3)
    exit()
  for x_ in g[x]:
    new_x, new_l = x_, (l+1)%3
    if visited[new_x][new_l] == -1:
      visited[new_x][new_l] = visited[x][l]+1
      queue.append([new_x, new_l])
    
print(visited[t][0])

Submission status: Runtime Error

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

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