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 = map(int, input().split())
lst = []
if n > 0:
  lst = list(map(int, input().split()))
a = 100
b = 0

for i in range(0, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)

Submission status: Wrong Answer

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

for i in range(1, 102):
  if i in lst:
    continue

  if a > abs(x-i):
    a = abs(x-i)
    b = i

print(i)

Submission status: Wrong Answer

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

p_list.sort()
r = 200
answer = 101

for i in range(0, 102):
    if i in p_list:
        continue
    else:
        if r > abs(i - X):
            r = abs(i - X)
            answer = i
        else:
            print(answer)
            break

Submission status: Wrong Answer

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

p_list.sort()
r = 200
answer = 0

for i in range(0, 102):
    if i in p_list:
        continue
    else:
        if r > abs(i - X):
            r = abs(i - X)
            answer = i
        else:
            print(answer)
            break

Submission status: Wrong Answer

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

p_list.sort()
r = 200

for i in range(0, 102):
    if i in p_list:
        continue
    else:
        if r >= abs(i - X):
            r = abs(i - X)
        else:
            print(i-1)
            break

Submission status: Wrong Answer

Solution code:
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  for j in range(n):
    if slist[j]==abs(x-i):
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==abs(x+i):
      out=1
  if out !=1:
    print(x+i)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X,Y = map(int, input().split())
n = list(map(int, input().split()))

a=list(range(101))

for number in n:
    a.remove(number)

import numpy as np


def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

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

print(getNearestValue(a,X))

Submission status: Wrong Answer

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

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

n=set(n for n in range(-100,101))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)

Submission status: Wrong Answer

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

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

n=set(n for n in range(1,101))

pd=list(n-p)

min1=1000

for i in range(len(pd)):
    if abs(pd[i]-x)<abs(min1-x):
        min1=pd[i]
    elif abs(pd[i]-x)==abs(min1-x):
        min1=min(pd[i],min1)
print(min1)

Submission status: Wrong Answer

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


m = 100
ans=100

for i in  range(0,101):
    if(i in p):
        continue

    elif(abs(i-x) < m):
        m = 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:

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


    m = 100
    ans=100

    for i in  range(-100,101):
        if(i in p):
            continue

        if(abs(i-x) < m):
            m = 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:

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


    m = 100
    ans=100

    for i in  range(-1,101):
        if(i in p):
            continue

        if(abs(i-x) < m):
            m = 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:

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


    m = 100
    ans=100

    for i in  range(100):
        if(i in p):
            continue

        if(abs(i-x) < m):
            m = 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:

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


    m = 100
    ans=100

    for i in  range(100):
        if(i in p):
            continue

        if(abs(i-x) < m):
            m = 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:

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


    m = 100
    
    for i in  range(100):
        if(i in p):
            continue

        if(abs(i-x) < m):
            m = abs(i-x)
            ans = i
    
    print(ans)

Submission status: Wrong Answer

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


     
def main():
# s = input()[0:-1]
# n = int(input())
    x,n= map(int, input().split())
    p = list(map(int,input().split()))
    y = [abs(x - i) for i in p]
    ans = sorted(y)
    c = [0]*120
    for i in ans:
        c[i]+=1
    
    for i,j in enumerate(c):
        if j == 0:
            print(x+i) 
            exit()


# a = [int(input()) for i in range()]



# ab=[]
# for i in range():
#     a,b = map(int, input().split())
#     ab.append([a,b])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(-100, 100+1)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(1, 100)]
ps = list(filter(lambda i: i not in ps, pss))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
        elif mins == temp:
            if ans > p:
                ans = p

print(ans)

Submission status: Wrong Answer

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

for i in range(50):
  if not X-i in n_l:
      print(X-i)
      break
  elif not X+i in n_l:
      print(X+i)
      break
  pass

Submission status: Wrong Answer

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

for i in range(N-2):
  if n_l[i]<= X < n_l[i+1]:
    print(n_l[i])
  else:
    print(n_l[N-1])
    break

Submission status: Wrong Answer

Solution code:
def bin_search(arr,k):
    low, high = 0, n - 1
    mid=0
    while (low <= high):
        mid= low+(high-low)//2
        if arr[mid]==k:
            return mid
        if arr[mid]>k:
            high=mid-1
        else:
            low=mid+1
    return mid

x,n= map(int,input().split(' '))
if n!=0:
    arr= list(map(int,input().split(' ')))
    arr.sort()
    idx= bin_search(arr,x)

    l,r=-1,-1
    for i in range(1,idx):
        left= arr[idx-i]
        if x-left>i:
            l=(arr[idx-i+1]-1)
            break
    if l==-1:
        l=arr[0]-1
    for i in range(1,n-idx):
        right= arr[idx+i]
        if right-x>i:
            r=(arr[idx+i-1]+1)
            break
    if r==-1:
        r=arr[n-1]+1
    if (x-l)<=(r-x):
        print(l)
    else:
        print(r)
else:
    print(x)

Submission status: Wrong Answer

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

flag = 0
mv = 10000

for i in range(n):
	if (x-in_list[i])**2<mv:
		mv = math.sqrt((x-in_list[i])**2)
		flag = i+1
print(flag)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(1, 100+1)]
ps = list(filter(lambda x: x not in ps, pss))

ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(1, 100+1)]
ps = list(set(pss)-set(ps))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    ans = p
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(1,100+1)]
ps = list(set(pss)-set(ps))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(100)]
ps = list(set(pss)-set(ps))
ans = x

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
pss = [i for i in range(100)]
ps = list(set(pss)-set(ps))
ans = 0

for i, p in enumerate(ps):
    temp = abs(x-p)
    if i == 0:
        mins = temp
        ans = p
    else:
        if mins > temp:
            mins = temp
            ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
x,y = map(int, input().split())
p = list(map(int, input().split()))
ans = 100

for i in range(x+1):
    for j in [-1,+1]:
        a = x + i * j
    if p.count(a) == 0:
        print(a)
        exit(0)

Submission status: Wrong Answer

Solution code:
x,y = map(int, input().split())
p = list(map(int, input().split()))
ans = 100

for i in range(x+1):
    for j in [-1,+1]:
        a = x + i * j
    if p.count(a) == 0:
        print(a)
        break

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1

for i in range(-1, 101):
    if i == -1 or i == 0:
        temp_abs = abs(x-i)
        if n_abs > temp_abs:
            n_abs = temp_abs
            ans = i
    else:
        temp_abs = abs(x-i)
        if n_abs > temp_abs and p_list[i-1] != 1:
            n_abs = temp_abs
            ans = i
        elif n_abs == temp_abs and i < ans and p_lsit[i-1] != 1:
            n_abs = temp_abs
            ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
p = list(map(int,input().split()))
p_list = [0 for i in range(100)]
n_abs = 1000
ans = 100000

for i in p:
    p_list[i-1] = 1


for i in range(-100, 101):
    if abs(x-abs(i)) < n_abs and i > 0 and p_list[i-1] != 1:
        n_abs = abs(x-abs(i))
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

X, N = MI()
P = LI()
ans = X

if len(P) == 0:
    print(ans)
    exit()

for i in range(101):
    if X - i in P:
        ans = X - i
        break
        
    if X + i in P:
        ans = X + i
        break

print(ans)

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

X, N = MI()
P = LI()
ans = X

if len(P) == 0:
    print(ans)
    exit()

for i in range(101):
    if not i in P:
        if X - i in P:
            ans = X - i
            break
        
        if X + i in P:
            ans = X + i
            break
print(ans)

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

X, N = MI()
P = LI()
flg = 1000
ans = X

if len(P) == 0:
    print(ans)
    exit()

for i in range(101):
    if not i in P:
        if abs(X - i) < flg:
            ans = i
            flg = abs(X - i)
        
        if abs(X + i) < flg:
            ans = i
            flg = abs(X + i)

print(ans)

Submission status: Wrong Answer

Solution code:
def INT():
    return int(input())

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

def LI():
    return list(map(int, input().split()))

X, N = MI()
P = LI()
flg = 1000
ans = X

if not X in P or len(P) == 0:
    print(ans)
    exit()

for i in range(1, 100):
    if not i in P:
        if abs(X - i) < flg:
            ans = i
            flg = abs(X - i)
        
        if abs(X + i) < flg:
            ans = i
            flg = abs(X + i)

print(ans)

Submission status: Wrong Answer

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

    pn = set(int(x) for x in input().split())

    ans = 0
    i = 1
    while True:
        s, b = X - i, X + i
        if s not in pn:
            ans = s
            break
        elif b not in pn:
            ans = b
            break
        i += 1

    print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    X, _ = map(int, input().split())
    try:
        pn = [int(x) for x in input().split()]
    except EOFError:
        print(X)
        return

    ans = 0
    i = 1
    while True:
        s, b = X - i, X + i
        if s not in pn:
            ans = s
            break
        elif b not in pn:
            ans = b
            break
        i += 1

    print(ans)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

a = -1
if not p:
    print(X)
    sys.exit()

for i in range(1, 101):
    tmp_1 = X - i
    tmp_2 = X + i
    if tmp_1 not in p:
        print(tmp_1)
        sys.exit()
    elif tmp_2 not in p:
        print(tmp_2)
        sys.exit()

Submission status: Wrong Answer

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

a = -1
if not p:
    print(X)
    sys.exit()

for i in range(1, 100):
    tmp_1 = X - i
    tmp_2 = X + i
    if tmp_1 not in p:
        print(tmp_1)
        sys.exit()
    elif tmp_2 not in p:
        print(tmp_2)
        sys.exit()

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = input().split()
p.sort()
q = p[::-1]
a = x
b = x
for i in q:
  if a == int(i):
    a -= 1
for i in p:
  if b == int(i):
    b += 1 
if x - a <= b - x:
  print(a)
else:
  print(b)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
P = [int(i) for i in input().split()]
P = sorted(P)
diff = abs(x-(P[0]-1))
ans = P[0]-1
for i in range(1, 101):
  if i not in P and abs(x-i) < diff:
    diff = abs(x-i)
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
P = [int(i) for i in input().split()]
P = sorted(P)
diff = abs(x-(P[0]-1))
ans = P[0]-1
for i in range(P[0], P[-1]+1):
  if i not in P and abs(x-i) < diff:
    diff = abs(x-i)
    ans = i
print(ans)

Submission status: Wrong Answer

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

if n == 0:
    p = set([])
else:
    p = list(map(int, input().split()))
a = list(set(range(1, 201)) - set(p))
abs_diff = [abs(i - x) for i in a]
min_abs_diff = min(abs_diff)
for i, j in zip(a, abs_diff):
    if j == min_abs_diff:
        print(i)
        break

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(n):
    num = x-i
    if num not in p:
        print(num)
        exit()
    num = x+i
    if num not in p:
        print(num)
        exit()

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    x,n = map(int, input().split())
    p_list = list(map(int, input().split()))
    x_list = [i for i in range(0,101)]
    ans = 0
    min_abs = 10**3
    
    for i in p_list:
        x_list.remove(i)

    for j in x_list:
        if min_abs > abs(j-x):
            min_abs = abs(j-x)
            ans = j

    print(ans)
    
    

   
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
count=1
x,y=0,0
while True:
  if X-count not in P:
    print(X-count)
    break
  if X+count not in P:
    print(X+count)
    break
  count+=1

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
count=1
x,y=0,0
while True:
  if X+count not in P:
    x=X+count
  if X-count not in P:
    y=X-count
  if x !=0 or y !=0:
    if x==0:
      print(y)
      exit()
    elif y==0:
      print(x)
      exit()
    else:
      print(min(x,y))
      exit()
  count+=1

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    for i in range(X):
        
        if X-i not in nums:
            print(X-i)
            exit()
        
        if X+i not in nums:
            print(X+i)
            exit()

Submission status: Wrong Answer

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


diff = 10000
best = -1
for i in range(1, 201):
    if i not in P:
        d = abs(X-i)
        if diff > d:
            best = i
            diff = d
            # print(i)
print(best)

Submission status: Wrong Answer

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

set_p = set(p)

num = 2000
ans = 0
for i in range(1, 200):
    if i not in set_p:
        if num > abs(x - i):
            num = abs(x - i)
            ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
X, N, *p = map(int, read().split())
p=list(p)
 
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			#exit(0)

Submission status: Wrong Answer

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

        for i in range(100):
                if X - i not in p and X - i > 0:
                        print(X - i)
                        break
                if X + i not in p:
                        print(X + i)
                        break

Submission status: Wrong Answer

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

        for i in range(50):
                if X - i not in p:
                        print(X - i)
                        break
                if X + i not in p:
                        print(X + i)
                        break

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-101,102):
    if not i in p:
        if abs(i-X) < MIN:
            MIN = abs(i-X)
            minnum = i
print(minnum)

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-100,102):
    if not i in p:
        if abs(i-X) < MIN:
            MIN = abs(i-X)
            minnum = i
print(minnum)

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-1,102):
    if not i in p:
        if abs(X-i) < MIN:
            MIN = abs(X-i)
            minnum = i
print(minnum)

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = 101   #
minnum = 0
for i in range(-1,101):
    if not i in p:
        if abs(X-i) < MIN:
            MIN = abs(X-i)
            minnum = i
print(minnum)

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = getmax()+1   #
minnum = 0
for i in range(getmin()-1,getmax()+2):
    if not i in p:
        if abs(X-i) < MIN:
            MIN = abs(X-i)
            minnum = i
print(minnum)

Submission status: Wrong Answer

Solution code:
import sys
def getmax():
    max = 0
    for i in p:
        if i > max:
            max = i
    return max
def getmin():
    min = p[0]
    for i in p:
        if i < min:
            min = i
    return min
X,N = map(int,input().split())
if N ==0:
    print(X)
    sys.exit()
if N == 1:
    p = int(input())
    print(p)
    sys.exit()
p = list(map(int,input().split()))  #
MIN = getmax()   #
minnum = 0
for i in range(getmin()-1,getmax()+2):
    if not i in p:
        if abs(X-i) < MIN:
            MIN = abs(X-i)
            minnum = i
print(minnum)

Submission status: Wrong Answer

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

count = 1
while True:
  if N == 0:
    print(X)
    break
  if X - count not in p:
    print(X - count)
    break
  if X + count not in p:
    print(X + count)
    break
  count += 1

Submission status: Wrong Answer

Solution code:
# C - Forbidden List
X, N = map(int, input().split()) 
num_list = list(map(int, input().split())) 
for i in range(len(num_list)):
    num_list[i] = num_list[i]-X
print(num_list)
for i in range(101):
    if (-i in num_list) is False:
        print(X-i)
        break
    if (i in num_list) is False:
        print(X+i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

X,Y = list(map(int, input().split()))

YES = "Yes"  
NO = "No" 

for i in range(X+1):
    two = i
    four = X-i
    
    if 2 * two + 4 * four == Y:
        print(YES)
        sys.exit()

print(NO)

Submission status: Wrong Answer

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


z=float("inf")
ans_temp=[0,0]
ans=[0,0]

y=[i for i in range(101) if i not in p]

for i in y:
  if z>abs(x-i):
    ans[0]=abs(x-i)
    ans[1]=i
  elif z==abs(x-i):
    ans_temp[0]=abs(x-i)
    ans_temp[1]=i
    if ans_temp[1]<ans[1]:
      ans[1]=ans_temp[1]
  z=abs(x-i)
print(ans[1])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
from collections import defaultdict
import math

x, n = map(int, input().split())
P = list(map(int, input().split()))
if len(P) == 0:
    print(x)
    exit()
for i in range(x, max(P)+2):
    if i not in P:
        a = i
        break
for i in range(x, -1, -1):
    if i not in P:
        b = i
        break
print(a, b)
if abs(a-x) < abs(b-x):
    print(a)
else:
    print(b)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = {int(i) for i in input().split()}
abs_d = 0
while x in p:
    for d in {-abs_d, abs_d}:
        x += d
        if x not in p:
            print(x)
            break
    abs_d += 1

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()
  if x+i not in a:
    print(x+i)
    exit()

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
a=input().split()
for i in range(n):
  if x-i not in a:
    print(x-i)
    exit()
  if x+i not in a:
    print(x+i)
    exit()

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(x)
else:
    for i in range(1,102):
        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=list(map(int,input().split()))
if n==0:
    print(x)
else:
    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=list(map(int,input().split()))
if n==0:
    print(0)
else:
    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())

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  for j in range(0, int(n/2)+ 1):
    #print(j)
    if x-j not in p:
      print(x-j)
      break
    else:
      if x+j not in p:
        print(x+j)

Submission status: Wrong Answer

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

before = abs(0 - X)
Ans = 1
j=0
for i in range(100):
    if N == 0:
        Ans = X
        break
    if N == 100:
        Ans = 101
        break
    number = i+1
    if P[j] != number:
        dis = abs(number - X)
        # print(dis)
        if before <= dis:
            break
        before = dis
        Ans = number
    elif j < N-1:
        j +=1
print(Ans)

Submission status: Wrong Answer

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

before = abs(0 - X)
Ans = 1
j=0
for i in range(100):
    if N == 0:
        Ans = X
        break
    number = i+1
    if P[j] != number:
        dis = abs(number - X)
        # print(dis)
        if before <= dis:
            break
        before = dis
        Ans = number
    elif j < N-1:
        j +=1
print(Ans)

Submission status: Wrong Answer

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:
    i = 0
    while i<=120:
        if x - i not in p and x-i>0:
            ans = x - i
            break
        elif x + i not in p and x+i<121:
            ans = x + i
            break
        else:
            i += 1
            pass

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

for i in range(0, 100):
    a = x - i
    b = x + i

    if a >= 1 and a not in p:
        print(a)
        break
    elif b <= 100 and b not in p:
        print(b)
        break

Submission status: Wrong Answer

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

for i in range(0, 101):
    a = x - i
    b = x + i

    if a >= 1 and a not in p:
        print(a)
        break
    elif b <= 100 and b not in p:
        print(b)
        break

Submission status: Wrong Answer

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

for i in range(0, 101):
    a = x - i
    b = x + i

    if a >= 0 and a not in p:
        print(a)
        break
    elif b <= 100 and b not in p:
        print(b)
        break

Submission status: Wrong Answer

Solution code:
#coding:utf-8

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

P = [int(y) for y in input().split()]

flag = True
x = 0
count = 0

while flag:
    x = X - count
    if(x not in P):
        print("{}".format(x))
        break

    x = X + count
    if(x not in P):
        print("{}".format(x))
        break

    count += 1

    if(count == X):
        flag = False

Submission status: Wrong Answer

Solution code:
X, N = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
plus = X
minus = X
if N == 0:
    print(X)
    exit()
while True:
    plus += 1
    minus -= 1

    if minus not in array:
        print(minus)
        exit()
    if plus not in array:
        print(plus)
        exit()