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()))
l = 0
r = 0
for i in a:
    if i < x:
        l += 1
    elif i > x:
        r += 1
print(min(l, r))

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

for i in reversed(range(0, X+1)):
  if i-1 in A:
    cost_a += 1
  
for j in range(X, N+1):
  if j in A:
    cost_b += 1

print(min(cost_a, cost_b))

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

    
    left = 0
    right = 0

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

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

    print(min([left, right]))

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

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

print(min(y,z))

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

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

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

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

Solution (Python):

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

if x < a[0] or x > a[m - 1]:
    print(0)
else:
    print(min(len([p for p in a if p < x]), len([q for q in a if q > x])))

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

import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
week=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod_,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod_-2,mod_)*pow(fac[r],mod_-2,mod_))%mod_
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)


import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)

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


main()

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

roots = [0] * (N+1)

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

ans_s = 0
for i in range(0,X):
    ans_s += roots[i]
ans_g = 0
for i in range(X+1,N+1):
    ans_g += roots[i]
print(min(ans_s,ans_g))

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

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

Solution (Python):












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

lis = [0]*N
for i in arrA:
    lis[i]=1

ans = min(sum(lis[:X]),sum(lis[X:]))

print(ans)

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

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

count = 0

for i in A:
    if i > X:
        break
    count += 1

if count < M/2:
    print(count)
else:
    print(M-count)

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

Solution (Python):
n, m, x = map(int, input().split())
a_list = map(int, input().split())
less_a = 0
larger_a = 0
for a in a_list:
    if a < x:
        less_a += 1
    else:
        larger_a += 1
print(min(less_a, larger_a))

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n, m, x = MII()
    aa = MII()
    l_c = sum([1 for a in aa if a < x])
    r_c = sum([1 for a in aa if a > x])
    print(min(l_c, r_c))


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

n,m,x = map(int,input().split())
a = list(map(int,input().split()))
flag = [False]*(n+1)
for i in range(len(a)):
    flag[a[i]] = True
cnt1 = 0
cnt2 = 0
for i in range(x):
    if flag[i] == True:
        cnt2 += 1
for i in range(x+1,n+1):
    if flag[i] == True:
        cnt1 += 1
print(min(cnt1,cnt2))

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

N, M, X = map(int, input().split())
A = list(map(int, input().split()))
index = bisect.bisect_right(A, X)
print(min(index, len(A) - index))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
	n,m,x = MI()
	a = LI()
	for i,aa in enumerate(a):
		if(aa>x):
			print(min(i, m-i))
			exit()

if __name__ == '__main__':
	main()

Solution (Python):
x,y,z= map(int,input().split())
a = list(map(int,input().split()))
print(min(len([i for i in a if i < z]),(len([i for i in a if z<i <= x]))))

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
ans = min(cnt,m-cnt)
print(ans)

Solution (Python):

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

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

print(min(right, left))

Solution (Python):
n,m,x = 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):
import numpy as np
N,M,X,*A = map(int,open(0).read().split()) 
A = np.array(A)
print(min((A>X).sum(),(A<X).sum()))

Solution (Python):

url = "https://atcoder.jp//contests/abc094/tasks/abc094_b"

def main():
    N, M, X = list(map(int, input().split()))
    Ms = list(map(int, input().split()))
    count = 0
    for i in range(0, X + 1):
        if i in Ms:
            count += 1
    ans = count
    count = 0
    for i in range(X, N):
        if i in Ms:
            count += 1
    ans = count if ans > count else ans
    print(ans)
if __name__ == '__main__':
    main()

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

N=[]
for i in range(n+1):
    N.append(i*0)

for i in range(len(a)):
    N[a[i]]=1

print(min(sum(N[0:x+1]),sum(N[x+1:-1])))

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

right = list(filter(lambda x: x > X, a))
left = list(filter(lambda x: x < X, a))

ans = len(right) if len(right) < len(left) else len(left)

print(ans)

Solution (Python):
def myAnswer(N:int,M:int,X:int,A:list) -> int:
   masu =[]
   for i in range(N+1):
      if(i in A):
         masu.append(1)
      else:
         masu.append(0)
   return min(sum(masu[:X]),sum(masu[X+1:]))


def modelAnswer():
   tmp=1
def main():
   N,M,X =map(int,input().split())
   A =list(map(int,input().split()))
   print(myAnswer(N,M,X,A[:]))

if __name__ == '__main__':
   main()

Solution (Python):
import itertools
import copy
N ,M,X = (map(int,input().split(" ")))
nums = list((map(int,input().split(" "))))
a1 = sum([ num > X for num in nums])
a2 = sum([ num < X for num in nums])
print(min(a1,a2))

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

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

a1list=[]
a2list=[]
for a in alist:
  if a<X:
    a1list.append(a)
  else:
    a2list.append(a)
    
print(min(len(a1list),len(a2list)))

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

cost_a, cost_b = 0, 0

for i in range(X, N):
    if i in A:
        cost_a += 1
for i in range(0, X):
    if i in A:
        cost_b += 1
print(min(cost_b, cost_a))

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

print(min(len(A[:index]), len(A[index:])))

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

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

left_cost = len([a for a in A if a < X])
right_cost = len([a for a in A if X < a])
print(min(left_cost, right_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):
from bisect import bisect_left
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
i = bisect_left(A,X)
ans = min(len(A[0:i]),len(A[i:M]))
print(ans)

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

dicts = {i:0 for i in range(1, n)}
for i in range(m):
    dicts[a[i]] += 1

a, b = 0, 0

for i in range(1,n):
    if i < x:
        a += dicts[i]
    if i > x:
        b += dicts[i]

print(min(a, b))

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

l = [a for a in A if a < X]
r = [a for a in A if a > X]

print(len(l) if len(l) < len(r) else len(r))

Solution (Python):
from bisect import bisect_left as bl,bisect_right as br
n,m,now=map(int,input().split())
l=list(map(int,input().split()))
print(min(bl(l,now),m-bl(l,now)))

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

sum=len(a)
cost=100
costL=0
for i in range(M):
  if a[i]!=0 and a[i]<X:
    costL=costL+1
if min(costL,sum-costL)<cost:
  cost=min(costL,sum-costL)
print(cost)

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

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

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

for i in range(m+1):
  if A[i] > x:
    print(min(i,m-i))
    exit()

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):
    if i in A:
        right += 1
for i in range(0, X+1):
    if i in A:
        left += 1
print(min(right,left))

Solution (Python):
import sys

def resolve():
    N, M, X = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    pos = X
    costN = 0
    while True:
        if pos == N: 
            break
        pos += 1
        if pos in A:
            costN += 1
    pos = X
    cost0 = 0
    while True:
        if pos == 0: 
            break
        pos -= 1
        if pos in A:
            cost0 += 1
    print(min(cost0, costN))

if '__main__' == __name__:
    resolve()

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

Solution (Python):
n, m, x = map(int, input().split())
A = sorted(map(int, input().split()))
cost_0, cost_n = 0, 0
for a in A:
  if a < x: cost_0 += 1
  else: cost_n += 1
ans = min(cost_0, cost_n)
print(ans)

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    n, m, x = map(int,input().strip().split())
    temp = list(map(int, input().strip().split()))
    a = ["none" for _ in range(n+1)]
    for i in temp:
        a[i] = "isCharge"

    ans1=0
    ans2=0
    for i in range(x, n+1):
        if a[i] == "isCharge":
            ans1+=1
    for i in range(0, x+1)[::-1]:
        if a[i] == "isCharge":
            ans2+=1
    print(min(ans1,ans2))


if __name__ == '__main__':
    main()

Solution (Python):
n,m,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
a.sort()
one=0
while a:
    check=a.pop()
    if check>x:
        one+=1
    else:
        a.append(check)
        break
two=len(a)

print(min(one,two))

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

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

import bisect

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

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

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

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

tolls = [0] * (N+1)

for item in A:
    tolls[item] = 1

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

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

print(min(ans1, ans2))

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

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

for i in range(0,x):
  if a[cnt]==i:
    count1+=1
    if cnt==len(a)-1:
      pass
    else:
      cnt+=1
    
for j in range(x+1,n+1):
  if a[cnt]==j:
    count2+=1
    if cnt==len(a)-1:
      pass
    else:
      cnt+=1
      
print(count1 if count1<=count2 else count2)

Solution (Python):
n, m, x = map(int, input().split())
list_A = list(map(int, input().split()))
left = 0
right = 0
for num in list_A:
    if num < x:
        left += 1
    if num > x:
        right += 1

print(min(left, right))

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

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

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

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

print(min(ctr, M - ctr))

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

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

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

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

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

print(min(ans1, ans2))

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n,m,x = map(int,input().split())
  a = list(map(int,input().split()))
  cost = 0
  for i in range(x+1,n):
    if a.count(i):
      cost += 1
  mi_ = cost
  cost = 0
  for i in range(1,x):
    if a.count(i):
      cost += 1
  mi_ = min(mi_, cost)
  
  print(mi_)
if __name__ == '__main__':
  main()

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

lmt=len(list(takewhile(lambda x:x<X,A)))


ans=min(lmt,M-lmt)
print(ans)

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 = list(map(int, input().split()))
A = set(map(int, input().split()))
back = 0
for num in range(0, X):
  if num in A:
    back += 1
forward = 0
for num in range(X+1, N+1):
  if num in A:
    forward += 1
print(min([back,forward]))

Solution (Python):

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

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

print(min(cnt, m - cnt))

Solution (Python):

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

Solution (Python):
import numpy as np

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

ans = min(np.count_nonzero(A < X), np.count_nonzero(A > X))
print(ans)

Solution (Python):
def main():
    n, m, x = map(int, input().split())
    a = list(map(int, input().split()))
    right = list(filter(lambda y: y<x, a))
    left = list(filter(lambda y: y>x, a))
    print(min(len(right), len(left)))

if __name__ == "__main__":
    main()

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

    for i in range(m):
        array = [a<x for a in A]
    print(min(sum(array), m-sum(array)))


if __name__ == '__main__':
    main()

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
l=set(a)&set(list(range(1,x)))
r=set(a)&set(list(range(x+1,n)))
print(min(len(l),len(r)))

Solution (Python):
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
l.append(x)
l.sort()
print(min(m - l.index(x), l.index(x)))

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m,x = iim()
before = 0
after = 0
A = iil()
for i in A:
    if i < x:
        before += 1
    else:
        after += 1

print(min(before,after))

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

ans = 0

for i in a:
  if i < x:
    ans += 1

print(min(ans, m-ans))

Solution (Python):
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)


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

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

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

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

print(min(cnt, m-cnt))

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

cnt = 0
for a in A:
    if a > X:
        break
    cnt += 1

print(min(cnt, M - cnt))

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

go_left=sum(a > X for a in A)
go_right=sum(a < X for a in A)
print(min(go_left, go_right))

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

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

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

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

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

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

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


if __name__ == '__main__':
    main()

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

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

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 = ans1 + 1

for i in range(x + 1, n + 1):
    if i in A:
        ans2 = ans2 + 1

print(min(ans1, ans2))

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

ans = float("inf")

t = 0
for i in range(x+1, n+1):
    t += cost[i]
ans = min(ans, t)


t = 0
for i in range(x-1, -1, -1):
    t += cost[i]

ans = min(ans, t)

print(ans)

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