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, _, x = [int(x) for x in input().split()]
an = list(map(int,input().split()))
print(min(len([a for a in an if x < a]),len([a for a in an if a < x])))

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()))
for i in range(m):
  if a[i]>x:
    print(min(i, m-i))
    exit()

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

l = sum(1 if i < x else 0 for i in a)
r = m -l

print(min(l,r))

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

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

right_cost = len([ai for ai in a if ai > x])
left_cost =  len([ai for ai in a if ai < x])

print(min(right_cost, left_cost))

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

a = [0 for _ in range(N+1)]
for n in A:
    a[n] = 1

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

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

for i in range(X):
    if i in A:
        cost0+=1

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

print(min(cost0,costN))

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

left=0
right=0

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

Solution (Python):
n,m,x,*l=map(int,open(0).read().split())
s=sum(i in l for i in range(x))
print(min(s,m-s))

Solution (Python):
n,m,x,*l=map(int,open(0).read().split())
s=sum(1 for i in range(x) if i in l)
print(min(s,m-s))

Solution (Python):
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
cnt_1 = 0
cnt_2 = 0
for a in A:
    if a < x:
        cnt_1 += 1

cnt_2 = m - cnt_1
print(min(cnt_1,cnt_2))

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

    lower_cnt = 0
    upper_cnt = 0

    for a in A:
        if a < X:
            lower_cnt += 1
        elif a > X:
            upper_cnt += 1

    print(min(upper_cnt, lower_cnt))

main()

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

A.append(X)
idx = sorted(A).index(X)

print(min(idx, M-idx))

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

Solution (Python):
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
c = sum(1 if y < x else 0 for y in l)
print(c if c < len(l)-c else len(l)-c)

Solution (Python):

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

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

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

print(min(left, right))

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

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

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

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()))
cost=0
for i in range(x,n+1):
    if i in a:
        cost+=1
ans=cost
cost2=0
for i in range(x,0,-1):
    if i in a:
        cost2+=1
ans=min(ans,cost2)
print(ans)

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

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

A_left =[]
A_right = []

for i in A:
  if i < X:
    A_left.append(i)
  elif i > X:
    A_right.append(i)
print(min(len(A_left),len(A_right)))

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

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

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())
a = list(map(int,input().split()))
a.append(x)
a = sorted(a)
a = list(map(str,a))
b = a.index(str(x))
if b+1 <= len(a)/2:
  print(b)
else:
  print(m-b)

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

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

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

l = list(range(0, n+1))
former = l[:x]
latter = l[x+1:]

print(min(len(set(former) & set(a)), len(set(latter) & set(a))))

Solution (Python):

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

tg = [1 if i in a else 0 for i in range(n + 1)]
print(min(sum(tg[:x]), sum(tg[x:])))

Solution (Python):
from bisect import bisect_left, bisect_right

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

a = bisect_left(A, X)
b = bisect_right(A, X)
c = min([a, M-a, b, M-b])
print(c)

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

line = list(range(0,n+1))
routeA = set(line[:x])
routeB = set(line[x+1:])

print(min(len(a & routeA),len(a & routeB)))

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

l = len(list(filter(lambda a: a < X, A)))
r = len(list(filter(lambda a: a > X, A)))
print(min(l, r))

Solution (Python):
import bisect

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

left = bisect.bisect_left(A,X)
right = M - bisect.bisect_right(A,X)
print(min(left,right))

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

count1 = 0
for i in range(X,N):
    if i in set(gates):
        count1 += 1
    

count2 = 0
for i in range(0,X):
    if i in set(gates):
        count2+= 1
print(min(count1,count2))

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

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

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

ans_tmp1 = 0
ans_tmp2 = 0

for j in range(M):
    if A[j] > X and N > A[j]:
        ans_tmp1 += 1
    elif A[j] > N:
        break
    elif A[j] < X:
        ans_tmp2 += 1 

ans = min(ans_tmp1,ans_tmp2)

print(ans)

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

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

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

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

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

print(bisect(A, X)) if bisect(A, X) < M - bisect(A, X) else print(M - bisect(A, X))

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

Solution (Python):
n, m, x = map(int, input().split(' '))
fee_points = [x for x in map(int, input().split(' '))]
root = []
for i in range(0, n):
    if i in fee_points:
        root.append(1)
    else:
        root.append(0)

if sum(root[:x]) >= sum(root[x:]):
    print(sum(root[x:]))
else:
    print(sum(root[:x]))

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

Solution (Python):
'''
X:スタート地点
0, N:ゴール地点
m は料金所の個数。aを料金所とする

5 3 3
1 2 4
↓
0 1 2 3 4 5
  a a   a
0     X   N


Xより左にあるaの数と、右にあるaの数を比較して小さい方の数を出力

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




cells = [0]*(n+1)

for a in A:
    cells[a] = 1


l_count = sum(cells[:x])
r_count = sum(cells[x+1:])


print(min(l_count, r_count))

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [i for i in b if a[2] < i]
print(min(len(c),(len(b)-len(c))))

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

Solution (Python):
a, b, c = map(int, input().split())
d = list(map(int, input().split()))
e = 0
f = 0
for i in d:
    if i < c:
        e += 1
    elif i > c:
        f += 1
print(min(e, f))

Solution (Python):
Tmp = []
Tmp = input().rstrip().split(' ')

nN = int(Tmp[0])
nM = int(Tmp[1])
nX = int(Tmp[2])

nAns1 = 0
nAns2 = 0
Tmp = input().rstrip().split(' ')
for i in range(nM):
  nTmp = int(Tmp[i])
  if nTmp < nX:
    nAns1 += 1
  else:
    nAns2 += 1

if nAns1 < nAns2:
  print(nAns1)
else:
  print(nAns2)

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

left, right = 0, 0
for i in range(M):
    if A[i] < X:
        left += 1
    if A[i] > X:
        right += 1

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

Solution (Python):



N, M, X = map(int, input().split(' '))
AM = list(map(int, input().split(' ')))
cost = len(list(filter(lambda x: x < X, AM)))
print(min(cost, len(AM) - cost))

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

print(sumL) if sumL < sumR else print(sumR)

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

left_cost = 0
for toleft in range(x-1, 0, -1):
    if toleft in a:
        left_cost += 1

right_cost = 0
for toright in range(x, n+1):
    if toright in a:
        right_cost += 1

print(min(left_cost, right_cost))

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

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


modori_cost,iki_cost = 0,0 

for i in A:
  if i<X:
    modori_cost +=1
  else:
    iki_cost +=1
    

print(min(modori_cost,iki_cost))

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

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

array = [int(i) for i in input().split()]
cnta = 0
cntb = 0

for i in range(m):
  if array[i] < x:
    cnta +=1
  else:
    cntb +=1
    
print(min([cnta,cntb]))

Solution (Python):
n,m,x = list(map(int,input().split()))
a = list(map(int,input().split()))
left = sum(i<x for i in a)
right = sum(i>x for i in a)
print(min(left,right))

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

cost_right=0
cost_left=0

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

for j in range(0,x):
    if j in a:
        cost_left+=1

print(min(cost_right,cost_left))

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

li = [1 if i in li else 0 for i in range(1, n+1)]

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

Solution (Python):

n, m, x = map(int, input().split(' '))
A = [int(el) for el in input().split(' ')]

B = [1 if i in A else 0 for i in range(n)]
print(min(sum(B[:x+1]), sum(B[x:])))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
count_l = 0
count_r = 0
for i in A:
    if i <= X:
        count_l += 1
    elif i >= X:
        count_r += 1
print(min(count_l, count_r))

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

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 0 < a[i] < x:
        b += 1
    elif x < a[i] < n:
        c += 1
print(min(b,c))

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

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


ans = []

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

ans.append(tmp)

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

ans.append(tmp)

print(min(ans))

Solution (Python):
N, M, X = map(int, input().split())
A = [int(s) for s in input().split()]
l = [v < X for v in A].count(True)
print(min(l, M - l))

Solution (Python):
import math



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

ls = list(map(int,input().split(" ")))




left = [i for i in ls if i < x]
right = [i for i in ls if i > x]
print(min([len(left),len(right)]))

Solution (Python):

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

a = len(list(filter(lambda s: s > x, xs)))
b = len(list(filter(lambda s: s < x, xs)))

print(min(a, b))

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

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

goal1 = 0
goal2 = 0

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

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

print(min(goal1, goal2))

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

lCnt = 0
rCnt = 0
for i in sList:
    if X < i:
        lCnt += 1
    elif X > i:
        rCnt += 1

ans = min(lCnt, rCnt)
print(ans)

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

Solution (Python):
from copy import *
from sys import *
from math import *
import queue
from collections import defaultdict,Counter,deque

setrecursionlimit(1000000)


def main():
	n,m,x = map(int,input().split())
	a = list(map(int,input().split()))
	ans = 0
	sna = 0
	for i in a:
		if(i<x):
			ans+=1
		if(i>x):
			sna+=1
	print(min(ans,sna))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class Queue():
	
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)

class Stack():
	
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)

main()

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

Solution (Python):
n, m, x = map(int, input().split())
li = list(map(int, input().split()))
count_b = 0
count_s = 0

for i in li:
    if x<=i: count_b += 1 
    else: count_s += 1

if count_b < count_s: last_count = count_b
else: last_count = count_s 

print(last_count)

Solution (Python):
N, M, X = map(int, input().split())
tolls = list(map(int, input().split()))
gate_l = 0
for toll in tolls:
  if toll > X:
    break
  gate_l += 1
print(min(gate_l, M-gate_l))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    a, b, x = LI()
    if a <= x <= a + b:
        print("YES")
    else:
        print("NO")
    return


def B():
    n, m, x = LI()
    a = LI()
    print(min(bisect.bisect_left(a, x), m - bisect.bisect_right(a, x)))
    return


def C():
    n = II()
    x = LI()
    xb = x[::1]
    xb.sort()
    a = xb[n // 2 - 1]
    b = xb[n // 2]
    for i in range(n):
        if x[i] <= a:
            print(b)
        elif x[i] >= b:
            print(a)
        
    return


def D():
    return



if __name__ == '__main__':
    B()

Solution (Python):
a, b, c = map(int, input().split())
d = list(map(int, input().split()))
e = f = 0
for i in range(b):
    if 0 <= d[i] <= c:
        e += 1
    elif c <= d[i] <= a:
        f += 1
print(min(e, f))

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

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

c1 = c2 = 0

for a in alist:
  if a < x:
    c1 += 1
  else:
    c2 += 1

print(min(c1, c2))

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

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

Solution (Python):
n,m,x=map(int,input().split())
l=sorted(list(map(int,input().split()))+[x])
a=l.index(x)
print(min(len(l[:a]),len(l[a+1:])))

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

Solution (Python):
N, M, X = map(int, input().split())
a = {int(i) for i in input().split()}
l = set(range(0, X+1))
r = set(range(X, N+1))
print(min([len(a.intersection(l)) , len(a.intersection(r))]))

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

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

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

left = 0
for i in range(1, x):
    if i in As:
        left += 1

right = 0
for i in range(x+1, n):
    if i in As:
        right += 1

if left < right:
    print(left)
else:
    print(right)

Solution (Python):
a, b, c = map(int, input().split())
d = list(map(int, input().split()))
e = 0
f = 0
for i in range(b):
    if d[i] > c:
        e += 1
    else:
        f += 1
print(min(e, f))

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

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
B = [False]*(N+1)
for a in A: B[a] = True
print(min(B[:X].count(True),B[X:].count(True)))

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

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

ans = []
xx = X
num = 0
for i in range(1, 101):
    X += 1
    if A.count(X) == 1:
        num += 1

ans.append(num)
num = 0
for i in range(1, 101):
    xx -= 1
    if A.count(xx) == 1:
        num += 1

ans.append(num)
ans.sort()
print(ans[0])

Solution (Python):
import math
n,m,x = map(int,input().split(' '))
a = list(map(int,input().split(' ')))
pos = 0
ans1 = 0
ans2 = 0
for i in range(0,m):
    if a[i] > x:
        pos = i
        break
for i in range (0,pos):
    ans1+=1
for i in range (pos,m):
    ans2+=1

print(min(ans1,ans2))

Solution (Python):
n, m, x = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
l = [t for t in a if t < x]
r = [t for t in a if t > x]
print(min(len(l), len(r)))

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

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

l=[]

for i in range(n):
    if i in a:
        l.append(1)
    else:
        l.append(0)
l.append(0)
        
ans=min(sum(l[:x+1]),sum(l[x:]))
print(ans)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, M, X = map(int, input().split(" "))
	A = input().split(" ")
	A = [int(s) for s in A]
	
	p = bisect_left(A,X)
	
	aa = len(A)-p
	bb = p
	
	print(min(aa,bb))
	
if __name__ == "__main__":
	main()

Solution (Python):
def smaller(x, y):
	if x < y: return x
	return y

N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(0, M):
	if A[i] < X:
		cnt1 += 1
	else:
		cnt2 += 1
print(smaller(cnt1, cnt2))

Solution (Python):



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

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

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

Solution (Python):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = []
d = 0

for i in range(a[2]):
  if i in b:
    d+=1
else:
  c.append(d)
  d = 0

for i in range(a[0]-a[2]):
  if i+a[2] in b:
    d+=1
else:
  c.append(d)
  print(min(c))

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

Solution (Python):
from bisect import bisect_left

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

b = bisect_left(a, x)
print(min(b, m-b))

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

ans = 0
for a in A:
    if a < X:
        ans += 1

print(min(ans, M-ans))

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

lower = 0
upper = 0
for i in a:
    if i < x: lower += 1
    else: upper += 1
print(min(lower, upper))

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

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

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

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

L = len([a for a in A if a < X ])
R = len(A) - L

print(min(L, R))

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

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

cnt1=0
cnt2=0

for j in a:
    if x>j:
        cnt1+=1

    else:
        cnt2+=1
print(min(cnt1,cnt2))

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

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

print(min(v,len(a)-v))

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

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

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

    left = 0
    right = 0
    for i in al:
        if i < x:
            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()))

mass = [0] * N
for i in A:
    mass[i] = 1

right = sum(mass[X:])
left = sum(mass[:X])

print(min(right, left))

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N, M, X = (int(_) for _ in input().split())
    A = list(int(_) for _ in input().split())
    print(min(len([i for i in A if i < X]),len([i for i in A if i > X])))
    
if __name__ == '__main__':
    main()

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

count_l = 0
count_r = 0

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

print(min(count_l, count_r))

Solution (Python):
def resolve():
	n,m,x=map(int,input().split())
	a=list(map(int,input().split()))
	t=sum([1 for i in a if i<x])
	b=m-t
	print(min(t,b))
resolve()

Solution (Python):

from bisect import bisect_left


def main():
    n, m, x = list(map(int, input().rstrip().split()))
    lst = sorted(list(map(int, input().rstrip().split())))
    cur = bisect_left(lst, x)
    print(min(cur, m - cur))


if __name__ == "__main__":
    main()

Solution (Python):

n, m, x = list(map(int, input().rstrip().split()))
lst = sorted(list(map(int, input().rstrip().split())) + [x])
print(min(lst.index(x), m - lst.index(x)))

Solution (Python):



N, M, X = map(int, input().split())
toll = [int(i) for i in input().split()]
counter1 = 0
counter2 = 0

for i in range(X - 1, 0, -1):
    for j in range(len(toll)):
        if toll[j] == i:
            counter1 += 1

for k in range(X, N):
    for l in range(len(toll)):
        if toll[l] == k:
            counter2 += 1

if counter1 <= counter2:
    print(counter1)
else:
    print(counter2)

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

left = 0
right = 0
for ai in input().split():
    ai = int(ai)
    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()))

l = 0
r = 0

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

print(min(l,r))

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

N, M, X = nl()
As = nl()

before = 0
after = 0
for i in range(M):
    if As[i] < X:
        before += 1
    if X < As[i]:
        after += 1
print(min(before, after))

Solution (Python):

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

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

fr = 0
bh = 0

for i in A:

    if i < X:
        fr += 1

    else:
        bh += 1

print (min(fr,bh))

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

Solution (Python):
def abc():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    l = len([_ for _ in a if _ < x])
    r = len([_ for _ in a if _ > x])
    print(min(l, r))


abc()

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

mn = 0
cnt = 0
for a in A:
    if a < X:
        cnt += 1
for a in A:
    if a > X:
        mn += 1
print(min(mn, cnt))