Buggy python submission (verdict: Runtime Error):
n, m, x = map(int, input().split())
a = list(map(int, input().split()))

cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Fixed submission:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
b = range(x-1,0,-1)
for i in b:
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Fixed submission:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int,input().split())
a = list(map(int,input().split())

#leftto0
cost_left = 0
b = range(x-1,0,-1)
for i in b:
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Fixed submission:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int,input().split())
a = list(map(int,input().split())

#leftto0
cost_left = 0
b = range(0,x)
B = b.reverse()
for i in B:
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Fixed submission:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Buggy python submission (verdict: Runtime Error):
n, m, x = map(int,input().split())
a = list(map(int,input().split())

#leftto0
cost_left = 0
for i in range(0,x).reverse:
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, N):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))

Fixed submission:
n, m, x = map(int,input().split())
a = list(map(int,input().split()))

#leftto0
cost_left = 0
for i in range(x-1,0,-1):
    if i in a:
        cost_left+= 1
    
#right_to_N
cost_right = 0
for i in range(x+1, n):
    if i in a:
        cost_right+= 1
    
print(min(cost_left, cost_right))