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 = list(map(int, input().split()))
if N!=0:
    P = set(list(map(int, input().split())))
else:
    print(X)
    exit(0)

dist = 100
r = None
for i in range(100, -1, -1):
    if not i in P and abs(X-i) <= dist:
        dist = abs(X-i)
        print (i, dist)
        r = i

print(r)

Submission status: Wrong Answer

Solution code:
def abc170_c_2():
    """
    もっとシンプルに考えると
    Xから-1、+1と順番に探索して、見つかったものをリターンすればOKなはず。
	最大で±100まで探索の必要がある？
	"""
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        for i in range(1, 101):
            for s in [-1, +1]:
                a = x + i * s
                if a not in p:
                    return a
    print(solve())

if __name__ == '__main__':
    abc170_c_2()

Submission status: Wrong Answer

Solution code:
def abc170_c_2():
    """
    もっとシンプルに考えると
    Xから-1、+1と順番に探索して、見つかったものをリターンすればOKなはず。
    """
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        for i in range(1, 51):
            for s in [-1, +1]:
                a = x + i * s
                if a not in p:
                    return a
    print(solve())

if __name__ == '__main__':
    abc170_c_2()

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split(' '))
if N == 0:
    print(X)
else:
    P_ls = list(map(int, input().split(' ')))
    diff, rst = -1, 0
    for i in range(101, -1, -1):
        if diff == -1:
            diff = abs(X - i)
            rst = i
        else:
            diff = min(diff, abs(X - i))
            if diff == abs(X - i):
                rst = i
    print(rst)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if n == 0:
#t == False:
    re = x #n = 0でよかった。ここでは、listの中にxがなかったときにreにxを入れている。
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_1 == False:
            re = x + i + 1
            break
        elif TorF_2 == False:
            re = x - i - 1
            break

print(re)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if t == False:
    re = x #n = 0でよかった。ここでは、listの中にxがなかったときにreにxを入れている。
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_1 == False:
            re = x + i + 1
            break
        elif TorF_2 == False:
            re = x - i - 1
            break
        
print(re)

Submission status: Wrong Answer

Solution code:
ans = 10000000
x,n = map(int, input().split())
p = input().split(" ")
for i in range(n):
  if ans > int(p[i]):
    ans = int(p[i])
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()] if n != 0 else []
min_ = 100
cnt = 0
for i in range(100 + 1):
  if abs(i - x) < min_ and not i in a:
    min_ = abs(i - x)
    cnt = i
print(cnt)

Submission status: Wrong Answer

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

ans = 0
if N > 0:
  p = list(map(int, input().split()))
  r = [i for i in range(-101, 101) if i not in p]
  d = [abs(X-i) for i in r]
  ans = r[d.index(min(d))]
else:
  ans = X

print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N > 0:
  p = list(map(int, input().split()))
  r = [i for i in range(101) if i not in p]
  d = [abs(X-i) for i in r]
  print(r[d.index(min(d))])
else:
  print(X)

Submission status: Wrong Answer

Solution code:
def py():
  x, n = map(int, input().split())
  p = list(map(int, input().split()))
  if p == []:
    print(x)
    return
  list0=[]
  for i in range(101):
    list0.append(i)
  for j in p:
    list0.remove(j)
  list1=[]
  for i in list0:
    list1.append(abs(x-i))
  if x-min(list1) in list0:
    print(x-min(list1))
  else:
    print(x+min(list1))
    
py()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if N == 0:
    print(X)

for n in range(X + 1):
    for m in [-1, 1]:
        l = X + n*m
        if d.count(l) == 0:
            print(l)
            exit(0)

Submission status: Wrong Answer

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

if N == 0:
    print(X)

for n in range(X + 1):
    for m in [-1, 1]:
        l = X + n*m
        if d.count(l) == 0:
            print(l)
            exit()

Submission status: Wrong Answer

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

for n in range(X + 1):
    for m in [-1, 1]:
        l = X + n*m
        if d.count(l) == 0:
            print(l)
            break

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N!=0:
  plist =list(map(int,input().split()))
  maxN = max(plist)
  Anslist =[i for i in range(maxN+1)]
  #print (Anslist)
  for i in range(len(plist)):
    Anslist.remove(plist[i])
  Anslist.remove(0)
  #print(Anslist)

  ans = 0
  min=100
  for i in range(len(Anslist)):
    if min>abs(X-Anslist[i]):
      min = abs(X-Anslist[i])
      ans = Anslist[i]
  print(ans)
else :print(X)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N!=0:
  plist =list(map(int,input().split()))
  maxN = max(plist)
  Anslist =[i for i in range(maxN+1)]
  print (Anslist)
  for i in range(len(plist)):
    Anslist.remove(plist[i])
  Anslist.remove(0)
  print(Anslist)

  ans = 0
  min=100
  for i in range(len(Anslist)):
    if min>abs(X-Anslist[i]):
      min = abs(X-Anslist[i])
      ans = Anslist[i]
  print(ans)
else :print(X)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N!=0:
  plist =list(map(int,input().split()))
  maxN = max(plist)
  Anslist =[i for i in range(maxN+1)]
  #print (Anslist)
  for i in range(len(plist)):
    Anslist.remove(plist[i])
  #print(Anslist)

  ans = 0
  min=100
  for i in range(len(Anslist)):
    if min>abs(X-Anslist[i]):
      min = abs(X-Anslist[i])
      ans = Anslist[i]
  print(ans)
else :print(X)

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
p = sorted(p,reverse = False)
p_x = []
if p == []:
    print(X)
else:
    for i in range(-1,200):
        if not(i in p):
            p_x.append(i)#番兵
    idx_x = bisect.bisect_left(p_x,X)
    if abs(X-p_x[idx_x-1]) < abs(X-p_x[idx_x]):
           print(p_x[idx_x-1])
    else:
           print(p_x[idx_x])

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
p = sorted(p,reverse = False)
p_x = []
if p == []:
    print(X)
else:
    for i in range(-200,200):
        if not(i in p):
            p_x.append(i)#番兵
    idx_x = bisect.bisect_left(p_x,X)
    if abs(X-p_x[idx_x-1]) < abs(X-p_x[idx_x]):
           print(p_x[idx_x-1])
    else:
           print(p_x[idx_x])

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
p = sorted(p,reverse = False)
p_x = []
if p == []:
    print(X)
else:
    for i in range(-100,100):
        if not(i in p):
            p_x.append(i)
    p_x.append(101)#番兵
    idx_x = bisect.bisect_left(p_x,X)
    if abs(X-p_x[idx_x-1]) < abs(X-p_x[idx_x]):
           print(p_x[idx_x-1])
    else:
           print(p_x[idx_x])

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
p = sorted(p,reverse = False)
p_x = []
if p == []:
    print(X)
else:
    for i in range(-1,max(p)):
        if not(i in p):
            p_x.append(i)
    p_x.append(101)#番兵
    idx_x = bisect.bisect_left(p_x,X)
    if abs(X-p_x[idx_x-1]) < abs(X-p_x[idx_x]):
           print(p_x[idx_x-1])
    else:
           print(p_x[idx_x])

Submission status: Wrong Answer

Solution code:
def run():
	X, N = [int(v) for v in input().rstrip().split()]
	p = []
	if N > 0:
		p = [int(v) for v in input().rstrip().split()]

	i = -1
	try:
		i = p.index(X)
	except ValueError:
		pass

	if i == -1:
		# not contained	
		return X

	d1 = {}
	for k in range(0, 101):
		d1[k] = k

	for v in p:
		del d1[v]

	l2 = sorted(list(d1.keys()))

	l2.append(X)
	l2.sort()
	i = l2.index(X)

	r = 0
	if i == 0:
		r = l2[1]
	elif (i + 1) == len(l2):
		r = l2[-2]
	else:
		v1 = l2[i + 1] - X
		v2 = X - l2[i - 1]
		if v1 < v2 :
			r = l2[i + 1]
		elif v1 > v2 :
			r = l2[i - 1]
		else:
			# v1 == v2
			r = l2[i - 1]


	return r

r = run()
print(r)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if y%2==1 or x>50:
 print("No")
else:
 if 2*x<=y<=4*x:
  print("Yes")
 else:
  print("No")

Submission status: Wrong Answer

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

for y in range(x+1):
  for b in[1,-1]:
    c=x+y*b
    if a.count(c)==0:
      print(c)
      exit()

Submission status: Wrong Answer

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

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(1, 101):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(101)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i] - X
print(ans + X)

Submission status: Wrong Answer

Solution code:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(101)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i]
print(ans)

Submission status: Wrong Answer

Solution code:


X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i+1 for i in range(100)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i]
print(ans)

Submission status: Wrong Answer

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

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

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

x1,x2 = x,x
for i in range(1000):
  x1 -= 1
  x2 += 1
  if x1 not in p:
    print(x1)
    exit()
  if x2 not in p:
    print(x2)
    exit()

Submission status: Wrong Answer

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

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

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

x1,x2 = x,x
for i in range(1000):
  x1 -= 1
  x2 += 1
  if x1 not in p:
    print(x1)
    exit()
  if x2 not in p:
    print(x2)
    exit()

Submission status: Wrong Answer

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

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

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

x1,x2 = x,x
for i in range(100):
  x1 -= 1
  x2 += 1
  if x1 not in p:
    print(x1)
    exit()
  if x2 not in p:
    print(x2)
    exit()

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
#p = [4,7,10,6,5]
if N == 0:
    print(X)
    exit()

p.sort()
all = [i for i in range(1,101)]
for i in p:
    if i in all:
        all.remove(i)

if len(all) == 0:
    if X < 51:
        print(0)
        exit()
    else:
        print(101)
        exit()
min = 101
min_k = 0
for k,i in enumerate(all):
    tmp = abs(X-i)
    if min > tmp:
        min = tmp
        min_k =k
print(all[min_k])

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
#p = [4,7,10,6,5]
if N == 0:
    print(X)
    exit()

p.sort()
all = [i for i in range(1,101)]
for i in p:
    if i in all:
        all.remove(i)
if len(all) == 0:
    print(0)
    exit()
min = 101
min_k = 0
for k,i in enumerate(all):
    tmp = abs(X-i)
    if min > tmp:
        min = tmp
        min_k =k
print(all[min_k])

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
#p = [4,7,10,6,5]
if N == 0:
    print(X)
    exit()

p.sort()
all = [i for i in range(1,101)]
for i in p:
    if i in all:
        all.remove(i)
if len(all) == 0:
    exit()
min = 101
min_k = 0
for k,i in enumerate(all):
    tmp = abs(X-i)
    if min > tmp:
        min = tmp
        min_k =k
print(all[min_k])

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-1,102):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i
print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-1,102):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i
print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-1,102):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
        else:
            continue
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-1,101):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
        else:
            continue
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-5,105):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
            break
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-2,102):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
            break
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(-1,101):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
            break
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
c=1000
for i in range(0,101):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
            break
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(ans==a):
            if(c>i):
                c=i
        elif(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

p=list(map(int,input().split()))
ans=1000
for i in range(0,101):
    b=1
    for j in range(n):
        if(p[j]==i):
            b=0
            break
    if(b==0):
        continue
    else:
        a=abs(x-i)
        if(a<ans):
            ans=a
            c=i

print(c)

Submission status: Wrong Answer

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

if N == 0:
  print(X)
  
else:
  P = list(map(int, input().split()))
  A = [0]
  for i in range(1, 102):
    if (i in P) == False:
      A.append(i)
      
  c = 0
  for j in range(len(A)):
    if abs(X - A[j]) < abs(X - c):
      c = A[j]
    else:
      c = c
  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()))
  A = [0]
  for i in range(1, 101):
    if (i in P) == False:
      A.append(i)
      
  c = 0
  for j in range(len(A)):
    if abs(X - A[j]) < abs(X - c):
      c = A[j]
    else:
      c = c
  print(c)

Submission status: Wrong Answer

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

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

A = [0]


for i in range(1, 101):
  if (i in P) == False:
    A.append(i)
  
c = 0
  
for j in range(len(A)):
  if abs(X - A[j]) < abs(X - c):
    c = A[j]
  else:
    c = c
    
print(c)

Submission status: Wrong Answer

Solution code:
N,M=list(map(int,input().split()))
L=list(map(int,input().split()))
if N not in L:
  print(N)
  exit()
c=N
d=N
while True:
  if c not in L:
    break
  else:
    c-=1
while True:
  if d not in L:
    break
  else:
    d+=1
if abs(d-M)>=abs(c-M):
  print(c)
else:
  print(d)

Submission status: Wrong Answer

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

for i in range(X + 1):
    for j in [-1, +1]:
        ans = X + i * j

        if p.count(ans) == 0:
            print(ans)
            break
    else:
        continue
    break

Submission status: Wrong Answer

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

for i in range(n):
    if x - i not in p:
        ans = x - i
        break
    elif x + i not in p:
        ans = x + i
        break

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X, N =map(int, input().split())
p_list=list(map(int, input().split()))
#i=N
#1st Xがp_listにあるか
	#あれば+=!
	#なければ答え
#|X-i|=1がp_listにあるか
	#あれば+=!
	#なければ答え

i=N
j=0
while True:
	if X-j not in p_list:
		print(X+j)
		exit()
	elif X+j not in p_list:
		print(X-j)
		exit()
	else:
		j+=1

Submission status: Wrong Answer

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

if n==0:
    print(x)
else:
    q=[abs(p[i]-x) for i in range(n)]
    re=max(q) #xと最も離れているものはどれだけ離れてるか
    i=0
    if re==0:
        print(x-1)
    else:
        while(i < re):
            if x-i not in p:
                print(x-i)
                break
            elif x+i not in p:
                print(x+i)
                break
            i += 1
        if i==re:
            print(x-i-1)

Submission status: Wrong Answer

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

if n==0:
    print(x)
else:
    q=[abs(p[i]-x) for i in range(n)]
    print("q=",q)
    re=max(q) #xと最も離れているものはどれだけ離れてるか
    print("re=",re)
    i=0
    if re==0:
        print(x-1)
    else:
        while(i < re):
            if x-i not in p:
                print(x-i)
                break
            elif x+i not in p:
                print(x+i)
                break
            i += 1
        if i==re:
            print(x-i-1)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
count = 1
res = 0
while True:
    before = X - count
    after = X + count
    if before not in p:
        res = before
        break
    elif after not in p:
        res = after
        break
    count += 1
print(res)

Submission status: Wrong Answer

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

Q = list()
for i in range(200):
    Q.append(i+1)
for j in P:
    Q.remove(j)

Q_len = len(Q)
swich = True

if N == 0:
    print(X)
else:
        for i in range(Q_len+1):
            if swich == True:
                xm = X-i
                xp = X+i
                for j in range(Q_len):
                    if xm == 0:
                        print(0)
                        swich = False
                    elif xm == Q[j]:
                        print(xm)
                        swich = False
                    elif xp == Q[j]:
                        print(xp)
                        swich = False
            else:
                break

Submission status: Wrong Answer

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

Q = list()
for i in range(100):
    Q.append(i+1)
for j in P:
    Q.remove(j)

Q_len = len(Q)
swich = True

if N == 0:
    print(X)
else:
        for i in range(Q_len+1):
            if swich == True:
                xm = X-i
                xp = X+i
                for j in range(Q_len):
                    if xm == 0:
                        print(0)
                        swich = False
                        break
                    elif xm == Q[j]:
                        print(xm)
                        swich = False
                        break
                    elif xp == Q[j]:
                        print(xp)
                        swich = False
                        break
            else:
                break

Submission status: Wrong Answer

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

Q = list()
for i in range(100):
    Q.append(i+1)
for j in P:
    Q.remove(j)

Q_len = len(Q)
swich = True

if N == 0:
    print(X)
else:
        for i in range(Q_len+1):
            if swich == True:
                xm = X-i
                xp = X+i
                for j in range(Q_len):
                    if xm == 0:
                        print(-1)
                        swich = False
                        break
                    elif xm == Q[j]:
                        print(xm)
                        swich = False
                        break
                    elif xp == Q[j]:
                        print(xp)
                        swich = False
                        break
            else:
                break

Submission status: Wrong Answer

Solution code:
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    ans = -100
    for i in range(-1,101):
        if i not in p and abs(i-x) < abs(ans-x):
            ans = i
    print(ans)
    
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def solve():
    X,N = [int(i) for i in input().split()]
    if N == 0:
        print(X)
        return

    P = set([int(i) for i in input().split()])
    for i in range(len(P)):
        target = X - i
        if target not in P:
            print(target)
            break
        target = X + i
        if target not in P:
            print(target)
            break

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

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

mi=10e9+7;

if((x-1 and x+1) not in p):
	print(abs(x-1))
if (x-1 in p) and (x+1 not in p):
	print(abs(x-1))

if (x+1 in p) and (x-1 not in p):
	print(x+1)

if((x-1 and x+1) in p):
		for i in range(min(p),max(p)+1):
			if i not in p:
				if mi>i:
					mi=i;
		print(mi)

Submission status: Wrong Answer

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

if n==0:
    print(x)
p = list(range(n))
p = list(map(int, input().split()))
p_2 = list(range(n))
for i in range(n):
    p_2[i] = x-p[i]

for i in range(100):
    h = p_2.count(i)
    h_2 = p_2.count(-i)
    if h==0 and h_2!=0:
        print(x-i)
        break
    elif h!=0 and h_2==0:
        print(x+i)
        break
    elif h==0 and h_2==0:
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
    print(x)
p = list(range(n))
p = list(map(int, input().split()))
p_2 = list(range(n))
for i in range(n):
    p_2[i] = x-p[i]
for i in range(n):
    h = p_2.count(i)
    h_2 = p_2.count(-i)
    if h==0 and h_2!=0:
        print(x-i)
        break
    elif h!=0 and h_2==0:
        print(x+i)
        break
    elif h==0 and h_2==0:
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
    print(x)
p = list(range(n))
p = list(map(int, input().split()))
p_2 = list(range(n))
for i in range(n):
    p_2[i] = x-p[i]
for i in range(100):
    h = p_2.count(i)
    h_2 = p_2.count(-i)
    if h==0 and h_2!=0:
        print(x-i)
        break
    elif h!=0 and h_2==0:
        print(x+i)
        break
    elif h==0 and h_2==0:
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
# Forbidden List
X,N = map(int,input().split())
p = list(map(int, input().split()))
ans = 200
for i in range(-1,101):
    if i not in p:
        ans = [ans, i][abs(X-i) <= abs(X-ans)]
print(ans)

Submission status: Wrong Answer

Solution code:
# Forbidden List
X,N = map(int,input().split())
p = list(map(int, input().split()))
ans = 200
for i in range(-1,101):
    if i not in p:
        ans = [ans, i][abs(X-i) < abs(X-ans)]
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if not N == 0:
  p_l = list(map(int, input().split()))
if N == 0:
  print(X)
  exit()
a = b = X
if not a in p_l:
  if not b in p_l:
    if a > b:
      print(b)
      exit()
    else:
      print(a)
      exit()
  print(a)
  exit()
elif not b in p_l:
  if not a in p_l:
    if a > b:
      print(b)
      exit()
    else:
      print(a)
      exit()
  print(b)
while True:
  a += 1
  b -= 1
  if a in p_l and b in p_l:
    continue
  if not a in p_l:
    if not b in p_l:
      if a > b:
        print(b)
        exit()
      else:
        print(a)
        exit()
    print(a)
    exit()
  elif not b in p_l:
    if not a in p_l:
      if a > b:
        print(b)
        exit()
      else:
        print(a)
        exit()
    print(b)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if not N == 0:
  p_l = list(map(int, input().split()))
if N == 0:
  print(X)
  exit()
a = b = X
while True:
  a += 1
  b -= 1
  if a in p_l and b in p_l:
    continue
  if not a in p_l:
    if not b in p_l:
      if a > b:
        print(b)
        exit()
      else:
        print(a)
        exit()
    print(a)
    exit()
  elif not b in p_l:
    if not a in p_l:
      if a > b:
        print(b)
        exit()
      else:
        print(a)
        exit()
    print(b)

Submission status: Wrong Answer

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

        while True:
            if (x - b) not in p:
                break
            else:
                b += 1

    if a >= b:
        print(x - b)
    else:
        print(x + a)

Submission status: Wrong Answer

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

    while True:
        if (x - b) not in p:
            break
        else:
            b += 1

if a >= b:
    print(x - b)
else:
    print(x + a)

Submission status: Wrong Answer

Solution code:
x, n = list(map(int, input().split()))
if n == 0:
  inputs = []
else:
  inputs = list(map(int, input().split()))
nums = [0] * 202
diff = 1000
n = 100
for i in inputs:
  nums[i] = 1
for i in range(0, 101):
  d = abs(i - x)
  if nums[i] == 1:
    continue
  if d < diff:
    diff = d
    n = i
print(n)

Submission status: Wrong Answer

Solution code:
x, n = list(map(int, input().split()))
if n == 0:
  inputs = []
else:
  inputs = list(map(int, input().split()))
nums = [0] * 101
diff = 1000
n = 100
for i in inputs:
  nums[i] = 1
for i in range(0, 101):
  d = abs(i - x)
  if nums[i] == 1:
    continue
  if d < diff:
    diff = d
    n = i
print(n)