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=[int(i) for i in input().split()]
ans=chk=0
for i in a:
    if i<x: ans+=1
    else: chk+=1
print(min(ans,chk))

Solution (Python):
e = [[int(i) for i in input().split()] for i in range(2)]

r = 0
l = 0

for a in e[1]:
    if e[0][2] > a:
        l += 1
    elif e[0][2] < a:
        r += 1

if l <= r:
    print(l)
else:
    print(r)

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

Solution (Python):


INF = float('inf')


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


N, M, X = inpl()
A = inpl()

ans = 0
for i in range(M):
    if X < A[i]:
        break
    ans += 1

if ans > M - ans: ans = M - ans

print(ans)

Solution (Python):
n,m,x=map(int,input().split())
a=input().split()
a=list(map(int,list(a)))
arr1=list(y for y in a if 0<y<x)
arr2=list(y for y in a if x<y)
print(min(len(arr1),len(arr2)))

Solution (Python):
n,m,x=map(int,input().split())
a=input().split()
a=list(map(int,list(a)))
c=0
d=0
k=x
while (x<n):
    if x in a:
        c+=1
    x+=1
while (0<k):
    if k in a:
        d+=1
    k-=1
print(min(c,d))

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

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


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

l = [0 if i not in A else 1 for i in range(N+1)]
print(min(sum(l[X+1:-1]), sum(l[1:X])))

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

fee_st.append(x)
fee_st.sort()
p = fee_st.index(x)

if p < m/2:
    print(p)
else:
    print(m-p)

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
before = 0
after = 0
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())
fee_list = list(map(int, input().split()))
count = 0
while fee_list[count] <= x:
  count += 1
fee_0 = count
fee_n = m-count
  
ans_0 = fee_0
ans_n = fee_n

print(min(ans_0,ans_n))

Solution (Python):
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
l,r = 0,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 = map(int,input().split())

ans_l = 0
ans_r = 0
for a in A:
    if a<X:
        ans_l += 1
    else:
        ans_r += 1
        
print(min(ans_l,ans_r))

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

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

print(ans)

Solution (Python):
from bisect import bisect
n, m, p = map(int, input().split())
a = list(map(int, input().split()))
print(min(abs(bisect(a, n, 0, len(a))-bisect(a, p, 0, len(a))),
          abs(bisect(a, 0, 0, len(a))-bisect(a, p, 0, len(a)))))

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
A.append(X)
A.sort()
flag = False
for i in range(N+1):
  if (A[i] == X):
    flag = True
    break
if flag:
  print(min(len(A[i+1:]),len(A[:i])))

Solution (Python):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
p=0;q=0
for i in range(x):
  p+=a.count(i)
for j in range(x,n):
  q+=a.count(j)
print(min(p,q))

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

arr = [0 for _ in range(N+1)]
for x in list(map(int,input().split())):
    arr[x] = 1

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

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
A.append(X)
A.sort()
m = A.index(X)
n = len(A) - 1 - A.index(X)
if n == 0:
  print(0)
elif m < n:
  print(m)
elif m >= n:
  print(n)

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

left_a_list = [a for a in a_list if a < x]
right_a_list = [a for a in a_list if a > x]
min_cost = min(len(left_a_list), len(right_a_list))

print(min_cost)

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

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

count=0
listA.sort()
index=0
while True:
    if listA[index]<x and index<len(listA):
        count+=1
        index+=1
    else:
        break

print(min([count, len(listA)-count]))

Solution (Python):
N, M, X = list(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 a > X])
print(min(left_cost, right_cost))

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

cost = 9999999

pass

left_cost = len([a for a in A if a < X])

right_cost = len([a for a in A if a > X])

print(min(left_cost, right_cost))

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

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


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


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

if left_cost <= right_cost:
    print(left_cost)
else:
    print(right_cost)

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

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,M,X = inpl()
aa = inpl()
ind = bisect.bisect_left(aa,X)
print(min(ind,M-ind))

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

leftCost = 0
for place in a:
	if place > x:
		break
	else:
		leftCost += 1

rightCost = m - leftCost

if rightCost > leftCost:
	print(leftCost)
else:
	print(rightCost)

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

N, M, X = map(int, raw_input().split())
A = map(int, raw_input().split())
left = 0
right = 0
for i in range(0, M):
	if A[i] < X: left = left + 1
	if A[i] > X: right = right + 1

print smaller(left, right)

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

A = [int(i) for i in input().split()]

masu = [0 for _ in range(N+1)]

for i in A:
    masu[i] = 1

L = sum(masu[:X])
R = sum(masu[X+1:N+1])

print(min(L, R))

Solution (Python):
c1=0
c2=0
N,M,X=map(int,input().split())
a=list(map(int,input().split()))
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_0 = [a for a in A if a < X ]
A_N = [a for a in A if a > X ]

print(min(len(A_0), len(A_N)))

Solution (Python):
def main17():
    buf = input("");
    bufs = buf.split();
    hai = [];
    for i in range(len(bufs)):
        hai.append(int(bufs[i]));
    buf = input("");
    bufs = buf.split();
    hai2 = [];
    pen = 0;
    for i in range(len(bufs)):
        hai2.append(int(bufs[i]));
    for i in range(len(hai2)):
        if hai[2] < hai2[i]:
            break;
        else:
            pen = pen + 1;
    if pen < len(hai2) / 2:
        print(pen);
    else:
        print((len(hai2) - pen));




if __name__ == '__main__':
    main17()

Solution (Python):
c1 = 0
c2 = 0
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
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=map(int,input().split())

up=0
down=0

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

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

up = 0
down = 0

for a in a_s:
    if a > x:
        up += 1
    else:
        down += 1

print(min(up, down))

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

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

cnt1 = 0
cnt2 = 0
for i in range(M):
  if A[i] < X:
    cnt1 += 1
  else:
    cnt2 += 1

print(min(cnt1,cnt2))

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

sm = 0
la = 0
for a in A:
  if(int(a) < X):
    sm += 1
  else:
    la += 1

print(min(sm, la))

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

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

for i in range(X+1):
    count += A.count(i)

ans = min(count, len(A)-count)
print(ans)

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

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

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

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

Solution (Python):


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    N, M, X = map(int, input().split())
    A = list(map(int, input().split()))
    l, r = 0, 0
    for a in A:
        if a < X:
            l += 1
        else:
            r += 1

    print(min(l, r))


if __name__ == '__main__':
    main()

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

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


print(min(sum(1 for a in A if a < X), sum(1 for a in A if a > X)))

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


print(min(sum(1 for a in A if a < X), sum(1 for a in A if a > X)))

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

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(10000)




def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))




def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]




dp = None


def main():
    N, M, X = li_input()
    A = li_input()

    C = []
    for i in range(N + 1):
        if i in A:
            C.append(1)
        else:
            C.append(0)

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


main()

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

to_0_count = 0
to_N_count = 0
for i in range(0, X):
    if i in a_list:
        to_0_count +=1
for i in range(X+1, N+1):
    if i in a_list:
        to_N_count +=1
print(min([to_0_count, to_N_count]))

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

ans1 = len([a for a in A if a < x])
ans2 = len([a for a in A if a > x])
print(min(ans1,ans2))

Solution (Python):
n,m,x=map(int,input().split())
cnt=0
for c in map(int,input().split()):cnt+=c>x
print(min(cnt,m-cnt))

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

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


to_0 = 0
to_N = 0
for a in A:
    if a<X:
        to_0 += 1
    else:
        to_N += 1

print(min(to_0,to_N))

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

ans1 = len([a for a in A if a<X])
ans2 = len([a for a in A if a>X])
print(min(ans1,ans2))

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

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

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

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

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

x_more = [x < a_i for a_i in a]

print(min(x_more.count(True), x_more.count(False)))

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

Solution (Python):
from bisect import bisect_left

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

i = bisect_left(axs, x)
print(min(i, len(axs) - i))

Solution (Python):
n,m,x = map(int,input().split())
i = list(map(int,input().split()))
cs = []
cl = []    
for j in range(m):
    if x > i[j]:
        cs.append(i[j])
    else:
        cl.append(i[j])
print(min(len(cs),len(cl)))

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

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

a.append(X)
b=sorted(a)
print(min(len(b)-b.index(X)-1,b.index(X)))

Solution (Python):

n=[int(i) for i in input().split()]
Ad=0
Au=0
A=[int(i) for i in input().split()]
for i in range(n[1]):
  if(A[i]>n[2]):
    Au+=1
  else:
    Ad+=1
if(Au>=Ad):
  print(Ad)
else:
  print(Au)

Solution (Python):


def main():
    N, M, X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    cnt_first = 0
    cnt_last = 0

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

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

    if cnt_first < cnt_last:
        print(cnt_first)
    else:
        print(cnt_last)




if __name__ == '__main__':
    main()

Solution (Python):

costa = 0
costb = 0
n = 0


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


for i in range(X,-1,-1):
    j = A.count(i)
    if j == 1:
        costa = costa + 1

for n in range(X,N+1):
    k = A.count(n)
    if k == 1:
        costb = costb + 1

if costa > costb:
    print(costb)
else:
    print(costa)

Solution (Python):
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
idx=X
cnt_left=0
cnt_right=0
cost_list=[0 for _ in range(N)]
for c in A:
    cost_list[c]=1
    
left=sum(cost_list[:idx])
right=sum(cost_list[idx:])
    
print(min(right,left))

Solution (Python):
n, m, x = map(int, input().split())
a_tmp = input().split()
a = []
for _ in a_tmp:
    a.append(int(_))
cost_l = 0
cost_r = 0
j = 0
for i in range(n+1):
    if i < x:
        if i == a[j]:
            cost_l += 1
            j += 1
            if j >= len(a):
                break
    elif x < i:
        if i == a[j]:
            cost_r += 1
            j += 1
            if j >= len(a):
                break
    else:
        continue
print(min(cost_l, cost_r))

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

xt = 0
for i in a:
    if x < i:
        xt = a.index(i)
        break;

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

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

def main():
    list = [0] * (N + 1)
    for _ in range(M):
        a = A.pop()
        list[a] = 1
    left = list[:X + 1]
    right = list[X:]
    ans = min(sum(left), sum(right))
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):

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

l.append(x)
l.sort()

print(min(l.index(x),m-l.index(x)))

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

left_cost = sum(costV[:X])
right_cost = sum(costV[X+1:])
print(min(left_cost,right_cost))

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

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

print(min(a, b))

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

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

d=0
e=0

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

print(min([d,e]))

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

a.sort()

s = len(a)

cnt = 0
for v in a:
    if v > x:
        cnt += 1
print(min(s - cnt, cnt))

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

Solution (Python):
"""
https://abc094.contest.atcoder.jp/tasks/abc094_b
"""
[n,m,x]=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
b=0
c=0
for i in a:
    if 0<i and i<x:
        b=b+1
    if x<i and i<n:
        c=c+1
print(min(b,c))

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

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


for i in range(n+1):
  
  if st == 0:
    print("0")
    break

  if i in a:
    num += 1
  
  if i == st:
    
    res_l = num
    
    res_r = m - num
    
    print(min(res_l,res_r))
    
    break

Solution (Python):
n,m,x = input().split()
N = int(n)
M = int(m)
X = int(x)
left = []
right = []

A = input().split()
A = list(map(int,A))
for i in range(len(A)):
	if(A[i]<X):
		left.append(A[i])
	elif(A[i]>X):
		right.append(A[i])

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

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

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

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

Solution (Python):
N, M, X = map(int, input().split())
cost = list(map(int, input().split()))
n = len(list(filter(lambda x: x>X, cost)))
m = len(list(filter(lambda x: x<X, cost)))
print(m if n>=m else n)

Solution (Python):
N, M, X = map(int, input().split())
cost_mas = list(map(int, input().split()))
cost = 0
n = len(list(filter(lambda x: x>X, cost_mas)))
m = len(list(filter(lambda x: x<X, cost_mas)))
print(cost+m if n>=m else cost+n)

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

    ans = min(len([v for v in a if 0 < v and v < x]),
              len([v for v in a if x < v and v <= n]))
        
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M, X = map(int, input().split())
Ai = list(map(int, input().split()))
m = [i for i in Ai if i < X]
M = [o for o in Ai if o > X]
a = len(m)
b = len(M)
if a > b:
  print(b)
if b > a:
  print(a)

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

Solution (Python):
N,M,X=map(int,raw_input().split())
A=map(int,raw_input().split())
cost=[0]*(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()))

ct1 = 0
ct2 = 0

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

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

print(min(ct1, ct2))

Solution (Python):


if __name__ == "__main__":
	N, M, X = list(map(int, input().split()))
	As = list(map(int, input().split()))
	cost = 0
	for A in As:
		if A > X:
			break
		cost += 1
	print(min(cost, M-cost))

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

go_0 = sum([ai < x for ai in a]) 
go_n = sum([ai > x for ai in a]) 
print(min(go_0, go_n))

Solution (Python):
N, M, X = map(int, input().split())
tolls = [int(i) for i in input().split()]
print(min(sum([1 for p in tolls if p < X]), sum([1 for p in tolls if p > 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):
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
i=0
cost=0
while a[i]<x:
  cost+=1
  i+=1
print(min(cost,len(a)-cost))

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

result = len(set(range(0,X))&A)
result = min(result, len(set(range(X,N))&A))

print(result)

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

result = len(set(range(0,X))&A)
result = min(result, len(set(range(X,N))&A))

print(result)

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

w = 0
e = 0
for i in a:
    if i < x:
        w += 1
    elif x < i:
        e += 1
print(min(w, e))

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

to_zero = 0
to_N = 0
for A_i in A:
    if A_i < X:
        to_zero += 1
    elif N > A_i > X:
        to_N += 1
print(min(to_zero, to_N))

Solution (Python):
N,M,X = map(int,input().split())
toll_index = [int(i) for i in input().split() if int(i) not in [0,N,X]]
toll_array = [1 if j in toll_index else 0 for j in range(N+1)]
ZtoX, XtoN = sum(toll_array[0:X]),sum(toll_array[X:N])
print([ZtoX,XtoN][ZtoX>XtoN])

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

print(min(a,b))

Solution (Python):
from bisect import bisect_left

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

i = bisect_left(axs, x)
print(min(len(axs[:i]), len(axs[i:])))

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

t= [i for i in A if i> 0 and i< X]
s= [i for i in A if i> X and i<N]

print(min(len(t),len(s)))

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

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

cnt_b = 0
cnt_s = 0
for i in a:
    if i > X:
        cnt_b += 1
    else:
        cnt_s += 1
print(min(cnt_b, cnt_s))

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

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

t = [i for i in A if i<X and 0<i]
s = [i for i in A if i>X and i<N]

print(min(len(t),len(s)))

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

Solution (Python):
l = map(int, raw_input().split())
n = l[0]
m = l[1]
x = l[2]

a = map(int, raw_input().split())



for i in xrange(0,m):
	if a[i] > x:
		if m - i < i:
			print m - i
			break
		else:
			print i
			break

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

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

cl = 0

for i in range(M):
  if A[i] < X:
    cl = cl + 1
cr = len(A) - cl

print(min(cl, cr))

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

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

countA=0
countB=0

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

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

print(min(countA,countB))

Solution (Python):
l = list(map(int,input().split()))
a = list(map(int,input().split()))
b = []
c = []
for n in a:
    if n > l[2]:
        b.append(n)
    else:
        c.append(n)
print('{}'.format(min(len(b),len(c))))

Solution (Python):
N, M, X = map(int, input().split())
arr = input().split()
list_fee = []

for i in range(N):
    if arr == []:
        break
    if int(arr[0]) == i+1:
        list_fee.append(1)
        arr.pop(0)
    else:
        list_fee.append(0)
    
a = list_fee[:X].count(1)
b = list_fee[X:].count(1)

print(min(a, b))

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

counterToN,counterToX = 0,0

for i in A:
    if i - 1 < X :
        counterToN += 1
    else :
        counterToX += 1

print(min([counterToN,counterToX]))

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

idx = 0

while idx < M:
    if A[idx] > X:
        break
    idx += 1

res = min(idx, M - idx)
print(res)

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

count = 0
for i in range(x):
  if i in fee_station:
    count += 1

print(count if count < len(fee_station) - count else len(fee_station) - count)

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

cost_0, cost_N = 0, 0

for i in range(M):
    if A[i] < X:
        cost_0 += 1
    else:
        cost_N += 1

if cost_0 < cost_N:
    print(cost_0)
else:
    print(cost_N)

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

cost_0, cost_N = 0, 0

for i in range(M):
    if A[i] < X:
        cost_0 += 1
    else:
        cost_N += 1

if cost_0 < cost_N:
    print(cost_0)
else:
    print(cost_N)

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

a = [i in A for i in range(1, N+1)]
print(min(sum(a[:X]), sum(a[X:])))

Solution (Python):
import bisect
_,m,x=map(int,input().split());*a,=map(int,input().split());i=bisect.bisect_left(a,x);print(min(i,m-i))

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

forward = 0
back = 0
for i in a:
    if i < x:
        back += 1
    elif i > x:
        forward += 1

print(min(back, forward))

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

a = list(map(int, input().split()))
s = 0
assert len(a) == M
for i in range(M):
    if a[i] < X:
        s += 1
    else:
        break
print(min(len(a) - s, s))

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

for i in a:
    for j in range(x):
        if i == j:
            to_0 += 1

    for k in range(x, n):
        if i == k:
            to_n += 1

if to_0 >= to_n:
    print(to_n)
else:
    print(to_0)

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

r = l = 0
for a in A:
    if a < X:
        r += 1
    elif a > X:
        l += 1
print(min(r, l))

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

setA = set(A) 
s1 = range(0, X)
s2 = range(X, N+1)
a1 = set(s1) & (setA)
a2 = set(s2) & (setA)
cost1 = len(a1)
cost2 = len(a2)

if cost1 >= cost2:
    print(cost2)
else:
    print(cost1)

Solution (Python):
l = input().split()
n = int(l[0])
m = int(l[1])
x = int(l[2])
a = input().split()
i = 0
while(1):
    if int(a[i]) > x:
        break
    i = i + 1
if i < m - i:
    print(i)
else:
    print(m - i)

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

l = len([a_i for a_i in a if a_i < x])
r = len([a_i for a_i in a if a_i > x])

ans = l
if r < ans:
    ans = r
print(ans)

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