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())
ans_y = None
if n == 0:
  print(x)
elif n == 1:
  p = list(map(int, input().split()))
  if x == p[0]:
    print(x-1)
  else:
    print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  m = float("inf")
  if x<p[0] or p[n-1]<x:
    print(x)
  else:
    for y in [y for y in range(p[0]-1,p[n-1]+2) if not y in p]:
      if abs(x-y)<m:
        m = abs(x-y)
        ans_y = y
  if ans_y != None:
    print(ans_y)

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

    difX = [[0]*2]*N

    for i in range(N):
        difX[i] = [abs(X-p[i]),i]

    min_dif_p = p[min(difX)[1]]

    pluslist = [min_dif_p]
    minuslist = [min_dif_p]

    for i in range(100):
        pluslist.append(pluslist[-1]+1)
        if pluslist[-1] not in p:
            break

    for i in range(100):
        minuslist.append(minuslist[-1]-1)
        if minuslist[-1] not in p:
            break

    ans1 = pluslist[-1]
    ans2 = minuslist[-1]

    if abs(ans1-X) < abs(ans2-X):
      print(ans1)
    else:
      print(ans2)

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

Solution (Python):
import sys
x = input().split()
y = input().split()

if len(y) == 0:
    print(x[0])
    sys.exit()
a=[]
b=[]
for n in range(-1,102):
    b.append(n)
   
for nn in range(len(y)):
    
    b.remove(int(y[nn]))
for m in range(len(b)):  
    d = b[m] - int(x[0])
    if d < 0:
        c = d*(-1)
    if d >= 0:
        c = d
    a.append(c)
mm = min(a)
if str((int(x[0]) - mm)) in y:
    print(int(x[0]) + mm)
else:
    print(int(x[0]) - mm)

Solution (Python):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input(). split()))
if X not in P:
    print(X)
    exit()

for n in range(1, N + 1):    
    if not (X - n) in P:
        print(X - n)
        exit()
    if not (X + n) in P:
        print(X + n)
        exit()
print(min(P) - 1)

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

if N == 0:
    P = []
else:
    P = list(map(int,input().split()))

def serch(X,N,P):
    dif = []
    
    for i in range(N):
        dif.append(abs(P[i]-X))
    
    dif.sort()
    
    difcount = {}
    for i in dif:
        if i in difcount:
            difcount[i] += 1
        else:
            difcount[i] = 1

    for i in range(1,101):
        if i not in difcount:
            return X-i
        
        if difcount[i] == 1:
            if X - i in P:
                return X+i
            else:
                return X-i
                
if X not in P:
    print(X)
else:
    print(serch(X,N,P))

Solution (Python):

able = list()
for i in range(103):
    able.insert(i, i-1)

X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(len(p)):
    able.remove(p[i])

target = 1000
ans = 1000
for i in range(len(able)):
    
    if (target > abs(X - able[i])):
        
        
        
        target = abs(X - able[i])
        ans = able[i]
    
    

print(ans)

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

diff = 1000
ans = None
for i in range(X - 51, X + 51, 1):
    isInPs = False
    index = 0
    for j in ps:
        if ps[index] == i:
            isInPs = True
            break
        index += 1
    if isInPs == False:
        testDiff = abs(X - i)
        if testDiff < diff:
            diff = testDiff
            ans = i
print(ans)

Solution (Python):
def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    _near = -1
    for i in range(-1, 102):
        if i in p:
            continue
        if abs(_near - x) > abs(i - x):
                _near = i
    print(_near)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
X, N = map(int, input().split())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(-201, 201))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[min_index])

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

a = 100
num = 0

for i in range(202):
    if (i-100) not in p:
        b = (i-100)-X
        if abs(b) < a:
            a = abs(b)
            num = (i-100)

print(num)

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

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if y - i < 0:
            print(p[0] - 1)
            break
        elif x - i != p[y - i]:
            print(x - i)
            break
        if n <= y + i:
            print(p[n - 1] + 1)
            break
        elif x + i != p[y + i]:
            print(x + i)
            break
        i = i + 1

Solution (Python):
a = list(map(int,input().split()))
if not a[1] ==0:
  b = list(map(int,input().split()))
  b2 = sorted(b)
  if abs(a[0]-b2[0]) <= abs(a[0]-b2[a[1]-1]):
    c = b2[0]-a[0]-1
  else:
    c = b2[a[1]-1]-a[0]+1
  if a[0] < b2[0]:
    print(a[0])
  elif a[0] > b2[a[1]-1]:
    print(a[0])
  else:
    for i in range(a[1]-1):
      if abs(b2[i+1]-b[i])>1:
        for j in range(b2[i+1]-b2[i]-1):
          if abs(c) > abs(b2[i]-a[0]+j+1):
            c = b2[i]-a[0]+j+1
          elif abs(c) == abs(b2[i]-a[0]+j+1) and c > b2[i]-a[0]+j+1:
            c = b2[i]-a[0]+j+1
    print(c+a[0])
else:
  print(a[0])

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

if N != 0:
  plist = list(map(int,input().split()))
  plistnew = []
  plistno = []
  anslist = []
  abslist1 = []
  abslist2 = []
  
  for i in range(-5,105):
    plistnew.append(i)
  
  for j in plistnew:
    if j in plist:
      pass
    else:
      plistno.append(j)

  for k in plistno:
    abslist1.append(X-k)
    abslist2.append(abs(X-k))
  
  minabs = min(abslist2)

  for l in range(len(abslist2)):
    if abslist2[l] == minabs:
      anslist.append(plistno[l])
  print(min(anslist))
  
if N == 0:
  print(X)

Solution (Python):
import sys

def minCheck(X):
  if X in L:
    return minCheck(X-1)
  else:
    return X

def maxCheck(X):
  if X in L:
    return maxCheck(X+1)
  else:
    return X

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

A = input().split()
L = [int(b.strip()) for b in A]  


if X in L:
  minA = minCheck(X-1)
  maxB = maxCheck(X+1)
  a = abs(X - minA)
  b = abs(X - maxB)
  if a > b:
    print(maxB)
  else:
    print(minA)
else:
  print(X)

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

Solution (Python):
import sys
def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
list_n = [0, -1, 1]
for i in range(2, 101):
  list_n.append(-i)
  list_n.append(i)
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
x = [0] * N
for i in range(0, N):
    x[i] = p[i] - X
for i in list_n:
    if my_index(x, i) == -1:
        print(X+i)
        break

Solution (Python):
X,N = map(int,input().split())
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    mini = 999
    ANS = 0
    for i in range(102):
        if P.count(i) == 0:
            if mini > abs(X-i):
                mini = abs(X-i)
                ANS = i
    print(ANS)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
else:
  ps = list(map(int, input().split()))
counters = [0 for _ in range(len(ps)+1)]
counters[0] = 1

for i,p in enumerate(ps):
  distance = abs(x - p)
  if distance < len(ps):
    counters[distance] += 1

for i,counter in enumerate(counters):
  if counter == 0:
    print(x-i)
    break
  elif counter == 1:
    if x-i in ps:
      print(x+i)
    else:
      print(x-i)
    break

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

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

Solution (Python):
x, n = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if len(a) == 0:
    print(x)
    quit()
y = x
while y in a:
    y -= 1
z = x
while z in a:
    z += 1
if x - y > z - x:
    print(z)
else:
    print(y)

Solution (Python):
def resolve():
    X, N = [int(i) for i in input().split()]
    if N == 0:
        print(X)
        return
    p_list = [int(i) for i in input().split()]
    min_len_with_X = 200
    min_len_i = 0
    for i in range(102):
        if i in p_list:
            continue
        if abs(i - X) < min_len_with_X:
            min_len_with_X = abs(i - X)
            min_len_i = i
    print(min_len_i)

resolve()

Solution (Python):

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

i = 0

while True:
    if x-i not in p or  x+i not in p:
        if x-i not in p:
            print(x-i)
        else:
            print(x+i)

        break
    else:
        i += 1

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

ans = x
p.sort()  
cnt = 0

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

Solution (Python):
import math
input_a= input().split(" ")
X=int(input_a[0])
N=int(input_a[1])
dis=X+3
dis2=100
if N!=0:
  array= input().split(" ")
else:
  array=[0,0]

num=X
num2=-100
for i in range(N+1):

  
  if str(num) not in array:
    dis=abs(X-num)
    num2=X-dis
    num1=num
    if str(num2) not in array:
    	numa=min([num,num2])
    else:
      numa=num1
    break
  num=num+1
    

num=X
i=0
for i in range(dis):
  
  if str(num) not in array:
    
    dis2=abs(X-num)
    num3=X+dis2

    if str(num3) not in array:
    	numb=min([num,num3])
    else:
      numb=num
      break
  num=num-1

if dis<dis2:
  print(numa)
elif dis==dis2:
  print(numb)
else:
  print(numb)

Solution (Python):
import collections
x,n=map(int,input().split())
if n!=0:
    l=list(map(int,input().split()))
    v=collections.Counter(l)
if n==0:
    print(x)
else:
    for i in  range(101):
        if x not in v:
            ans=x
            break
            
        if x-i not in v:
            ans=x-i
            break
        if x+i not in v:
            ans=x+i
            break
    print(ans)

Solution (Python):
x, n = map(int, input().split())
lst = []
x1 = x
x2 = x

def minus(num):
    return int(num) - 1


def plus(num):
    return int(num) + 1


if n != 0:
    lst = list(map(int, input().split()))
    for j in range(n):
        count = 0
        for i in lst:
            if x1 == i:
                x1 = minus(x1)
                break
            count += 1
        if count == n:
            break
    for j in range(n):
        count = 0
        for i in lst:
            if x2 == i:
                x2 = plus(x2)
                break
            count += 1
        if count == n:
            break

    if x >= 0:
        ans1 = x - x1
        ans2 = x2 - x
        if ans1 <= ans2:
            print(x1)
        else:
            print(x2)
    else:
        ans1 = (x1 - x) * (-1)
        ans2 = (x - x2) * (-1)
        if ans1 <= ans2:
            print(x1)
        else:
            print(x2)
else:
    print(x)

Solution (Python):
x, n = map(int, input().split())
not_p = []
if n != 0:
    p = list(map(int, input().split()))
    not_p = [i for i in range(201) if i not in p]
else:
    not_p = [i for i in range(201)]

mn = 101
ans = 100
for i in not_p:
    d = abs(x - i)
    if mn > d:
        mn = d
        ans = i

print(ans)

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  diffs = [i-x for i in range(102)]
  for p_i in p:
    diffs[p_i] = 1000
    ans = 1000
    for n in diffs:
      if abs(ans) > abs(n):
        ans = n
  print(x+ans)

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

if n == 0:
    print (x)
else:
    p=list(map(int,input().split(' ')))

    chk_x = False
    pmax = 0
    pmin = 101
    for pr in p:
        if pmax < pr:
            pmax = pr
        if pmin > pr:
            pmin = pr
        if pr == x:
            chk_x = True

    all_i = list(range(0,102))
    target_i = list(set(all_i)^set(p))

    minsub = abs(target_i[0] - x) + 1
    ans = -1
    for i in target_i:
        if abs(i-x) < minsub:
            minsub = abs(i-x)
            ans = i
    if not chk_x:
        print(x)
    else:
        print (ans)

Solution (Python):
X, N = list(map(int, input().split()))
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))
absp = []
for i in p:
  absp.append(i-X)
if not 0 in absp:
  print(X)
  exit()
for check in range(1,101):
  if not check*(-1) in absp:
    print(X-check)
    exit()
  if not check in absp:
    print(X+check)
    exit()

Solution (Python):
def main1 ():
  X, N =map(int, input().split())
  i = 0
  if N == 0:
    print(X)
  else:
    p = list(map(int, input().split()))
    for i in range(100):
      if X - i not in p:
        return print(X - i)
      elif X + i not in p:
        return print(X + i)
      i += 1

main1()

Solution (Python):
x,n=map(int,input().split())
import sys
if n==0:
    _=input()
    print(x)
    sys.exit()
    
p_list=list(map(int,input().split()))
r=list(range(102))
a=list(set(r)-set(p_list))
ans=100000
kkk=100000
for i in a:
    tem=abs(i-x)
    if ans>tem:
        ans=tem
        kkk=i
    
print(kkk)

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
q = set(range(0,102))
q = q - set(p)
q_list = list(q)
ans = 100
d = 100
for i in range(102-n):
   if d != min(d,abs(x - q_list[i])):
       ans = q_list[i]
       d = abs(x - q_list[i])
print(ans)

Solution (Python):
X,Y=map(int, input().split())
p=list(map(int, input().split()))
for i in range(100):
    if X-i not in p:
        ans=X-i
        break
    elif X+i not in p:
        ans=X+i
        break
print(ans)

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

    a = [i for i in range(102)]
    for i in range(n):
        a[p[i]] = 1000
    minimum = 1000
    result = 1000
    for i in reversed(range(102)):
        if a[i] != 1000:
            if minimum >= abs(x - a[i]):
                minimum = abs(x - a[i])
                result = a[i]

    print(result)

Solution (Python):
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)

Solution (Python):
x, n = [int(s) for s in input().split(" ")]
if n == 0:
  print(x)
else:
  plist = [int(s) for s in input().split(" ")]

  dlist = {}
  for p in plist:
    d = abs(p - x)
    if d in dlist or d == 0:
      dlist[d] = (True, None)
    else:
      dlist[d] = (False, p - x)

  sorted_d = sorted(dlist.items(), key=lambda x:x[0])

  ans = 0
  prevk = 0
  flag = False
  for k, v in sorted_d:
    if not flag and prevk == 0 and k >= 1:
      ans = 0
      break
    elif k - prevk > 1:
      ans = -(prevk + 1)
      break
    elif not v[0]:
      ans = -v[1]
      break
    flag = True
    prevk = k
    ans = -(k + 1)
  print(x + ans)

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

nearest = x
sub = 0

if p:
    dets = [i == x for i in p]
    hit = any(dets)
    sub += 1
    while hit:
        nearest = x - sub
        dets = [i == nearest for i in p]
        hit = any(dets)
        if not hit:
            break
        nearest += 2 * sub
        dets = [i == nearest for i in p]
        hit = any(dets)
        if not hit:
            break
        sub += 1

print(nearest)

Solution (Python):
data = input().split()
x = int(data[0])
n = int(data[1])

p = input().split()
for i in range(n):
	p[i] = int(p[i])

if n == 0:
	print(x)
	exit()
if not x in p:
	print(x)
	exit()

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

Solution (Python):
X,N = map(int, input().split())
A = list(map(int, input().split()))
if N == 0:
    print(X)
else:
    if N == 1:
        if A[0] != X:
            print(X)
        else:
            print(X-1)
    else:
        B = []
        for i in range(N):
            B.append(abs(X-A[i]))
        B.sort()
        t = 0
        for i in range(N):
            if (i+1)//2 != B[i]:
                break
            else:
                t = t+1
        if t == N:
            if N%2 == 1:
                print(X-((N+1)//2))
            else:
                k = 0
                for i in range(N):
                    if A[i] == X-(N//2):
                        k = k+1
                if k == 0:
                    print(X-(N//2))
                else:
                    print(X+(N//2))
        else:
            if t%2 == 1:
                print(X-(t+1)//2)
            else:
                k = 0
                for i in range(N):
                    if A[i] == X-(t//2):
                        k = k+1
                if k == 0:
                    print(X-(t//2))
                else:
                    print(X+(t//2))

Solution (Python):
num = list(map(int, input().split()))
if num[1] != 0:
    arr = list(map(int, input().split()))
    arr.sort()
    l_num = arr[0]
    l_diff = 10000
    for i in range(arr[0]-1, arr[-1]+2):
        if abs(num[0]-i) < l_diff and i not in arr:
            
            l_num = i
            l_diff = abs(num[0]-i)
    print(l_num)
else:
    print(num[0])

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

lis = [1] * (201)
for p in P: lis[p+99] -= 1

for i in range(100+1):
    up = X+i
    down = X-i
    if lis[100+down-1] == 1:
        print(down)
        exit()
    elif lis[100+up-1] == 1:
        print(up)
        exit()

Solution (Python):
X, N = input().split()
X = int(X)
N = int(N)
searchA = X
searchB = X
max = 100
z = X

if N != 0:
  A = list(map(int, input().split()))
  for val in range(max):
    if searchA in A:
      if searchA > -1:
        searchA -= 1
      else:
        continue
    else:
      z = searchA
      break
    if searchB in A:
      if searchB < 102:
        searchB += 1
      else:
        continue
    else:
      z = searchB
      break
    
print(z)

Solution (Python):
import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_list = sorted(num_list)
num_100 = list(range(-100, 102))

if n ==0:
    print(x)
else:
 for num in num_list:
     num_100.remove(num)

 numbers1 = np.array(num_100)
 numbers2 = numbers1 - x
 numbers3 = np.abs(numbers2)
 min_index = numbers3.argmin()
 print(numbers1[min_index])

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

i=0

while True:
    if X-i not in P:
        result=X-i
        break
    elif X+i not in P:
        result=X+i
        break
    else:
        i+=1

print(result)

Solution (Python):
import sys
x,n=map(int,input().split())
ans=10000
ans1=[]
ans2=[]
if n>0:
    l=list(map(int,input().split()))
else:
    print(x)
    sys.exit()
for i in range(len(l)):
    if abs(ans-l[i])<ans:
        ans1.append(l[i])
        ans1.append(l[i]-1)
        ans1.append(l[i]+1)
ans1=sorted(ans1)
for j in range(len(ans1)):
    if abs(x-ans1[j])<ans and ans1[j] not in l:
        ans2.append(ans1[j])
        ans=min(ans,x-ans1[j])
print(max(ans2))

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

if n == 0:
    print(x)
elif n ==100:
    if x >50:
        print(101)
    else:
        print(0)
else:
    p = list(map(int, input().split()))
    d = []
    c=0
    for e in p:
        d.append(abs(e-x))
    d1 = d[0]
    z=p[0]
    for i in range(len(d)):
        if d[i] < d1:
            d1 = d[i]
            z = p[i]
    for j in range(1,100):
        for g in p:
            if z+j != g:
                c +=1
                w1 = z+j
        if c == n:
            break
        c = 0
    c=0
    for j2 in range(1,100):
        for g2 in p:
            if z-j2 != g2:
                c +=1
                w2 = z-j2
        if c == n:
            break
        c = 0
    if w2 < 0:
        print(w1)
    elif abs(w1-x) < abs(w2-x):
        print(w1)
    else:
        print(w2)

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

  for i in range(100):
    plus = (x+i)  in li
    minus = (x-i)  in li
  
    if plus == 1 and minus == 1:
      pass  
    elif plus == 1 and minus == 0:
      print(x-i)
      break
    elif plus == 0 and minus == 1:
      print(x+i)
      break
    else:
      print(x-i)
      break

Solution (Python):
x, n = input().split()
pn = map(int,input().split())
ints = [i for i in range(102)]
for p in pn:
  ints[p] = -200

x = int(x)
_min = 200
argmin = -100
for _int in ints:
  if abs(_int - x) < _min:
    _min = abs(_int - x)
    argmin = _int

print(argmin)

Solution (Python):
def main():
    x,n=map(int,input().split())
    p=list(map(int,input().split()))
    if n==0:
        print(x)
        return
    i=0
    while True:
        if x+i not in p:
            print(x+i)
            break
        if x-i not in p:
            print(x-i)
            break
        i-=1
if __name__ == "__main__":
    main()

Solution (Python):
X,N = map(int, input().split())
P = list(map(int, input().split()))
maxP = 0 if P == [] else max(P)
le = 1000
for k in reversed(range(X+1)):
  if k not in P:
    le = X-k
    ans = k
    break

for k in range(X,102):
  if k not in P:
    if le > k-X:
      ans = k
      break
print(ans)

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

if n != 0:
  p = list(map(int, input().split()))
  q = []
  for i in range(102):
    if i in p:
      q.append(150)
    else:
      q.append(abs(i-x))
  list_indexMin = [i for i, v in enumerate(q) if v == min(q)] 
  print(min(list_indexMin))
else:
  print(x)

Solution (Python):
import sys
x,n=map(int,input().split())
ans=10000
ansaa=10000
ans1=[]
ans2=[]
ans3=[]
if n>0:
    l=list(map(int,input().split()))
else:
    print(x)
    sys.exit()
for i in range(len(l)):
    if abs(ans-l[i])<ans:
        ans1.append(l[i])
        ans1.append(l[i]-1)
        ans1.append(l[i]+1)
ans1=sorted(ans1)
for j in range(len(ans1)):
    if abs(x-ans1[j])<ans and ans1[j] not in l:
        ans2.append(ans1[j])
        ans=min(ans,x-ans1[j])
print(max(ans2))

Solution (Python):
X,N = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    for i in range(100):
        if not X - i in P:
            a = X - i
            break
        if not X + i in P:
            a = X + i
            break
    print(a)

Solution (Python):
X,N = list(map(int,input().split()))
p = list(map(int,input().split()))
s = 1
t = 1
for i in range(100):
    for j in range(N):
        if p[j] == X-i:
            s *= 0
        else:
            s *= 1
        if p[j] == X+i:
            t *= 0
        else:
            t *= 1
    if s == 1:
        print(X-i)
        break
    elif t == 1:
        print(X+i)
        break
    else:
        s = 1
        t = 1

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

if n ==0:
    print(x)
else:
    for j in range(51):
        ll = []
        if not x-j in p:
            ll.append(x-j)
        if len(ll) != 0:
            print(min(ll))
            break
        if not x+j in p:
            ll.append(x+j)
        if len(ll) != 0:
            print(min(ll))
            break

Solution (Python):
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
li = []
ans = []
Min_sa = 9999999999
for i in range(-200,201):
    if i not in p:
        li.append(i)
for i in li:
     Min_sa = min(Min_sa,abs(x-i))
for i in li:
    if abs(x-i) == Min_sa:
        ans.append(i)
print(min(ans))

Solution (Python):
x,n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

if n == 0 :
    print(x)
    exit()
elif not x in p :
    print(x)
    exit()
p.sort()
mini = abs(x-(p[0]-1))
maxi = abs(x-(p[-1]+1))
indenxX = p.index(x)
for i in range(1,indenxX+1) :
    if p[indenxX-i] !=  x-i :
        mini = i
        break
for i in range(1,n-indenxX) :
    if p[indenxX+i] != x+i :
        maxi = i
        break


if mini <= maxi :
    print(x-mini)
else :
    print(x+maxi)

Solution (Python):
x, n = map(int,input().split())
ps = list(map(int,input().split()))
mtmp = x
ptmp = x
rt = True
r = []
if x not in ps:
  print(x)
elif len(ps) == 0:
  print(x)
else:
  while True:
    if mtmp+1 not in ps:
      r.append(mtmp+1)
      rt = False
    if ptmp-1 not in ps:
      r.append(ptmp-1)
      rt = False
    mtmp = mtmp+1
    ptmp = ptmp-1
    if rt:
      continue
    else:
      break
  print(min(r))

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

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

i = 0
for i in range(100):
    if not x-i in ps:
        print(x-i)
        break
    if not x+i in ps:
        print(x+i)
        break

Solution (Python):
X, N = map(int, input().split())
if N > 0:
    P = list(map(int, input().split()))
    res = float('Inf')
    A = [0]*101
    for n in range(N):
        A[P[n]-1] += 1
    cnt = 1
    man = float('Inf')
    for a in A:
        if a == 0:
            total = abs(X - cnt)
            if res > total:
                res = total
                man = cnt
        cnt += 1
    if abs(X - 0) <= res:
        man = 0
    print(man)
else:
    print(X)

Solution (Python):
X,N=map(int,input().split())
L=list(map(int,input().split()))
L.append(X)
if L.count(X)==1:
  print(X)
else:
  set(L)
  for i in range(1,X+1):
    if X-i not in L:
      print(X-i)
      break
    elif X+i not in L:
      print(X+i)
      break

Solution (Python):
x,n=map(int,input().split())
if n==0:
	print(x)
else:
	l=list(map(int,input().split()))
	if x not in l:
		print(x)
	else:
		v=0
		c=0
		d=0
		for i in range(1,len(l)+1):
			if x-i not in l:
				print(x-i)
				v=1
				break
			else:
				c+=1
			if x+i not in l:
				print(x+i)
				v=1
				break
			else:
				d+=1	
		if v==0:
			print(min(x-c-1,x+d+1))

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

  ans = X;
  min_value = 202

  if N == 0:
    print(ans)
  else:
    p = list(map(int, input().split()))
    a = [i for i in range(0, 202)]

    for v in p:
      a[v] = -1

    for i in range(0, 202):
      if a[i] != -1:
        d = abs(X - a[i])

        if(min_value > d):
          min_value = d
          ans = i

    print(ans);

if __name__ == '__main__':
  main()

Solution (Python):
from sys import stdin

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

def solve():
    i = 1
    if N == 0:
        print(X)
        return
    if not X in p:
        print(X)
        return
    while True:
        if not X-i in p:
            print(X-i)
            return
        if not X+i in p:
            print(X+i)
            return
        i += 1

solve()

Solution (Python):

import sys

x, n = map(int, input().split())
try:
    p = list(map(int, input().split()))
except EOFError:
    print(x)
    sys.exit()

sorted_p = sorted(p, reverse=True)
except_p = [i for i in range(0, 102) if i not in sorted_p]

memory_min = 10000
memory_index = 0

for k, ep in enumerate(except_p):
    if abs(ep - x) < memory_min:
        memory_min = abs(ep - x)
        memory_index = k

print(except_p[memory_index])

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

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

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

ans = 0
for i in range(1,102):
    if i in a:
        continue
    if abs(x-ans) > abs(x-i):
        ans = i
print(ans)

Solution (Python):
X, N = (int(x) for x in input().split())
p = list(map(int, input().split()))

if N == 0 or p.count(X) == 0: 
    print(X)
else:
    for i in range(60): 
        i += 1 
        A = X - i
        B = X + i
        if p.count(A) == 0 and p.count(B) == 0: 
            print(A)
            break
        elif p.count(A) == 0:
            print(A)
            break
        elif p.count(B) == 0:
            print(B)
            break

Solution (Python):
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
unique = set(range(0, 102)) - set(p)
ans = {}
ans2 = []
for i in unique:
  calc = abs(x-i)
  if calc in ans.keys():
    ans[calc] = min(ans[calc], i)
  else:
    ans[calc] = i
  ans2.append(calc)
print(ans[min(ans2)])

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

Solution (Python):
x, n = map(int, input().split())
*P, = map(int, input().split())
Q = [q for q in range(1000) if q not in P]
dist = 1000
for q in Q:
    if abs(q - x) < dist:
        ans = q
        dist = abs(q - x)
print(ans)

Solution (Python):
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