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: Time Limit Exceeded

Solution code:
n=int(input())
numeros=[int (x) for x in input().split()]
qtd=[]
K=1
cont2=0
while True:
    cont=0
    cont1=0
    for num in numeros:
        if num<K:
            cont+=1
        else:
            cont1+=1
    if cont==cont1:
        cont2+=1
    K+=1
    if K>max(numeros):
        break
print(cont2)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
numeros=[int (x) for x in input().split()]
qtd=[]
K=1
while True:
    cont=0
    cont1=0
    for num in numeros:
        if num<K:
            cont+=1
        else:
            cont1+=1
    if cont==cont1:
        qtd.append(K)
    K+=1
    if K>max(numeros):
        break

print(len(qtd))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
numeros=[int (x) for x in input().split()]
cont=0
cont1=1
qtd=[]
K=1
while True:
    for num in numeros:
        if num<K:
            cont+=1
        else:
            cont1+=1
    if cont==cont1:
        qtd.append(K)
    K+=1
    if K>max(numeros):
        break
    cont=0
    cont1=0
print(len(qtd))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d=list(map(int,input().split()))
cnt=0
for i in range(min(d),max(d)+1):
    abc=0
    arc=0
    for j in range(len(d)):
        if d[j] <= i:
            abc+=1
        else:
            arc+=1
    if abc == arc:
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=list(map(int,input().split()))
cnt=0
for i in range(min(D),max(D)+1):
    c=[]
    for d in D:
        if d>=i:
            c.append(d)
    if len(c)==N//2:
        cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(num)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
ans=0
for k in range(1,d[-1]+1):
    abc=[k>i for i in d]
    arc=[k<=i for i in d]
    if sum(arc)==sum(abc):
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
ans = 0
for i in range(1,d[-1] + 1):
    if sum(x <i for x in d) == N//2:
        ans += 1
    else:
        pass
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(1,max(d) + 1):
    if sum(x > i for x in d) == N//2:
        ans += 1
    else:
        pass
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
d = load_list()

l = 1
r = int(math.pow(10, 5))

def check(k):
    abc = []
    arc = []
    for e in d:
        if e >= k:
            arc.append(e)
        else:
            abc.append(e)
    if len(arc) > len(abc):
        return 1
    elif len(abc) > len(arc):
        return -1
    else:
        return 0


ans1 = -1
while l < r:
    mid = int((l + r) / 2)
    c = check(mid)
    if c == 0:
        ans1 = mid
        break
    elif c == 1:
        l = mid + 1
    elif c == -1:
        r = mid - 1
    

if ans1 == -1:
    print(0)
    exit()
tmp = ans1
cnt = 1
while True:
    if check(tmp - 1) == 0:
        cnt += 1
        tmp -= 1
    else:
        break
tmp = ans1
while True:
    if check(tmp + 1) == 0:
        cnt += 1
        tmp += 1
    else:
        break
    

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(k + 1):
    ar = 0
    ab = 0
    for j in l:
        if j >= i:
          ar += 1
        else:
            ab += 1
    if ar == ab:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

c = 0

for k in range(1,max(d)+1):
	arc = []
	abc = []
	for j in range(len(d)):
		if d[j] >= k:
			arc.append(d[j])
		else:
			abc.append(d[j])
	
	if len(abc) == len(arc):
		c += 1

print(c)

Submission status: Time Limit Exceeded

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

same = N // 2
count = 0

for i in range(2, 10 ** 5 + 1):
    count += d.count(i - 1)
    if count == same:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
arc = []
abc = []
cnt = 0
if n % 2 == 1:
    print(0)
    exit()
d.sort()
right = n // 2
left = right - 1
for i in range(d[left],d[right]+1):
    k = i
    abc = []
    arc = []
    for j in d:
        if j >= k:
            arc.append(j)
        elif j < k:
            abc.append(j)
    if len(arc) == len(abc):
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = 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):
    tmp = [x>=i for x in d]
    if tmp.count(True)==tmp.count(False):
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

j=-1
for i in range(1,len(s)):
    tmp=s[i]
    if s[i-1]>tmp:
        j=i
        while True:
            if s[j-1]>tmp and j>0:
                s[j]=s[j-1]
                j=j-1
            else:
                s[j]=tmp
                break
print(s[(n-1)//2+1]-s[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
D=sorted(map(int,input().split()))
maximum=max(D)
medium=0
for threshold in range(1,maximum+1):
    count=0
    for d in D:
        if d<threshold:
            count+=1
    if count==len(D)//2:
        medium+=1
print(medium)

Submission status: Time Limit Exceeded

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

for i in range(1, max(d) + 1):
    abc = []
    arc = []
    for j in d:
        if j >= i:
            arc.append(j)
        else:
            abc.append(j)
    if len(abc) == len(arc):
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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


ans = 0

for i in range(min(d),max(d) + 1):
    ARC = 0
    ABC = 0
    for j in range(N):
        if d[j] < i:
            ARC = ARC + 1
        else:
            ABC = ABC + 1
    if ABC == ARC:
        ans = ans + 1 

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int, input().split()))
cnt = 0
maxd = max(d)
mind = min(d)
for K in range(mind, maxd+1):
  if len([i for i in d if i >= K]) == len([i for i in d if i < K]): cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

def main():
    N = int(input())
    d = list(map(int, input().split()))
    mind = min(d)
    maxd = max(d)

    ans = 0
    for i in range(mind, maxd):
        n = sum(x > i for x in d)
        if n == N // 2:
            ans += 1


    print(ans)


main()

Submission status: Time Limit Exceeded

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

L=2
R=2*10**5


while 1:
    #print('Lis',L)
    #print('Ris',R)
    k=int((L+R)/2)
    #print('kis',k)
    ABC_num=0
    for i in range(len(d)):
        if d[i]<k:
            ABC_num+=1
    #print('ABC_num_is',ABC_num)
    if ABC_num==N/2:
        k_start=k
        break
    elif (L+1)==R:
        k_start=0
        break
    elif ABC_num<N/2:
        L=k
    else:
        R=k       
if k_start!=0:
    k=k_start+1
    while 1:
        ABC_num=0
        for i in range(len(d)):
            if d[i]<k:
                ABC_num+=1
        if ABC_num==N/2:
            k+=1
        else:
            k_r=k-1
            break
    k=k_start-1
    while 1:
        ABC_num=0
        for i in range(len(d)):
            if d[i]<k:
                ABC_num+=1
        if ABC_num==N/2:
            k-=1
        else:
            k_l=k+1
            break
    #print('k_ris',k_r)
    #print('k_lis',k_l)
    print(k_r-k_l+1)
else:
    print(0)

Submission status: Time Limit Exceeded

Solution code:
def calculate(arr):
    length = len(arr)
    s1 = (length // 2) - 1
    s2 = (length // 2)

    if arr[s2] == arr[s1]:
        return 0
    else:
        return arr[s2] - arr[s1]


def rank(arr):
    lastIndex = len(arr) - 1
    while lastIndex > 0:

        for i in range(lastIndex):
            if arr[i + 1] < arr[i]:
                tmp = arr[i + 1]
                arr[i + 1] = arr[i]
                arr[i] = tmp

        lastIndex = lastIndex - 1

    return arr

N = int(input())

if N == 0:
    result = 0
else:
    arr = rank([int(s) for s in  input().split(" ")])
    result = calculate(arr)

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int,input().split()))
E = []
while len(d)>0:
  a = min(d)
  E.append(a)
  d.remove(a)

k = int(N/2)
print(int(E[k])-int(E[k-1]))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
D = [int(i) for i in input().split(" ")]
count = 0
maxd = max(D)
for i in range(maxd+1):
    ARC = []
    ABC = []
    for j in D:
        if i < j:
            ARC.append(j)
        else:
            ABC.append(j)
    if len(ARC) == len(ABC):
        count+=1
print(count)

Submission status: Time Limit Exceeded

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

count = 0
for k in range(min(d_list), max(d_list) + 1):
    ABC = 0
    ARC = 0
    for i in range(N):
        if k > d_list[i]:
            ABC += 1
        else:
            ARC += 1
    if ABC > ARC:
        break
    elif ABC == ARC:
        count += 1
    else:
        pass

print(count)

Submission status: Time Limit Exceeded

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

ans = 0

for i in range(min(d), max(d)+1):
    d_list = [x for x in d if i <= x]

    if len(d_list) == N // 2:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
d=list(map(int,input().split()))
n=0
for k in range(1,10**5+1):
  m=0
  for b in d:
    if b<k:
      m+=1
  if m==N/2:
    n+=1
print(n)

Submission status: Time Limit Exceeded

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 D[i]<j and i<N-1:
        i+=1
    if i==N//2 :
        point+=1
print(point)

Submission status: Time Limit Exceeded

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

K = 1
while max(d) >= K:
    abc = []
    arc = []
    for i in d:
        if i >= K:
            arc.append(i)

        else:
            abc.append(i)
    if len(abc) == len(arc):
        ans += 1
    K += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = int(input())
d = [int(i) for i in input().split(" ")]
uni = np.unique(d)
co = [d.count(i) for i in uni]
tm = 0
for i in range(n):
    tm += co[i]
    if tm == n//2:
        print(uni[i+1]-uni[i])
        break
    if tm > n//2:
        print(0)
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

list_d = sorted(list(map(int, input().split())))

d_max = max(list_d)
d_min = min(list_d)

score = 0
for i in range(d_min, d_max+2):

    #abcを数える
    score1 = 0
    score2 = 0
    for j in list_d:
        if j < i:
            score1 += 1

        if j >= i:
            score2 += 1


    if score1 == score2:
        score += 1

print(score)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

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

a=sorted(m)
count=0

for i in range(min(a),max(a)+1):
    b=[j for j in a if i > j]
    if len(b) == N/2:
        count +=1
          
print(count)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
d.sort()
count = 0
dp = 0
for i in range(1,max(d)+1):
    dp += d.count(i)
    if dp == N / 2:
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
k_max = max(d)
k_min = min(d)
result = 0
for k in range(k_min,k_max+1):
    count = 0
    for i in range(n):
        if d[i] >= k:
            count += 1
        if count > n//2:
            break
    if count == n//2:
        result += 1
print(result)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=list(map(int, input().split()))
c=0
x = sorted(p)
a,b= x[int(n/2)-1], x[int(n/2)]
for k in range(a, b+1):
  arc = []
  abc = []
  for i in p:
    if k >= i:
      arc.append(arc)
    elif k <= i:
      abc.append(abc)
  if len(arc) == len(abc):
    c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=list(map(int, input().split()))
c=0
for k in range(min(p), max(p)+1):
  arc = []
  abc = []
  for i in p:
    if k >= i:
      arc.append(arc)
    elif k <= i:
      abc.append(abc)
  if len(arc) == len(abc):
    c+=1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
p=list(map(int, input().split()))
c=0
for k in range(1, max(p)+1):
  arc = []
  abc = []
  for i in p:
    if k >= i:
      arc.append(arc)
    elif k <= i:
      abc.append(abc)
  if len(arc) == len(abc):
    c+=1
print(c)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(K+1):
    temp_abc = 0
    temp_arc = 0
    for j in range(N):
        if d[j] >= i:
            temp_abc += 1
        else:
            temp_arc += 1
    if temp_abc == temp_arc:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] > a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a


n = int(input())

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

d = int(n / 2)

p = bSort(p)


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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
p_list = list(map(int, input().split()))
if n > 2:
	for i in range(int(n/2)-1):
		p_list.remove(max(p_list))
		p_list.remove(min(p_list))
print(max(p_list)-min(p_list))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
p_list = list(map(int, input().split()))
for i in range(int(n/2)-1):
	p_list.remove(max(p_list))
	p_list.remove(min(p_list))
print(max(p_list)-min(p_list))

Submission status: Time Limit Exceeded

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

m=int(n/2)
cnt=0
for i in range(L[m-1]+1,L[m]+1):
    
    if len(L[:m])==m:
        cnt+=1
        
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int, input().split()))
""" 
d = [9, 1, 4, 4, 6, 7]
#N = 8
N = 6
#d = [9, 1, 14, 5, 5, 4, 4, 14]
d = [9, 1, 4, 4, 6, 7]
 """
# prob
# [number,value]
prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1

""" print(prob)
print(sorted(prob, key=lambda x: x[1]))
 """
sorted_d = sorted(prob, key=lambda x: x[1])

d_max = sorted_d[N-1][1]
d_min = sorted_d[0][1]
#print(d_min, d_max)

cnt = 0
for i in range(N):
    """ print(sorted_d[0:i])
    print(sorted_d[i:])
 """
    if len(sorted_d[0:i]) == len(sorted_d[i:]):
        """ print("True")
        print(sorted_d[i][1])
        print(sorted_d[i-1][1])
        print(sorted_d[i][1] - sorted_d[i-1][1])
         """
        cnt += sorted_d[i][1] - sorted_d[i-1][1]
    # print("------")

print(cnt)

Submission status: Time Limit Exceeded

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

cnt = 0
for i in range(max(D)+1):
  ARC = 0
  ABC = 0
  for d in D:
    if i <= d:
      ARC +=1
    else:
      ABC +=1
  if ARC == ABC:
    cnt +=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] < i:
      s += 1
    if d[j] >= i:
      b += 1
    j += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  j = 0
  i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d_s=input().split()
d=[int(x) for x in d_s]
judge=0
count=0
for i in range(1,100000):
  for x in d:
    if x==i:
      count+=1
  if count==n/2:
    judge+=1
  elif count>n/2:
    break
print(judge)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
d=sorted(list(map(int,input().split())))
length=len(d)
k=[]
half_length=length//2
for i in range(d[half_length-1],d[half_length]+1):
    k.append(i)

ans1=[]
ans2=[]

count=0
for i in k:
    for j in d:
        if(j<i):
            ans1.append(j)
        else:
            ans2.append(j)
    if(len(ans1)==len(ans2)):
        count=count+1 
    ans1.clear()
    ans2.clear()
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] <= i:
      b += 1
    if d[j] > i:
      s += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
cs = [0]
ans = 0
for i in range(d[-1]):
  cs.append(cs[i]+d.count(i))

ans = cs.count(n/2)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int,input().split()))
y=0

for K in range(100000):
	k=0
	for i in range(n):
		if K<=x[i]:
			k=k+1
	if k==n/2:
		y=y+1
print(y)

Submission status: Time Limit Exceeded

Solution code:
input_line=int(input())
ARC = [int(i)for i in input().split()]
count=0
for i in range(10**5):
  AARC = ARC
  for s in ARC:
    if s<i:
      while s in AARC:
        AARC.remove(s)
  if (input_line//2)== len(AARC):
    count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
input_line=int(input())
ARC = [int(i)for i in input().split()]
ABC = []
count=0
for i in range(10**5):
  AARC = ARC
  AABC = ABC
  for s in ARC:
    if s < i :
      AABC.append(s)
      AARC.remove(s)
      while s in AARC:
        AABC.append(s)
        AARC.remove(s)
  if len(AABC) == len(AARC):
    count+=1

print(count)

Submission status: Time Limit Exceeded

Solution code:
# Check Examples

#python 3.7.
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0
det=len([])

p=sorted(p)
for i in range(n):
	arc=p[i:]
	abc=p[:i]
	
	if det and len(arc)<=len(abc):
		cnt=p[i]-p[i-1]
		break
	if arc>abc:det=True

print (cnt)

Submission status: Time Limit Exceeded

Solution code:
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

p=sorted(p)
for i in range(n-1):
	arc1=p[i:]
	abc1=p[:i]
	
	arc2=p[i+1:]
	abc2=p[:i+1]
	if len(arc1)>len(abc1) and len(arc2)<=len(abc2):
		cnt=p[i+1]-p[i]

print (cnt)

Submission status: Time Limit Exceeded

Solution code:
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

for i in range(min(p),max(p)+1):
	arc=[z for z in p if z>=i]
	abc=[z for z in p if z<i]
	if len(arc)==len(abc):cnt+=1
	if len(arc)<len(abc):break

print (cnt)

Submission status: Time Limit Exceeded

Solution code:
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

for i in range(1,max(p)+1):
	arc=[z for z in p if z>=i]
	abc=[z for z in p if z<i]
	if len(arc)==len(abc):cnt+=1
	if len(arc)<len(abc):break

print (cnt)

Submission status: Time Limit Exceeded

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

d.sort()

for i in range(int(d[int(N/2)-1]),int(d[int(N/2)]+1)):
    ABC=0
    ARC=0
    for j in range(int(N)):

        if d[j]<i:
            ABC+=1
        else:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

ave_d=sum(d)/N

diff=[]

for num1 in d:
    diff.append(num1-ave_d)

diff2=[]

for num2 in diff:
    diff2.append(num2**2)

dis_d=sum(diff2)/N

std_d=math.sqrt(dis_d)

for i in range(int(ave_d-std_d),int(ave_d+std_d+1)):
    ABC=0
    ARC=0
    for j in range(int(N)):

        if d[j]<i:
            ABC+=1
        else:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = [int(i) for i in input().split()]
while len(lst) > 2:
    lst.remove(min(lst))
    lst.remove(max(lst))
print(max(lst)-min(lst))

Submission status: Time Limit Exceeded

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

for i in range(int(max(d)+1)):
    ABC=0
    ARC=0
    for j in range(int(N)):

        if d[j]<i:
            ABC+=1
        else:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sorted_diffs = sorted(diffs)
abc = 0
arc = 0
result = 0
flag = False

for i in range(sorted_diffs[-1]+1):
    abc = 0
    arc = 0
    if i-1 not in diffs:
        if flag:
            result += 1
        continue
    for diff in sorted_diffs:
        if diff < i:
            abc += 1
        else:
            arc += 1
    if abc != 0 and abc == arc:
        result += 1
        flag = True
    elif abc > arc:
        print(result)
        exit()

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

sorted_diffs = sorted(diffs)
abc = 0
arc = 0
result = 0

for i in range(sorted_diffs[-1]+1):
    abc = 0
    arc = 0
    for diff in sorted_diffs:
        if diff < i:
            abc += 1
        else:
            arc += 1
    if abc != 0 and abc == arc:
        result += 1
    elif abc > arc:
        print(result)
        exit()

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d = list(map(int, input().split(' ')))
c = 0
mid = (max(d) + min(d))//2
for i in range(mid//2, mid*2):
    a = sum([1 for val in d if val < i])
    b = sum([1 for val in d if val >= i])
    if a == b:
        c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n1=int(input())
n2 = [int(x) for x in input().split()]

cnt_ARC = 0
cnt_ABC = 0
cnt = 0

for i in range(max(n2)):
  cnt_ARC = 0
  cnt_ABC = 0
  for j in range(len(n2)):
    if i+1 <= n2[j]:
      cnt_ARC += 1
    elif i+1 > n2[j]:
      cnt_ABC += 1

  if cnt_ARC == cnt_ABC:
    cnt += 1
    
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
num_input = int(input())
input_arr = [int(x) for x in input().split()]

max_input = max(input_arr)
count = 0

for input_ in range(max_input):
    first_arr = [s for s in input_arr if input_ < s]
    second_arr = [s for s in input_arr if input_ >= s]
    if len(first_arr) == len(second_arr):
        count = count + 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter

N = int(input())

c = Counter(list(map(int, input().split())))
D = sorted(list(c.keys()))

x = 0
s = 0
for k in D:
    a = sum([c[d] for d in D if d <= k])
    b = sum([c[d] for d in D if d > k])
    if a == b:
        x = k
    elif a > b and x > 0:
        s = k - x
        break

print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[int(s) for s in input().split()]
cnt=0
mx=max(l)
for i in range(1,mx+1):
  k=i
  arc=0
  abc=0
  for j in range(len(l)):
    if l[j]>=k:
      arc+=1
    else:
      abc+=1
  if arc==abc:
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys

n=int(input())
ls=list(map(int,input().split()))
ls.sort()
end_k=ls[len(ls)//2]

cnt=0

for i in range(end_k):
    num=0
    for j in range(n):
        if ls[j]>i:
            num+=1
    if num==n//2:
        cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

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

max_dif = max(dif)

ans = 0
for i in range(max_dif+1):
	ARC = []
	ABC = []
	for j in range(n):
		if dif[j] >= i:
			ARC.append(dif[j])
		else:
			ABC.append(dif[j])
			
	if len(ARC) == len(ABC):
		ans += 1
		
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from numpy import array
n = int(input()) / 2
d = array([int(i) for i in input().split()])

c = 0
b = 0
for i in sorted(d):
    if sum(d < i) == n:
        c += i - b
    b = i
print(c)

Submission status: Time Limit Exceeded

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

banken = 1
for item in d:
    if len(d[:banken]) == len(d[banken:]):
        break
    if banken >= len(d):
        break
    banken += 1

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

Submission status: Time Limit Exceeded

Solution code:
x = int(input())
y = input().split()
for u in range(len(y)):
    y[u] = int(y[u])
y = sorted(y)
count = 0

for i in range(max(y)):
    a = [u for u in y if u > i]
    if len(a) == int(len(y) / 2):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n=input()
s=input()
s=s.replace(" ",",")
s=str(s).split(",")
l=list(s)
x=0
for i in range(100000):
  a=0
  b=0
  for j in range(int(n)):
    if int(int(l[j]))>=i+1:
      a=a+1
    else:
      b=b+1
  if a==b:
    x=x+1
print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
L = list(int(i) for i in input().split()) 
n = N//2
cnt = 0
data = sorted(L)
data1 = data[:n]
data2 = data[n:]
for i in range(100000):
    if max(data1) < i and i <= min(data2):
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

th1=-1
th2=0
for k in range(100000):
    c1 = 0
    c2 = 0
    for i in range(n):
        if d[i]<k:
            c1+=1
        elif d[i]>=k:
            c2+=1
    if c1==c2 and th1==-1:
        th1=k
    if th1!=-1 and c1 != c2:
        th2 = k-1
        break
if th1 != -1:
    print(th2-th1+1)
else:
    print(th2)

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

L=0
R=0
DDT = 0
ans = 0
for K in range(statistics.median_low(d)-min(d),statistics.median_low(d)+max(d)):
    for i in range(N):
        if d[i] == K:
            DDT += 1
        elif d[i] < K:
            L += 1
        else:
            R += 1
    if L == R:
        ans += 1
    else:
        while DDT > 0:
            if L < R:
                L += 1
                DDT -= 1
            elif L > R:
                R += 1
                DDT -= 1
            else:
                L += 1
                DDT -= 1
        if L == R:
            ans += 1
    L = 0
    R = 0
    DDT = 0
print(ans-1)

Submission status: Time Limit Exceeded

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

li.sort()

ind=int(n//2)-1

count=0
for k in range(li[ind]+1,li[ind+1]+1):
  miman=0
  ijou=0
  for num in li:
    if num >= k:
      ijou+=1
    elif num < k:
      miman+=1
      
  if ijou==miman:
    count+=1
    
print(count)