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: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

#a = int(input())
x, n = map(int, input().split())
try:
    p = list(map(int, input().split()))
    #s = input()
    #s,t = input().split()
    #
    #readline = sys.stdin.readline
    #n,m = [int(i) for i in readline().split()]
    #ab = [[int(i) for i in readline().split()] for _ in range(n)]

    ans = x
    ll = [x]
    lu = [x]
    i = 1

    for _ in range(n):
        if ll[-1] not in p:
            print(ll[-1])
            break
        elif lu[-1] not in p:
            print(lu[-1])
            break
        ll.append(ll[-1]-i)
        lu.append(lu[-1]+i)
except:
    print(x)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
ans1 = 999999
for i in range(101,0,-1):
    if i not in p:
        if abs(x - i) < abs(x - ans1):
            ans1 = i
print(ans1)

Submission status: Wrong Answer

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

if len(P) == 0:
    print(X)
    sys.exit()

flg = 1000
ans = 1000
m = max(P)

for i in range(m + 1):
    if not i in P and flg > abs(X - i):
        flg = abs(X - i)
        ans = i

if ans == 1000:
    ans = m + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
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())
x, n = M()
n_l = LI()
suchi_list = [i for i in range(1, 101)] # 1~100までのリスト
ans = -1
for i in n_l:
    suchi_list.remove(i)
if x in suchi_list:
    ans = x
else:
    for j in range(1, 101):
        if x+j in suchi_list:
            ans = x+j
        if x-j in suchi_list:
            ans = x-j
        if ans != -1:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

for i in range(N) :
    if X not in p :
        print(int(X))
        sys.exit()
    else :
        X = X + (i+1)* ( (-1)**((i+1) ))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    import bisect
    x,n = map(int,input().split())
    if n>0:
        p = list(map(int,input().split()))
    else:
        p = []
    d = [i for i in range(1,101)]
    for i in range(len(d)):
        if d[i] in p:
            d[i] = 0
    d = sorted(d)
    q = bisect.bisect_right(d,x)
    if q>=len(d):
        print(d[len(d)-1])
    else:
        if abs(d[q-1]-x)<=abs(d[q]-x):
            print(d[q-1])
        else:
            print(d[q])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

p = list(map(int, input().split()))
p = sorted(p)
q = [i for i in range(min(p), max(p)+1)]
r = []

for i in q:
    if i not in p:
        r.append(i)
y = 100
ans = 0

for i in r:
    if y >= abs(x-i):
        ans = i
    y = min(ans, abs(x-i))

print(ans)

Submission status: Wrong Answer

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

minv=100
v=0
if P:
  for i in range(max(P)+1):
    if not(i in P):
      if abs(X-i) < minv:
        minv=abs(X-i)
        v=i
else:
  v=X

print(v)

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    m = 1000
    n = 1000

    for i in range(201):
        c = i - 100
        d = abs(X - c)
        if c not in p:
            if d < m:
                m = d
                n = c
            elif d == m and c < n:
                n = c
    print(n)

Submission status: Wrong Answer

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

if n == 0:
    print(x)
    exit

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

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

Submission status: Wrong Answer

Solution code:

X,N=map(int,input().split())
p=[0]*N
p=list(map(int,input().split()))
mixmix=float('inf')
hozon=-1
if(p.count(X)!=1):
    print(X)
    exit()
for i in range(1,101):
    if(p.count(X-i)!=1):
        print(X+i)
        exit()
    elif(p.count(X+i)!=1):
        print(X-i)
        exit()

Submission status: Wrong Answer

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

p.sort()


ans1 = 100
ans2 = 100

flag = 1

for i in range(100):
    if x-i not in p:
        if x-i <= 100:
            ans1 = x-i
            flag = 0
    if x+i not in p:
        if x+i <= 100:
            ans2 = x+i
            flag = 0
    if flag == 0:
        break
    else:
        continue

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

x , n = map(int , input().split())
if n == 0:
	print(x)
	exit()
arr = list(map(int , input().split()))
ans = 10**10
m = max(arr) + 1
mi = 10**10
for i in range(-100 , 100):
	if i not in arr:
		if mi > abs(x-i):
			#print(abs(x-i),i)
			ans = i
			mi = abs(x-i)
		if mi == abs(x-i):
			ans = min(ans , i)
print(ans)

Submission status: Wrong Answer

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

ans = 0
tmp = float("inf")
for i in range(1, 101):
    if i not in p:
        if abs(x - i) < tmp:
            tmp = abs(x - i)
            ans = i
            print(i,tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

k,n = ip()
if n:
    x = ip()
    x = set(x)
    a = k-1
    while a in x:
        a -= 1
    b = k+1
    while b in x:
        b += 1
    if abs(a-k) < abs(b-k):
        print(a)
    elif abs(b-k) < abs(a-k):
        print(b)
    else:
        print(min(a,b))
else:
    print(k)

Submission status: Wrong Answer

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

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

    d = float("inf")
    ans = -1
    for n in reversed(range(101)):
        if not n in P and abs(X - n) <= d:
            ans = n
            d = abs(X - n)

    print(ans)

Submission status: Wrong Answer

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

else:
  a = b = x
  for i in range(100):
    a -= 1
    b += 1
    if a not in p :
      print(a)
      break
    elif b not in p:
      print(b)
      break

Submission status: Wrong Answer

Solution code:
import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = min(p)
  max_val = max(p)
  not_p = [i for i in range(min_val,max_val+1,1)]

  for i in range(N):
    not_p.remove(p[i])
  #print(not_p)

  min_val = 101
  out_num = 101
  for i in range(len(not_p)):
    if X != not_p[i] and abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
else:
  out_num = 0
print(out_num)

Submission status: Wrong Answer

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

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

s = []

for i in range(101):
    s.append(i)
    
if n != 0:
    for i in p:
        s.remove(i)

if n == 0:
    print(x)
else:
    if x in s:
        print(x)
    elif x<s[0]:
        print(s[0])
    elif x>s[-1]:
        print(s[-1])
    else:
        for i in range(len(s)-1):
            if s[i]<=x<=s[i+1]:
                if abs(x-s[i])<abs(x-s[i+1]):
                    print(s[i])
                elif abs(x-s[i])==abs(x-s[i+1]):
                    print(s[i])
                else:
                    print(s[i+1])
                break

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_left

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

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

    P.sort()

    ind=bisect_left(P,X)

    if (P[ind]!=X):
        print(X)
    else:
        left=ind-1
        right=ind+1
        leftX=X-1
        rightX=X+1

        while left>=0 or right<=N-1:
            if left>=0:
                if P[left]!=leftX:
                    print(leftX)
                    sys.exit()

            if right<=N-1:
                if P[right]!=rightX:
                    print(rightX)
                    break

            left-=1
            right+=1
            leftX-=1
            rightX+=1



if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

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

for i in range(n):
    if (x-i) not in p:
        print(x-i)
        sys.exit()
    if (x+i) not in p:
        print(x+i)
        sys.exit()

Submission status: Wrong Answer

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

ans = 0
m = float("inf")
for i in range(-100, 101):
    if i not in p:
        if abs(i-x) < m:
            ans = i
            m = abs(i-x)

print(ans)

Submission status: Wrong Answer

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


min= 1000

p.sort()

for i in range(100):
  if (i not in p ) and len(p) > 0:
    a = abs(i-X)
    if a<min:
      min=a
      ans = i

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
pp=[i for i in range(1,101)]
p=list(set(pp)-set(p))
ans=1000
z=1000
num=len(p)
for i in range(num-1,0,-1):
    a=p[i]
    if abs(x-a)<=z:
        z=abs(x-a)
        if a<ans:
            ans=a
            if ans==x:
                break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
N , M = (map(int , input().split()))
if M == 0:
    print(N)
    sys.exit()
A = list(map(int , input().split()))
aa = [i for i in range(1,101)]
ans_list = {}
for i in aa:
    if i not in A:
        ans_list.update({i:abs(N-i)})
for i in ans_list:
    if ans_list[i] == min(list(ans_list.values())):
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import math
x, n = map(int, input().split())
p = list(map(str, input().split()))
dis = {}
for i in p:
    dis[i] = True

res = -1
mins = 100
for i in range(100+1):
    if not dis.get(str(i)) and math.fabs(i - x) < mins:
        res = i
        mins = math.fabs(i - x)

print(res)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
P =list(map(int,input().split()))
ans = 100
point = 0
for i in range(101):
    if i not in P:
        if ans > abs(X-i):
            ans = abs(X-i)
            point = i
print(point)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    dif = 1
    while True:
        if not x - dif in p:
            a = x - dif
            break
        elif not x + dif in p:
            a = x + dif
            break
        dif += 1
    print(a)

Submission status: Wrong Answer

Solution code:
'''
Author : Shubhanshu Jain;
'''

import math
import random;
from collections import defaultdict 
mod =1000000007
r1 = lambda : int(input());
rm = lambda : map(int,input().split());
rms = lambda : map(str,input().split());
rls = lambda : list(rm())

def solve():
    x,n = rm();
    ls = rls();
    ar = [0]*101;
    for i in ls:
        ar[i]= 1;
    f = x;end = x;
    # ar[x]=1
    while(f>=1 or end<=100):
        if(f<=0):
            print(f);
            break;
        if(f>=1 and ar[f]==0):
            print(f);
            break;
        if(end<=100 and ar[end]==0):
            print(end);
            break;
        f-=1;
        end+=1;
            
        





def def_value(): 
	return "nan"
	
solve();

Submission status: Wrong Answer

Solution code:
def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    min = 100000
    ans = 0
    for i in range(-100,101):
        if i in p:
            pass
        elif min > abs(i-x):
            min = abs(i-x)
            ans = i
            
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))
    K = X
    L =0
    for i in range(X+1,100):
        if i in p:
            continue
        else:
            K = i-X
            L = i
            break
    for i in range(X-K,X):
        if i in p:
            continue
        else:
            L = i
    print(L)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
 
## input
 
# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
 
X,N=map(int, input().split())
if N==0:
    print(X)
    sys.exit()

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

P.sort()

tmp1 = 0
tmp2 = 0

for i in range(X,100):
    if P.count(i)==0:
        tmp1 = i
        break

j = X
while j > 0:
    if P.count(j)==0:
        tmp2 = j
        break    
    j -= 1

tmp3 = abs(X - tmp1)
tmp4 = abs(X - tmp2)

if tmp3 >= tmp4:
    print(tmp2)
else:
    print(tmp1)

Submission status: Wrong Answer

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

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

p.sort()

minp = 999
minv = x
for i in range(1, 101):
    if i in p:
        continue
    else:
        if abs(i - x) < minp:
            minp = abs(i - x)
            minv = i
        else:
            break
print(minv)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X,N=map(int, input().split())
lis = list(map(int, input().split()))
p=list(range(-N,101))
# print(p)
for i in lis:
    p.remove(i)
# print(p)
d=10000
m=10000
for i in p:
    if d > abs(X-i):
        d = abs(X-i)
        m = i
print(m)

Submission status: Wrong Answer

Solution code:

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


for i in range(1,N):
    a = X+i
    b = X-i
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break

if N==0:
    print(X)

Submission status: Wrong Answer

Solution code:
x,n  = map(int, input().split())
p = list(map(int, input().split()))
if x in p:
    diff = 1000
    index = 0
    for i in range(101):
        if i != x:
            if abs(x-i) <diff and i not in p:
                diff = x-i
                index = i
    print(index)
else:
    print(x)

Submission status: Wrong Answer

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

p = sorted(list(map(int, input().split())))
P = []

for i in range(101):
    P.append(i)


MOD = 10**9+7
tmp = 0
m = 9999999999999
ans = 0

P[0] = MOD
for i in range(N):
    P[p[i]] = MOD


for i in reversed(range(0,len(P))):
    tmp = abs(P[i]-X)
    m = min(m,tmp)
    if m == tmp:
        ans = i
print(ans)

Submission status: Wrong Answer

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 len(al) > 1:
    if abs(al[-1]-x) == abs(al[-2]-x):
        print(al[-2])
    else:
        print(al[-1])
else:
    print(al[-1])

Submission status: Wrong Answer

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

if len(P) == 0:
    print(X)
    sys.exit()

flg = 1000
ans = 0
m = max(P)

for i in range(m + 1):
    if not i in P and flg > abs(X - i):
        flg = abs(X - i)
        ans = i

if ans == 1000:
    ans = m + 1

print(ans)

Submission status: Wrong Answer

Solution code:
# abc170_c.py
X , N = map(int,input().split())
P = list(map(int,input().split()))
ans = (X,0)
for i in range(101):
    if P.count(i)==0:
        # print(abs(X-i),i,X,ans)
        if ans[0] > abs(X-i):
            ans = (abs(X-i),i)
print(ans[1])

Submission status: Wrong Answer

Solution code:
x, n = [int(i) for i in input().split()]
ps = [int(i) for i in input().split()]
ans = 0
d = 100
for i in range(1, 101):
    if i not in ps:
        tmp = abs(i-x)
        if d > tmp:
            d = tmp
            ans = i

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = 1
if len(P) > 0:
    for p in range(1, 101):
        if abs(X - p) < abs(X - a) and (p not in P):
            a = p
else:
    a = X

print(a)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
elif n == 100:
    print(0)
    exit()
p = list(map(int,input().split()))
t = list(range(-100,101))
u = set(t)-set(p)
u = list(u)
u.sort()
dif = 2**60
ans = 2**60
for a in u:
    tmp = abs(a-x)
    if dif > tmp:
        ans = a
        dif = tmp
    elif dif == tmp:
        if ans > a:
            ans = a
if x <= dif:
    ans = 0
print(ans)

Submission status: Wrong Answer

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

    l = [int(i) for i in range(100, -100, -1)]
    for i in range(n):
        l.remove(p[i])
    ans = 101
    for i in range(len(l)):
        if ans >= abs(l[i]-x):
            ans = abs(l[i]-x)
        else:
            return l[i-1]
    



print(solve())

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p_li = list(map(int,input().split()))
p_li.sort()
if p_li.count(x) == 0:
    print(x)
    exit()
dum1 = x-1
dum2 = x+1
for i in range(n):
    if p_li.count(dum1) == 0 and dum1 >= 1:
        print(dum1)
        exit()
    if p_li.count(dum2) == 0 and dum2 <= 100:
        print(dum2)
        exit()
    dum1 -= 1
    dum2 += 1

Submission status: Wrong Answer

Solution code:
#! env/bin/local python3
import sys

x, n = map(int, input().split())
try:
    p = list(map(int, input().split()))
except EOFError:
    sys.exit()

sorted_p = sorted(p)
except_p = [i for i in range(-101, 101) if i not in sorted_p]

memory_min = 1000
memory_index = None

for k, ep in enumerate(except_p):
    if abs(ep - x) < memory_min:
        memory_min = abs(ep - x)
        memory_index = k

print(except_p[memory_index])

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
P  = list(map(int,input().split()))
ans = 0
neko = float("inf")
for i in range(-100,101):
    if i in P:
        continue
    if neko > abs(i - x):
        neko = abs(i - x)
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  plist=list(map(int,input().split()))
  for i in range(1000):
    if x-i-1 not in plist:
      print(x-i-1)
      break
    elif x+i+1 not in plist and x-i-1 in plist:
      print(x+i+1)
      break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if(N==0):
    print(X)
else:
    P = [int(i) for i in input().split()]
    A = []
    for i in range(101):
        if not i in P:
            A.append([abs(X-i),i])

    A.sort()
    print(A[0][1])

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
l = []
if len(p) == 0:
    print(X)
    exit()
for i in range(-1000, max(p)):
    if not i in p:
        l.append(i)

ans_n = 1000
ans = 0
for i in range(len(l)):
    if ans_n > abs(X-l[i]):
        ans_n = abs(X-l[i])
        ans = l[i]

print(ans)

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
if len(p) == 0:
    print(x)
    exit(0)
for abs in range(n+1):
    print(f'{x} {abs}')
    if (x - abs) not in p:
        print(x-abs)
        exit(0)
    elif (x + abs) not in p:
        print(x+abs)
        exit(0)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
q=list(range(-1,101))
for i in range(n):
    q.remove(p[i])
ans=0
for i in q:
    if abs(x-i)==abs(x-ans):
        ans=min(i,ans)
    elif abs(x-i)<abs(x-ans):
        ans=i
print(ans)

Submission status: Wrong Answer

Solution code:
# print('input >>')
X, N = map(int,(input().split()))
ps = list(map(int,(input().split())))

all_num = [i for i in range(0, 101)]

for p in ps: # 10000
    all_num.remove(p)

diff = 1000
ans = 1000
anss = []

for num in all_num:
    my_diff = abs(num - X)
    if my_diff < diff:
        ans = num
        diff = my_diff

# print('-----output-----')
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-14 21:12:01 +0900
# LastModified: 2020-06-14 21:20:31 +0900
#


import os
import sys
#import numpy as np
#import pandas as pd


def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))    
    if n==0:
        print(x)
        return
 
    for i in range(1,200):
        if not x-i in p:
            print(x-i)
            return 
        if not x+i in p:
            print(x+i)
            return
            


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

    check = [True]*101

    for i in p:
        check[i] = False

    mini = 100000
    index = 1

    for i in range(1,101):
        if check[i]:
            if mini > abs(x-i):
                #print(mini, abs(x-i), i)
                mini = abs(x-i)
                index = i
    print(index)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
plis = list(map(int, input().split()))
lis = [i for i in range(101)]
for p in plis:
    lis.remove(p)
ans = float('inf')
for i in lis:
    if abs(i - X) < abs(ans-X):
        ans = i
print(ans)

Submission status: Wrong Answer

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

ans = X
if N==0:
    print(ans)
else:
    for n in range(1,100):
        if X-n >= 0 and X-n not in P:
            ans = X-n
            break
        elif X+n <= 100 and X+n not in P:
            ans = X+n
            break
    print(ans)

Submission status: Wrong Answer

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

mindiff = 1000
minval = None
for i in range(1, 100+1):
    diff = abs(X- i)
    if i not in P and diff < mindiff:
        mindiff = diff
        minval = i
print(minval)

Submission status: Wrong Answer

Solution code:
# abc170_c.py
X , N = map(int,input().split())
P = list(map(int,input().split()))
ans = (X,0)
for i in range(101):
    if P.count(i)==0:
        print(abs(X-i),i,X,ans)
        if ans[0] > abs(X-i):
            ans = (abs(X-i),i)
print(ans[1])

Submission status: Wrong Answer

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

small = x - 1
large = x + 1
while 0 <= small and large <= 100:
    if small not in p:
        print(small)
        break
    elif large not in p:
        print(large)
        break
    else:
        small -= 1
        large += 1

Submission status: Wrong Answer

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

for i in range(X):
    if (X - i) in Mylist:
        print(X-i)
    elif (X + i) in Mylist:
        print(X+i)

Submission status: Wrong Answer

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

P = list(map(int, input().split()))
candidates = [i for i in range(-1, 101)]

ans = 1000
min_diff = 1000
for c in candidates:
    if c in P:
        continue
    diff = abs(X - c)
    if diff < min_diff:
        ans = c
        min_diff = diff

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import bisect_left, bisect_right

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

X,N = LI()
P_jyogai = LI()

P = list(range(1,101))

P_difference = set(P)-set(P_jyogai)

sabun = 100000000
ans = 0
for p_diff in list(P_difference):
    temp = abs(X-p_diff)
    if sabun > temp:
        sabun = temp
        ans = p_diff
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
if N !=0:
  p = list(map(int, input().split()))
if N ==0:
  print(X)
  exit()  
if p.count(X) == 0:
  print(X)
for a in range(1000):
  if p.count(X-a) ==0:
    print(X-a)
    exit()
  elif p.count(X+a) ==0:
    print(X+a)
    exit()

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split(" "))
if n==0:
  print(x)
else:
  line=list(map(int,input().split(" ")))
  a=0
  b=1
  while a==0:
    if x-b not in line:
      min=x-b
      a=1
    elif x+b not in line:
      min=x+b
      a=1
    else:
      b=b+1
  print(min)

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
if X>=51:
    ans=101
else:
    ans=0
p=list(map(int,input().split()))
for i in range(102):
    if i in p:
        p.remove(i)
    else:
        p.append(i)
for i in range(102-N):
    if abs(X-p[i])<=abs(X-ans):
        ans=p[i]
print(ans)

Submission status: Wrong Answer

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

if n == 0:
    # input()
    print(x)
else:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if x - small > large - x:
        print(large)
    else:
        print(small)

Submission status: Wrong Answer

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

x = a[0]
n = a[1]
d = list(map(int,input().split()))

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

    max_int = d[np.argmax(d)]

    p = []
    for var in range(0,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: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

from pprint import pprint
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = list(map(int, input().split()))
    diff = INF
    res = None

    for i in range(1, 100 + 1):
        if i in P:
            continue
        if abs(x - i) < diff:
            res = i
            diff = abs(x - i)

    print(res)

Submission status: Wrong Answer

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

ans = 100000
for i in range(101):
    if not i in p:
        if abs(i - x) < abs(ans - x):
            ans = i
            
print(ans)

Submission status: Wrong Answer

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

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

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

for i in range(1,50):
    if X-i not in p:
        print(X-i)
        exit()
    elif X+i not in p:
        print(X+i)
        exit()

print(X)

Submission status: Wrong Answer

Solution code:
X,N = map(int,(input().split()))
p = list(map(int,(input().split())))
ans = []
for i in range(0,102):
    if i not in p:
        m = abs(i-X)
        ans.append((m,i))
ans.sort()
print(ans)
print(ans[0][1])