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:
#C
X,N = map(int,input().split())
p = list(map(int,input().split()))
r = 100
for i in range(100,min(p)-2,-1):
    if i in p:
        pass
    else:
        if abs(r-X) >= abs(i-X):
            r = i
        else:
            pass
print(r)

Submission status: Runtime Error

Solution code:
6 5
4 7 10 6 5

Submission status: Runtime Error

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

best = 100000000
ret = x

if n:
	mn = min(ps)
	mx = max(ps)
	s = set(ps)
	for i in range(mn, mx+1):
		if i not in s:
			d = abs(x-i)
			if d < best:
				best = d
				ret = i
	if ret == x:
		up = abs(mx + 1 - x)
		down = abs(mn - 1 - x)
		ret = mn-1 if down <= up else mx+1
		
if x not in s:
	ret = x

print(ret)

Submission status: Runtime Error

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

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i =+ 1

Submission status: Runtime Error

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

if N == 0:
    print(X)
    break
    
else:
    for i in range(100):
    if (X-(i+1)) and (X+i+1) in p:
        continue
    
    elif (X-i-1) not in p:
        print(X-i-1)
        break
    
    elif (X+i+1) not in p:
        print(X+i+1)
        break

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*100
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,50):
        if(list_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(list_io[(x-1)+i] == 0):
            print(x+i)
            break

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
x, N = map(int, input().split())

if N != 0:
    p1, p2, p3, p4, p5 = map(int, input().split())
    num_list = [p1, p2, p3, p4, p5]

min_abs = 100
min_num = 0

for num in range(1, 101):
    if not num_list:
        min_num = x
        break
    if num in num_list:
        continue
    else:
        b = abs(num-x)
        if b < min_abs:
            min_abs = b
            min_num = num
            
print(min_num)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
x,n=map(int,input().split())
if n!=0:
    a=list(map(int,input().split()))
else:
    a=[0]*3
number=[0]*101

for num in range(len(a)):
    number[a[num]]=a[num]
    
counter=0
plus=0
ans=0

while counter==0:
    if number[x-plus]==0:
        counter+=1
        ans=x-plus
    elif number[x+plus]==0:
        counter+=1
        ans=x+plus
    else:
        plus+=1
        if plus>x or plus>100-x:
            ans=0

print(ans)

Submission status: Runtime Error

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

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

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        if a not in p:
            ans = a
        b = start + v + 1
        if b not in p:
            if ans > b:
                ans = b
            break
            
else:
    ans = x
    
print(ans)

Submission status: Runtime Error

Solution code:
a,b = int(input().split())
arr = list(map(int, input().split()))
if b == 0:
  print(a)
x = max(arr)
while a < x:
  if a in arr:
    if a-1 in arr:
      a += 1
    else:
      a -= 1 
  else:
    print(a)
    break

Submission status: Runtime Error

Solution code:
import bisect

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

p.sort()

index = bisect.bisect_left(p,x)

if n==0:
    print(x)
else:
    for i in range(n):
        print(index-i, index+i)
        if p[index-i] != x-i:
            print(x-i)
            break
        elif p[index+i] != x+i:
            print(x+i)
            break

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
x =a[0]
n =a[1]
if n==0:
  print(x)
else:
  p = list(map(int,input().split()))
  p.sort()
  out_p = []
  for i in range(p[n-1]-p[0]+1):
    if not i+p[0] in p:
      out_p.append(i+p[0])
  if min(p)>x or max(p)<x:
    print(x)
  else:
    re_p =[]
    for j in range(len(out_p)):
      re_p.append(abs(out_p[j]-x))
    print(out_p[re_p.index(min(re_p))])

Submission status: Runtime Error

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

P = list(map(int, input().split()))
minmin = []
minn = 101
for i in range(1, 101):
    abs1 = abs(i - X)
    if not i in P and minn >= abs1:
        minn = abs1
        minmin.append(i)

if len(minmin) > 2 and abs(X - minmin[-1]) == abs(X - minmin[-2]):
    print(minmin[-2])
    exit()
print(max(minmin))

Submission status: Runtime Error

Solution code:
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(z[0])
else:
  p = list(map(int, input().split()))
  count = 0
  l = []
  for i in range(-150, 150):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)

Submission status: Runtime Error

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

syou = 1000
kouho = 1000

for i in range(-100, 101):
    flag = 0
    for j in range(n):
        if i == p[j]:
            flag = 1

    if flag == 1:
        continue

    if syou > abs(x-i):
        kouho = i
        syou = abs(x-i)
        continue
    elif syou == abs(x-i):
        kouho = min([kouho, i])
        continue

for k in range(n):
    if p[k] > 0:
        print(kouho)
        exit()

print(min(p))

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
sa = []
num = []
for i in range(1,101):
    if i in p:
        continue
    sa.append(abs(x-i))
    num.append(i)

print(num[sa.index(min(sa))])

Submission status: Runtime Error

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

    min = 1000

    for i in range(1, 101):

        if i in p:
            continue

        elif min > abs(x - i):
            result = i
            min = abs(x - i)

    print(result)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

  for i in range(n-2):
    if x-i not in p:
      ans.append(-i)
      break
    elif x+i not in p:
      ans.append(i)
      break
    else:
      ans.append(-3)
  print(x+ans[0])

Submission status: Runtime Error

Solution code:
import sys

x,n = map(int,input().split())
if n != 0:
    l = list(map(int,input().split()))
else:
    print(x)
    sys.exit()

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

tmp = []
for i in range(x-50,x+50):
    tmp.append(i)

ans = []
for j in tmp:
    if j not in l:
        ans.append(j)

tmp1 = 100
for k in ans:
    tmp2 = abs(x-k)
    if tmp2 != 0:
        if tmp1 >= tmp2:
            tmp1 = tmp2

ans2 = []
for m in ans:
    a = abs(m-x)
    if a == tmp1:
        ans2.append(m)

print(min(ans2))

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
if n == 0:
    print(x)
    exit()
lst = [int(i) for i in input().split()]
n_lst = [int(i) for i in range(1,101)]

for i in range(x,101 - x):
    if not(n_lst[i] in lst):
        mn1 = n_lst[i]
        break
n_lst = n_lst[::-1]
for i in range(100 - x, 101):
    if not(n_lst[i] in lst):
        mn2 = n_lst[i]
        break
if abs(mn1-x) >= abs(mn2-x):
    print(mn2)
else:
    print(mn1)

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

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

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


z=101
p_list = list(map(int,input().split()))
pp_list = [i for i in range(min(p_list),max(p_list)+1)]

for j in p_list:
    pp_list.remove(j)

for k in pp_list:
    zettaiti = abs(x-k)

    if z > zettaiti:
        z = zettaiti
        ans = k

print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n != 0:
  n = list(map(int, input().split()))
  min_n = min(n)
  max_n = max(n)
  ans = []
  for i in range(1, max(x - min_n, max_n - x) + 1):
    if n.count(x + i) == 0:
      ans.append(x + i)

    if n.count(x - i) == 0:
      ans.append(x - i)
    
    if ans != []:
      break

  print(min(ans))
else:
  print(x)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = []
sortlist = []
p.sort()
p1 = p[0]
pn = p[n-1]
new = [i for i in range(p1-1, pn+1)]
nolist = set(new) ^ set(p)
nolist = list(nolist)
print(nolist)
for i in range(0, len(nolist)):
    d = abs(nolist[i] - x)
    sortlist.append(d)

k = sortlist.index(min(sortlist))
print(nolist[k])

Submission status: Runtime Error

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


l = [0]*100

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))
if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

Submission status: Runtime Error

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

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

p = list(map(int, input().split()))
p = sorted(p)
q = [i for i in range(1, 100+1)]
r = []


for i in q:
    if i not in p:
        r.append(i)

s = [abs(x-i) for i in r]

print(r[s.index(min(s))])

Submission status: Runtime Error

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

pl=[]
if n==0:
    print(x)
else:
    for i in range(n):
        pl.append(abs(p[i]-x))
    sort_p=sorted(pl)
    #print(sort_p)
    if sort_p[0]!=0:
        print(x)
    else:
        num=0
        for i in range(1,n):
            if i%2!=0:
                num+=1
            if sort_p[i]!=num:
                ans=num
                break
        #print(ans)
        small=x-ans
        big=x+ans
        #print(p)
        #print(small,big)
        if (small not in p)&(big not in p):
            print(small)
        elif small in p:
            print(big)
        elif big in p:
            print(small)

Submission status: Runtime Error

Solution code:
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(z[0])
else:
  p = list(map(int, input().split()))
  count = 0
  l = []
  for i in range(-100, 101):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)

Submission status: Runtime Error

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-1, X)]
big = [i for i in range(X+1, 101)]
small.reverse()
print(small)
print(big)
print(max(len(big),len(small)))
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    X, N = LI()
    if N == 0:
        print(X)
        return

    p = LI()

    p_max = max(p)
    p_min = min(p)

    if X < p_min or p_max < X:
        print(X)
        return
    else:
        d = [abs(i-X) for i in range(p_min, p_max+1) if i not in p]
        d_min = min(d)
        for i in range(p_min, p_max+1):
            if i not in p:
                if abs(i-X)==d_min:
                    print(i)
                    return

if __name__ == '__main__':
    resolve()

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
for i in range(n):
    p = list(map(int,input().split()))
flaga,flagb = 0
for i in range(1,n):
    for j in range(n):
        if x-i == p[j]:
            flaga = 1
        if x+i == p[j]:
            flagb = 1
    if(flaga == 0):
        print(x-i)
    elif(flagb == 0):
        print(x+i)
    elif(flaga == 0 and flagb == 0):
        print(x-i)

Submission status: Runtime Error

Solution code:
import bisect
a,b=map(int,input().split())
c=list(map(int,input().split()))

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

m=sorted(list(set(n)^set(c)))
bisect.insort_right(m,a)

m=sorted(list(set(m)))

if b==0:
    print(a)

elif a==100:
    print(m[m.index(a)]-1)

elif abs(a-m[m.index(a)]-1)<abs(a-m[m.index(a)+1]):
    print(m[m.index(a)+1])

elif abs(a-m[m.index(a)]-1)==abs(a-m[m.index(a)+1]):
    print(m[m.index(a)]-1)

else:
    print(m[m.index(a)]-1)

Submission status: Runtime Error

Solution code:
import numpy as np

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

p_list = [int(n) for n in input().split()]

X_near = np.array(list(range(int(np.ceil(X - N/2)), int(np.floor(X + N/2)) + 1)))

remain_list = []

for i in X_near:
    if i not in p_list:
        remain_list.append(i)
        
remain_array = np.array(remain_list)
min_bool = np.abs(X - remain_array).min() == np.abs(X - remain_array)
print(remain_array[min_bool][0])

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))
l = []
for i in range(1,101):
  l.append(i)
L = []
for i in l:
  if i not in p:
    L.append(i)
l = []
for i in L:
  l.append([i, abs(x-i)])
a = min(l, key = lambda t: t[1])
print(list(a)[0])

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
if(n!=0):
    a = list(map(int,input().split()))
else:
    print(x)
flag=True
k = 0

while(True):
    b = x - k
    c = x + k
    if(not(b in a)):
        print(b)
        break
    elif(not(c in a)):
        print(c)
        break
    k = k + 1

Submission status: Runtime Error

Solution code:
import numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                if X-maxn>a[i]+1-X
                maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))

Submission status: Runtime Error

Solution code:
def main():
    import sys
    X, N = map(int, sys.stdin.readline().split())
    P = list(map(int, sys.stdin.readline().split()))
    ans = []
    for i in range(0, 101):
        if X-i<0:
            break
        if not (X-i) in P:
            ans +=[i]
            break
    for i in range(0, 101):
        if X+i >100:
            break
        if not (X+i) in P:
            ans +=[i]
            break
    
    if ans[0]-ans[1] !=0:
        print(min(ans)+X)
    else:
        print(ans[0])



if __name__=='__main__':
    main()

Submission status: Runtime Error

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

l = list(range(1,101))
s = []
  
for i in p:
  l.remove(i)

for j in l:
  s.append(abs(X-j))
  
ans = min(s)

if l.count(X+ans) == 1 and l.count(X-ans) == 1:
  print(X-ans)

elif l.count(X+ans) == 1 and l.count(X-ans) != 1:
  print(X+ans)
  
elif l.count(X+ans) != 1 and l.count(X-ans) == 1:
  print(X-ans)

Submission status: Runtime Error

Solution code:
import sys

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

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

all_list = [int(x) for x in range(min(list_p), max(list_p) + 1)]
target_list = sorted(list(set(list_p) ^ set(all_list)))

ans = [abs(num - X) for num in target_list]
# print(ans)
# print(min(ans))
# print(ans.index(min(ans)))
print(target_list[ans.index(min(ans))])

Submission status: Runtime Error

Solution code:
import numpy as np

def main():
    x, n = [int(x) for x in input().split()]
    if n > 0:
        ps = [int(x) for x in input().split()]
        s = set(list(range(1, 101)))
        notps = s - set(ps)
        ps = np.array(list(notps))
        ps = ps - x
        ps = [abs(p) for p in ps]
        ps.sort()
        m = ps[0]
        if x - m in notps:
            print(x - m)
            return
        elif x + m in notps:
            print(x + m)
            return
    else:
        print(x)
    

main()

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
x,n=map(int,input().split())
if n!=0:
    a=list(map(int,input().split()))
else:
    a=[0]*3
number=[0]*101

for num in range(len(a)):
    number[a[num]]=a[num]
    
counter=0
plus=0
ans=0

while counter==0:
    if number[x-plus]==0:
        counter+=1
        ans=x-plus
    elif number[x+plus]==0:
        counter+=1
        ans=x+plus
    else:
        plus+=1

print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

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

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


z=101
pp_list = [i for i in range(min(p_list),max(p_list)+1)]

for j in p_list:
    pp_list.remove(j)

for k in pp_list:
    zettaiti = abs(x-k)

    if z > zettaiti:
        z = zettaiti
        ans = k

print(ans)

Submission status: Runtime Error

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

P_sub_abs = [abs(i - X) for i in P]
if(P_sub_abs.count(0) == 0):
    print(X)
    exit()
for i in range(1, 100):
    if(P_sub_abs.count(i) == 1):
        list = [X - i, X + i]
        list.remove(P[P_sub_abs.index(i)])
        print(list[0])
        exit()
    elif(P_sub_abs.count(i) == 0):
        print(X - i)
        exit()

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left,bisect_right
def main():
    x,n=map(int,input().split())
    PP=list(map(int,input().split()))
    P=[]
    if n==0:
        print(x)
        sys.exit()
    for xx in range(101):
        if xx in PP:continue
        P.append(xx)
    for i,p in enumerate(P[:-1]):
        if p>=x:
            P_right=p
            break
        P_left=p
    if abs(P_left-x)<=abs(P_right-x):
        print(P_left)
    else:
        print(P_right)

if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
import numpy as np

input = sys.stdin.readline


def main():
    X, N = list(map(int, input().split(" ")))
    if N==0:
        print(X)
        exit(0)
    arr = list(map(int, input().split(" ")))
    if X not in arr:
        print(X)

    arr.sort()
    for i in range(len(arr)):
        if arr[i] >= X:
            diff = 1
            while True:
                if X - diff not in arr:
                    print(X-diff)
                    exit(0)
                if X + diff not in arr:
                    print(X+diff)
                    exit(0)
                diff +=1


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

P=list(map(int,input().split()))
P=sorted(P)
x=bisect_left(P,X)
if x>=len(P):
    print(X)
    sys.exit()
if P[x]!=X:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    x1=bisect_left(P,A)
    x2=bisect_left(P,B)

    if P[x1]!=A:
        print(A)
        break
        
    if P[x2]!=B:
        print(B)
        break

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n > 0:
    ps = list(map(int, input().split()))
else:
    ps = []
nums = [n for n in range(1, 101) if n not in ps]

if x in nums:
    print(x)
else:
    abs_plus = sorted([n-x for n in nums if n-x >= 0])
    abs_minus = sorted([-(n-x) for n in nums if n-x < 0])
    if abs_plus[0] >= abs_minus[0]:
        print(x-abs_minus[0])
    else:
        print(x+abs_plus[0])

Submission status: Runtime Error

Solution code:
X, N = list(map(int, input().split()))
if N != 0:
    P = list(map(int, input().split()))
    ans = 0
    L = X
    L = X
    for _ in range(N // 2):
        L = L - 1
        H = H + 1
        if L not in P:
            print(L)
            break
        if H not in P:
            print(H)
            break
else:
    print(X)

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)

	for x in range(0,diff+1):
		if X-x not in p
			print(X-x)
			break
		if X+x not in p
			print(X+x)
			break

Submission status: Runtime Error

Solution code:
kazulist = []
for i in range(100):
    kazulist.append(i+1)
 
a = list(input().split(" "))
target = int(a[0])
syokyo = int(a[1])
 
b = list(input().split(" "))
for i in b:
    kazulist.pop(int(i))
 
saisyosa = 100
kotae = 0
for i in kazulist:
    sa = target - int(i)
    if sa < 0:
        sa *= -1
    if sa < saisyosa:
        saisyosa = 0
        kotae = i
 
print(kotae)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = list(range(1, 100))
ll = []
if n ==0:
    print(x)
else:
    for i in p:
        l.remove(i)
    for j in range(100):
        if x-j in l:
            ll.append(x-j)
        if x+j in l:
            ll.append(x+j)
        if len(ll) != 0:
            print(min(ll))
            break

Submission status: Runtime Error

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

if N == 0:
    print(X)
else:
    A = [i for i in range(1,100)]

    for i in P:
        A.remove(i)

    a = (np.array(A) - X)**2
    j = np.argmin(a)
    print(A[j])

Submission status: Runtime Error

Solution code:
A1 = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
 
X = A1[0]
N = A1[1]
diff = 100
ans=[]
ans0 = 100
 
for i in range(N):
  diff0 = abs(p[i]-X)
  if diff0 < diff:
    diff = diff0
    ans.append(p[i])
if int(len(ans)) > 1:
  for i in range(int(len(ans))):
    if ans[i] < ans0:
      ans0 = ans[i]
else:
  ans0 = ans[0]
print(ans0)

Submission status: Runtime Error

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

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

  p.sort()
  q=list(range(1,max(p)+1))

  for i in p:
    q.remove(i)

  Z=1000
  ans=-1
  for i in q:
    if( abs(X-i)<Z):
      Z=abs(X-i)
      ans=i
  
  print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import bisect


def solve(X: int, N: int, p: "List[int]"):
    sortp = sorted(p)
    if(N == 0):
        print(X)
        exit()

    for i in range(100):
        # 左側
        l = X - i
        index = bisect.bisect_left(sortp,l)
        if(sortp[index] != l):
            print(l)
            exit()

        # 右側
        r = X + i
        index = bisect.bisect_left(sortp,r)
        if(sortp[index] != r):
            print(r)
            exit()

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(X, N, p)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
if n == 0:
    ans = x
else:
    p = sorted(p)
    min_p = min(p)
    max_p = max(p)
    j = 0
    ans = 0
    if x < min_p:
        ans = x
    elif x > max_p:
        ans = x
    elif x == min_p:
        if min_p+1 == p[1]:
            ans = min_p-1
        else:
            ans = min_p+1
    elif x == max_p:
        if max_p-1 == p[len(p)-1]:
            ans = max_p+1
        else:
            ans = max_p-1
    else:
        for i in range(min_p+1, max_p):
            if i == p[j+1]:
                j += 1
            else:
                if abs(ans-x) > abs(i-x):
                    ans = i
print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
num_list = list(map(int, input().split()))
dif = 101
o_list = []
num_list.sort(reverse=True)

if len(num_list) == 0:
    print(x)
    exit()

for i in range(1, max(num_list)):
    if i not in num_list:
        o_list.append(i)

o_list.sort(reverse=True)

for num in o_list:
    if abs(x - num) <= dif:
        # if x not in num_list:
        dif = abs(x -num)
        ans = num

print(ans)

Submission status: Runtime Error

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

syou = 1000
kouho = 1000

for i in range(-100, 101):
    flag = 0
    for j in range(n):
        if i == p[j]:
            flag = 1

    if flag == 1:
        continue

    if syou > abs(x-i):
        kouho = i
        syou = abs(x-i)
        continue
    elif syou == abs(x-i):
        kouho = min([kouho, i])
        continue

for k in range(n):
    if p[k] > 0:
        print(kouho)
        exit()
    
print(max(p))

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
p = list(map(int, input().split()))
#print(p)
#A.sort()
dis = p[0] - X
ans = p[0]
for pi in p :
  if abs(pi-X) < abs(dis):
    ans = pi
    dis = pi - X
    #print("if")
  elif pi-X == -abs(dis):
    ans = pi
    dis = pi - X
  #print(pi-X, abs(pi-X), dis,abs(dis))
print(ans)

Submission status: Runtime Error

Solution code:
from bisect import bisect_left as bl
x,n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    i = 0
    p.sort()
    a = bl(p, x)
    if a == n:
        print(x)
    elif p[a] != x:
        print(x)
    else:
        while(True):
            i += 1
            if p[bl(p, x-i)] != x-i:
                print(x-i)
                break
            elif p[bl(p, x+i)] != x+i:
                print(x+i)
                break

Submission status: Runtime Error

Solution code:
def dev(y,x):
    if y<x:
        return 2*(x-y)-1
    else:
        return 2*(y-x)


x,n=map(int,input().split())
if n==0:
    print(x)
else:
    p=[int(y) for y in input().split()]
    q=[dev(y,x) for y in p]
    q.sort()
    r=0
    while True:
        if q[r]!=r:
            break
        r+=1
    if r%2==0:
        print(x+r//2)
    else:
        print(x-(r+1)//2)

Submission status: Runtime Error

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

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

tmp = []
for i in range(x-50,x+50):
    tmp.append(i)

ans = []
for j in tmp:
    if j not in l:
        ans.append(j)

tmp1 = 100
for k in ans:
    tmp2 = abs(x-k)
    if tmp2 != 0:
        if tmp1 >= tmp2:
            tmp1 = tmp2

ans2 = []
for m in ans:
    a = abs(m-x)
    if a == tmp1:
        ans2.append(m)

print(min(ans2))

Submission status: Runtime Error

Solution code:
from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

memos = [False] * 102

for p in P:
    memos[p] = True

tgt = x
offset = 1
look_down = True
while True:

    if memos[tgt] == False:
        break
    if look_down:
        look_down = False
        tgt = tgt-offset
    else:
        look_down = True
        tgt = offset + offset
        offset += 1

print(tgt)

Submission status: Runtime Error

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


l = [0]*X

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))
if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
try:
    p=list(map(int,input().split()))
    p.sort()
    min=abs(p[n-1])
    for i in range(p[0],p[n-1]):
        if i not in p:
            if min>abs(i-x):
                min=abs(i-x)
                ans=i
except:
    ans=x
print(ans)

Submission status: Runtime Error

Solution code:
X,N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
nlist = [0 for i in range(100)] 
for i in p:
    nlist[i-1]=1
for i in range(max(X+1,100-X+1)):
    
    if X-i-1>=0:
        if nlist[X-i-1] == 0:
            result = X-i
            break
    if X+i-1>=0:
        if nlist[X+i-1] == 0:
            result = X+i
            break
print(result)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
nums = list(range(1, 101))
for p in ps:
    nums.remove(p)
for i, num in enumerate(nums):
    if num > x:
        break
if i - 1 < 0:
    print(nums[i])
else:
    diff1 = abs(nums[i - 1] - x)
    diff2 = abs(nums[i] - x)
    if diff1 < diff2:
        print(nums[i - 1])
    elif diff1 > diff2:
        print(nums[i])
    else:
        print(nums[i-1])