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())
p = list(map(int,input().split()))

y = []
z = []
for i in range(n):
    if x - p[i] >= 0:
        y.append(x - p[i])
    else:
        z.append(p[i] - x)



y = sorted(y)
z = sorted(z)

if y[0] == z[0]:
    print(y[0])
elif y[0] > z[0]:
    print(z[0])
else:
    print(y[0])

Submission status: Runtime Error

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

y = []
z = []
for i in range(n):
    if x - n[i] >= 0:
        y.append(x - n[i])
    else:
        z.append(n[i] - x)



y = sorted(y)
z = sorted(z)

if y[0] == z[0]:
    print(y[0])
elif y[0] > z[0]:
    print(z[0])
else:
    print(y[0])

Submission status: Runtime Error

Solution code:
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

X,N = MI()

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

P = LI()

_min = 10**9
ans = []
for p in range(1,101):
    if p in P:
        continue

    if abs(X-p) == _min:
        ans.append(p)
    elif abs(X-p) < _min:
        _min = abs(X-p)
        ans = []
        ans.append(p)

print(min(ans))

Submission status: Runtime Error

Solution code:
x,n = map(int, input().split())
a = list(map(int, input().split()))
candicate = []
for i in range(101):
  exist = False
  for d in a:
    if i == d:
      exist = True
      break
  if exist == False:
    candicate.append(i)

for j in range(len(candicate) + 1):
  if candicate[j] == x:
    print(x)
    break
  elif candicate[j] < x and x < candicate[j+1]:
    if abs(candicate[j] - x) <= abs(candicate[j+1] - x):
      print(candicate[j])
    else:
      print(candicate[j+1])

Submission status: Runtime Error

Solution code:
x,n = map(int, input().split())
a = list(map(int, input().split()))
candicate = []
for i in range(101):
  exist = False
  for d in a:
    if i == d:
      exist = True
      break
  if exist == False:
    candicate.append(i)

for j in range(len(candicate)):
  if candicate[j] == x:
    print(x)
    break
  elif candicate[j] < x and x < candicate[j+1]:
    if abs(candicate[j] - x) <= abs(candicate[j+1] - x):
      print(candicate[j])
    else:
      print(candicate[j+1])

Submission status: Runtime Error

Solution code:
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
  if x not in p:
    print(x)
    exit()
  ans+=[-1,1]

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
mp = set(range(1,101))
p = set(list(map(int,input().split())))
lp = list(mp-p)
sub_lp = [abs(i-x) for i in lp]
print(lp[sub_lp.index(min(sub_lp))])

Submission status: Runtime Error

Solution code:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p_max = max(p)
p = set(p)
#リストに含まれるものは飛ばす
for i in range(1, 101):
    if X - i not in p:
        print(X -1)
        break
    if X + i not in p:
        print(X + i)
        break

Submission status: Runtime Error

Solution code:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p_max = max(p)
diff = [0]
#リストに含まれるものは飛ばす
for i in range(1, 101):
    if X - i not in p:
        print(X -1)
        break
    if X + i not in p:
        print(X + i)
        break

Submission status: Runtime Error

Solution code:
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p_max = max(p)
diff = [0]
#リストに含まれるものは飛ばす
for i in range(1, 101):
    if X - i not in P:
        print(X -1)
        break
    if X + i not in P:
        print(X + i)
        break

Submission status: Runtime Error

Solution code:
import numpy as np


def getNearestValue(list, num):

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]


if __name__ == "__main__":

    X, N = list(map(int, input().split()))
    p = list(map(int, input().split()))
    print(np.sort(p))
    print(getNearestValue(p, X-1))
    for i in range(np.sort(p)):

Submission status: Runtime Error

Solution code:
from sys import stdin
x, n = [int(x) for x in stdin.readline().rstrip().split()]

hundred = [int(s) for s in range(1,101)]
ps = [int(s) for s in stdin.readline().rstrip().split()]
ps.sort()

def answer():
    for i in range(len(ps)):
        hundred[ps[i] - 1] = 0
    for i in range(len(hundred)):
        if hundred[i] - x < 0:
            hundred[i] = (hundred[i] - x) * (-1)
        else:
            hundred[i] -= x
    print(1 + hundred.index(min(hundred[:(x-1)])))


#answer()

if n == 0:
    print(x)
else:
    answer()

Submission status: Runtime Error

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

    mask = [0] * 101 
    for pe in p:
        mask[pe] = 1

    b, e = x, x
    while True:
        if mask[b] == 0 or mask[e] == 0:
            break
        b -= 1
        e += 1

    if mask[b] == 0:
        print(b)
    else:
        print(e)



main()

Submission status: Runtime Error

Solution code:
k,n=map(int,input().split())
if(n==0):
    print(k)
else:
  l=sorted(list(map(int,input().split())))
  a=[]
  a.append(k)
  for i in range(1,n-1):
    a.append(k-i)
    a.append(k+i)
  if(n%2==0):
    a.pop(-1)
  for i in range(n):
    if(l[i] in a):
        continue
    else:
         if(i!=n-1):
             print(min(a[i],a[i+1]))
             break
         else:
             print(a[i])
             break

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
p=set(list(map(int,input().split()))
ans=0
flag=0
while flag==0:
    if not x-ans in p:
        print(x-ans)
        flag=1
    elif not x+ans in p:
        print(x+ans)
        flag=1
    ans+=1

Submission status: Runtime Error

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
x,n=input2()
p=sorted(input_array())
q=[0]*102
result=[10000,-1]
for i in range(n):
	q[p[i]]=1
for i in range(102):
	if q[i]==0:
		num=abs(i-x)
		if num<result[0]:
			result=[num,i]
print(result[1])

Submission status: Runtime Error

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

  if x not in num:
    print(x)
  else:
    y = num.index(x)
    if y == (n-1):
      if num[y-1] == x-1:
        print(x+1)
      else:
        print(x-1)
    elif y == 0:
      print(x-1)
    else:
      for i in range(x):
        y = x-i
        if y not in num:
          under = y
          count_under = i
          break
      for j in range(x):
        y = x + j
        if y not in num:
          upper = y
          count_upper = j
          break
      
      if count_under <= count_upper:
        print(under)
      else:
        print(upper)

Submission status: Runtime Error

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

q = [i for i in Z if i not in p]
t = []

for i in range(0, len(q)):
    t.append(abs(int(X)-q[i]))

print(q[(t.index(min(t)))])

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
    for s in [-1, +1]:
        a = X + s * d
        if p.count(a) == 0:
           print(a)
            exit(0)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
l1=list(map(int,input().split())
for i in range(a+1):
     for j in [-1,1]:
        p=a+j*i
        if li.count(p)==0:
            print(p)
            exit(0)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
l1=list(map(int,input().split())
for i in range(a+1):
     for j in [-1,1]:
        p=a+j*i
        if li.count(p)==0:
            print(p)
            break
     break

Submission status: Runtime Error

Solution code:
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)    
else:
    L = list(range(max(0,X-N),min(101,X+N)))

    if X+N <= 100:
        L.append(X+N)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    #print(L)

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(L)]

    if X in L:
        print(X)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Submission status: Runtime Error

Solution code:
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)    
else:
    L = list(range(max(0,X-N),min(101,X+N)))

    if X+N <= 100:
        L.append(X+N)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    #print(L)

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(P)]

    if X in L:
        print(X)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Submission status: Runtime Error

Solution code:
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)
else:
    L = list(range(max(0,X-N),min(101,X+N)))
    if X+N == 100:
        L.append(100)

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    #print(L)

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(P)]

    if X in L:
        print(X)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Submission status: Runtime Error

Solution code:
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)
else:
    L = list(range(max(0,X-N),min(101,X+N)))

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(P)]

    if X in L:
        print(X)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Submission status: Runtime Error

Solution code:
import random

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

P = input().split()
P = [int(c) for c in P]

if len(P) == 0:
    print(X)
else:
    L = list(range(max(0,X-N),min(100,X+N)))

    for i in range(N):
        if P[i] in L:
            L.remove(P[i])

    while len(L) > 2:
        rand = random.randint(1,len(L)-2)
        if L[rand] == X:
            break
        elif L[rand] > X:
            L = L[0:rand+1]
        else:
            L = L[rand:len(P)]

    if L[rand] == X:
        print(0)
    else:
        if abs(L[0]-X) > abs(L[1]-X):
            print(L[1])
        else:
            print(L[0])

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))
a=1000000000000000000
for i in l:
    b=abs(x-i)
    if b<a:
        a=b
        c=i
    elif b==a:
        if i<c:
            c=i
    
print(c)

Submission status: Runtime Error

Solution code:
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(101)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if abs(X - NP[left]) <= abs(X - NP[right]):
    print(NP[left])
  else:
    print(NP[right])
    
main()

Submission status: Runtime Error

Solution code:
#input x,n and p as intergers. p acts as an array
x,n=int(input()).split()
p=int([]).split()
length=len(p)

#define the closest number
def closestnum(p,length):
    return p[min(range(length))]
#print when x is not it p
for x not in p:
    print(round(closestnum(p,length)))

Submission status: Runtime Error

Solution code:
#the program is to find the nearest number which is not included in N, and if more than 1 number, it will take the smallest one

#we will declare the x and n integer
x, n = map(int, input().split())

#declare the pi
p = list(map(int, input().split()))


for s in range(x + 1):
        for b in [-1, +1]:
                result = X + b * a
                    if p.count(result) == 0:
print(result)

Submission status: Runtime Error

Solution code:
#the program is to find the nearest number which is not included in N, and if more than 1 number, it will take the smallest one

#we will declare the x and n integer
x, n = map(int, input().split())

#declare the pi
p = list(map(int, input().split()))


for a in range(x + 1):
for b in [-1, +1]:
result = X + b * a
if p.count(result) == 0:
print(result)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
p=list(map(int, input().split()))
youso=[]
for i in range(1,101):
    if not i in p:
        youso+=[i]
hikaku=[]
for i in youso:
    hikaku+=[(i,abs(x-i))]
hikaku1=sorted(hikaku,key=lambda x:x[1])
if n == 0:res = x
else :res=hikaku1[0][0]
print(res)

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()))

import bisect
p.sort()
i = bisect.bisect_left(p,x)

for h in range(1, p[-1]-p[0]+2):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()

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()))

import bisect
p.sort()
i = bisect.bisect_left(p,x)
print(p)
for h in range(1, p[-1]-p[0]+2):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
if n ==0:
    print(x)
else:
    p = list(map(int,input().split()))
    l = {}
    for i in range(1,max(p)+1):
        if i not in p:
            l[i] = abs(x-i)

    min_value = min(l.values())
    val_list = list(l.values())
    key_list = list(l.keys())
    print(key_list[val_list.index(min_value)])

Submission status: Runtime Error

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

if n > 0:
    p_list = [int(i) for i in input().split()]
else:
    print(x)
    sys.exit(0)

table = {i for i in range(1, 101)}
table = list(table - set(p_list))
diff = 0
d_min = 101
pre_i = table[0]

for i in table:
    diff = abs(x - i)
    if d_min > diff:
        d_min = diff
    else:
        break
    pre_i = i

print(pre_i)

Submission status: Runtime Error

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

if n > 0:
    p_list = [int(i) for i in input().split()]
else:
    print(x)
    sys.exit(0)

table = {i for i in range(101)}
table = table - set(p_list)
diff = 0
d_min = 100

for i in table:
    diff = abs(x - i)
    if d_min > diff:
        d_min = diff
    else:
        break
    pre_i = i

print(pre_i)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
mem = []
mind = 100
for i in range(1, 100+1):
    if i not in p:
        t = abs(x-i)
        if t < mind:
            mem.append([i, t])
            mind = t
mem = sorted(mem, key=lambda x: (x[1], x[0]))
print(mem[0][0])

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
elif  2 <= N:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
    print(" ")
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

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

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

	for i in range(101):
  		for j in [-1, 1]:
    		a = X + i * j
    		if not a in p and 1 <= a <= 100:
      			print(a)
     			sys.exit()

Submission status: Runtime Error

Solution code:
import sys

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

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

	for i in range(101):
  		for j in [-1, 1]:
    		a = X + i * j
    		if a in p and 1 <= a <= 100:
      			print(a)
     			sys.exit()

Submission status: Runtime Error

Solution code:
import sys

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

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

	for i in range(101):
  		for j in [-1, 1]:
    		a = X + i * j
    		if a in p and 1 <= a <= 100:
      			print(a)
     			break

Submission status: Runtime Error

Solution code:
import sys

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

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

	for i in range(101):
  		for j in [-1, 1]:
    		a = X + i * j
    		if a in p and 1 <= a <= 100:
      		print(a)
      		sys.exit()

Submission status: Runtime Error

Solution code:
6 5
4 7 10 6 5x,n=map(int, input().split())
try:
    l=list(map(int ,input().split()))
    i=1
    while(True):
        if (x-i) not in l:
            print(x-i)
            break
        if(x+i) not in l:
            print(x+i)
            break
        i+=1

except:
    print(x)

Submission status: Runtime Error

Solution code:
if __name__=="__main__":
    X,N = list(map(int,input().split(" ")))
    p = list(map(int,input().split(" ")))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
x,n = map(int,input().split())
l = list(map(int,input().split()))
not_l,ans = [],[]
if not x in l:
	print(x)
	sys.exit()
l = sorted(l)
for i in range(1,50):
	if not i in l:
		not_l.append(i)
for j in range(len(not_l)):
	ans.append([not_l[j],abs(not_l[j]-x)])
ans.sort(key=lambda x:x[1])
print(ans[0][0])

Submission status: Runtime Error

Solution code:
import sys
x,n = map(int,input().split())
l = list(map(int,input().split()))
not_l,ans = [],[]
if not x in l:
	print(x)
	sys.exit()
l = sorted(l)
for i in range(1,101):
	if not i in l:
		not_l.append(i)
for j in range(len(not_l)):
	ans.append([not_l[j],abs(not_l[j]-x)])
ans.sort(key=lambda x:x[1])
print(ans[0][0])

Submission status: Runtime Error

Solution code:
def main():
  X,N = list(map(int, input().split()))
  P = list(map(int, input().split()))
  # handle corner case:
  if N==0: return
  #allowed elements
  Q = set([i for i in range(1,100+1)])
  for p in P:
    Q.remove(p)
  Q = sorted(Q)
  # distance from X
  D = [abs(q-X) for q in Q]
  # find smallest minimizer
  minD = min(D)
  for d,q in zip(D,Q):
    if d==min(D):
      break
  print(q)
    
if __name__=='__main__':
  main()

Submission status: Runtime Error

Solution code:
def main():
  X,N = list(map(int, input().split()))
  if N==0: return
  #forbidden elements
  P = list(map(int, input().split()))
  #allowed elements
  Q = set([i for i in range(1,100+1)])
  for p in P:
    Q.remove(p)
  Q = sorted(Q)
  # distance from X
  D = [abs(q-X) for q in Q]
  # find smallest minimizer
  minD = min(D)
  for d,q in zip(D,Q):
    if d==min(D):
      break
  return q
    
main()

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
numberlist = sorted(list(map(int, input().split())) )
#print(numberlist)

list_100 = []
for i in range(1,101):
    list_100.append(i)

def xx(n):
    return abs(n-X)

numberlist = list(set(list_100) - set(numberlist)) #初期リストに含まれない数のリスト
number_x = sorted(map(xx, numberlist) ) #n-X絶対値順
#print(number_x)

ans1 = X + number_x[0]
ans2 = X - number_x[0]
if ans2 in numberlist:
    print(ans2)
else:
    print(ans1)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
    for s in [-1, +1]:
            a = X + s * d
if p.count(a) == 0:
print(a)
exit(0)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
for s in [-1, +1]:
a = X + s * d
if p.count(a) == 0:
print(a)
exit(0)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
for s in [-1, +1]:
a = X + s * d
if p.count(a) == 0:
print(a)
exit(0)

Submission status: Runtime Error

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


list_100 = []
for i in range(1,101):
    list_100.append(i)

def xx(n):
    return abs(n-X)

numberlist = list(set(list_100) - set(numberlist)) #初期リストに含まれない数のリスト
number_x = sorted(map(xx, numberlist) ) #n-X絶対値順
ans1 = X + number_x[0]
ans2 = X - number_x[0]
if ans2 in numberlist:
    print(ans2)
else:
    print(ans1)

Submission status: Runtime Error

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

list_100 = []
for i in range(1,101):
    list_100.append(i)

def xx(n):
    return abs(n-X)

numberlist = list(set(list_100) - set(numberlist)) #初期リストに含まれない数のリスト
number_x = sorted(map(xx, numberlist) ) #n-X絶対値順
ans1 = X + number_x[0]
ans2 = X - number_x[0]
if ans2 in numberlist:
    print(ans2)
else:
    print(ans1)

Submission status: Runtime Error

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

list_100 = []
for i in range(1,101):
    list_100.append(i)

def xx(n):
    return abs(n-X)

numberlist = list_100 - numberlist #初期リストに含まれない数のリスト
number_x = sorted(map(xx, numberlist) ) #n-X絶対値順
ans1 = X + number_x[0]
ans2 = X - number_x[0]
if ans2 in numberlist:
    print(ans2)
else:
    print(ans1)

Submission status: Runtime Error

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

if N==0:
  print(X)
else:
  P = list(map(int,input().split()))
  hash_p = [0]*101
  for i in P:
    hash_p[i] += 1
  for i in range(N):
    if hash_p[X-i]==0:
      print(X-i)
      break
    if hash_p[X+i]==0:
      print(X+i)
      break

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
x = a[0]
p = list(map(int, input().split()))
for i in range(0,max(p)):
  if x-i not in p:
    print(x-i)
    break
  if x+i not in p:
    print(x+i)
    break

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    l=[0 for i in range(100)]
    P=list(map(int,input().split()))
    for p in P:
        l[p-1]=1
 
    upper=0
    down=0
    for i in range(100):
        if l[x-1+i]==0:
            upper=x+i
            break
        
    for i in range(100):
        if l[x-1-i]==0:
            down=x-i
            break
            
    print(upper if abs(upper-x)<abs(down-x) else down)

Submission status: Runtime Error

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

l=[0 for i in range(100)]
  
if n==0:
    print(x)
else:
    P=list(map(int,input().split()))
    for p in P:
        l[p-1]=1
 
    upper=0
    down=0
    for i in range(100):
        if l[x-1+i]==0:
            upper=x+i
            break
        
    for i in range(100):
        if l[x-1-i]==0:
            down=x-i
            break
            
    print(upper if abs(upper-x)<abs(down-x) else down)

Submission status: Runtime Error

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

l=[0 for i in range(100)]
  
if n==0:
    print(x)
else:
    P=list(map(int,input().split()))
    for p in P:
        l[p-1]=1
    #print(l)
    upper=0
    down=0
    for i in range(100):
        if l[x-1+i]==0:
            upper=x+i
            break
        
        
    for i in range(100):
        if l[x-1-i]==0:
            down=x-i
            break
            
        
    #print(upper,down)
    print(upper if abs(upper-x)<abs(down-x) else down)

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(X, 101):
    if i in p:
        continue
    else:
        break

for j in range(0,X+1)[::-1]:
    if j in p:
        continue
    else:
        break

if abs(X - j) <= abs(x - i):
    print(j)
else:
    print(i)

Submission status: Runtime Error

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

try:
  p = set(map(int, input().split()))
  num = set(range(1,101))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))

  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

Submission status: Runtime Error

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

try:
  p = set(map(int, input().split()))
  num = set(range(1,101))
  mem = []
  result = -1

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(X - item))

  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

Submission status: Runtime Error

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

p = np.array(list(map(int, input().split())))
for i in range(100):
    if not x-i in p:
        print(x-i)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()

Submission status: Runtime Error

Solution code:
x,n=input().split()
x=int(x)
n=int(n)
lst = [ ]
lst=input()
lst=lst.split()
for i in range(0,n):
    lst[i]=int(lst[i])
minv=min(lst)
maxv=max(lst)
dis=100000
for i in range(minv-2,maxv+3):
    if(i not in lst and abs(i-x)<dis):
        dis=abs(i-x)
        clv=i
        
print(clv)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
lst = [int(input()) for _ in range(n)]
a = 100
b = 0

for i in range(1, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
lst = [int(input()) for _ in range(n)]
a = 100
b = ''

for i in range(1, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)

Submission status: Runtime Error

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

    i_l= []
    j_l= []

    for i in reversed(range(0,x)):
        if i in p:
            continue
            i = i-1
        else:
            i_l.append(i)
    #print('i_l',i_l)
    for j in range(x,100):
        if j in p:
            continue
            j = j+1
        else:
            j_l.append(j)
    #print('j_l',j_l)
    if x-i_l[0] == j_l[0]-x:
        print(i_l[0])
    elif x-i_l[0] > j_l[0]-x:
        print(j_l[0])
    else:
        print(i_l[0])

Submission status: Runtime Error

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

    i_l= []
    j_l= []

    for i in reversed(range(0,x)):
        if i in p:
            continue
            i = i-1
        else:
            i_l.append(i)
    print('i_l',i_l)
    for j in range(x,100):
        if j in p:
            continue
            j = j+1
        else:
            j_l.append(j)
    print('j_l',j_l)
    if x-i_l[0] == j_l[0]-x:
        print(i_l[0])
    elif x-i_l[0] > j_l[0]-x:
        print(j_l[0])
    else:
        print(i_l[0])

Submission status: Runtime Error

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

    i_l= []
    j_l= []

    for i in reversed(range(0,x)):
        if i in p:
            continue
            i = i-1
        else:
            i_l.append(i)
       
    for j in range(x,100):
        if j in p:
            continue
            j = j+1
        else:
            j_l.append(j)

    if x-i_l[0] == j_l[0]-x:
        print(i_l[0])
    elif x-i_l[0] > x-j_l[0]:
        print(j_l[0])
    else:
        print(i_l[0])

Submission status: Runtime Error

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

    i_l= []
    j_l= []

    for i in reversed(range(0,x)):
        if i in p:
            continue
            i = i-1
        else:
            i_l.append(i)
       
    for j in range(x,100):
        if j in p:
            continue
            j = j+1
        else:
            j_l.append(j)

    if x-i_l[0] == x-j_l[0]:
        print(i_l[0])
    elif x-i_l[0] > x-j_l[0]:
        print(j_l[0])
    else:
        print(i_l[0])

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
lst = list(map(int,input().split()))
ans = lst[0]

for e in lst:
  if abs(e-n) < abs(e-ans):
    ans = e
   
  elif abs(e-n) == abs(e-ans):
    ans = min(e,ans)
    
  else:
    pass
  
print(ans)