Problem:
 Score : 200 points    Problem Statement There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.  Initially, you are in Square X .
You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N .
However, for each i = 1, 2, ..., M , there is a toll gate in Square A_i , and traveling to Square A_i incurs a cost of 1 .
It is guaranteed that there is no toll gate in Square 0 , Square X and Square N .  Find the minimum cost incurred before reaching the goal.      Constraints  1 \leq N \leq 100  1 \leq M \leq 100  1 \leq X \leq N - 1  1 \leq A_1 < A_2 < ... < A_M \leq N  A_i \neq X  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  M  X  A_1  A_2  ...  A_M       Output Print the minimum cost incurred before reaching the goal.        Sample Input 1 5 3 3
1 2 4      Sample Output 1 1  The optimal solution is as follows:   First, travel from Square 3 to Square 4 . Here, there is a toll gate in Square 4 , so the cost of 1 is incurred.  Then, travel from Square 4 to Square 5 . This time, no cost is incurred.  Now, we are in Square 5 and we have reached the goal.   In this case, the total cost incurred is 1 .       Sample Input 2 7 3 2
4 5 6      Sample Output 2 0  We may be able to reach the goal at no cost.       Sample Input 3 10 7 5
1 2 3 4 6 8 9      Sample Output 3 3

Solution (Python):
N , M , X = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
    if A[i] > X:
        break
print(min(i , M - i))

Solution (Python):
N,M,X=map(int, input().split())
a=list(map(int, input().split()))
a.append(X)
a.sort()
print(min(a.index(X),len(a)-a.index(X)-1))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(str,input().split()))
count_bef=0
count_aft=0

for i in range(0,X):
  if str(i) in A:
    count_bef += 1
for j in range(X,N+1):
  if str(j) in A:
    count_aft += 1
if count_bef<=count_aft:
  print(count_bef)
else:
  print(count_aft)

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
print(min(len([i for i in A if i<X]),len([i for i in A if i>X])))

Solution (Python):
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
l,r = 0,0
for a in A:
	if a < x:
		l += 1
	else:
		r += 1
print(min(r,l))

Solution (Python):
import numpy as np

N,M,X=list(map(int,input().split(" ")))
A=np.asarray(list(map(int,input().split(" "))))

print(min(len(A[A<X]),len(A[A>X])))

Solution (Python):
N,M,X = map(int,input().split())
li = list(map(int,input().split()))
ans1 = 0
ans2 = 0
for i in range(X,N):
  for j in range(M):
    if li[j] == i:
      ans1 += 1
for i in range(X):
  for j in range(M):
    if li[j] == i:
      ans2 += 1
print(min(ans1,ans2))

Solution (Python):
n,m,x = map(int,input().split())
numbers = list(map(int,input().split()))
y = x
z = x
x0 = 0
xn = 0
for i in range (0,x):
  y -= 1
  if y in numbers:
    x0 += 1
  else:
    continue
for j in range(x,n):
  z += 1
  if z in numbers:
    xn += 1
  else:
    continue
print(min(x0,xn))

Solution (Python):
N, M, X =list(map(int,input().split()))
A = list(map(int, input().split()))

ans1 = 0
for i in range(1,X):
    for j in A:
        if i == j:
            ans1 += 1



ans2 = 0           
for i in range(X+1, N):
    for j in A:
        if i == j:
            ans2 += 1

    

print(min(ans1,ans2))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
table=[False]*(n+1)
for i in a:
  table[i]=True
left=sum(table[:x])
right=sum(table[x:])
print(min(left,right))

Solution (Python):
N, M, X = (int(i) for i in input().split())
A = sorted([int(i) for i in input().split()])
ans = 0
for i in A:
    if X < i: break
    ans += 1
print(min(ans, M - ans))

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,m,x=map(int,input().split())
A=list(map(int,input().split()))
i=bisect.bisect_left(A,x)
print(min(i,m-i))

Solution (Python):

import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,m,x=map(int,input().split())
A=list(map(int,input().split()))
i=bisect.bisect_left(A,x)
print(min(i,m-i))

Solution (Python):
import bisect
N, M, X = map(int, input().split())
lst = list(map(int, input().split()))

a = bisect.bisect_left(lst, X)
print(min(M-a, a))

Solution (Python):
def examB():
    N, M, X = LI()
    A = LI()
    L0 = bisect.bisect_left(A,X)
    L1 = M-L0
    ans = min(L0,L1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, X = MAP()
A = LIST()
idx = bisect(A, X)
print(min(idx, M-idx))

Solution (Python):
n,m,x = map(int,input().split())
al = list(map(int,input().split()))

a = [1 for i in al if i > x]
b = [1 for i in al if i < x]

print(min(len(a), len(b)))

Solution (Python):
N,M,X = map(int,input().split())
A = [int(i) for i in input().split()]
tall = [0] * (N+1)
for a in A:
    tall[a] = 1
print(min(sum(tall[:X]),sum(tall[X+1:])))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
gatedict = {i : 0 for i in range(n + 1)}
for i in range(m) :
    gatedict[a[i]] = 1
before = 0
for p in range(x) :
    before += gatedict[p]
after = 0
for q in range(x+1,n+1) :
    after += gatedict[q]
print(min(before, after))

Solution (Python):
N, M, X = list(map(int, input().split()))
nl = len([a for a in map(int, input().split()) if a<X])
print(min(nl,M-nl))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

right_cost = 0
pos = X
for i in range(N-X):
    pos += 1
    if pos in A:
        right_cost += 1
        
left_cost = 0
pos = X
for i in range(X):
    pos -= 1
    if pos in A:
        left_cost += 1

print(min(right_cost, left_cost))

Solution (Python):
N,M,X = map(int,input().split())
L = list(map(int,input().split()))
over = 0
lower = 0
for i in L:
    if(i < X):
        lower += 1
    else:
        over += 1
ans = min(over,lower)
print(ans)

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
r = 0
l = 0
for i in range(x, n+1):
    if i in a:
        r += 1
for i in range(0, x):
    if i in a:
        l += 1
print(min(r, l))

Solution (Python):
from sys import stdin
import numpy as np
n,m,x= [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

lin= [0]*(n+1)

for i in li:
    lin[i] = 1
print(min(sum(lin[:x]),sum(lin[x+1:])))

Solution (Python):
n,m,x=map(int,input().split())
a=[int(i) for i in input().split()]
right=0
left=0
for i in a:
  if i>x:
    right+=1
  else:
    left+=1
print(min(right,left))

Solution (Python):
n, m, x = map(int, input().split())
list_a = list(map(int, input().split()))
count = sum([1 for one_a in list_a if one_a < x])
print(min(count, len(list_a)-count))

Solution (Python):
n, m, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(min(len([ai for ai in a if ai < x]), len([ai for ai in a if ai > x])))

Solution (Python):
n,m,x=map(int,input().split())
a=map(int,input().split())

left=0
right=0

for ai in a:
  if ai<x:
    left+=1
  else:
    right+=1
print(min(left,right))

Solution (Python):

n, m, x = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]

squares = [0] * (n + 1)

for i in range(m):
    squares[a[i]] = 1

print(min(squares[:x].count(1), squares[x + 1:].count(1)))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in a:
  if i<x:
    c+=1
if c<m-c:
  print(c)
else:
  print(m-c)

Solution (Python):
import bisect

n, m, x = map(int, input().split())
A = list(map(int, input().split()))
r = bisect.bisect_right(A, x)
if 2*r <= m:
  print(r)
else:
  print(m-r)

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
left=0
right=0
for i in a:
    if i in range(0,x):
        left+=1
    else:
        right+=1
print(min(left,right))

Solution (Python):
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Solution (Python):
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
l_big = [i for i in l if i > x]
l_small = [i for i in l if i < x]
print(min(len(l_big), len(l_small)))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 0

for i in range(M):
    if A[i] < X:
        l += 1
    else:
        r += 1

print(min(l, r))

Solution (Python):
N, M, X = map(int, input().split())
l = list(map(int, input().split()))

G0, GN = 0, 0

for i in range(X):
  if i in l:
    G0 += 1

for i in range(X, N):
  if i in l:
    GN += 1
    
print(min(G0, GN))

Solution (Python):

n,m,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
ans1=0
for i in range(x):
    if i in a:
        ans+=1
    
for j in range(x+1,n+2):
    if j in a:
        ans1+=1
        
print(min(ans,ans1))

Solution (Python):
a,b,c=map(int,input().split())
x=list(map(int,input().split()))
c1=0
c2=0
for i in range(b):
    if x[i]<c:
        c1+=1
    else:
        c2+=1
print(min(c1,c2))

Solution (Python):
n,m,x = map(int,input().split())
import numpy as np
a = np.array(list(map(int,input().split())))
print(min(np.sum((0<a) & (a<x)),np.sum((x<a) & (a<n))))

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

def main():
    n,m,x=map(int,input().split())
    aa=list(map(int,input().split()))
    print(min([sum(1 for a in aa if a < x),sum(1 for a in aa if a > x)]))

main()

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
cost = [0]*(n+1)
for i in a:
    cost[i] += 1
ans = min(sum(cost[0:x]), sum(cost[x:]))
print(ans)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m,x = inpl()
a = inpl()
for i in range(m):
    if a[i] >= x:
        break
print(min(i,m-i))

Solution (Python):


import sys



import bisect






def main():
    n, m, x, *a = (int(i) for i in sys.stdin.read().split())
    th_x  = bisect.bisect_left(a, x)
    cost = min(th_x, m - th_x)
    print(cost)
    


if __name__ == "__main__":
    
    main()

Solution (Python):
n, m, x = list(map(int, input().split()))
A = list(map(int, input().split()))

zero_g = 0
n_g = 0

for i in range(len(A)):
    if A[i] < x:
        zero_g += 1
    else:
        n_g += 1
print(min(n_g, zero_g))

Solution (Python):
N, M, X = map(int, input().split())
A = [0] * N
for i in [int(a) for a in input().split()]:
    A[i] += 1
B = [0] * (N+1)
C = [0] * (N+1)
for i in range(N):
    B[i+1] = B[i] + A[i]
for i in range(N)[::-1]:
    C[i] = C[i+1] + A[i]

print(M - max(B[X+1], C[X]))

Solution (Python):
n,m,x=map(int,input().split())
A = [int(x) for x in input().split()]
right = 0
left =0
for i in range(x,n+1):
  if i in A:
    right +=1
for i in range(x):
  if i in A:
    left +=1
print(min(right,left))

Solution (Python):
import bisect
import sys
input = sys.stdin.readline


def main():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))

    x = bisect.bisect_left(A, X)
    ans = min(len(A[:x]), len(A[x:]))

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
c1, c2 = 0, 0
for i in range(X, N):
    if i in A:
        c1 += 1
for i in range(1, X+1):
    if i in A:
        c2 += 1
print(min(c1, c2))

Solution (Python):
import bisect

n, m, x = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]

index = bisect.bisect(a, x)
print(min(len(a[:index]), len(a[index:])))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

import numpy as np
A=np.array(A)
print(min(np.count_nonzero(A > X),np.count_nonzero(A < X)))

Solution (Python):
n,m,x = map(int,input().split())

A = [int(i) for i in input().split()]
couA = 0
couB  =0
for i in range(x,n):
    if A.count(i):
        couA +=1
for j in range(x,0,-1):
    if A.count(j):
        couB +=1
print(min(couA,couB))

Solution (Python):
n,m,x = map(int,input().split())
a = map(int,input().split())
left = 0
right = 0

for i in a:
    if i < x:
        left += 1
    else:
        right += 1
print(min(right,left))

Solution (Python):
N,M,X = map(int,input().split())
A = [0]*(N+1)
for a in map(int,input().split()):
  A[a] = 1
print(min(sum(A[:X]),sum(A[X:])))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
a=0
b=0
for m in range(M):
    if A[m]<X:
        a+=1
    else:
        b+=1
print(min(a,b))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

right = 0
left = 0
for a in A:
  if a < X:
    left += 1
  else:
    right = len(A) - left
    break

print(min(left, right))

Solution (Python):
import bisect

n,m,x = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]

l2 = bisect.bisect(l,x)

print(min(len(l)-l2,l2))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
tmp1 = list(range(X))
tmp2 = list(range(X+1,N))
ans = []
count = 0
for i in range(len(tmp1)):
    if tmp1[i] in A:
        count += 1
ans.append(count)
count = 0
for j in range(len(tmp2)):
    if tmp2[j] in A:
        count += 1
ans.append(count)
print(min(ans))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in a:
    if i < x:
        count += 1
print(min(count, len(a)-count))

Solution (Python):
n, m, x = map(int, input().split())
a_list = list(map(int, input().split()))
under = 0
for a in a_list:
  if a < x:
    under += 1
print(min(under, len(a_list)-under))

Solution (Python):
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Solution (Python):
import bisect as bi

N,M,X=map(int,input().split())
A=list(map(int,input().split()))

i=bi.bisect_left(A,X)

print(min(i,M-i))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
a = 0
b = 0

for i in A:
  if i < X:
    a += 1
  else:
    b += 1
print(min(a, b))

Solution (Python):
n, m, x = map(int, input().split())

tollList = [0] * (n + 1)
a = list(map(int, input().split()))

for num in a:
    tollList[num] = 1
ans = min(sum(tollList[0:x+1]), sum(tollList[x:]))


print(ans)

Solution (Python):
N, M, X = map(int, input().split())
A = [int(a) for a in input().split()]

masu = [0 for _ in range(N+1)]
for a in A:
  masu[a] = 1
answer = min(sum(masu[:X]), sum(masu[X:]))
print(answer)

Solution (Python):
n, m, x = map(int,input().split())
A = list(map(int,input().split()))
left = [1 for i in A if i <x]
right = [1 for i in A if i > x]
Answer = min(sum(left), sum(right))

print(Answer)

Solution (Python):
N,M,X=map(int,input().split())
A=[int(i) for i in input().split()]
a=len([1 for i in A if 0<i<X])
b=len([1 for i in A if X<i<N])
print(min(a,b))

Solution (Python):
def main():

    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    count1 = 0
    for i in range(M):
        if A[i] < X: count1 += 1
    return min(count1, len(A)-count1)



if __name__ == '__main__':
    print(main())

Solution (Python):
n,m,x = map(int,input().split())
a = [int(i) for i in input().split()]
cnt1 = 0
cnt2 = 0
for i in range(x,n+1):
    if i in a:
        cnt1 += 1
for i in range(x,-1,-1):
    if i in a:
        cnt2 += 1
print(min(cnt1,cnt2))

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
l = []
before = 0
after = 0
for i in range(n+1):
  l.append(i)

for i in range(m):
  if a[i] < x:
    before += 1
  else:
    after += 1
print(min(before, after))

Solution (Python):
n,m,x = map(int,input().split())
a = [int(i) for i in input().split()]
c = 0
d = 0
for i in a:
    if i < x:
        c+=1
    else:
        d+=1
print(min(c,d))

Solution (Python):
n,m,x = map(int,input().split())
aa = list(map(int,input().split()))

left=0
right=0
for ai in aa:
  if ai < x:
    left += 1
  elif ai > x:
    right += 1
print(min(left,right))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
l = 0
r = 0
for a in A:
  if a < X:
    l += 1
  else:
    r += 1
print(min(l, r))

Solution (Python):
N, M, X = map(int, input().split())

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


for i in range(M):
    if A[0] >= X:
        ans = 0
        break
    elif A[M-1] <= X:
        ans = 0
        break
    else:
        if A[i-1] < X and X < A[i]:
            ans = min(i,M-i)

print(ans)

Solution (Python):
N, M, X = map(int, input().split())

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

left = 0
right = 0

for i in A:
    if X < i:
        left += 1
    elif X > i:
        right += 1

print(min(left, right))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))


for i in range(M):
    if A[0] >= X:
        ans = 0
        break
    elif A[M-1] <= X:
        ans = 0
        break
    else:
        if A[i] == X:
            ans = min(i, M-1-i)
        elif A[i-1] < X and X < A[i]:
            ans = min(i,M-i)

print(ans)

Solution (Python):
n,m,x = map(int, input().split())
s = sum(int(i)<x for i in input().split())
print(min(s,m-s))

Solution (Python):
n,m,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = len(list(filter(lambda y:y>x, a)))
b = len(a)-f
print(f if f < b else b)

Solution (Python):
n,m,x = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = list(filter(lambda y:y>x, a))
if len(f) < len(a)-len(f):
  print(len(f))
else:
  print(len(a)-len(f))

Solution (Python):
n, m, x = map(int, input().split())
a = [int(x) for x in input().split()]
key1 = len(a)
key2 = 0
for i in range(key1):
    if a[i] <= x:
        key2 += 1
    else:
        break
print(min([key2, key1-key2]))

Solution (Python):
n, m, x = map(int, input().split())
A = list(map(int, input().split()))

cnt = 0
for a in A:
    if a < x:
        cnt += 1
    else:
        break

print(min(cnt, len(A)-cnt))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
l,r=0,0
for i in a:
  if i<x:
    l+=1
  else:
    r+=1
print(min(l,r))

Solution (Python):
N,M,X = map(int, input().split())
H = list(map(int, input().split()))
left = 0
right = 0
for i in range(N):
    if i in H:
        if i < X:
            left += 1
        else:
            right += 1
print(min(left, right))

Solution (Python):
n, m, x = map(int, input().split())
a = [int(j) for j in input().split()]

print(min(len([i for i in a if i < x]), len([i for i in a if i > x])))

Solution (Python):
N, M ,X = map(int, input().split())
A = list(map(int, input().split()))

cost = [0]*(N+1)
for idx in range(M):
    cost[A[idx]] = 1

print(min(sum(cost[:X]), sum(cost[X+1:])))

Solution (Python):
N, M, X = map(int, input().split())
array = list(map(int, input().split()))
index = [0] * (N+1)
tmp = 0
tmp2 = 0
for i in range(N):
    if i in array:
        index[i] = 1
for i in range(X,N+1):
    tmp += index[i]
for i in range(0,X+1):
    tmp2 += index[i]
if tmp <= tmp2:
    print(tmp)
else:
    print(tmp2)

Solution (Python):
n,m,x=map(int,input().split())
a_ls=list(map(int,input().split()))
low=0
high=0
for i in a_ls:
	if i > x:
		high += 1
	else:
		low += 1
print(min(low,high))

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))

tozero = len([i for i in a if i<x])
print(min(tozero,len(a)-tozero))

Solution (Python):

N,M,X = map(int, input().split())

A_list = [int(e) for e in input().split()]

cost_to_zero = 0
cost_to_N = 0

for toll_gate in A_list:
    if toll_gate < X:
        cost_to_zero += 1
    elif toll_gate > X:
        cost_to_N += 1

print(min(cost_to_zero,cost_to_N))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
backward = 0
forward = 0

for i in range(x):
    if i in a:
        backward += 1

for i in range(x, n + 1):
    if i in a:
        forward += 1

print(min(forward, backward))

Solution (Python):
n,m,x = map(int,input().split())
arr = list(map(int,input().split()))

l = 0

for a in arr:
    if a < x:
        l += 1
r = m-l
print(min(l,r))

Solution (Python):
n,m,x=map(int,input().split())
k=[0]*(n+1)
a=[int(_) for _ in input().split()]
for i in a:
    k[i] = 1
print(min(sum(k[:x]),sum(k[x:])))

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
cnt=0
for y in a:
    if y < x:
        cnt+=1
print(min(cnt,m-cnt))

Solution (Python):
n,m,x=map(int,input().split())
*a,=map(int,input().split())
left=len([b for b in a if b < x])
right=len([b for b in a if b > x])
print(min(left, right))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
k = [x for x in range(X+1,N)]
b = [x for x in range(0,X)]
right = 0
left = 0
for i in range(len(A)):
  if A[i] in k:
    right += 1
  elif A[i] in b:
    left += 1
print(min(right,left))

Solution (Python):
import sys
from bisect import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n,m,x=map(int, input().split())
    a=list(map(int, input().split()))
    i=bisect_left(a,x)
    print(min(i,m-i))

main()

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
left = [A[i] for i in range(M) if A[i] < X ]
right = [A[i] for i in range(M) if A[i] > X]
print(min(len(left),len(right)))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
R=[0]*(N+1)
for i in A:
    R[i]+=1

print(min(sum(R[:X+1]),sum(R[X:])))

Solution (Python):
N,M,X = map(int, input().split())
A = list(map(int, input().split()))

l_cnt = 0
for i in range(M):
    if A[i] < X:
        l_cnt += 1
    else:
        break

print(min(l_cnt, M-l_cnt))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
for i in range(M):
    if A[i]<X:
        cnt += 1
print(min(cnt,M-cnt))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
L=0
for a in A:
    if a<X:
        L+=1
    else:
        break
print(min(M-L,L))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
L=0
for a in A:
    if a<X:
        L+=1
    else:
        break
R=M-L
print(min(R,L))

Solution (Python):
N,M,X=map(int,input().split())
A=[]
A+=list(map(int,input().split()))
s=0
z=0
for j in range(M):
    if A[j]>X:
        s+=1
    elif A[j]<X:
        z+=1
print(min(s,z))

Solution (Python):
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))

Solution (Python):
n,m,X=map(int,input().split())
a=list(map(int,input().split()))
x=0
y=m
for i in range(m):
    if a[i]<=X:
        x+=1
        y-=1
print(min(x,y))

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    print(
        min(
            sum([i in a for i in range(x, n + 1)]),
            sum([i in a for i in range(x, 0, -1)]),
        )
    )


if __name__ == "__main__":
    main()

Solution (Python):

std_input = open(0).readlines()
N, M, Q = map(int, std_input[0].split())

A = list(map(int, std_input[1].split()))

cnt_up = 0
cnt_down = 0
Qup = Q
Qdown = Q
for i in range(N-Q):
    Qup += 1
    if Qup in A:
        cnt_up += 1
for i in range(N):
    Qdown -= 1

    if Qdown < 0:
        break
    if Qdown in A:
        cnt_down += 1

print(min(cnt_up,cnt_down))

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, m, x = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    ca = 0
    cb = 0
    for i in range(m):
        if a[i] < x:
            ca += 1
        else:
            cb += 1
    print(min(ca, cb))


if __name__ == '__main__':
    slove()

Solution (Python):
n, m, x = map(int, input().split())
an = list(map(int, input().split()))

print(min( len([a for a in an if a < x]), len([a for a in an if a > x])))

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, M, X] = string_to_int(inputs[0])
    A = string_to_int(inputs[1])
    cost_0 = 0
    cost_n = 0
    for a in A:
        if a < X:
            cost_0 += 1
        elif a > X:
            cost_n += 1
    return min([cost_0, cost_n])


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Solution (Python):
from bisect import bisect_left
N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
b = bisect_left(A,X)
if b==0:
  print(0)
  exit()
print(min(b,M-b))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

count1=0
for i in range(X,N):
    for j in A:
        if i == j:
            count1 +=1
            
count2=0            
for i in range(X+1):
    for j in A:
        if i == j:
            count2 +=1
        
print(min(count1,count2))

Solution (Python):
N,M,X = map(int,input().split())
A = set(map(int,input().split()))
Af = [1 for i in range(1,X) if i in A]
Al = [1 for i in range(X+1,N) if i in A]
print(min(sum(Af),sum(Al)))

Solution (Python):
n,m,x = map(int,input().split())
a = [int(_) for _ in input().split()]
cnt_a =0
cnt_b=0
for i in range(len(a)):
  if a[i] <x:
    cnt_a +=1
  else:
    cnt_b+=1
print(min(cnt_a,cnt_b))

Solution (Python):
def bb094():
    n,m,x = list(map(int, input().split()))
    am = list(map(int, input().split()))

    toz = 0
    for i in range(x, 0, -1):
        if am.count(i) == 1:
            toz += 1

    ton = 0
    for i in range(x, n, 1):
        if am.count(i) == 1:
            ton += 1

    print(min([toz, ton]))

bb094()

Solution (Python):
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
for i in a:
    if i < x:
        ans += 1
print(min(ans,m-ans))

Solution (Python):
n, m, x = map(int, input().split())
*a, = map(int, input().split())
c = len([1 for y in a if y < x])
print(min(c, m-c))

Solution (Python):
from bisect import bisect_left
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
p = bisect_left(a, x)
print(min(m-p, p))

Solution (Python):
n,m,x = map(int,input().split())
li = [0]*(n+1)
a = list(map(int,input().split()))
for i in range(m):
    li[a[i]] = 1

print(min(sum(li[:x]),sum(li[x:])))

Solution (Python):
a, b, c = map(int, input().split())
L = list(map(int, input().split()))
print(min(len(set(L)&set(range(1,c))),len(set(L)&set(range(c+1,a)))))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
res = [0]*N
for a in A:
    res[a] = 1
print(min(sum(res[:X]), sum(res[X:])))

Solution (Python):
n,m,x=map(int, input().split())
l=list(map(int, input().split()))
a=0
for i in l:
	if i<x:
		a+=1
print(min(a,len(l)-a))

Solution (Python):
n,m,x=map(int, input().split())
l=list(map(int, input().split()))
a=0
for i in l:
	if i<x:
		a+=1
print(min(a,len(l)-a))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

c1 = 0
for i in a:
    if i < x:
        c1 += 1

c2 = 0
for i in a:
    if i > x:
        c2 += 1

print(min(c1, c2))

Solution (Python):
N, M, X = map(int, input().split())
charge_list = list(map(int, input().split()))

count_up = 0
for i in range(M):
    if X < charge_list[i]:
        count_up += 1
    else:
        pass


count_down = 0
for i in range(M):
    if charge_list[i] < X:
        count_down += 1
    else:
        pass


print(min(count_up, count_down))

Solution (Python):
N,M,X = map(int, input().split())
A = [int(a) for a in input().split()]

p = 0
for i in range(1, X):
    if i in A:
        p += 1

q = 0
for i in range(X+1, N):
    if i in A:
        q += 1

print(min(p, q))

Solution (Python):
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]

u, l = 0, 0
for a in A :
    if a > X :
        u += 1
    elif a < X :
        l += 1
        
print(min(u, l))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
ans_ = 0
for i in range(m):
    if a[i] < x:
        ans += 1
    if a[i] > x:
        ans_ += 1
print(min(ans, ans_))

Solution (Python):
n,m,x = map(int,input().split())
A = [int(i) for i in input().split()]

go,back = 0,0

for a in A:
    if a < x:
        go += 1
    else:
        back += 1

print(min(go,back))

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
count_1=0
count_2=0
for i in range(M):
  if A[i]<X:
    count_1+=1
  else:
    count_2+=1
print(min(count_1,count_2))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
to_zero = sum([1 for a in A if a < X])
to_n = sum([1 for a in A if a > X])
if to_zero >= to_n:
    print(to_n)
else:
    print(to_zero)

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
R=0;L=0
for i in range(len(a)):
    if x<a[i]:R+=1
    else:L+=1
print(min(R,L))

Solution (Python):
n,m,x = map(int,input().split())
a = [int(i) for i in input().split()]
l = [1 for i in a if i<x]
r = [1 for i in a if x<i]
print(min(sum(l),sum(r)))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))

count_low = 0
count_high = 0

for i in range(M):
    if A[i] < X:
        count_low += 1
    else:
        count_high += 1

print(min(count_low, count_high))

Solution (Python):



N, M, X = map(int, input().split())
A = list(map(int, input().split()))


cost = [0] * (N + 1)
for i in range(M):
    cost[A[i]] = 1


print(min(sum(cost[:X]), sum(cost[X + 1:])))

Solution (Python):
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
L=0
R=0

for i in range(m):
    if a[i]>x:
        R+=1
    else:
        L+=1
print(min(L,R))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
root1=0
root2=0
for i in range(m):
    if x>a[i]:
        root1+=1
    else:
        root2+=1
print(min(root2,root1))