Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline

x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    a=0
    d=0
    while a==0:
        if x-d in p:
            if x+d in p:
                d+=1
            else:
                a=x+d
        else:
            a=x-d
    print(a)

Fixed submission:
import sys
input=sys.stdin.readline
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    d=0
    while True:
        if x-d in p:
            if x+d in p:
                d+=1
            else:
                a=x+d
                break
        else:
            a=x-d
            break
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    a=0
    d=0
    while a==0:
        if x-d in p:
            if x+d in p:
                d+=1
            else:
                a=x+d
        else:
            a=x-d
    print(a)

Fixed submission:
import sys
input=sys.stdin.readline
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=list(map(int,input().split()))
    d=0
    while True:
        if x-d in p:
            if x+d in p:
                d+=1
            else:
                a=x+d
                break
        else:
            a=x-d
            break
    print(a)

Buggy python submission (verdict: Runtime Error):
x,n = map(int,input().split())
if n == 0:
    print(x)
p = list(map(int,input().split()))

num1 = x

for i in range(n):
    num1 += 1
    if num1 not in p:
        dif1 = num1- x
        break

num2 = x
for k in range(n):
    num2 -= 1
    if num2 not in p:
        dif2 = x - num2
        break

if dif1 > dif2:
    print(num2)
elif dif1 < dif2:
    print(num1)
elif dif1 == dif2:
    print(num2)


Fixed submission:
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))
    
    if x not in p:
        print(x)
    else:

        num1 = x

        for i in range(n):
            num1 += 1
            if num1 not in p:
                dif1 = num1- x
                break

        num2 = x
        for k in range(n):
            num2 -= 1
            if num2 not in p:
                dif2 = x - num2
                break

        if dif1 > dif2:
            print(num2)
        elif dif1 < dif2:
            print(num1)
        elif dif1 == dif2:
            print(num2)

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

p = list(map(int,input().split()))

num1 = x

for i in range(n):
    num1 += 1
    print(num1 in p)
    if num1 not in p:
        dif1 = num1- x
        break

num2 = x
for k in range(n):
    num2 -= 1
    if num2 not in p:
        dif2 = x - num2
        break

if dif1 > dif2:
    print(num2)
elif dif1 < dif2:
    print(num1)
elif dif1 == dif2:
    print(num2)


Fixed submission:
x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))
    
    if x not in p:
        print(x)
    else:

        num1 = x

        for i in range(n):
            num1 += 1
            if num1 not in p:
                dif1 = num1- x
                break

        num2 = x
        for k in range(n):
            num2 -= 1
            if num2 not in p:
                dif2 = x - num2
                break

        if dif1 > dif2:
            print(num2)
        elif dif1 < dif2:
            print(num1)
        elif dif1 == dif2:
            print(num2)