TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
p_list = [str(e) for e in input().split()]

for i in range(N + 1):
    x = X - i
    y = X + i
    if str(x) in p_list == 0:
        print(x)
        break
    elif str(y) in p_list == 0:
        print(y)
        break

X, N = map(int, input().split())
p_list = [int(e) for e in input().split()]

t = 0
for i in range(N + 1):
    x = X - i
    y = X + i
    if x in p_list:
        t += 0
    else:
        print(x)
        break
    if y in p_list:
        t += 0
    else:
        print(y)
        break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
x,n =map(int,input().split())

if  n==0:
 print(x)
else:
 P =list(map(int,input().split()))
 l = list(range(2*x))
 result = list(set(l) - set(P))
 abs = list(np.abs(np.array(result)-x))
 abs.remove(0)
 min = min(abs)
 print(abs)
 print(result[abs.index(min)])

import numpy as np
x,n =map(int,input().split())

if  n==0:
 print(x)
else:
 P =list(map(int,input().split()))
 for i in range(100):
  if  (x-i) not in P:
   print(x-i)
   break
  elif (x+i) not in P:
   print(x+i)
   break

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x,n = map(int,input().split())
p = list(map(int,input().split()))
tmp = []
for i in range(-101,101):
    tmp.append(i)

if n == 0:
    print(x)
else:
    for i in p:
        tmp.remove(i)
    
    ans = []
    for i in tmp:
        a = abs(x-i)
        ans.append(a)

    b = min(ans)
    print(ans)
    c = x+b
    d = x-b

    if c and d in tmp:
        print(d)
    elif c in tmp:
        print(c)
    elif d in tmp:
        print(d)

x,n = map(int,input().split())
p = list(map(int,input().split()))
tmp = []
for i in range(-101,102):
    tmp.append(i)

if n == 0:
    print(x)
else:
    for i in p:
        tmp.remove(i)
    
    ans = []
    for i in tmp:
        a = abs(x-i)
        ans.append(a)
 
    b = min(ans)
    
    c = x+b
    d = x-b
 
    if c and d in tmp:
        print(d)
    elif c in tmp:
        print(c)
    elif d in tmp:
        print(d)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


x, n = multi_int_input()

arr = list_input()

arr = set(arr)

a = 1

while(True):
    l = x+a
    r = x - a

    if (l not in arr):
        print(l)
        break
    elif (r not in arr):
        print(r)
        break



from collections import defaultdict, deque
from itertools import permutations
from sys import stdin,stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq

int_input=lambda : int(stdin.readline())
string_input=lambda : stdin.readline().split()
multi_int_input =lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input=lambda : list(map(int,stdin.readline().split()))
string_list_input=lambda: list(string_input())
MOD = pow(10,9)+7


x, n = multi_int_input()

arr = list_input()

arr = set(arr)

a = 0

while(True):
    l = x - a
    r = x + a

    if (l not in arr):
        print(l)
        break
    elif (r not in arr):
        print(r)
        break

    a+=1

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n = map(int,input().split())
P = list(map(int,input().split()))

for i in range(101):
  xl = x - 1
  xr = x + 1
  if xl not in P:
    print(xl)
    break
  if xr not in P:
    print(xr)
    break
  

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

for i in range(101):
  xl = x - i
  xr = x + i
  if xl not in P:
    print(xl)
    break
  if xr not in P:
    print(xr)
    break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n = map(int, input().split())
l = list(map(lambda t : int(t)-x, input().split()))
p = [0] + sorted(map(abs,l))
for i in range(n//2):
  if ( n == 2 * i +1 ) or ( not ( p[2*i+1] == i )):
    if -i in l:
      print(x+i)
    else:
      print(x-i)
    break


import functools as ft
x,n = map(int, input().split())
l = map(lambda t : int(t)-x, input().split())
p = sorted(map(abs,l))
for i in range((n//2)+1):
    if not ( p[i] == p[i+1] ==i ):
        if -i in l:
            print(x+i)
        else:
            print(x-i)

import functools as ft
x,n = map(int, input().split())
l = map(lambda t : int(t)-x, input().split())
p = sorted(map(abs,l))
for i in range(n/2):
    if not ( p[i] == p[i+1] ==i ):
        if -i in l:
            print(x+i)
        else:
            print(x-i)

x,n = map(int, input().split())
l = map(lambda t : int(t)-x, input().split())
p = [0]
p.extend( sorted(map(abs,l)))
for i in range(n//2+1):
  if not ( p[2*i] == p[2*i+1] == i ):
    if i in l:
      print(x+i)
    else:
      print(x-i)
    break

x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  l = list(map(lambda t : int(t)-x, input().split()))
  p = [0] + sorted(map(abs,l))
  for i in range(n//2):
    if ( n == 2 * i +1 ) or ( not ( p[2*i+1] == i )):
      if -i in l:
        print(x+i)
      else:
        print(x-i)
      break

x,n = map(int, input().split())
l = map(lambda t : int(t)-x, input().split())
p = sorted(map(abs,l))
for i in range(n//2+1):
    if not ( p[i] == p[i+1] ==i ):
        if -i in l:
            print(x+i)
        else:
            print(x-i)

x,n,*p=map(int,open(0).read().split())
print(min({*range(999)}-{*p},key=lambda y:abs(y-x)))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
else:
  P=list(map(int,input().split()))
L=[]
A=[]
A_1=[]
for i in range(-100,200):
  L.append(i)
for i in P:
  L[i+100]=200
for i in L:
  A.append(abs(X-i))
A_1=sorted(A)
a=A_1[0]
for i in L:
  if i==X-a:
    print(i)
    sys.exit()
  elif i==X+a:
    print(X+a)
    break
print(a)

import sys
X,N=map(int,input().split())
if N==0:
  print(X)
  sys.exit()
else:
  P=list(map(int,input().split()))
L=[]
A=[]
A_1=[]
for i in range(-100,200):
  L.append(i)
for i in P:
  L[i+100]=200
for i in L:
  A.append(abs(X-i))
A_1=sorted(A)
a=A_1[0]
for i in L:
  if i==X-a:
    print(i)
    sys.exit()
  elif i==X+a:
    print(X+a)
    break

Verdicts: Wrong Answer

Accepted
Problem: 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.

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



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

for i in range(101):
  if X-i not in P:
    print(X-i)
    exit()
  elif X+i not in P:
    print(X+i)
    exit()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import bisect

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())


def main():
  X,N = LI()[:]
  P = LI()
  P.sort()
  print(X,N)
  print(P)

  if N==0:
    print(X)
    exit()
    
  index = bisect.bisect_left(P, X)
  
  l = index
  r = index
  for i in range(0,100):
    up = X + i
    down = X - i
    
    if l < 0:
      print(down)
      break
    
    if r > N:
      print(up)
      break
     
    
    if P[l] != down:
      print(down)
      break
     
    if P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()


import sys
import bisect

def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())


def main():
  X,N = LI()[:]
  if N > 0:
    P = LI()
    P.sort()
  else:
    print(X)
    exit()
  
  #print(X,N)
  #print(P)
  
  index = bisect.bisect_left(P, X)
  #print("index=",index)
  if index >= N :
    print(X)
    exit()
    
  l = index
  r = index
  for i in range(0,200):
    up = X + i
    down = X - i
    
    #print("l=",l,"r=",r)
     
    
    if l < 0 or P[l] != down:
      print(down)
      break

    if r >= N or P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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 x1<len(P) and P[x1]!=A:
        print(A)
        break
        
    if x2<len(P) and P[x2]!=B:
        print(B)
        break

import sys
X,N=list(map(int,input().split()))
P=list(map(int,input().split()))
if not X in P:
    print(X)
    sys.exit()
A=X
B=X
while True:
    A-=1
    B+=1
    if not A in P:
        print(A)
        sys.exit()
    if not B in P:
        print(B)
        sys.exit()

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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

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

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

for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#input from user X and N
#input from user p
#print the number that is nearest to X but not included in p
#if N = 0, p doesn't have to be taken, only X will be printed
#time complexity O(n)

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


a = X + 1
b = X - 1
if a < b :
    if a not in p:
        print(a)

elif b < a:
    if b not in p:
        print(b)

            


# inpute integer (x) along with integer sequence (n)
# finding the integer nearest to x within the given range 100
# no time i have to submit
x, n = map(int, input().split())  # take input from the user
P = list(map(int, input().split()))

for i in range(101):  # loop through the range
    length = x - i
    result = x + i
    if length not in P:
        print(length)
        break
    elif result not in P:
        print(result)
        break



Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N = map(int,input().split())
l = list(map(int,input().split()))
n_l = sorted(l)

for i in range(N-2):
  if n_l[i]<= X < n_l[i+1]:
    print(n_l[i])
  else:
    print(n_l[N-1])
    break

X,N = map(int,input().split())
l = list(map(int,input().split()))
n_l = sorted(l)

for i in range(N-2):
  if n_l[i]<= X < n_l[i+1]:
    print(n_l[i])
  else:
    print(n_l[N-1])
    break

X,N = map(int,input().split())
l = list(map(int,input().split()))
n_l = sorted(l)

for i in range(100):
  if not X-i in n_l:
      print(X-i)
      break
  elif not X+i in n_l:
      print(X+i)
      break
  pass

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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(i)


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)

kazulist = []
for i in range(-100,200):
    kazulist.append(i)
 
a = list(input().split(" "))
target = int(a[0])
syokyo = int(a[1])

if syokyo != 0:
    b = list(input().split(" "))
    for i in b:
        kazulist.remove(int(i))
 
saisyosa = 100
kotae = 0
for i in kazulist:
    sa = target - int(i)
    #print(sa)
    if sa < 0:
        sa *= -1
    if sa < saisyosa:
        saisyosa = sa
        kotae = i
 
print(kotae)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
N,M=list(map(int,input().split()))
L=list(map(int,input().split()))
if N not in L:
  print(N)
  exit()
c=N
d=N
while True:
  if c not in L:
    break
  else:
    c-=1
while True:
  if d not in L:
    break
  else:
    d+=1
if abs(d-M)>=abs(c-M):
  print(c)
else:
  print(d)
    
  
    
    

N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
  
for i in range(100):
  if N-i not in A:
    print(N-i)
    exit()
  elif N+i in A and N+i!=N-i:
    print(N+i)
    exit()

N,M=list(map(int,input().split()))
L=list(map(int,input().split()))
if N not in L:
  print(N)
  exit()
c=N
d=N
while True:
  if c not in L:
    break
  else:
    c-=1
while True:
  if d not in L:
    break
  else:
    d+=1
if abs(d-N)>=abs(c-N):
  print(c)
else:
  print(d)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
#print(x,n)
#print(p)
#print(max(p))
y = 100
ans = n
if n == 0:
  print(x)
else:
  for i in range(100):
    if p.count(i) == 0:
      print('i=',i,abs(x-i))
      if abs(x-i) < y:
        ans = i
        y = abs(x-i)
  print(ans)

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

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

s = 1000000000

for i in range(-100,102):
    if i in p:
        continue
    s = min(abs(x-i),s)
    

#if not x-s in p:
#    print(x - s)
#else:
#    print(x + s)


x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
#print(x,n)
#print(p)
#print(max(p))
y = 100
ans = n
if n == 0:
  print(x)
else:
  for i in range(0,101):
    if i != x:
      if p.count(i) == 0:
        print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
  print(ans)

x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
y = 101

if n == 0:
  print(x)
else:
  for i in range(0,101):
    
      if p.count(i) == 0:
        print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
          print('i=',i,'abs=',abs(x-i),'ans=',ans)
  print(ans)

x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
#print(x,n)
#print(p)
#print(max(p))
y = 100
ans = n
if n == 0:
  print(x)
else:
  for i in range(max(p)+1):
    if p.count(i) == 0:
      for j in range(i,100):
        #print('i=',i,abs(x-j))
        if abs(x-j) < y:
          ans = j
          y = abs(x-j)
  print(ans)

x,n = list(map(int,input().split()))
if n >0 :
  p = list(map(int,input().split()))
y = 101

if n == 0:
  print(x)
else:
  for i in range(0,102):
    
      if p.count(i) == 0:
        #print('i=',i,abs(x-i))
        if abs(x-i) < y:
          ans = i
          y = abs(x-i)
          #print('i=',i,'abs=',abs(x-i),'ans=',ans)
  print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = list(map(int, input().split()))

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

arr.sort()
print(arr)
i = arr.index(x)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if row >= 0 and arr[row] != x - j:
    print(x - j)
    exit(0)
  elif high <= n-1 and arr[high] != x + j:
    print(x + j)
    exit(0)
  j += 1

print(x-1)



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

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

arr.sort()
if x in arr:
  i = arr.index(x)
else:
  print(x)
  exit(0)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if x - j not in arr:
    print(x - j)
    exit(0)
  elif x + j not in arr:
    print(x + j)
    exit(0)
  j += 1

print(x-1)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def main():
  X,N = list(map(int, input().split()))
  if N==0: return
  
  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]
  
  minD = min(D)
  for d,q in zip(D,Q):
    if d==min(D):
      break
  return q
    
main()

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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            print(int(d))
            break
        elif int(d) == x+i:
            print(int(d))
            break
    else:
        continue
    break

xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if d == x-i:
            print(d)
            break
        elif d == x+i:
            print(d)
            break

xn=input().split()
x=int(xn[0])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            break
    else:
        print(x-i)
        break
    
    for d in data:
        if int(d) != x+i:
            break
    else:
        print(x+i)
        break
    

xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            print(d)
            break
        elif int(d) == x+i:
            print(d)
            break
    break

xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if d == x-i:
            print(d)
            break
        elif d == x+i:
            print(d)
            break
    break

xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) != x-i:
            print(int(d))
            break
        elif int(d) != x+i:
            print(int(d))
            break
    else:
        continue
    break

xn=input().split()
x=int(xn[0])
n=int(xn[1])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            print(int(d))
            break
        elif int(d) == x+i:
            print(int(d))
            break
    else:
        continue
    break

xn=input().split()
x=int(xn[0])

data=input().split()
for i in range(100):
    for d in data:
        if int(d) == x-i:
            break
    else:
        print(x-i)
        break
    
    for d in data:
        if int(d) == x+i:
            break
    else:
        print(x+i)
        break
    

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N=map(int,input().split())
List=[int(i) for i in input().split()]
A=X
B=X
if X in List == True:    
    p=True
    q=True
    while p==True:
        A=A-1
        p= A in List
    while q==True:
        B=B+1
        q= B in List
    if X-A <= B-X:
        print (A)
    else:
        print (B)
else:
    print(X)

X,N=map(int,input().split())
List=[int(i) for i in input().split()]
A=X
B=X
C=X in List
if C == True:    
    p=True
    q=True
    while p==True:
        A=A-1
        p= A in List
    while q==True:
        B=B+1
        q= B in List
    if X-A <= B-X:
        print (A)
    else:
        print (B)
else:
    print(X)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N=map(int,input().split())
if N>0:
  p=list(map(int,input().split()))
  d=abs(X-p[0])
if N>0:
  for i in range(N):
    d=min(abs(X-p[i]),d)
  print(p[i])
else:
  print(X)

X,N=map(int,input().split())
l=[]
for i in range(100):
  l.append(i+1)
if N>0:
  p=list(map(int,input().split()))
  l1=[x for x in l if x not in p]
  d=abs(X-l1[0])
if N>0:
  for i in range(N):
    d=min(abs(X-l1[i]),d)
  print(l1[i])
else:
  print(X)

x, n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [i for i in range(0,102) if i not in a] 
b_tmp = list(map(lambda s:abs(s-x), b)) 
address = b_tmp.index(min(b_tmp))
print(b[address])

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, y = map(int, input().split())

if (x == 1 and y == 2) or (x == 1 and y == 4):
    print('Yes')
    quit()

for i in range(-101,201):
    if i * 2 + (x - i) * 4 == y:
        print('Yes')
        quit()
print('No')

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

if y == 0:
    print(x)
    quit()

ans=[]
for i in range(-101,201):
    if not i in li:
        ans.append(abs(i - x))

if not x - min(ans) in li:
    print(x-min(ans))
elif not min(ans) + x in li:
    print(min(ans) + x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, input().split()))
print (p)

for i in range(100):
    if not((x - i) in p):
        print (x - i)
        exit ()
    if not((x + i) in p):
        print (x + i)
        exit()


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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N = map(int,input().split())
p = list(map(int, input().split()))

i = 0

if X not in p:
  print(X)

else:
  while True:
    i += 1
    if X - i not in p:
      print(X-i)
    if X+i not in p:
      print(X+i)

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

i = 0

if X not in p:
  print(X)

else:
  while True:
    i += 1
    if X - i not in p:
      print(X-i)
      break
    if X+i not in p:
      print(X+i)
      break


Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

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

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, inpot().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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))

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

a = [i for i in range(-110,210)]

for j in p:
    d = a.index(j)
    a.pop(d)

a.append(x)
a = set(a.sort())

idx_x = a.index(x)

if (idx_x == 0):
    print(a[idx_x+1])
    sys.exit()
if (idx_x == len(a)-1):
    print(a[-2])
    sys.exit()

lesser = a[idx_x-1]
greater = a[idx_x+1]

dl = abs(x - lesser)
dg = abs(greater - x)

if (dl <= dg):
    print(lesser)
else:
    print(greater)


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

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

i = 0
while True:
    if (not (x-i) in p):
        print(x-i)
        break
    if (not (x+i) in p):
        print(x+i)
        break
    i += 1


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
a,b= map(int,input().split())
N = list(map(int,input().split()))
S =[]
key = 9999
for i in range(b):
	c = [N[i]-a]
	S.extend(c)
for i in range(b):
	if key > abs(S[i]):
		key= abs(S[i])
if key ==0:
	print(a)
else:
	if a - key in S:
		print(a-key)
	else:
		print(a+key)

a,b= map(int,input().split())
N = list(map(int,input().split()))
S =[]
key = 0
while(1):
	if a-key in N:
		if a +key in N:
			key +=1
		else:
			print(a+key)
			break
		
	else:
		print(a-key)
		break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n = (int(x) for x in input().split())
p = [int(x) for x in input().split()]

result = 100

l = list(range(0,6))



if len(p) == 0:
    kotae = x
else:
    for i in range(len(p)):

        l[p[i]] = 200


    for i in reversed(range(len(l))):
     
  

        if l[i] != 200:

            if result >= abs(l[i] - x):
                result = abs(l[i] - x)
               
                kotae = l[i]
          
            



print(kotae)

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

result = 100

l = list(range(0,102))



if len(p) == 0:
    kotae = x
else:
    for i in range(len(p)):

        l[p[i]] = ""



    for i in reversed(range(len(l))):
     
        if l[i] != "":

            if result >= abs(l[i] - x):
                result = abs(l[i] - x)
               
                kotae = l[i]          
            
print(kotae)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if x in p:
  print(x)
else:
  for i in range(100):
    if x-i in p:
      print(x-i)
      break
    if x+i in p:
      print(x+i)
      break

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

if not(x in p):
  print(x)
else:
  for i in range(100):
    if not(x-i in p):
      print(x-i)
      break
    if not(x+i in p):
      print(x+i)
      break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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(ans)

X, N = map(int,input().split())
if N > 0:
  p = list(map(int, input().split()))
else:
  p=[]
#print(p)
p.sort()
#dis = p[0] - X
ans_1 = X
ans_2 = X
for i in range(N) :
  pi = p[i]
  if pi == ans_1:
    ans_1 += 1

p.reverse()
for i in range(N) :
  pi = p[i]
  if pi == ans_2:
    ans_2 -= 1

ans = X
if abs(ans_1 - X) < abs(ans_2 - X):
  ans = ans_1
elif ans_1 - X == -abs(ans_2 - X):
  ans = ans_1
else:
  ans = ans_2
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x,n = [int(x) for x in input().split()]
if n == 0:
  print(x)
else:
  p = [int(x) for x in input().split()]
  p.sort()
  ans = []
  for i in range(1,101):
    if i in p:
      continue
    b = abs(x - i)
    ans.append((i,b))
  ans = sorted(ans,key = lambda x: x[1])
  print(ans)
  print(ans[0][0])

x,n = [int(x) for x in input().split()]
if n == 0:
  print(x)
else:
  p = [int(x) for x in input().split()]
  p.sort()
  a = 1000
  for i in range(n):
    b = abs(x - p[i])
    if b < a:
      a = i
  print(a)

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)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]

dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(dec_num)
            break

from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = [int(x) for x in stdin.readline().strip().split(" ")]

minv = 10000
num = 0

if N == 0:
  print(X)
else:
  for i in range(len(num_list)):
    if minv > abs(X - num_list[i]):
      minv = abs(X - num_list[i])
      num = i
  print(num)

from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = [int(x) for x in stdin.readline().strip().split(" ")]

minv = 10000
num = 0

if N == 0:
  print(X)
else:
  for i in range(len(num_list)):
    if minv > abs(X - num_list[i]):
      minv = abs(X - num_list[i])
      num = i
  print(num_list[num])

from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = stdin.readline().strip().split(" ")

minv = 10000
num = 0

if N == 0:
  print(X)
else:
  for i in range(len(num_list)):
    if minv > abs(X - num_list[i]):
      minv = abs(X - num_list[i])
      num = i
  print(num)

    
    
    

from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]


dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(inc_num)
            break

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
X,N = map(int, input().split())
P = list(map(int, input().split()))

if P.len == 0:
  print(X)
else:
  for i in range(X,1):
    if P.index(X-i) == 0:
      print(X-i)
      break
    elif P.index(X+1) == 0:
      print(X+1)
      break
    else:
      continue

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

if P.len == 0:
  print(X)
else:
  for i in range(X,1):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue

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

if len(P) == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue


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

if P.len == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue

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

if len(P) == 0:
  print(X)
else:
  for i in range(0,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input(). split()))

if N == 1:
    if not (X - 1) in P:
        print(X - 1)
        exit()
    if not (X + 1) in P:
        print(X + 1)
        exit()

for n in range(1, (N // 2) + 1):
    print(X - n)
    print(X + n)
    if not (X - n) in P:
        print(X - n)
        exit()
    if not (X + n) in P:
        print(X + n)
        exit()
if min(P) - 1 < 0:
    print(max(P) + 1)
    exit()
print(min(P) - 1)

X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input(). split()))
if X not in P:
    print(X)
    exit()

for n in range(1, N + 1):    
    if not (X - n) in P:
        print(X - n)
        exit()
    if not (X + n) in P:
        print(X + n)
        exit()
print(min(P) - 1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, input().split()))

table = [0 for i in range(100)]
for i in p:
    table[i-1] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 99-i
    if (table[idx] == 0) and (dis >= abs(idx+1-x)):
        ans = idx+1
        dis = abs(idx+1-x)
if ans == mx:
    if 50 >= x
        print(0)
    else:
        print(101)
else:
    print(ans)


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

table = [0 for i in range(102)]
for i in p:
    table[i] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 101-i
    if (table[idx] == 0) and (dis >= abs(idx-x)):
        ans = idx
        dis = abs(idx-x)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, input().split()))
a = 1
ans = ''
p.sort()
print(p)
while ans == '':
  if len(p) == 0:
    ans = x
  elif x - a not in p:
    ans = x - a
  elif x + a not in p:
    ans = x + a
  else:
    a += 1
print(ans)

x, n = map(int, input().split())
p = list(map(int, input().split()))
a = 0
ans = ''
while ans == '':
  if len(p) == 0:
    ans = x
  elif x - a not in p:
    ans = x - a
  elif x + a not in p:
    ans = x + a
  else:
    a += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int,input().split())
answer = 0
if N != 0:
  mapped_list = map(int,input().split())
  list = list(mapped_list)
  print(list)
  for i in range (N):
    if (X-i in list) == False:
      answer = X-i
      break
    elif (X+i in list) == False:
      answer = X+i
      break
else:
  answer = X 
  
print(answer)

X, N = map(int,input().split())
answer = 0
if N != 0:
  mapped_list = map(int,input().split())
  list = list(mapped_list)
  for i in range (N):
    if (X-i in list) == False:
      answer = X-i
      break
    elif (X+i in list) == False:
      answer = X+i
      break
else:
  answer =X

print(answer)
  

Verdicts: Wrong Answer

Accepted