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: Runtime Error

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
while i < N:
    if !((X - i) in P):
        res1 = (X - i)
    i += 1
while j < N:
    if !((X + j) in P):
        res2 = (X + j)
    j += 1
if res2 > res1:
    res0 = res1
else if res1 > res2:
    res0 = res2
else if res2 == res1:
    res0 = res1
print(res0)

Submission status: Runtime Error

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

array.sort()

min = min(array)
max = max(array)

all_elements_list = [x for x in range(min, max+1)]
#print(all_elements_list)

a = set(array)
b = set(all_elements_list)
diff = b - a
#print(diff)

distance = 10000000000
answer = 0
for i in diff:
#    print("i: {}".format(i))
    if abs(x - i) < distance:
        distance = abs(x - i)
#        print("distance: {}".format(distance))
        answer = i

print(answer)

Submission status: Runtime Error

Solution code:
def seek(p_find,n):
    if p[p_find-n+1]<X-n:
        return X-n
    elif X+n<p[p_find+n+1]:
        return X+n
    else:
        n+=1
        return seek(p_find,n)
        
X,Y=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
if Y==0:
    print(X)
else:
    for i in range(len(p)-1):
        p_find=1
        if p[i]<=X and X<=p[i+1]:
            p_find=i
            print(seek(p_find,1))
            break
        elif p[Y-1]<X:
            print(p[Y-1]+1)
            break
        elif X<p[0]:
            print(p[0]-1)
            break

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
for k in range(200):
  temp = X-k
  if temp not in p:
    print(temp)
    break
  semp = X+k
  if semp not in p:
    print(semp)
    break

Submission status: Runtime Error

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 = count(P)
if P_number < 1 or 100 < P_number:
    sys.exit()

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

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ue = []
shita = []
#xより値の大きい値を順に比較していき、リストpに存在しない最小値を取得する
for i in range(x+1,p[-1]+2):
    if False == (i in p):
        ue.append(i)
 
#xより値の小さい値を順に比較していき、リストpに存在しない最大値を取得する
for i in range(p[0] -1,x):
    if False == (i in p):
        shita.append(i)

'下記のコードの検証はまだ行っていないため、次回は下記のコードの実行検証から確認をする'

abs_ue = 100
for i in ue:
    if abs_ue > abs[x - i]:
        abs_ue = i
        break

abs_shita = 100
daburi = []
for i in shita:
    if abs_shita > abs(x - i):
        abs_shita = i
        break

if n == 0:
    print(x)
elif abs_ue > abs_shita:
    print(abs_shita)
else:
    print(abs_ue)

Submission status: Runtime Error

Solution code:
def seek(p_find,n):
    if p[p_find-n+1]<X-n:
        return X-n
    elif X+n<p[p_find+n+1]:
        return X+n
    else:
        n+=1
        return seek(p_find,n)
        
X,Y=map(int,input().split())
p=list(map(int,input().split()))
p.sort()
p_find=1
if Y==0:
    print(X)
else:
    for i in range(len(p)-1):
        if p[i]<=X and X<=p[i+1]:
            p_find=i
            break
    print(seek(p_find,1))

Submission status: Runtime Error

Solution code:
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]
# neg,pos=[],[]
# for i in arr:
# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:
# 		neg.append(i-x)
# pos=sorted(pos)
# neg=sorted(neg)
diff=[]
for i in arr:
    
	diff.append(x-i)
i=-1
j=0
while i in diff:
	i=i-1
while j in diff:
	j=j+1
if abs(i)<abs(j):
    print(x-i)
else:
    print(x-j)
# print(x+)

Submission status: Runtime Error

Solution code:
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]
# neg,pos=[],[]
# for i in arr:
# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:
# 		neg.append(i-x)
# pos=sorted(pos)
# neg=sorted(neg)
diff=[]
for i in arr:
	diff.append(x-i)
i=-1
j=1
while i in diff:
	i=i-1
while j in diff:
	j=j+1
print(min(x+i,x+j))

Submission status: Runtime Error

Solution code:
x , n = map(int , input().split())
b = list(map(int,input().split()))
for i in b:
    a[i] = 1
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: Runtime Error

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

Submission status: Runtime Error

Solution code:
X,N = list(map(int,input().split()))
if N != 0:  
  pn = list(map(int,input().split()))
  i = 0
  pall = list(range(100))
  test = list(set(pall) - set(pn) - {0})

  ans = []
  while i < len(test):
    if X - N//2 < test[i] < X + N//2 :
      ans.append(test[i])
    i += 1
  print(min(ans))
  
else:
  print(X)

Submission status: Runtime Error

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) - {0})
  ans = []
  while i < len(test):
    if X - N//2 < test[i] < X + N//2 :
      ans.append(test[i])
    i += 1
  print(min(ans))
else:
  print(X)

Submission status: Runtime Error

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)

MAX = 0
for i in range(N):
  if MAX < X - p[i]:
    MAX = X - p[i]
    
for i in range(MAX):
  if X - i not in p:
    ans = X - i
    break
for i in range(MAX):
  if X + i not in p:
    ans = min(X - ans, ans - X) + X
    break
print(ans)

Submission status: Runtime Error

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

pall = list(range(100))

if N != 0:
  test = list(set(pall) - set(pn))
  while i < 100:
    if test[i] == X:
      print(test[i])
      exit()
else:
  print(X)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
np = [x for x in range(102) if x not in p]
mnd = 103
mnv = 103
for i in np:
	if abs(i - x) < mn:
		mnv = i
		mnd = abs(i - x)
print(mnv)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
np = [x for x in range(102) if x not in p]
mnd = 103
mnv = 103
for i in np:
  if abs(i - x) < mn:
    mnv = i
    mnd = abs(i - x)
print(mnv)

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split(" "))
if N != 0:
    p_list = list(map(int,input().split(" ")))
target = X
target_num_min = X
target_num_plus = X
if X in p_list:
    while True:
        target_num_min -= 1
        if target_num_min not in p_list:
            target = target_num_min
            break
        target_num_plus += 1
        if target_num_plus not in p_list:
            target = target_num_plus
            break
print(target)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

w, cnt = 0, 0
while True:
  w += ((-1) ** cnt) * cnt
  cnt += 1

  if x + w not in p:
  　print(x + w)
  	break

Submission status: Runtime Error

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

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

A = list(range(1, max(p) + 1))

S = list(set(A) - set(p))
S.sort()

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

print(ans_v)

Submission status: Runtime Error

Solution code:
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
tmp = [i for i in range(1,101) if i not in P]

idx = 0
tmpP = 999
for i,p in enumerate([abs(i-x) for i in tmp]):
    if p < tmpP:
        idx = i
        tmpP = p

print(tmp[idx])

Submission status: Runtime Error

Solution code:
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
tmp = [i for i in range(1,101) if i not in P]

for i, p in enumerate(tmp):
    if x <= p:
        r = tmp[i:]
        l = tmp[:i]
        break
    
lans,rans = l[-1],r[0]

if abs(lans-x) != abs(rans-x):
    if abs(lans-x) < abs(rans-x): print(lans)
    else: print(rans)
else:
    print(lans)

Submission status: Runtime Error

Solution code:
import sys

X, N = (int(x) for x in input().split())
if N != 0:
  p = [int(x) for x in input().split()]
else:
  print(X)
  sys.exit()
i = 0
ans = X
flag = False
while True:
  if X + i in p: continue
  ans = X + i
  flag = True
  if X - i in p: continue
  ans = X - i
  flag = True
  if flag: break
  i += 1
pritn(ans)

Submission status: Runtime Error

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

if(N>0):
  P = list(map(int,input().split()))
  PP = []
  for i in range(1,101):
    if i not in P:
      PP.append(i)
  lo = 0
  hi = len(PP)-1

  while(lo<hi):
    mid = lo + ((hi - lo)//2)
    if PP[mid]< X:
      lo = mid + 1
    else:
      hi = mid
  n1 = PP[lo]
  n2 = PP[lo-1]
  if abs(X-n1)<abs(X-n2):
    print(n1)
  else:
    print(n2)
else:
  print(X)

Submission status: Runtime Error

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

if(N>0):
  P = list(map(int,input().split()))
  PP = []
  for i in range(1,101):
    if i not in P:
      PP.append(i)
  lo = 0
  hi = len(PP)-1

  while(lo<=hi):
    mid = lo + ((hi - lo)//2)
    if PP[mid]<= X:
      lo = mid + 1
    else:
      hi = mid
  n1 = PP[lo]
  n2 = PP[lo-1]
  if abs(X-n1)<abs(X-n2):
    print(n1)
  else:
    print(n2)
else:
  print(X)

Submission status: Runtime Error

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

if(N>0):
  P = list(map(int,input().split()))
  PP = []
  for i in range(1,101):
    if i not in P:
      PP.append(i)
  lo = 0
  hi = len(PP)-1

  while(lo<hi):
    mid = lo + ((hi - lo)//2)
    if PP[mid]<= X:
      lo = mid + 1
    else:
      hi = mid
  n1 = PP[lo]
  n2 = PP[lo-1]
  if abs(X-n1)<abs(X-n2):
    print(n1)
  else:
    print(n2)
else:
  print(X)

Submission status: Runtime Error

Solution code:
X,N = int(input().split())
list = [int(x) for x in input().split()]

min_num = 150

for a in range(X - N - 2, X + N + 3):
    counter = 0
    A = abs(X - a)
    for b in list:
        if a == b:
            counter = 1
        else:
            continue
    if counter == 1:
        continue
    else:
        if A == abs(X - a):
            min_num = (a, min_num)
        elif A > abs(X - a):
            min_num = a
        else:
            continue

print(min_num)

Submission status: Runtime Error

Solution code:
X,N = int(input().split())
list = [int(x) for x in input().split()]

min_num = 150

for a in range(-10,110):
    counter = 0
    A = abs(X - a)
    for b in list:
        if a == b:
            counter = 1
        else:
            continue
    if counter == 1:
        continue
    else:
        if A == abs(X - a):
            min_num = (a, min_num)
        elif A > abs(X - a):
            min_num = a
        else:
            continue

print(min_num)

Submission status: Runtime Error

Solution code:
a,b=input().split()
pp=input().split()
a=int(a)
b=int(b)
p=[]
for pa in pp:
    p.append(int(pa))
x=0
y=-1
while:
    if a+x not in p:
        aa=a+x
        break
    elif a+y not in p:
        aa=a+y
        break
    x+=1
    y+=-1
print(aa)

Submission status: Runtime Error

Solution code:
import numpy as np
x,n = map(int,input(). split ())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    num = max(p)
    ans = [0]*(100+1)
    temp = -1
    val2 = 100

    for i in range(2+100):
        temp += 1
        ans[i] = temp
    # for i in range(n):
    #     temp1 =p[i]
    #     ans.remove(temp1)
    ans = list(set(ans) ^ set(p))
    ans.sort()
    # print(ans)

    for i in range(2+100-n):
        val1 = abs(ans[i]-x)
        if val1 < val2:
            val2 = val1
            xx = i

    # print(ans)
    # print(min(ans)) 
    # print(min(ans)+x) 
    print(ans[xx])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

print(koho[0])

Submission status: Runtime Error

Solution code:
def main():
    x, n = map(int, input().split())
    r = [i for i in range(1, 101)]
    np = [int(i) for i in input().split()]
    p = list(set(r) - set(np))
    p.sort()
    _min, _max = 0, len(p) - 1
    while _min <= _max:
        pos = _min + (_max - _min) // 2
        if p[pos] == x:
            break
        elif p[pos] < x:
            _min = pos + 1
        else:
            _max = pos - 1

    print(p[pos])

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

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

l = [ i for i in range(1,101) ]

if len(P) == 0:
    print(X)
    sys.exit()

idx = l.index(X)

ans = 0
for i in range(1,100):
    if l[idx+i] not in P:
        ans = i
        break

ans1 = 0
for i in range(1,100):
    if l[idx-i] not in P:
        ans1 = i
        break

if ans<ans1:
    print(l[idx+ans])
else:
    print(l[idx-ans1])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

import sys

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

Submission status: Runtime Error

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

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


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

Submission status: Runtime Error

Solution code:
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

###################################################

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

d_min = 1000
ans = 1000
for num in range(-1, 102):
    if num in P:
        continue
    
    d = abs(x-num)
    if d < d_min:
        d_min = d
        ans = num

print(ans)

Submission status: Runtime Error

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

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

import sys

min_abs = min(abs_value)

for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Runtime Error

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

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


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

Submission status: Runtime Error

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

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

import sys

for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Runtime Error

Solution code:
import sys

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

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

for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import sys

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

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

for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Runtime Error

Solution code:
import sys

X,N = (int(x) for x in input().split())
P = list(map(int,input().split()))

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

for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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

table = [0] * 100
for a in data:
    a -= 1
    table[a] = 1

x -= 1
left = None
idx = x
while idx > 0:
    if table[idx] == 0:
       left = idx
       break
    idx -= 1
idx = x
right = None
while idx < 100:
    if table[idx] == 0:
        right = idx
        break
    idx += 1

lscore = abs(x-left)
rscore = abs(x-right)

if lscore <= rscore:
    print(left+1)
else:
    print(right+1)

Submission status: Runtime Error

Solution code:
x, n = map(int,input().split())
p = [int(i) for i in input().split()]
number = list(range(1,101,1))

left = list(range(1,x))
left.reverse()

right = list(range(x,101,1))

for i in left:
    if i in p:
        continue
    else:
        left_max = i
        break

for i in right:
    if i in p:
        continue
    else:
        right_min = i
        break

if abs(x - left_max) <= abs(x - right_min):
    print(left_max)
else:
    print(right_min)

Submission status: Runtime Error

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
x, y = map(int, input().split())
if y == 0:
  print(x)
  exit()
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(0, 100)
for i in p_n:
    pp[i] += 10000
sa = min(abs(pp-x))
if sa <= 100:
    if pp[x-sa] >= 10000:
        print(x+sa)
    else:
        print(x-sa)
else:
    print("0")

Submission status: Runtime Error

Solution code:
x, n, *P = map(int, open(0).read().split())
P = set(P)
for i in range(51):
    Q = {x-i, x+i} - P
	if Q:
		print(min(Q))
		break

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x, n = [int(i) for i in input().split(' ')]
if n > 0:
    p = [int(i) for i in input().split(' ')]

    p.append(x)
    p.sort()
    i = p.index(x)

    y = x
    double = 0

    for j in range(1, i + 1):
        if i == j:
            low = x - j - 1
        elif not x - j + double == p[i - j]:
            if x == p[i - j]:
                double += 1
            else:
                low = x - j + double
                break
    double = 0
    for j in range(1, len(p) - i + 1):
        if j + i == len(p):
            high = x + j + 1
        elif not x + j - double == p[i + j]:
            if x == p[i + j]:
                double += 1
            else:
                high = x + j - double
                break

    if x - low > high - x:
        print(high)
    else:
        print(low)
else:
    print(x)
    exit()

Submission status: Runtime Error

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

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

	ans = -1
	mn = 10000

	for i in range(1, 101):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	if d == 10000:
		if(x <= 50):
			ans = 0
		else:
			ans = 101
	print(ans)

Submission status: Runtime Error

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

NL = []
for i in range(100):
    NL.append(i+1)

for l in L:
    NL.remove(l)

NL.append(X)
NL.sort()

LR = NL.index(X)+1
LL = NL.index(X)-1


if (NL[LR]-X) < (X-NL[LL]):
    print(NL[LR])
else:
    print(NL[LL])

Submission status: Runtime Error

Solution code:
import sys

x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
else:
    p = [102]
sa = 201

for i in range(100):
    if abs(i-x+1) < sa:
        if not((i+1) in p):
            sa = abs(i-x+1)
            ans = i+1
print(ans)

Submission status: Runtime Error

Solution code:
import sys

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

sa = 201

for i in range(100):
    if abs(i-x+1) < sa:
        if not((i+1) in p):
            sa = abs(i-x+1)
            ans = i+1
print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
l = list(map(int, input().split()))
flg = false
t = x
while flg == False:
  if t in l:
    t -= 1
  else:
    ans = t
    flg = True
flg = False
t = x
while flg == False:
  if t in l:
    t += 1
  else:
    if abs(x-ans) > abs(x-t):
      ans = t
    flg = True
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

#リストを作る
all_l = [i for i in range(0,101)]

#Pの数値を消去
for p in P:
    all_l.remove(p)
    
#全探索
kouho = x
for i in range(200):
    kouho1 = x-i
    kouho2 = x+i
    if kouho1 not in P:
        print(x-i)
        break
    elif kouho2 not in P:

Submission status: Runtime Error

Solution code:
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      b = p.count(a)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
X, N = map(int,input().split())
p = list(map(int, input().split()))
mylist=list(np.arange(1,101))
new_list = set(mylist) - set(p)
new_list2 = list(new_list)
a= []
for i in new_list:
    b = abs(i-X)
    a.append(b)
c = [i for i, v in enumerate(a) if v == min(a)]
print(new_list2[c[0]])

Submission status: Runtime Error

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)

Submission status: Runtime Error

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i) for i in range(102)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min[tmp])

print(num_list[ans])

Submission status: Runtime Error

Solution code:
x, n =map(int, input().split())
if n>0:
    p=list(map(int, input().split()))
    p.sort()
    dif=p[n-1]-x
    for i in range(0,x-p[0]+1):
        if x-i in p:
            a=0
        else:
            ans=x-i
            dif=i
            break
    for i in range(1,dif):
        if x+i in p:
            a=0
        else:
            ans=x+i
            break
    print(ans)
else:
    print(x)

Submission status: Runtime Error

Solution code:
x, n =map(int, input().split())
p=list(map(int, input().split()))
p.sort()
dif=p[n-1]-x
for i in range(0,x-p[0]+1):
    if x-i in p:
        a=0
    else:
        ans=x-i
        dif=i
        break
for i in range(1,dif):
    if x+i in p:
        a=0
    else:
        ans=x+i
        break

print(ans)

Submission status: Runtime Error

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

try:
  plist = list(map(int, input().split()))
except:
	plist =[]

abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])

try: A = min(abst1)
except:A=0
  
try:
	for j in range(0,len(abst1)):
	  if abst2[j][1] == A:
    	if abst2[j][0]>X:
      	if abst2[j][0]-X>=X+1:
        	print(0)
        	break
    	print(abst2[j][0])
    	break
except:print(0)

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 101

for i in p:
    flag[i] = False

for i in range(101):
    if flag[x-i]:
        print(x-i)
        break
    elif flag[x+i]:
        print(x+i)
        break

Submission status: Runtime Error

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = max(num_list[i], X) - min(num_list[i], X)

ans = [i for i,x in enumerate(tmp) if x == min(tmp)]
# print(num_list)
# print(tmp)
# print(ans)
if len(ans) == 2:
    print(min(num_list[ans[0]],num_list[ans[1]]))
else:
    print(num_list[ans])

Submission status: Runtime Error

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

try:
  plist = list(map(int, input().split()))
except:
	plist =[]

abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])

A = min(abst1)

for j in range(0,len(abst1)):
  if abst2[j][1] == A:
    if abst2[j][0]>X:
      if abst2[j][0]-X>=X+1:
        print(-1)
        break
    print(abst2[j][0])
    break

Submission status: Runtime Error

Solution code:
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)


print(X[O])

Submission status: Runtime Error

Solution code:
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)


print(X[O])
print(X)
print(H)
print(O)

Submission status: Runtime Error

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

try:
  plist = list(map(int, input().split()))
except:
	plist =[]

abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])

A = min(abst1)

for j in range(0,len(abst1)):
  if abst2[j][1] == A:
    if j>X:
      if j-X>=X+1:
        print(-1)
        break
    print(abst2[j][0])
    break