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:
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-10,x+10):
    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 = [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,100-X)):
    
    if X-i>=0:
        if nlist[X-i-1] == 0:
            result = X-i
            break
    if X-i>=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())
if N != 0:
    p = list(map(int, input().split()))
else:
    print(X)
    exit()

if N = 100:
    print(0)
    exit()

for i in range(X+1):
    if not i in p:
        x = i

for i in range(X,101):
    if not i in p:
        y = i
        break

if (X-x) == (y-X):
    print(x)
elif (X-x) > (y-X):
    print(y)
else:
    print(x)

Submission status: Runtime Error

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

x = a[0]
n = a[1]
d = list(map(int,input().split()))

if (n == 0):
    print(x)
else:
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]SSS
    if (x < min_int or max_int < x):
        print(x)
    else:
        p = []
        for var in range(min_int,max_int):
            if var not in d:
                p.append(var)
            else:
                continue
        ans = []
        for pp in p:
            ans.append(np.abs(pp - x))
        ans = np.array(ans)
        print(p[np.argmin(ans)])

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
p = sorted(list(map(int, input().split())))
P = list(range(1, 101))
[P.remove(pp) for pp in p]
p_min_abs = 10000000
for pp in P:
    if abs(pp - X) < p_min_abs:
        p_min_abs = abs(pp - X)
        p_min = pp
print(p_min)

Submission status: Runtime Error

Solution code:
import sys
import math
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

x,n = I2()
if n != 0:
    p = Intl()
else:
    p = []
p.sort()
if not x in p:
    print(x)
else:
    b,e = 0,n-1
    for i in range(n):
        if p[i] == x:
            b = max(b,i-1)
            e = min(e,i+1)
            break
    #print(b,e)
    r = []
    s = []
    for i in range(p[b],p[e]+2):
        if i not in p:
            r.append(i)
            s.append(abs(x-i))
    print(r[s.index(min(s))])

Submission status: Runtime Error

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

if n != 0:
    s = set(map(int, input().split()))
    origin_set = set(range(1, 101))
    result_set = origin_set - s
    result_list = list(result_set)
    result_num = 1000

    for i in result_list:
      if abs(x-i) < result_num:
        min_num = i
        result_num = abs(x-i)
      elif abs(x-i) == result_num:
        if i < min_num:
          min_num = i
    print(min_num)
else:
  print(x)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

q = [x for x in range(1, 101) if x not in p]
diffs = [abs(x-qk) for qk in q]
mindiff = min(diffs)
idx = diffs.index(mindiff)
print(q[idx])

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()
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:
x, n = map(int, input().split())
if (n != 0):
  p = list(map(int, input().split()))
else:
  print(x)
  exit()

kouho = list(range(1, max(p) + n))
# print(kouho)

for i in range(len(p)):
  if p[i] != x:
    del kouho[kouho.index(p[i])]

kouho_num = kouho.index(x)
right = kouho_num + 1
left = kouho_num - 1


if abs(kouho[right] - kouho[kouho_num]) > abs(kouho[kouho_num] - kouho[left]):
  print(kouho[left])
elif abs(kouho[right] - kouho[kouho_num]) == abs(kouho[kouho_num] - kouho[left]):
  print(kouho[left])
else:
  print(kouho[right])

Submission status: Runtime Error

Solution code:

X,N=map(int,input().split())
p=list(map(int,input().split()))
for i in range(102):
    if i in p:
        p.remove(i)
    else:
        p.append(i)
for i in range(102-N):
    if abs(X-p[i])<abs(X-ans):
        ans=p[i]
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
X,N = map(int,input().split())
p = list(map(int,input().split()))
idx = 0
if X < min(p):idx =0
elif X>max(p):idx =N-1
else:idx = np.abs(np.asarray(p) - X).argmin()
print(idx+1)

Submission status: Runtime Error

Solution code:
import math

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

if n == 0:
    print(x)

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

    ans = []

    for i in range(x+1, 100):
        if i not in p:
            ans.append(i)
            break

    for i in range(x-1, 0, -1):
        if i not in p:
            ans.append(i)
            break

    if abs(x-ans[0]) < abs(x-ans[1]):
        print(ans[0])
    elif abs(x-ans[0]) == abs(x-ans[1]):
        print(min(ans))
    else:
        print(ans[1])

Submission status: Runtime Error

Solution code:
x , n= map(int,input().split())
p = list(map(int,input().split()))
ans = []
if n == 0:
    print(x)
else:
    for i in range(1,101):
        if i in p:
            pass
        else:
            ans.append(i)
    sa = []
    for i in range(len(ans)):
        sa.append(abs(ans[i]-x))
    MIN=min(sa)
    for i in range(len(ans)):
        if MIN == abs(ans[i]-x):
            print(ans[i])

Submission status: Runtime Error

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

for p in P:
  p = abs[p - x]
  
print(min(P))

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
nump = list(map(int,input().split()))
if(n ==0):
    print(x)
else:
    list_io = [0]*100
    for i in range(n):
        list_io[nump[i]-1] = 1
    # print(list_io)
    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
    # print("?")

Submission status: Runtime Error

Solution code:
xn = list(map(int, input().split()))
d={}
for i in range(101):
    d[str(i)]=0
for i in range(101):
    d[str(-i)]=0


if xn[1]!=0:
    p = list(map(int, input().split()))
    for i in range(xn[1]):
        d[str(p[i])]=1
    for i in range(101):
        if d[str(xn[0]-i)]==0:
            miflag=1
            mi=i
            print(xn[0]-mi)
            break
        if d[str(xn[0]+i)]==0:
            maflag=1
            ma=i
            print(xn[0]+ma)
            break
else:
    print(xn[0])

Submission status: Runtime Error

Solution code:
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

Submission status: Runtime Error

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

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

ans = integers[0]
minabs = abs(integers[0] - x)
for i in integers:
    if abs(i - x) < minabs:
        minabs = abs(i - x)
        ans = i
        break

print(ans)

Submission status: Runtime Error

Solution code:
from bisect import bisect

X, N = [int(n) for n in input().split()]
if N==0:
    print(X)
else:
    P = sorted([int(n) for n in input().split()])
    idx = bisect(P, X)
    for i in range(P[idx-1], 101):
        if i not in P:
            ans_r = i
            break
    for j in range(1, P[idx-1]):
        if j not in P:
            ans_l = j
    if abs(X-ans_l) == abs(ans_r-X):
        print(min([ans_l, ans_r]))
    else:
        print(ans_l if abs(X-ans_l) < abs(ans_r-X) else ans_r)

Submission status: Runtime Error

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

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()
    if p[bl(p, x)] != 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:
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    for i in range(1, 101):
        if i in p:
            continue

        if i <= x:
            ans = i
        elif x - ans > i - x:
            ans = i
    else:
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

def resolve():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return
    A = set(map(int, input().split()))
    dic = {}
    for i in range(1, 101):
        if i not in A:
            dic[i] = abs(X-i)

    sorted_A = sorted(dic.items(), key=lambda x:x[1])
    print(sorted_A[0][0])

if __name__ == "__main__":
    resolve()

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    for i in range(1, 101):
        if i in p:
            continue

        if i <= x:
            ans = i
        elif x - ans > i - x:
            ans = i
    else:
        print(ans)


if __name__ == '__m

Submission status: Runtime Error

Solution code:

def main():
    x,y = list(map(int, input().split()))

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if len(ans) == 1:
        print(ans[0])
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
lst = []
str = input()
l = str.split(' ')
n = int(lst[0])
no = int(lst[1])
  
  
for i in range(0,no):
  inp = int(input())
  lst.append(inp)
  
for i in range(1,100):
  if n-i not in lst:
    print(n-i)
    break
  if n+i not in lst:
    print(n+i)
    break

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 = [i for i in range(-1, 102)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 100

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
Ps=list(map(int,input().split()))
numlist=[]
for i in range(101):
    numlist.append(i)
for p in Ps:
    numlist.remove(p)
import bisect
a=bisect.bisect_left(numlist,x)
b=a-1
if abs(numlist[a]-x)>=abs(numlist[b]-x):
    print(numlist[b])

else:
    print(numlist[a])

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
if n==0: exit(print(x))
p = list(map(int,input().split()))
p.sort()
if x not in p: exit(print(x))
for i in range(x,101):
    if i not in p:
        h = i
        break
for i in range(x,0,-1):
    if i not in p:
        l = i
        break
if abs(x-h)>=abs(x-l): print(l)
if abs(x-l)>abs(x-h): print(h)

Submission status: Runtime Error

Solution code:
import sys
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit(1)
p = [int(x) for x in input().split()]
k = 0
while x in p:
    if not x - k in p:
        print(x - k)
        exit(1)
    elif not x + k in p:
        print(x + k)
        exit(1)
    else:
        k += 1
        continue
print(x)

Submission status: Runtime Error

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

print(ans)

Submission status: Runtime Error

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

if Y == 0:
  print(X)
  
else:
  num_list = list(map(int,input().split()))
  max_num = max(num_list)
  min_num = min(num_list)
  min_serch=100

  for i in range(min_num,max_num+1):
    serch_num = abs(X-i)
    if (i not in num_list) and serch_num < min_serch:
      min_serch = serch_num
      
      correct_num = i
      
  print(correct_num)

Submission status: Runtime Error

Solution code:
#H, W = map(int,input().split())
#N = int(input())
#al = list(map(int,input().split()))
X, N = map(int,input().split())
pl = list(map(int,input().split()))

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

anslst = []
for n in lst:
    if not n in pl:
        anslst.append(n)


ans = 101
idx = 0
for i in range(len(anslst)):
    tmp = abs(X-anslst[i])
    if tmp < ans:
        ans = tmp
        idx = i


print(anslst[idx])

Submission status: Runtime Error

Solution code:
import sys

x, n = map(int, input().split())
p = list(map(int, input().split()))
flag = [False]*100
for i in p:
    flag[i-1] = True
for j in range(0, n+1):
    l = max(0, x-1-j)
    r = min(100, x-1+j)
    if not flag[l]:
        print(l+1)
        sys.exit()
    if not flag[r]:
        print(r+1)
        sys.exit()

Submission status: Runtime Error

Solution code:
def resolve():
    X, N = map(int, input().split())
    P = [int(input()) for _ in range(N)]
    if X in P:
        for j in range(N):
            if X+j in P:
                continue
            else:
                print(X+j)
                exit()
            if X-j in P:
                continue
            else:
                print(X-j)
                exit()
    else:
        print(X)
resolve()

Submission status: Runtime Error

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

x,n = i2()
p = intl()

m = 100
ls = [int(i) for i in range(1,101)]
for i in range(n):
	ls.remove(p[i])
for j in range(len(ls)):
	if abs(x - ls[j]) < m :
		m = abs(x - ls[j])
		ans = ls[j]
		
print(ans)

Submission status: Runtime Error

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

A.sort()
ans=0

if A[0]!=A[1]:
    ans=1

for i in range(1,N):
    if A[i]==A[i-1]:            
        continue
    for j in range(i):
        if A[i]%A[j]==0:
            break
        if j==i-1:
            ans+=1

print(ans)

Submission status: Runtime Error

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

p.sort()
diff = list(set(t) ^ set(p))

for i in range(len(diff)):
  diff[i] -= x

ans = diff[0]
for i in range(1,len(diff)):
  if abs(ans) > abs(diff[i]):
    ans = diff[i]
    
ans += x
print(ans)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
P=list(map(int,input().split()))
Q=P.copy()
for i in range(n):
    P[i]=abs(P[i]-x)
P.sort()

for i in range(n):
    if (i+1)//2 == P[i]:
        continue
    else:
        count=(i+1)//2
        break

if n==0:
    print(x)
elif x-count in Q:
    print(x+count)
else:
    print(x-count)

Submission status: Runtime Error

Solution code:
lst = []
str = input()
l = str.split(' ')
n = int(lst[0])
n0 = int(lst[1])
  
  
for i in range(0,no):
  inp = int(input())
  lst.append(inp)
  
for i in range(1,100):
  if n-i not in lst:
    print(n-i)
    break
  if n+i not in lst:
    print(n+i)
    break

Submission status: Runtime Error

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

if x not in a:
    print(x)
else:
    a.sort()
    idx=a.index(x)
    i=max(idx-1,0)
    j=min(idx+1,n-1)
    d=1
    ans=0
    while(True):
        if(a[i]!=x-d):
            ans=x-d
            break
        else:
            i-=1
        if(a[j]!=x+d):
            ans=x+d
            break
        else:
            j+=1
        d+=1
    print(ans)

Submission status: Runtime Error

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

x = a[0]
n = a[1]
d = list(map(int,input().split()))

if (n == 0):
    print(x)
else:
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]

    if (x < min_int or max_int < x):
        print(x)
    else:

        p = []
        for var in range(min_int,max_int):
            if var not in d:
                p.append(var)
            else:
                continue




        ans = []

        for pp in p:
            ans.append(np.abs(pp - x))
        ans = np.array(ans)
        print(p[np.argmin(ans)])

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=[]
    for xx in range(101):
        if xx in PP:continue
        P.append(xx)
    P_left=P[bisect_left(P,x)-1]
    P_right=P[bisect_left(P,x)]
    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:
X ,N = map(int,input().split())
P = list(map(int,input().split()))
A = list(range(min(P),max(P)))
P.sort()
ans = 0
min = 100
if N == 0:
    print(X)
    exit(0)


for a in A:
    if a not in P:
        if abs(a-X) < min:
            min = abs(a-X)
            ans = a
print(ans)

Submission status: Runtime Error

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

exist = [False] * 101
p = list(map(int, input().split()))

for i in range(N):
    exist[p[i]] = True

for i in range(200):
    if X - i <= 0:
        print(X-i)
        exit()

    if not exist[X-i]:
        print(X-i)
        exit()

    if not exist[X+i]:
        print(X+i)
        exit()

    if X + i > 100:
        print(X+i)
        exit()

Submission status: Runtime Error

Solution code:
X,N = map(int, input().split())
if N ==0:
  print(X)
  exit() 
if N ==0:
  print(X)
  exit() 
if p.count(X) == 0:
  print(X)
  exit()
for a in range(1000):
  if p.count(X-a) ==0:
    print(X-a)
    exit()
  elif p.count(X+a) ==0:
    print(X+a)
    exit()

Submission status: Runtime Error

Solution code:
/* *>>>>>Anshit_Bhardwaj<<<<<* */
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n, a;
    cin >> x >> n;
    vector<bool> arr(102, false);
    f(i, 0, n){
        cin >> a;
        arr[a] = true;
    }
    int ans;
    for(int i = x; i < arr.size(); i++){
        if(arr[i] == false){
            ans = i;
            break;
        }
    }
    for(int i = x; i >= 0; i--){
        if(arr[i] == false){
            if(abs(i - x) <= abs(ans - x)){
                ans = i;
            }
            break;
        }
    }
    if(abs(ans - x) > abs(x)){
        ans = 0;
    }
    cout << ans << endl;
}

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 = [i for i in range(0, 101)]

    for r in p:
        idx = q.index(r)
        del q[idx]

    if X in q:
        print(X)

    else:
        q.sort()
        mindif = 100

        for num in q:
            dif = abs(X - num)
            if mindif <= dif:
                break
            else:
                mindif = dif
                ans = num
        print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split());
if n == 0:
    print(x);
if n == 1:
    b = int(input());
    if b == x:
        print(x-1);
    else:
        print(x);
else:
    a = list(map(int,input().split()));
    
    for i in range(n):
        if a.count(x-i) == 0:
            ooo = 1;
            break;
        if a.count(x+i) == 0:
            ooo = 2;
            break;
        
            
    if ooo == 1:
        print(x-i);
    else:
        print(x+i);

Submission status: Runtime Error

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

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

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

sa_min = 1000000
for i in range(1, 101):
    if i not in p_list:
        if sa_min > abs(i - x):
            sa_min = abs(i - x)
            ans = i
print(ans)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 1
    a = x-1
    b = x+1
    while ans == 0:
      if X-i != P[a]:
        ans = X-i
      elif X+i != P[b]:
        ans = X+i
        a -= 1
      else:
        a -= 1
        b += 1
        i += 1
  else:
    ans = X
print(ans)

Submission status: Runtime Error

Solution code:
z = list(map(int, input().split()))
x = z[0]
p = list(map(int, input().split()))
count = 0
l = []
for i in range(1, 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())
a=list(map(int,input().split()))

dtmp = 100
for i in range(n):
  d=abs(x-a[i])
  if d<dtmp:
    dtmp=d
    ans=x
  elif d==dtmp:
    ans=x
print(ans)

Submission status: Runtime Error

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

    if n > 0:
        p = list(map(int, input().split()))
        q = [i for i in range(1, max(p)+1)]
        for item in p:
            if item in q:
                q.remove(item)

        ans = []
        current_min = float('inf')
        for item in q:
            diff = abs(x-item)
            if diff < current_min:
                current_min = diff
                ans = []
                ans.append(item)
            elif diff == current_min:
                ans.append(item)

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


if 'unittest' not in globals():
    resolve()

Submission status: Runtime Error

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

def getNearestValue(list, num):
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
if x not in p:
    print(x)
else:
    t = [i for i in range(1,101)]
    for i in range(n):    
        t.remove(p[i])
#     print(t)
    print(getNearestValue(t, x))

Submission status: Runtime Error

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

listP.sort()

minD = 200
val = 0
bef = None
for p in listP:
    if bef == None:
        bef = p
    else:
        if p-1 == bef:
            pass
        else:
            if bef < x < p:
                minD = 0
                val = x
            elif x <= bef:
                if abs(bef+1-x) < minD:
                    minD = abs(bef+1-x)
                    val = bef+1
            else:
                if abs(p-1-x) < minD:
                    minD = abs(p-1-x)
                    val = p-1
        bef = p
if abs(bef+1-x) < minD:
    val = bef+1
elif not x in listP:
    val = x
elif val == 0:
    if abs(0-x) > abs(101-x):
        val = 101
    else:
        val = 0

print(val)

Submission status: Runtime Error

Solution code:
import numpy as np
x,n = map(int, input().split())
if n != 0:
    p = list(map(int, input().split()))
if n == 0:
    print(x)
    exit()
ll = np.ones(1)
for i in range(99):
    ll = np.append(ll,int(i+1))
    
for j in p:
    ll= ll[~(ll == j)]

# print(ll)

a = np.zeros(len(ll))
for i in range(len(ll)):
    a[i]=abs(x-ll[i])
# print(ll)
print(int(ll[np.argmin(a)]))

Submission status: Runtime Error

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

tmp = 1000
result = []
result2 = []
for i in range(1, 101):
    if i in A:
        continue

    hoge = abs(X - i)
    if hoge <= tmp:
        tmp = hoge
        result2.append(tmp)
        result.append(i)

result3 = []
for i, v in enumerate(result2):
    if v == min(result2):
        result3.append(result[i])

print(min(result3))

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
li = list(map(int, input().split()))
li.sort()
if len(li) == 0:
    print(x)
    exit()
x1 = x - 1
x2 = x + 1
li1 = []
li2 = []
while x1 >= x - 10:
    if x1 not in li:
        li1.append(x1)
    x1 -= 1
li1.sort(reverse=True)
while x2 <= x + 10:
    if x2 not in li:
        li2.append(x2)
    x2 += 1
li2.sort()
if x - li1[0] > li2[0] - x:
    print(li2[0])
else:
    print(li1[0])

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline

def main():
  x, n = map(int, input().rstrip().split())
  if n == 0:
    print(x)
    sys.exit()
  else:
    p = list(map(int, input().rstrip().split()))
	if x > max(p):
      print(x)
      sys.exit()
    else:
      p_x = set(range(max(p)+1))
      p_temp = set(p)
      p_diff = p_x - p_temp
      p_temp = list(p_diff)
      p_dir = []

      for i in range(len(p_temp)):
        p_dir.append(abs(p_temp[i] - x))
      print(p_temp[p_dir.index(min(p_dir))])
  
if __name__ == "__main__":
  main()

Submission status: Runtime Error

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


l = [0]*N

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

for i in range(N):
  if i == 0:
    if l[0] == 1:
      continue
    else:
      print(X)
  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())
l = [int(x) for x in input().split()]
mp = [False]*101
for i in range(n):
    mp[l[i]] = True



queue = [x]
while(queue):
    now = queue.pop(0)
    if(mp[now]==False):
        print(now)
        exit()
    queue.append(now-1)
    queue.append(now+1)

Submission status: Runtime Error

Solution code:
import numpy as np

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

        l = []
        for i in range(1,101):
            if i not in p:
                l.append(i)
        
        l2 = []
        for j in range(1,101):
            nump = x+j
            numm = x-j
            if nump in l:
                l2.append(nump)
            if numm in l:
                l2.append(numm)
            if len(l2)>0:
                break
        print(np.min(l2))

        
    
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
lis=[i+1 for i in range(100)]
flag=True
if n==0:
  flag=False
  print(x)
if x==100:
  p=list(map(int,input().split()))
  print(100)
  flag=False

if flag:
  p=list(map(int,input().split()))
  for i in p:
    lis.remove(i)
  for i in range(len(lis)):
    if lis[i]>x:
      id=i
      break
  if id>=1:
    if abs(x-lis[id])<abs(x-lis[id-1]):
      print(lis[id])
    else:
      print(lis[id-1])
  else:
    print(lis[0])

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 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:
#C - Forbidden List
X,N= map(int,input().split())
p= list(map(int,input().split()))
A= list(range(1,X+1))
for i in range(N):
    A.remove(p[i])

D = 101
ans = 0
for j in range(len(A)):
    if D >= abs(X - A[j]):
        D = abs(X - A[j])
        ans = A[j]
    else:
        pass
print(ans)

Submission status: Runtime Error

Solution code:

def main():
    x,y = list(map(int, input().split()))

    if y == 0:
        print(x)
        exit()
    nums = list(map(int, input().split()))
    ans = []
    # 右へ進む
    for i in range(x, 101):
        if i not in nums:
           ans.append(i)
           break
    for i in range(x, 0, -1):
        if i not in nums:
           ans.append(i)
           break
    if abs(ans[0] - x) == abs(ans[1] - x):
        print(min(ans))
    elif abs(ans[0] - x) > abs(ans[1] - x):
        print(ans[1])
    elif abs(ans[0] - x) < abs(ans[1] - x):
        print(ans[0])

if __name__ == '__main__':
    main()