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()))
s = range(1, 100)
a = [abs(i - x) for i in s]
min_ = 50000
if n == 0:
    print(x)
else:
    for i in range(99):
        if a[i] < min_ and (not i + 1 in p):
            min_ = a[i]
            ans = i + 1
    print(ans)

Submission status: Runtime Error

Solution code:
# C

import bisect

x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p_list = {int(x) for x in input().split()}
    q_list = {int(x) for x in range(101)}
    q_list = list(q_list - p_list)

    p = bisect.bisect_left(q_list, x)
    if p == 0:
        print(q_list[p])
    else:
        if abs(q_list[p-1] - x) <= abs(q_list[p] - x):
            print(q_list[p-1])
        else:
            print(q_list[p])

Submission status: Runtime Error

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


if N == 0:
    print(X)
else:
    P = list(map(int,input().split()))
    min_abs = 99999
    min_abs_list = []
    search_list = [i for i in range(1,101) if i not in P]
    
    
    
    for p in search_list:
        diff = abs(X-p)
        if diff < min_abs:
            min_abs = diff
            min_abs_list=[]
            min_abs_list.append(p)
        if diff == min_abs:
            min_abs_list.append(p)
        
    print(min(min_abs_list))

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

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

sa_min = 1000000
for i in range(1, 101):
    if i not in p_list:
        if sa_min > abs(i - x):
            sa_min = abs(i - x)
            ans = i
print(ans)

Submission status: Runtime Error

Solution code:
def resolve():
    X, N = map(int, input().split())
    P = []
    for i in range(N):
        p = int(input())
        P.append(p)
    plus = 1
    while True:
        if X in P:
            if plus%2 == 1:
                X -= plus
            else:
                X += plus
        else:
            print(X)
            exit()
        plus += 1
resolve()

Submission status: Runtime Error

Solution code:
def main():
  x,n = map(int, input().split())
  li = list(map(int, input().split()))

  if n==0:
    return x

  if x in li:
    li.pop(x)
    
  newli = ［0］*n
  for i in range(n):
    newli［i］= abs(x-li［i］)
    
  ansindex = newli.index(min(newli))
  print(li［ansindex］)
  
main()

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
P = [int(p) for p in input().split()]

is_exit = [False] * 101

for p in P:
    is_exit[p] = True

if not is_exit[X]:
    print(X)
else:
    l = X - 1
    r = X + 1
    while True:
        if not is_exit[l]:
            print(l)
            exit()
        if not is_exit[r]:
            print(r)
            exit()
        l -= 1
        r += 1

Submission status: Runtime Error

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

num = sorted([[abs(X - i),i] for i in range(1,101) if i not in P],key = lambda x: x[0])

print(num[0][1])

Submission status: Runtime Error

Solution code:
x,n=map(int,input().split())
nlist=list(map(int,input().split()))
Nlist=[]
if len(nlist)==0:
    print(x)
    exit(0)
for i in range(max(nlist)):
    if i+1 not in nlist:
        Nlist.append(i+1)
abslist=[abs(x-i) for i in Nlist]

if x+min(abslist) in Nlist:
    print(x+min(abslist))
else:
    print(x-min(abslist))

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
P = list(map(int,input().split()))
if N==0:
    print(X)
else:
    Q = [i+1 for i in range(100)]
    for pi in P:
        Q.remove(pi)
    Q1 = [abs(qi - X) for qi in Q]
    print(Q[Q1.index(min(Q1))])

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n!=0:
    p = input().split()
    p = [int(i) for i in p]

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

Submission status: Runtime Error

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    x, n = i_map()
    if n == 0:
        print(x)
        exit()
    num_list = i_list()

    num_list.sort()

    abs_num = INF
    ans_list = []

    for i in range(1,101):
        if i in num_list:
            continue
        if abs_num > abs(i-x):
            ans_list = []
            abs_num = abs(i-x)
            ans_list.append(i)
        elif abs_num == abs(i-x):
            ans_list.append(i)

    ans_list.sort()

    print(ans_list[0])

if __name__ == '__main__':
    main()

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()))
    nums = {i for i in range(1, 101)}
    nothings = nums - set(p)
    differences = {}
    for i in nothings:
        difference = abs(X - i)
        if difference in differences:
            differences[difference].append(i)
        else:
            differences[difference] = [i]
    ans = sorted(differences.items())
    print(min(ans[0][1]))

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

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

num=[i for i in range(1,101)]
for i in p:
    num[i-1]=0

num.sort()
# print(num)
min=1000
for i in num:
    if min>abs(x-i):
        min=abs(x-i)
        ans=i
print(ans)import sys
input = sys.stdin.readline

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

num=[i for i in range(1,101)]
for i in p:
    num[i-1]=0

num.sort()
# print(num)
min=1000
for i in num:
    if min>abs(x-i):
        min=abs(x-i)
        ans=i
print(ans)

Submission status: Runtime Error

Solution code:
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
hako=set(P)
P.sort()
kari=[]
if len(P)==0:
    print(100)
    exit()
if X<P[0]:
    print(X)
    exit()
if X>P[-1]:
    print(X)
    exit()
for i in range(-200,101):
    if i not in hako:
        kari.append(i)
#print(kari)
tekitpu=kari[bisect.bisect_left(kari,X)]
aho=kari[bisect.bisect_left(kari,X)-1]
#print(tekitpu,aho)
if abs(tekitpu-X)<abs(X-aho):
    print(tekitpu)
else:
    print(aho)

Submission status: Runtime Error

Solution code:
ans = None
for r in range(100):
    for i in [-r, r]:
        if (X + i) not in p:
            ans = X+i
            break

    if ans is not None:
        break


print(ans)

Submission status: Runtime Error

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

idx = p_list.index(x)

i = 0
while True:
    x_i = x - i
    x_j = x + i

    if x_i not in p_list:
        print(x_i)
        exit()
    if x_j not in p_list:
        print(x_j)
        exit()

    i += 1

Submission status: Runtime Error

Solution code:
lst = []
n = int(input())
no = int(input())
for i in range(0,no):
  inp = int(input)
  lst.append(inp)
  if inp==n:
    index = i
for i in range(1,100:
  if n-i not in lst:
    print(n-i)
    break
  if n+i not in lst:
    print(n+i)
    break

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
P = list(map(int,input().split()))
Q = [i+1 for i in range(100)]
for pi in P:
    Q.remove(pi)
Q1 = [abs(qi - X) for qi in Q]
print(Q[Q1.index(min(Q1))])

Submission status: Runtime Error

Solution code:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(1,101):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Submission status: Runtime Error

Solution code:
(X,N) = map(int,input().split())
p = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    for i in range N:
        if (X - i) not in p:
            print(X-i)
            break
        elif(X+i) not in p:
            print(X+i)
            break

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
if n!=0:
    p = input().split()
    p = [int(i) for i in p]

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

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split())
P = [int(i) for i in input().split()]
for i in range(1,100):
    if i in P:
        pass
    else:
        if abs(X-ans) > abs(X-i):
            ans = i
print(ans) if N != 0 else print(X)

Submission status: Runtime Error

Solution code:
X, N = map(int, input().split())
if N != 0:
    p = list(map(int, input().split()))
else:
    p = []

res = 10**9
MIN = res

for i in range(-100,X+1):
    if not i in p:
        x = i

for i in range(X,101):
    if not i in p:
        y = i
        break

if (X-x) == (y-X):
    print(x)
elif (X-x) > (y-X):
    print(y)
else:
    print(x)

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 = []
    B = []
    for i in range(101):
        if i not in P and i <= X:
            A.append(i)
        elif i not in P and i > X:
            B.append(i)
    A = sorted(A,reverse=True)
    B = sorted(B)
    a = abs(X - A[0])
    b = (B[0] - X)
    if a <= b:
        print(A[0])
    else:
        print(B[0])

Submission status: Runtime Error

Solution code:
def searchInsert(nums, target):
    l = 0
    r = len(nums) - 1
    while (l <= r):
        mid = (l + r) // 2
        if target == nums[mid]:
            return mid
        elif target > nums[mid]:
            l = mid + 1
        else:
            r = mid - 1
    return l
x,y=map(int,input().split())
a=set(list(map(int,input().split())))
if y==0:
    print(x)
else:
    b=[i for i in range(1,101)]
    b=set(b)
    c=list(b-a)
    t=searchInsert(c,x)

    print(min(c[t],c[t-1]))

Submission status: Runtime Error

Solution code:
X,N = map(int,input().split())
if N==0:
    print(X)
    exit()
P = [int(i) for i in input().split()]
ans = X+10
tmp = []
P2 = [int(i) for i in range(min(P),max(P)+1)]
P3 = list(set(P2)-set(P))

for i in P3:
    if ans > abs(X-i):
        ans = abs(X-i)
        tmp.append(i)
print(max(tmp))

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
if n:
    p = set(map(int,input().split()))
mini = float('inf')
ans = float('inf')
for i in range(0,110):
    if i not in p:
        if abs(x-i)<mini:
            mini = abs(x-i)
            ans = i
        elif abs(x-i)==mini and ans>i:
            ans=i
print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin

A = list(map(int,stdin.readline().split()))
B = list(map(int,stdin.readline().split()))
C = [x for x in range(1,101)]
C = set(C)
B = set(B)
C = C.difference(B)
C = list(C)
X=A[0]
N=A[1]
record=max(C)
number=0

for t in C:
    diff=abs(t-X)
    if diff<record:
        record=diff
        number=t
    elif diff==record:
        number=min(number,t)

print(number)

Submission status: Runtime Error

Solution code:
def binarySearch (arr, l, r, x): 
  
    # Check base case 
    if r >= l: 
  
        mid = l + (r - l) // 2
  
        # If element is present at the middle itself 
        if arr[mid] == x: 
            return mid 
          
        # If element is smaller than mid, then it  
        # can only be present in left subarray 
        elif arr[mid] > x: 
            return binarySearch(arr, l, mid-1, x) 
  
        # Else the element can only be present  
        # in right subarray 
        else: 
            return binarySearch(arr, mid + 1, r, x) 
  
    else: 
        # Element is not present in the array 
        return -1

l=list(map(int, input().split(' ')))

find=l[0]
n=l[1]

if n==0:
    print(find)
else:
    l=list(map(int, input().split(' ')))
    l=sorted(l)

    a=find+1
    b=find-1
    
    while True:
        if binarySearch(l, 0, n, b)==-1:
            print(b)
            break
        elif binarySearch(l, 0, n, a)==-1:
            print(a)
            break
        else:
            a+=1
            b-=1

Submission status: Runtime Error

Solution code:
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  q = list(map(int,input().split()))
  q = list(set(q))
  p = [i for i in range(-1 , 102)]
  for i in range(len(q)):
    p.remove(q[i])

  S = 100
  for i in range(len(p)):
    if abs(X - p[i]) < S :
      ans = p[i]
      S = X - ans
    elif abs(X - p[i]) == S :
      if p[i] < ans :
        ans = p[i]
  print(ans)

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000
al = []
for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Submission status: Runtime Error

Solution code:
x, n = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
a = []
for i in range(1,101):
    if i not in p:
        a.append(i)

m = []
for i in range(len(a)):
    m.append(abs(a[i] - x))

miner = min(m)
res = []
for i in a:
    if abs(x - i) == miner:
        res.append(i)

print(min(res))

Submission status: Runtime Error

Solution code:
# cook your dish here
x,n=list(map(int, input().split()))
l=list(map(int, input().split()))
l.sort()
HA=101
no=-1
for i in range(l[-1]+1):
    if i not in l:
        if abs(x-i)<HA:
            HA=abs(x-i)
            no=i
print(no)

Submission status: Runtime Error

Solution code:
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))

    P_not = np.array(list(set(list(range(1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

Submission status: Runtime Error

Solution code:
x, n = [int(i) for i in input().split()]
flag = [0 for i in range(101)]
if (n != 0):
    p = [int(i) for i in input().split()]

    for i in p:
        flag[i] = 1



for i in range(100):
    if flag[x-i] == 0:
        ans = x-i
        break

    if flag[x+i] == 0:
        ans = x+i
        break
    
print(ans)

Submission status: Runtime Error

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

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
if x in all_list:
  ans = x
else:
  abs_ = 100
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)

Submission status: Runtime Error

Solution code:
rom sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    arr = []
    for i in range(-100, 201):
        if not i in p:
            arr.append(i)
    ans = arr[0]
    for ai in arr:
        if abs(ai - x) < abs(ans - x):
            ans = ai
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Runtime Error

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:list(input())
ips=lambda:input().split()

"""========main code==============="""

a,b=ml()
n=set()
for i in range(b):
    n.add(ii())
r=0
for i in range(a,1001):
    if(i not in n):
        r=i
        break
l=0    
for i in range(a-1,-1,-1):
    if(i not in n):
        l=i
        break
if(abs(l-a)<=abs(r-a)):
    print(l)
else:
    print(r)

Submission status: Runtime Error

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p1 = [i for i in range(0,101)]
for i in p:
    if i in p1:
        p1.remove(i)
ans = 1000

for i in p1:
    if ans >= abs(i-x):
        ans = min(abs(i-x),ans)
        al.append(i)

if len(al) == 0:
    if x < 50:
        print(0)
    else:
        print(101)
elif abs(al[-1]-x) == abs(al[-2]-x):
    print(al[-2])
else:
    print(al[-1])

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

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

ps_sort = list(sorted(ps))
not_in_ps = np.array([[abs(i-X), i] for i in range(101) if i not in ps_sort])
print(not_in_ps[np.argmin(not_in_ps[:,0], 0), 1])

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:
    for i in range(1, 100-x+1):
        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:
            pass

print(ans)

Submission status: Runtime Error

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

for i in range(N):
    p[i] = int(p[i])
    
if N == 0:
    print(X)
else:    
    for i in range(1,N+1):
        if not (X+i) in p:
            print(X+i)
            break
        elif not (X-i) in p:
            print(x-i)

Submission status: Runtime Error

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    X, N = mulinputs()
    ps = set(mulinputs())

    mins = [ [] for _ in range(100)]
    
    m = INF
    for p in range(1,101):
        if p in ps:
            continue
        tmp = abs(X-p)
        if tmp < m:
            m = tmp
            mins[m].append(p)

    mins[m].sort()
    # 出力
    print(mins[m][0])

Submission status: Runtime Error

Solution code:
targ, length = map(int, input().split(' '))

banned = [False] * 100

bans = input()
if bans != '':
    for ban in bans.split(' '):
        banned[int(ban) - 1] = True

for dist in range(100):
    if banned[targ - dist - 1]:
        print(targ - dist)
        exit()
    elif banned[targ + dist - 1]:
        print(targ + dist)
        exit()

Submission status: Runtime Error

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

targets = set(range(1, 101)) - P
print(min([(target, abs(X - target)) for target in targets], key=lambda x: x[1])[0])

Submission status: Runtime Error

Solution code:
X,N=map(int,input().split())
if N==0:
  print("0")
  exit()
P=list(map(int,input().split()))
nP=[]
min=10**15
for i in range(1,101):
  if i not in P:
    nP.append(i)
anlist=[]
for i in nP:
  if min>abs(i-X):
    min=abs(i-X)
    anlist.append(i)
print(anlist[-1])

Submission status: Runtime Error

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf

def bin(arr, val):
    l,r = 0, len(arr)-1
    while l <= r:
        mid = (l + r)//2
        if arr[mid] == val: return 1
        elif arr[mid] <= val: l = mid + 1
        elif arr[mid] >= val: r = mid - 1
    return 0

x,n = imap()
p = sorted(iarr())

for i in range(n):
    a,b = x-i,x+i
    if not bin(p,a): ans = a; break
    if not bin(p,b): ans = b; break

if n==0: ans = x
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
x,n=map(int,input().split())
p=np.array(list(map(int,input().split())))
p_abs=sorted(list(map(lambda k:abs(k-x),p)))
#print(p_abs)

if(len(p_abs)==0 or p_abs[0]!=0):
    print(x)
else:
    i=1
    while(True):
        if(p_abs[2*i-1]!=i or p_abs[2*i]!=i):
            if(x-i not in p):
                print(x-i)
            else:
                print(x+i)
            break
        else:
            i+=1

Submission status: Runtime Error

Solution code:
x,n,*a=map(int,open(0).read().split())
b=[1]*101
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

Submission status: Runtime Error

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

l = list(range(1, 101))

p = list(set(l)-set(p))
sa = [abs(x - p[i]) for i in range(len(p))]
sa_min = min(sa)

for i in range(len(p)):
    if sa[i] == sa_min:
        print(p[i])
        break

Submission status: Runtime Error

Solution code:
# coding: utf-8
import sys
# from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10 ** 7)
#from heapq import heappop, heappush
#from collections import defaultdict
# import math
# from itertools import product, accumulate, combinations, product
# import bisect# lower_bound etc
#import numpy as np
# from copy import deepcopy
#from collections import deque
#import numba
#import math

def run():
    X, N = map(int, input().split())
    P = list(map(int, sysread().split()))
    exist = [False] * 101
    for p in P:
        exist[p] = True
    resid = 0

    while True:
        if not exist[X - resid]:
            print(X - resid)
            return None
        if not exist[X + resid]:
            print(X+resid)
            return None
        resid += 1


if __name__ == "__main__":
    run()

Submission status: Runtime Error

Solution code:
import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
hako=set(P)
P.sort()
kari=[]
if len(P)==0:
    print(100)
    exit()
if X<P[0]:
    print(X)
    exit()
if X>P[-1]:
    print(X)
    exit()
for i in range(101):
    if i not in hako:
        kari.append(i)
#print(kari)
tekitpu=kari[bisect.bisect_left(kari,X)]
aho=kari[bisect.bisect_left(kari,X)-1]
#print(tekitpu,aho)
if abs(tekitpu-X)<abs(X-aho):
    print(tekitpu)
else:
    print(aho)

Submission status: Runtime Error

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

all_list = [i for i in range(1,101)]
p = reversed(sorted(p))

for i in p:
  all_list.pop(i-1)
  
if x in all_list:
  ans = x
else:
  abs_ = 100
  for i in all_list:
    if abs(x - i) < abs_:
      abs_ = abs(x - i)
      ans = i

print(ans)

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split());
if n == 0:
    print(x);
else:
    a = list(map(int,input().split()));
    
    for i in range(n):
        if a.count(x-i) == 0:
            ooo = 1;
            break;
        if a.count(x+i) == 0:
            ooo = 2;
            break;
            
    if ooo == 1:
        print(x-i);
    else:
        print(x+i);

Submission status: Runtime Error

Solution code:
def resolve():
    X, N = map(int, input().split())
    P = []
    for i in range(N):
        p = int(input())
        P.append(p)
    plus = 1
    while True:
        if X in P:
            if plus%2 == 1:
                X -= plus
                plus +=1
            else:
                X += plus
                plus += 1
        else:
            print(X)
            exit()
resolve()

Submission status: Runtime Error

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

if n == 0:
    print(x)
else:
    s = set([x for x in range(102)])
    s -= set(p)
    for i in range(1,51):
        if x-i in s:
            print(x-i)
            break
        if x+i in s:
            print(x+i)
            break

Submission status: Runtime Error

Solution code:
x, n = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  print(100)
  exit()
old_diff = 100
for i in range(1, 101):
  if i in p:
    continue
  else:
    diff = abs(x-i)
    if diff < old_diff:
      ans = i
      old_diff = abs(x-i)
print(ans)