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())
An = map(int,input().split())
cost = [0]*N
for A in An: cost[A] = 1
costL = sum(cost[:X])
costR = sum(cost[X:])
print(costL if costL <= costR else costR)

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

for i in input().split():
    if int(i) < x:
        low += 1
    else:
        high += 1

print(min(low, high))

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

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

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

ans = [0]*(n+1)

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

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

Solution (Python):
from bisect import bisect_left
N, M, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
index = bisect_left(A, X)
print(min(len(A[:index]), len(A[index:])))

Solution (Python):
from bisect import bisect_left
from bisect import bisect_right
N, M, X = map(int, input().split())
A = sorted(list(map(int, input().split())))
index = bisect_left(A, X)
s = len(A[:index])
g = len(A[index:])
print(min(s,g))

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

    line = [0 for _ in range(n+1)]
    for i in range(n+1):
        if i in As:
            line[i] += 1
    ans = min(sum(line[:x]), sum(line[x:]))
    print(ans)


if __name__ == "__main__":
    main()

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

left=0
right=0

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

print(min(left,right))

Solution (Python):
import bisect

def Toll_Gates(n , m , x , al):

    al.sort()
    ans = 0

    left = bisect.bisect_left(al, x)
    right = m - left

    ans = min(left , right)

    return ans

def main():
    n , m , x = map(int , input().split())
    al = list(map(int, input().split()))
    print(Toll_Gates(n , m , x , al))

if __name__ == '__main__':
    main()

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

A.sort()
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()))	

ans1=0
ans2=0

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

for j in range(x,-1,-1):
    if j in a:
        ans2+=1

print(min(ans1,ans2))

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

left=0
right=0

for i in A:
  if i>X:
    right+=1 
  else:
    left+=1
ans=min(left,right)
print(ans)

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

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
P = list(filter(lambda x: x < X, A))
Q = list(filter(lambda x: x > X, A))
print(min(len(P), len(Q)))

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

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
import bisect
id = bisect.bisect_left(A,X)
print(min(len(A[:id]),len(A[id:])))

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

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

Solution (Python):
N,M,X=map(int,input().split())
A=input().split()
B=[int(a) for a in A if int(a)>X]
C=[int(b) for b in A if int(b)<X]
b=len(B)
c=len(C)
print(min(b,c))

Solution (Python):
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n, m, x = map(int, input().split())
a = map(int, input().split())
left = 0
right = 0
for aa in a:
    if aa < x:
        left += 1
    else:
        right += 1
print(min(left, right))

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

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

c2=0
for i in range(x,0,-1):
    if i in a:
        c2+=1
print(min(c1,c2))

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

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

up_a = [i for i in a if i < x]
down_a = [i for i in a if  x < i]

print(min(len(up_a), len(down_a)))

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

import bisect
ind = bisect.bisect(A,X)
ans = min(ind,M-ind)
print(ans)

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()))
left=0
right=0
for i in a:
    if i>x:
        right+=1
    else:
        left+=1
ans=min(left,right)
print(ans)

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

print(min(c1,c2))

Solution (Python):

def main():
    import sys
    
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    
    from itertools import combinations, permutations
    
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    

    

    N, M, X =map(int, input().split())
    A = list(map(int, input().split()))
    res = 0
    for i in A:
        if i>=X:
            res += 1
    print(min(res, M-res))

if __name__ == '__main__':
    main()

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

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

A_left = [a for a in A if a < X]
A_right = [a for a in A if a > X]
print(min(map(len, (A_left, A_right))))

Solution (Python):


import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

N, M, X = na()
X -= 1
a = na()
b = [0] * N
for i in range(M):
    b[a[i] - 1] = 1

l, r = 0, 0
for i in range(N):
    if i < X:
        l += b[i]
    else:
        r += b[i]

print(min(l, r))

Solution (Python):
import bisect
N,M,X=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
index = bisect.bisect_right(A,X)
print(min(index,M-index))

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

print(min(ans))

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

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

right = 0
for r in range(x, n+1):
    if r in a:
        right += 1

left = 0
for l in range(x):
    if l in a:
        left += 1

print(min(right, left))

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

Solution (Python):
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M, X = list(map(int, sys.stdin.readline().split()))
    LINES = list(map(int, sys.stdin.readline().split()))
    s = [i for i in LINES if i > 0 and i < X]
    l = [i for i in LINES if i > X and i < N + 1]
    print(min(len(s), len(l)))


if __name__ == '__main__':
    main()

Solution (Python):








def resolve():
    n,m,x=map(int,input().split())
    A=list(map(int,input().split()))

    B=sorted(A+[x])
    print(min(B.index(x), m-B.index(x)))

resolve()

Solution (Python):
list = list(map(int,input().split()))
a = list[0]
p = list[1]
b = list[2]
c = 0
d = 0
tax = [int(i) for i in input().split()]
for i in range(p):
	t=tax[i]
	if t<b:
		c=c+1
	if t>b:
		d=d+1
if c>d:
	print(d)
else:
	print(c)

Solution (Python):
import numpy as np
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
A = np.array(A)
print(min(len(A[A<X]),len(A[A>=X])))

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

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):
from bisect import bisect_left

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

x = bisect_left(A,X)
print(min(x,M-x))

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

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

s = 0
b = 0

for y in a:
    if y > x:
        b += 1
    elif y < x:
        s += 1
print(min(b,s))

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=[int(i) for i in input().split()]
res=sum([0 if a<X else 1 for a in A])
print(min(res,M-res))

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

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

count = 0
for i in range(M):
  if A[i] < X:
    count += 1
    
print(min(count, M-count))

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

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

count1 = 0

count2 = 0

for i in range(x,n+1):
    if i in t:
        count1 += 1

for j in range(x, 0, -1):
    if j in t:
        count2 += 1
print(min(count1,count2))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
arr = [0] * (N + 1)
arr[0], arr[N] = 0, 0
for i in A:
    arr[i] = 1
l, r = sum(arr[:X]), sum(arr[X + 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 =list(map(int, input().split()))
A = list(map(int, input().split()))

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

print(min(sum(lower), sum(upper)))

Solution (Python):
n, m, x = map(int, input().split())
A = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(m):
  if A[i] < 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()))
a = [i for i in a if i < x]
print(min(len(a),m-len(a)))

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







print(min(len(a[:a.index(x)]),len(a[a.index(x)+1:])))

Solution (Python):


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

Solution (Python):


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

r0=0
rn=0

for i in r:
    if i<x:
        r0=r0+1
    else:
        rn=rn+1


if r0<rn:
    print(r0)
else:
    print(rn)

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

for i in a:
  s=sum(int(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()))

grid=[0]*(n+1)
for i in a:
    grid[i]+=1
print(min(sum(grid[:x]),sum(grid[x:])))

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

if __name__ == '__main__':
    main()

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

up=0
down=0
for i in range(M):
    if(a[i]<X):
        down+=1
    else:
        up+=1
print(min(down,up))

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

ans1 = 0
ans2 = 0

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

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

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


SQUARES = [0] * (n + 1)
for a in A:
    SQUARES[a] = 1


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

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

first_cnt,end_cnt=0,0

for i in range(M):
    if A[i]<X:
        first_cnt+=1
    else:
        end_cnt+=1
        
print(min(first_cnt,end_cnt))

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

Solution (Python):
import numpy as np
N, M, X=map(int, input().split())
A=list(map(int, input().split()))
x=np.searchsorted(A, X, side='left')
y=M-x
print(min(x, y))

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

A_before = [x for x in A if x<X]
A_after = [x for x in A if x>X]

print(min(len(A_before), len(A_after)))

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

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

print(min(a,b))

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

A_=[0]*(N+1)
for a in A:
    A_[a]=1
ans1=0
for a in A_[X+1:]:
    if a==1:
        ans1+=1
ans2=0
for a in reversed(A_[:X]):
    if a==1:
        ans2+=1

print(min(ans1,ans2))

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

cnt_1=0
cnt_2=0
for i in range(M):
    if A[i]<X:
        cnt_1+=1
    elif A[i]>X:
        cnt_2+=1
    else:
        pass
print(min(cnt_1,cnt_2))

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

Solution (Python):

n,m,x=map(int,input().split())
a=[int(p)<x for p in input().split()]
print(min(sum(a),len(a)-sum(a)))

Solution (Python):
from bisect import bisect

n,m,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
z=bisect(a,x)
print(min(z,m-z))

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

left = sum(a[:x])
right = sum(a[x+1:])

print(min([left, right]))

Solution (Python):
n, m, x = map(int, input().split())
count1 = 0
count2 = 0
for a in map(int, input().split()):
  if a < x:
    count1 += 1
  else:
    count2 += 1

print(min(count1, count2))

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

Solution (Python):
N, M, X = map(int, input().split())
A_li = list(map(int, input().split()))
front = 0
for i in range(X):
    if i in A_li:
        front += 1
back = 0
for j in range(X, N + 1):
    if j in A_li:
        back += 1
print(min(front, back))

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

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

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

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

left = len([v for v in alist if v < x])
right = len([v for v in alist if v > x])

print(min(left,right))

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

a=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(m,n+1):
    
    if i in a:
        ans1+=1
for i in range(0,m+1):
    if i in a:
        ans2+=1

print(min(ans1,ans2))

Solution (Python):



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

sum_L=0
sum_R=0
for a in A_list:
    if a < X:
        sum_L += 1
    elif a > X:
        sum_R += 1

print( min(sum_L,sum_R) )

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

len_left = len([i for i in A if i < X])
len_right = len([i for i in A if i > X])

ans = min(len_left,len_right)
print(ans)

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

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

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

Low=0
High=0

for i in range(M):
    if A[i]<X:
        Low+=1
    else:
        High+=1
print(min(Low,High))

Solution (Python):
def solve():
    N, M, X = [int(_) for _ in input().split()]
    masu = [0] * (N + 1)
    A = [int(_) for _ in input().split()]
    for a in A:
        masu[a] = 1
    return min(sum(masu[0:X]), sum(masu[X:]))
if __name__ == '__main__':
    print(solve())

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

grids = [0] * (N + 1)
for a in A:
    grids[a] = 1

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

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

a.append(x)
a.sort()

print(min(len(a[:a.index(x)]),len(a[a.index(x)+1:])))

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()))
Z=[0]*(N+1)
for i in range (M):
	for j in range (N):
		if L[i]==j:
			Z[j]=1
print(min(sum(Z[0:X+1]),sum(Z[X:N+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):
n, m, x = map(int, input().split())
a = [int(_) for _ in input().split()]
mass = [0] * (n+1)
for i in range(m):
    mass[a[i]] = 1
print(min(sum(mass[:x]), sum(mass[x+1:])))

Solution (Python):
import math
import itertools


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

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


print(min(total, total2))

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int,input().split()))
c1 = c2 = 0
for i in a:
    if i<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()))
import bisect
x_index = bisect.bisect_left(a, x)
print(min(len(a[:x_index]), len(a[x_index:])))

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

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

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

answer = min(to_0, to_N)
print(answer)

Solution (Python):
import bisect

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

ind = bisect.bisect_left(A, X)
print(min(ind, len(A) - ind))

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

lower = list(filter(lambda num: num < x, a_list))
larger = list(filter(lambda num: num > x, a_list))

print(min(len(lower),len(larger)))

Solution (Python):
n,m,x=map(int,input().split())
N=[int(i) for i in range(n+1)]
a=[int(i) for i in input().split()]
min1=0
min2=0
for i in N[x:]:
    for j in a:
        if i==j:
            min1+=1
for k in N[:x]:
    for l in a:
        if k==l:
            min2+=1
print(min(min1,min2))

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

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

bigger = []
smaller = []
for t in tolls:
    if t > X :
        bigger.append(t)
    elif t < X :
        smaller.append(t)
        
print(min(len(bigger), len(smaller)))

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

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

Solution (Python):
N, M, X = map(int,input().split())
A = set(map(int,input().split()))
l = set()
r = set()
for i in range(X):
    l.add(i)
for i in range(X, N):
    r.add(i)
l_tall = l & A
r_tall = r & A
if len(l_tall) <= len(r_tall):
    print(len(l_tall))
else:
    print(len(r_tall))

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

a,b = 0,0
for i in range(m):
    if l[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()))

r1 = 0
r2 = 0
for i in range(m):
    if a[i] == x: continue
    if a[i] < x : r1 += 1
    if a[i] > x : r2 += 1

print(min(r1, r2))

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

fee1 = 0
fee2 = 0

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

print(min(fee1, fee2))

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

A = list(map(int, input().split()))
t = 0
s = 0
for i in A:
    if i > c:
        t += 1
    if i < c:
        s += 1
print(min(s, t))

Solution (Python):

N,M,X = map(int,input().split())
A = list(map(int,input().split()))
judge = 1
k = 0
n1 = 0; n2 = 0

for i in range(N+1):
    if i == A[k] and judge == 1:
        n1 += 1
        if k != M-1:
            k += 1
    if i == A[k] and judge == 2:
        n2 += 1
        if k != M-1:
            k += 1
    if i == X:
        judge = 2
print(min(n1,n2))

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

Solution (Python):
def main():
    squares, tolls_number, start = map(int, input().split(" "))
    tolls = list(map(int, input().split(" ")))
    first_toll_index = 0
    for i in range(tolls_number):
        if tolls[i] > start:
            first_toll_index = i
            break
    print(min(len(tolls[:first_toll_index]), len(tolls[first_toll_index:])))


if __name__ == '__main__':
    main()

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

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

Solution (Python):



import bisect


def main():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    index = bisect.bisect_left(A, X)
    print(min(index, M - index))


if __name__ == "__main__":
    main()

Solution (Python):




def main():
    N, M, X = map(int, input().split())
    A = set(list(map(int, input().split())))
    X0 = set(list(range(0, X)))
    XN = set(list(range(X, N + 1)))
    print(min(len(X0 & set(A)), len(XN & set(A))))


if __name__ == "__main__":
    main()

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m,x=INTM()
    A=LIST()
    money=[0]*(n+1)
    for i in A:
        money[i]=1
    sum0 = sum(money[0:x+1])
    sumn = sum(money[x:n])
    print(min(sum0,sumn))
if __name__ == '__main__':
    do()

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

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

z = 0
k = 0

for i in a:
	if i < x:
		z += 1
	else:
		k += 1

print(min(z,k))

Solution (Python):
N,M,X = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
L, R = [], []
for i in a:
    if i < X:
        L.append(i)
    elif X < i:
        R.append(i)

if len(L) > len(R):
    print(len(R))
else:
    print(len(L))

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

print(min(cost,m-cost))

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

cnt1 = 0
cnt2 = 0

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

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

a.sort()

cl = 0
for i in range(len(a)):
    if a[i] <= x:
        cl += 1

cr = 0
for i in range(len(a)):
    if a[i] >= x:
        cr += 1
print(min(cl,cr))

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

Solution (Python):
import bisect
N,M,X=map(int,input().split())
L=list(map(int,input().split()))
num=bisect.bisect(L,X)
print(min(len(L[num:]),len(L[:num])))

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
  
print(min(sum(c[:x]), sum(c[x:])))

Solution (Python):

from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
INF = float('inf')

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

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


d1 = len([i for i in a if i < x])
d2 = len([i for i in a if i > x])

print(min(d1, d2))

Solution (Python):

import bisect
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
r = bisect.bisect_left(a,x)

print (min(len(a[:r]),len(a[r:])))

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

cx = 0
cy = 0
xy = 0
for i in a:
	if i >= x:
		cy += 1
	else:
		cx += 1
print (min(cx,cy))