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())
p = list(map(int, input().split()))
a = 1
ans = ''
p.sort()
print(p)
while ans == '':
  if len(p) == 0:
    ans = x
  elif x - a not in p:
    ans = x - a
  elif x + a not in p:
    ans = x + a
  else:
    a += 1
print(ans)

Submission status: Wrong Answer

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)
    min = x
    max = x

    for i in range(10000):
        
        min -= 1
        max -= 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if p == []:
    print(x)
else:
    # a = min(p)
    # b = max(p)
    min_diff = 10000000
    ans = 0
    for i in range(-1000, 1000):
        if i in p:
            continue
        kero = abs(i-x)
        if kero <= min_diff:
            min_diff = kero
            ans = i
    print(ans)

Submission status: Wrong Answer

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

for i in range(1,100):
  if n[0] - i not in x:
    print(n[0] - i)
    exit()
  elif n[0] + i not in x:
    print(n[0] + i)
    exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(1,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])

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)
    sys.exit()

p.sort()
pMax = max(p)
not_in_p = [-1]
for i in range(102):
    if i not in p:
        not_in_p.append(i)

j = 0
for k in not_in_p:
    if k - x == 0:
        print(k)
        sys.exit()

    else:
        not_in_p[j] -= x
    j += 1

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
P=set(map(int,input().split()))
d=float('inf')
ans=0
for i in range(101):
    if i in P:
        continue
    tmp=abs(x-i)
    if tmp<d:
        ans=i
        d=tmp
print(ans)

Submission status: Wrong Answer

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

for i in range(1,102):
  if n[0] - i not in x:
    print(n[0] - i)
    exit()
  elif n[0] + i not in x:
    print(n[0] + i)
    exit()

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N != 0:
  P = list(map(int, input().split()))
else:
  print(X)
  exit()
list = []
list2 = []
for i in range(-5,max(P)+50):
  if i not in P and i != X:
    res = abs(X - i)
    list.append(res)
    list2.append(i)
    
maxres = list.index(min(list))
if maxres != 0:
  print(list2[maxres])
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-100, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if p == []:
    print(x)
else:
    # a = min(p)
    # b = max(p)
    min_diff = 100
    ans = 0
    for i in range(-1000, 1000):
        if i in p:
            continue
        kero = abs(i-x)
        if kero <= min_diff:
            min_diff = kero
            ans = i
    print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if(n == 0):
    print(x)
elif(n == 100):
    ff = 101-x
    gg = x
    if(ff < gg):
        print(101)
    else:
        print(0)
else:
    p = list(map(int, input().split()))
    if(x==1 and p == [1]):
        print(0)
    m = [i for i in range(1, 1000)]
    for i in range(len(m)):
        if(m[i] in p):
            m[i] = 10000
        else:
            m[i] = abs(x-m[i])
    print(m)
    print(m.index(min(m))+1)

Submission status: Wrong Answer

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


if X in A:
    for diffm in range(X, 0, -1):
        if diffm in A:
            continue
        else:
            break

    for diffp in range(X, 102):
        if diffp in A:
            continue
        else:
            break

    if (X - diffm) > (diffp - X):
        print(diffp)
    else:
        print(diffm)

    exit(0)

else:
    print(X)

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
if B == 0:
    print(A)
else:
    L = list(map(int,input().split()))
    K = L.copy()
    L = [abs(i - A) for i in L]
    L = sorted(L)
    #print(L)
    X = []
    for i in range(1,B+1):
        X+=[i//2]
    if X != L:
        for i in range(B):
            if L[i] != X[i]:
                break
        s,t = A-X[i],A+X[i]
        print(s,t)
        if (s in K) ==True:
            print(t)
        else:
            print(s)
    else:
        print(min(K) -1 )

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
elif 2*x-1>=n:
  for i in range(n):
    y=x-i
    if y not in a:
      print(y)
      break
    z=x+i
    if z not in a:
      print(z)
      break
else:
  for i in range(2*x,101):
    if i not in a:
      print(i)
      break

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N != 0:
  P = list(map(int, input().split()))
else:
  print(X)
  exit()
list = []
list2 = []
for i in range(150):
  if i not in P and i != X:
    res = abs(X - i)
    list.append(res)
    list2.append(i)
    
maxres = list.index(min(list))
if list2[maxres] != 0:
  print(list2[maxres])
else:
  print(-1)

Submission status: Wrong Answer

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

c=[]
ans=100000000
b=[]
for i in range(-10000,10001):
  c.append(i)
for i in range(n):
  c.remove(p[i])
  
for i in range(len(c)):
  sa=abs(x-c[i])
  if ans>sa and sa!=0:
    ans=sa
    
for i in range(len(c)):
  if ans==abs(x-c[i]):
    b.append(c[i])

if ans==100000000:
  print(x)
else:
  b.sort()
  print(b[0])

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
m=100
j=0
for i in range(0,102):
    if abs(x-i)<m and str(i) not in str(p):
        m=abs(x-i)
        j=i
print(j)

Submission status: Wrong Answer

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

if n == 0:
    print(x)
else:
    q = []
    r = []
    min_ = 1000
    for i in range(1, 101):
        if not i in p:
            q.append(i)
    
    before_j = 1000
    for j in q:
        diff = int(abs(x - j))
        
        if min_ == diff:
            r.append(before_j)
            r.append(j)
            
        min_ = min(diff, min_)
        if min_ == diff:
            before_j = j
    
    if r == []:
        print(before_j)
    else:
        print(min(r))

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N != 0:
  P = list(map(int, input().split()))
else:
  print(X)
  exit()
list = []
list2 = []
for i in range(102):
  if i not in P and i != X:
    res = abs(X - i)
    list.append(res)
    list2.append(i)
    
maxres = list.index(min(list))
if list2[maxres] != 0:
  print(list2[maxres])
else:
  print(-1)

Submission status: Wrong Answer

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

for i in range(1,101):
  if n[0] - i not in x:
    print(n[0] - i)
    break
  elif n[0] + i not in x:
    print(n[0] + i)
    break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n > 0:
    p = list(map(int, input().split()))
    sorted_p = sorted(p)

    min_num = sorted_p[0]
    max_num = sorted_p[-1]

    candidate_list = []
    no_flag = 0
    candidate_num = -1
    distance = 10000

    for cnt in range(0, max_num):
        no_flag = 0
        for nums in range(n):
            if cnt == sorted_p[nums]:
                no_flag = 1

        if no_flag == 0:
            candidate_list.append(cnt)

    for cnt in range(len(candidate_list)):
        if abs(x - candidate_list[cnt]) < distance:
            candidate_num = candidate_list[cnt]
            distance = abs(x - candidate_num)

    print(candidate_num)

else:
    print(x)

Submission status: Wrong Answer

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

for i in range(1,100):
  if n[0] - i not in x:
    print(n[0] - i)
    break
  elif n[0] + i not in x:
    print(n[0] + i)
    break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
if p == []:
    print(x)
else:
    a = min(p)
    b = max(p)
    min_diff = 100
    ans = 0
    for i in range(a, b+1):
        if i in p:
            continue
        kero = abs(i-x)
        if kero <= min_diff:
            min_diff = kero
            ans = i
    print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))
		ymin = min(min(A), X)-1
		ymax = max(max(A), X)
		Y = {}
		for y in range(ymin, ymax):
			if y in A:
				None
			else:
				key = int(abs(X-y))
				if key in Y.keys():
					Y[key].append(y)
				else:
					Y[key] = [y]
		key = min(Y.keys())
		print(min(Y[key]))
resolve()

Submission status: Wrong Answer

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

c=[]
ans=100000
b=[]
for i in range(-1000,1001):
  c.append(i)
for i in range(n):
  c.remove(p[i])
  
for i in range(len(c)):
  sa=abs(x-c[i])
  if ans>sa and sa!=0:
    ans=sa
    
for i in range(len(c)):
  if ans==abs(x-c[i]):
    b.append(c[i])

if ans==10000:
  print(x)
else:
  b.sort()
  print(b[0])

Submission status: Wrong Answer

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

int_list = [i for i in range(102)]
forbidden_list = list(set(int_list) - set(p))
num_X = int_list.index(X)
c = 10000000

if X in forbidden_list:
  print(X)
elif X == 0:
  print(-1)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b > a:
      print(forbidden_list[i - 1])
      break
    else:
      print(forbidden_list[i])
      break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - abs(x), diff)
    print(sorting(sl)[0]+x)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,101) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) #b_tmpはbとxの差分のリストをさくせい
address = b_tmp.index(min(b_tmp))
print(b[address])

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  for i in range(1,101):
    if i not in a:
      print(i)
      break

Submission status: Wrong Answer

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

arr = []
flag = 0

if n == 0:
    flag = 1
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    min = x
    max = x
    for i in range(101):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            flag = 1
            break

        if max not in arr:
            print(max)
            flag = 1
            break

if flag == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
a,b = map(int, input().split()) 

if b==0:
    print(a)
    exit()
num_list = list(map(int, input().split()))

    

num=[True]*101
#print(num)


for i in range(b):
    num[num_list[i]]=False


num[0]=False
#print(num)

count=0
min_min=100
min_max=100
i=a
#print()
#print(i)

flag_i=0
frag_j=0
if i==100 and num[100]==True:
    print(100)
    exit()
    
#elif i==100 and 100 in num_list:
    
if i==100:
    i=99
    
if num[i]==True:
    print(i)
    exit()
    
while 1:
    if i-1==99:
        flag_i=1
        min_min=99
        break
    elif num[i-1]==True:
        min_min=i-a
        break
    i+=1
j=a
#print(min_min)
#print(i)
count=0

while 1:
    if j-1==0:
        flag_j=1
        min_max=100
        break
    elif num[j-1]==True:
        min_max=a-j
    j-=1
#print(min_max)
#print(j)
if min_min<min_max:
    print(i-1)
    
else:
#   if flag_j==1:
#       j=j+1
    print(j-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

arr = []
flag = 0

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    min = x
    max = x
    for i in range(101):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            flag = 1
            break

        if max not in arr:
            print(max)
            flag = 1
            break

Submission status: Wrong Answer

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

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)
d = 1
while True:
  if x-d not in p:
    print(x-d)
    break
  if x+d not in p:
    print(x+d)
    break
  d += 1

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N != 0:
  P = list(map(int, input().split()))
else:
  print(X)
  exit()
list = []
list2 = []
for i in range(101):
  if i not in P and i != X:
    res = abs(X - i)
    list.append(res)
    list2.append(i)
    
maxres = list.index(min(list))
print(list2[maxres])

Submission status: Wrong Answer

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

arr = []
flag = 0

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    min = x
    max = x
    for i in range(101):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            flag = 1
            break

        if max not in arr:
            print(max)
            flag = 1
            break

if flag == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
a,b = map(int, input().split()) 

if b==0:
    #print(a)
    exit()
num_list = list(map(int, input().split()))

    

num=[True]*101
#print(num)


for i in range(b):
    num[num_list[i]]=False


num[0]=False
#print(num)

count=0
min_min=100
min_max=100
i=a
#print()
#print(i)

flag_i=0
frag_j=0
if i==100 and num[100]==True:
    print(100)
    exit()
    
#elif i==100 and 100 in num_list:
    
if i==100:
    i=99
    
if num[i]==True:
    print(i)
    exit()
    
while 1:
    if i-1==99:
        flag_i=1
        min_min=99
        break
    elif num[i-1]==True:
        min_min=i-a
        break
    i+=1
j=a
#print(min_min)
#print(i)
count=0

while 1:
    if j-1==0:
        flag_j=1
        min_max=100
        break
    elif num[j-1]==True:
        min_max=a-j
    j-=1
#print(min_max)
#print(j)
if min_min<min_max:
    print(i-1)
    
else:
#   if flag_j==1:
#       j=j+1
    print(j-1)

Submission status: Wrong Answer

Solution code:
s = {i+1 for i in range(-101,100)}
#print(s)
x, n =map(int,input().split())
 
if n == 0:
  print(x)
  exit()
  
il = list(map(int,input().split()))
 
for i in range(n):
  s.discard(il[i])
s = list(s)
s.sort()
#print(s)
 
absmin = 10000000
ans = 0
 
for i in range(len(s)):
  j = abs(x-int(s[i]))
  if j < absmin:
    ans = s[i]
    absmin = j
    if j == 0:
      break
 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input().split())
p = [int(i) for i in input().split()]
q = []

if n == 0 or x not in p:
  print(x)
  sys.exit() 

for i in range(1, 101):
  if x + i not in p:
    q.append(x + i)
    if x - i not in p:
      q.append(x - i)
      break
    break

print(min(q))

Submission status: Wrong Answer

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


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

if N==0:
    print(X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
X,N = (int(i) for i in input().split())
if N !=0:
    p = list(map(int, input().split()))
elif N ==0:
    p=[-1]
p.sort()
#
ans =[]
for i in range(-1,101):
    if i not in p:
        ans.append((abs(i-X),i))
ans.sort()
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
import sys

(x, n) = map(int, sys.stdin.readline().strip().split())
list_input = list(map(int, input().split()))

if x not in list_input:
    print(x)
    exit()

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

Submission status: Wrong Answer

Solution code:
first_input = input().split()
x = int(first_input[0])
n = int(first_input[1])
if n != 0:
    second_input = map(int, input().split())
    p_a = list(map(int, second_input))
else:
    second_input = input()

def create_full_array(minimum, maximum):
    full_list = []
    for i in range(minimum,maximum+1):
        full_list.append(int(i))
    return full_list

if n == 0:
    print(x)
elif x > max(p_a) + 1 or x < min(p_a):
    ans = x - 1
    print(ans)
elif x == max(p_a) + 1:
    ans = x + 1
    print(ans)
else:
    full_array = create_full_array(min(p_a), max(p_a))
    if x in p_a:
        target_list = list(set(p_a)^set(full_array))
        abs_key = {}
        if len(target_list) == 0:
            if abs(x - min(p_a) - 1) <= abs(x - max(p_a) + 1):
                print(abs(x - min(p_a) - 1))
            else:
                print(abs(x - max(p_a) + 1))
        else:
            for i in target_list:
                abs_key[i] = abs(x-i)
            minimum = min(abs_key.values())
            t_k = []
            t_v = []
            [t_k.append(k) for k, v in abs_key.items() if v == minimum]
            print(min(t_k))

    else:
        print(x)

Submission status: Wrong Answer

Solution code:
s = {i+1 for i in range(-101,101)}
#print(s)
x, n =map(int,input().split())

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

for i in range(n):
  s.discard(il[i])
s = list(s)
s.sort()
print(s)

absmin = 100
ans = 0

for i in range(len(s)):
  j = abs(x-int(s[i]))
  if j < absmin:
    ans = s[i]
    absmin = j

print(ans)

Submission status: Wrong Answer

Solution code:
num_input = [input() for i in range(2)]
x = int(num_input[0].split()[0])
n = int(num_input[0].split()[1])

num_list = [int(n) for n in num_input[1].split()]
num_list.sort()

ans=x

if n!=0 and n!=1 and n!=100:
    if x in num_list:
        index=num_list.index(x)

        value_left=x-1
        value_right=x+1

        if index!=0:
            index_left=index-1
        if index!=n-1:
            index_right=index+1
        
        if index==0:
            ans=x-1
            print(1)
        elif index==n-1:
            if num_list[index-1]==x-1:
                ans=x+1
                print(2)
            else:
                ans=x-1
                print(3)
        else:
            for i in range(n):
                if num_list[index_left]!=value_left:
                    ans=value_left
                    break
                elif num_list[index_right]!=value_right:
                    ans=value_right
                    break
                if index_left!=0:
                    index_left=index_left-1
                if index_right!=n:
                    index_right=index_right+1
                value_left=value_left-1
                value_right=value_right+1

if n==1:
    ans=x-1

if n==100:
    if x<=50:
        ans=0
    if x>50:
        ans=101

print(ans)

Submission status: Wrong Answer

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    min = x
    max = x
    for i in range(101):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break
    else:
        print(-1)

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(101):
    if not (x-(i+1)) in p:
      print(x-(i+1))
      break
    elif not (x+(i+1)) in p:
      print(x+(i+1))
      break

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()
wk = 101
an = 0
if n ==100:
    print(0)
    sys.exit()
for i in range(102):
    if x!=i:
        if p.count(i)==0:
            if abs(x-i)<wk:
                an =i
                wk = abs(x-i)

print(an)

Submission status: Wrong Answer

Solution code:
import sys

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

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

li.sort()

result1 = 0
counter1 = 1
kekka1 = 0
while(True):

    try:
        result1 = li.index(x+counter1)
        kekka1 = li[result1]
        counter1 = counter1+1
    except ValueError as e:
        break

result2 = 0
counter2 = 1
kekka2 = 0
while(True):
    try:
        result2 = li.index(x-counter2)
        kekka2 = li[result2]
        counter2 = counter2+1
    except ValueError as e:
        break

if counter1 < counter2:
    print(abs(x+counter1))
elif counter1 > counter2:
    print(abs(x-counter2))
elif counter1 == counter2:
    print(abs(x-counter2))

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(102):
    if not (x-(i+1)) in p:
      print(x-(i+1))
      break
    elif not (x+(i+1)) in p:
      print(x+(i+1))
      break

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, 101):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()

Submission status: Wrong Answer

Solution code:
import sys

X, N = map(int, input().split(" "))
if N == 0:
    print(X)
    sys.exit(0)
if N == 100:
    sys.exit(0)

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

l = list(range(0, 102))
for p in P:
    l.pop(l.index(p))

dis_min = 1000
n = 1000
for i in l:
    dis = abs(i - X)
    if dis_min > dis:
        dis_min = dis
        n = i
    elif dis_min == dis:
        if n > i:
            n = i

print(n)

Submission status: Wrong Answer

Solution code:
import numpy as np
x,y =map(int, input().split())
p =list(map(int, input().split()))

n = []
b=10000

for c1 in range(101):
    if c1 not in p:
        if(abs(x-b) > abs(x-c1)):
            b=c1

if y == 0:
    print(x)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
import sys

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

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

li.sort()

result1 = 0
counter1 = 1
kekka1 = 0
while(True):

    try:
        result1 = li.index(x+counter1)
        kekka1 = li[result1]
        counter1 = counter1+1
    except ValueError as e:
        break

result2 = 0
counter2 = 1
kekka2 = 0
while(True):
    try:
        result2 = li.index(x-counter2)
        kekka2 = li[result2]
        counter2 = counter2+1
    except ValueError as e:
        break

if counter1 < counter2:
    print(x+counter1)
elif counter1 > counter2:
    print(abs(x-counter2))
elif counter1 == counter2:
    print(abs(x-counter2))

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)
d = 1
for i in range(1, 100):
  if x-d not in p:
    print(x-d)
    break
  if x+d not in p:
    print(x+d)
    break
  d += 1

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  for i in range(n):
    y=x-i
    if y not in a:
      print(y)
      break
    z=x+i
    if z not in a:
      print(z)
      break

Submission status: Wrong Answer

Solution code:
import sys

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

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

li.sort()

result1 = 0
counter1 = 1
kekka1 = 0
while(True):

    try:
        result1 = li.index(x+counter1)
        kekka1 = li[result1]
        counter1 = counter1+1
    except ValueError as e:
        break

result2 = 0
counter2 = 1
kekka2 = 0
while(True):
    try:
        result2 = li.index(x-counter2)
        kekka2 = li[result2]
        counter2 = counter2+1
    except ValueError as e:
        break

if counter1 < counter2:
    print(x+counter1)
elif counter1 > counter2:
    print(x-counter2)
elif counter1 == counter2:
    print(abs(x-counter2))

Submission status: Wrong Answer

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

if A[1]==0:
  print(A[0])
else:
  B = list(map(int, input().split()))
  l=[i for i in range(1, 101)]
  for i in range(A[1]):
    l.remove(B[i])
  for i in range(len(l)):
    l[i]=abs(A[0]-l[i])
    print(min(l)+A[0])

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
cnt = 10000
cnt1 = 0
for i in range(-100,101):
  if not i in p:
    if abs(cnt) > abs(X-i):
      cnt = X-i
      cnt1 = i
print(cnt1)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)

Submission status: Wrong Answer

Solution code:
num_input = [input() for i in range(2)]
x = int(num_input[0].split()[0])
n = int(num_input[0].split()[1])

num_list = [int(n) for n in num_input[1].split()]
num_list.sort()

ans=x

if n!=0 and n!=1 and n!=100:
    if x in num_list:
        index=num_list.index(x)

        value_left=x-1
        value_right=x+1

        if index!=0:
            index_left=index-1
        if index!=n-1:
            index_right=index+1
        
        if index==0:
            ans=x-1
        elif index==n-1:
            if num_list[index-1]!=x-1:
                ans=x+1
            else:
                ans=x-1
        else:
            for i in range(n):
                if num_list[index_left]!=value_left:
                    ans=value_left
                    break
                elif num_list[index_right]!=value_right:
                    ans=value_right
                    break
                if index_left!=0:
                    index_left=index_left-1
                if index_right!=n:
                    index_right=index_right+1
                value_left=value_left-1
                value_right=value_right+1

if n==1:
    ans=x-1

if n==100:
    if x<=50:
        ans=0
    if x>50:
        ans=101

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
x,y =map(int, input().split())
p =list(map(int, input().split()))

n = []
b=10000

if(y==0):
    print(x)
    
else:
    for c1 in range(101):
        if c1 not in p:
            if(abs(x-b) > abs(x-c1)):
                b=c1
                print(b)

Submission status: Wrong Answer

Solution code:
# 初期入力
import sys
input = sys.stdin.readline
X,N = (int(i) for i in input().split())
if N !=0:
    p = list(map(int, input().split()))
elif N ==0:
    p=[-1]
p.sort()
p_100 =[i for i in range(1,101)]
p =p_100
#
ans =[]
for i in range(-1,101):
    if i not in p:
        ans.append((abs(i-X),i))
ans.sort()
if len(ans) >=2:
    print(ans[0][1])

Submission status: Wrong Answer

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)

    min = x
    max = x
    for i in range(101):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break