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

Solution (Python):
N,M,X=map(int,input().split())
B=0
C=0
L=list(map(int,input().split()))
for I in L:
	if I<X:
		B+=1
	else:
		C+=1
print(min(B,C))

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

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

Solution (Python):


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

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

Y = [0 for i in range(N)]
for j in range(M):
    Y[A[j]] = 1

rightSideCost = sum(Y[0:X])
leftSideCost = sum(Y[X:N])

print(min(rightSideCost,leftSideCost))

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

cost1 = 0
cost2 = 0
for i in range(N):
   if (i<X)and(i in A):
      cost1 += 1
   elif (i>X)and(i in A):
      cost2 += 1

print(min([cost1,cost2]))

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

sum_0 = 0
sum_N = 0

for i in range(len(a)):
    if a[i]<x:
        sum_0 +=1
    if a[i]>x:
        sum_N+=1
print(min(sum_0, sum_N))

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

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

if count >= (M / 2):
    answer = M - count
else:
    answer = count

print(answer)

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

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

for i in range(x, n+1):
    for j in range(len(a)):
        if a[j] == i:
            costN += 1

if cost0 <= costN:
    print(cost0)

else:
    print(costN)

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

Z=0
for j in range(0,X):
    if j in A:
        Z+=1
print(min(Y,Z))

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

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

c2 = 0
for i in range(x, 0, -1):
    if i in r:
        c2 += 1

print(min(c1, c2))

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

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

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

print(min([c1,c2]))

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

left = len([p for p in data if p < x])
right = len([p for p in data if p > x])

print(min([left,right]))

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

Solution (Python):
import bisect


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    N, M, X = get_next_ints()
    costs = get_next_ints()
    costs = sorted(costs)
    x_index = bisect.bisect(costs, X)
    left_cost = len(costs[0:x_index])
    right_cost = len(costs[x_index:])
    if left_cost < right_cost:
        print(left_cost)
    else:
        print(right_cost)
solve()

Solution (Python):
n,m,x=[int(i) for i in input().split()]
a=[int(i) for i in 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 = [int(a) for a in input().split()]
SUM = 0
i = 0

while(A[i] < X):
    SUM += 1
    i += 1

print(min(SUM, M - SUM))

Solution (Python):
a, b, x = map(int, input().split())
array = [int(x) for x in input().split()]

tmp = 0
tmp2 = 0
for i in range(1, x+1):
    if i in array:
        tmp +=1

for j in range(x, a+x):
    if j in array:
        tmp2 += 1

print(min(tmp, tmp2))

Solution (Python):
N, M, X = map(int, input().split())
a = list(map(int, input().split()))
c = 0
for x in range(X, N):
    if x in a:
        c += 1
if c >= M / 2:
    print(M - c)
else:
    print(c)

Solution (Python):
a, b, c = map(int, input().split())
a = [int(i) for i in input().split()]

small = 0
large = 0

for i in range(len(a)):
	if c > a[i]:
		small += 1
	if c < a[i]:
		large += 1

if small >= large:
	print(large)
else:
	print(small)

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

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

P = 0
Q = 0

for j in range(X):
    if j in A:
        P += 1

for k in range(N-X):
    if k + X + 1  in A:
        Q += 1

print(min(P, Q))

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

Solution (Python):
line = list(map(int,input().split()))
cost = list(map(int,input().split()))
costl = 0
costr = 0
for i in range(line[1]):
    if cost[i] < line[2]:
        costl += 1
    if cost[i] > line[2]:
        costr += 1
print(min(costr,costl))

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

k = sum(ai<x for ai in a)
j = sum(ai>x for ai in a)
print(min(k,j))

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


chkptList = list(map(int,input().split()))
TollToOrigin = 0
TollToN = 0
for i in range(X):
    TollToOrigin += chkptList.count(i)
for i in range(X,N):
    TollToN += chkptList.count(i)

print(min(TollToOrigin, TollToN))

Solution (Python):


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

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

cost_0 = 0
cost_n = 0

for i in a:
    if i < x:
        cost_0 += 1
    if i > x:
        cost_n += 1

print(min(cost_0, cost_n))

Solution (Python):
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M, X] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    input_raw = read_func().strip().split()
    A = set([])
    for i in range(M):
        A.add(int(input_raw[i]))
    to_zero_cost = 0
    for i in range(X , -1, -1):
        if i in A:
            to_zero_cost += 1
    to_N_cost = 0
    for i in range(X , N + 1):
        if i in A:
            to_N_cost += 1
    print min(to_N_cost, to_zero_cost)

if __name__ == '__main__':
    main()

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

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

totalUp = 0
i = x


while i!=n:
    if i in a:
        totalUp+=1
    i+=1

totalDown = 0

i = x
while i!=0:
    if i in a:
        totalDown+=1
    i-=1

print(min(totalUp,totalDown))

Solution (Python):
def min_toll(x, n, tolls):
    toll_to_0 = toll_to_n = 0
    for i in range(1, x):
        toll_to_0 += i in tolls
    for i in range(x + 1, n + 1):
        toll_to_n += i in tolls
    return min(toll_to_0, toll_to_n)


if __name__ == '__main__':
    n, _, x = map(int, input().split())
    tolls = list(map(int, input().split()))
    print(min_toll(x, n, tolls))

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

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

print(min(sum(cost[:X - 1]), sum(cost[X - 1:])))

Solution (Python):





if __name__ == '__main__':
    from bisect import bisect_left

    n, m, x = list(map(int, input().split()))
    a = list(map(int, input().split()))
    low = bisect_left(a, x)
    print(min(len(a[:low]), len(a[low:])))

Solution (Python):
n, m, x = map(int, raw_input().split())
a = map(int, raw_input().split())
l = map(lambda i: 1 if i in a else 0, xrange(n+1))
print min(sum(l[:x]), sum(l[x:]))

Solution (Python):
import bisect

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

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

main()

Solution (Python):
N,M,X=map(int,input().split())
A=[None]*M
A=list(map(int,input().split()))
lowNum=sum(x>X for x in A)
cost=min(lowNum, M - lowNum)
print(cost)

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

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

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

Solution (Python):
def main():
    N, M, X = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]
    
    upside_cost = sum(i > X for i in A)
    downside_cost = sum(i < X for i in A)
    
    if(upside_cost < downside_cost):
        print(upside_cost)
    else:
        print(downside_cost)
        
if __name__=="__main__":
    main()

Solution (Python):
import sys
if __name__ == "__main__":
    N, M, X = list(map(int, (input().split(' '))))
    A = list(map(int, (input().split(' '))))
    cost = [0 for i in range(N+1)]
    ans1 = 0
    ans2 = 0
    for i in range(N+1):
        if i in A:
           cost[i] = 1
    for i in range(X, -1, -1):
        ans1 += cost[i]
    for i in range(X, N+1):
        ans2 += cost[i]
    if ans1 < ans2:
        print(ans1)
    else:
        print(ans2)

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

c = 0
while a[c] < x:
    c += 1
print(min(c, m - c))

Solution (Python):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
j = m
for i in a:
    if i > x:
        j = a.index(i)
        break
c = min(j, m-j)

print(c)

Solution (Python):
n,m,x = map(int,input().split())
li = list(map(int,input().split()))
costto0=0
costton=0
for an in li:
    if  an < x:
        costto0 = costto0+1
    else:
        costton = costton+1
print(min(costto0,costton))

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

bi = bisect_left(a, x)
ci = m - bisect_left(a, x)
if bi < ci:
    print(bi)
else:
    print(ci)

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

cnt=0
i=0

while A[i]<X:
    cnt+=1
    i+=1

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

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

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

b = sum(i < x for i in a)

if  b <= m - b:
    print(b)
else:
    print(m - b)

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

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


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

print min(cost1,cost2)

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

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

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

if count * 2 > M:
    print(M-count)
else:
    print(count)

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

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

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

back,go = 0,0

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

Solution (Python):



N,M,X=map(int,input().split())
Mlist=list(map(int,input().split()))
Nlist=[0]*N
for a in Mlist:
  Nlist[a]=1

a=sum(Nlist[X:])
b=sum(Nlist[:X])
print(min([a,b]))

Solution (Python):
if __name__ == '__main__':
    N, M, X = map(int, input().split())
    N, M, X = N - 1, M - 1, X - 1
    A = [A_i - 1 for A_i in map(int, input().split())]

    to_zero = len([A_i for A_i in A if A_i < X])
    to_N = len([A_i for A_i in A if X < A_i])

    print(min(to_zero, to_N))

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

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

lower_count = 0
larger_count = 0
for a in A:
    if a > x:
        larger_count += 1
    elif a < x:
        lower_count += 1
if lower_count < larger_count:
    print(lower_count)
else:
    print(larger_count)

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

for a in A:
    if a > x:
        break
    count += 1
    
print(min(count,len(A)-count))

Solution (Python):
N, M, X = (int(x) for x in input().split())
A = tuple(int(x) for x in input().split())
count = 0
for a in A:
 if a > X:
  break
 count += 1
print(min(count, M-count))

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

cost_l = 0
cost_r = 0
left = True

for ai in A:
    if left:
        if ai > X:
            left = False
            cost_r += 1
            continue
        cost_l += 1
    else:
        cost_r += 1

print(min(cost_l, cost_r))

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
for i in masu:
    if(i > x):
        max2 += 1
if max1 >= max2:
    print(max2)
else:
    print(max1)

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

N,M,X = int(N),int(M),int(X)

costN = 0

x = X 
while x <= N:
    if str(x) in A:
        costN += 1
    x += 1 

cost0 = 0
x = X
while 0 <= x:
    if str(x) in A:
        cost0 += 1
    x -= 1


print(min(costN, cost0))

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

A.append(X)
A.sort()

i = A.index(X)
left = len(A[:i])
right = len(A[i+1:])

print(min(left, right))

Solution (Python):
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c1 = 0
c2 = 0
for i in range(len(b)):
    if b[i] < a[2]:
        c1 = c1 + 1
for i in range(len(b)):
    if b[i] > a[2]:
        c2 = c2 + 1
print(min(c1, c2))

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

    for i in range(M):
        if A[i] > X:
            pos = i
            break
        else:
            pos = M

    print(min(pos, M - pos))

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

i = 0
left_fee = 0
while fee[i] < X:
    left_fee += 1
    i += 1

print(min(left_fee, len(fee) - left_fee))

Solution (Python):



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

S1 = 0
S2 = 0
for A in As:
    if A < X:
        S1 += 1
    else:
        S2 += 1

print(min(S1, S2))

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

ncount = 0
xcount = 0

for i in A:
    if x > i:
        ncount += 1
    elif x < i:
        xcount += 1

print(min(ncount, xcount))

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):
n,m,x = list(map(int,input().split()))
alst = list(map(int,input().split()))
r = 0
l = 0
for a in alst:
  if x < a:
    r += 1
  elif x > a:
    l += 1
print(min(r,l))

Solution (Python):
N, M, X = map(int, input().split())
Gates = [0] * (N+1)
G = list(map(int, input().split()))
for g in G:
    Gates[g] = 1

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

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

tmp=[0]*(n+1)
for i in range(n):
    if i in a:
        tmp[i]=1

tmpa,tmpb=0,0

for i in range(x):
    tmpa+=tmp[i]
for i in range(x,n+1):
    tmpb+=tmp[i]
print(min(tmpa,tmpb))

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n,m,x = na()
a = na()

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

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

print(min(cost0,cost1))

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

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




c0 = 0
c1 = 0

for i in range(n):
    if i < x:
        if i in a:
            c0 += 1
    if i > x:
        if i in a:
            c1 += 1

result = min(c0, c1)
print(result)

Solution (Python):
def min(a,b):
    if a < b:
        return a
    else:
        return b
n,m,x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
right = 0
left = 0

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

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

print(min(right, left))

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

cost1 = len(list(filter(lambda x: x in range(0, X), A[:])))
cost2 = len(list(filter(lambda x: x in range(X, N + 1), A[:])))

print(min(cost1, cost2))

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

cost1 = cost2 = 0

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

print(min(cost1, cost2))

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

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

Solution (Python):
def abc094B():
    n = input().split()
    n = list(map(int, n))
    a = input().split()
    a = list(map(int, a))
    count = 0
    for i in a:
        if n[2] > i:
            count += 1
    print(min(count, n[1] - count))


abc094B()

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

bk = 0
fr = 0

for i in range(m):
    if a[i] < x:
        bk += 1
    elif (x < a[i]) and (a[i] < n):
        fr += 1
print(min(bk, fr))

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

for i in range(M):
  Ans[A[i]-1]=1
ans=min(sum(Ans[X:]),sum(Ans[:X]))
print(ans)

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

Solution (Python):



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

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

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

Solution (Python):
import sys

n, m, x = list(map(lambda x: int(x), sys.stdin.readline().strip().split(" ")))
a = list(map(lambda x: int(x), sys.stdin.readline().strip().split(" ")))

cost1 = 0
cost2 = 0

for p in a:
    if p < x:
        cost1 += 1
    else:
        cost2 += 1
print(str(min(cost1, cost2)))

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

Asmall = [i for i in A if i < X]
Alarge = [i for i in A if i > X]

print(min(len(Asmall), len(Alarge)))

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

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

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

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

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

toll = []
for i in range(n):
    if i in a:
        toll.append(1)
    else:
        toll.append(0)
print(min(sum(toll[:x]), sum(toll[x:])))

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

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, input().rstrip().split()) 
A=list(map(int, input().rstrip().split())) 
work1=[]
work2=[]
for i in range(len(A)):
    if A[i]<X:
        work1.append(A[i])
    else:
        work2.append(A[i])
print(min(len(work1),len(work2)))

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

Solution (Python):
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        
        return input()

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(3)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(
                    int,
                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]


def solve():
    n, m, x = IO_for_Contest.read_n_int(3)
    a = IO_for_Contest.read_n_int(m)
    cost = [0] * (n + 1)
    for e in a:
        cost[e] = 1
    left = sum(cost[0:x])
    right = sum(cost[x:len(cost)])
    print(min(left, right))

if __name__ == '__main__':
    
    solve()

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

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

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

print(min(num1, num2))

Solution (Python):
N, M, X = list(map(int, input().split()))
A = list(map(int, input().split()))
sumA = len(A)
sum_left = len([a for a in A if a < X])
print(min(sumA - sum_left, sum_left))

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

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

cost1 = 0
cost2 = 0
for i in A_LIST:
    if i > X:
        cost1 += 1
    elif i < X:
        cost2 += 1

print(min(cost1, cost2))

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

b=[i for i in a if i<x]
c=[i for i in a if i>x]
if len(b)<=len(c):
    print(len(b))
else:
    print(len(c))

Solution (Python):
def inpl(): return list(map(int, input().split()))
N, M, X = inpl()
A = inpl()
c0, cN = 0, 0
for i in range(X):
    if i in A:
        c0+=1
for i in range(X, N):
    if i in A:
        cN+=1
print(min(c0, cN))

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

cost1 = set(range(X)) & A_set
cost2 = set(range(X, N)) & A_set

print(min(len(cost1), len(cost2)))

Solution (Python):
d = list(map(int, input().split()))
a = list(map(int, input().split()))

n = d[0]
m = d[1]
x = d[2]

costl  = 0
costh  = 0
for i in range(m):
    if a[i] < x:
        costl += 1
    elif x < a[i]:
        costh += 1
    else:
        costl += 0

print(min(costl,costh))

Solution (Python):
n,m,x=list(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(left,right))

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

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

left = 0
for ai in A:
    if X > ai:
        left += 1
    else:
        break
right = M - left
print(min(left, right))

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

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

for i in A:
    if i < X:
        costL += 1
    else:
        costR += 1
print(min(costL,costR))

Solution (Python):
N,M,X = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
a = [0]*(N+1)
for e in A:
  a[e]+=1
tmp1=sum(a[:X])
tmp2=sum(a[X:])
print(min(tmp1,tmp2))

Solution (Python):
nmx = input().split()
n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])
a = input().split()
for i in range(m):
    a[i] = int(a[i])
    
cl = 0
cr = 0

for i in range(n):
    if i in a:
        if i < x:
            cl += 1
        else:
            cr += 1

print(min(cl,cr))

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

left = count
right = len(a) - count

print(min(right, left))

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

a.sort()

left = 0
right = 0

for q in a:
  if q > x:
    left += 1
  elif q < x:
    right += 1
print min([left,right])

Solution (Python):
n,m,x = map(int,input().split())
lis = list(map(int,input().split()))
cou = 0
co = 0
for i in range(x,n+1):
	if i in lis:
		cou += 1
for k in range(x):
	if k in lis:
		co += 1
print(min(cou,co))

Solution (Python):
tmp = list(map(int,input().split()))
N , M , X = tmp[0], tmp[1],tmp[2]
As = list(map(int,input().split()))
c0 = sum([bool(i<X) for i in As])
cs = M-c0
print(min(c0,cs))

Solution (Python):
n, m, x = map(int, input().split())
A = map(int, input().split())
forword = 0
back = 0
for i, a in enumerate(A):
    if a < x:
        forword += 1
    else:
        back += 1

print(min(forword, back))

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

Solution (Python):
n,m,x=[int(k) for k in raw_input().split(" ")]
a=[int(k) for k in raw_input().split(" ")]
b,o=0,0
for k in a:
    if k<x:
        b+=1
    else:
        o+=1

print min(o,b)

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

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

left = 0
right = 0

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

print(min(left, right))