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:
X, N = map(int,input().split())
if N > 0:
  P = set([int(_) for _ in input().split()])
else:
  P = set()
  
candidates = [i for i in range(-1,101) if i not in P]

candidates = sorted(candidates, key = lambda i: abs(i - X))

print(candidates[0])

Submission status: Wrong Answer

Solution code:
x, n=map(int, input().split())
try:
  l=list(map(int, input().split()))
except EOFError:
  print(x)
  exit()
for i in range(100-x):
  if x+i in l and x-i in l:
    continue
  elif x+i in l:
    print(x-i)
    exit()
  elif x-i in l:
    print(x+i)
    exit()
  else:
    print(x-i)
    exit()

Submission status: Wrong Answer

Solution code:
def resolve():
    X, N = map(int, input().split())
    if N != 0:
        P = list(map(int, input().split()))
        if X in P:
            for j in range(1, N):
                if X-j in P:
                    continue
                else:
                    print(X-j)
                    exit()
                if X+j in P:
                    continue
                else:
                    print(X+j)
                    exit()
        else:
            print(X)
    else:
        print(X)
resolve()

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    P = list(map(int, input().split()))
    for i in range(1,102):
        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: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N!=0:
    p=list(map(int,input().split()))
    checkNum=[0 for j in range(101)]
    for i in range(len(p)):
        checkNum[p[i]]=1
    i=0
    while(X-i>=0 or X+i<=100):
        if X-i>=0:
            if checkNum[X-i]==0:
                print(X-i)
                break
        if X+i<=100:
            if checkNum[X+i]==0:
                print(X+i)
                break
        i+=1
else:
    print(X)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
P = [int(i) for i in input().split()]
ans = 100000
for i in range(1,101):
    if i in P:
        pass
    else:
        if abs(X - ans) > abs(X-i):
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x, n =map(int, input().split())
l = list(map(int, input().split()))
if n == 0:
    print(x)
elif not(x in l):
     print(x)   
else:
    for i in range(n//2):
        if not(x - i in l):
            print(x-i)
            break
        elif not (x+i in l):
            print(x+i)
            break

Submission status: Wrong Answer

Solution code:
def main():
    x, n = map(int,input().split())
    li = list(map(int,input().split()))
    li.sort()
    ans = 0
    j = 0
    for i in range(101):
        if li == []:
            if abs(ans - x) > abs(i - x):
                ans = i
        elif li[j] == i:
            if j != n-1:
                j += 1
        else:
            if abs(ans - x) > abs(i - x):
                ans = i
    print(ans)
        

 
 
if __name__ == '__main__':
  main()

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 = map(int, readline().split())
p = set(map(int, readline().split()))

ans = x
tmp = 10 ** 9
for i in reversed(range(101)):
    if i not in p:
        if tmp >= abs(x - i):
            tmp = abs(x - i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
P =  set(map(int, input().split()))
Nums = set(range(1, 101))
Nums = Nums - P
sorted(Nums)


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

print(minIndex)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))
t = list(range(-100,101))
u = set(t)-set(p)
u = list(u)
u.sort()
dif = 2**60
ans = 2**60
for a in u:
    tmp = abs(a-x)
    if dif > tmp:
        ans = a
        dif = tmp
    elif dif == tmp:
        if ans > a:
            ans = a
if x <= dif:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
X,N=map(int, input().split())
P=sorted(list(map(int, input().split())))
pabs=[]
for p in P:
	pabs.append(abs(X-p))

pabs.sort()


cnt=0
temp=0

if 0 in pabs:
	for i in range(1,max(pabs)):
		
		if i in pabs:
			
			if pabs.count(i)==1:
				if X-i not in P:
					print(X-i)
					break
				else:
					print(X+i)
					break
				
			else:
				continue
			
		else:
			print(X-1)
			break
									
else:
	print(X)

Submission status: Wrong Answer

Solution code:
nums=[int(s) for s in input().split()]

x=nums[0]
n=nums[1]

if n==0:
  print(x)
else:
  row=[int(s) for s in input().split()]
  ls=[]
  for i in range(-100,101):
    if i not in row:
      ls.append(abs(i-x))

  ls.sort()
  if x-ls[0] not in row:
    print(x-ls[0])
  else:
    print(x+ls[0])

Submission status: Wrong Answer

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

tmp = 1000
result = []
result2 = []
for i in range(0, 101):
    if i in A:
        continue

    hoge = abs(X - i)
    if hoge <= tmp:
        tmp = hoge
        result2.append(tmp)
        result.append(i)

result3 = []
for i, v in enumerate(result2):
    if v == min(result2):
        result3.append(result[i])

print(min(result3))

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
pp = set(p)
numlist = [i for i in range(1, 101)]
numlistt = set(numlist)
newlist = numlistt - pp
newlistt = list(newlist)
newlisttt = newlistt.sort()
absn = 100
ans = 1000

for i in newlistt:
    if absn > abs(X-i):
        if absn == abs(X-i):
            break
        else:
            ans = i
            absn = abs(X-i)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

d = list(range(p[0]-1,p[N-1]+1))
ans = []
for i in d:
    if not(i in p):
        ans.append(i)
res = 1e+9
c = 0
for i in ans:
    tmp = abs(X-i)
    if tmp < res:
        res = tmp
        c = i
print(c)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
if 1 < N:
    P = list(map(int,input().split()))
    count1 = int()
    count2 = int()
    ans1 = 101
    ans2 = 101
    i = 0
    while 100 < ans1 and 100 < ans2:
        count1 = X-i
        count2 = X+i
        if P.count(count1) == 0:
            ans1 = count1
        if P.count(count2) == 0:
            ans2 = count2
        i += 1
    if ans1 < ans2:
        print(ans1)
    else:
        print(ans2) 
else:
    print(X)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  flag = True
  i = 0
  ans_min, ans_max = 0, 0
  while flag:
    cand = max(X - i, 1)
    if not cand in p:
      ans_min = cand
      flag = False
    cand = min(X + i, 100)
    if not cand in p:
      ans_max = cand
      flag = False
    i += 1
    
  if ans_min != 0:
    print(ans_min)
  else:
    print(ans_max)

Submission status: Wrong Answer

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

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

num_list = list(map(int,input().split()))
i = 1

while True:
  if (x-i) not in num_list:
    print(x-i)
    break
  elif (x+i) not in num_list:
    print(x+i)
    break
  i += 1

Submission status: Wrong Answer

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

if N == 0:
    print(X)


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

Submission status: Wrong Answer

Solution code:
import numpy as np

a = input()
a, b = a.split()
a = int(a)
if int(b) == 0:
  print(a)
  exit()
n = input()
n = [int(i) for i in n.split()]
li = []
for i in range(min(n), max(n) + 1):
  if i in n:
    pass
  else:
    li.append(i)
mini = [np.inf, 0]
for i in li:
  if abs(i - a) == mini[0]:
    if i < mini[1]:
      mini = [abs(i - a), i]
  elif abs(i - a) < mini[0]:
    mini = [abs(i - a), i]
print(mini[1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
else:
  l = list(map(int, input().split()))
  for i in range(50):
    if x+i not in l:
      print(x+i)
      sys.exit()
    elif x-i not in l:
      print(x-i)
      sys.exit()

Submission status: Wrong Answer

Solution code:
X, N = map( int, input().split() )
ret = X
if N > 0:
  P = sorted( list( map( int, input().split() ) ))
  dis = 10 ** 18
  for i in range( 100, -1, -1 ):
    if i in P:
      continue
    if dis - abs( i - X ) >= 0:
      ret = i
      dis = abs( i - X )
  
print( ret )

Submission status: Wrong Answer

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

hidden_L = [i+1 for i in range(100)]

for A_i in A_L:
    hidden_L.remove(A_i)

counter = 0

while True:
    minus = X - counter
    plus  = X + counter
    if minus in hidden_L:
        print(str(minus))
        break
    if plus in  hidden_L:
        print(str(plus))
        break
    counter = counter + 1

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
if N==0: print(100)
else:
    p=list(map(int,input().split()))
    ans=10000
    m=100
    for i in range(100):
        if m>(i+1)-X and (not i+1 in p):
            if abs(ans-X)!=abs((i+1)-X):
                ans=i+1
            m=abs((i+1)-X)
    print(ans)

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(101);a=1000;b=1000;c=10000
for i in range(N):
  S[P[i]]=1
#print(S)
if N==0:
  print(X)
else:
  i=X-1
  while i>0:
    if S[i]==0:
      a=i
      break
    i=i-1
  i=X+1
  while i<100:
    if S[i]==0:
      b=i
      break
    i=i+1
  #print(a,b)
  if abs(a-X)>abs(b-X):
    c=b
  else:
    c=a
  print(c)

Submission status: Wrong Answer

Solution code:
import math
x,n=map(int,input().split())
if n==0:
  p=[]
else:
  p=list(map(int,input().split()))
p_sort=sorted(p)
result={}
for i in range(100+1):
  if not i in p_sort:
    result[i]=abs(x-i)
print(min(result, key=result.get))

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
hazusu=list(map(int,input().split()))
kouho=100
ans=0
for i in reversed(range(-2,101)):
    if i in hazusu:
        continue
    d=abs(X-i)
    if d<=kouho:
        kouho=d
        ans=i
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

X, N = read_ints()
if N == 1:
    print(X)
    exit()
P = read_ints()

for i in range(101):
    b = X + i
    a = X - i
    if a not in P:
        print(a)
        exit()
    if b not in P:
        print(b)
        exit()

Submission status: Wrong Answer

Solution code:
import collections
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
p=list(map(lambda i:abs(x-i),p))
c=collections.Counter(p)
p.sort()

for i in range(len(p)):
  if p[i]!=(i+1)//2:
    if p[i-1]==p[i-2]:
      if x-p[i-1]-1 in p:
        print(x+p[i-1]+1)
      else:
        print(x-p[i-1]-1)
      sys.exit()
    elif i==1:
      if x-1 in p:
        print(x+1)
      else:
        print(x-1)
      sys.exit()
    elif i==0:
      print(x)
      sys.exit()
    else:
      if x-p[i-1] in p:
        print(x+p[i-1])
      else:
        print(x-p[i-1])
      sys.exit()
print(x)

Submission status: Wrong Answer

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

	for i in range(1, 100):
		a = x-i
		b = x+i
		if a not in line:
			print(a)
			exit()
		if b not in line:
			print(b)
			exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
anss = [101] * 103
r = list(range(0, 101))
r.append(-1)
for i in r:
  if (i not in ps):
    anss[i] = abs(x - i)
m = min(anss)
for i, ans in enumerate(anss):
  if ans == m:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)
for i in range(100):
    ll = np.append(ll,int(i+2))
    
for j in p:
    ll= ll[~(ll == j)]

if len(ll) == 0:
    print(x)
    exit()
# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))

Submission status: Wrong Answer

Solution code:
x, n = (int(each) for each in input().split())
if n == 0:
    print(x)
else:
    p = [int(each) for each in input().split()]
    candidate = 0
    for i in range(max(p)):
        if i not in p and abs(i-x) < abs(candidate-x):
            candidate = i
            # print('replaced')
    print(candidate)

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
p=list(map(int,input().split()))
if N==0:
  print(X)
else:
  for i in range(0,X+1):
    if abs(X-i) not in p or abs(X+i) not in p:
      print(max([abs(X-i),abs(X+i)]))
      break

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
P=list(map(int,input().split()))
hako=set(P)
#print(hako)
ans=[]
P.sort()
kari=[]
for i in range(-200,101):
    if i not in hako:
        kari.append(i)
for i in range(len(kari)):
    ans.append([abs(X-kari[i]),kari[i]])
ans.sort()
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

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

i = 0
if X not in p:
    r = bisect_left(p, X)
    l = r-1
    if abs(p[l]-X) <= abs(p[r]-X):
        print(p[l])
    else:
        print(p[r])
else:
    i = 1
    while p[p.index(X)] + i in p:
        i += 1
    up = p[p.index(X)] + i
    
    i = 1
    while p[p.index(X)] - i in p:
        i += 1
    down = p[p.index(X)] - i

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

Submission status: Wrong Answer

Solution code:
c,x = map(int,input().split())
if not x:
    print(c)
    exit()
a = list(map(int,input().split()))
s = list(range(1,100+5))
for i in a:
    s.remove(i)

diffB = 99999
n = 9999

for i in s:
    if diffB > abs(c-i):
        diffB = abs(c-i)
        n = i
print(n)

Submission status: Wrong Answer

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

minv=100
v=0
if P:
  for i in range(-100,101):
    if not(i in P):
      if abs(X-i) < minv:
        minv=abs(X-i)
        v=i
else:
  v=X

print(v)

Submission status: Wrong Answer

Solution code:
#C
X,N = map(int,input().split())
p = list(map(int,input().split()))
r = 101
for i in range(100,0,-1):
    if i in p:
        pass
    else:
        if abs(r-X) >= abs(i-X):
            r = i
        else:
            pass
print(r)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
pli = [int(i) for i in input().split()]
ans = 0
for s in range(1, 100):
    if not x in pli:
        ans = x
    elif not x - s in pli and not x + s in pli:
        ans = x - s
        break
    elif x - s in pli and not x + s in pli:
        ans = x + s
        break
print(ans)

Submission status: Wrong Answer

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

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


a = 1
for m in range(100 + 1):
    if m in p:
        continue
    else:
        if abs(x - a) > abs(x - m):
            a = m

print(a)

Submission status: Wrong Answer

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

    check = [True]*101

    for i in p:
        check[i] = False

    mini = 100000
    index = 1

    for i in range(0,101):
        if check[i]:
            if mini > abs(x-i):
                #print(mini, abs(x-i), i)
                mini = abs(x-i)
                index = i

    #マイナス
    for i in range(1,101):
        if mini >= abs(x+i):
            #print(mini, abs(x+i), -i)
            mini = abs(x+i)
            index = -i

    print(index)

Submission status: Wrong Answer

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

    i = 1
    if not p:
        return X
    while p:
        if X - i in p:
            p.remove(X - i)
        else:
            return X - i

        if X + i in p:
            p.remove(X + i)
        else:
            return X + i
        i += 1
    return X - i


print(main())

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
import numpy as np
# sympy as syp(素因数分解とか)
Mod = 1000000007
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1] 
for i in range(2, 10**5 + 1):
    fact.append((fact[-1] * i) % Mod)
    inv.append((-inv[Mod % i] * (Mod // i)) % Mod)
    factinv.append((factinv[-1] * inv[-1]) % Mod)
    
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p
    
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    ans = float("inf")
    numlist = [i for i in range(101)]
    for i in range(100):
        if numlist[i] in p:
            numlist[i] = -1
    cnt = 0
    for i, numele in enumerate(numlist):
        if ans > abs(x - (numlist[i])):
            ans = abs(x - numlist[i])
            cnt = i
    if ans <= 100:
        print(cnt)
    else:
        print(abs(x-101))
    

if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

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

pn_bar = [int(_) for _ in range(1,100+1) if (_ not in pn)]

"""
print(X,N)
print(pn)
print(pn_bar)
"""

now_min = 10000
ans = 10000
for i in pn_bar:
    delta = abs(i - X)
    if(delta < now_min):
        ans = i
        now_min = delta
        
print(ans)

Submission status: Wrong Answer

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

import bisect as bis
p.sort()
now = x
k = 1

for i in range(100):
    pm = k * (-1)**k
    index = bis.bisect_left(p, now)
    if index < len(p) and p[index] == now:
        now += pm
        k += 1
    else:
        print(now)
        break

Submission status: Wrong Answer

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

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

p_set = set(p_list)
min_p = min(p_list)
max_p = max(p_list)

compare_X = X
min_d = 100000
min_d_i = compare_X

while True:
    if compare_X not in p_set:
        d = abs(X - compare_X)
        min_d = min(min_d, d)
        if min_d == d:
            min_d_i = compare_X

    compare_X += 1
    if compare_X > max_p:
        break

compare_X = X


while True:
    if compare_X not in p_set:
        d = abs(X - compare_X)
        min_d = min(min_d, d)
        if min_d == d:
            min_d_i = compare_X

    compare_X -= 1
    if compare_X < min_p:
        break


print(min_d_i)

Submission status: Wrong Answer

Solution code:
X,N=map(int, input().split())
p=list(map(int, input().split()))
seisuu=[0 for i in range(0,101)]
if N==0:
    print(X)
else:
    for i in range(0,N):
        seisuu[p[i]]=1
    count1=X-1
    count2=X+1
    ans=0
    while True:
        if count1>=0 and count2<=100:
            if seisuu[count1]==0:
                ans=count1
                break
            elif seisuu[count2]==0:
                ans=count2
                break
        else:
            if count1<0:
                ans=count1
                break
            elif count2>100:
                ans=count2
                break
        count1-=1
        count2+=1
    print(ans)

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 = map(int, readline().split())
p = set(map(int, readline().split()))

ans = 10 ** 9
tmp = 10 ** 9
for i in reversed(range(101)):
    if i not in p:
        if tmp >= abs(x - i):
            tmp = abs(x - i)
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
  print(x)
  quit()
lst=list(map(int,input().split()))
a=list(range(101))
for i in lst:
  if i in a:
    a.remove(i)
b=[]
for j in a:
  b.append(abs(j-x))
print(a[b.index(min(b))])

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
if N == 0:
    print(X)
elif N == 100:
    print(0)
else:
    p = list(map(int,input().split()))
    K = X
    L = 0
    for i in range(X,101):
        if i in p:
            continue
        else:
            K = i-X
            L = i
            break
    if L == X:
        print(X)
    else:
        for i in range(X-K,X):
            if i in p:
             continue
            else:
             L = i
        print(L)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x,n=map(int, input().split())
if n == 0:
  print(x)
  exit()
p=list(map(int, input().split()))
all=set(range(-100,101))
s_p=set(p)
kouho=sorted(all-s_p)
min_dis=100
for i in kouho:
  dis=abs(i-x)
  if min_dis > dis:
    min_i=i
    min_dis=dis
print(min_i)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    l = list(map(int, input().split()))
    m = [i for i in range(101)]
    s = list(set(m) - set(l))
    answer_list = []
    for i in s:
        if i <= X:
            answer_list.append(X - i)
        else:
            answer_list.append(i - X)
    answer = min(answer_list)
    if X - answer in s:
        print(X - answer)
    else:
        print(X + answer)

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
p=list(map(int,input().split()))
if N==0:
  print(X)
else:
  for i in range(0,X):
    if abs(X-i) not in p or abs(X+i) not in p:
      print(max([abs(X-i),abs(X+i)]))
      break

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = 101
for i in range(-100,102):
    if not i in p:
        if abs(i-X) < abs(ans-X):
            ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
P = list(map(int,input().split()))
if N == 0:
    print(X)
for i in range(N):
    if not (X-i in P):
        print(X-i)
        exit()
    elif not (X+i in P):
        print(X+i)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
def solve():
    X, N = [int(x) for x in input().split()]
    if N > 0:
        pn = [int(x) for x in input().split()]
    else:
        pn = []
    pn = set(pn)
    ans = X
    if N == 0:
        return ans
    left = 0
    right = 0
    while True:
        left += 1
        if (X - left) not in pn:
            return X - left
        right += 1
        if (X + right) not in pn:
            return X + right


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

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

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


a = list(range(101))

for i in lis:
    a.remove(i)

ans = 10000    
tans = 0
for j in a:
    tmp = abs(j-x)
    if tmp < ans:
        tans = j
        ans = tmp
        
print(tans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
a = list(map(int, input().split()))
if (x not in a):
    print(x)
    exit()


tar1 = x
tar2 = x
ff1 = True
ff2 = True

while True:
    if (ff1 is True):
        tar1 -= 1
        if (tar1 not in a):
            print(tar1)
            exit()
        if (tar1 == 0):
            ff1 = False

    if (ff2 is True):
        tar2 += 1
        if (tar2 not in a):
            print(tar2)
            exit()
        if (tar2 == 100):
            ff1 = False

    if ((ff1 is False) and (ff2 is False)):
        break

Submission status: Wrong Answer

Solution code:
# = int(input())
X, N = map(int, input().split())
p = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
zero = [0]*101
minimum = 101

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

for i in range(N):
    zero[p[i]] = 1

for i in range(101):
    if zero[i] == 0:
        if abs(X-i) < minimum:
            minimum = abs(X-i)
            count = i
print(count)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
nlist=list(map(int,input().split()))
Nlist=[]
if n==0:
    print(x)
    exit(0)

for i in range(-max(nlist),max(nlist)):
    if i not in nlist:
        Nlist.append(i)
abslist=[abs(x-i) for i in Nlist]
#print(abslist)
if x-min(abslist)  not in nlist:
    print(x-min(abslist))
else:
    print(x+min(abslist))