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:
    print(x)

p = set(map(int, input().split()))
for i in range(100):
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x + i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n = a
m = a

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

		print(n)
		exit()



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

Submission status: Wrong Answer

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

n = a
m = a

for i in range(b):

	if n in p:	
		n = n-1
			
	else:
		if n > 0:
			print(n)
			exit()

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

Submission status: Wrong Answer

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

n = a
m = a

for i in range(b):

	if n in p:	
		n = n-1
		if n < 1:
			n = 1
	else:
		print(n)
		exit()

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

Submission status: Wrong Answer

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

n = a
m = a

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

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

Submission status: Wrong Answer

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

n = a
m = a

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

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

Submission status: Wrong Answer

Solution code:
x, t = map(int, input().split())
data = list(map(int, input().split()))
data.sort()
if t == 0:
  print(x)
else:
  s = 100
  for i in data:
    tmp = abs(i-x)
    if tmp < s:
      s = tmp
      ans = i
    else:
      break
  print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n>0:
	p=list(map(int,input().split()))
else:
	p=[]
if x not in p:
	print(x)
else:
	k=1
	while True:
		if x-k>0 and (x-k) not in p:
			print(x-k)
			break
		elif (x+k) not in p:
			print(x+k)
			break
		k+=1

Submission status: Wrong Answer

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


    def getDiff(target, arg):
        return abs(target - arg)


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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(1,x[1]+1):
  y = x[0]+1
  y2 = x[0]-1
  if y not in l:
    print(y)
    break
  elif y2>0 and y2 not in l:
    print(y2)
    break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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

Submission status: Wrong Answer

Solution code:
X,N=[int(s) for s in input().split()]
p = [int(s) for s in input().split()]
prelist =  list(range(1,101))
a =100

for i in range(len(p)):
    prelist.remove(p[i])

for j in range(len(prelist)):
    if(abs(X-a) != min(abs(X-a),abs(X-prelist[j]))):
        a = prelist[j]
print(a)

Submission status: Wrong Answer

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

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)
elif x not in nlist:
    print(x)
    exit(0)
 
delta=200
ans=-x
for i in range(-x,101):
    if i not in nlist:
        X=abs(x-i)
        if X<delta:
            ans=i
            delta=X
print(ans)

Submission status: Wrong Answer

Solution code:
X,N = input().split(' ')
x =int(X)
n = int(N)
try:
    kara_int = list(map(int,input().split(' ')))
except ValueError:
    print(X)
except EOFError:
    print(X)


for s in range(n):
    if x+s not in kara_int or x-s not in kara_int:
        if x-s in kara_int:
            print(str(x+s))
        else:
            print(str(x-s))
        break

Submission status: Wrong Answer

Solution code:
X,N = input().split(' ')
x =int(X)
n = int(N)
try:
    kara_int = list(map(int,input().split(' ')))
except ValueError:
    print(X)
except EOFError:
    print(X)


for s in range(n):
    if x+s not in kara_int and x-s not in kara_int:
        if x-s in kara_int:
            print(str(x+s))
        else:
            print(str(x-s))
        break

Submission status: Wrong Answer

Solution code:
X,N = input().split(' ')
x =int(X)
n = int(N)
try:
    kara_int = list(map(int,input().split(' ')))
except ValueError:
    print(X)
except EOFError:
    print(X)


for s in range(n):
    if x+s not in kara_int:
        if x-s in kara_int:
            print(str(x+s))
        else:
            print(str(x-s))
        break

Submission status: Wrong Answer

Solution code:
X,N = input().split(' ')
x =int(X)
n = int(N)
try:
    kara_int = list(map(int,input().split(' ')))
except ValueError:
    print(X)


for s in range(n):
    if x+s not in kara_int:
        if x-s in kara_int:
            print(str(x+s))
        else:
            print(str(x-s))
        break

Submission status: Wrong Answer

Solution code:
x, y = map(int, input().split())
p = list(map(int, input().split()))
if p:
    max = max(p)
    nums =  []
    nums2 = []
    for i in range(1, max+1):
        if p.count(i):
            nums.append(i)
            nums2.append(i)
        else:
            nums.append(abs(x-i))
            nums2.append(i)
    else:
        min = nums.index(min(nums))
        print(nums2[min])
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()))
    
    for i in range(1,102):
        down = X - i
        up = X + i
        if down in p and up in p:
            pass
        elif down in p:
            temp = up
            break
        else:
            temp = down
            break



    print(temp)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n!=0:
  p=list(map(int,input().split()))
  hantei=10**9+1
  sp=set(p)
  ans=0
  for i in range(1,10000):
    if not i in sp:
      if hantei>abs(i-x):
        hantei=abs(i-x)
        ans=i
  print(ans)
else:
  print(x)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  plist = list(map(int,input().split()))
  ans = -2000
  dist1 = 1000
  for i in range(-101,101):
    dist2 = abs(X-i)
    if dist2 < dist1 and not(i in plist):
      ans = i
      dist1 = dist2
  print(ans)

Submission status: Wrong Answer

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

p.sort()

p0 = [-1]
j = 0
for i in range(1,100):
    if p[j]!=i:
        p0.append(i)
    elif p[j] == i:
        j+=1
    if j == N:
        for i0 in range(i+1,100):
            p0.append(i0)
        break
p0.append(101)
p1 = [0 for i in range(len(p0))]
for i in range(len(p0)):
    p1[i] = p0[i]-X
    p1[i] = np.abs(p1[i])
    
ii = np.argmin(p1)

print(p0[ii])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():    
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    p = list(map(int, input().split()))
    print(p)
    check = 0
    while(1):
        s = check//2
        if check%2 == 0:
            ans = x-s
        else:
            ans = x+s
        if not ans in p:
            print(ans)
            return
        check += 1
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
x,n=map(int,input().split())
arr=np.array(list(map(int,input().split())))
i=0
while (x+i in arr) and (x-i in arr):
  if not(x-i-1 in arr):
    print(x-i-1)
    exit()
  elif not(x+i+1 in arr):
    print(x+i+1)
    exit()
  i+=1

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

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

solve(x,n,seq)

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

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

solve(x,n,seq)

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

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

solve(x,n,seq)

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

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

solve(x,n,seq)

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

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

solve(x,n,seq)

Submission status: Wrong Answer

Solution code:
X, N=map(int, input().split())
a=list(map(int, input().split()))
s=set(a)
ans=0
for i in range(101):
  if (i not in s) and abs(ans-X)>abs(i-X):
    ans=i
print(ans)

Submission status: Wrong Answer

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

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

    lower = max(x - 1, 1)
    higher = x + 1

    seq_set = set()

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

    if lower_diff <= higher_diff:
        print(lower)
    else:
        print(higher)
    

solve(x,n,seq)

Submission status: Wrong Answer

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

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

    lower = x - 1
    higher = x + 1

    seq_set = set()

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

    if lower_diff <= higher_diff:
        print(lower)
    else:
        print(higher)
    

solve(x,n,seq)

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()))
 
p.sort()
min = [100, 100]
 
for i in range(0,101):
  if i in p:
    continue
  hoge = abs(x - i)
  if min[0] > hoge:
    min[0] = hoge
    min[1] = i
 
print(min[1])

Submission status: Wrong Answer

Solution code:
import sys
 
x, n = map(int, input().split())
 
if n == 0:
  print(x)
  sys.exit()
  
if n == 1:
  print(abs(x - int(input())))
  sys.exit()
 
p = list(map(int, input().split()))
 
p.sort()
min = [100, 100]
 
for i in range(101):
  if i in p:
    continue
  hoge = abs(x - i)
  if min[0] > hoge:
    min[0] = hoge
    min[1] = i
 
print(min[1])

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
pl = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()
for i in range(n):
  if not x-i in pl:
    print(x-i)
    exit()
  if not x+i in pl:
    print(x+i)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import sys

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

ans1 = int()
ans2 = int()

p.sort()

if x not in p:
    print(x)
    sys.exit()


for j in range(x + 1, 101, 1):
    if j not in p:
        ans1 = j
        break
for k in range(x - 1, 0, -1):
    if k not in p:
        ans2 = k
        break


if ans1 - x < x - ans2:
    print(ans1)
else:
    print(ans2)

Submission status: Wrong Answer

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

ls.sort()
if len(ls) == 0:
  print(X)
  exit()

start = ls[0]
size = len(ls)
end = ls[size - 1]
s = [i for i in range(start, end+1)]

not_ls = set(s) - set(ls)

not_ls = list(not_ls)
not_ls.sort(reverse=True)

print(not_ls)

ans = 999
num = 999
for i in not_ls:
  if abs(X - i) <= num:
    num = 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()))

Q=[0]*101
for i in range(-100,101):
    Q[i]=abs(X-i)


for i in  p:
    Q[i]=1000

print(Q.index(min(Q)))

Submission status: Wrong Answer

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

Q=[0]*101
for i in range(101):
    Q[i]=abs(X-i)


for i in  p:
    Q[i]=1000

print(Q.index(min(Q)))

Submission status: Wrong Answer

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

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
ls = list(map(int, input().split()))
s = [i for i in range(1, 101)]

not_ls = set(s) - set(ls)

not_ls = list(not_ls)
not_ls.sort(reverse=True)

ans = 999
num = 999
for i in not_ls:
  if abs(X - i) <= num:
    num = abs(X - i)
    ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
X, N = [int(x) for x in input().strip().split()]
p = set([int(x) for x in input().strip().split()])
ans = 0
diff = X
for i in range(102):
  if i in p:
    continue
  if abs(X - i) < diff:
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = [int(x) for x in input().strip().split()]
p = [int(x) for x in input().strip().split()]
ans = 0
diff = X
for i in range(102):
  if abs(X - i) < diff:
    ans = i
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x:
    ans = i
    break
print(ans)

Submission status: Wrong Answer

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

if n==0:
  print(x)
else:
  back,front = x-1,x+1
  while back>=0 or front<=100:
    if back not in seq:
      print(back)
      break
    elif front not in seq:
      if front<=100:
      	print(front)
      	break
    back-=1
    front+=1

Submission status: Wrong Answer

Solution code:
import sys

X,N = map(int,input().split())
P = list(map(int,input().split()))
if X < 1 or 100 < X:
    sys.exit()
if N < 0 or 100 < N:
    sys.exit()
if N == 0:
    print(X)
    sys.exit()

P_number = len(P)
if P_number < 1 or 100 < P_number:
    sys.exit()

res1 = 100
res2 = 100
res0 = 0
i = 0
j = 0
while i < N:
    if (X - i) not in P:
        res1 = (X - i)
        break
    i += 1
while j < N:
    if (X + j) not in P:
        res2 = (X + j)
        break
    j += 1
if i > j:
    res0 = res2
elif j > i:
    res0 = res1
elif i == j:
    res0 = res1
print(res0)

Submission status: Wrong Answer

Solution code:
X, N = list(map(int, input().split()))
if N == 0: print(X)
else:
    p = list(map(int, input().split()))
    q = [X-1, X+1]

    while True:

        if not q[0] in p:
            print(q[0])
            break
        elif not q[1] in p:
            print(q[1])
            break
        q = [q[0]-1, q[1]+1]

Submission status: Wrong Answer

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

if n==0:
  print(x)
else:
  back,front = x-1,x+1
  while back>=0 or front<=100:
    if back not in seq:
      print(back)
      break
    elif front not in seq:
      print(front)
      break
    else:
      back-=1
      front+=1

Submission status: Wrong Answer

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

if n==0:
  print(x)
else:
  back,front = x-1,x+1
  while back>=0 and front<=101:
    if back not in seq:
      print(back)
      break
    elif front not in seq:
      print(front)
      break
    else:
      back-=1
      front+=1

Submission status: Wrong Answer

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

result = 100
ans = 0
if n == 0:
    print(x)
    exit()
else:
    p = list(map(int,input().split()))
    for i in range(1,102):
        if p.count(i) == 0:
            if abs(x-i) < result:
                result = abs(x-i)
                ans = i
print(ans)

Submission status: Wrong Answer

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

if n==0:
  print(x)
else:
  for i in range(x-1,min(seq)+1,-1):
    if i not in seq:
      li.append(i)

  for i in range(x+1,max(seq)+1):
    if i not in seq:
      li.append(i)

  min1=100000
  res=0
  for i in range(len(li)):
    if li[i]<x:
      a=x-li[i]
      if a<min1:
        min1=a
        res=li[i]
    else:
      a=li[i]-x
      if a<min1:
        min1=a
        res=li[i]
  print(res)

Submission status: Wrong Answer

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

result = 100

l = list(range(0,101))

if len(p) == 0:
    kotae = x
else:
    for i in range(len(p)):

        l[p[i]] = ""


    for i in reversed(range(len(l))):
     
  

        if l[i] != "":

            if result >= abs(l[i] - x):
                result = abs(l[i] - x)
               
                kotae = l[i]          
            
print(kotae)

Submission status: Wrong Answer

Solution code:
import sys

X,N = map(int,input().split())
P = list(map(int,input().split()))
if X < 1 or 100 < X:
    sys.exit()
if N < 0 or 100 < N:
    sys.exit()

P_number = len(P)
if P_number < 1 or 100 < P_number:
    sys.exit()

res = [100,100]
i = 0
while i < N:
    if res[0] > abs(X - P[i]) and res[1] > P[i]:
        res[0] = abs(X - P[i])
        res[1] = P[i]
    i += 1
print(res[1])

Submission status: Wrong Answer

Solution code:
lst = []
l = []
str = input()
l = str.split(' ')
n = int(l[0])
no = int(l[1])
if no==0:
  print(n)
 

else:  
  str1 = input()
  lst = str1.split(' ')
  for i in range(0,no):
    lst[i] = int(lst[i])
  for i in range(1,101):
    if n-i not in lst:
      print(n-i)
      break
    if n+i not in lst:
      print(n+i)
      break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
pnum = [i for i in range(1, 101) if i not in p]
# print(pnum)
d = float('inf')
for i in pnum:
    if d > abs(x-i):
        d = abs(x-i)
        ans = i

if d >= min(x, 101-x):
    if x <= 101-x:
        ans = 0
    else:
        ans = 101
        
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()))

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
pnum = [i for i in range(1, 101) if i not in p]
# print(pnum)
d = float('inf')
for i in pnum:
    if d > abs(x-i):
        d = abs(x-i)
        ans = i

if d >= x:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
pnum = [i for i in range(1, 101) if i not in p]
# print(pnum)
d = float('inf')
for i in pnum:
    if d > abs(x-i):
        d = abs(x-i)
        ans = i

if d > x:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
x , n = map(int , input().split())
b = []
if n!=0:
    b = list(map(int,input().split()))
t = 1
ans = 0
while 1:
    if x-t not in b:
        ans = x - t
        break
    if x+t not in b:
        ans = x + t
        break
    t += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = 0
if N != 0:
  
  pn = list(map(int,input().split()))
  pall = list(range(101))
  test = list(set(pall) - set(pn))
  ans = []
  
  while i < len(test):
    if X - N//2 -1 <= test[i] <= X + N//2 :
      ans.append(test[i])
    i += 1
  print(min(ans))
else:
  print(X)

Submission status: Wrong Answer

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

i = 0
if N != 0:
  
  pn = list(map(int,input().split()))
  pall = list(range(100))
  test = list(set(pall) - set(pn))
  ans = []
  
  while i < len(test):
    if X - N//2 -1 <= test[i] <= X + N//2 :
      ans.append(test[i])
    i += 1
  print(min(ans))
else:
  print(X)

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()))
if N == 1:
  if p[0] == X:
    print(X-1)
  else:
    print(X)
ans = 0
d = 0
for i in range(N):
  if d < abs(X-p[i]):
    d = abs(X-p[i])
    
for i in range(d+1):
  if X - i not in p:
    ans = X - i
    print(ans)
    exit()
  elif X + i not in p:
    ans = X + i
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split(' '))
if n > 0:
    p = list(map(int, input().split(' ')))
    r = x + 1
    l = x - 1
  
    ansr = 0
    ansl = 0
    while r <= 100:
        if r not in p:
            break
        r += 1
    ansr = r
    while l >= 1:
        if l not in p:
            break
        l -= 1
    ansl = l
    vr = ansr - x
    vl = x - ansl
    if vr == vl:
        ans = ansl if ansl < ansr else ansr
    else:
        ans = ansl if vl < vr else ansr
else:
    ans = x
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
answer = 0
if N != 0:
  mapped_list = map(int,input().split())
  list = list(mapped_list)
  print(list)
  for i in range (N):
    if (X-i in list) == False:
      answer = X-i
      break
    elif (X+i in list) == False:
      answer = X+i
      break
else:
  answer = X 
  
print(answer)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split(' '))
if n > 0:
    p = list(map(int, input().split(' ')))
    r = x + 1
    l = x - 1
  
    ansr = 0
    ansl = 0
    while r <= 101:
        if r not in p:
            break
        r += 1
    ansr = r
    while l >= 0:
        if l not in p:
            break
        l -= 1
    ansl = l
    vr = ansr - x
    vl = x - ansl
    if vr == vl:
        ans = ansl if ansl < ansr else ansr
    else:
        ans = ansl if vl < vr else ansr
else:
    ans = x
print(ans)

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()))
ans = 0
d = 0
for i in range(N):
  if d < abs(X-p[i]):
    d = abs(X-p[i])
    
for i in range(d+1):
  if X - i not in p:
    ans = X - i
    print(ans)
    exit()
  elif X + i not in p:
    ans = X + i
    print(ans)
    exit()

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 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))
del b[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])