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.



Sample input:
6 5
4 7 10 6 5


Sample output:
8

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
ans = 0
for i in l-p:
    ans = min((abs(x-ans), ans), (abs(x-i), i))[1]
print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

x,n = map(int,input().split())
L=list(map(int,input().split()))
if n==0:
    print(x)
    sys.exit()
if x not in L:
    print(x)
    sys.exit()
else:
    L.sort()
    for i in range(1,2*x):
        if x-i not in L:
            print(x-i)
            break
        if x+i not in L:
            print(x+i)
            break

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
ans = 0
for i in l-p:
    if abs(x-ans) > abs(x-i):
        ans = i
print(ans)

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
p = set(map(int, input().split()))
l = set(i for i in range(102))
sa = 1000
ans = 0
for i in l-p:
    if sa > abs(x-i):
        sa = abs(x-i)
        ans = i
print(ans)

Submission status: Accepted

Solution code:
a, b= map(int, input().split())
lista= [int (x) for x in input().split()]

for i in range(102):
    if a-i not in lista:
        print(a-i)
        break
    elif a+i not in lista:
        print(a+i)
        break

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b = map(int, input().split())
result = set(map(int, input().split()))

for i in range(200):
    if a-i not in result:
        print(a-i)
        exit()
    elif a+i not in result:
        print(a+i)
        exit()

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
A = list(map(int, input().split()))
a = 0
while True:
  if X-a not in A:
      print(X-a)
      break
  if X+a not in A:
      print(X+a)
      break
  a += 1

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import os
from sys import stdin
import bisect

def solve(tc):
    x, n = map(int, stdin.readline().split())
    if n==0:
        print(x)
        return

    seq = list(map(int, stdin.readline().split()))
    cand = list()
    for i in range(102):
        if i not in seq:
            cand.append(i)

    k = bisect.bisect_left(cand, x)
    ans = cand[k]
    if x-cand[k-1]<=cand[k]-x:
        ans = cand[k-1]
    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1

Submission status: Accepted

Solution code:
def main():
    X, N = map(int, input().split())
    P = set(map(int, input().split()))
    for i in range(51):
        if X - i not in P:
            print(X-i)
            return
        if X + i not in P:
            print(X+i)
            return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(102):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Submission status: Accepted

Solution code:
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(110):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][1])

Submission status: Accepted

Solution code:
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]] = 0
    minimum = 100
    result = 100
    for i in reversed(range(102)):
            d = abs(x - a[i])
            if d <= minimum:
                minimum = d
                result = a[i]
    print(result)

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
else:
  P = [int(x) for x in input().split()]  
  if X in P:
    i = 1
    while True:
      if (X-i in P) and (not X+i in P):
        print(X+i)
        exit()
      elif (not X-i in P) and (X+i in P):
        print(X-i)
        exit()
      elif (X-i in P) and (X+i in P):
        i+=1
      elif (not X-i in P) and (not X+i in P):
        print(X-i)
        exit()
  else:
    print(X)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import bisect

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

p_list = [0]*100

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

p_list = [0]+p_list+[0]

dis = 100
index = -1
for i, j in enumerate(p_list):
    if j == 1:
        continue
    # print(i+1, abs(x-(i+1)))
    if dis > abs(x-i):
        dis = abs(x-i)
        index = i
        # index=i

print(index)

Submission status: Accepted

Solution code:
X, N = [int(i) for i in input().split(" ")]

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(1000)}
ranges = all_p - p

diff = 1e9
for i in ranges:
    if diff > abs(i - X):
        diff = abs(i - X)

ans_1 = X + diff
ans_2 = X - diff

for i in ranges:
    if i == ans_2:
        print(ans_2)
        break
else:
    print(ans_1)

Submission status: Accepted

Solution code:
#n=int(input())
x,n=map(int,input().split())
pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=x
if not x in pl:
    ans=x
else:
    for i in range(1,1000):
        x1=x+i
        x2=x-i
        if not x2 in pl:
            ans=x2
            break
        elif not x1 in pl:
            ans=x1
            break
print(ans)

Submission status: Accepted

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

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

def func(x, p):
    d = {}

    for i in range(len(p)):
        if p[i] not in d.keys():
            d[p[i]] = 1

    if x not in d.keys():
        return x

    p1 = x-1
    p2 = x+1

    odd = 1
    ans = 0

    while True:
        if odd == 1:
            if p1 not in d.keys():
                ans = p1
                break
            
            p1 -= 1
        else:
            if p2 not in d.keys():
                ans = p2
                break
            
            p2 += 1
        
        odd *= -1

    return ans

ans = func(x, p)
print(ans)

Submission status: Accepted

Solution code:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x,n,*p = map(int,read().split())
nums=list(range(-1,102))
for a in p:
    nums.remove(a)
ans=min(nums,key=lambda y: (abs(y-x),y))
print(ans)

Submission status: Accepted

Solution code:
def solve(x,n,p):
    if x not in p:
        return x
    tmps = x-1
    tmpl = x+1
    while True:
        if tmps not in p:
            return tmps
        if tmpl not in p:
            return tmpl
        tmps -= 1
        tmpl += 1

    

if __name__ == '__main__':
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    print(solve(x,n,p))

Submission status: Accepted

Solution code:
X,N = map(int,input().split())
p = list(map(int,input().split()))
min = 100
pp = list(map(lambda x: x-X, p))
i = 0
f = 0
while f == 0:
    if not i in pp:
        res = X + i
        break
    if i >= 0:
        i = -1 * (i +1)
    else:
        i = -1 * i
print(res)

Submission status: Accepted

Solution code:
X, N = [int(x) for x in input().split()]

if N > 0:
    p = [int(x) for x in input().split()]

    for i in range(N + 1):
        if X - i not in p:
            print(X - i)
            break
        elif X + i not in p:
            print(X + i)
            break
else:
    print(X)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
d={int(x):True for x in input().split()}

temp=n
ans=0
while(True):
    if(temp not in d):
        ans=temp
        break
    temp+=1
temp=n
while(True):
    if(temp not in d):
        if(abs(n-temp)<=abs(n-ans)):
            ans=temp
        break
    temp-=1
print(ans)

Submission status: Accepted

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

if n == 0:
    print(x)
    quit()
p = set(map(int,input().split()))
dibba = 0
dif = float("inf")
for i in range(-100,201):
    if i not in p:
        diff = abs(x-i)
        if diff < dif:
            dif = diff
            dibba = i
print(dibba)

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
P = list(map(int, input().split()))
diff, ans = 1000, -1
for i in range(0, 102):
    if (P.count(i)):
        continue
    if (abs(i - x) < diff):
        diff = abs(i - x)
        ans = i
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,x= map(int, input().split())
mt = list(map(int, input().split()))
i=0
while(1):
    if((n-i) not in mt):
        print(n-i)
        break
    if((n+i) not in mt):
        print(n+i)
        break
    i+=1

Submission status: Accepted

Solution code:
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]

i = 0

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

while (True):
    a = X + i
    b = X - i
    if b in P and a not in P:
        print(a)
        break
    if a in P and b not in P:
        print(b)
        break
    if a not in P and b not in P:
        print(b)
        break
    i += 1

Submission status: Accepted

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

d = 0
while True:
    if X - d not in P:
        print(X - d)
        break
    if X + d not in P:
        print(X + d)
        break
    d += 1

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
L = list(map(int, input().split()))
i = 0
while True:
    if x-i not in L: print(x-i); break
    if i+x not in L: print(i+x); break
    i+=1

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
x, n = list(map(int, input().split()))
ps = set(map(int, input().split()))

diff = 0
while True:
    if x - diff not in ps:
        print(x - diff)
        break
    if x + diff not in ps:
        print(x + diff)
        break
    diff += 1

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
lp = list(map(int, input().split()))

lp.sort()

distance = 0
try:
    idx = lp.index(x)
    while True:
        distance += 1
        dmin = x-distance
        dmax = x+distance
        if (idx-distance) < 0 or dmin != lp[idx-distance]:
            print(dmin)
            exit()
        if (idx+distance) >= len(lp) or  dmax != lp[idx+distance]:
            print(dmax)
            exit()
except ValueError:
    print(x)
    exit()

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min((i for i in range(102) if i not in a), key=lambda y:abs(x-y)))

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
a = set(map(int, input().split()))
print(min([i for i in range(102) if i not in a], key=lambda y:abs(x-y)))

Submission status: Accepted

Solution code:
def main():
    # s1 = list(map(int,input().split()))
    s = [input().split() for l in range(2)]
    X, N, p, v = int(s[0][0]), int(s[0][1]), {int(x): int(x) for x in s[1]}, 0
    for i in range(0, 100, 1):
        if X - i not in p:
            v = abs(X - i)
            break
        elif X + i not in p:
            v = abs(X + i)
            break
    print(v)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys

if n==0:
  print(x)
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(0, 102) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)

Submission status: Accepted

Solution code:
import sys

X, N = map(int, input().split())
P = list(map(int, input().split()))
NL = [ i for i in range(0, 102) if i == X or i not in P ]

if len(P) == 0 or X not in P:
    print(X)
    sys.exit()

idx = NL.index(X)
if NL[idx + 1] - X >= X - NL[idx-1]:
    print(NL[idx-1])
else:
    print(NL[idx+1])

Submission status: Accepted

Solution code:
x, n = list(map(int, input().split()))
if not n:
  print(x) 
else:
  l = list(map(int, input().split()))
  dic = {} 
  for ll in l: dic[ll] = 1
  i = 0
  while True:
    if not dic.get(x-i,0):
      print(x-i)
      break
    elif not dic.get(x+i, 0):
      print(x+i) 
      break
    i+=1

Submission status: Accepted

Solution code:
#abc170
x, n = map(int, input().split())
ln = []
if n == 0:
  pass
else:
  ln = list(map(int, input().split()))
i = 0

while True:
    
    
    if (x-i in ln) == False:
        print(x-i)
        break
    elif (x+i in ln) == False:
        print(x+i)
        break  
    else:
        i +=1

Submission status: Accepted

Solution code:
x,n = map(int, input().split())
seq = [int(x) for x in input().split()]

def solve(x, n, seq):
    if n == 0:
        print(x)
        return

    lower = x - 1
    higher = x + 1

    seq_set = set()

    for i in range(n):
        current = seq[i]
        seq_set.add(current)
    
    
    while lower in seq_set and lower > 0:
        lower -= 1
    
    while higher in seq_set and higher <= 100:
        higher += 1
    
    lower_diff = abs(lower - x)
    higher_diff = abs(higher - x)

    if lower_diff and higher_diff > 1 and x not in seq_set:
        print(x)
    elif lower_diff <= higher_diff:
        print(lower)
    elif higher not in seq_set:
        print(higher)
    else:
        print(x)
    

solve(x,n,seq)

Submission status: Accepted

Solution code:
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

Submission status: Accepted

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))
ans=0
m=abs(ans-x)
for i in range(102):
    if (not i in l) and m>abs(i-x):
        ans=i
        m=abs(i-x)
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]


dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(inc_num)
            break

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for i in range(N // 2 + 3):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
if N:
    p = list(map(int, input().split()))
    for i in range(N // 2 + 3):
        if X - i not in p:
            print(X - i)
            break
        if X + i not in p:
            print(X + i)
            break
else:
    print(X)

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
p_list = list(map(int, input().split()))

if N == 0: #①
   print(X)
else:
   for i in range(0,100):#②
       if not X-i in p_list:#③
           print(X-i)
           break
       elif not X+i in p_list:
           print(X+i)
           break

Submission status: Accepted

Solution code:
x,n= map(int, input().split())
p=list(map(int, input().split()))
ans=105

for i in range(-100,102):
    if i in p:
        continue
    if ans>abs(x-i):
        ans=abs(x-i)
        s=i
print(s)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
x, n = map(int,input().split())
p = [int(i) for i in input().split()]

tmp = 2000
ans = 2000
for i in range(-50, 105):
    if not i in p:
        if tmp > abs(x - i):
            tmp = abs(x - i)
            ans = i
print(ans)

Submission status: Accepted

Solution code:
X,N = map(int,input().split())
A = [int(i) for i in input().split()]

ans = 0

for i in range(1,102):
  if i in A:
    pass
  else:
    if abs(ans - X) > abs(i-X):
      ans = i
print(ans)

Submission status: Accepted

Solution code:
x,y = map(int,input().split(" "))
if y == 0:
    print(x)
    exit()
ar = list(map(int,input().split(" ")))
if x not in ar:
    print(x)
else:
    a = x
    b = x
    while True:
        a -= 1
        if a not in ar:
            print(a)
            exit()
        b += 1
        if b not in ar:
            print(b)
            exit()

Submission status: Accepted

Solution code:
import bisect
num = []
X, N = map(int, input().split())

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

if len(num) > 0:
    num.sort()
    id = bisect.bisect_left(num, X)

    #travel upward
    idDown = id
    down = X
    while (idDown >= 0) and (down == num[idDown]):
        down -= 1
        idDown -= 1

    idUp = id
    up = X
    while (idUp < N) and (up == num[idUp]):
        up += 1
        idUp += 1

    if (X - down) <= (up - X):
        print(down)
    else:
        print(up)

else:
    print(X)

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
P = list(map(int, input().split()))
INF = 10**18
ans = INF
for i in range(-100, 102):
    if i in P:
        continue
    if ans > abs(x-i):
        ans = abs(x-i)
        cnt = i
print(cnt)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
x,n = ma()
P = list(ma())
import collections
co = collections.Counter(P)
mi = -1
ab = 10**9
for i in range(-1,102):
    if abs(x-i) <ab:
        if co[i] >0:
            continue
        ab = abs(x-i)
        mi = i
print(mi)

Submission status: Accepted

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

d = 1001
for i in range(102):
    if i in p:
        continue
    if abs(x-i) < d:
        d = abs(x-i)
        ans = i
print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    diff = INF
    ans = X if X not in s else None
    for i in range(-1, 102):
        if i in s:
            continue

        tmp = abs(X - i)
        if tmp < diff:
            diff = tmp
            ans = i

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
y = 101
#ans = x
if n == 0:
  print(x)
else:
  for i in range(0,102):
    #if i != x:
      if p.count(i) == 0:
        #print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
          #print('i=',i,'abs=',abs(x-i),'ans=',ans)
  print(ans)

Submission status: Accepted

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    x,n = map(int, input().split())
    p = list(map(int, input().split()))
    l = [abs(i-x) if i not in p else 103 for i in range(102)]

    ans = l.index(min(l))
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
X, N = [int(x) for x in input().split()]

def main(X, N):
    if N == 0:
        return X
    arrp = [int(x) for x in input().split()]
    minus = X
    plus = X
    while True:
        if minus not in arrp:
            print(minus)
            exit()
        if plus not in arrp:
            print(plus)
            exit()
        minus -= 1
        plus += 1

print(main(X, N))

Submission status: Accepted

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


absp= list()
for i in p:
    absp.append(i-x)


absp = sorted(absp, key=abs)


uper, lower = 0, 0
while True:
    if not lower in absp:
        print(x+lower)
        exit()

    elif not uper in absp:
        print(x+uper)
        exit()

    uper += 1
    lower += -1

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
a = list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
arr = set(map(int, input().split()))
dif = 0
while True:
  if x - dif not in arr:
    print(x - dif)
    break
  if x + dif not in arr:
    print(x + dif)
    break
  dif += 1

Submission status: Accepted

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

min=0
dev=200

for i in range(0,102):
  if i in p or abs(x-i)>=dev:
    continue
  dev=abs(x-i)
  min=i
print(min)

Submission status: Accepted

Solution code:
X,N = input().split()
list = [int(x) for x in input().split()]

min_num = [300, abs(int(X) - 300)]

for a in range(0,102):
    A = abs(int(X) - a)
    
    if a in list:
        continue
        
    else:
        if A > min_num[1]:
            continue
            
        elif A == min_num[1]:
            min_num[0] = min(a,min_num[0])
            min_num[1] = abs(int(X) - min_num[0])
            
        elif A < min_num[1]:
            min_num[0] = a
            min_num[1] = abs(int(X) - min_num[0])
            
print(min_num[0])

Submission status: Accepted

Solution code:
x,n=map(int,input().split())
if n!=0:
  p=list(map(int,input().split()))
  p2=list(map(lambda s:s-x,p))
a=0
i=0
if n==0:
  print(x)
else:
  while a==0:
    if i in p2:
      if i==0:
        i=-1
      elif i>0:
        i=-1*(i+1)
      else:
        i=-1*i
    else:
      print(x+i)
      a=1
      break

Submission status: Accepted

Solution code:

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

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


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

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

Submission status: Accepted

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

if N == 0:
  ans = X
else:
  p = list(map(int, input().split()))
  ans = 0
  for i in range(200):
    if i in p:
      continue
    else:
      dis = i - X
      if dis < abs(ans - X):
        ans = i

print(ans)

Submission status: Accepted

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000
applied = 1000
for i in range(-1,102):
    if i in p:
        pass
    else:
        dif = abs(x-i)
        if dif < ans:
            ans = dif
            applied = i
        else:
            pass
print(applied)

Submission status: Accepted

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 1000
applied = 1000
for i in range(-100,102):
    if i in p:
        pass
    else:
        dif = abs(x-i)
        if dif < ans:
            ans = dif
            applied = i
        else:
            pass
print(applied)

Submission status: Accepted

Solution code:
a,b = map(int, input().split())
if b>0:
	p = list(map(int, input().split()))
else:
	print(a)
	exit()

n = a
m = a

for i in range(b+1):
	"""
	print(n)
	print(m)
	print("")
	"""
	if n in p:	
		n = n-1			
	else:

		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
p = set(map(int, input().split()))
if n == 0:
    print(x)
else:
    for i in range(101):
        if x - i not in p:
            print(x - i)
            break
        elif x + i not in p:
            print(x + i)
            break

Submission status: Accepted

Solution code:
X,N = map(int, input().split())
p = []
if N > 0:
  p = list(map(int, input().split()))
a = list(range(0, 111))
a = [item for item in a if item not in p]
res = a[0]
m = abs(res - X)
for i in a:
  j = abs(i - X)
  if j < m:
    m = j
    res = i
    
print(res)

Submission status: Accepted

Solution code:
X, N = map(int, input().split())
if N==0:
    print(X)
else:
    p = list(map(int, input().split()))
    
    for i in range(0,102):
        down = X - i
        up = X + i
        if down in p and up in p:
            pass
        elif down in p:
            temp = up
            break
        else:
            temp = down
            break



    print(temp)

Submission status: Accepted

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
min = float('inf')

for i in range(0, 102)[::-1]:
    if abs(x - i) <= min:
        if i not in p:
            min = abs(x - i)
            ans = i

print(ans)

Submission status: Accepted

Solution code:
import sys
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
lis = [i for i in range(102)]
for val in p:
    if val in lis:
        lis.remove(val)

d = {}
for i in lis:
    d[i] = abs(i - X)
ds = sorted(d.items(), key=lambda x: x[1])
print(ds[0][0])

Submission status: Accepted

Solution code:
x,n = [int(i) for i in input().split()]
if n == 0:
  print(x)
  exit()
p = [int(i) for i in input().split()]

num = list(range(102))
nums = []
for i in num:
  if not(i in p):
    nums.append(i)
#print(nums)
p2 = [abs(nums[i]-x) for i in range(len(nums))]
p2min = min(p2)
for i in range(len(p2)):
  if p2[i] == p2min:
    print(nums[i])
    exit()

Submission status: Accepted

Solution code:
target, N = [int(x) for x in input().split(" ")]
if N == 0:
    print(target)
else:
    p_array = [int(x) for x in input().split(" ")]

    for i in range(N+1):
        superior = target - i
        if not(superior in p_array):
            print(superior)
            break

        inferior = target + i
        if not(inferior in p_array):
            print(inferior)
            break

Submission status: Accepted

Solution code:
x,n=map(int,input().split())
List=set(list(map(int,input().split())))
if(n==0):
  print(x)
else:
  i=j=x
  ans=x
  while True:
    if(i not in List):
      ans=i
      break
    if(j not in List):
      ans=j
      break
    else:
      i-=1
      j+=1

      
  print(ans)

Submission status: Accepted

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

    for i in range(51):
        a = x - i
        b = x + i
        if a not in p and a >= 0:
            print(a)
            return
        if b not in p and b <= 101:
            print(b)
            return
    
        
if __name__ == '__main__':
    main()

Submission status: Accepted

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


if p == []:
    print(x)
    exit()

for i in range(101):
    if (x - i) not in p or (x + i) not in p:
        if x - i in p:
            print(x + i)
            exit()
        print(x - i)
        exit()

Submission status: Accepted

Solution code:
def main():
  ## IMPORT MODULE
  #import sys

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    x, n = 6, 5
    P = [4, 7, 10, 6, 5]

  else:
    ##INPUT 
    #n = input()
    x, n = map(int, input().split())
    if n == 0:
      P = []
    else: 
      P = list(map(int, input().split()))

  ## SUBMITION CODES HERE
  for i in range(1, 100):
    if x - i not in P:
        dif_mis = x-i
        break

  for i in range(0, 100):
    if x + i not in P:
        dif_pls = x+i
        break

  if (x-dif_mis)**2 > (x-dif_pls)**2:
    print(dif_pls)
  else:
    print(dif_mis)

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
X,N = map(int, input().split())
p = list(map(int, input().split()))
dif = 1

if(X not in p):
    print(X)
else:
    while True:
        if(X-dif not in p):
            dif = dif*(-1)
            break
        elif(X+dif not in p):
            break
        else:
            dif=dif+1
    print(X+dif)

Submission status: Accepted

Solution code:
import numpy as np

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

num_list = list(set([*range(0,102)]) - set(p_list))

diff = np.abs(np.array(num_list)-X)
diff_arg_min = np.argmin(diff)

print(num_list[diff_arg_min])