Problem:
 Score : 300 points    Problem Statement Given are an integer X and an integer sequence of length N : p_1, \ldots, p_N .  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X , that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.      Constraints  1 \leq X \leq 100  0 \leq N \leq 100  1 \leq p_i \leq 100  p_1, \ldots, p_N are all distinct.  All values in input are integers.         Input Input is given from Standard Input in the following format:  X  N  p_1  ...  p_N       Output Print the answer.        Sample Input 1 6 5
4 7 10 6 5      Sample Output 1 8  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the one nearest to 6 is 8 .       Sample Input 2 10 5
4 7 10 6 5      Sample Output 2 9  Among the integers not contained in the sequence 4, 7, 10, 6, 5 , the ones nearest to 10 are 9 and 11 . We should print the smaller one, 9 .       Sample Input 3 100 0      Sample Output 3 100  When N = 0 , the second line in the input will be empty. Also, as seen here, X itself can be the answer.

Solution (Python):
x,n = map(int,input().split())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True


if(mp[x]==False):
    print(x)
    exit()


for i in range(x-1,-1,-1):
    if(i==0):
        bottom_savei = 0
        bottom_abs = abs(x) 
        break
    if(mp[i]==False):
        bottom_savei = i
        bottom_abs = abs(x-i)
        break


for i in range(x+1,102):
    if(i==101):
        top_savei = 101
        top_abs = abs(101 - x)
        break
    if(mp[i]==False):
        top_savei = i
        top_abs = abs(x-i)
        break
    
if(bottom_abs <= top_abs):
    print(bottom_savei)
else:
    print(top_savei)

Solution (Python):
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      if a not in p:
        ans = a
      else:
        ans = A
      break
  print(ans)

Solution (Python):
import numpy as np
def read():
    return list(map(int, input().split()))
x, _ = read()
p = read()
rem = np.array(p) - x
count = 0
while True:
    if (-1) * count not in rem:
        print(x - count)
        break
    if count not in rem:
        print(x + count)
        break

    count += 1

Solution (Python):
x,y = map(int,input().split())
l = list(map(int,input().split()))

if len(l) == 0 :
    print(x)
    exit()

for i in range(200):
    if not((x - i) in l):
        print(x - i)
        exit()

    elif not((x + i) in l):
        print(x + i)
        exit()

Solution (Python):
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int, input().split())]
ans = x
d = 1000000000
for c in range(101+1): 
    ok = True
    for p in P:
        if p == c:
            ok = False
            break
    if ok:
        if d > abs(x - c):
            d = abs(x - c)
            ans = c
print(ans)

Solution (Python):
n,m = map(int,input().split())
if(m>0):
  l = list(map(int,input().split()))
  i=n
  j=n
  while(i in l):
    i-=1
  while(j in l):
    j+=1
  if(abs(n-i)<abs(n-j)): print(i)
  elif(abs(n-i)>abs(n-j)): print(j)
  else: print(min(i,j))
else: print(n)

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict



sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, N = il()
    P = il()

    if len(P) == 0:
        print(X)
        exit()

    mx = max(P)
    p = MAX
    ret = 0
    for n in range(mx + 2):
        if n not in P and p > abs(X - n):
            ret = n
            p = X - n
    print(ret)


if __name__ == '__main__':
    main()

Solution (Python):
def fun(x):
  var=1
  first=0
  while True:
     if (x-var) not in n:
        first +=(x-var)
        
        return var
    
     var +=1

def funco(x):
  var=1
  first=0
  while True:
     if (x-var) not in n:
        first +=(x-var)
        
        return first
    
     var +=1
      
      

    

def fun2(x):
  var=1
  second=0
  while True:
    if (x+var) not in n:
       second +=(x+var)
      
       return var

    var +=1

def fun2co(x):
  var=1
  second=0
  while True:
    if (x+var) not in n:
       second +=(x+var)
      
       return second

    var +=1


def main(x):
  if x not in n:
    print(x)
    return
  s=(fun(x))
  t=(fun2(x))
  
  
  if s>t:
    print(fun2co(x))
  else:
    print(funco(x))

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


if x[1]<=0:
  print(x[0])

else:
  n=list(map(int,input().split()))
  main(x[0])

Solution (Python):
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])

    
    if X not in Ps:
        print(X)
        exit(0)

    
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Solution (Python):
X, N = map(int,input().split(' '))
if N == 0:
    print(X)
    exit()

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i) for i in range(102)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min(tmp))

print(num_list[ans])

Solution (Python):

X,N=[int(x) for x in input().rstrip().split()]
p=[int(x) for x in input().rstrip().split()]
nai=[]
for i in range(0,102):
  if i not in p:
    nai.append(i)

nai.append(X)
nai.sort()
ind = nai.index(X)
if abs(nai[ind-1]-X)<=abs(nai[ind+1]-X):
  print(nai[ind-1])
else:
  print(nai[ind+1])

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
for i in range(100):
         if (x - i) not in p:
                  print(x-i)
                  exit()
         if (x + i) not in p:
                  print(x+i)
                  exit()

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 102

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 101)
    if flag[low]:
        print(low)
        break
    elif flag[high]:
        print(high)
        break

Solution (Python):
X ,N = [int(i) for i in input().split()]
N_list = [int(n) for n in input().split()]
count = 0
while(True):
    if not X-count in N_list:
        min_abs = X - count
        break
    elif not X+count in N_list:
        min_abs = X + count
        break
    count += 1
print(min_abs)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)

diff = 101
indx = 0
ans = (101, 0)
if n != 0:
    for now in range(0, 102):
        if now not in p:
            now_diff = abs(now - x)
            ans = min(ans, (now_diff, now))
    print(ans[1])
else:
    print(x)

Solution (Python):
a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])

Solution (Python):
X, N, *d = map(int, open(0).read().split())
if N == 0:
    print(X)
else:
    ans = -100
    for i in range(102):
        if i not in d and abs(i - X) < abs(ans - X):
            ans = i

    print(ans)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)

diff = 101
indx = 0
if n != 0:
    for now in range(0, 102):
        if now not in p:
            now_diff = abs(now - x)
            if diff > now_diff:
                diff = now_diff
                indx = now
            else:
                break
    print(indx)
else:
    print(x)

Solution (Python):
X, N = [int(i) for i in input().split()]
if N == 0:

    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    
    

    
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Solution (Python):
x,n = map(int,input().split())
if n == 0:
  print(x)
  quit()
lis = list(map(int,input().split()))
ans = 9999999
for y in range(x-101,x+101):
  if not(y in lis) and abs(x - y) < abs(x - ans):
    ans = y
  if not(y in lis) and abs(x - y) == abs(x - ans):
    if ans > y:
      ans = y
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

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


l = x
h = x

while True:
    if l not in p:
        break
    else:
        l -= 1

while True:
    if h not in p:
        break
    else:
        h += 1

if (x - l) <= (h - x):
    print(l)
else:
    print(h)

Solution (Python):
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(0,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break

Solution (Python):
x, y = map(int, input().split())
p = list(map(int, input().split()))

for diff in range(101):
    
    a = x - diff
    
    if a not in p:
        print(a)
        exit()
    
    a = x + diff
    if a not in p:
        print(a)
        exit()

Solution (Python):
nii=lambda:map(int,input().split())
lnii=lambda:list(map(int,input().split()))

x,n=nii()
p=lnii()

dist=1000
ans=1000
for i in range(101,-1,-1):
  if i not in p:
    t_dist=abs(x-i)
    if t_dist<=dist:
      dist=t_dist
      ans=i
print(ans)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))
numlist = []

for i in range(102):
  if not i in p:
    numlist.append(i)
m = 500
for j in numlist:
  sa = abs(X-j)
  if sa < m:
    m = sa
    num = j

print(num)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()

p = list(map(int, input().split()))
l = []
for i in range(-100,102):
  l.append(i)

L = []
for i in l:
  if i not in p:
    L.append(i)

l = []
for i in L:
  l.append([i, abs(x-i)])
a = min(l, key = lambda t: t[1])
print(list(a)[0])

Solution (Python):
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))

Solution (Python):
from typing import List


def main():
    X, N = map(int, input().split())

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

    p_lst: List[int] = list(map(int, input().split()))

    for i in range(51):
        if X - i not in p_lst:
            print(X - i)
            exit()
        if X + i not in p_lst:
            print(X + i)
            exit()


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
lis=[]
for i in range(102):
    lis.append(i)

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;

 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max+1]
    arr=arr[arr>=P_min-1]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    
    lis_min=min(lis_)
 
    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Solution (Python):
def solve():
    X, N = map(int,input().split())
    p = set(map(int,input().split()))

    ans = float('inf')
    for i in range(102):
        if not i in p:
            if abs(ans-X) > abs(i-X):
                ans = i
    
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):
def main():
    k = [int(i) for i in input().split()]
    x = k[0]
    n = k[1]
    if(n==0):
        print(x)
        return 0
        
    nums = [int(i) for i in input().split()]
    
    a=x
    b=x
    
    while(True):
        if(a not in nums):
            print(a)
            break
        if(b not in nums):
            print(b)
            break
        a-=1
        b+=1
    return 0
    
main()

Solution (Python):
def solve():
    X,N = map(int, raw_input().split())
    if N == 0:
        return  X

    P = map(int, raw_input().split())
    P = sorted(P)
    x = P[-1]
    for p in P:
        if X <= p:
            x = p
            break

    m = 1000000
    ans = 0
    for i in range(x-110, x+110):
        if i not in P:
            d = abs(X - i)
            if d < m:
                m = d
                ans = i
    return ans

print solve()

Solution (Python):
x,n=map(int,input().split())
if n!=0:
  li=list(map(int,input().split()))
else:
  li=[]
z=0

while True:
  if x-z not in li:
    print(x-z)
    break
  if x+z not in li:
    print(x+z)
    break
  z+=1

Solution (Python):
x,n = map(int,input().split())
if(n==0):
    print(x)
    exit()

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

ans = -2
dif = 1000
for i in range(-1,102):
    if(i in p):
        continue
    dif_i = abs(i-x)
    if(dif > dif_i):
        dif = dif_i
        ans = i

print(ans)

Solution (Python):
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  ans=-1
  for i in range(0,102):
    if i not in a and abs(i-x)<abs(ans-x):
      ans=i
  print(ans)

Solution (Python):
X,N = [int(i) for i in input().split()]
p = sorted([int(i) for i in input().split()], key=lambda x: x) if N > 0 else [0]

diffMin = 10**9 
minNum = -10**9
for i in range(0, 100+1+1):
  if i not in p and diffMin > abs( X-i ) :
     diffMin = min(diffMin,abs( X-i ))
     minNum = i
print(minNum)

Solution (Python):
x,n=map(int,input().split())
l=list(map(int,input().split()))
if x not in l:
    print(x)
elif n==0:
    print(x)
else:
    a=101
    p1=0
    for i in range(102):
        if i not in l:
            if abs(x-i)<a:
                a=abs(x-i)
                p1=i

    print(p1)

Solution (Python):
import sys

x,n = map(int, input().split())
p = sorted(list(map(int, input().split())))
res = [x,-1]
for i in range(101):
    a = x - i
    b = x + i
    if a not in p:
        print(a)
        sys.exit()
    if b not in p:
        print(b)
        sys.exit()

Solution (Python):
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(101):
    a = x - i
    b = x + i

    if a not in p:
        print(a)
        exit()
    elif b not in p:
        print(b)
        exit()

Solution (Python):


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

d = [0 for _ in range(201)]
for i in range(-100, 101):
    d[i+100] = i+1 

for i in p:
    d.remove(i)

d2 = [0 for _ in range(len(d))]
for i in range(len(d)):
    d2[i] = abs(d[i]-x)

m = 10000
for i in reversed(range(len(d2))):
    if d2[i] <= m:
        m = d2[i]
        tmpi = i 

print(d[tmpi])

Solution (Python):
from typing import List


def main():
    X, N = map(int, input().split())

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

    p_lst: List[int] = list(map(int, input().split()))

    for i in range(100):
        if X - i not in p_lst:
            print(X - i)
            exit()
        if X + i not in p_lst:
            print(X + i)
            exit()


if __name__ == "__main__":
    main()

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

C = list({i for i in range(0, 101+1)} - set(P))
C.sort()
dist = float('inf')
result = None
for i in C:
    if abs(X - i) < dist:
        result = i
        dist = abs(X - i)

print(result)

Solution (Python):
try:
  x,n = list(map(int, input().split()))
  ps  = list(map(int, input().split()))
  
  
  
  
  if not (x in ps):
    print(x)
    exit(0)
  
  for item in range(1,101):
    if not x-item in ps:
      print(x-item)
      exit(0)
    elif not x+item in ps:
      print(x+item)
      exit(0)
except EOFError:
  print(x)

Solution (Python):
x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))

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

all = set(range(0, 102))
kouho = all - set(P)

min_dis = 200
for i in kouho:
    dis = abs(i-X)
    if min_dis > dis:
        min_i = i
        min_dis = dis

print(min_i)

Solution (Python):
x,n=map(int,input().split())
if n!=0:
  s=set(list(map(int,input().split())))
else:
  s=[]
diff=10**18
ans=10**18
for i in range(-10000,10000):
  if i in s:
    continue
  else:
    if abs(x-i)<diff:
      ans=i
      diff=abs(x-i)
print(ans)

Solution (Python):
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    if N == 0:
        print(X)
        return
    diff = 100
    ans = -1
    for i in range(102):
        if i in P:
            continue
        d = abs(i - X)
        if d < diff:
            diff = d
            ans = i
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
a,b=map(int,input().split())
s = list(map(int, input().split()))
t = 0
h = 0
if b ==0:
    print(a)
else:
    for i in range(a,a+2+b):
        if not i in s:
            t = i
            break
    for i in range(a-1,a-2-b,-1):
        if not i in s:
            h = i
            break
    if abs(t-a)>=abs(h-a):
        print (h)
    else:
        print(t)

Solution (Python):
x,n = map(int,input().split())
if n == 0:print(x);exit(0)
*p, = sorted(map(int,input().split()))
pp = set(p)
ans = 9e9
for i in range(0,102):
    if i in pp: continue
    if abs(i-x) < ans:
        xx = i
        ans = abs(i-x)
    else:
        break
print(xx)

Solution (Python):
from math import *
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18

ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)

Solution (Python):
x,n=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
ans=float('inf')
cnt=0
for i in range(0,110):
    if not i in p:
        if ans>abs(x-i):
            cnt=i
            ans=abs(x-i)

print(cnt)

Solution (Python):
X,N = map(int,input().split())
n = list(map(int,input().split()))
xn = list(range(0,102))
answer = 0
for i in range(N):
  xn.remove(n[i])
mindis = 100
for i in range(len(xn)):
  dis = abs(X-xn[i])
  if dis < mindis:
    mindis = dis
    answer = xn[i]
print(answer)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007




def main():
	X,N = inputMap()
	p = inputList()

	sa = inf
	pointer = 0
	for i in range(200,-100,-1):
		if i in p:
			continue
		tmp = abs(X-i)
		if tmp <= sa:
			sa = tmp
			pointer = i

	if sa == inf:
		if X > 50:
			print(101)
		else:
			print(0)
	else:
		print(pointer)




if __name__ == "__main__":
	main()

Solution (Python):
from collections import defaultdict

x, n = map(int, input().split())
p = list(map(int, input().split()))
h = defaultdict(lambda: False)
for i in p:
    h[i] = True
i = 0
while True:
    if not h[x - i]:
        print(x - i)
        break
    if not h[x + i]:
        print(x + i)
        break
    i += 1

Solution (Python):
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))
    check = float('inf')
    ans = 0
    for i in range(102):
        if i not in p:
            if check > abs(x - i):
                ans = i
                check = abs(x - i)
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
x, n = map(int, input().split())
arr = sorted(list(map(int, input().split())))
mins = 10000
idx = 0
for i in range(0, 102):
    if abs(x-i) < mins and i not in arr:
        mins = abs(x-i)
        idx = i
print(idx)

Solution (Python):
x, n = map(int, input().split())

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

if x <= 50:
    minp = x
    minv = 0
    p.sort()
else:
    minp = abs(101 - x)
    minv = 101
    p.sort(reverse=True)

if n == 0:
    print(x)
elif n == 100:
    if x <= abs(101 - x):
        print(0)
    else:
        print(101)
else:
    for i in range(1, 101):
        if i in p:
            continue
        else:
            if abs(i - x) < minp:
                minp = abs(i - x)
                minv = i
            elif abs(i - x) == minp:
                if (minv > i):
                    minv = i
    print(minv)

Solution (Python):
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))

    ans = min(
        (i for i in range(0, 102) if i not in P),
        key=lambda x: abs(X - x)
    )
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_list()

Solution (Python):
a = list(map(int, input().split()))
if a[1] == 0:
    print(a[0])
else:
    b = list(map(int, input().split()))
    c = []
    out = 0
    res = 10000001
    for i in range(102):
        if i not in b:
            c.append(i)
    for j in c:
        if (abs(j - a[0]) < res):
            res = abs(j - a[0])
            out = j
    print(out)

Solution (Python):
import sys
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
    sys.exit()

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(abs(x-i))
    else:
        not_in_p.append(102)

address = not_in_p.index(min(not_in_p))
print(address)

Solution (Python):
X, N = map(int, input().split())
line = list(map(int, input().split()))
notLine = [i for i in range(-100, 201) if i not in line]
left = -1
right = len(notLine)
while abs(right - left) > 1:
    middle = (right + left) // 2
    if notLine[middle] >= X:
        right = middle
    else:
        left = middle

if X - notLine[left] <= notLine[right] - X:
    print(notLine[left])
else:
    print(notLine[right])

Solution (Python):
X,N = map(int,input().split())
P = set(map(int,input().split()))

o = []
for i in range(2 * X + 1):
    if i in P:
        continue
    o.append(abs(i-X)*10000+i)

print(min(o)%10000)

Solution (Python):
x,y=map(int,input().split())
if y==0:
  print(x)
  exit()
p=list(map(int,input().split()))
for i in range(200):
  if not x-i in p:
    print(x-i)
    exit()
  if not x+i in p:
    print(x+i)
    exit()

Solution (Python):
X,N = map(int,input().split())
P = list(map(int,input().split()))
ans = 100
l = 101
for i in range(0,102):
    if P.count(i) == 0:
        if abs(i-X) < l:
            
            l = abs(i-X)
            ans = i
print(ans)

Solution (Python):
import sys


def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(N+1):
        if X-i not in list_p:
            print(X-i)
            sys.exit()

        if X+i not in list_p:
            print(X+i)
            sys.exit()

Solution (Python):



def main():
    X, N = map(int, input().split())
    if (N > 0):
        P = list(map(int, input().split()))
        ans = 0
        abs_temp = 101

        for pi in range(0, 102):
            n = abs(pi - X)
            if n < abs_temp  and not pi in P:
                ans = pi
                abs_temp = n
            elif n == abs_temp  and not pi in P and pi < ans:
                ans = pi
                abs_temp = n

        print(ans)

    else:
        print(X)


if __name__ == "__main__":
    main()

Solution (Python):
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])

Solution (Python):
def c_forbidden_list(RANGE=50):
    X, N = [int(i) for i in input().split()]
    P = set([int(i) for i in input().split()]) if N != 0 else set()

    for t in range(RANGE + 1):
        if X - t not in P:
            return X - t
        elif X + t not in P:
            return X + t
    return None  

print(c_forbidden_list())

Solution (Python):
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  
  if not i in p:
    print(i)
    sys.exit()
  if not (x+c) in p:
    print(x+c)
    sys.exit()
  c+=1

Solution (Python):
x, n = map(int, input().split())
p = set(list(map(int, input().split())))

ans = 0
for i in range(102):
    if abs(i - x) < abs(ans - x):
        if i not in p:
            ans = i

print(ans)

Solution (Python):
def solution(X, N, P):
    P = set(P)
    if N <= 0 or X not in P:
        return X
    for i in range(1, len(P) + 1):
        left = X - i
        right = X + i
        if left not in P:
            return left
        if right not in P:
            return right

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

Solution (Python):
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
P = [*map(int,input().split())]
ans = 100 + 100 
for d in range(100): 
    now_diff = abs(ans - x)
    min_x, max_x = x - d, x + d
    if min_x not in P:
        if now_diff > abs(min_x - x): ans = min_x
    elif max_x not in P:
        if now_diff > abs(max_x - x): ans = max_x
print(ans)

Solution (Python):
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(0,102))
s_p=set(p)
kouho=sorted(all-s_p)

min_dis=201
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)

Solution (Python):
X,N=map(int,input().split())
li=list(map(int,input().split()))
sa = 101
for i in range(102):
    if sa > abs(X-i) and not i in li:
        sa = abs(X-i)
        ans = i
print(ans)

Solution (Python):
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(-100,102))
s_p=set(p)
kouho=sorted(all-s_p)

min_dis=201
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)

Solution (Python):
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(0,102):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Solution (Python):
X, N = map(int, input().split())
P = list(map(int, input().split()))
differ=[]

if N == 0:
    print(X)
else:
    for i in range(0,102):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    print(ans)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))

p_all = set(range(0, 102)) - set(p)


mi = float('inf')
ans = 0
for i in p_all:
    if abs(x - i) < mi:
        mi = abs(x - i)
        ans = i

print(ans)

Solution (Python):
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))
ans=0
if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  for i in range(0,102):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=i
  print(ans)

Solution (Python):
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = X
for i in range(101):
    ans = X - i
    if ans in p:
        ans = X + i
        if ans in p:
            continue
        else:
            break
    else:
        break

print(ans)

Solution (Python):
X,N = map(int,input().split())

if N == 0:
  print(X)
  exit()
else:
  P = list(map(int,input().split()))

  for i in range(100):
    if (X-i) not in P:
      print(X-i)
      break
    elif (X+i) not in P:
      print(X+i)
      break

Solution (Python):


def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    X, N = MII()
    p = LII()

    mn = 101
    ans = 0
    for i in range(-1, 102):
        if i not in p:
            if mn > abs(X - i):
                ans = i
                mn = abs(X - i)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
X,N=map(int,input().split())
p=list(map(int,input().split()))
diff=98
for x in range(102):
    if x not in p and abs(X-x)<diff:
        diff=abs(X-x)
        ans=x
print(ans)

Solution (Python):
from collections import Counter
x,n = map(int,input().split())
p = list(map(int,input().split()))
 
num_list = list(range(0,102))
y = (num_list + p)
 
counter = Counter(y)
result =  [elem for elem in y if counter[elem] < 2]
 

ans = 10 *100000000000
 
for i in result:
    temp = abs(i - x)
    if ans > temp:
        ans = temp
        res = i
print(res)

Solution (Python):
x, n = map(int, input().split())
p = list(map(int, input().split()))

p_all = set(range(0, 102)) - set(p)


mi = float('inf')
ans = 0
for i in p_all:
    if abs(x - i) < mi:
        mi = abs(x - i)
        ans = i

print(ans)