Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split(' '))
min_num = 100

ls = [0] * 201
for i in range(0, 201):
    ls[i] = i

ls_in = [0] * n
if n > 0:
    ls_in = list(map(int, input().split(' ')))
    for i in ls_in:
        ls.remove(i)
    ls.reverse()
    for i in ls:
        min_num = min(abs(x-i), min_num)
        if abs(x-i) == min_num:
            ans = i 
    print(ans)
else:
    print(x)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('03_C - Forbidden List.txt', 'r')
sys.stdin = f

X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
                rst = i
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
print(rst)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff = -1
    for i in range(101, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff =  abs(X - i)
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X - i):
                    rst = i
    print(rst)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    P_ls.sort(reverse=True)
    diff = -1
    for i in range(100, -1, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X-i):
                    rst = i
    print(rst)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    P_ls.sort(reverse=True)
    diff = -1
    for i in range(100, 0, -1):
        if i not in P_ls:
            if diff == -1:
                diff = abs(X - i)
            else:
                diff = min(diff, abs(X - i))
                if diff == abs(X-i):
                    rst = i
    print(rst)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split(' '))
min_num = 100

ls = [0] * 100
for i in range(0, 100):
    ls[i] = i+1

ls_in = [0] * n
if n > 0:
    ls_in = list(map(int, input().split(' ')))
    for i in ls_in:
        ls.remove(i)
    ls.reverse()
    for i in ls:
        min_num = min(abs(x-i), min_num)
        if abs(x-i) == min_num:
            ans = i 
    print(ans)
else:
    print(x)