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



Sample input:
5 3 3
1 2 4


Sample output:
1

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!python
# -*- coding: utf-8 -*-

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# print(n,m,x)
# print(a)

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:])))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:]))

Submission status: Accepted

Solution code:
N, M, X,=map(int, input().rstrip().split()) #input parameters
A=list(map(int, input().rstrip().split())) #input parameters
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)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_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__':
    # doctest.testmod()
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
d=list(map(int,input().split()))
e=0
f=0
for i in range(b):
  if d[i]>c:
    e=e+1
  if d[i]<c:
    f=f+1
if e>f:
  print(f)
else:
  print(e)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    ans = 0
    for i in range(X-1, 0, -1):
        if i in A:
            ans += 1
    c = 0
    for i in range(X+1, N):
        if i in A:
            c += 1
    if ans > c:
        ans = c
    print(ans)


    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
a=list(map(int,input().split()))
cnt1, cnt2 = 0, 0
for i in range(x):
  if a[i] <= x:
    cnt1 += 1
for j in range(x, n):
  if x <= a[i] <= n:
    cnt2 += 1
print(min(cnt1 -1, cnt2 -1))

Submission status: Runtime Error

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

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

# ゴールするまでにかかるコストの最小値
print(min(sum1, sum2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
a = [int(input()) for in range(M)]
count_low = 0
count_high = 0
for i in range(a):
  if a[i-1]<X:
    count_low +=1
for i in range(a):
  if a[i-1]>X:
    count_high +=1
print(min(count_low,count_high))

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
a = [int(input()) for in range(M)]
count_low = 0
count_high = 0
for i in range(M):
  if a[i-1]<X:
    count_low +=1
for i in range(M):
  if a[i-1]>X:
    count_high +=1

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
an1 = 0
an2 = 0
nu = 0
for i in range(1,X):
    if i == li[nu]:
        an1 += 1
        nu += 1
for i in range(X+1,N):
    if i == li[nu]:
        an2 += 1
        nu += 1
if an1 > an2:
    print(an2)
else:
    print(an1)

Submission status: Runtime Error

Solution code:
N,M,X = map(int, input().split())
li = list(map(int, input().split()))
an1 = 0
an2 = 0
nu = 0
for i in range(1,X+1):
    if i == li[nu]:
        an1 += 1
        nu += 1
for i in range(X+1,N):
    if i == li[nu]:
        an2 += 1
        nu += 1
if an1 > an2:
    print(an2)
else:
    print(an1)

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
a = map(int, input().split())
print(min(sum([1 for i in a if i>x]),sum([1 for i in a if i<x]))

Submission status: Runtime Error

Solution code:
n,m,x,*a=map(int,open(0).read().split());print(min(c:=sorted(a).index(x),m-c))

Submission status: Runtime Error

Solution code:
import math

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

pits = []

cost = 0

for i in range(0, N+1):
    pits.append(i)

half = int(len(pits) / 2)


if X == half:
    cost_r = 0
    cost_l = 0
    for a in A:
        # 右側
        if X < a:
            cost_r += 1
        # 左側
        if X > a:
            cost_l += 1
    cost = min(cost_l, cost_r)
elif half < X:
    for a in A:
        if X < a:
            count += 1
else:
    for a in A:
        if X > a:
            count += 1

print(cost)

Submission status: Runtime Error

Solution code:
import math

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

pits = []

cost = 0

for i in range(0, N+1):
    pits.append(i)

half = int(len(pits) / 2)


# 真ん中
if X == half:
    cost_r = 0
    cost_l = 0
    for a in A:
        # 右側
        if X < a:
            cost_r += 1
        # 左側
        if X > a:
            cost_l += 1
    cost = min(cost_l, cost_r)
# 右側
elif half < X:
    for a in A:
        if X < a:
            count += 1
# 左側
else:
    for a in A:
        if X > a:
            count += 1

print(cost)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def actual(N, M, X, A):
    # マスXの左右それぞれにある料金所の数を調べればOK
    toll_gates_left = [a_i for a_i in A if a_i < X]
    toll_gates_right = [a_i for a_i in A if X < a_i]

    return min(len(toll_gates_left), len(toll_gates_right))

N, M, X = map(int, input().split())
A = [int(input()) for _ in range(N + 1)]

print(actual(N, M, X, A))

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
d=list(map(int, input().split())
d.append(c)
d.sort()
print(min(d.index(c), len(d)-d.index(c)-1))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
nums=[0]*(n+1)
indices=list(map(int,input().split()))
for i in indices:
    nums[i]=1
print(min(num[:x].count(1),nums[x:].count(1)))

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

if max(a) <= x or min(a) >= x:
    print(0)
    exit(1)

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

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

print(min(cost_0, cost_n))

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cost_0, cost_n = 0, 0

if max(a) <= x or min(a) >= x:
    print(0)
    exit(1)

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

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

print(min(cost_0, cost_n))

Submission status: Runtime Error

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

# xは最初の位置
# nは目的地
# aは料金所（コスト1）

cost = 0
cost2 = 0

for i in range(len(a)):
  if a[i] > x and a[i] < n:
    cost += 1
for j in range(x):
  if a[j] > 0 and a[j] < x :
    cost2 += 1
    
if cost < cost2:
  print(cost)
else:
  print(cost2)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
la=list(map(int,input().split()))
n,m,x=map(int,input().split())
la=list(map(int,input().split()))
count1=0
count2=0
while x>=0:
    for i in la:
        if x==i:
            count1+=1
    x-=1
while x<=n:
    for i in la:
        if x==i:
            count2+=1
    x+=1
if count2>count1:
    print(count1)
else:
    print(count2)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def f10():
    N, M, X=map(int, input().split())
    A=[int(i)-1 for i in input().split()]
    X = X-1
    s=sum(A[i]<X for i in A)
    print(min(s, M-s))

def main():
    f10()

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)

Submission status: Runtime Error

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

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  else:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
else:
  print(count_low)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

left = 0
right = 0

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

Submission status: Runtime Error

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

left = 0
right = 0

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

Submission status: Runtime Error

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

left = 0
right = 0

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

Submission status: Runtime Error

Solution code:
n,m,x = map(int, input().split())
arr = list(map(int,input().split()))
i = 0
while arr[i] < x:
  i += 1

print(min(len(arr)-i, i)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
a=[int(input()) for i in range(m)]
cnt=0
for i in range(m):
  if x<a[i]:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
a=[int(input())>x for i in range(m)]
print(a.count(True))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
a=[int(input())>x for i in range(m)]
print(sum(a))

Submission status: Runtime Error

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

keep=0
hidari=1
while keep<x:
  keep=a[hidari]
  hidari+=1

keep=10*100
migi=-1
while keep>x:
  keep=a[migi]
  migi-=1
  
print(min([hidari-1,-migi-2]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(m):
    if a[i] > x:
        break
    y = i+1
for i in range(m):
    if a[-1-i] < x:
        break
    z = i+1
print(min([m-y,m-z]))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M,X=map(int, input().split())
A=list(map(int, input().split()))
print(min([len([1 for a in A if a>X]),len([1 for a in A if a<X])])

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
n_list = [map(int,input().split())]
ans = 0
for i in n_list:
  if i >=c and i <=a:
    ans+=1
    
print(ans)