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:
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flaga=1
    if slist[j]==x+i:
        flagb=1
            
  if flaga=1 and flagb=1:
    flaga=0
    flagb=0
  elif flagb==0:
    print(x-i)
    exit()
  elif flaga==0:
    print(x+i)
    exit()

Submission status: Runtime Error

Solution code:
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
s=list(map(int,input().split()))
slist=sorted(s)

  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Submission status: Runtime Error

Solution code:
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Submission status: Runtime Error

Solution code:
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Submission status: Runtime Error

Solution code:
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n+1):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Submission status: Runtime Error

Solution code:
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(n/2+4):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(n/2+1):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()

Submission status: Runtime Error

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

dist=0
for i in range(0,100):
 if abs(x-i)>=0:
  for j in s:
    if s[j]==i:
    else:
      print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys

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

ordered = sorted(p)

if n == 0:
    print(x)
else:
    x_index = ordered.index(x)

    max = max(ordered)
    min = min(ordered)

    tar_nums = {i for i in range(min, max + 1)}
    not_contains_nums = tar_nums.difference(p)

    result = -9999999
    for i in not_contains_nums:
        if abs(x - i) < abs(x - result):
            result = i
    print(result)

Submission status: Runtime Error

Solution code:
import sys

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

ordered = sorted(p)

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

x_index = ordered.index(x)

max = max(ordered)
min = min(ordered)

tar_nums = {i for i in range(min, max + 1)}
not_contains_nums = tar_nums.difference(p)

result = -9999999
for i in not_contains_nums:
    if abs(x - i) < abs(x - result):
        result = i
print(result)

Submission status: Runtime Error

Solution code:
N = int(input())
A_n = sorted(list(map(int, input().split(' '))))
count = 0
for i in range(len(A_n)):
    # print(list(map(lambda x: x%A_n[i], A_n)))
    if list(map(lambda x: A_n[i]%x, A_n)).count(0) == 1:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 101):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -100, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Submission status: Runtime Error

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

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

else :
    n = list(map(int, input().split()))
    a=list(range(101))

for number in n:
    a.remove(number)

a.sort()

sa=abs(X-a[0])
for i in range((len(a))):
    if sa>abs(X-a[i+1]):
        sa=abs(X-a[i+1])
    
    else:
        print(a[i])
        break

Submission status: Runtime Error

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

a=list(range(101))

for number in n:
    a.remove(number)

a.sort()

sa=abs(X-a[0])
for i in range((len(a))):
    if sa>abs(X-a[i+1]):
        sa=abs(X-a[i+1])
    
    else:
        print(a[i])
        break

Submission status: Runtime Error

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

for i in range(0, x):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break


print(ans)

Submission status: Runtime Error

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

for i in range(0, x):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break


print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
try:
  list_P = [int(p) for p in input().split()]
  list_not_P = [x for x in range(min(list_P)-1, max(list_P)+2) if not x in list_P]
  list_abs = [abs(x - i) for i in list_not_P]
  Index = list_abs.index(min(list_abs))
  print(list_not_P[Index])
except EOFError:
  print(x)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda i: i not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
sx = max(ps)
pss = [i for i in range(1, sx+1)]
ps = list(filter(lambda x: x not in ps, pss))


ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins >= temp:
            mins = temp
            ans = p

print(ans)

Submission status: Runtime Error

Solution code:
def bin_search(arr,k):
    low, high = 0, n - 1
    while (low <= high):
        mid= low+(high-low)//2
        if arr[mid]==k:
            return mid
        if arr[mid]>k:
            high=mid-1
        else:
            low=mid+1

x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    arr.sort()
    idx= bin_search(arr,x)

    l,r=-1,-1
    for i in range(1,idx):
        left= arr[idx-i]
        if x-left>i:
            l=(arr[idx-i+1]-1)
            break
    if l==-1:
        l=arr[0]-1
    for i in range(1,n-idx):
        right= arr[idx+i]
        if right-x>i:
            r=(arr[idx+i-1]+1)
            break
    if r==-1:
        r=arr[n-1]+1
    if (x-l)<=(r-x):
        print(l)
    else:
        print(r)
else:
    print(x)

Submission status: Runtime Error

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

flag = 0
mv = 10000

for i in range(n):
	if (x-in_list[i])**2<mv:
      mv = math.sqrt((x-in_list[i])**2)
      flag = i+1
print(flag)

Submission status: Runtime Error

Solution code:
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1

for i in range(0, 102):
    if i == 0:
        temp_abs = abs(x-i)
        if n_abs > temp_abs:
            n_abs = temp_abs
            ans = i
    else:
        temp_abs = abs(x-i)
        if n_abs > temp_abs and p_list[i-1] != 1:
            n_abs = temp_abs
            ans = i
        elif n_abs == temp_abs and i < ans and p_lsit[i-1] != 1:
            n_abs = temp_abs
            ans = i

print(ans)

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 = list(range(1,101))

    rl =  set(l)-set(p)
    m = 100
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

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 = list(range(1,101))

    rl =  set(l) - set(p)
    m = max(p)
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

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 = list(range(min(p),max(p)+1))

    rl =  set(l) - set(p)
    m = max(p)
    for i in  rl:
        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    print(ans)

Submission status: Runtime Error

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

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i
print(ans)

Submission status: Runtime Error

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

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i

print(ans)

Submission status: Runtime Error

Solution code:
X,N = list(map(int, input().split()))
P = set(list(map(int, input().split())))
pSort = sorted(P)
nums = []
for i in range(1,101):
  nums.append(i)
for p in pSort:
  nums.remove(p)
nums = list(map(lambda x: X - x, nums))
nums.append(0)
nums.remove(0)
oldnum  = 0
for num in nums:
  if num < 0:
    break
  oldnum = num
print(X - oldnum if oldnum <= num * -1 else X - num)

Submission status: Runtime Error

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

if n == 0:
    p = set([])
else:
    p = list(map(int, input().split()))
p = list(map(int, str.split()))
a = list(set(range(201)) - set(p))
abs_diff = [abs(i - x) for i in a]
min_abs_diff = min(abs_diff)
for i, j in zip(a, abs_diff):
    if j == min_abs_diff:
        print(i)
        break

Submission status: Runtime Error

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

if n == 0:
    print(100)
else:
    p = list(map(int, input().split()))
    a = list(set(range(1, 101)) - set(p))
    abs_diff = [abs(i - x) for i in a]
    min_abs_diff = min(abs_diff)
    for i, j in zip(a, abs_diff):
        if j == min_abs_diff:
            print(i)
            break

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
for i in range(50):
    pFlag = True
    mFlag = True
    for j in range(len(p)):
        if p[j] == x+i:
            pFlag = False
        if p[j] == x-i:
            mFlag = False
    if mFlag:
        a = (-1)* i
        break
    if pFlag:
        a = i
        break
print(x+a)

Submission status: Runtime Error

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
else:
    p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-101,102):
    if not i in p:
        if abs(i-X) < MIN:
            MIN = abs(i-X)
            minnum = i
print(minnum)

Submission status: Runtime Error

Solution code:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int X = scan.nextInt();
		int N = scan.nextInt();
		Integer p[] = new Integer[N];
		//int min = Math.abs(100 - X);
		int min = 100;
        int result = X;

		for (int i = 0; i < N; i++) {
			p[i] = scan.nextInt();
		}

		for (int i = 0; i <= 200; i++) {
			if (Math.abs(X - i) < min && !Arrays.asList(p).contains(i)) {
				min = Math.abs(X - i);
				result = i;
			}
		}

		System.out.println(result);

	}

}

Submission status: Runtime Error

Solution code:
x,n=map(int,,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()

Submission status: Runtime Error

Solution code:
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  # Xの両隣がpに存在しないかみていく（pに存在しない値をみつけたいので）
  a = target - i # まずは左隣をみていく(Xよりi小さい)
  if a not in num:
    print(a)
    exit()

  b = target + i # 次に右隣をみていく(Xより大きい)
  if b not in nums:
    print(b)
    exit()
  
# 配列pが与えられなかったとき(長さが0のとき)でも、「Xより0小さい値がpに存在しない」ので、そのままXが返せる

Submission status: Runtime Error

Solution code:
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  a = target + u
  if b not in nums:
    print(b)
    exit()

Submission status: Runtime Error

Solution code:
X,N=map(int,input().split())
p=sorted(map(int,input().split()))
a=[p[0]:p[N+1]]
for i in range(N+1):
    a.remove(p[i])
a=sorted(a.append(X))
x1=a[index.X-1]
x2=a[index.X+1]
if (X-x1)>=(x2-X):
  print x1
else:
  print x2

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

  all_list = list(range(1,101))
  for i in list_:
    all_list.remove(i)

  left = 0
  right = len(all_list)-1

  while left<right:
    mid = (left + right) // 2
    if x < all_list[mid]:
      right = mid
    else:
      left = mid+1
  
  small = all_list[left-1]
  big = all_list[right]

  if abs(small-x)<abs(big-x):
    print(small)
  elif abs(small-x)>abs(big-x):
    print(big)
  else:
    print(small)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
S=map(int, input().split())
K=(list(range(1,101)))
for i in S:
    K.remove(i)
L=[]
for i in K:
    L.append(abs(x-i))
m=min(L)
ind_m=L.index(m)
print(K[ind_m])

Submission status: Runtime Error

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

if x not in p:
    ans = x
else:
    i = 0
    while i<=100:
        if x - i not in p and x-i>0:
            ans = x - i
            break
        elif x + i not in p and x+i<101:
            ans = x + i
            break
        else:
            i += 1
            pass

print(ans)

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp
  ret = i
  tmp = abs(x-i)
print(ret)

Submission status: Runtime Error

Solution code:
x ,n = map(int, input().split())
s = list(map(int, input().split()))
number = list(range(0,102))
min = 100
if n == 0:
  print(x)
  exit()
  
for i in range(n):
  number.remove(s[i])

for i in range(100 - n):
  if min > abs(x - number[i]):
    min = abs(x - number[i])
    j = i
print(number[j])

Submission status: Runtime Error

Solution code:
x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
 
for i in range(x+1):
 for s in [-1,+1]:
   a=x+s*d
   if a not in p:
     print(a)

Submission status: Runtime Error

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

for i in range(x+1):
 for s in [-1,+1]:
   a=X+s*d
   if a not in p:
     print(a)

Submission status: Runtime Error

Solution code:
x ,n = map(int, input().split())
s = list(map(int, input().split()))
number = list(range(1,101))
min = 100
if n == 0:
  print(x)
  exit()
  
for i in range(n):
  number.remove(s[i])

for i in range(100 - n):
  if min > abs(x - number[i]):
    min = abs(x - number[i])
    j = i
print(number[j])

Submission status: Runtime Error

Solution code:
import sys
if n == 0:
  print(x)
  sys.exit()
x, n = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x + i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

Submission status: Runtime Error

Solution code:
import sys
x, n = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x + i)
      sys.exit()
  if x + i not in lst:
      print(x + i)
      sys.exit()

Submission status: Runtime Error

Solution code:
c=[]
d=0
e=[]

a,b=map(int,input().split())
c=int(input().split())
if c!=null:
 for i in range(c):
  d=a-c
  e.append(abs(d))
print(min(e))

Submission status: Runtime Error

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

y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])

new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-abs(X)))

if N != 0:
    print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

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

y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])

new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-abs(X)))

if N != 0:
    print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

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

y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])

new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-X))

if N != 0:
    print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

Solution code:
X, _ = map(int, input().split(' '))
p = map(int, input().split(' '))

num_list = set(range(1, 101)) - set(p)

min = 101
for num in num_list:
  if abs(X - num) < min:
    min = abs(X - num)
    min_value = num
    
print(num)

Submission status: Runtime Error

Solution code:
X, _ = map(int, input().split(' '))
p = map(int, input().split(' '))

num_list = set(range(1, 101)) - set(p)

min = 101
for num in num_list:
  if abs(X - num) < min:
    min = abs(X - num)
    min_value = num

Submission status: Runtime Error

Solution code:
X, _ = map(int, input().split(' '))
p = map(int, input().split(' '))

num_list = set(range(1, 101)) - set(p)

min = 101
for num in num_list:
  if abs(X - num) < min:
    min = abs(X - num)
    min_value = abs(X - num)

Submission status: Runtime Error

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

num_set = set(range(1, 101)) - set(num_list)

min = 10000
for num in list(num_set):
  if abs(X - num) < min:
    min = abs(X - num)
    min_value = num

print(num)

Submission status: Runtime Error

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

num_set = {list(range(1, 100))} - set(num_list)

min = 10000
for num in list(num_set):
  if abs(X - num) < min:
    min = abs(X - num)
    min_value = num

print(num)

Submission status: Runtime Error

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

y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])

new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-X))

print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

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

y = list(range(1, 101))
for i in range(N):
    if p[i] in y:
        y.remove(p[i])
        
new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-X))
    
print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

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

y = list(range(1, 101))

for j in range(N):
    y.remove(p[j])

new_y = []
for i in range(len(y)):
    new_y.append(abs(y[i]-X))

print(y[new_y.index(min(new_y))])

Submission status: Runtime Error

Solution code:
def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
x = int(input())
n = int(input())
a = list(map(int,input().split()))
print(serch_1(a,x),serch_2(a,x))
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))

Submission status: Runtime Error

Solution code:
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    


main()

Submission status: Runtime Error

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

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

y = []
for i in range(N):
    y.append(abs(X-p[i]))
print(p[y.index(min(y))])

Submission status: Runtime Error

Solution code:
n = input().split()
n = [int(i) for i in n]
m = input().split()
m = [int(i) for i in m]
 
ans_1 = n[0]
ans_2 = n[0]
 
ans = []
while True:
  	if n[1] == 0:
      ans.append(0)
      
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
        
    elif not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Runtime Error

Solution code:
n = input().split()
n = [int(i) for i in n]
m = input().split()
m = [int(i) for i in m]


ans_1 = n[0]
ans_2 = n[0]

ans = []
while True:
  	if n[1] == 0:
      ans.append(0)
      
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
        
    elif not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
X,N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = list(map(int, input().split()))
    q = [i+1 for i in range(100)]
    r = list(set(q)-set(p))
    s = np.argsort(np.abs(np.array(r)-X))
    if r[s[0]] == r[s[1]]:
        print(min(r[s[0]], r[s[1]]))
    else:
        print(r[s[0]])

Submission status: Runtime Error

Solution code:
import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(1, 100) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L[0][0])

Submission status: Runtime Error

Solution code:
import numpy as np
X,N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = list(map(int, input().split()))
    q = [i+1 for i in range(100)]
    r = list(set(q)-set(p))
    i = np.argsort(np.abs(np.array(r)-X))[0]
    print(r[i])

Submission status: Runtime Error

Solution code:
import sys

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, i - a) for i in range(1, 100) if i not in c]
L.sort(key=lambda x: abs(x[1]))
print(L[0][0])

Submission status: Runtime Error

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

if N==0:
  print(X)
else:
  nums=[int(x) for x in input().split()]
  
  for i in nums:
    if i-X>0:
      diff.append(i-X)
  diff.sort()
  for i in diff:
    if X+i not in nums:
      print(X+i)
      break

Submission status: Runtime Error

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

lower = min(a)
upper = max(a)
mini = 10000005
res = -1
for i in range(lower-1,upper+2):
    if i not in a:
        if abs(x-i)<mini:
            mini = abs(x-i)
            res = i

print(res)

Submission status: Runtime Error

Solution code:
import operator

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

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

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)
    
print(min(abs_val_dict.items(), key=operator.itemgetter(1))[0])

Submission status: Runtime Error

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

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

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)
    
print(max(abs_val_dict, key = abs_val_dict.get()))

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n <= 0:
    print(x)
else:
    tbl = [0 for i in range(101)]
    data_in = input().split()
    for num in data_in:
        tbl[int(num)] = 1
    for i in range(1, 101, 1):
        if (x-i >= 0) and (tbl[x-i] == 0):
            print(x-i)
            break
        if (x+i <= 101) and (tbl[x+i] == 0):
            print(x+i)
            break