Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(-1000, 1000)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0, x):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break


print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0, x):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break


print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda x: x not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda x: x not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)