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

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

print(min(len([x for x in A if x<X]), len([x for x in A if x>X])))

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

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

if ans1<ans2:
    print(ans1)
else:
    print(ans2)

Solution (Python):
n,m,x=map(int,input().split())
A=list(map(int,input().split()))
costright,costleft=0,0
for a in A:
  if a>x:
    costright+=1
  else:
    costleft+=1

print(min(costright,costleft))

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

A.append(X)
A.sort()

front = []
back = []

while len(A) > 0:
    pop = A.pop(0)
    if pop == X:
        while len(A) > 0:
            back.append(A.pop(0))
    else:
        front.append(pop)

print(min(len(front), len(back)))

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

print(min(len([x for x in grids if x < X]), len([x for x in grids if x > X])))

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

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

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

Solution (Python):
a,b,c=map(int,input().split())
b=list(map(int,input().split()))
i=c
total=0
total2=0
while True:
    i+=1
    if i in b:
        total+=1
    if i==a:
        break
i=c
while True:
    i-=1
    if i in b:
        total2+=1
    if i==0:
        break
print(min(total,total2))

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	
	n, m, x = tin()
	
	al = lin()
	pre = sum([1 for v in al if v < x])
	post = len(al)-pre
	return min(pre, post)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

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

Solution (Python):
def resolve():
    n, m, x = map(int, input().split())
    al = list(map(int, input().split()))
    al = sorted(al)
    ans = [0, 0]
    for i in al:
        if i < x:
            ans[0] += 1
        elif x < i:
            ans[1] += 1
    ans = sorted(ans)
    print(ans[0])
resolve()

Solution (Python):
def main():
    l = [int(_) for _ in input().split()]
    n = l[0]
    m = l[1]
    x = l[2]
    a = [int(_) for _ in input().split()]

    cost_to_zero = 0
    cost_to_m = 0

    for i in range(len(a)):
        if a[i] > x:
            cost_to_m += 1
        else:
            cost_to_zero += 1

    answer = min([cost_to_zero, cost_to_m])
    print(answer)


if __name__ == "__main__":
    main()

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

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

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

res = min(counter, m-counter)
print(res)

Solution (Python):
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, m, x = nm()
    A = nl()
    cost = [0] * 101
    for a in A:
        cost[a] = 1
    ans_1 = 0
    ans_2 = 0
    for i in range(x):
        ans_1 += cost[i]
    for i in range(x, n + 1):
        ans_2 += cost[i]
    print(min(ans_1, ans_2))


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

Solution (Python):
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
set0 = len(set(i for i in a if i < x))
setn = len(set(j for j in a if j > x))
print(min(set0,setn))

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
  else:
    break
print(min(cnt,M - cnt))

Solution (Python):
import sys
from collections import deque

import math

def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    l = r = 0
    for i in range(0,x+1):
        if i in a:
            l += 1
    sign = 1 if x<n else -1
    for i in range(x,n+sign,sign):
        if i in a:
            r += 1
    ans = min(l,r)
    print(ans)
    return

if __name__=='__main__':
    n,m,x = IL()
    a = set(IL())
    solve()

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

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

Solution (Python):
def main():
    _, m, x = map(int, input().split())
    a = {int(an) for an in input().split()}
    cnt_smaller = sum(an < x for an in a)
    print(min(cnt_smaller, m - cnt_smaller))


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    _, m, x = map(int, input().split())
    a = {int(an) for an in input().split()}
    cnt_smaller = sum(an < x for an in a)
    print(min(cnt_smaller, m - cnt_smaller))


if __name__ == '__main__':
    main()

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

box = [0]*(N+1)

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

cost_l = 0
for i in range(X+1):
    cost_l += box[i]
cost_r = 0
for i in range(X,N+1):
    cost_r += box[i]

print(min(cost_l,cost_r))

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

u = []
l = []

for i in range(m):
    if a[i] < x:
        l.append(a[i])
    elif a[i] > x:
        u.append(a[i])

print(min(len(u), len(l)))

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

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

cost = [0,0]

for i in a:
    if i < x:
        cost[0] += 1
    else:
        cost[1] += 1
print(min(cost))

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
    else:
        cnt_2+=1
print(min(cnt_1,cnt_2))

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

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

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

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

g1, g2 = 0, 0
for i in range(x):
  if i in lst:
    g1 += 1
    
for i in range(x+1, n):
  if i in lst:
    g2 += 1
    
print(min(g1, g2))

Solution (Python):
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n ,m ,x, a):
  ans = 0
  right = (x > a).sum()
  left = (x < a).sum()
  return min(right, left)
  
n, m, x = map(int, readline().split())
a = np.array(readline().split(), np.int64)
print(main(n, m, x, a))

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

low=sum(i>x for i in l)
hight=sum(i<x for i in l)

print(min(low,hight))

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

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

lst = [len(A[:A.index(X)]), len(A[A.index(X)+1:])]

print(min(lst))

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

left_gates = [i for i in gate if i < x]
right_gates = [j for j in gate if x < j]

ans = min(len(left_gates), len(right_gates))

print(ans)

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

for i in range(m):
	if a[i] > x:
		if i < m - i:
			print(i)
		else:
			print(m-i)
		exit()

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

cnt_lower=0
cnt_higher=0

for i in a:
    if i>x:
        cnt_lower+=1
    elif i<x:
        cnt_higher+=1
    else:
        continue
        
ans = min(cnt_lower, cnt_higher)
print(ans)

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

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

s=len(a)

ans=0

for i in a:
  if i<x:
    ans+=1
    
print(min(ans,s-ans))

Solution (Python):


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

index = bisect.bisect_left(a, x)

ans = min(len(a[:index]), len(a[index:]))

print(ans)

Solution (Python):
import sys
from bisect import bisect_left as bl
input = sys.stdin.readline
N, M, X = map(int, input().split())
a = list(map(int, input().split()))
x = bl(a, X)
print(min(x, M - x))

Solution (Python):
from sys import stdin

n,m,x = [int(x) for x in stdin.readline().split()]
a_lst = [int(x) for x in stdin.readline().split()]

cost_left = sum([1 for i in range(0, x) if i in a_lst])
cost_right = sum([1 for i in range(x+1, n+1) if i in a_lst])

print(min(cost_left, cost_right))

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

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

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

i = 0
j = 0
while 1:
  if j in A and j < X:
    i = j
    j += 1
  elif j < X:
    j += 1
  else:
    break
    
smaller = 0
bigger = 0
if i == 0:
  print(0)
else:
  for k in range(A.index(i) + 1):
    smaller += 1
  
  for k in range(A.index(i) + 1, M, 1):
    bigger += 1

  print(min(smaller, bigger))

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

former = []
latter = []

for i in range(len(a_list)):
    if a_list[i] < x:
        former.append(a_list[i])
    else:
        latter.append(a_list[i])
print(min(len(former), len(latter)))

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

for i in a:
    if i > x:
        cnt1 += 1
    else:
        cnt2 += 1
        
print(min(cnt1, cnt2))

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

s=[0 for i in range(N)]
for i in range(M):
    s[A[i]]=1
    
for i in range(X):
    cnt_0=sum(s[:X])

for j in range(N-X):
    cnt_N=sum(s[X:])

print(min(cnt_0,cnt_N))

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

P = [0] * (N + 1)

for A in A:
    P[A] = 1

a = P[:X].count(1)
b = P[X - N:].count(1)



print(min(a, b))

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

ans = 0
for i in A:
	ans += X>i
	
ans_N = 0
for i in A:
	ans_N += X<i

print(min(ans,ans_N))

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

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

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

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

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

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
    else:
        break

print(min(ans,m-ans))

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

u = [i for i in L if i < X]
o = [i for i in L if i > X]
print(min(len(u), len(o)))

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

Ncnt = [i for i in A if i>X]
Zcnt = [i for i in A if i<X]
print(min(len(Ncnt), len(Zcnt)))

Solution (Python):
N,M,X = map(int,input().split())
l = list(map(int,input().split()))
num = X
ans1 = 0
ans2 = 0
while num <= N:
  if num in l:
    ans1 += 1
  num += 1
num = X
while num >= 0:
  if num in l:
    ans2 += 1
  num -= 1
print(min(ans1,ans2))

Solution (Python):
from bisect import bisect_left

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

i = bisect_left(A, X)
print(min(i, len(A) - i))

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

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

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

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

G_0 = 0
G_N = 0
for a in A:
    if a < X:
        G_0 += 1
    else:
        G_N += 1

print(min(G_0,G_N))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
lst=[0]*(n+1)

for i in a:
    lst[i]+=1

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

Solution (Python):
def toll(n, x, tolls):
	rcount = 0
	lcount = 0
	for i in range(x, n):
		if i in tolls:
			rcount += 1
	for i in range(1, x):
		if i in tolls:
			lcount += 1
	return min(rcount, lcount)
n, m, x = map(int, input().split())
tolls = list(map(int, input().split()))
print(toll(n, x, tolls))

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

go_left = 0
go_right = 0

for i in range(x, n+1):
    if a.count(i) == 1:
        go_right += 1

for j in range(0, x):
    if a.count(j) == 1:
        go_left += 1

print(min(go_left, go_right))

Solution (Python):
n, m, x = map(int,input().split())
a = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
for i in range(x):
    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=map(int,input().split())
n=[*range(1,n+1)];maxN=max(n)
a=list(map(int,input().split()))
count1,count2=0,0
for i in range(x,maxN+1):
  if i in a:
    count1+=1
for i in range(x,0,-1):
  if i in a:
    count2+=1
print(min(count1,count2))

Solution (Python):
def main():
    N, M, X = map(int, input().split())
    a = list(map(int, input().split()))
    if X < a[0] or a[M-1] < X:
        print(0)
        return
    else:
        for i in range(M):
            if X < a[i]:
                t = i
                break
        b = M - t
        f = t
        print(min(f, b))
main()

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

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

count1 = count2 = 0

for i in p:
    if 0 < i <= x:
        count1 += 1
    elif x <= i <= n:
        count2 += 1
    
print(min(count1,count2))

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

ans_N = M - bisect.bisect_left(A,X)
ans_0 = bisect.bisect_left(A,X)
print(min(ans_N,ans_0))

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

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

Solution (Python):









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

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


print(min(ans1, ans2))

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

l = 0; r = 0

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

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

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

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

Solution (Python):
N,gate,start=list(map(int,input().split()))
W=list(map(int,input().split()))
le=0
ri=0
for i in range(start,N+1):
  if i in W:
    ri+=1
for k in range(start+1):
  if k in W:
    le+=1
print(min(ri,le))

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

G = sum([a < X for a in A])

print(min(G, M-G))

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, M, X, *A = map(int, read().split())
    
    v = 0
    for a in A:
        if a < X:
            v += 1
        else:
            break
    
    print(min(v, M - v))
    return


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import math


def resolve():
    import sys
    input = sys.stdin.readline
    
    
    nmx = [int(x) for x in input().rstrip().split(" ")]
    x = nmx[2]
    a_list = [int(x) for x in input().rstrip().split(" ")]


    left_cost = sum(1 for a in a_list if a < x)
    right_cost = len(a_list) - left_cost

    ans = left_cost if left_cost < right_cost else right_cost

    print(ans)




if __name__ == "__main__":
    resolve()

Solution (Python):
N_masu, M_exp, X_pos = map(int, input().split())
exp_pos = list(map(int, input().split()))

cos_1 = 0
cos_2 = 0

for i in range(M_exp):
    pos = exp_pos[i]
    
    if (pos <= X_pos):
        cos_1 += 1
    else:
        cos_2 += 1

print(min(cos_1,cos_2))

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

c1 = 0
c2 = 0
for a in aa:
    if a < x:
        c1 += 1
    if a > x:
        c2 += 1
print(min(c1, c2))

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

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

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

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m, x = inintm()
A = inintl()

h = 0
l = 0

for a in A:
    if a < x:
        l += 1
    else:
        h += 1

print(min(h, l))

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

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

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

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

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

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

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

import bisect

t = bisect.bisect_left(A, X)
ans = min(t, M - t)
print(ans)

Solution (Python):
import numpy as np

N, M, X = map(int, input().split())
A = np.array(list(map(int, input().split())))
if len(A[A < X]) > len(A[A > X]):
    print(len(A[A > X]))
else:
    print(len(A[A < X]))

Solution (Python):

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

dammy = [0]*(N+1)

for i in A:
    dammy[i]=1
    if i==X:
        dammy[i]=0



left = sum(dammy[0:X+1])
right = sum(dammy[X+1:N+1])


print(min(left,right))

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

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

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

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

print(min(len(list(filter(lambda x:x<X,A))), len(list(filter(lambda x:x>X,A)))))

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

distance_to_head = len([i for i in A if i < X])
distance_to_tail = len([i for i in A if X < i])
print(min(distance_to_head, distance_to_tail))

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

distance_to_head = len(list(filter(lambda x: X < x, A)))
distance_to_tail = len(list(filter(lambda x: x < X, A)))
print(min(distance_to_head, distance_to_tail))

Solution (Python):





import math
import fractions
import sys
import bisect
import heapq  
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr



def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod



def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,m,x = lr()
a = [0 for i in range(n+1)]
l = lr()
for num in l:
    a[num] = 1
a1 = [0]
for num in a:
    a1.append(num+a1[-1])
print(min(a1[x+1]-a1[0], a1[n+1]-a1[x+1]))

Solution (Python):
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
a = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        a += 1
        nu += 1
    if nu == len(li):
        break
b = len(li) - a
if a > b:
    print(b)
else:
    print(a)

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

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

for i in a_list:
    r_list[i] = 1

zahyo = x
a = 0

while zahyo != 0:
    zahyo -= 1
    if r_list[zahyo] == 1:
        a += 1
zahyo = x
b = 0

while zahyo != n:
    zahyo += 1
    if r_list[zahyo] == 1:
        b += 1

print(min(a,b))

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

cost = [0 for _ in range(n + 1)]
for ai in a:
    cost[ai] = 1
print(min(sum(cost[:x]), sum(cost[x:])))

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

res1 = 0
res2 = 0

for a in A:
    if a < X:
        res1 += 1
    else:
        res2 += 1

print(min(res1, res2))

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

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

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

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

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