ZhenlongDai/ACPR huggingface dataset:
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X,N=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
ans1=100
for i in range(1,101):
    if i in p:
        a=p.pop(0)
        continue
    A=abs(X-i)
    if ans1>A:
        ans1=A
        ans=i
    elif ans1==A:
        ans=min(ans,i)
    else:
        break
print(ans)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X,N=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=0
ans1=X
for i in range(1,102):
    if i in p:
        a=p.pop(0)
        continue
    A=abs(X-i)
    if ans1>A:
        ans1=A
        ans=i
    elif ans1==A:
        ans=min(ans,i)
    else:
        break
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X,N = map(int,input().split())
P = [int(i) for i in input().split()]
ans = -1
for i in range(1,100):
    if i in P:
        pass
    else:
        if abs(X-ans) > abs(X-i):
            ans = i
print(ans) if N != 0 else print(X)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
X,N = map(int,input().split())
P = [int(i) for i in input().split()]
ans = 100000
flag = False
for i in range(-1,102):
    if i in P:
        pass
    else:
        if abs(X - ans) > abs(X-i):
            flag = True
            ans = i
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int,input().split())
p = list(map(int,input().split()))
a = x-1
b = x+1

while 1:
    if a not in p:
        ans = a
        break
        
    if b not in p:
        ans = b
        break
        
    a -= 1
    b += 1

if n == 0:
    ans = x
    
print(ans)

Failing test case input:
3 1
4 5 1 1 0

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
x,n = map(int,input().split())
p = list(map(int,input().split()))
a = x-1
b = x+1

if x not in p:
    ans = x

else:
    while 1:
        if a not in p:
            ans = a
            break

        if b not in p:
            ans = b
            break

        a -= 1
        b += 1
    
print(ans)
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x, n = map(int, input().split())

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


n = 0
ans = 0

if x == 100:
    print(100)
else:
    
    

    for i in range(1,101):
    
        
        if i in p:
            continue
            
        tmp = abs(x-i)

        if i == 1:
            n = tmp
            ans = i
        
        if tmp < n:
            n = tmp
            ans = i
        
    print(ans)

Failing test case input:
2 0
3 6 1 8 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())

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

abs_n = 0
ans = 0

if n == 0:
    print(x)
else:
    
    

    for i in range(-100,201):
    
        
        if i in p:
            continue
            
        tmp = abs(x-i)
        

        if i == -100:
            abs_n = tmp
            ans = i
        
        if tmp < abs_n:
            abs_n = tmp
            ans = i
        
    print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



X, N = map(int,input().split())
p = {int(x) for x in input().split()}


ans = 0
i = 0

while True:
    tmp = X + i
    if tmp not in p:
        ans = tmp
        break
    tmp = X - i
    if tmp not in p:
        ans = tmp
        break
    i += 1
print(ans)
    

Failing test case input:
10 5
4 7 10 6 5

Expected output:
9

Actual output:
11


Fixed submission (verdict: Accepted):
X, N = map(int,input().split())
p = {int(x) for x in input().split()}


ans = 0
i = 0

while True:
    tmp = X - i
    if tmp not in p:
        ans = tmp
        break
    tmp = X + i
    if tmp not in p:
        ans = tmp
        break
    i += 1
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
lst = list(map(int, input().split()))
i = 0
while True:
  if x + i not in lst:
    if x - i not in lst:
      print(x - i)
      exit()
    else:
      print(x + i)
      exit()
  i += 1

Failing test case input:
12 1
2 12 0 16 13

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x - i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


X, N = map(int, input().split())
P = list(map(int, input().split()))

P2 = []

for i in range(1, 101):
    if i in P:
        continue
    P2.append(i)

sa = 10**9
ret = -1
for p in P2:
    if abs(X-p) < sa:
        sa = abs(X-p)
        ret = p

print(ret)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):


X, N = map(int, input().split())
P = list(map(int, input().split()))

P2 = []

for i in range(-100, 201):
    if i in P:
        continue
    P2.append(i)
sa = 10**9
ret = -1
for p in P2:
    if abs(X-p) < sa:
        sa = abs(X-p)
        ret = p

print(ret)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int,input().split())
if N > 0:
  P = set([int(_) for _ in input().split()])
else:
  P = []
l_cand = -1
r_cand = 101

for i in range(1,X+1):
  if i not in P:
    l_cand = i
    
for i in range(100,X,-1):
  if i not in P:
    r_cand = i

diff_l = abs(l_cand - X)
diff_r = abs(r_cand - X)

if diff_l <= diff_r:
  print(l_cand)
else:
  print(r_cand)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
X, N = map(int,input().split())
if N > 0:
  P = set([int(_) for _ in input().split()])
else:
  P = set()

l_cand = None
r_cand = None
i = 0
while (l_cand is None) and (r_cand is None):
  if X - i not in P and l_cand is None:
    l_cand = X - i
  if X + i not in P and r_cand is None:
    r_cand = X + i
  i += 1
  
if l_cand is not None:
  print(l_cand)
else:
  print(r_cand)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    import sys
    X, N = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    L = []
    for i in range(1, 101):
        if not i in P:
            L.append(i)
    
    ans =1000
    ans2 = 0
    for l in L:
        if ans > abs(X-l):
            ans = abs(X-l)
            ans2 = l
    if ans2 <= X:
        print(ans2)
    else:
        print(abs(X-ans2)+X)


if __name__=='__main__':
    main()

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
def main():
    import sys
    X, N = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    
    i = 0
    while True:
        if X-i in P:
            pass
        else:
            print(X-i)
            break
        if X +i in P:
            pass
        else:
            print(X+i)
            break
        i+=1
    


if __name__=='__main__':
    main()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
  X, N = map(int, input().split())
  if N == 0:
    return X
  
  P = list(map(int, input().split()))
  
  delta = []
  for n in range(-1, 102):
    if n in P:
      delta.append(float('inf'))
    else:
      delta.append(abs(X - n))
      
  minD = min(delta)
  for i, d in enumerate(delta):
    if d == minD:
      return i + 1


print(main())

Failing test case input:
12 1
2 2 3 16 4

Expected output:
12


Actual output:
14


Fixed submission (verdict: Accepted):
def main():
  X, N = map(int, input().split())
  if N == 0:
    return X
  
  P = list(map(int, input().split()))
  
  delta = []
  for n in range(-1, 102):
    if n in P:
      delta.append(float('inf'))
    else:
      delta.append(abs(X - n))
      
  minD = min(delta)
  for i, d in enumerate(delta):
    if d == minD:
      return i - 1


print(main())
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

else:
    p = list(map(int, input().split()))
    li = [i for i in range(1, 101) if i not in p]
    li.sort(reverse = True)

    tmp1 = float('inf')
    ans = float('inf')

    for i in li:
        if abs(i - x) <= tmp1:
            if i < ans:
                ans = i
                tmp1 = abs(i - x)

    print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())

if n == 0:
    print(x)
    exit()

else:
    p = list(map(int, input().split()))
    li = [i for i in range(-101, 102) if i not in p]
    li.sort(reverse = True)

    tmp1 = float('inf')
    ans = float('inf')

    for i in li:
        if abs(i - x) <= tmp1:
            if i < ans:
                ans = i
                tmp1 = abs(i - x)

    print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(101,0,-1):
    if i not in p:
        if abs(x - i) < abs(x - ans1):
            ans1 = i
print(ans1)


Failing test case input:
10 3
1 7 10 6 5

Expected output:
9


Actual output:
11


Fixed submission (verdict: Accepted):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(101,-1,-1):
    if i not in p:
        if abs(x - i) <= abs(x - ans1):
            ans1 = i
print(ans1)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()

nun_list = list(map(int, input().split()))
answer = nun_list[0]
for i in nun_list:
    if abs(x - answer) >= abs(x - i):
        if abs(x - answer) == abs(x - i):
            if answer > i:
                answer = i
        else:
            answer = i
tmp = 0
for i in range(0,1000):
    if not nun_list.__contains__(answer -i):
        tmp = answer -i
        break
    if not nun_list.__contains__(answer + i):
        
        tmp = answer + i
        break
print(tmp)
if abs(x - tmp) <= abs(x - 0):
    print(tmp)
else :
    print(tmp)

Failing test case input:
41 3
3 0 1 45 0

Expected output:
41


Actual output:
44
44


Fixed submission (verdict: Accepted):
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()

if x == 1:
    print(0)
    sys.exit()


if n == 100:
    if x <= 50:
        print(0)
        sys.exit()
    else:
        print(101)
        sys.exit()


nun_list = list(map(int, input().split()))
answer = 0

for i in range(0, 210):
    if nun_list.__contains__(i):
        continue
    else :
        if abs(x - answer) >= abs(x - i):
            if abs(x - answer) == abs(x - i):
                if answer > i:
                    answer = i
            else:
                answer = i
if abs(x - answer) <= abs(x - 0):
    print(answer)
else :
    print(0)
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x,n=map(int,input().split())
a=list(map(int,input().split()))	

b=[]

for i in a:
  b.append(abs(i-x))

if len(b)!=0:
  m=min(b)
else:
  print(0)
  exit()
  
if m==0:
  for i in range(1,max(a)):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
    

Failing test case input:
6 2
4 7 10 8 5

Expected output:
6


Actual output:

Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
if n!=0:
  a=list(map(int,input().split()))	
else:
  print(x)
  exit()
  
b=[]

for i in a:
  b.append(abs(i-x))

m=min(b)
  
if m==0:
  for i in range(max(b)+2):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x, n = map(int, input().split())
p_str = input()

if n == 0:
    print(x)
    exit()

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

for i in range(1, 101):
    i1 = x - i
    i2 = x + i
    if i1 not in p:
        print(i1)
        break
    elif i2 not in p:
        print(i2)
        break
    else:
        continue


Failing test case input:
7 1
4 5 17 16 10

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p_str = input()

if n == 0:
    print(x)
    exit()

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

for i in range(0, 101):
    i1 = x - i
    i2 = x + i
    if i1 not in p:
        print(i1)
        break
    elif i2 not in p:
        print(i2)
        break
    else:
        continue

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 100:
    print("")
elif n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
exit()
nums = [n for n in range(1, 101) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])

Failing test case input:
15 3
7 5 3 24 11

Expected output:
15


Actual output:

Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    print(x)
    exit()
nums = [n for n in range(-1, 102) if n not in ps]

abs_plus = sorted([n-x for n in nums if n-x >= 0])
abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
if abs_plus == []:
    print(x-abs_minus[0])
elif abs_minus == []:
    print(x+abs_plus[0])
elif abs_plus[0] >= abs_minus[0]:
    print(x-abs_minus[0])
else:
    print(x+abs_plus[0])
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(x+1):
    if not(x - i - 1) in p:
        print(x - i - 1)
        exit()
    elif not(x + i + 1) in p:
        print(x + i + 1)
        exit()
print(x)

Failing test case input:
6 2
4 7 10 14 5

Expected output:
6


Actual output:
8


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(x+1):
    if not(x - i) in p:
        print(x - i)
        exit()
    elif not(x + i) in p:
        print(x + i)
        exit()
print(x)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X,N = map(int, input().split())
P = list(map(int, input().split()))

if len(P) == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue


Failing test case input:
6 2
4 7 10 8 2

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
X,N = map(int, input().split())
P = list(map(int, input().split()))

if len(P) == 0:
  print(X)
else:
  for i in range(0,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
min_diff = float('inf')
for i in range(1, 101):
    if i in a:
        continue
    if (abs(i - X) < min_diff) or (abs(i - X) == min_diff and i < ans):
        min_diff = abs(i - X)
        ans = i
print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
min_diff = float('inf')
for i in range(0, 102):
    if i in a:
        continue
    if (abs(i - X) < min_diff) or (abs(i - X) == min_diff and i < ans):
        min_diff = abs(i - X)
        ans = i
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
p = list(map(int, input().split()))

for i in range(1, 101):
    if N == 0:
        print(X)
        break
    elif p.count(X-i) == 0:
        print(abs(X-1))
        break
    elif p.count(X+i) == 0:
        print(abs(X+i))
        break


Failing test case input:
10 3
7 5 3 6 5

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
p = list(map(int, input().split()))

for i in range(1, 101):
    if N == 0:
        print(X)
        break
    elif p.count(X) == 0:
        print(X)
        break
    elif p.count(X-i) == 0:
        print(abs(X-i))
        break
    elif p.count(X+i) == 0:
        print(abs(X+i))
        break
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X = [int(a) for a in input().split()][0]
P = [int(b) for b in input().split()]

found = 0
num = 1
answer = X
while(answer == X):
  if not (X - num in P):
    answer = X - num
  elif not (X + num in P):
    answer = X + num
  num += 1
print(answer)

Failing test case input:
6 0
8 3 15 16 2

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
inp = [int(a) for a in input().split()]
X = inp[0]
N = inp[1]
if N == 0:
  print(X)
else:
  P = [int(b) for b in input().split()]

  found = 0
  num = 0
  answer = X
  while(found == 0):
    if not (X - num in P):
      found = 1
      answer = X - num
    elif not (X + num in P):
      found = 1
      answer = X + num
    num += 1
  print(answer)

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def LI():return list(map(int,input().split()))
def MI():return map(int,open(0).read().split())
def I():return int(input())
def yes():print("Yes")
def no():print("No")

from collections import deque, Counter
from heapq import heappop, heappush
INF=float("inf")




x,n=LI()
if n==0:
    print(x)
    exit()
p=LI()
p.sort()



ans=-1
tmp=INF
for i in range(0,100+2):
    if i in p:continue
    k=abs(i-x)
    if k<tmp:
        tmp=k
        ans=i


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:

Fixed submission (verdict: Accepted):
def LI():return list(map(int,input().split()))
def MI():return map(int,open(0).read().split())
def I():return int(input())
def yes():print("Yes")
def no():print("No")



INF=float("inf")




x,n=LI()
if n==0:
    print(x)
    exit()
p=LI()
p.sort()

ans=-1
tmp=INF
for i in range(-100,200):
    if i in p:continue
    k=abs(i-x)
    if k<tmp:
        tmp=k
        ans=i
    
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, x = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

Failing test case input:
36 16
0 0 16 23 8

Expected output:
36


Actual output:
15


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    ans = x
    absol = 1000

    for i in range(x + 1, 101):
        if i not in p:
            if abs(i - x) < absol:
                absol = abs(i - x)
                ans = i
                break
    for i in range(x, 0, -1):
        if i not in p:
            if abs(i - x) <= absol:
                absol = abs(i - x)
                ans = i
                break    
    print(ans)

if __name__ == '__main__':
    main()


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))

    if x not in p:
        print(x)
    else:
        off = 1
        for i in range(200):
            k = x - off
            if k not in p and -99 < k <= 200:
                print(k)
                break
            k = x + off
            if k not in p and -99 < k <= 200:
                print(k)
                break
            off += 1

if __name__ == '__main__':
    main()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if p is None or not x in p:
  print(x)
else:
  for i in range(1, n):
    if not (x - i) in p:
      print(x - i)
      break
    elif not (x + i) in p:
      print(x + i)
      break

Failing test case input:
6 2
4 7 10 6 5

Expected output:
8


Actual output:

Fixed submission (verdict: Accepted):
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if p is None or not x in p:
  print(x)
else:
  for i in range(1, n + 1):
    if not (x - i) in p:
      print(x - i)
      break
    elif not (x + i) in p:
      print(x + i)
      break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):




def main():
    x, n = map(int, input().split())
    if n > 1:
        p_set = set(map(int, input().split()))
    else:
        p_set = set()

    for i in range(101):
        if (x - i) not in p_set:
            print(x - i)
            return
        elif (x + i) not in p_set:
            print(x + i)
            return


if __name__ == '__main__':
    main()


Failing test case input:
12 1
2 12 0 16 13

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):




def main():
    x, n = map(int, input().split())
    if n >= 1:
        p_set = set(map(int, input().split()))
    else:
        p_set = set()

    print(f(x, p_set))


def f(x, p_set):
    for i in range(101):
        if (x - i) not in p_set:
            return x - i
        elif (x + i) not in p_set:
            return x + i


if __name__ == '__main__':
    main()
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
input = sys.stdin.readline



def main():
    X, N = [int(i) for i in input().strip().split()]
    p_list = [int(i) for i in input().strip().split()]

    base = list()
    for i in range(1, 101):
        if i not in p_list:
            base.append(i)

    dif = float("inf")
    ans = None
    for j in base:
        if abs(j - X) < dif:
            dif = abs(j-X)
            ans = j

    return ans


if __name__ == "__main__":
    print(main())


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline



def main():
    X, N = [int(i) for i in input().strip().split()]
    p_list = [int(i) for i in input().strip().split()]

    base = list()
    for i in range(-110, 110):
        if i not in p_list:
            base.append(i)

    dif = float("inf")
    ans = None
    for j in base:
        if abs(j - X) < dif:
            dif = abs(j-X)
            ans = j

    return ans


if __name__ == "__main__":
    print(main())

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = 0
min_dis = 10**10
ch = [0 for i in range(101)]
for i in range(len(p)):
    ch[p[i]] = 1
for i in range(1, 101):
    idx = 101-i
    if ch[idx] == 0 and abs(x-idx) <= min_dis :
        min = idx
        min_dis = abs(x-idx)
print(min)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = 0
min_dis = 10**10
ch = [0 for i in range(102)]
for i in range(len(p)):
    ch[p[i]] = 1
for i in range(102):
    idx = 101-i
    if ch[idx] == 0 and abs(x-idx) <= min_dis :
        min = idx
        min_dis = abs(x-idx)
print(min)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a = list(map(int,input().split()))
x = a[0]
if a[1] == 0 :
    print(x)
else :
    b = list(map(int,input().split()))
    retu = []
    for i in range(1,101) :
        retu.append(i)
    for i in b :
        if i in retu :
            retu.remove(i)
    print(retu)
    k = 1000
    ans = i
    for i in retu :
        y = abs(i - x)
        if y < k :
            k = y
            ans = i

    print(ans)

Failing test case input:
18 1
10 9 2 6 5

Expected output:
18


Actual output:
[1, 3, 4, 7, 8, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]
18


Fixed submission (verdict: Accepted):
a = list(map(int,input().split()))
x = a[0]
if a[1] == 0 :
    print(x)
else :
    b = list(map(int,input().split()))
    retu = []
    for i in range(0,102) :
        retu.append(i)
    for i in b :
        if i in retu :
            retu.remove(i)
    k = 1000
    ans = 0
    for i in retu :
        y = abs(i - x)
        if y < k :
            k = y
            ans = i
    print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())

if N == 0:
    print(X)
else:
    p = set(map(int, input().split()))

    num = set(range(-102, 102))

    l = list(num.difference(p))

    ans = 0
    absol = 102

    for i in l:
        a = abs(X - i)
        if a == 0:
            pass
        elif a < absol:
            absol = a
            ans = i
        else:
            pass

    print(ans) 

Failing test case input:
62 1
1 1 2 16 18

Expected output:
62


Actual output:
61


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())

if N == 0:
    print(X)
else:
    p = set(map(int, input().split()))

    num = set(range(-102, 102))

    l = list(num.difference(p))
    l.sort()

    ans = 0
    absol = 110

    for i in l:
        a = abs(X - i)
        if a < absol:
            absol = a
            ans = i
        else:
            pass

    print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 100

for i in p:
    l[i-1] =1

print(l)

diff=min(101-x,x)
ans=0 if x < 51 else 101
for i in range(100):
    if l[i] == 0 and diff > abs(x-(i+1)):
        diff= abs(x-(i+1))
        ans=i+1

print(ans)


Failing test case input:
10 3
7 2 3 6 5

Expected output:
10


Actual output:
[0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
10


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 102

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(0,102):
    if l[i] == 0 and diff > abs(x-i):
        diff= abs(x-i)
        ans=i

print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = input().split()
X = int(n[0])
N = int(n[1])

try:
    n2 = input()
except:
    pass

if N == 0:
    print(X)

else:
    n2 = n2.split()
    p = [int(item) for item in n2]

    for i in range(101):
        if i == 0:
            if X not in p:
                print(X)
        tmp = []

        if (X + i not in p ):
            tmp.append(X + i)

        if (X - i not in p ):
            tmp.append(X - i)
    
        if len(tmp)!=0:
            print(min(tmp))
            break


Failing test case input:
2 1
4 5 1 7 3

Expected output:
2


Actual output:
2
2


Fixed submission (verdict: Accepted):
n = input().split()
X = int(n[0])
N = int(n[1])

try:
    n2 = input()
except:
    pass

if N == 0:
    print(X)

else:
    n2 = n2.split()
    p = [int(item) for item in n2]

    for i in range(101):
        if i == 0:
            if X not in p:
                print(X)
                break
        tmp = []

        if (X + i not in p ):
            tmp.append(X + i)

        if (X - i not in p ):
            tmp.append(X - i)
    
        if len(tmp)!=0:
            print(min(tmp))
            break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
wks = 101
an = 0

for i in range(1,101):
    if x!=i:
        if p.count(i)==0:
            if abs(x-i)<wk:
                an =i
                wk = abs(x-i)
            else:
                print(an)
                sys.exit()
print(an)

Failing test case input:
10 3
7 2 3 6 5

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0

 
  
for i in range(102):
    
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n=map(int,input().split())

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

n=set(n for n in range(1,101))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x,n=map(int,input().split())

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

n=set(n for n in range(-100,102))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[];
if(fl!=[]):
    for a in lst:
         fl.append(int(a))
else:
    print(X)
for a in range(len(fl)):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break


Failing test case input:
6 5
3 7 10 6 5

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
l=input()
ls=l.split(" ")
X=int(ls[0])
N=int(ls[1])
lstr=input()
lst=lstr.split(" ")
fl=[]
if(N!=0):
    for a in lst:
         fl.append(int(a))
for a in range(101):
    if(X-a not in fl):
         print(X-a)
         break
    if(X+a not in fl):
         print(X+a)
         break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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


if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]


answer = min(X - minimum - 1, X - maximum + 1)
for candidate in range(minimum, maximum):
    if candidate in p: continue

    diff_answer = abs(X - answer)
    diff_candidate = abs(X - candidate)
    
    answer = candidate if diff_candidate < diff_answer else answer

print(answer)


Failing test case input:
36 16
0 0 16 23 8

Expected output:
36


Actual output:
22


Fixed submission (verdict: Accepted):
import math

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


if N == 0:
    print(X)
    exit()

p.sort()

minimum = p[0]
maximum = p[len(p) - 1]

if X < minimum or maximum < X:
    print(X)
    exit()

diff_min = abs(X - minimum - 1)
diff_max = abs(X - maximum + 1)
if diff_min == diff_max:
    answer = min(minimum - 1, maximum + 1)
else:
    answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
lis =  []
lis2 = []

if n == 0:
  print(x)
else:
  lis = list(map(int, input().split()))
  lis.sort()
  if x not in lis:
    print(x)
  else:
    y = x + 1
    z = x - 1
    while True:
      if y in lis and z in lis:
        y += 1
        z += 1
      elif y not in lis and z not in lis:
        print(z)
        break
      elif y not in lis:
        print(y)
        break
      elif z not in lis:
        print(z)
        break
  


Failing test case input:
6 5
3 7 10 6 5

Expected output:
4


Actual output:
8


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
lis =  []

if n == 0:
  print(x)
else:
  lis = list(map(int, input().split()))
  if x not in lis:
    print(x)
  else:
    y = x + 1
    z = x - 1
    while True:
      if y in lis and z in lis:
        y += 1
        z -= 1
      elif z not in lis:
        print(z)
        break
      elif y not in lis:
        print(y)
        break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if not x in p:
  print(x)
else:
  for i in range(1, n):
    if not (x - i) in p:
      print(x - i)
      break
    elif not (x + i) in p:
      print(x + i)
      break

Failing test case input:
12 1
2 12 0 16 13

Expected output:
11


Actual output:

Fixed submission (verdict: Accepted):
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

if p is None or not x in p:
  print(x)
else:
  for i in range(1, n + 1):
    if not (x - i) in p:
      print(x - i)
      break
    elif not (x + i) in p:
      print(x + i)
      break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(1,101):
    if i not in p:
        if abs(x - i) < abs(x - ans1):
            ans1 = i
print(ans1)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(101,-1,-1):
    if i not in p:
        if abs(x - i) <= abs(x - ans1):
            ans1 = i
print(ans1)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = list(map(int, input().split()))
lst = list(map(int, input().split()))

dif = float("INF")
ans = 0

for i in range(1,101):
    if i not in lst:
        if dif>abs(i-x):
            dif = abs(i-x)
            ans = i
        elif dif==abs(i-x):
            ans = min(ans,i)

print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x,n = list(map(int, input().split()))
lst = list(map(int, input().split()))

dif = float("INF")
ans = 0

for i in range(102):
    if i not in lst:
        if dif>abs(i-x):
            dif = abs(i-x)
            ans = i
        elif dif==abs(i-x):
            ans = min(ans,i)

print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n=map(int,input().split())
if n == 0:
  print(x)
else:
  list=list(map(int,input().split()))
  i=1
  while i<1000:
    if not((x-i) in list):
      print(x-i)
      break
    if not((x+i) in list):
      print(x+i)
      break
    i+=1

Failing test case input:
15 1
1 8 3 16 11

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
if n == 0:
  print(x)
else:
  list=list(map(int,input().split()))
  if not(x in list):
    print(x)
  else:
    i=1
    while i<1000:
      if not((x-i) in list):
        print(x-i)
        break
      if not((x+i) in list):
        print(x+i)
        break
      i+=1

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst: 
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst: 
        print(x + df)
        exit()
    df = -df
    df += 1

Failing test case input:
10 5
4 7 10 6 5

Expected output:
9

Actual output:
11


Fixed submission (verdict: Accepted):
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df -= 1

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
p = list(map(int, input().split()))
q = set(range(1, 100))
r = q - set(p)
max = 1000
ans = X

if N == 0:
    print(X)
else:
    for i in r:
        if abs(X - i) < max:
            max = abs(X - i)
            ans = i

    print(ans)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
p = list(map(int, input().split()))
q = set(range(-1, 102))
r = list(q - set(p))
r.sort()
max = 1000
ans = X

if N == 0:
    print(X)
else:
    for i in r:
        if abs(X - i) < max:
            max = abs(X - i)
            ans = i

    print(ans)

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x, n = map(int, input().split())
p = list(map(int, input().split()))

sa = float("inf")
ans = 0
for i in range(100, 0, -1):
    if sa >= abs(x - i) and (i not in p):
        ans = i
        sa = abs(x - i)
print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = list(map(int, input().split()))

sa = float("inf")
ans = 0
for i in range(105, -5, -1):
    if sa >= abs(x - i) and (i not in p):
        ans = i
        sa = abs(x - i)
print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
line = input().split()

num = int(line[0])
arrn = int(line[1])

if arrn==0:
  print(num)
  
else:
  arr = input().split()
  i = 1;
  
  while True:
    
    left = num - i
    if left > 0:
      if str(left) in arr:
        print("",end="")
      else:
        print(left)
        break

    
    right = num + i
    if str(right) in arr:
      print("",end="")
    else:
      print(right)
      break

    i += 1

Failing test case input:
12 1
4 4 3 16 4

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
line = input().split()

num = int(line[0])
arrn = int(line[1])

if arrn==0:
  print(num)
  
else:
  arr = input().split()
  i = 1;
  
  if str(num) in arr:
    while True:
      
      left = num - i
      if str(left) in arr:
        print("",end="")
      else:
        print(left)
        break

      
      right = num + i
      if str(right) in arr:
        print("",end="")
      else:
        print(right)
        break

      i += 1
  else:
    print(num)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int, input().split())
if n==0:
  print(x)
else:
  p = list(map(int, input().split()))
  
  for i in range(101):
    if not (x-(i+1)) in p:
      print(x-(i+1))
      break
    elif not (x+(i+1)) in p:
      print(x+(i+1))
      break


Failing test case input:
15 1
1 8 3 16 11

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
x,n = map(int, input().split())
if n==0:
  print(x)
else:
  p = list(map(int, input().split()))
  
  for i in range(101):
    if not x-i in p:
      print(x-i)
      break
    elif not x+i in p:
      print(x+i)
      break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  print(100)
  exit()
old_diff = 10000
for i in range(1, 101):
  if i in p:
    continue
  else:
    diff = abs(x-i)
    if diff < old_diff:
      ans = i
      old_diff = abs(x-i)

try:
  print(ans)
except:
  print()

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  print(100)
  exit()
old_diff = 10000
for i in range(-110, 110):
  if i in p:
    continue
  else:
    diff = abs(x-i)
    if diff < old_diff:
      ans = i
      old_diff = abs(x-i)

try:
  print(ans)
except:
  print()
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
def main():
    x, n = map(int, input().split())
    p = list(map(int,input().split()))
    
    if (n==0):
        print(x)
        sys.exit()

    for i in range(n):
        low = x - i
        if (low not in p):
            print(low)
            sys.exit()
            
        up = x + i
        if (up not in p):
            print(up)
            sys.exit()
    
main()


Failing test case input:
3 2
4 2 1 8 3

Expected output:
5


Actual output:

Fixed submission (verdict: Accepted):
import sys
def main():
    x, n = map(int, input().split())
    p = list(map(int,input().split()))

    if (n == 0):
        print(x)
    else:
        for i in range(100):
            low = x - i
            if (low not in p):
                print(low)
                sys.exit()
            up = x + i
            if (up not in p):
                print(up)
                sys.exit()
                
main()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

x, n = map(int, input().split())
p = list(map(int, input().split()))
list_p = [i for i in range(-1, 102)] 
t = x
num = x

if(x == n):
  print(x - 1)
  sys.exit()

for i in p:
  list_p[i + 1] = -2

for i in range(len(list_p)):
  if(list_p[i] == -2):
    continue
  else:
    if(abs(list_p[i] - x) <= t):
      t = abs(list_p[i] - x)
      num = min(num, list_p[i])

print(num) 


Failing test case input:
12 1
2 2 3 16 4

Expected output:
12


Actual output:
0


Fixed submission (verdict: Accepted):
import sys

x, n = map(int, input().split())
p = list(map(int, input().split()))
list_p = [i for i in range(-1, 102)] 
t = x
num = x

for i in p:
  list_p[i + 1] = -2

for i in range(len(list_p)):
  if(list_p[i] == -2):
    continue
  else:
    if(abs(list_p[i] - x) <= t):
      if(abs(list_p[i] - x) < t):
        t = abs(list_p[i] - x)
        num = list_p[i]
      elif(abs(list_p[i] - x) == t):
        t = abs(list_p[i] - x)
        num = min(num, list_p[i])
print(num)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(1,n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break


Failing test case input:
15 3
7 5 3 16 8

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x, n = input().split()
x = int(x)
n = int(n)
m = list(map(int,input().split()))
sa = 999
ans = 0

if x in m:
    print(x)
    exit()
elif len(m) == 0:
    exit()

for k in range(1,n):
    if m.count((x - k)) == 0 and x - (x - k) < sa:
        sa =  x - (x - k)
        ans = x - k

for l in range(1,100):
    if m.count((x + l)) == 0 and (x+l) - x < sa:
        sa = (x+l) - x
        ans = x + l

print(ans)

Failing test case input:
6 0
4 3 26 16 4

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
x, n = input().split()
x = int(x)
n = int(n)
m = list(map(int,input().split()))
sa = 999
ans = 0

if m.count(x) == 0 :
    print(x)
    exit()
elif len(m) == 0:
    print(x)
    exit()

for k in range(1,200):
    if m.count((x - k)) == 0 and x - (x - k) < sa:
        sa =  x - (x - k)
        ans = x - k

for l in range(1,200):
    if m.count((x + l)) == 0 and (x+l) - x < sa:
        sa = (x+l) - x
        ans = x + l

print(ans)

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
X, N = map(int, input().split())
P =  set(map(int, input().split()))
Nums = set(range(1, 101))
Nums = Nums - P
sorted(Nums)


minNum = 99999
minIndex = 0
for n in Nums:
    if minNum == abs(X-n):
        break
    if abs(X - n)< minNum:
        minNum = abs(X - n)
        minIndex = n

print(minIndex)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
P =  set(map(int, input().split()))
Nums = set(range(-100, 200))
Nums = Nums - P
sorted(Nums)


minNum = 99999
minIndex = 0
for n in Nums:
    if minNum == abs(X-n):
        break
    if abs(X - n)< minNum:
        minNum = abs(X-n)
        minIndex = n

print(minIndex)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

x,n = map(int, "100 0".split())

line = list(map(int, "".split()))

plus = x
minus = x

if not x in line:
    print(x)
    exit()

while True:

    if plus <= 100:
        plus += 1

    if minus >= 0:
        minus -=1


    if not minus in line:
        print(minus)
        exit()

    if not plus in line:
        print(plus)
        exit()

    if plus > 100 and minus < 0:
      exit()


Failing test case input:
10 3
13 7 3 6 5

Expected output:
10


Actual output:
100


Fixed submission (verdict: Accepted):
x,n = map(int, input().split())
line = list(map(int, input().split()))

plus = x
minus = x

if not x in line:
    print(x)
    exit()

while True:

    if plus <= 100:
        plus += 1

    if minus >= 0:
        minus -=1


    if not minus in line:
        print(minus)
        exit()

    if not plus in line:
        print(plus)
        exit()

    if plus > 100 and minus < 0:
      exit()