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

cost1 = 0
for i in range(1, X):
    if i in Am:
        cost1+= 1

cost2 = 0
for i in range(X + 1, N):
    if i in Am:
        cost2 += 1
print(min(cost1, cost2))

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

a = [int(i) for i in input().rstrip().split(' ')]

c1 = len(list(filter(lambda i: i < x, a)))
c2 = len(list(filter(lambda i: i > x, a)))
print(min(c1, c2))

Solution (Python):
goal,num,start = map(int,input().split())
A = list(map(int,input().split()))
route = [0 for i in range(goal+1)]
for ind in A:
    route[ind] = 1
print(min(sum(route[start:goal]),sum(route[0:start+1])))

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

Solution (Python):



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


temp1 = X
cost1 = 0
while(1):
	if temp1 == N:
		break
	temp1 += 1
	for j in range(M):
		if temp1 == A[j]:
			cost1 += 1


temp2 = X
cost2 = 0
while(1):
	if temp2 == 0:
		break
	temp2 -= 1
	for j in range(M):
		if temp2 == A[j]:
			cost2 += 1


print(min(cost1,cost2))

Solution (Python):
N,M,X = (int(i) for i in input().split())
places = input()
placelistchar = places.split(" ")

placelist = []
for k in range(M):
    placelist.append(int(placelistchar[k]))


countbig = 0
countsmall = 0


for i in range(0,N):
    if(i in placelist):
        if i<X:
            countsmall += 1
        else:
            countbig += 1

print(min(countsmall,countbig))

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

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

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

big_A = list(filter(lambda x: x > X, A))
len_min_A = len(A) - len(big_A)

if len(big_A) < len_min_A:
    print(len(big_A))
else:
    print(len_min_A)

Solution (Python):
from itertools import accumulate
N, M, X = map(int, input().split(' '))
Toll = list(map(int, input().split(' ')))
cost = [1 if i in Toll else 0 for i in range(N+1)]
cost_cum = list(accumulate(cost))
print(min(cost_cum[X]-cost_cum[0], cost_cum[N]-cost_cum[X]))

Solution (Python):
import numpy as np

def main():
    n, m, x = map(int, input().split())
    a = map(int, input().split())
    
    arr_np = np.array(list(a))

    print(min(np.sum(arr_np < x) ,np.sum(arr_np > x)))

if __name__ == '__main__':
    main()

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

row = [0]*(N+1)

for i in A:
    row[i]=1
    
print(min(sum(row[:X]),sum(row[X:])))

Solution (Python):
import bisect
m,n,x=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
b=bisect.bisect_left(a,x)
print(min(b,n-b))

Solution (Python):
import bisect
m,n,x=[int(i) for i in input().split()]
a=sorted([int(i) for i in input().split()])
b=bisect.bisect_left(a,x)
print(min(b,n-b))

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


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

cntm = 0
cntp = 0

for i in range(M):
    if X < a[i]:
        cntm += 1

    else:
        cntp += 1


if cntm < cntp:
    print(cntm)

else:
    print(cntp)

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

cost = [0 for i in range(n+1)] 

for i in range(m):
  cost[a[i]] = 1

print(min(sum(cost[:x]),sum(cost[x+1:n+1])))

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

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

Solution (Python):
a = input()
a = a.rstrip().split(" ")
goal2 = int(a[0])
sekisyosuu = int(a[1])
start = int(a[2])

b = input()
sekisyo = b.rstrip().split(" ")



up=0
dn=0
for i in range(len(sekisyo)):
    if int(sekisyo[i])>=int(start):
        up = up+1
        i+=1
    else:
        dn = dn+1
        i +=1
    



if int(up)<int(dn):
    print(up)
else:
    print(dn)

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int, input().split()))
ans1 = 0
for i in range(X,N):
    if i in A:
        ans1 += 1
ans2 = 0
for i in range(X,0,-1):
    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()))

to_N = list(range(X,N))
to_0 = list(range(0,X))

to_N_count = 0
for i in to_N:
    for j in  A:
        if i == j:
            to_N_count += 1

to_0_count = 0
for i in to_0:
    for j in A:
        if i == j:
            to_0_count += 1

print(min(to_N_count,to_0_count))

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

Solution (Python):
N, M, X = [int(x) for x in input().split(" ")]
arr = [0 for x in range(N+1)]
for i in [int(a) for a in input().split(" ")]:
	arr[i] = 1
kiri = arr[0:X].count(1)
kanan = arr[X+1:].count(1)
print(min(kiri, kanan))

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

for i in An:
    if i < X:
        count += 1
    else:
        pass

if count >= M - count:
    print (M - count)
else:
    print (count)

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

cost, left, right = {}, 0, 0

for i in a:
    cost[i] = True

for i in reversed(range(0, x)):
    left += (1 if i in cost else 0)

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

print(min(left, right))

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

cost = {}

for i in a:
    cost[i] = True

left = right = 0

for i in reversed(range(0, x)):
    left += (1 if i in cost else 0)

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

print(min(left, right))

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

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

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

for i in range(len(a)):
    if a[i] > x:
        over +=1
    else:
        under+=1
        
print(min(over,under))

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

Solution (Python):
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
B = abs(np.array(A)-X)
i = np.where(B == min(B))[0][0]
if A[i]-X > 0:
    print(min(M-i,i))
else:
    print(min(i+1,M-i-1))

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

left = 0
right = 0

for ai in a:
    if ai < X:
        left += 1
    else:
        right += 1

print(min(left, right))

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

c1 = len([i for i in gates if i < X])
can = [c1, M - c1]

print(min(can))

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
    elif(i >= X):
        r += 1
print(min(l, r))

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

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

Solution (Python):
N, M, X = map(int, raw_input().split(" "))
A = map(int, raw_input().split(" "))
r = len([ai for ai in A if ai < X])
l = len([ai for ai in A if ai > X])
print(min((r,l)))

Solution (Python):
N, M, X = map(int, input().split(" "))
A = map(int, input().split(" "))
left, right = 0,0
for ai in A:
  if ai < X: left+=1
  else: right+=1
print(min(right, left))

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

Solution (Python):
ipt1 = [int(i) for i in input().split()]
a = [int(i) for i  in input().split()]
n = ipt1[0]
m = ipt1[1]
x = ipt1[2]
cost_0 = 0
cost_n = 0
for i in range(m):
    if a[i] < x:
        cost_0 += 1
    else:
        cost_n += 1

print(int(min(cost_0, cost_n)))

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

Solution (Python):
import bisect

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

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

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

for i in range(0,M):
    if int(list[i]) <= X:
        route0 = route0 + 1


for i in range(0,M):
    if int(list[i]) > X:
        routeN = routeN + 1

print(min(route0,routeN))

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

to0, toX = 0, 0
for m1 in m_list:
    if m1 > x:
        toX += 1
    else:
        to0 += 1
print(min(to0,toX))

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

Solution (Python):


import math
import sys
import itertools
import numpy as np

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

cost_r=0
cost_l=0
i=0
while i < m :
    if a[i] > x :
        cost_r += 1
    i += 1
i=m-1
while i >= 0 :
    if a[i] < x :
        cost_l += 1
    i -= 1
answer = cost_r
if cost_l < answer:
    answer = cost_l

print(answer)

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

Solution (Python):
N, M, X = map(int, raw_input().split())
A = map(int, raw_input().split())
p = len(filter(lambda a: a < X, A))
q = len(filter(lambda a: a > X, A))
print min(p, q)

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

Solution (Python):
N, M, X = map(int, raw_input().split())
A = map(int, raw_input().split())
p = len(filter(lambda a: a < X, A))
q = len(filter(lambda a: a > X, A))
print min(p, q)

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

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

Solution (Python):
def get_values():
    return [int(a) for a in input().split()]

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

left_cost = 0
for a in As:
    if a > X:
        break
    left_cost += 1
right_cost = len(As) - left_cost
print(min(left_cost, right_cost))

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

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

for i,a in enumerate(A):
    if a>X:
        print(min(i,M-i))
        break

Solution (Python):

from bisect import bisect
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
pos = bisect(A, X)
ans = [len(A[:pos]), len(A[pos:])]
print(min(ans))

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

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

print(min([len(list(filter(lambda a:a>X,A))),len(list(filter(lambda a:a<X,A)))]))

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

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

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

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

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

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

print(min(count,m-count))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
left = 0
for i in range(m):
    if x > a[i]:
        left += 1
    else:
        break
right = m - left
cost_min = left if left < right else right
print('{}'.format(cost_min))

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

for i in range(m+1):
    if a[i]==x:
        j=i
print(min(j,m-j))

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

Solution (Python):
def minimum_cost(N, M, X, gates):
    left = range(X, -1, -1)
    right = range(X, N + 1)

    left_cost = right_cost = 0
    for i in left:
        if i in gates:
            left_cost += 1
    
    for i in right:
        if i in gates:
            right_cost += 1

    min_cost = left_cost
    if min_cost > right_cost:
        min_cost = right_cost

    return min_cost


if __name__ == "__main__":
    N, M, X = list(map(int, input().rstrip().split(" ")))
    gates = [int(x) for x in input().rstrip().split(" ")]

    print(minimum_cost(N, M, X, gates))

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




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



cnt = 0
for i in range(x, n + 1):
    cnt += A[i]

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


if cnt < cnt_:
    print(cnt)
else:
    print(cnt_)

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

print(count0 if count0 < countN else countN)

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

forward_cost = 0
backward_cost = 0

i = X
while i <= N:
    i += 1

    if i in A_list:
        forward_cost += 1

i = X
while i >= 0:
    i -= 1

    if i in A_list:
        backward_cost += 1

print(min(forward_cost, backward_cost))

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

for i in range(M):
  if X < A[i]:
    break
    
cost = min([len(A[0:i]), len(A[i:M])])

print(cost)

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

cost = 0
cost2 = 0

for i in range(X, N):
   if i in a:
       cost += 1

for i in range(X, 0, -1):
    if i in a:
        cost2 += 1

if cost < cost2:
    print(cost)
else:
    print(cost2)

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

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

    ans = min(sum(costs[0:X+1]), sum(costs[X:]))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N,M,X = map(int, input().split())
n = list(map(int, input().split()))
Ni = list(range(N,X,-1))
Nk = list(range(0,X))
Ni_set = set(Ni)
Nk_set = set(Nk)
n_set = set(n)
Ni_ten = list(Ni_set & n_set)
Nk_ten = list(Nk_set & n_set)
if len(Ni_ten)< len(Nk_ten):
 print(len(Ni_ten))
else:
  print(len(Nk_ten))

Solution (Python):

"""
B - Toll Gates
https://beta.atcoder.jp/contests/abc094/tasks/abc094_b

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    N, M, X = map(int, input().split())
    points = [0] * (N + 1)
    gates = [int(x) for x in input().split()]
    for g in gates:
        points[g] = 1

    ans_0 = sum(points[:X])
    ans_n = sum(points[X:N])
    print(min(ans_0, ans_n))


if __name__ == '__main__':
    main(sys.argv[1:])

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

for i in range(0,M):
    if A[int(i)] in range(0,X):
        countA += 1
for j in range(0,M):
    if A[int(j)] in range(X,N+1):
        countB += 1
if countA > countB:
    print(countB)
else:
    print(countA)

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

cost_l = 0
cost_r = 0


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


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

print(min(cost_l, cost_r))

Solution (Python):


def main():
    N,M,X = map(int, input().split(" "))

    A = [0]*(N+1)
    for i in map(int, input().split(" ")):
        A[i] = 1

    print(min(sum(A[0:X]), sum(A[X:N])))



if __name__ == '__main__':
    main()

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

left=0
right=0

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

Solution (Python):
N, M, X = (int(_) for _ in input().split())
A = [int(_) for _ in input().split()]
cost = [0, 0]
for a in A:
    if a < X:
        cost[0] += 1
    else:
        cost[1] += 1

print(min(cost))

Solution (Python):
n, m, x = map(int, input().split(" "))
a = input().split(" ")
sum_zero = 0
sum_n = 0
for i in range(1, x):
    if str(i) in a:
        sum_zero += 1

for i in range(x+1, n):
    if str(i) in a:
        sum_n += 1
print(min(sum_zero, sum_n))

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

    cost_move_to_left = 0
    cost_move_to_right = 0
    for i in a:
        if i > x:
            cost_move_to_left += 1
        elif i < x:
            cost_move_to_right += 1

    print(cost_move_to_left if cost_move_to_left < cost_move_to_right else cost_move_to_right)



if __name__ == '__main__':
    main()

Solution (Python):


N, M, X = map(int, input().split())
cost0 = len([i for i in input().split() if int(i) < X])
if cost0 * 2 <= M:
    print(cost0)
else:
    print(M - cost0)

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

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

Solution (Python):
n, m, x = map(int, input().split())
fee = set(map(int, input().split()))
ls = list(range(n+1))
f, b = ls[:x], ls[x+1:]
print(min(len(fee & set(f)), len(fee & set(b))))

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

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

Solution (Python):
import math

def solve(x, a):
	low = 0
	high = len(a)-1
	while high >= low:
		t = (high+low)//2
		if x>a[t]:
			low = t+1
		else:
			high = t-1
	t = math.ceil((high+low)/2)
	return min(t, len(a)-t)
		
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
print(solve(x,a))

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

for b in a:
    c += 1
    if x < b:
        c -= 1
        if c < (m/2):
            print(c)
        else:
            print(m-c)
        break

Solution (Python):
s=list(map(lambda x:int(x), input().split()))
a=list(map(lambda x:int(x), input().split()))
cost=[len(list(filter(lambda x:x<s[2], a))),
      len(list(filter(lambda x:x>s[2], a)))]
print(min(cost))

Solution (Python):
n,m,x=[int(x) for x in input().split()]
arr=[int(x) for x in input().split()]
goLeft = 0
goRight = 0
for i in arr:
    if i < x:
        goLeft += 1
    else:
        goRight += 1
print(min(goLeft,goRight))

Solution (Python):


n,m,x=map(int,raw_input().split())
a=map(int,raw_input().split())
cnt0=0
cntn=0
for i in a:
 if i<x:
  cnt0+=1
 else:
  cntn+=1
print min(cnt0,cntn)

Solution (Python):

n, m, x = map(int, input().split())
i = sum((1 for ai in map(int, input().split()) if ai < x))
print(min(i, m-i))

Solution (Python):

n, m, x = map(int, input().split())
a = list(map(int, input().split()))
i = 0
while a[i] < x:
    i += 1
print(min(i, len(a)-i))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
 
a.append(x)
a = sorted(a)
 
index = a.index(x)
if index < len(a) - (index + 1):
    print(index)
else:
    print(len(a) - (index + 1))

Solution (Python):



a, b, x = map(int, input().split())

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

count_low, count_high = [0, 0]

for i in cost_idxs:
    if i < x:
        count_low += 1
    elif i > x:
        count_high += 1

min_cost = min(count_low, count_high)


print("{}".format(min_cost))

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

a.append(x)
a = sorted(a)

index = a.index(x)
if index < len(a) - (index + 1):
    print(index)
else:
    print(len(a) - (index + 1))

Solution (Python):
l = list(int(i) for i in input().split())
A = list(int(i) for i in input().split())

left_cost = 0
right_cost = 0

for i in range(l[1]):
    if A[i] < l[2]:
        left_cost += 1
    else:
        right_cost += 1

if left_cost < right_cost:
    print("%d" % left_cost)
else:
    print("%d" % right_cost)

Solution (Python):
nmx = input().split()
n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])

a = input().split()
numl = 0
numr = 0
a = [int(x) for x in a]

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

if numl > numr:
    print("%d"%numr)
else:
    print("%d"%numl)

Solution (Python):
n, m, x = map(int,input().split())
A = list(map(int,input().split()))
right = len(list(filter( lambda num : num < x , A)))
left = len(A) - right
if right >= left:
    print(left)
else:
    print(right)

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

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

Solution (Python):

if __name__ == "__main__":
    n, m, x = map(int, input().split())
    factors = [ tmp for tmp in range(n+1) ]
    gateFlag = [ False for tmp in range(n+1) ]
    a = list(map(int, input().split()))
    for tmp in range(m):
        gateFlag[a[tmp]] = True
    ansFactor = 0
    ansFactor2 = 0
    pivot = x
    while pivot-1 > 0:
        if gateFlag[pivot-1]:
            ansFactor += 1
        else:
            pass
        pivot -= 1
    else:
        pivot = x
    while pivot+1 < n:
        if gateFlag[pivot+1]:
            ansFactor2 += 1
        else:
            pass
        pivot += 1
    print(min(ansFactor, ansFactor2))

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

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


former = sum(j<X for j in A)
later = M-former

if former <= later:
    print(former)
else:
    print(later)

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

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

p = 0
for k in range(1,X):
    if k in A:
        p += 1
q = 0
for k in range(X+1,N+1):
    if k in A:
        q += 1

print(min(p,q))

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

left = 0
right = 0
for item in a:
    if item < x:
        left += 1
    else:
        right += 1

print(min(left, right))

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

a = list(map(int, input().split()))
for i in range(m):
    if a[i] < x:
        cost_a += 1
    else:
        cost_b += 1
print(min(cost_a, cost_b))

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

cost = []
costA=0
costB=0
l=0



for i in range(n+1):
    if i==A[l]:
        cost.append(1)
        if l < len(A)-1:
            l+=1
    else:
        cost.append(0)

for j in range(x):
    if cost[j]==1:
        costA+=1

for k in range(x,n):
    if cost[k]==1:
        costB+=1



print(min(costA,costB))

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

pre=post=0

for i in range(x):
    if i in mlist:
        pre += 1

for i in range(x,n+1):
    if i in mlist:
        post += 1

print(min(pre,post))

Solution (Python):
import sys

l=input().split()
N=int(l[0])
M=int(l[1])
X=int(l[2])

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


migi=0
hidari=0
for item in l:
	if(item>X):
		migi+=1
	else:
		hidari+=1

if(migi>hidari):
	print(hidari)
else:
	print(migi)

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

pre = 0
post = 0
for ai in a:
	if ai < X:
		pre += 1
	else:
		post += 1

res = min(pre, post)

print(res)

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

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

l = []

for c in a:
    if c < x:
        l.append(c)

if len(l) < m-len(l):
    print(len(l))
else:
    print(m-len(l))

Solution (Python):


N, M,X = list(map(int,raw_input().split()))
li = list(map(int,raw_input().split()))
right = len(list(filter(lambda x:x<X,li)))
left = len(list(filter(lambda x:x>X,li)))
print min(right,left)

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

ans1=int(0)
ans2=int(0)

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

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

print(min(ans1,ans2))

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

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

Solution (Python):
N, M, X = map(int, input().split())
F = [0 for _ in range(N+1)]
for A in input().split():
	F[int(A)] = 1
print(min(sum(F[:X+1]), sum(F[X:])))

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


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

cost0 = costn = 0

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

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

print(min(cost0, costn))

Solution (Python):
if __name__ == '__main__':
    N, M, X = map(int, input().split())
    A = map(int, input().split())
    cost_map = {}
    for i in A:
        cost_map[i] = 1
    cost_to_0 = [0 for i in range(N+1)]
    cost_to_N = [0 for i in range(N+1)]
    for i in range(1, N+1):
        if i in cost_map:
            cost_to_0[i] = cost_to_0[i-1] + 1
        else:
            cost_to_0[i] = cost_to_0[i-1]

    for i in range(0, N)[::-1]:
        if i in cost_map:
            cost_to_N[i] = cost_to_N[i+1] + 1
        else:
            cost_to_N[i] = cost_to_N[i+1]
    print(min(cost_to_0[X], cost_to_N[X]))

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

cost = 0

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

print(min(cost, m - cost))

Solution (Python):


n, m, x = map(int, input().split())
a = list(map(int, input().split()))
to_zero = len([v for v in a if v > 0 and v < x])
to_n = len([v for v in a if v > x and v < n])
print(min(to_zero, to_n))

Solution (Python):
A,B,C = map(int,input().split())

List_one = [0]*B
List_one = list(map(int,input().split()))

List_one.append(C)



List_one.sort()


x = List_one.index(C)

if x>=B-x:
    print(B-x)
else:
    print(x)

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

num = 0
for i in places:
    if i > X:
        break
    num += 1

print(min([num,N-num]) )

Solution (Python):

                                                
NMX = [int(i) for i in input().split()]         
N, M, X = NMX[0],  NMX[1],  NMX[2]              
fee_station = [int(i) for i in input().split()] 
                                                
increase = 0                                    
decrease = 0                                    
                                                
for i in range(M):                              
  if fee_station[i] > X:                        
    increase += 1                               
  else:                                         
    decrease += 1                               
                                                
print(min(increase, decrease))

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