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())
al = list(map(int, input().split()))

right_route = 0
for i in range(x, n+1):
    if i in al:
        right_route += 1

left_route = 0
for i in reversed(range(1, x+1)):
    if i in al:
        left_route += 1

print(min(right_route, left_route))

Solution (Python):
from bisect import bisect

n, m, x = map(int, input().split())
aaa = list(map(int, input().split()))
l = bisect(aaa, x)
r = m - l
print(min(l, r))

Solution (Python):
n,m,x = map(int,input().split())
a = map(int,input().split())
r = 0
l = 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())
a=[int(x) for x in input().split()]

mas=[0 for i in range(n+1)]

for aa in a:
    mas[aa-1]=1

l1=mas[0:x]
l2=mas[x:n]

print(min(sum(l1),sum(l2)))

Solution (Python):
f = lambda:map(int,input().split())
_,m,x = f()
l = list(f())
c = len([i for i in l if i<x])
print(min(c, m-c))

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

former = sum(x > i for i in a)
later = sum(x < i for i in a)

print(min(former, later))

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

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

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

ans = min(l,r)
print(ans)

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

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

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

for i in a:
    if(i >= x):
        cnt += 1
    else:
        cnt1 += 1

print(min(cnt, cnt1))

Solution (Python):


import bisect
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
for i in A:
    if i<=X:
        cnt+=1
    else:
        break

if (M/2)>=cnt:
    print(cnt)
else:
    print(M-cnt)

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

ans1 = 0
ans2 = 0
for a in A:
    if a < x:
        ans1 += 1
    else:
        ans2 += 1
print(min(ans1, ans2))

Solution (Python):

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

f=[0 for i in range(N+1)]

for i in range(M):
    f[A[i]]=1

print(min(sum(f[:X]),sum(f[X:])))

Solution (Python):

N, M, X = map(int, input().split())
A = list(map(int, input().split()))
route = [0 for i in range(N+1)]
for i in range(M):
    route[A[i]] = 1
print(min(sum(route[:X]), sum(route[X:])))

Solution (Python):
a,b,c = map(int, input().split())
l = list(map(int, input().split()))
cost = [0] * (a+1)
for i in range(a):
  if i in l:
    cost[i] = 1

sum1 = sum(cost[0:c:])
sum2 = sum(cost[c::])
print(min(sum1,sum2))

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

for j in range(x+1,n+1,1):
	if (j in a):
		r_cou+=1

print(min(r_cou,l_cou))

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

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

for i in range(x, n):
    if i in a:
        ans1 += 1
for i in range(1, x):
    if i in a:
        ans2 += 1
print(min(ans1, ans2))

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

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
uppercost=0
lowercost=0
for i in range(M):
    if A[i]>X:
        uppercost=uppercost+1
    else:
        lowercost=lowercost+1

print(min(uppercost,lowercost))

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

a1 = 0
a2 = 0
for b in arr:
    if b <x:
        a1 += 1
    elif b > x:
        a2 +=1
print min(a1, a2)

Solution (Python):
import bisect

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

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

print(min(a, M-a))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
l = [0]*n
for i in a:
    l[i] = 1
if sum(l[:x]) > sum(l[x:]):
    print(sum(l[x:]))
else:
    print(sum(l[:x]))

Solution (Python):
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
count_min = 0
count_max = 0
for i in a:
  if x > i:
    count_min += 1
  else:
    count_max += 1
if count_min >= count_max:
  print(str(count_max))
else:
  print(str(count_min))

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

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 sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
less_x = 0
for i in range(m):
    if a[i] < x: less_x += 1
print(min(less_x,m - less_x))

Solution (Python):
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c = sum(int(b)<x for b in a )
d = len(a) - c
print(min(c,d))

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 = [0] * (n + 1)
l_add = list(map(int, input().split()))
for i in range(m):
    l[l_add[i]] = 1
print(min(sum(l[:x]), sum(l[x:])))

Solution (Python):
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys




read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M, *A = map(int, read().split())
X = A[0]
A.append(N)
A.sort()
num = A.index(X)

print(min(len(A[:num]), len(A[num+1:-1])))

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a.sort()
if a.index(x) <= m//2:
    print(a.index(x))
else:
    print(m-a.index(x))

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

s1 = 0
s2 = 0
for a in arr:
    if a < x:
        s1 += 1
    elif a > x:
        s2 += 1

print min(s1, s2)

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

ans = 100000000000
now = 0
for i in range(0, x):
    now += v[i]
ans = min(ans, now)

now = 0
for i in range(x, n):
    now += v[i]
ans = min(ans, now)

print(ans)

Solution (Python):


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

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

to_0 = set(range(0, X))
to_N = set(range(X, N+1))

print(min(len(a & to_0), len(a & to_N)))

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

for i in input().split():
    k = int(i)
    a[k] = 1

left = right = 0
for i in range(n+1):
    if i < x:
        left += a[i]
    else:
        right += a[i]

ans = min(left, right)
print(ans)

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

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

cost1 = 0
cost2 = 0

for i in range(len(List)):
    if List[i] < x:
        cost1+=1
    else: cost2+=1

print(min(cost1,cost2))

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

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

to_0 = sum([1 for a in A if a < X])
to_N = sum([1 for a in A if a > X])
ans = min(to_0, to_N)

print(ans)

Solution (Python):

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

ans1 = 0
tmp1 = []
for i in range(x):
    tmp1.append(i)
for j in range(m):
    if a[j] in tmp1:
        ans1 += 1

ans2 = 0
tmp2 = []
for i in range(x, n + 1):
    tmp2.append(i)
for j in range(m):
    if a[j] in tmp2:
        ans2 += 1
print(min(ans1,ans2))

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

mass =[0]*n

for i in lst1:
    mass[i-1] = 1

x -= 1
print(min(sum(mass[:x]),sum(mass[x:])))

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

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

def main():
	
	
	N,M,X = map(int,input().split())
	vA = set(map(int,input().split()))
	
	
	L1 = sum(i in vA for i in range(0,X))
	L2 = sum(i in vA for i in range(X,N))
	res = min(L1,L2)
	print(res)
	
main()

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

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

pList = []
s = aList.pop(0)
for i in range(n+1):
  if i == s:
    pList.append(1)
    if not(len(aList) == 0):
      s = aList.pop(0)
  else:
    pList.append(0)

resultS = 0
resultG = 0
for i in range(0,x+1):
  resultS += pList[i]
for i in range(x,n+1):
  resultG += pList[i]

if resultS<= resultG:
  print(resultS)
else:
  print(resultG)

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
C = sum(a < X for a in A)
print(min(C,len(A)-C))

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

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

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

back=999
foward=999

for i in range(M):
    if A[i]==X:
        back=i
        foward=M-i+1
        break
    if A[i]>X:
        back=i
        foward=M-i
        break
    
print(min(back,foward))

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

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

tolls = [1 if i in As else 0 for i in range(N)]

print(min(sum(tolls[X-1:0:-1]), sum(tolls[X+1:])))

Solution (Python):
N, M, X=map(int, input().split())
sum=sum(int(i)<X for i in input().split())
print(min(sum, M-sum))

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

c1 = 0
for i in reversed(range(1, x)):
   if (i in a):
      c1 += 1

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

if (c1 <= c2):
   print(c1)
else:
   print(c2)

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

grid = [0]*(N+1)
for a in A:
  grid[a] += 1
  
left = sum(grid[:X+1])
right = sum(grid[X:])
print(min(left, right))

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

to_left =[1 for i in range(X-1, 0, -1) if i in A] 

print(min(sum(to_left), M-sum(to_left)))

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

to_left =[1 for i in range(X-1, 0, -1) if i in A] 
to_right =[1 for i in range(X+1, N, 1) if i in A]
print(min(sum(to_left), sum(to_right)))

Solution (Python):
import sys
input = sys.stdin.readline
N,M,X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
r = 0
l = 0
for i in range(M) :
    if X - A[i] > 0 :
        l+=1
    else :
        r+=1
print(min(r,l))

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

l = list(map(int,input().split()))
ll = [0 for _ in range(n+1)]

for i in l:
    ll[i] = 1

mae = ll[:x + 1]
ato = ll[x + 1:]

print(min(sum(mae),sum(ato)))

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

l = len([aa for aa in a if aa < x])

print(min(l, m - l))

Solution (Python):
import bisect
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
left=bisect.bisect(a,x)
right=len(a)-left
print(min(left,right))

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

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

cost_l = 0

for i in range(m):
    if a[i] <= x:
        cost_l += 1
    else:
        break
cost_r = m - cost_l
print(min(cost_l, cost_r))

Solution (Python):
import sys
input = sys.stdin.readline
n,m,x=map(int,input().split())
A=list(map(int,input().split()))
from bisect import bisect_left as bl
a=bl(A,x)

print(min(a,m-a))

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

l = list(range(n))[:x]
r = list(range(n))[x+1:]
lcost = 0
rcost = 0

for i in range(len(l)):
    if l[i] in a:
        lcost += 1

for i in range(len(r)):
    if r[i] in a:
        rcost += 1

print(min(lcost, rcost))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
i = X
j = X
while i <= N:
  if i in A:
    cnt1 += 1
  i += 1
while j >= 0:
  if j in A:
    cnt2 += 1
  j -= 1
print(min(cnt1, cnt2))

Solution (Python):
n, m, x = map(int, input().split())
li = list(map(int, input().split()))
left_c = 0
right_c = 0
for i in range(x, 0, -1):
  if i in li:
    left_c += 1
  
for i in range(x, n+1):
  if i in li:
    right_c += 1
    
print(min(left_c, right_c))

Solution (Python):
import sys
input = sys.stdin.readline
N, M, X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
import numpy as np
A = np.array(A)
right = np.count_nonzero(A > X)
left = np.count_nonzero(A < X)
print(min(left, right))

Solution (Python):

"""
Created on Thu Jan  2 17:08:37 2020

@author: student2
"""
potrn = 0
potrnn = 0
n,m,x = map(int,input().split())
v = [0 for i in range(n)]
for y in map(int,input().split()):
    v[y-1]=1
for z in range(x):
    if v[z] == 1:
        potrn +=1
for g in range(x,n):
    if v[g] == 1:
        potrnn +=1
print (min(potrn,potrnn))

Solution (Python):
n,m,x=map(int,input().split(" "))
li=list(input().split(" "))
for g in range(m):
    li[g]=int(li[g])
br=0
br2=0
k=x
pp=x
for i in range(pp):
    x-=1
    for z in range(m):
        if x==li[z]:
            br+=1
for i in range(n-pp):
    k+=1
    for z in range(m):
        if k==li[z]:
            br2+=1
print(min(br,br2))

Solution (Python):
from bisect import bisect_left
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
idx = bisect_left(A, x)
print(min(len(A[:idx]), len(A[idx:])))

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

Solution (Python):

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

dis_l = 0
dis_r = 0

l = [0]*(n+1)
for i in range(m):
    l[a[i]] += 1

e = l[:x]
f = l[x+1:n+1]

if e.count(1) < f.count(1):
    print(e.count(1))
else:
    print(f.count(1))

Solution (Python):
"""
Created on Wed Jan  1 14:22:42 2020
"""

n, m, x = map(int, input().split())
has = [0] * (n + 1)
v = list(map(int, input().split()))
for i in range(m):
    has[v[i]] = 1
res1 = 0
res2 = 0
for i in range(n + 1):
    if has[i] == 1:
        if i <= x:
            res1 += 1
        else:
            res2 += 1
print(min(res1, res2))

Solution (Python):
N, M, X = map(int, input().split())
A = sorted(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, k = (map(int, input().split()))
a = list(map(int, input().split()))
f = lambda x:1 if x<k else 0
f2 = lambda x:1 if x>k else 0
y = list(map(f, a))
z = list(map(f2, a))
print(min(sum(y), sum(z)))

Solution (Python):
N,M,X=map(int,input().split())
a=[int(i) for i in input().split()]
l,r=[],[]
for i in a:
  if i<X:
    l.append(i)
  else:
    r.append(i)
print(min(len(l),len(r)))

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

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

to0 = list(range(n+1))[:x]
cost1 = len(set(to0) & set(a))

ton = list(range(n+1))[x:]
cost2 = len(set(ton) & set(a))

ans = min(cost1, cost2)
print(ans)

Solution (Python):
def get(S):
    return list(map(S, input().split()))

N, M, X = get(int)
A = get(int)

cost = [0 for _ in range(0, N + 2)]

for i in A:
    cost[i] = 1

L = sum(cost[0 : X + 1])
R = sum(cost[X : N + 1])
print(min(L, R))

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

for i in range(m):
    if a[i]<x:
        left += 1
    else:
        right += 1

print(min(left, right))

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

if a[0] < x < a[m-1]:
    for i in range(1,m):
        if x < a[i]:
            ans = min(i,m-i)
            break
else:
    ans = 0

print(ans)

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

if a[0] < x < a[m-1]:
    for i in range(1,m):
        if x < a[i]:
            ans = min(len(a[:i]),len(a[i:]))
            break
else:
    ans = 0

print(ans)

Solution (Python):
N,M,X =(map(int,input().split()))
A =list(map(int,input().split()))
print(min(sum(a>X for a in A),sum(a<X for a in A)))

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())
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()))
l = [0]*(n+1)
for i in a:
    l[i-1]=1
print(min(sum(l[0:x-1]),sum(l[x-1:n])))

Solution (Python):
li = list(map(int,input().split()))
A=list(map(int,input().split()))
a=0
b=0
for i in range(len(A)):
    if A[i]<li[2]:
        a+=1
    else:
        b+=1
print(min(a,b))

Solution (Python):
import sys
from bisect import bisect_left as bi_l

n, m, x, *a = map(int, sys.stdin.read().split())

def main():
    left = bi_l(a, x)
    right = m - left
    return min(left, right)

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

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

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 < X:
                left += 1
        else:
                right += 1
print(min(left, right))

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

Solution (Python):


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

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

left = [i for i in a if i < x]
right = [i for i in a if i >= x]


print(min(len(left), len(right)))

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

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

COST = 0
for i in range(X):
  if X - i - 1 in A:
    COST += 1

print(min(cost, COST))

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

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

costa=0
costb=0
for i in a:
    if i<x:
        costa+=1
    elif i>x:
        costb+=1

print(min(costa,costb))

"""


5 3 3
1 2 4

1


7 3 2
4 5 6

0

10 7 5
1 2 3 4 6 8 9

3
"""

Solution (Python):
a,b,c = (map(int, input().split())) 
n = list(map(int, input().split())) 
chargeA=0
chargeB=0

for i in range(b):
  if c<n[i]<a:
    chargeA+=1
  else:
    chargeB+=1
print(min(chargeA,chargeB))

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

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 = map(int, input().split())
A = list(map(int, input().split()))

import bisect

l = bisect.bisect_left(A, x)
ans = min(l, m-l)
print(ans)

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

import bisect

l = bisect.bisect_left(a, x)
print(min(l, m-l))

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

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

for a in A:
	cost[a-1] = 1

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

Solution (Python):
import math

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

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

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

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

Solution (Python):
import sys
n,m,x = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))

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

print(min(count, m-count))

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

print(min(len([i for i in range(1, X) if i in A]), len([i for i in range(X + 1, N) if i in A])))

Solution (Python):

cnt_min=0
cnt_max=0
ans=0
n,m,x=map(int,input().split())
lst=list(map(int,input().split()))

for i in lst:
    if i < x:
        cnt_min+=1
    else:
        cnt_max+=1
print(cnt_max if cnt_min>cnt_max else cnt_min)

Solution (Python):
NMX = list(map(int, input().split()))
A = list(map(int, input().split()))
masu = {}
for i in range(NMX[0]+1):
	if(i in A):
		masu[i] = 1
	else:
		masu[i] = 0
right=0
for i in reversed(range(0,NMX[2]+1)):
	right+=masu[i]
left=0
for i in reversed(range(NMX[2]+1,NMX[0]+1)):
	left+=masu[i]
if(right>left):
	print(left)
else:
	print(right)

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

left = 0
right = 0

for a in A:
    if a < x:
        left += 1
    elif x < a:
        right += 1

print(min(right, left))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
count = 0
B = []
if N == X:
  print(0)
else:
  for x in range(X,N+1):
    if x in A:
      count += 1
  B.append(count)
  count = 0
  for x in range(X,0,-1):
    if x in A:
      count += 1
  B.append(count)
  print(min(B))

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

left = 0
right = 0
for i in input_list:
    if i < x: left += 1
    elif i > x: right += 1

print(min(left, right))

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

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

ans2 = 0
for i in reversed(range(X)):
  if i in A:
    ans2 += 1

print(min(ans1,ans2))

Solution (Python):
"""B - Toll Gates
https://atcoder.jp/contests/abc094/tasks/abc094_b
N M X
A_1 A_2 ... A_M

>>> main(5, 3, 3, [1, 2, 4])
1
>>> main(7, 3, 2, [4, 5, 6])
0
>>> main(10, 7, 5, [1, 2, 3, 4, 6, 8, 9])
3
"""


def main(n, m, x, a):
    line = [0 for _ in range(n)]

    for a in a:
        line[a - 1] = 1

    to_left = sum(line[x - 1:])
    to_right = sum(line[x - 1::-1])

    print(min(to_left, to_right))


if __name__ == '__main__':
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))

    main(n, m, x, a)

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

c=0
for i in range(x):
  if i==a[c]:
    c+=1
print(c if 2*c<m else m-c)

Solution (Python):
n,m,x=map(int,input().split())
a=[int(i) for i in input().split()]
j=0
for i in range(m):
    if a[i]>x:
        j=i
        break
print(min(len(a)-j,j))

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

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

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

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

cost1 = 0
for i in range(x, n+1):
    if i in a:
        cost1 += 1
    
cost2 = 0
for i in range(x):
    i = x-i
    if i in a:
        cost2 += 1
print(min(cost1, cost2))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
C = [0 for _ in range(N)]
for a in A:
    C[a] = 1

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

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

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

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] = 1
print(min(sum(cost[0:x - 1]), sum(cost[x:n - 1])))

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

Solution (Python):
N,M,X=map(int,input().split())
A=[int(i) for i in input().split()]
a=0
b=0
for i in range(M):
  if A[i]<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()))

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

Solution (Python):
n,m,x=map(int,input().split())
l=list(map(int,input().split()))
a=[]
b=[]
for i in range(m):
    if l[i]<x:
        a.append(l[i])
    else :
        b.append(l[i])
print(min(len(a),len(b)))

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

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

a2 = sum([1 for i in lst if i > x])
a1 = m - a2
print(min(a1, a2))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
for i,x in enumerate(A):
  if x > X:
    t = i
    break

print(min(t,M-t))

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

Solution (Python):
N,M,X=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls_0=[e for e in ls if e<X]
ls_N=[e for e in ls if e>X]
print(min([len(ls_0),len(ls_N)]))

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

count0 = 0
countn = 0
for i in range(x):
    if i in a:
        count0 += 1
for i in range(x,n):
    if i in a:
        countn += 1
ans = min(count0,countn)
print(ans)

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

cst_0 = 0
cst_m = 0

for i in range(m):
    if ls_a[i] < x:
        cst_0 += 1
    elif ls_a[i] > x:
        cst_m += 1

print(min(cst_0, cst_m))

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

Solution (Python):

N,M,X = map(int, input().split())
A_list = [int(e) for e in input().split()]










cost_to_0 = 0
cost_to_M = 0

for i in range(M):
    if A_list[i] < X:
        cost_to_0 += 1
    else:
        cost_to_M += 1
          
print(min(cost_to_M,cost_to_0))

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

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

l = [0]*n

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

f = sum(l[0:x])
g = sum(l[x:n])

print( f if f<g else g)

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

count_l = 0
count_r = 0

for a in A:
    if a > x:
        count_r += 1
    else:
        count_l += 1

ans = min(count_l, count_r)
print(ans)

Solution (Python):
NMX=list(map(int,input().split()))
A=list(map(int,input().split()))
N=NMX[0]
M=NMX[1]
X=NMX[2]

left = sum(x<X for x in A)
right = sum(x>X for x in A)
print(min(left,right))