Problem:


Score : 300 points

Problem Statement

Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.

Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

1 \leq X \leq 100

0 \leq N \leq 100

1 \leq p_i \leq 100

p_1, \ldots, p_N are all distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X N
p_1 ... p_N

Output

Print the answer.

Sample Input 1

6 5
4 7 10 6 5

Sample Output 1

8

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.

Sample Input 2

10 5
4 7 10 6 5

Sample Output 2

9

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.

Sample Input 3

100 0

Sample Output 3

100

When N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.



Sample input:
6 5
4 7 10 6 5


Sample output:
8

Submission status: Runtime Error

Solution code:
X,N=map(int, input().split())
p=list(map(int, input().split()))
seisuu=[0 for i in range(0,101)]
if N==0:
    print(X)
else X==100:
    print(X)
else:
    for i in range(0,N):
        seisuu[p[i]]=1
    count1=X-1
    count2=X+1
    ans=0
    if seisuu[X]==0:
        print(X)
    else:
        while True:
            if count1>0 and count2<=100:
                if seisuu[count1]==0:
                    ans=count1
                    break
                elif seisuu[count2]==0:
                    ans=count2
                    break
            else:
                if count1<=0:
                    ans=0
                    break
                elif count2>100:
                    ans=101
                    break
            count1-=1
            count2+=1
        print(ans)

Submission status: Runtime Error

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

    a = [i for i in range(101)]
    for i in range(n):
        a[p[i]] = 1000
    min = 1000
    result = 1000
    if n == 100:
        result = min(abs(100-x),abs(x))
    else:
        for i in reversed(range(1,101)):
            if a[i] != 1000:
                if min >= abs(x - a[i]):
                    min = abs(x - a[i])
                    result = a[i]

    print(result)

Submission status: Runtime Error

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

x = a[0]
n = a[1]

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

Submission status: Runtime Error

Solution code:
import numpy as np
listA=[]
lis=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)

X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]

    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)   

    for i in range(P_max+1):
        lis.append(i)
    lis.remove(0)
    
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)

    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N != 0:
    
    p_list = [int(n) for n in input().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())
    
else:
    p_list = input()
    print(X)

Submission status: Runtime Error

Solution code:
a = input().split()
if a[1] == "0":
  print(a[0])
else:
  number_list = input().split()
  n = 1
  number = int(a[0])
  while True:
    num = number + n
    num2 = number - n
    if str(num) not in number_list or str(num2) not in number_list:
      if str(num) in number_list:
        print(num2)
      else:
        print(num1)
      break
    n += 1

Submission status: Runtime Error

Solution code:
i=(input().split())

X=int(i[0])
N=int(i[1])

if N==0:
    print(X)
else:
    j=(input().split())
    d=[]
    e=[]
    jj=[]
    for a in range(len(j)):
        jj.append(int(j[a]))
            
    for b in range(max(jj)):
        if b+1 not in jj:
            d.append(abs(X-(b+1)))

    w=X+min(d)
    v=X-min(d)

    if v in jj:
        print(w)
    else:
        print(v)

Submission status: Runtime Error

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

num1 = x

for i in range(n):
    num1 += 1
    if num1 not in p:
        dif1 = num1- x
        break

num2 = x
for k in range(n):
    num2 -= 1
    if num2 not in p:
        dif2 = x - num2
        break

if dif1 > dif2:
    print(num2)
elif dif1 < dif2:
    print(num1)
elif dif1 == dif2:
    print(num2)

Submission status: Runtime Error

Solution code:
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()
    
  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
     
    # Left優先
    if P[l] != down:
      print(down)
      break
     
    if P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
import bisect
a,b=map(int,input().split())
c=list(map(int,input().split()))

if a not in c:
    print(a)
    exit()

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

m=sorted(list(set(n)^set(c)))
bisect.insort_right(m,a)

m=sorted(list(set(m)))
if len(m)<3:
    print(m[m.index(a)-1])

elif b==0:
    print(a)

elif a==100:
    print(m[m.index(a)+1])

elif abs(a-m[m.index(a)-1])<abs(a-m[m.index(a)+1]):
    print(m[m.index(a)-1])

elif abs(a-m[m.index(a)-1])==abs(a-m[m.index(a)+1]):
    print(m[m.index(a)-1])

else:
    print(m[m.index(a)+1])

Submission status: Runtime Error

Solution code:
def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    else:
        p = [int(i) for i in input().split()]

    s = []
    for i in range(101):
        if not i in p:
            s.append(i)
    if not x in p:
        print(x)
        return
    
    t = s + [x]
    t.sort()
    pos = t.index(x)
    if abs(x-t[pos-1]) <= abs(x-t[pos+1]):
        print(t[pos-1])
    else:
        print(t[pos+1])

resolve()

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
q=list()
for i in range(101):
    q.append(i)

for j in range(n+1):
    q.remove(p[j])
min=1000
for k in range(0,101-n):
    a=x-q[k]
    if min>=abs(a):
        min=abs(a)

print(abs(min-x))

Submission status: Runtime Error

Solution code:
import sys
X,N=map(int,input().split())
if N==0:
    print(X)
    sys.exit()
A=list(map(int,input().split()))
B=[]
for i in range(1,101):
    CH=int(0)
    for k in range(N):
        if i==A[k]:
            CH=1
    if CH==0:
        B.append(int(i))
C=[0 for _ in range(len(B))]
for j in range(len(B)):
    if B[j]-X>=0:
        C[j]=int(B[j]-X)
    else:
        C[j]=int(X-B[j])
m=min(C)
kouho1 = int(X-m)
kouho2 = int(X+m)
#print(B[3])
#print(kouho2)
for k in range(len(B)):
    if int(B[k])==int(kouho1):
        print(B[k])
        sys.exit()
for l in range(len(B)):
    if int(B[l])==int(kouho2):
        print(B[l])
        sys.exit()

Submission status: Runtime Error

Solution code:
def main():
    x, n = map(int, input().split())
    
    if n==0:
        print(x)
    else:
        p = list(map(int, input().split()))
        truefalse = [True]*100
        for i in range(n):
            truefalse[p[i]-1] = False
        
        a = 0
        while 1:
            if truefalse[x-a-1]:
                print(x-a)
                break
            elif truefalse[x+a-1]:
                print(x+a)
                break
            else:
                a += 1

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
k, n = map(int, input().split())
if n == 0:
    print(0)
else:
    l = list(map(int, input().split()))
    l.sort()
    k1 = [i for i in range(min(l), max(l) + 1) if i not in l]
    d = {}
    for i in range(len(k1)):
        d[k1[i]] =max(k1[i],k)-min(k1[i],k)
    k2 = min(d, key=d.get)
    if len(d)==0:
      print(0)
    else:
      print(k2)

Submission status: Runtime Error

Solution code:
import numpy as np
X, N = map(int, input().split())
p = list(map(int, input().split()))
cnt1 = []
cnt2 = []
for i in range(100):
  if not i+1 in p:
    cnt1.append(i+1)
    cnt2.append(abs(i+1-X))
cnt2_ = np.array(cnt2)
b = np.argmin(cnt2)
print(cnt1[b])

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)
o_nums = list(input().split())

if length > 0:
  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)+1):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(diffs_abs[smallest_diff_index]) in diffs: # ターゲットよりも小さい、最も差分が小さい値を探す
    index = diffs.index(-(diffs_abs[smallest_diff_index]))
    print(nums[index])
  else:
    print(nums[smallest_diff_index])

else:
  print(target)

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]
# print(minimum, maximum)

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

# answer = min(abs(X - minimum - 1), abs(X - maximum + 1))
for candidate in range(minimum, maximum):
    if candidate in p: continue

    diff_answer = abs(X - answer)
    diff_candidate = abs(X - candidate)
    # print(candidate, diff, answer)
    answer = candidate if diff_candidate < diff_answer else answer

print(answer)

Submission status: Runtime Error

Solution code:
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
     
    # Left優先
    if P[l] != down:
      print(down)
      break
     
    if P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
q=list()
for i in range(100):
    q.append(i)

for j in range(n):
    q.remove(p[j])
min=1000
for k in range(0,101-n):
    a=x-q[k]
    if min>=abs(a):
        min=abs(a)

print(abs(min-x))

Submission status: Runtime Error

Solution code:
x, y = map(int, input().split())
if(y != 0):
  p = list(map(int, input().split()))
  p.sort()  
  nonp = list()
  for i in range(p[0], p[-1] + 1):
    if(i not in p):
      nonp.append(i)
  if(len(nonp) == 1):
    print(nonp[0])
  else:
  	print(min(nonp, key = lambda d:abs(d-x)))
else:
  print(x)

Submission status: Runtime Error

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

P_ori=list(map(int,input().split()))
if P_ori.count(X)==0:
    print(X)
    exit()

P1=sorted(P_ori)
N=list(range(1,101))
PZ=[]
for i in range(len(N)):
    if P1.count(N[i])==0:
        PZ.append(N[i])

PZ.append(X)
P2=sorted(PZ)
t=P2.index(X)
if t==0:
    print(P2[1])
elif t==len(P2):
    print(P2[t-1])
else:
    dist1=abs(P2[t-1]-P2[t])
    dist2=abs(P2[t]-P2[t+1])
    if dist1<=dist2:
        print(P2[t-1])
    else:
        print(P2[t+1])

Submission status: Runtime Error

Solution code:
import numpy as np
lis=[]
for i in range(101):
    lis.append(i)
lis.remove(0)

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)

X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]

    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)

    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Submission status: Runtime Error

Solution code:
k, n = map(int, input().split())
if n == 0:
    print(0)
else:
    l = list(map(int, input().split()))
    l.sort()
    k1 = [i for i in range(min(l), max(l) + 1) if i not in l]
    d = {}
    for i in range(len(k1)):
        d[k1[i]] =max(k1[i],k)-min(k1[i],k)
    k2 = min(d, key=d.get)
    print(k2)

Submission status: Runtime Error

Solution code:
xn=input()
p=input()
x,n=xn.split()
if p==' ':
  print(int(x))
else:
  p={int(i) for i in p.split()}
  s={i for i in range(1,100)}
  s_p=list(s-p)
  d=[abs(i-int(x)) for i in s_p]
  print(s_p[d.index(min(d))])

Submission status: Runtime Error

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

if n!=0:
    p_list = list(map(int, input().split()))
    
    if n%2==0:
        kouho = list(range((x-n//2-1),(x+n//2)))
    else:
        kouho = list(range((x-n//2-1),(x+n//2+1)))
        kouho2 = set(kouho) - set(p_list)
        ans = [j for i, j in enumerate(list(kouho2)) if abs(j-x) == min(abs(np.array(list(kouho2)) - x))]
        ans = min(ans)

else:
    ans = [x]

print(ans)

Submission status: Runtime Error

Solution code:
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
     
    # Left優先
    if P[l] != down:
      print(down)
      break
     
    if P[r] != up:
      print(up)
      break
    
    l -= 1
    r += 1
    
if __name__ == '__main__':
	main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

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

P_set = list(set(P))
#print(P_set)
#print(P_set[1])

ans_chk = 0

if ( X < P_set[0] or X > P_set[N-1] ):
  print(X)
  ans_chk = 1

if ( ans_chk==0 ):
  for i in range(len(P)):
    if ( P_set[i] == X ):
      X_i = i
      break
    elif ( P_set[i] > X ):
      print(X)
      ans_chk = 1
      break

if ( ans_chk==0 ):
  
  if ( X_i >= N-(X_i+1) ): # 上の数が少ない → 下は1回多くする
    M = N-(X_i+1)
    temp_ans = X + N-(X_i+1) +1
    #print("temp_ans =",temp_ans)
    
    for i in range(1,M+1):
      print(i)
      if ( P_set[ X_i -i ] != X-i ):
        print(X-i)
        ans_chk = 1
        break
      elif ( P_set[ X_i +i ] != X+i ):
        print(X+i)
        ans_chk = 1
        break
    
    if ( ans_chk==0 ):
      if ( P_set[ X_i -(M+1) ] != X-(M+1) ):
        print( X-(M+1) )
        ans_chk = 1


  else: # 下の数が少ない → そのまま
    M = X_i
    temp_ans = X - X_i -1
    #print("temp_ans =",temp_ans)
  
    for i in range(1,M+1):
      print(i)
      if ( P_set[ X_i -i ] != X-i ):
        print(X-i)
        ans_chk = 1
        break
      elif ( P_set[ X_i +i ] != X+i ):
        print(X+i)
        ans_chk = 1
        break

if ( ans_chk==0 ):
  print(temp_ans)

Submission status: Runtime Error

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

for i in range (-100, 100, 1):
  c_list.append(i)

if n == 0:
  ans = x
else:
  p = list(map(int, input().split()))
  for i in range(len(p)):
    c_list[c_list.index(p[i])] = 250
  # print(c_list)
  diff = 500
  for i in range(len(c_list)):
    if abs(x - c_list[i]) < diff:
      diff = x - c_list[i]
      ans = c_list[i]

print(ans)

Submission status: Runtime Error

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

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

num1 = x

for i in range(n):
    num1 += 1
    print(num1 in p)
    if num1 not in p:
        dif1 = num1- x
        break

num2 = x
for k in range(n):
    num2 -= 1
    if num2 not in p:
        dif2 = x - num2
        break

if dif1 > dif2:
    print(num2)
elif dif1 < dif2:
    print(num1)
elif dif1 == dif2:
    print(num2)

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)

if length > 0:
  o_nums = list(input().split())

  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)+1):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(diffs_abs[smallest_diff_index]) in diffs: # ターゲットよりも小さい、最も差分が小さい値を探す
    index = diffs.index(-(diffs_abs[smallest_diff_index]))
    print(nums[index])
  else:
    print(nums[smallest_diff_index])

else:
  print(target)

Submission status: Runtime Error

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

P_ori=list(map(int,input().split()))
if P_ori.count(X)==0:
    print(X)
    exit()

P1=sorted(P_ori)
N=list(range(1,101))
PZ=[]
for i in range(len(N)):
    if P1.count(N[i])==0:
        PZ.append(N[i])

PZ.append(X)
P2=sorted(PZ)
t=P2.index(X)
if t==0:
    print(P2[1])
else:
    dist1=abs(P2[t-1]-P2[t])
    dist2=abs(P2[t]-P2[t+1])
    if dist1<=dist2:
        print(P2[t-1])
    else:
        print(P2[t+1])

Submission status: Runtime Error

Solution code:
import numpy as np
def calc_double(nn):
    return nn -x

x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
p_all = list(range(-200,200,1))

for i in enumerate(p):
    l_in = [s for s in p_all if s not in p]

data2 = []
for val in l_in:
    data2.append(abs(calc_double(val)))

min_index =np.argmin(data2)
print(l_in[min_index])

Submission status: Runtime Error

Solution code:
xn=input()
p=input()
x,n=xn.split()
if p=='':
  print(int(x))
else:
  p={int(i) for i in p.split()}
  s={i for i in range(1,100)}
  s_p=list(s-p)
  d=[abs(i-int(x)) for i in s_p]
  print(s_p[d.index(min(d))])

Submission status: Runtime Error

Solution code:
x, n = input().strip().split()
x, n = [int(x), int(n)]
p = list(map(int, input().strip().split()))
q=[0]*n
for i in range (n):
    q[i]=abs(x-p[i])
q.sort()

if q[0]>=1:
    print(x)
else:
    for i in range (n+1):
        if p.count(x-(q[0]+i))==0:
            s=x-(q[0]+i)
            break
    for i in range (n+1):
        if p.count(x+q[0]+i)==0:
            t=x+(q[0]+i)
            break
if (x-s)<=(t-x):
    print(s)
else:
    print(t)

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)

if length > 0:
  o_nums = list(input().split())

  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(diffs_abs[smallest_diff_index]) in diffs: # ターゲットよりも小さい、最も差分が小さい値を探す
    index = diffs.index(-(diffs_abs[smallest_diff_index]))
    print(nums[index])
  else:
    print(nums[smallest_diff_index])

else:
  print(target)

Submission status: Runtime Error

Solution code:
import sys

X,N = input().split()
if N == "0":
  print(X)
  sys.exit()

else:
  p = [int(e) for e in input().split()]
  p.sort()
  # print(p)
  # [4, 7, 10, 6, 5]
  X = int(X)

  f = int(p[0])
  e = int(p[-1])
  ans = 999
  for num in range(f,e):
    if num in p:
      continue
    else:
      tmp = abs(X-int(num))
      if tmp < ans:
        ans = tmp
        a = num

  print(a)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    seisulist = list(map(int, input().split()))
    if max(seisulist) > x:
        size = max(seisulist) + 1
    else:
        size = x + 1
    numlist = [i for i in range(1,size) if i not in seisulist]
    xretu = [x]*len(numlist)
    hikizan = [abs(s-t) for (s, t) in zip(numlist, xretu)]
    sa = min(hikizan)
    if x-sa not in seisulist:
        print(x-sa)
    else:
        print(x+sa)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split(" "))
data = list(map(int, input().split(" ")))
point = 0
i = -1
while(1){
	if x not in data:
  		print(x)
  		break;
  	elif x+i not in data:
  		print(x+i)
        break
    elif x+(-1*i) not in data:
        print(x+(-1*i))
        break
    else:
  		i=i-1  
}

Submission status: Runtime Error

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

hidden_L = [i+1 for i in range(100)]

for A_i in A_L:
    hidden_L.remove(A_i)

hidden_d = dict()
for B_i in hidden_L:
    hidden_d[B_i] = abs(B_i-X)

keys = [int(k) for k, v in hidden_d.items() if v == min(hidden_d.values())]
print(min(keys))

Submission status: Runtime Error

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

for i in range(1,101):
  if i in A:
    pass
  else:
    B.append(i)

C=[abs(X-j) for j in B]
s=min(C)

y=C.index(s)

z=B[y]

print(z)

Submission status: Runtime Error

Solution code:
##C
X,N = map(int,input().split())
P = list(map(int,input().split()))
i=0

while X+i<=100:
    if X+i not in P:
        ans1 = X+i
        break
    i += 1
while X-i>=0:
    if X-i not in P:
        ans2 = X-i
        break
    i += 1
if ans1-X>=X-ans2:
    print(ans2)
else:
    print(ans1)

Submission status: Runtime Error

Solution code:
import numpy as np
lis=[]
for i in range(101):
    lis.append(i)
lis.remove(0)

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)

X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]

    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)

    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default

    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Submission status: Runtime Error

Solution code:
x, n = map(int,input().split())
p = [int(input()) for _ in range(n)]
n_list = [i for i in range(1,101)]
for j in p:
    n_list.remove(j)

ans = {}
for k in n_list:
    ans[k] = abs(x-k)

print(min(ans, key=ans.get))

Submission status: Runtime Error

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

min_abs = min([abs(X-i) for i in range(1, 100+1) if not i in P])

delta, notP = [], []
for i in range(1, 101):
    if not i in P:
        delta.append(abs(X-i))
        notP.append(i)

i = delta.index(min(delta))
print(notP[i])

Submission status: Runtime Error

Solution code:
import numpy as np

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

if N != 0:
    
    p_list = [int(n) for n in input().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())
    
else:
    print(X)

Submission status: Runtime Error

Solution code:
X,N=map(int,input().split())
P=list(map(int,input().split()))
 
if N==0:
    print(X)
else:
    if X<min(P):
        ans=X
        print(ans)
    
    elif X in range(min(P),max(P)+1):
        #大した大きい数じゃないので全探索すればいい
        ans_len=200 #ひとまずの仮定
        for i in range(min(P),max(P)+1):
            if i in P:
                continue
            else:
                l=abs(X-i)
                if l < ans_len:
                    ans_len=l
                    ans=i
        print(ans)
                
    else:
        ans=X
        print(ans)

Submission status: Runtime Error

Solution code:
if n==0:
    print(x)
    quit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    quit()
p.sort()
ans=[]
#本題
for i in range(p[0],p[-1]+1):
    if i not in p:
        ans.append(i)
ans.append(100000000)
for i in range(len(ans)):
    if ans[i]>x:
        if abs(x-ans[max(i-1,0)]) <= abs(x-ans[i]):
            print(ans[max(i-1,0)])
        else:
            print(ans[i])
        quit()

Submission status: Runtime Error

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

P_ori=list(map(int,input().split()))
if P_ori.count(X)==0:
    print(X)
    exit()

P1=sorted(P_ori)
N=list(range(1,101))
PZ=[]
for i in range(len(N)):
    if P1.count(N[i])==0:
        PZ.append(N[i])

PZ.append(X)
P2=sorted(PZ)
t=P2.index(X)

dist1=abs(P2[t-1]-P2[t])
dist2=abs(P2[t]-P2[t+1])
if dist1<=dist2:
    print(P2[t-1])
else:
    print(P2[t+1])

Submission status: Runtime Error

Solution code:
X,N = map(int, input().split())
p = list(map(int, input().split()))
p = sorted(p)
lista = list(range(101))
for i in p:
    if i in lista:
        lista.remove(i)
def binary_search_find_closest(data, target):
    if len(data) == 0:
        return None
    if len(data) == 1:
        return data[0]
    min_diff = float('inf')
    imin = 0
    imax = len(data) - 1
    closest_num = None
    while imin <= imax:
        imid = imin + (imax - imin) // 2
        #　中心の左右の値と目標との差を計算する。
        if imid + 1 < len(data):
            min_diff_right = abs(data[imid+1] - target)
        if imid > 0:
            min_diff_left = abs(data[imid-1] - target)
        # 最初の差と最も最小に近い値を更新する。
        if min_diff_left < min_diff:
            min_diff = min_diff_left
            closest_num = data[imid-1]
        if min_diff_right < min_diff:
            min_diff = min_diff_right
            closest_num = data[imid+1]
        # 2分探索する。
        if data[imid] < target:
            imin = imid + 1
        elif data[imid] > target:
            imax = imid -1
        else:
            return data[imid]
    print(closest_num)
    return closest_num
binary_search_find_closest(lista,X)

Submission status: Runtime Error

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

l_num = x - 1
r_num = x + 1 
while l_num < x and r_num > x:
  if l_num not in p and r_num not in p:
    print(l_num)
    break
  elif l_num not in p:
    print(l_num)
    break
  elif r_num not in p:
    print(r_num)
    break
  l_num -= 1
  r_num += 1

Submission status: Runtime Error

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

min_abs = min([abs(X-i) for i in range(100+1) if not i in P])

delta, notP = [], []
for i in range(1, 101):
    if not i in P:
        delta.append(abs(X-i))
        notP.append(i)

i = delta.index(min(delta))
print(notP[i])

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
import sys
if n==0:
    print(x)
    sys.exit()
if n=100:
    print(0)
    sys.exit()
a=list(map(int,input().split()))
l=0
c=101
d=0

for i in range(1,101):
    for j in range(n):
        if i==a[j]:
            l=1
            break
    if l==1:
        l=0
        continue
    if abs(i-x)<c:
        c=abs(i-x)
        d=i
print(d)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
not_in_p = list(range(1,101))
for pn in p:
    if pn in not_in_p:
        not_in_p.remove(pn)
diff_p=[]
for not_in_pn in not_in_p:
    diff_p.append(abs(not_in_pn - X))
index = diff_p.index(min(diff_p))
print(not_in_p[index])