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:
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var X, N int
	fmt.Scanf("%d", &X)
	fmt.Scanf("%d", &N)

	P := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &P[i])
	}
	sort.Ints(P)
	fmt.Println(P)

	var a int = -1
	if len(P) > 0 {
		for p := 0; p < 102; p++ {
			if math.Abs(float64(X) - float64(p)) < math.Abs(float64(X) - float64(a)) && !Contain(P, p) {
				a = p
			}
		}
	} else {
		a = X
	}
	fmt.Println(a)
}

func Contain(s []int, e int) bool {
	for _, v := range s {
		if e == v {
			return true
		}
	}
	return false
}

Submission status: Runtime Error

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

abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])
A = min(abst1)
for j in range(0,len(abst1)):
  if abst2[j][1] == A:
    print(abst2[j][0])
    break

Submission status: Runtime Error

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

p = input().split(' ')
p =[int(i) for i in p]
num_list = [int(i+1) for i in range(100)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min(tmp))
# print(num_list)
# print(ans)
print(num_list[ans])

Submission status: Runtime Error

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

p = input().split(' ')
p =[int(i) for i in p]
num_list = [int(i+1) for i in range(100)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

print(num_list[tmp.index(min(tmp))])

Submission status: Runtime Error

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

if n == 0:
    print(x)

p = set(p)
else:
    _x = x 
    x_ = x
    while True:
        _x -= 1
        x_ += 1
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
plist = list(map(int, input().split()))
if len(plist)==0:
  print(X)
abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])
A = min(abst1)
for j in range(0,len(abst1)):
  if abst2[j][1] == A:
    print(abst2[j][0])
    break

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
plist = list(map(int, input().split()))
abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])
A = min(abst1)
for j in range(0,len(abst1)):
  if abst2[j][1] == A:
    print(abst2[j][0])
    break

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
a=0
if n == 0:
  a=x
else:
  for i in p:
    if abs(a-x) > abs(i-x):
      a=i
      k=p.index(i)

  if a!=x:
    a=x
  else:
    f=0
    j=0
    while f==0:
      j+=1
      if p[k-j] != a-j:
        a = a-j
        break
      if p[k+j] != a+j:
        f = 1
        a= a+j
        break
print(a)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
a=0
if n == 0:
  a=x
else:
  for i in p:
    if abs(a-x) > abs(i-x):
      a=i
      k=p.index(i)

if a!=x:
  a=x
else:
  f=0
  j=0
  while f==0:
    j+=1
    if p[k-j] != a-j:
      a = a-j
      break
    if p[k+j] != a+j:
      f = 1
      a= a+j
      break
print(a)

Submission status: Runtime Error

Solution code:
from math import 8
x,n=map(int,input().split())
a=[int(x) for x in input().split()]
s=[i for i in range(-100,105)]
s=set(s)-set(a)
s=list(s)
s.sort()
dif=10**18
#a.sort()
ans=s[0]
for i in range(len(s)):
	if abs(s[i]-x)<dif:
		dif=abs(s[i]-x)
		ans=s[i]
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys

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

if (x<1)or(100<x)or(n<0)or(100<n):
    sys.exit(0)

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

p = []
for i in range(n):
    p.append(int(input()))
    if (p[i]<1)or(100<p[i]):
        sys.exit(0)

j = 0;

while True:
    l = x-j;
    r = x+j;

    if (l in p)==False:
        print(l)
        sys.exit()

    if (r in p)==False:
        print(r)
        sys.exit()

    j += 1

Submission status: Runtime Error

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

P = list(map(int, input().split()))
t = x
for i in range(101):
  if not i in P:
    if t > abs(i - x):
      t = abs(i - x)
      ans = i
      
print(ans)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))
s=set()
p=x
res=0
while(True):
  if(not(p in l)):
    res=p
    break
  p-=1
s.add(res)
while(True):
  if(not(x in l)):
    res=x
    break
  x+=1
s.add(res)
print(min(res))

Submission status: Runtime Error

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

p = [int(i) for i in input().split()]
p.sort()

k=[]

if n==0: print(x)
else:
    for i in range(p[0],p[-1]):
        if not i in p: k.append(i)

    for j in range(len(k)):
        k[j] = abs(k[j]-x)

    minimo = min(k)

    if x+minimo in p: print(x-minimo)
    elif x-minimo in p: print(x+minimo)
    else: print(min(x+minimo,x-minimo))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
A = [int(hoge) for hoge in input().split()]
A = list(range(2,1000001))
A.sort()
M = max(A)
dp = [False] * (M+ 1)
ans = 0
prev = -1
for a in A:
    if dp[a] == False:
        for j in range(2,1 + (M// a)):
            dp[a*j] = True
        if a != prev:
            ans += 1
        else:
            dp[a] = True
            ans -= 1
    prev = a
print(ans)

Submission status: Runtime Error

Solution code:
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)
W = H.count(F)

    
    
    
print(X[O])

Submission status: Runtime Error

Solution code:
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+1] == i ):
    if i in l:
      print(x-i)
    else:
      print(x+i)
    break

Submission status: Runtime Error

Solution code:
# C
x, n = map(int, input().split())
p = list(map(int, input().strip().split()))
print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
        if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Submission status: Runtime Error

Solution code:
x,N=map(int,input().split())
p=list(map(int,input().split()))
ans=101
if x in p:
    for i in range(102):
        if i in p:
            continue
        ans=min(ans,abs(p[i]-x))
    if x+ans in p:
        ans*=-1
else:
    ans=0
print(x+ans)

Submission status: Runtime Error

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

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

#p.sort()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Submission status: Runtime Error

Solution code:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

Submission status: Runtime Error

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

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

p.sort()

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

Submission status: Runtime Error

Solution code:
def inp():
    ls=set(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(1, 102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Submission status: Runtime Error

Solution code:
def solution(X, N, P):
    if N <= 0 or X not in P:
        return X

    P.sort()
    diff = [abs(p - X) for p in P]
    X_idx = diff.index(0)
    left = sorted(diff[:X_idx])
    right = sorted(diff[X_idx+1:])

    for i in range(1, len(P)):
        left = X - i
        right = X + i

        nearest_l = None
        nearest_r = None
        if left not in P:
            nearest_l = left
            break
        if right not in P:
            nearest_r = right
            break
    else:
        nearest_r = len(P) + 1
    if nearest_l and nearest_r:
        nearest = min(nearest_l, nearest_r)
    elif nearest_l is not None:
        nearest = nearest_l
    elif nearest_r is not None:
        nearest = nearest_r
    return nearest

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

print(solution(X, N, P))

Submission status: Runtime Error

Solution code:
# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p and abs(x - i) < abs(x - ans):
            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()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(-1.N):
        a.remove(P[i])
        a = a
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Submission status: Runtime Error

Solution code:
minn = 10000000
if n == 0:
    print(x)
    
p = list(map(int, input().split()))
for i in range(1000):
    if i not in p:
        tmp = abs(x-i)  
        if minn > tmp:
            ans = i
            minn = tmp
        elif minn == tmp:
            ans = min(i, ans)
print(ans)

Submission status: Runtime Error

Solution code:
minn = 10000000
if n == 0:
    print(x)
    
p = list(map(int, input().split()))
for i in range(1000):
    if i not in p:
        tmp = abs(x-i)  
        if minn >= tmp:
            ans = i
            minn = tmp
        
print(ans)

Submission status: Runtime Error

Solution code:
import bisect
x,n=map(int,input().split())
l=list(map(int,input().split()))
k=[0]*(101)
for i in l:
    k[i]=1
s=10000
for i in range(1,101):
    if k[i]==1:
        continue
    if abs(x-i)<s:
        s=abs(x-i)
        ans=i
print(ans)

Submission status: Runtime Error

Solution code:
#C

ans = []
x,n = map(int,input().split())
l = list(map(int,input().split()))
l.sort()

nl = [0] * 100

for i in l:
    nl[i] = i

if(not (n == 0)):

    mx = x+1
    if(mx <= 100):
        for i in range(x+1,len(nl)+1):
            if( nl[i] ==  0):
                #ans.append(mx)
                break
            mx = mx + 1
    else:
        mx = 999
    
    
    mi = x - 1
    if(mi >= 1):
        for i in range(x-1,1,-1):
            if( nl[i] ==  0):
                #ans.append(mi)
                break
            mi = mi - 1
    else:
        mi = 999
    
    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    else:
        print(mi)
        
else:
    print(x)

Submission status: Runtime Error

Solution code:
#C

ans = []
x,n = map(int,input().split())
l = list(map(int,input().split()))
l.sort()

nl = [0] * 100

for i in l:
    nl[i] = i

if(not (n == 0)):

    mx = x+1
    if(mx <= 100):
        for i in range(x+1,len(nl)+1):
            if( nl[i] ==  0):
                #ans.append(mx)
                break
            mx = mx + 1
    else:
        mx = 999
    
    
    mi = x - 1
    if(mi >= 1):
        for i in range(x-1,1,-1):
            if( nl[i] ==  0):
                #ans.append(mi)
                break
            mi = mi - 1
    else:
        mi = 999
    
    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    else:
        print(mi)
        
else:
    print(n)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(p[address])

Submission status: Runtime Error

Solution code:
x,y=map(int,input().split())
if y==0:
  print(x)
else:
  lis=list(map(int,input().split()))
  l=[]
  for i in range(1,101):
    if i not in lis:
      l.append(i)
  
  p=[]
  for i in l:
    p.append(abs(x-i))
  p=sorted(p)

  if p[0]>x or (x-p[0])/2==0 :
    print(0)
  
  elif x-p[0] in l:
    print(x-p[0])
  else:
    print(p[0]+x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


for i in range(x, 0, -1):
  if not i in p:
    a1 = i
    break

for i in range(x, 100 + 2):
  if not i in p:
    a2 = i
    break

if x - a1 <= a2 - x:
  print(a1)
else:
  print(a2)

Submission status: Runtime Error

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

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

p.sort()

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
a,b = map(int, input().split()) 

if b==0:
    print(a)
    exit()
num_list = list(map(int, input().split()))

    

num=[True]*101
#print(num)


for i in range(b):
    num[num_list[i]]=False


num[0]=False
#print(num)

count=0
min_min=100
min_max=100
i=a

#print(i)
while 1:
    if i==100:
        break
    if num[i]==True:
        min_min=i-a
        break
    i+=1
j=a


while 1:
    if num[j]==True:
        min_max=a-j
        break
    j-=1
#print(min_max)
#print(j)
if min_min<min_max:
    print(i)
    
else:
    print(j)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
B=list(map(int,input().split()))
A=B.copy()
for i in range(b):
  A[i]= abs(A[i]-a)
A.sort()
for i in range(A[-1]+2):
  if A.count(i)==1:
    if i!=0:
      if a-i in B:
        result=a+i
        break
      else:
        result=a-i
        break
  elif A.count(i)==0:
    result=a-i
    break

    
print(result)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  ans=0
  for i in range(n):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
  if ans==0:
    for j in range(2*x,101):
      if j not in a:
        ans=j
        break
print(ans)

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  ans=0
  for i in range(n-1):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
  if ans==0:
    for j in range(2*x,101):
      if j not in a:
        ans=j
        break
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()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  　　print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np
input = stdin.readline

N = int(input())
A_list = list(map(int, input().split()))
ans_list =np.ones(N)
A_list = np.array(A_list)

for i in range(N):
    for j in range(i+1,N):
        if A_list[i] %  A_list[j] == 0:
            ans_list[i] = 0
            if (A_list[j] %  A_list[i] == 0):
                ans_list[j] = 0
        elif A_list[i] ==  A_list[j]:
                ans_list[i] = 0
                ans_list[j] = 0
        elif(A_list[j] %  A_list[i] == 0):
            ans_list[j] = 0
print(int(np.sum(ans_list)))

Submission status: Runtime Error

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

if n == 0:
	print(x)
else:	
	maximum = max(arr)
	minimum = 0
	l = {}


	for i in range(1,maximum+1):
		if i not in arr:
			minus = abs(i-x)
			l[i] = minus	
	value = list(l.values())	
#key = list(l.keys())
	min_key = min(value)
#print(value)
#print(key)

	for key,val in l.items():
		if val == min_key:
			print(key)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python
# -*- Coding: utf-8 -*-

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


if n == 0:
    print(x)
else:
    p_li.sort()
    if(x in p_li) == False:
        print(x)
    else:
        pst = p_li.index(x)
        for i in range(1,100):
            if x - i != p_li[pst - i]:
                print(x - i)
                break;
            elif x + i != p_li[pst + i]:
                print(x + i)
                break;

Submission status: Runtime Error

Solution code:
import math

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

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

# p.sort()

# minimum = p[0]
# maximum = p[len(p) - 1]

# if X < minimum or maximum < X:
#     print(X)
#     exit()

# diff_min = abs(X - minimum - 1)
# diff_max = abs(X - maximum + 1)
# if diff_min == diff_max:
#     answer = min(minimum - 1, maximum + 1)
# else:
#     answer = minimum - 1 if diff_min < diff_max else maximum + 1

for candidate in range(0, 100 + 2):
    if candidate in p : continue

    diff_candidate = abs(X - candidate)
    diff_answer = abs(X - answer)

    if diff_candidate == diff_answer:
        answer = min(candidate, answer)
    elif diff_candidate < diff_answer:
        answer = candidate

print(answer)

Submission status: Runtime Error

Solution code:
x,y=map(int,input().split())
if y==0:
  print(x)
else:
  lis=list(map(int,input().split()))
  l=[]
  for i in range(1,101):
    if i not in lis:
      l.append(i)
  
  p=[]
  for i in l:
    p.append(abs(x-i))
  p=sorted(p)

  if p[0]>x:
    print(0)
  
  elif x-p[0] in l:
    print(x-p[0])
  else:
    print(p[0]+x)

Submission status: Runtime Error

Solution code:
import bisect
x,n=[int(pop) for pop in input().split()]
a=[int(pop) for pop in input().split()]
a.sort()
lo=bisect.bisect(a,x)

if lo==len(a): print(a[-1]); exit()
if lo==0: print(a[0]); exit()

if x-a[lo-1]<=a[lo]-x: print(a[lo-1])
else: print(a[lo])

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    
    p=list(map(int,input().split()))
    q=[]
    for i in range(100):
        q.append(i)
 
    for j in range(0,n):
        q.remove(p[j])
 
    b=101
    min=999
    for k in range(0,len(q)):
        a=x-q[k]
        if min>=abs(a):

            min=abs(a)
        b=k
        
print(b+1)

Submission status: Runtime Error

Solution code:
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))
		ymin = min(min(A), X)-1
		ymax = max(max(A), X)
		Y = {}
		for y in range(ymin, ymax):
			if y in A:
				None
			else:
				key = int(abs(X-y))
				if key in Y.keys():
					Y[key] = Y[key].append(y)
				else:
					Y[key] = [y]
		key = min(Y.keys())
		print(min(Y[key]))
resolve()

Submission status: Runtime Error

Solution code:
if __name__=="__main__":
    # Problem C
    X, N = map(int, (input().split(' ')))
    if N > 0:
        P = map(int, input().split(' '))
        P_max = max(P)
        P_min = min(P)
        if X in P:
            for i in range(0, 100):
                if (X-i) not in P:
                    print(X-i)
                    break

                elif (X+i) not in P:
                    print(X+i)
                    break
        elif X not in P:
            print(X)
    else:
        print(X)

Submission status: Runtime Error

Solution code:
import bisect
x,n=[int(pop) for pop in input().split()]
a=[int(pop) for pop in input().split()]
a.sort()
lo=bisect.bisect(a,x)

if lo==len(a): print(a[-1]) exit()
if lo==0: print(a[0]) exit()

if x-a[lo-1]<=a[lo]-x: print(a[lo-1])
else: print(a[lo])

Submission status: Runtime Error

Solution code:
num_input = [input() for i in range(2)]
x = int(num_input[0].split()[0])
n = int(num_input[0].split()[1])

num_list = [int(n) for n in num_input[1].split()]
num_list.sort()

ans=x

if n!=0 and n!=1 and n!=100:
    if x in num_list:
        index=num_list.index(x)

        value_left=x-1
        value_right=x+1

        if index!=0:
            index_left=index-1
        if index!=n-1:
            index_right=index+1
        
        if index==0:
            ans=x-1
        elif index==n-1:
            if num_list[index-1]==x-1:
                ans=x+1
            else:
                ans=x-1
        else:
            for i in range(n):
                if num_list[index_left]!=value_left:
                    ans=value_left
                    break
                elif num_list[index_right]!=value_right:
                    ans=value_right
                    break
                if index_left!=0:
                    index_left=index_left-1
                if index_right!=n:
                    index_right=index_right+1
                value_left=value_left-1
                value_right=value_right+1

if n==1
    ans=x-1

if n==100:
    if x<=50:
        ans=0
    if x>50:
        ans=101

print(ans)

Submission status: Runtime Error

Solution code:
x,n= map(int,input().split())
u = 100
num_str=input().split()
s=list(map(int, num_str))
m  = list(range(-100, 100)) 
for k in s:
    m.remove(k)
for l in m:
    a = l - x
    if abs(u) > abs(a):
        u = a
print(u+x)

Submission status: Runtime Error

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

if A[1]==0:
  print(A[0])
else:
  B = list(map(int, input().split()))
  l=[i for i in range(1, 101)]
  for i in range(A[1]):
    l.remove(B[i])
  for i in range(len(l)):
    l[i]=abs(A[0]-l[i])
  print(min(l)+A[0])

Submission status: Runtime Error

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

mina =101
y = []
minc = []

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

for i in range(1,101):
    y.append(i)

if n == 0:
    print(x)
else:
    for j in range(n):
        y.remove(p[j])

    z = copy.copy(y)

    for k in range(len(y)):
        if abs(x - y[k]) < mina:
            mina = abs(x - y[k])
            minb = y[k]
            z.remove(minb)

    minc.append(minb)
    mina = 101

    for m in range(len(z)):
        if abs(x - z[m]) < mina:
            mina = abs(x - z[m])
            minb = z[m]

    minc.append(minb)

    print(min(minc))

Submission status: Runtime Error

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

mina =101
y = []
minc = []

for x not in p:
    print(x)
    exit()

for i in range(1,101):
    y.append(i)

if n == 0:
    print(x)
else:
    for j in range(n):
        y.remove(p[j])

    z = copy.copy(y)

    for k in range(len(y)):
        if abs(x - y[k]) < mina:
            mina = abs(x - y[k])
            minb = y[k]
            z.remove(minb)

    minc.append(minb)
    mina = 101

    for m in range(len(z)):
        if abs(x - z[m]) < mina:
            mina = abs(x - z[m])
            minb = z[m]

    minc.append(minb)

    print(min(minc))

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
minn = 10000000
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
for i in range(1, 101):
    if i not in p:
        tmp = abs(x-i)  
        if minn > tmp:
            ans = i
            minn = tmp
        elif minn == tmp:
            ans = min(i, ans)

print(ans)

Submission status: Runtime Error

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

def create_full_array(minimum, maximum):
    full_list = []
    for i in range(minimum,maximum+1):
        full_list.append(int(i))
    return full_list

if n == 0:
    print(x)
elif x > max(p_a) + 1 or x < min(p_a):
    ans = x - 1
    print(ans)
elif x == max(p_a) + 1:
    ans = x + 1
    print(ans)
else:
    full_array = create_full_array(min(p_a), max(p_a))
    if x in p_a:
        target_list = list(set(p_a)^set(full_array))
        abs_key = {}
        for i in target_list:
            abs_key[i] = abs(x-i)
        minimum = min(abs_key.values())
        t_k = []
        t_v = []
        [t_k.append(k) for k, v in abs_key.items() if v == minimum]
        print(min(t_k))

    else:
        print(x)

Submission status: Runtime Error

Solution code:
x,n = map(int, input().split())
p = sorted(map(int, input().split()))
if p == []:
    print(x)
else:
    a = p[-1]
    d =[]
    e = 0
    E = 0
    b = 1000
    c = 0
    for i in range(a):
        d += [e]
        e += 1
    for i in range(n):
        d.remove(p[E])
        E += 1
    for i in range(n):
        b = min((abs,x-d[c]),b)
        c += 1
    if (x-b) in d:
        print(x-b)
    else:
        print(x+b)

Submission status: Runtime Error

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

arr = []
tmp = input()
num = tmp.split(' ')
num_li = [int(i) for i in num]
arr.extend(num_li)

min = x
max = x

if n == 0:
    print(x)
else:
    for i in range(10000):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break

Submission status: Runtime Error

Solution code:
import numpy as np
 
X,N = map(int,input().split())
p = input()
 
if N != 0:
    
    p_list = [int(n) for n in p.split()]
    
    X_near = np.array(list(range(int(np.ceil(X - N/2)), int(np.floor(X + N/2)) + 1)))
 
    remain_list = []
 
    for i in X_near:
        if i not in p_list:
            remain_list.append(i)
        
 
    remain_array = np.array(remain_list)
    min_bool = np.abs(X - remain_array).min() == np.abs(X - remain_array)
    print(remain_array[min_bool].min())
    
if N == 0:
    print(X)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python
# -*- Coding: utf-8 -*-

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


if n == 0:
    print(x)
else:
    p_li.sort()
    if x in p_li == False:
        print(x)
        sys.exit()
    else:
        pst = p_li.index(x)
        for i in range(1,100):
            if x - i != p_li[pst - i]:
                print(x - i)
                break;
            elif x + i != p_li[pst + i]:
                print(x + i)
                break;

Submission status: Runtime Error

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

arr = []
tmp = input()
num = tmp.split(' ')
num_li = [int(i) for i in num]
arr.extend(num_li)

arr.sort()

min = x
max = x

if n == 0:
    print(x)
else:
    for i in range(10000):

        min -= 1
        max += 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
    return sorted(numbers_array, key=abs)

    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0])