Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    if n==0:
        print(x)
        sys.exit()
    P=list(map(int,input().split()))
    set_P=set(range(101))
    set_P-=set(P)
    P=list(set_P)
    P.sort()
    p_left,p_right=-10,1000
    for p in P:
        if p>=x:
            P_right=p
            break
        P_left=p
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    if n==0:
        print(x)
        sys.exit()
    P=list(map(int,input().split()))
    set_P=set(range(101))
    set_P-=set(P)
    P=list(set_P)
    P.sort()
    for p in P:
        if p>=x:
            P_right=p
            break
        P_left=p
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    PP=list(map(int,input().split()))
    P=[]
    if n==0:
        print(x)
        sys.exit()
    for xx in range(101):
        if xx in PP:continue
        P.append(xx)
    for i,p in enumerate(P[:-1]):
        if p>=x:
            P_right=p
            break
        P_left=p
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    PP=list(map(int,input().split()))
    P=[]
    for xx in range(101):
        if xx in PP:continue
        P.append(xx)
    P_left=P[bisect_left(P,x)-1]
    P_right=P[bisect_left(P,x)]
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    PP=list(map(int,input().split()))
    P=[]
    cunt=0
    for xx in range(101):
        if xx in PP:continue
        P.append(xx)
        cunt+=1
    P_left=P[max(bisect_left(P,x)-1,0)]
    P_right=P[bisect_left(P,x)]
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()