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: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
b.pop(0)
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if k==len(nl)-1:
    print(nl[k-1])
else:
    j=nl[k+1]-x
    if i<=j:
        print(nl[k-1])
    else:
        print(nl[k+1])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if nl.count(x)==2:
    print(x)
else:
    if k==len(nl)-1:
        print(nl[k-1])
    else:
        j=nl[k+1]-x
        if i<=j:
            print(nl[k-1])
        else:
            print(nl[k+1])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if k==len(nl)-1:
    print(nl[k-1])
else:
    j=nl[k+1]-x
    if i<=j:
        print(nl[k-1])
    else:
        print(nl[k+1])

Submission status: Wrong Answer

Solution code:
def main():
  x,n = [int(i) for i in input().split()]
  table = list(map(int, input().split()))
  
  for i in range(101):
    if x - i not in table:
      print(x-i)
      exit()
    elif x + i not in table:
      print(x+1)
      exit()
    	
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if k==len(nl)-1:
    j=105
else:
    j=nl[k+1]-x
if i<=j:
    print(nl[k-1])
else:
    print(nl[k+1])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
i=x-nl[k-1]
if k==len(nl)-1:
    j=100
else:
    j=nl[k+1]-x
if i<=j:
    print(nl[k-1])
else:
    print(nl[k+1])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input().split()))
p=list(map(int,input().split()))
x=a[0]
n=a[1]
b=list(range(101))
c=list(set(p)^set(b))
c.append(x)
nl=sorted(c)
k=nl.index(x)
print(nl[k-1])

Submission status: Wrong Answer

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

if(N>0):
  P = list(map(int,input().split()))
  #P = list(range(1,101))
  PP = []
  for i in range(1,101):
    if i not in P:
      PP.append(i)
  if len(PP)>0:
    lo = 0
    hi = len(PP)-1
    while(lo<hi):
      mid = lo + ((hi - lo)//2)
      if PP[mid]<= X:
        lo = mid + 1
      else:
        hi = mid
    n1 = PP[lo]
    n2 = PP[lo-1]
    if abs(X-n1)<abs(X-n2):
      print(n1)
    else:
      print(n2)
  else:
    print(X)
else:
  print(X)

Submission status: Wrong Answer

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

if N > 0:
  p = list(map(int, input().split()))
  A = list(range(1, max(X, max(p)) + 1))
else:
  p = []
  A = []
S = list(set(A) - set(p))
S.sort()

min_v = X
ans_v = X
for c in list(S):
  if abs(c - X) < min_v:
    ans_v = c
    min_v = abs(c - X)

print(ans_v)

Submission status: Wrong Answer

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

if N > 0:
  p = list(map(int, input().split()))
  A = list(range(1, max(p) + 1))
else:
  p = []
  A = []
S = list(set(A) - set(p))
S.sort()

min_v = X
ans_v = X
for c in list(S):
  if abs(c - X) < min_v:
    ans_v = c
    min_v = abs(c - X)

print(ans_v)

Submission status: Wrong Answer

Solution code:
import sys

X, N = (int(x) for x in input().split())
if N != 0:
  p = set([int(x) for x in input().split()])
else:
  print(X)
  sys.exit()

x = X
while x in p:
    x -= 1
minX = x

x = X
while x in p:
    x += 1
maxX = x

if abs(minX - X) < abs(maxX - X):
    print(minX)
else:
    print(maxX)

Submission status: Wrong Answer

Solution code:
import sys

X, N = (int(x) for x in input().split())
if N != 0:
  p = [int(x) for x in input().split()]
else:
  print(X)
  sys.exit()

ans = X
for i in range(0, 101, -1):
    if X + i not in p:
        ans = X + i
    if X - i not in p:
        ans = X - i
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

x, n = map(int, input().split())
p = list(map(int, input().split()))
if len(p) == 0:
    print(x)
    exit()
p.sort()
p = [-1] + p + [101]
idx = bisect.bisect_left(p, x)
mi = x
ma = x
for i in range(idx, -1, -1):
    if p[i] != mi:
        break
    mi -= 1
for i in range(idx, n):
    if p[i] != ma:
        break
    ma += 1
if abs(x - mi) < abs(x - ma):
    print(mi)
elif abs(x - ma) < abs(x - mi):
    print(ma)
else:
    print(mi)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if(N != 0):
    p = set(list(map(int, input().split())))
else:
    print(X)
    exit()

result = []

for i in range(101):
    result.append(i)

ans = set(result)-p
ans1 = 1*10**50


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if(N != 0):
    p = set(list(map(int, input().split())))
else:
    print(X)
    exit()

result = []

for i in range(max(p)):
    result.append(i)

ans = set(result)-p
ans1 = 1*10**50


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])

Submission status: Wrong Answer

Solution code:
import sys
number, length = [int(i) for i in input().split()]
try:
    the_list = [int(j) for j in input().split()]
except:
    print(number)
    sys.exit()

if len(the_list) == 0:
    print(number)
    sys.exit()

the_list.sort()

new_list = [z for z in range(1, the_list[-1]) if z not in the_list]


abs_difference = 100000000000000
value = 0

for i in new_list:
    temp_difference = abs(number-i)
    if temp_difference < abs_difference:
        abs_difference = temp_difference
        value = i

print(value)

Submission status: Wrong Answer

Solution code:

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

result = []

for i in range(max(p)):
    result.append(i)

ans = set(result)-p
ans1 = 1000000000000


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])

Submission status: Wrong Answer

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

sett=list(map(int,input().split()))
arr=[i for i in range(1,151) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)

Submission status: Wrong Answer

Solution code:

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

result = []

for i in range(max(p)):
    result.append(i)

ans = set(result)-p
ans1 = 1000000000000

print(ans)

for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        print(ans1, abs(i-X))
        index = count

print(list(ans)[index])

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
P = set(map(int, input().split()))
if n==0:
    print(x)
elif n==100 and x<=50:
    print(0)
elif n==100 and 50<x:
    print(101)
else:
    T = set(list(range(-1, 101))) - P
    diff = 101
    for t in T:
        if diff > abs(x-t):
            diff = abs(x-t)
            ans = t
    print(ans)

Submission status: Wrong Answer

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

sett=list(map(int,input().split()))
arr=[i for i in range(1,101) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
P = set(map(int, input().split()))
if n==0:
    print(x)
elif n==100 and x<=51:
    print(0)
elif n==100 and 51<x:
    print(101)
else:
    T = set(list(range(100))) - P
    diff = 101
    for t in T:
        if diff > abs(x-t):
            diff = abs(x-t)
            ans = t
    print(ans)

Submission status: Wrong Answer

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

sett=set(map(int,input().split()))
arr=[i for i in range(1,101) if i not in sett]

min_=100000
num=0
for i in arr:
	if abs(x-i)<min_:
		min_=abs(x-i)
		num=i



print(num)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
P = set(map(int, input().split()))
if n==0:
    print(x)
elif n==100 and x<=50:
    print(0)
elif n==100 and 50<x:
    print(101)
else:
    T = set(list(range(100))) - P
    diff = 101
    for t in T:
        if diff > abs(x-t):
            diff = abs(x-t)
            ans = t
    print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if not N:
  print(X)
  exit()

p = set(map(int, input().split()))
n = set(range(-100, 101))
l = n - p
ans = 10000
a = 10000
for i in l:
  tmp = abs(X - i)
  if a > tmp:
    a = tmp
    ans = i
  elif a == tmp:
    ans = min(ans, i)
    
print(ans)

Submission status: Wrong Answer

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

p,f = x-1,x+1
bans = set(map(int,input().split()))
while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1

Submission status: Wrong Answer

Solution code:
X, N = (int(i) for i in input().split())  
p = list(int(i) for i in input().split())  
cnt = 1000
res = 0
for i in range(101):
  if i in p :
    cnt = cnt
  else:
    if abs(X-i) < cnt :
      cnt = abs(X-i)
      res  = i
print(res)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 101
ans = 101
for i in range(-100,100+1):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
print(101)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 101
ans = 101
for i in range(1,100+1):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
s = 100
ans = 100
for i in range(100+1):
    if not i in p:
        if s > abs(x-i):
            s = abs(x-i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from math import floor,ceil,sqrt
# import bisect
# from collections import deque

# from types import GeneratorType
# def bootstrap(func, stack=[]):
#     def wrapped_function(*args, **kwargs):
#         if stack:
#             return func(*args, **kwargs)
#         else:
#             call = func(*args, **kwargs)
#             while True:
#                 if type(call) is GeneratorType:
#                     stack.append(call)
#                     call = next(call)
#                 else:
#                     stack.pop()
#                     if not stack:
#                         break
#                     call = stack[-1].send(call)
#             return call
#     return wrapped_function

Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
 
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 18
MOD = 10**9+7

x,n = Ri()
a = Ri()

s =  set([i for i in range(1,101)])
for i in a:
    if i in s:
        s.remove(i)

val = -1
dif = INF
for i in s:
    if abs(x - i) < dif:
        dif = abs(x-i)
        val = i

print(val)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_left
x, n = [int(i) for i in sys.stdin.readline().split()]
p_s = [int(i) for i in sys.stdin.readline().split()]
candidate = [i for i in range(1,1000) if i not in p_s]
ind = bisect_left(candidate, x)
if ind == len(candidate):
    print(candidate[-1])
elif ind == 0:
    print(candidate[-1])
elif x - candidate[ind-1] <= candidate[ind] - x:
    print(candidate[ind-1])
else:
    print(candidate[ind])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys
X, N = map(int, input().split())
if(N == 0):
    print(X)
    exit()
p = list(map(int,input().split()))

min = 1000
min_check = 0
l = list(range(1,100))
l_ans = list(set(l) - set(p))
num1 = 0
ans = 0
for i in range(0,len(l_ans)):
    num1 = X-l_ans[i]
    if(abs(num1) < min):
        min = abs(num1)
        ans = l_ans[i]
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = [0] * 102
k = 999

for i in range(0, 101):
  for j in range(N):
    if p[j] == i:
      l[i] = 1
    j = j+1
  i = i+1
for i in range(-1, 100):
  i = i+1
  if l[i] == 1:
    continue
  k = min(k, abs(X-i))

if l[X-k] == 1:
    print(X+k)
else:
    print(X-k)

Submission status: Wrong Answer

Solution code:
def main():
    x, n = map(int, input().split())
    r = [i for i in range(1, 101)]
    np = [int(i) for i in input().split()]
    p = list(set(r) - set(np))
    p.sort()
    for i in range(len(p)):
        if p[i] >= x:
            if abs(p[i - 1] - x) > abs(p[i] - x):
                print(p[i])
            else:
                print(p[i - 1])
            exit()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

koho = [i for i in range(1, 200) if i not in P]

koho.sort(key=lambda a: (abs(a - x), a))

print(koho[0])

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(min(inp),max(inp)+1):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(1,113):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
  print(x)
  exit(0)
inp = list(map(int,input().split()))
a = []
for i in range(1,101):
  if i not in inp:
    a.append(i)

res = 0
minn = 1e5
for i in a:
  if abs(i-x) < minn:
    minn = abs(i-x)
    res = i
    
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    x, n = LI()
    p = LI()
    ans = 0
    for i in range(101):
        if not i in p:
            if abs(ans - x) > abs(x - i):
                ans = i
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,101):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,101):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a <= 0:
		print(b)
		exit(0)
	elif b > 100:
		print(a)
	elif abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)

Submission status: Wrong Answer

Solution code:
X,N= map(int,input().split())
p = list(map(int, input().split()))
ans_tmp = 10**9
ans = X
if N==0:
    print(X)
else:
    for i in range(0,102):
        if i not in p and ans_tmp>abs(X-i):
            ans_tmp=abs(X-i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X,N= map(int,input().split())
p = list(map(int, input().split()))
ans_tmp = 10**9+7
ans = 0
if N==0:
    print(X)
else:
    for i in range(0,102):
        if i not in p and ans_tmp>abs(X-i):
            ans_tmp=abs(X-i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X,N= map(int,input().split())
p = list(map(int, input().split()))
ans_tmp = 10**9+7
ans = 0
if N==0:
    print(X)
else:
    for i in range(0,102):
        if i in p:
            continue
        else:
            tmp = abs(i-X)
            if tmp <ans_tmp:
                ans = i
                ans_tmp= min(tmp,ans_tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b = map(int, input().split())
if not b:
    print(a)
    exit()
arr = list(map(int, input().split()))
o = -1
m = 999999
for i in range(min(arr), max(arr)):
    if i not in arr and abs(i-a) < m:
        m = abs(i-a)
        o = i
print(o)

Submission status: Wrong Answer

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())
se = frozenset(P)

def gen_nums(X):
  low, high = X, X+1
  while True:
    yield low
    yield high
    low, high = low-1, high+1

for x in gen_nums(X):
  if x not in se:
    break

print(x)

Submission status: Wrong Answer

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

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

p.sort()

ans = 1000000

memo = x

for i in range(0,101):
    if i not in p and abs(i-x) < ans:
        ans = abs(i-x)
        memo = i
print(memo)

Submission status: Wrong Answer

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


for i in range(1,N+1):
    a = X+i
    b = X-i
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break

if N==0:
    print(X)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split(" "))
if N==0:
  print(X)
  exit()
P = list(map(int, input().split(" ")))
P.sort()

for i in range(N):
  if(P[i] > X):
    L = P[:i][::-1]
    U = P[i:]
    break
  elif(i == N-1):
    L = P[::-1]
    U = []

if (len(L) == 0 or L[0] != X):
  print(X)
  exit()

lans = -1
for i in range(1, len(L)):
  if (L[i-1] - L[i] > 1):
    lans = L[i-1]-1
    break
if(lans == -1):
  lans = L[len(L)-1]-1

if (len(U) == 0 or U[0] != X+1):
  uans = X+1
else:
  uans = -1
  for i in range(1, len(U)):
   if (U[i] - U[i-1] > 1):
      uans = U[i-1]+1
      break
  if(uans == -1):
    uans = U[len(U)-1]+1

print(L)
print(U)
if(abs(lans-X) <= abs(uans-X)):
  print(lans)
else:
  print(uans)

Submission status: Wrong Answer

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

# n=0の時の例外処理
if n==0:
  print(x)
  sys.exit()

for i in range(1, 101):
  if not((x-i) in ps):
    print(x-i)
    sys.exit()
  if not((x+i) in ps):
    print(x+i)
    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(1, 101):
  if not((x-i) in ps):
    print(x-i)
    sys.exit()
  if not((x+i) in ps):
    print(x+i)
    sys.exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(1, 101) if i not in P]
    mx = 102
    for p in NP:
        if abs(x-p) < abs(x-mx):
            mx = p
    print(mx)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = set(map(int, input().split()))
    NP = [i for i in range(0, 102) if i not in P]
    mx = 100
    for p in NP:
        if abs(x-p) < abs(x-mx):
            mx = p
    print(mx)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = [0] + list(map(int,input().split()))
ans = []
for i in range(max(p)+2):
    if i not in p:
        ans.append([abs(i-x),i])
ans.sort()
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = float('inf')
for i in range(101):
    if i not in p:
        if abs(i-x) < abs(ans-x):
            ans = i
        elif abs(i-x) == abs(ans -x):
            ans = min(ans,i)
print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = []
for i in range(101):
    if i not in p:
        ans.append([i - x,i])
ans.sort()
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,101):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,101):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a < 0:
		print(b)
		exit(0)
	elif b > 100:
		print(a)
	elif abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,101):
		if x - i in p:
			continue
		else:
			a = x - i
			break
	for j in range(1,101):
		if x + j in p:
			continue
		else:
			b = x + j
			break
	if a > 0 and abs(x-a) <= abs(x-b):
		print(a)
	else:
		print(b)
else:
	print(x)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
	print(x)
	exit(0)
if x in p:
	a,b = 0,0
	for i in range(1,11):
		if x + i in p:
			continue
		else:
			a = x + i
			break
	for j in range(1,11):
		if x - j in p:
			continue
		else:
			b = x - j
			break
	if abs(x-b) > abs(x-a):
		print(a)
	else:
		print(b)
else:
	print(x)

Submission status: Wrong Answer

Solution code:
import sys
X,N = map(int,input().split())
if N == 0:
  print(X)
  sys.exit()
  
p = list(map(int,input().split()))

for i in range(N):
  X_ = X+i
  _X = X-i
  
  if not _X in p:
    print(_X)
    sys.exit()
  elif not X_ in p:
    print(X_)
    sys.exit()

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
p = list(map(int, input().split()))
if len(p) == 0:
	print(x)
	exit(0)
a,b = 0,0
for i in range(1,11):
	if x + i in p:
		continue
	else:
		a = x + i
		break
for j in range(1,11):
	if x - j in p:
		continue
	else:
		b = x - j
		break
if abs(x-b) > abs(x-a):
	print(a)
else:
	print(b)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  q = [True] * 102
  for i in range(n):
    q[p[i]] = False
  d_min = 10**3
  for j in range(1, 102):
    if q[j]:
      d = abs(x - j)
      if d_min > d:
        ans = j
  print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

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

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      if i+1 < d:
        d = i+1
      break
print(d)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if X <= 50:
  l = X
  d = 0
else:
  l = 101 - X
  d = 101

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

for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(0)
  else:
    print(101)
  exit()
else:
  p = set(map(int, input().split()))

l = X
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(-1)
  else:
    print(101)
  exit()
else:
  p = set(map(int, input().split()))

l = X+1
d = -1
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
elif N == 100:
  if X <= 50:
    print(-1)
  else:
    print(101)
  exit()
else:
  p = set(map(int, input().split()))

l = 101
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=[int(x) for x in input().split()]
min=x
gap=101-x
if x==1:
	print(0)
	exit()
for i in range(102):
	if i in p:
		continue
	else:
		#print("i:",i)
		if abs(x-i) < gap:
			gap=x-i
			min=i
print(min)

Submission status: Wrong Answer

Solution code:
x,n,*p=map(int,open(i:=0).read().split())
while x in p:x+=i*-1**i;i+=1
print(x)

Submission status: Wrong Answer

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

#
P_n = [i for i in range(1,102,1) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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

l = 100
d = 0
for i in range(100):
  if i+1 not in p:
    li = abs(X-i-1)
    if li < l:
      l = li
      d = i+1
    elif li >= l:
      break
print(d)

Submission status: Wrong Answer

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


P_n = [i for i in range(101) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(110) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(109) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(105) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(101) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(0,110,1) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break