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:
X,N=[int(x) for x in input().split(" ")]
if N==0: print(X)
else:
    a=[int(x) for x in input().split(" ")]
    i=1
    res=0
    if not X in a:
        res=X
    while True:
        X+=i*(-1)**i
        if not X in a:
            res=X
            break
        i+=1
    print(res)

Submission status: Wrong Answer

Solution code:
a,b = map(float,input().split(' '))
b = b * 100
ans = int(a * b // 100)
print(ans)

Submission status: Wrong Answer

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

while True:
    if x-i not in p:
        ans = x-i
        break
    if x+i not in p:
        ans = x+i
        break
    i = i+1
    
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split()) #6,5
p = list(map(int, input().split())) #[4,7,10,6,5]
 
q = [(abs(X-i),i) for i in range(0,101) if not i in p]
q.sort()
 
print(q[0][1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
Y = list(map(int, input().split()))
x = int(X)
print(x)
for i in range(100):
    if x - i in Y:
        print(x + i)
        break
    elif x + i in Y:
        print(x - i)
        break

Submission status: Wrong Answer

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

c=[]
for ll in l:
  c.append(abs(x-ll))
print(l[c.index(min(c))])

Submission status: Wrong Answer

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

        targets = [x for x in list(range(-100, 101)) if x not in p]
        # print(f'{targets=}')
        abs_tar = [abs(x - v) for v in targets if v not in p]
        # print(f'{abs_tar=}')
        res = targets[abs_tar.index(min(abs_tar))]
        # print(f'{res=}')
    else:
        # 整数列がなにもない場合は自分自身が含まれていない最近値になる
        res = x
    print(res)


if __name__ == "__main__":
    Qc()

Submission status: Wrong Answer

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

        targets = [x for x in list(range(0, 101)) if x not in p]
        # print(f'{targets=}')
        abs_tar = [abs(x - v) for v in targets if v not in p]
        # print(f'{abs_tar=}')
        res = targets[abs_tar.index(min(abs_tar))]
        # print(f'{res=}')
    else:
        # 整数列がなにもない場合は自分自身が含まれていない最近値になる
        res = x
    print(res)


if __name__ == "__main__":
    Qc()

Submission status: Wrong Answer

Solution code:
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(1, c):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + i)
            break

Submission status: Wrong Answer

Solution code:
def main(X, N, p):
    result = None
    for i in range(max([X] + p) + 1):
        if not(i in p):
            if i <= X:
                result = i
            else:
                if (result is None) or (i - X < X - result):
                    result = i
                elif not (result is None) and (i - X >= X - result):
                    break
    print(result)


if __name__ == "__main__":
    X, N = [int(s) for s in input().split(' ')]
    input_s = input()
    p = []
    if input_s != "":
        p = [int(s) for s in input_s.split(' ')]
    main(X, N, p)

Submission status: Wrong Answer

Solution code:
def main(X, N, p):
    result = None
    for i in range(max([X] + p) + 1):
        if not(i in p):
            if i <= X:
                result = i
            else:
                if not (result is None) and (i - X < X - result):
                    result = i
                else:
                    break
    print(result)


if __name__ == "__main__":
    X, N = [int(s) for s in input().split(' ')]
    input_s = input()
    p = []
    if input_s != "":
        p = [int(s) for s in input_s.split(' ')]
    main(X, N, p)

Submission status: Wrong Answer

Solution code:
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(c):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + i)
            break

Submission status: Wrong Answer

Solution code:
def main(X, N, p):
    result = None
    for i in range(max([X] + p) + 1):
        if not(i in p):
            if i <= X:
                result = i
            else:
                if not (result is None) and (i - X < X - result):
                    result = i
                break
    print(result)


if __name__ == "__main__":
    X, N = [int(s) for s in input().split(' ')]
    input_s = input()
    p = []
    if input_s != "":
        p = [int(s) for s in input_s.split(' ')]
    main(X, N, p)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = input("").split(" ")
try:
    p = [int(i) for i in p]
    l = []
    for i in range(-100, 101):
        l.append(i)

    for i in range(N):
        if p[i] in l:
            l.remove(p[i])

    for i in range(-100, 101 - N):
        n = (X - l[i]) ** 2
        if n >= (X - l[i]) ** 2:
            print(l[i])
            break
        else:
            pass
except(ValueError):
    print(X)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = input("").split(" ")
try:
    p = [int(i) for i in p]
    l = []
    for i in range(101):
        l.append(i)

    for i in range(N):
        if p[i] in l:
            l.remove(p[i])

    for i in range(101 - N):
        n = (X - l[i]) ** 2
        if n >= (X - l[i - 1]) ** 2:
            print(l[i-1])
            break
        else:
            pass
except(ValueError):
    print(X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

from bisect import bisect_left

if N==0:
    t=X
else:
    l = bisect_left(P, X)
    for i in range(100):
        t=X-i
        if 0<=l-i and t != P[l-i]: break
        t=X+i
        if l+i < N and t != P[l+i]: break
print(t)

Submission status: Wrong Answer

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

s=set()
for i in range(101):
    s.add(i)

s=list(s-p)

a=[abs(x-i) for i in s]
print(s[a.index(min(a))])

Submission status: Wrong Answer

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

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

p.append(x)

d =100
num = 0

if n == 0:
    num = x
else:
    for i in range(102):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
print(num)

Submission status: Wrong Answer

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

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

p.append(x)

d =100
num = 0

if n == 0:
    num = x
else:
    for i in range(-1,102):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
print(num)

Submission status: Wrong Answer

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

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

p.append(x)

d =100
num = 0

if n == 0:
    num = x
else:
    for i in range(-1,101):
        if i not in p:
            d_temp = abs(x-i)
            if d_temp < d:
                d = d_temp
                num = i
print(num)

Submission status: Wrong Answer

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

dmin = 10 ** 9
ans = 0

for i in range(0, 101):
    if i not in p:
        d = (x - i) * (x - i)
        if d < dmin:
            dmin = d
            ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# Xは0~101の値になる
result = 0
current = 102
for i in range(1, 102):
    if i not in P:
        if abs(X - i) < current:
            result = i
            current = abs(X - i)
print(result)

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
# 近い順でソートできないか
# 負の数でも可なので、自分自身以外の場合は必ず二つある
# 一つあった場合はもう一方
# 一つもなかった場合は小さい方を選ぶ
P = sorted(P, key=lambda a: abs(a-X))
if N == 0 or P[0] != X:
    print(X)
else:
    # 1, 2が1ずれてるか、2, 3が2ずれてるか...と確認する
    i = 1
    print(P)
    for j in range(1, N):
        if abs(P[j] - X) != i:
            if X - i in P:
                print(X+i)
                exit()
            else:
                print(X-i)
                exit()

        if j % 2 == 0:
            i += 1
    if N % 2 == 1:
        print(X - (N+1) // 2)
    else:
        if X-N//2 in P:
            print(X+N//2)
        else:
            print(X-N//2)

Submission status: Wrong Answer

Solution code:
import io
import sys
_INPUT = """\
100 0

"""
sys.stdin = io.StringIO(_INPUT)

# ABC170
# C Forbidden List
X, N = map(int, input().split())
p = list(map(int, input().split()))
q = [-105 + i for i in range(211)]
c = 1000
for j in p:
    q.remove(j)
for k in q:
    d = X - q[k]
    if abs(d) < c:
        A = q[k]
        c = abs(d)
print(A)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
p = list(map(int, input().split()))
q = [-100 + i for i in range(201)]
c = 1000
for j in p:
    q.remove(j)
for k in q:
    d = X - q[k]
    if abs(d) < c:
        A = q[k]
        c = abs(d)
print(A)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N != 0:
  p = [int(e) for e in input().split()]
  ans = 99999999
  for i in range(1, 101):
    a = X - i
    b = X + i
    if a not in p:
      ans = min(ans, i)
    if b not in p:
      ans = min(ans, i)

  if X + ans not in p:
    if X - ans not in p:
      print(X - ans)
    else:
      print(X + ans)
else:
  print(X)

Submission status: Wrong Answer

Solution code:
def solve(x, ls):
    y = 0
    m = x
    for i in range(1, 102):
        if i in ls:
            continue
        if abs(x - i) < m:
            y = i
            m = abs(x - i)
    return y


def main(istr, ostr):
    x, n = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(x, ls)
    print(result, file=ostr)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = map(int, input().split())
p_list = sorted(list(p), reverse=False)
dist_list = list(map(lambda y: abs(y-x), p_list))
all_list = [[]]
for i in range(n):
  all_list.append([p_list[i], dist_list[i]])
del all_list[0] # appendは空に追加してしまうので最初の空を削除
sort_list = sorted(all_list, key=lambda z:(z[1],z[0]))
print(sort_list)

Submission status: Wrong Answer

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

if n == 0:
  print(x)
else :
  pn = [int(num) for num in input().split()]
  answers = {}
  for i in range(0,101):
    if not i in pn:
      answers[i] = abs(i-x)
  print(min(answers, key=answers.get))

Submission status: Wrong Answer

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

if n == 0:
  print(x)
else :
  pn = [int(num) for num in input().split()]
  answers = {}
  for i in range(0,100):
    if not i in pn:
      answers[i] = abs(i-x)
  print(min(answers, key=answers.get))

Submission status: Wrong Answer

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

for i in range(1, 101):
	if i not in p:
		not_p.append(i)
	else:
		not_p = not_p

dif = 10000
ans = 10000
for j in not_p:
	if abs(X - j) < dif:
		dif = abs(X - j)
		ans = j
	else:
		dif = dif
		ans = ans

print(ans)

Submission status: Wrong Answer

Solution code:

x,n = map(int, input().split())
if n!=0 :
    P = list(map(int, input().split()))
else:
    print(x)
    exit()

P.sort()
olp=lowp=min(P)-2
ohp=hip=max(P)+2
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        if olp<x :
            lowp=x
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )

Submission status: Wrong Answer

Solution code:

x,n = map(int, input().split())
if n!=0 :
    P = list(map(int, input().split()))
else:
    print(x)
    exit()

P.sort()
olp=lowp=min(P)-2
ohp=hip=max(P)+2
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

#print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )

Submission status: Wrong Answer

Solution code:

x,n = map(int, input().split())
if n!=0 :
    P = list(map(int, input().split()))
else:
    print(x)
    exit()

P.sort()
olp=lowp=min(P)-1
ohp=hip=max(P)+1
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

#print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

if M==0:
    print(N)
else:
    check_set=set(map(int, input().split()))
    ans_set = set([i for i in range(-1,101)])
    lst = list(ans_set-check_set)
    sorted_lst=sorted(lst)
    print(getNearestValue(sorted_lst, N))

Submission status: Wrong Answer

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

l = [i for i in range(101)]
l = list(set(l) - set(P))

print(min(l, key=lambda n: abs(X - n)))

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

if M==0:
    print(N)
else:
    check_set=set(map(int, input().split()))
    ans_set = set([i for i in range(-2,101)])
    lst = list(ans_set-check_set)
    print(getNearestValue(lst, N))

Submission status: Wrong Answer

Solution code:
N,M=map(int, input().split())
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

if M==0:
    print(N)
else:
    check_set=set(map(int, input().split()))
    ans_set = set([i for i in range(-1,101)])
    lst = list(ans_set-check_set)
    print(getNearestValue(lst, N))

Submission status: Wrong Answer

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

l = [i for i in range(1, 101)]
l = list(set(l) - set(P))

for i, v in enumerate(l):
    if v > X:
        print(l[i] if l[i]-X < X-l[i-1] else l[i-1])
        exit()

print(X)

Submission status: Wrong Answer

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

l = [i for i in range(1, 101)]
l = list(set(l) - set(P))
print(l)

for i, v in enumerate(l):
    if v > X:
        print(l[i] if l[i]-X < X-l[i-1] else l[i-1])
        exit()

print(X)

Submission status: Wrong Answer

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

l = [i for i in range(1, 101)]
l = list(set(l) - set(P))

for i, v in enumerate(l):
    if v > X:
        print(l[i] if l[i]-X < X-l[i-1] else l[i-1])
        exit()

Submission status: Wrong Answer

Solution code:
import sys

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

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

min_value = 10 ** 9
if X < p[0]:
  for x in range(-1, p[0]):
    c = abs(X - x) < abs(X - min_value)
    min_value = x if c else min_value
elif p[N-1] < X:
  for x in range(p[N-1]+1, 101):
    c = abs(X - x) < abs(X - min_value)
    min_value = x if c else min_value
else:
  s = set(p)
  for x in range(p[0], p[N-1]+1):
    if x in s:
      continue
    c = abs(X - x) < abs(X - min_value)
    min_value =x if c else min_value
  
print(min_value)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
    tmp_p = [0] * 101
if n == 0:
    print(x)
else:
    for i in range(n):
        tmp_p[p[i]] += 1
    if tmp_p[x] == 0:
        print(x)
    else:
        j = 1
        stop_min = 0
        stop_max = 0
        while stop_min == 0 or stop_max == 0:
            if x-j >= 0:
                if tmp_p[x-j] == 0:
                    print(x-j)
                    break
            else:
                stop_min += 1
            if x+j <= 100:
                if tmp_p[x+j] == 0:
                    print(x+j)
                    break
            else:
                stop_max += 1
            j += 1

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
    tmp_p = [0] * 101
if n == 0:
    print(x)
else:
    for i in range(n):
        tmp_p[p[i]] += 1
    if tmp_p[x] == 0:
        print(x)
    else:
        j = 1
        stop_min = 0
        stop_max = 0
        while stop_min == 0 or stop_max == 0:
            if x-j > 0:
                if tmp_p[x-j] == 0:
                    print(x-j)
                    break
            else:
                stop_min += 1
            if x+j <= 100:
                if tmp_p[x+j] == 0:
                    print(x+j)
                    break
            else:
                stop_max += 1
            j += 1

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
    tmp_p = [0] * 101
if n == 0:
    print(x)
else:
    for i in range(n):
        tmp_p[p[i]] += 1
    if tmp_p[x] == 0:
        print(x)
    else:
        j = 1
        while True:
            if x-j > 0:
                if tmp_p[x-j] == 0:
                    print(x-j)
                    break
            if x+j <= 100:
                if tmp_p[x+j] == 0:
                    print(x+j)
                    break
            j += 1

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))
    tmp_p = [0] * 101
if n == 0:
    print(x)
else:
    for i in range(n):
        tmp_p[p[i]] += 1
    if tmp_p[x] == 0:
        print(x)
    else:
        j = 1
        while True:
            if x-j >= 0:
                if tmp_p[x-j] == 0:
                    print(x-j)
                    break
            if x+j <= 100:
                if tmp_p[x+j] == 0:
                    print(x+j)
                    break
            j += 1

Submission status: Wrong Answer

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

i = 1
while True:
    left = x - i
    right = x + i
    if left not in p:
        print(left)
        break
    elif right not in p:
        print(right)
        break
    i += 1

Submission status: Wrong Answer

Solution code:
import sys

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

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

i = 1
while i < 103:
    left = x - i
    right = x + i
    if left not in p:
        print(left)
        sys.exit()
    elif right not in p:
        print(right)
        sys.exit()
    i += 1

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

i = 1
while i < 103:
    left = x - i
    right = x + i
    if left not in p:
        print(left)
        sys.exit()
    elif right not in p:
        print(right)
        sys.exit()
    i += 1

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

i = 1
while i < 102:
    left = x - i
    right = x + i
    if left not in p:
        print(left)
        sys.exit()
    elif right not in p:
        print(right)
        sys.exit()
    i += 1

Submission status: Wrong Answer

Solution code:
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
sa = [abs(x-q) if q not in P else float('inf') for q in range(101)]

ans,tmp = 101,float('inf')
for i,q in enumerate(sa):
    if (tmp > q):
        ans = i
        tmp = q
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = (int(i) for i in input().split())
P = [int(i) for i in input().split()]
sa = [abs(x-q) if q not in P else float('inf') for q in range(101)]

ans,tmp = 0,float('inf')
for i,q in enumerate(sa):
    if (tmp > q):
        ans = i
        tmp = q
print(ans)

Submission status: Wrong Answer

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

ans, sa = float('inf'), float('inf')
for q in range(101):
    if(abs(x - q) < sa and q not in P):
        ans = min(q, ans)
        sa = abs(x-q)
print(ans)

Submission status: Wrong Answer

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

ans, sa = 0, float('inf')
for q in range(101):
    if(abs(x - q) < sa and q not in P):
        ans = min(q, ans)
        sa = abs(x-q)
print(ans)

Submission status: Wrong Answer

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

ans, sa = 0, float('inf')
for q in range(101):
    if(abs(x - q) < sa and q not in P):
        ans = q
        sa = abs(x-q)
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(input().split())
ans = x
for i in range(n):
    if p.count(str(x - i)) and p.count(str(x + i)):
        continue
    elif p.count(str(x + i)):
        ans = x - i
        break
    elif p.count(str(x - i)):
        ans = x + i
        break
    else:
        ans = x - i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(input().split())
ans = x
for i in range(n):
    if p.count(str(x - i)) and p.count(str(x + i)):
        continue
    elif p.count(str(x + i)):
        ans = x - i
        break
    elif p.count(str(x - i)):
        ans = x + i
        break
    else:
        ans = x - i + 1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(input().split())
ans = x
for i in range(n):
    if p.count(x - i) and p.count(x + i):
        continue
    elif p.count(x + i):
        ans = x - i
        break
    elif p.count(x - i):
        ans = x + i
        break
    else:
        ans = x - i + 1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(input().split())
ans = x
for i in range(n):
    if p.count(x - i) and p.count(x + i):
        continue
    elif p.count(x - i):
        ans = x + i
        break
    elif p.count(x + i):
        ans = x - 1
        break
    else:
        ans = x - i + 1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
I=list(map(int,input().split()))
S=[]
T=[]
ans=[]
for i in range(-101,101):
    S.append(i)
    if i in I:
        S.remove(i)
for j in range(len(S)):
    if j==0:
        T.append(S[0])
    elif abs(x-S[j-1])>abs(x-S[j]):
        T.clear()
        T.append(S[j])
print(min(T))

Submission status: Wrong Answer

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

ans = 0

for i in range(int(N/2)+1):
    if not X-i in p:
        ans = X-i
        break
    if not X+i in p:
        ans = X+i
        break

print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
if n==0:
  print(x)
  quit()
p = list(map(int, input().split()))
ans = 0
for i in range(1,x+1):
  x1,x2 = x+i,x-i
  if (x1 in p) and (x2 in p):
    continue
  elif not((x1 in p) or (x2 in p)):
    ans = min(x1,x2)
    break
  elif not(x1 in p):
    ans = x1
    break
  else:
    ans = x2
    break
print(ans)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=sorted(map(int,input().split()))
ans=x
for i in range(n):
    if not (x-i) in p:
        ans=x-i
        break
    elif not (x+i) in p:
        ans=x+i
        break

print(ans)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
l=list(map(int,input().split()))
if x-1 not in l:
    print(x-1)
elif x-2 not in l:
    print(x-2)
elif x+1 not in l:
    print(x+1)
elif x+2 not in l:
    print(x+2)
else:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
ans = 0
dist = 100
for i in range(100):
    i+=1
    if not i in p:
        if abs(x-i)<dist:
            dist = abs(x-i)
            ans = i
print(ans)

Submission status: Wrong Answer

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

b=[]

for i in a:
  b.append(abs(i-x))

if len(b)!=0:
  m=min(b)
else:
  print(0)
  exit()
  
if m==0:
  for i in range(max(b)+2):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)

Submission status: Wrong Answer

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

b=[]

for i in a:
  b.append(abs(i-x))

if len(b)!=0:
  m=min(b)
else:
  print(0)
  exit()
  
if m==0:
  for i in range(1,max(a)+1):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)

Submission status: Wrong Answer

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

b=[]

for i in a:
  b.append(abs(i-x))

if len(b)!=0:
  m=min(b)
else:
  print(0)
  exit()
  
if m==0:
  for i in range(1,max(a)):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()
else:
  print(x)

Submission status: Wrong Answer

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

b=[]

for i in a:
  b.append(abs(i-x))

if len(b)!=0:
  m=min(b)
else:
  print(0)
  exit()
  
if m==0:
  for i in range(1,max(a)):
    if a.count(x-i)==0:
      print(x-i)
      exit()
    if a.count(x+i)==0:
      print(x+i)
      exit()

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
print(p)
for i in range(100):
    for j in p:
        if j == (x - i):
            break
    else:
        print(x - i)
        break
    for j in p:
        if j == (x + i):
            break
    else:
        print(x + i)
        break

Submission status: Wrong Answer

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

    ans = 0
    for i in range(101):
        if i in p:
            continue
        if abs(x - ans) > abs(x - i):
            ans = i
    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
xn = input().split()
x = int(xn[0]) #これに近い値

try:  # Nが０でないとき
    data_str = input().split()
    data_2 = []
    data = [int(s) for s in data_str] #data_strをint型に変換
    data.sort() #小さい順
    #dataにない値が出るまでxから１引き続ける　１引き続けた値をaとする
    a = x-1
    #check
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != a:
                    continue
                else:
                    a -= 1
                    break #forから抜け出す
            else:
                data_2.append(a)
                break #while2から抜け出す

        if len(data_2) == 1: #リストに１つデータが入っていたら　入ってないならwhile1ループ
            break #while1から抜け出す    


    #dataにない値が出るまでxかに１を足し続ける　１足し続けた値をbとする
    b = x + 1
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != b:
                    continue
                else:
                    b += 1
                    break #forから抜け出す
            else:
                data_2.append(b)
                break #while2から抜け出す

        if len(data_2) == 2: #リストに2つデータが入っていたら　入ってないならwhile1ループ
            break #while1から抜け出す  


    #aとbの小さい方をprint
    if abs(x-a) <= abs(b-x):
        print(a)
    else:
        print(b)
except:
    print(x)