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: Runtime Error

Solution code:
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
week=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod_,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod_-2,mod_)*pow(fac[r],mod_-2,mod_))%mod_
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
#################################### ########
# coding: utf-8
import re
import math
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
###################################################
def main():
    n,m,x=map(int,input().split())
    A=list(map(int,input().split()))
    ans=[0,0]
    for a in range(x,n+1):
      if a in A:
        ans[0]+=1
    for a in range(0,x+1):
      if A.find(a):
        ans[1]+=1
    print(min(ans))


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

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

print(min(len(l), M - len(l)))

Submission status: Runtime Error

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

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

print(min(len(l), len(r)))

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
right = 0
left = 0
for i in range(X, N):
    if i in A:
        right += 1
for i in range(0, X+1):
    if i in B:
        left += 1
print(min(right,left))

Submission status: Runtime Error

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

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

print(min(before,after))

Submission status: Runtime Error

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

ans = 0

for i in x:
  if str(i) in a:
    ans += 1

print(min(ans, m-ans))

Submission status: Runtime Error

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

ans = 0

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

print(min(ans, m-ans))

Submission status: Runtime Error

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

ans = 0

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

print(min(ans, m-ans))

Submission status: Runtime Error

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

ans = 0

for i in x:
  if (i in a):
    ans = ans + 1
  else:
    continue

print(min(ans, m-ans))

Submission status: Runtime Error

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

n-x = b

for toll in b:
  if ( n + b in a):
    toll = toll + 1
else:
  print(toll)

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
S = sum(s < X for s in A)
print(min(s, N-s))

Submission status: Runtime Error

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

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

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().splist())
list=list(map(int, input().splist()))
a, b = 0,0
for i in list:
    if i<X:
        a+=1
    else:
        b+=1
print(min(a, b))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
seq = []
for _ in range(n+1):
    seq.append(0)
for i in range(m):
    seq[a[i]] = 1
print(min(seq[0:x].count(1), seq[x+1:len(seq)]))

Submission status: Runtime Error

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

def cmb(n,r):
    from operator import mul
    from functools import reduce
    
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    
    return over // under

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        min_val = 1000000001
        num_min = 0

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val:
                min_val = A[i]-num_max/2
                num_min = A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M, X=map(int, input().split())
list=[0]*(N+1)
m=list(int() for i in input().split())
for i in m:
  list[i]=1
min(sum(list.loc[0:X]), sum(list.loc(X+1:N+1)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
for i in range(M):
    list[map(int, input().split())]=1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M, X=map(int, input().split())
list=[0]*(N+1)
for i in range(M):
    list[map(int, input().split())]=1
min(sum(list.loc[0:X]), sum(list.loc(X+1:N+1)))

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
while i <= N:
  if i in A:
    cnt1 += 1
  i += 1
while i >= 0:
  if i in A:
    cnt2 += 1
  i -= 1
print(min(cnt1, cnt2))

Submission status: Runtime Error

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


def ssum(A, l, r):
    ssum = 0
    for i in range(l, r):
        ssum += A[i]
    return ssum


print(min(ssum(A, 0, X), ssum(A, X, N+1)))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
def main(n, m, x, a):
    line = [0 for _ in range(n)]

    for a in a:
        line[a - 1] = 1

    to_left = sum(line[x - 1:])
    to_right = sum(line[x - 1::-1])

    print(min(to_left, to_right))


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

    main(n, m, x, a)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
food=list(range(1,m+1))
for i in range(n):
    k,*a=map(int,input().split())
    food &= set(a)
print(len(food))

Submission status: Runtime Error

Solution code:
#include <iostream>
int main(){int n,m,x,a=0,b=0,t;std::cin>>n>>m>>x;for(int i=0;i<m;++i){std::cin>>t;(t<x?++a:++b);}std::cout<<(a<b?a:b)<<"\n";}

Submission status: Runtime Error

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

a = bisect.bisect_left(lst, M)
print(min(N-a, a)

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:
    left+=1
  else:
    rihgt+=1
print(min(left,right))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
for i in range(m):
    a=map(int,input().split())
    count1=0
    count2=0
    for b in a:
        if b<x:
            count1+=1
        else:
            count2+=1
print(min(count1,count2))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
for i in range(m):
    a=map(int,input().split())
count1=0
count2=0
for b in a:
    if b<x:
        count1+=1
    else:
        count2+=1
print(min(count1,count2))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M,X=map(int,input().split())
A+=list(input())
s=0
z=0
for j in range(M):
  if A[j]>X:
    s+=1
  elif A[j]<X:
    z+=1
print(min(s,z))

Submission status: Runtime Error

Solution code:
import bisect from bisect_left
N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
b = bisect_left(A,X)
print(min(b,N-1-B))

Submission status: Runtime Error

Solution code:
# ABC094B - Toll Gates
from bisect import bisect_left


def main():
    N, M, X, *A = map(int, open(0).read().split())
    A.sort()
    cur = bisect_left(A, x)
    ans = min(cur, M - cur)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

li = [0] * (n - 1)
for a_ele in a:
    li[a_ele] = 1

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

Submission status: Runtime Error

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

a.append(x).sort()

if len(a[:a.index(x)]) >= len(a[-(a.index(x)+1):]):
  print(len(a[-(a.index(x)+1):]))
else:
  print(len(a[:a.index(x)]))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
b=[0]*(N+1)
A=list(map(int,input().split()))
for a in A:
  b[a]=1
c=0
for i in range(x):
  c+=b[i]
print(n-c if c>=n-c else c)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
b=[0]*(N+1)
A=list(map(int,input().split()))
for a in A:
  b[a]=1
c=0
for i in range(x):
  c+=b[i]
print(c if c>=n-c else n-c)

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
b=[0]*(N+1)
A=list(map(int,input().split()))
for a in A:
  b[a]=1
c=0
for i in range(x):
  c+=a[i]
print(c if c>=n-c else n-c)

Submission status: Runtime Error

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

cnt1 = 0
cnt2 = 0

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

print(min(cnt1,cnt2))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M,X = map(int, input().split())
a = input().split()
a += str(X) 
b = sorted(a).index(str(X))
if b <= (len(a)-1-b):
    print(b)
else:
    print(len(a)-1-b)

Submission status: Runtime Error

Solution code:
N,M,X = map(int, input().split())
a = input().split()
a += str(X) 
b = sorted(a).index(str(X))
if b <= (len(a)-1-b):
    print(b)
else:
    print(len(a)-1-b)

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
l = [int(input()) for _ in range(m)]
left = 0
right = 0
i = 0
while i < x:
    if i in l:
        left += 1
    i += 1
j = n-1
while j > x+1:
    if j in l:
        right += 1
    j -= 1

print(max(left, right))

Submission status: Runtime Error

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

route=[0]*n
for i in a:
  route[i-1]=1
ans=min(sum(route[:x]),sum(route[x:]))
print(ans(

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum(a[:a.index(x)+1]), sum(a[a.index(x)+1:])))

Submission status: Runtime Error

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

l = sum(1 if i < x else 0 for i in A)
r = m -l

print(min(l,r))

Submission status: Runtime Error

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

l = sum(1 if x < X else 0 for x in A)
r = m -l

print(min(l,r))

Submission status: Runtime Error

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

left=0
right=0

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit += 1
print(min(left,right))

Submission status: Runtime Error

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

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit =+ 1
print(min(left,right))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m, x = map(int, input().split())
c = [0] * (n + 1)
for i in (map(int, input().split())):
  c[i] = 1
print(min(sum(c[0:x], c[x:-1])))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, M, X = map(int, input().split())
tolls = list(map(int, input().split()))
gate_l = 0
for toll in tools:
  if toll > X:
    break
  gate_l += 1
print(min(gate_l, M-gate_l))

Submission status: Runtime Error

Solution code:
n,m,x=map(int,input().split())
A=[int(input()) for _ in range(m)]
start=0
goal=0
for i in range(x, n+1):
  for a in A:
    if i ==a:
      start+=1
for j in range(x):
  for a in A:
    if i ==a:
      goal+=1
print(min(start, goal))

Submission status: Runtime Error

Solution code:
N, M, X = map(int,input().split())
AL, AR = [],[]
for i in range(M):
  a = int(input())
  if a < X:
    AL.append(a)
  else:
    AR.append(a)
    
print(min(len(AL),len(AR)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n, m, x = map(str, input().split())
lst = [int(i) for i in input().split()]

left = 0
right = 0

for i in lst:
    if i < x:
        left += 1
    else:
        right += 1

print(min(left, right))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!

n,m,x=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort()
b=[1 for s in a if s<x]
c=sum(a)-b
print(min(b,c))

Submission status: Runtime Error

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

b = a.copy
for i in range(1,x,1):
  b = b - {i}

c = a.copy
for i in range(x+1,n,1):
  c = c - {i}

print(min(len(b),len(c)))

Submission status: Runtime Error

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

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

import bisect

l = bisect.bisect_left(a, x)

print(min(l, m-l))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a = int(input())
x = list(map(float, input().split()))
m = max(x)
M = m/2
t = 0
s = float("INF")
for i in x:
    #print(s,abs(M-i),i,M)
    if s >= abs(M-i):
        s = min(s,abs(M-i))
        t = i
print(str(int(m))+" "+str(int(t)))

Submission status: Runtime Error

Solution code:
a = int(input())
x = list(map(float, input().split()))
m = max(x)
M = m/2
t = 0
s = float("INF")
for i in x:
    print(s,abs(M-i),i,M)
    if s >= abs(M-i):
        s = min(s,abs(M-i))
        t = i
print(str(int(m))+" "+str(int(t)))

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())
print(N)
num = list(map(int, input().split()))
print(str_)
s = [i for i in num if i > X]
p = len(s)
q = M-p
if p >q:
    print(q)
else:
    print(p)

Submission status: Runtime Error

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

Submission status: Runtime Error

Solution code:
N=int(input())
L=[int(i) for i in input().split()]
L1=sorted(L)
a=L1[N//2]
b=L1[N//2-1]
for i in range(N):
  if L[i]<a:
    print(a)
  else:
    print(b)

Submission status: Runtime Error

Solution code:
N,M,X=(int(i) for i in input().split())
L=[int(input()) for i in range(M)]
a=0
b=0
for i in range(M):
  if L[i]<X:
    a+=1
  else:
    b+=1
print(min(a,b))

Submission status: Runtime Error

Solution code:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
if x == 1 or x == n:
    print(0)
else:
    for i in range(1, x):
        if len(a) != 0:
            if a[0] == i:
                ans1 += 1
                a.pop(0)
    if len(a) != 0:
        for i in range(x, n):
            if a[0] == i:
                ans2 += 1
                a.pop(0)
    ans = min(ans1, ans2)
    print(ans)

Submission status: Runtime Error

Solution code:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
if x == 1 or x == n or x == 2 or x == n-1:
    print(0)
else:
    for i in range(1, x):
        if a[0] == i:
            ans1 += 1
            a.pop(0)
    if len(a) != 0:
        for i in range(x, n):
            if a[0] == i:
                ans2 += 1
                a.pop(0)
    ans = min(ans1, ans2)
    print(ans)

Submission status: Runtime Error

Solution code:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
aa = a
if x == 1 or x == n:
    print(0)
else:
    for i in range(1, x):
        if a[0] == i:
            ans1 += 1
            a.pop(0)
    if len(a) != 0:
        for i in range(x, n):
            if a[0] == i:
                ans2 += 1
                a.pop(0)
    ans = min(ans1, ans2)
    print(ans)

Submission status: Runtime Error

Solution code:
n,m,x = map(int,input().split())
a = [int(input()) for i in range(m)]
x_s = 0
x_l = 0
for i in range(m):
    if x>a[i]:
        x_l+=1
    else:
        x_s+=1
print(min(x_s,x_l))

Submission status: Runtime Error

Solution code:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))
ans1 = 0
ans2 = 0
aa = a
for i in range(1, x):
    if a[0] == i:
        ans1 += 1
        a.pop(0)
if len(a) != 0:
    for i in range(x, n):
        if a[0] == i:
            ans2 += 1
            a.pop(0)
    

ans = min(ans1,ans2)
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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([j for j in a if i>x])))

Submission status: Runtime Error

Solution code:
K = input()
k=K.split('\n')
N,M,X=map(int, k[0].split())
A = [i for i in map(int, k[1].split())]
squares=[i for i in range(N+1)]



V=squares[X]
lowest=[]
highest =[]
for i in range(len(A)):
    if A[i]<V:
        lowest.append(A[i])
    else:
        highest.append(A[i])

if len(lowest)>len(highest):
    cost = len(highest)
else:
    cost = len(lowest)

print(cost)

Submission status: Runtime Error

Solution code:
n,b,sta=map(int,input().split())
A=list(map(int,input().split()))
Z=["F" for i in range(n+1)]
for i in A:
  A[i]="B"
fi=A[:sta:]
se=A[sta+1::]
print(min(fi.count("B"),se.count("B")))

Submission status: Runtime Error

Solution code:
n,b,sta=map(int,input().split())
A=list(map(int,input().split()))
Z=["F" for i in range(n+1)]
for i in A:
  A[i]="B"
fi=A[:n:]
se=A[n+1::]
print(min(fi.count("B"),se.count("B")))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = list(map(int,input().split()))
#検問所の入力
b=[]
c=[]
for i in range(X+1,N): #X+1からNの範囲の整数について 
  if i in a: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
  if i in a: #ある整数が検問所の整数として存在する
    c.append(1)
print(min(sum(b),sum(c))

Submission status: Runtime Error

Solution code:
N,M,X = map(int,input().split())
a = list(map(int(input().split())))
b = []
c = []
for i in range(0,X):
  if i in a:
    b.append(1)
for i in range(X+1,N):
  if i in a:
    c.append(1)
print(min(sum(b),sum(c)))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
array = [map(int,input().split())]
#検問所の入力
b=[]
c=[]
while X+1 <= i <= N: #X+1からNの範囲の整数について 
  if i in array: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
  if i in array: #ある整数が検問所の整数として存在する
    c.append(1)
print(sum(c))

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X:N): #XからNの範囲の整数について 
  if i in a is True: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1:X): #1からX-1の範囲の整数について
  if i in a is True: #ある整数が検問所の整数として存在する
    c.append(1)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X:N): #XからNの範囲の整数について 
  if i in a is True: #ある整数が検問所の整数として存在する
    b.append(1)

for i in range(1:X): #1からX-1の範囲の整数について
  if i in a is True: #ある整数が検問所の整数として存在する
    c.append(1)
    
print(min(sum(b),sum(c))) #リストb,cの要素の和のうちいずれか小さいほうを出力

Submission status: Runtime Error

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