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())
if n == 0:
    print(x);exit(0)
*p, = sorted(map(int,input().split()))
pp = set(p)
ans = 9e9
for i in range(p[0] - 1, p[-1] + 2):
    if i in pp: continue
    dis = abs(i-x)
    if dis < ans:
        xx = i
        ans = dis
        print(ans,i)
    else:
        break
print(xx)

Submission status: Wrong Answer

Solution code:

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

all = set(range(0, 101))
kouho = all - set(P)

min_dis = 200
for i in kouho:
    dis = abs(i-X)
    if min_dis > dis:
        min_i = i
        min_dis = dis

print(min_i)

Submission status: Wrong Answer

Solution code:
import sys


def read_input(trans=int):
    return list(map(trans, input().split()))


X, N = read_input()
if N == 0:
    print(X)
else:
    list_p = read_input()

    for i in range(N):
        if X-i not in list_p:
            print(X-i)
            sys.exit()

        if X+i not in list_p:
            print(X+i)
            sys.exit()

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
P = set(range(0,101)) - set(map(int,input().split()))
#print(P)
ans = 10000
l = 10000
for i in P:
    if abs(i-X) < l:
        #print(i)
        l = abs(i-X)
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

abslis = [[]for i in range(102)]*102
for n in range(N-1):
    abslis[abs(p[n]-X)].append(p[n])
if len(abslis[0]) == 0 :
    print(X)
else :
    for i in range(1,N-1):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X-i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            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()


p.sort()
min = 101
win = 101
for i in range(0, 101, 1):
  if (i in p or i == 0):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    print('sa:{}'.format(sa))
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    X, N = map(int, input().split())
    if (N > 0):
        P = list(map(int, input().split()))
        ans = 0
        abs_temp = 101

        for pi in range(-100, 102):
            n = abs(pi - X)
            if n < abs_temp and pi != X and not pi in P:
                ans = pi
                abs_temp = n
            elif n == abs_temp and pi != X and not pi in P and pi < ans:
                ans = pi
                abs_temp = n

        print(ans)

    else:
        print(X)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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


p.sort()
min = 101
win = 101
for i in range(-101, 101, 1):
  if (i in p or i == 0):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    print('sa:{}'.format(sa))
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    X, N = map(int, input().split())
    if (N > 0):
        P = list(map(int, input().split()))
        ans = 0
        abs_temp = 101

        for pi in range(0, 102):
            n = abs(pi - X)
            if n < abs_temp and pi != X and not pi in P:
                ans = pi
                abs_temp = n
            elif n == abs_temp and pi != X and not pi in P and pi < ans:
                ans = pi
                abs_temp = n

        print(ans)

    else:
        print(X)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    for i in range(0,102):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    print(differ)
    print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

abslis = [[]for i in range(102)]*102
for n in range(N):
    abslis[abs(p[n]-X)].append(p[n])
if len(abslis[0]) == 0 :
    print(X)
else :
    for i in range(1,N):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X-i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            break
# print(abslis[:10])

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
li=list(map(int,input().split()))
sa = 101
for i in range(101):
    if sa > abs(X-i) and not i in li:
        sa = abs(X-i)
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
x,n = map(int,input().split())
p = list(map(int,input().split()))
 
num_list = list(range(0,101))
y = (num_list + p)
 
counter = Counter(y)
result =  [elem for elem in y if counter[elem] < 2]
 

ans = 10 *100000000000
 
for i in result:
    temp = abs(i - x)
    if ans > temp:
        ans = temp
        res = i
print(res)

Submission status: Wrong Answer

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

    d = 1 << 30
    ans = -1
    for v in range(101):
        if v in P: continue
        diff = abs(X - v)
        if d > diff or (d == diff and ans > v):
            d = diff
            ans = v

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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


p.sort()
min = abs(x-p[0])
win = 101
for i in range(0, 101, 1):
  if (i in p):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)

Submission status: Wrong Answer

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

abslis = [[]for i in range(101)]*101
for n in range(N):
    abslis[abs(p[n]-X)].append(p[n])
if len(abslis[0]) == 0:
    print(X)
else :
    for i in range(1,N):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X-i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            break
# print(abslis[:10])

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
  
int_list = [i for i in range(102)]
forbidden_list = sorted(list(set(int_list) - set(p)))
num_X = int_list.index(X)
c = 10000000
 
if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b >= a:
      print(forbidden_list[i])
      break
    elif b < a:
      print(forbidden_list[i + 1])
      break
  else:
    if a < b:
      print(forbidden_list[i])
    else:
      print(forbidden_list[i + 1])

Submission status: Wrong Answer

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

abslis = [[]for i in range(101)]*101
for n in range(N):
    abslis[abs(p[n]-X)].append(p[n])
if len(abslis[0]) == 0:
    print(X)
else :
    for i in range(1,N):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X+i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            break
# print(abslis[:10])

Submission status: Wrong Answer

Solution code:
x,N=map(int,input().split())
p=list(map(int,input().split()))
ans=101
if x in p:
    for i in range(102):
        if i in p:
            continue
        ans=min(ans,abs(i-x))
    if x+ans in p:
        ans*=-1
else:
    ans=0
print(x+ans)

Submission status: Wrong Answer

Solution code:
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(101):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
l=list(map(int,input().split()))
tmp1=X-1
tmp2=X+1
if N==0:
    print(X)
else:
    while True:
        if  tmp1 not in l:
            print(tmp1)
            exit()
        else :
            tmp1-=1
        if  tmp2 not in l:
            print(tmp2)
            exit()
        else:
            tmp2+=1

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    for i in range(0,101):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    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()))
    a = list(range(10000000))
    ab = 10000000000
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(-1,101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Submission status: Wrong Answer

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

win = 101

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


min = abs(x-p[0])
p.sort()
for i in range(0, 101, 1):
  if (i in p):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)

Submission status: Wrong Answer

Solution code:
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
if n==0:
    print(x)
    exit(0)
ls=inp()
ls.sort()
ans=0
d=float('inf')
for i in range(1, 102):
    if i in ls:
        continue
    tmp = abs(x - i)
    if tmp < d:
        d = tmp
        ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[1] == 0:
    print(a[0])
else:
    b = list(map(int, input().split()))
    ans = 1
    out = 0
    res = abs(a[0] - ans)
    while (ans <= max(b) or abs(a[0] - ans) != res):
        if ans not in b:
            if (abs(a[0] - ans) < res):
                res = abs(a[0] - ans)
                out = ans
                if (out > max(b)):
                    break
        ans += 1
    print(out)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(-1,101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    for i in range(0,100):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    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()))
    a = list(range(10000000))
    ab = 10000000000
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N == 0 :
    print(X)
else :
    P = list(map(int,input().split()))
    a = list(range(10000000))
    ab = 101
    an = []
    for i in range(N):
        a.remove(P[i])
        a = a
    for j in range(101 - N):
        ab = min(ab,abs(X - a[j]))
    if X - ab in a :
        print(X - ab)
    elif X + ab in a:
        print(X + ab)

Submission status: Wrong Answer

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

win = 100

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


min = abs(x-p[0])
p.sort()
for i in range(1, 100, 1):
  if (i in p):
    continue

  sa = abs(i - x)
  if ( sa < min ):
    min = sa
    win = i
  elif ( sa == min ):
    if ( i > win ):
      win = win
    else:
      win = i

print (win)

Submission status: Wrong Answer

Solution code:
[X,N]=[int(i) for i in input().split()]
P=[int(i) for i in input().split()]
ans=0
k=0
for i in range(N):
  if X-i in P:
    if X+i in P:
      k=0
    else:
      ans=X+1
      break
  else:
    ans=X-1
    break
print(ans)

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    for i in range(0,100):
        if i not in P:
            differ.append(abs(X - i))
        else:
            differ.append(1000)
    ans = differ.index(min(differ))
    print(differ)
    print(ans)

Submission status: Wrong Answer

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

for i in range(101):
    a = int(x - i)
    b = int(x + i)
    if a not in p:
        print(a)
        exit()
    elif b not in p:
        print(b)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*100
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 100):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
        if j > x:
          ans = 0
      else:
        ans = A
        if j > x:
          ans = 0
      break
print(ans)

Submission status: Wrong Answer

Solution code:
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ls.sort()
if n==0:
    print(x)
    exit(0)
else:
    ans=0
    d=1000000000
    for i in range(1,102):
        if i in ls:
            continue
        tmp=abs(x-i)
        if tmp<d:
            d=tmp
            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()))
  for i in range(200):
    if i % 2 == 0:
      a = -1
    else:
        a = 1
    b = i // 2
    y = x + a*b
    if not y in p:
      if y > 0:
        print(y)
        exit()

Submission status: Wrong Answer

Solution code:
def inp():
    ls=list(map(int,input().split()))
    return ls
x,n=map(int,input().split())
ls=inp()
ls.sort()
if n==0:
    print(x)
    exit(0)
else:
    ans=0
    d=1000000000
    for i in range(1,101):
        if i in ls:
            continue
        tmp=abs(x-i)
        if tmp<d:
            d=tmp
            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()))
  for i in range(100):
    if i % 2 == 0:
      a = -1
    else:
        a = 1
    b = i // 2
    y = x + a*b
    if not y in p:
      print(y)
      exit()

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 = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  
  for i in range(N):
    not_p.remove(p[i])

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

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
p = list(map(int,input().split()))
if n == 0:
    print(x)
else:
    n_list = [i for i in range(-1,101)]
    ans = {}
    for k in n_list:
        if k not in p:
            ans[k] = abs(x-k)
    print(min(ans, key=ans.get))

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))
ans=0
if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  for i in range(0,101):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=i
  print(ans)

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 = 0
  max_val = 101
  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 = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
  print(out_num)
else:
  print(0)

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 = 0
  max_val = 101
  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 = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
  print(out_num)
else:
  out_num = 0

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))
ans=0
if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  for i in range(0,101):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=0
        ans+=i
  print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
a,b = map(int, input().split()) 

if b==0:
    print(a)
    exit()
num_list = list(map(int, input().split()))

    

num=[True]*101
#print(num)


for i in range(b):
    num[num_list[i]]=False


num[0]=False
#print(num)

count=0
min_min=100
min_max=100
i=a

#print(i)
while 1:
    if i==100:
        break
    if num[i]==True:
        min_min=i-a
        break
    i+=1
j=a


while 1:
    if j==1:
        break
    if num[j]==True:
        min_max=a-j
        break
    j-=1
#print(min_max)
#print(j)
if min_min<min_max:
    print(i)
    
else:
    print(j)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))

if y==0:
  print(x)
elif x not in nums:
  print(x)
else:
  ans=0
  for i in range(0,101):
    if i not in nums:
      if abs(x-i)<abs(x-ans):
        ans=0
        ans+=i
  print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B = map(int, input().split())
if B == 0:
    print(A)
else:
    L = list(map(int,input().split()))
    K = L.copy()
    L = [abs(i - A) for i in L]
    L = sorted(L)
    #print(L)
    X = []
    for i in range(1,B+1):
        X+=[i//2]
    if X != L:
        for i in range(B):
            if L[i] != X[i]:
                break
        s,t = A-X[i],A+X[i]
        #print(s,t)
        if (s in K) ==True:
            print(t)
        else:
            print(s)
    else:
        print(min(K) -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()

for i in range(N):
    if p.count(X - i) == 0:
        print(X - i)
        sys.exit()
    elif p.count(X + i) == 0:
        print(X + i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
  
int_list = [i for i in range(102)]
forbidden_list = list(set(int_list) - set(p))
num_X = int_list.index(X)
c = 10000000
 
if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b > a:
      print(forbidden_list[i - 1])
      break
    else:
      print(forbidden_list[i])
      break
  else:
    print(forbidden_list[-1])

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))

if y==0:
  print(x)
if x not in nums:
  print(x)
ans=0
for i in range(0,101):
  if i not in nums:
    if abs(x-i)<abs(x-ans):
      ans=0
      ans+=i
print(ans)

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 = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  print(not_p)
  for i in range(N):
    not_p.remove(p[i])

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if 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 = list(map(int,input().split()))
p = list(map(int,input().split()))

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

Submission status: Wrong Answer

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

if(m==0):
    print(n)
else:
    arr=list(map(int,input().strip().split()))
    j=n
    s1=n
    while(j>=1):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
                break
        if(flag==1):
            j=j-1
        else:
            s1=j
            break
    j=n
    s2=n
    while(j<=101):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
                break
        if(flag==1):
            j=j+1
        else:
            s2=j
            break
  

    a=abs(n-s1)
    b=abs(n-s2)
    if(a<=b):
        print(s1)
    elif(a>b ):
        print(s2)

Submission status: Wrong Answer

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

int_list = [i for i in range(102)]
forbidden_list = list(set(int_list) - set(p))
num_X = int_list.index(X)
c = 10000000

if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b > a:
      print(forbidden_list[i - 1])
      break
    else:
      print(forbidden_list[i + 1])
      break

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().strip().split())
nums = list(map(int, input().strip().split()))

if y==0:
  print(x)
ans=0
for i in range(0,101):
  if i not in nums:
    if abs(x-i)<abs(x-ans):
      ans=0
      ans+=i
print(ans)

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 = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  
  for i in range(N):
    not_p.remove(p[i])

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if 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())
P = list(map(int,input().split()))+[float("inf")]
P.sort()
k = 0
ans = 1000
for i in range(-100,101):
    if i == P[k]:
        k += 1
        continue
    if abs(i - X) < abs(ans - X):
        ans = i
print(ans)

Submission status: Wrong Answer

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

int_list = [i for i in range(102)]
forbidden_list = list(set(int_list) - set(p))
num_X = int_list.index(X)
c = 10000000

if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b > a:
      print(forbidden_list[i - 1])
      break
    else:
      print(forbidden_list[i + 1])
      break
  else:
    print(forbidden_list[-1])

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
P = list(map(int,input().split()))+[float("inf")]
P.sort()
k = 0
ans = 1000
for i in range(101):
    if i == P[k]:
        k += 1
        continue
    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:
    print(X)
    exit()
else:
    p=list(map(int,input().split()))
    A=[i for i in range(100) if i not in p]

mini=200
minip=200
for i in range(N):
    if abs(p[i]-X) <=mini:
        mini= abs(p[i]-X)
        minip=p[i]
        

minimini=200
answer=200
for a in A:
    if abs(a-minip)<minimini:
        minimini=abs(a-minip)
        answer=a

print(answer)

Submission status: Wrong Answer

Solution code:
def resolve():
	X, N = map(int, input().split())
	if N == 0:
		print(X)
	else:
		A = list(map(int, input().split()))
		Y = {}
		for y in range(-100, 100):
			if y in A:
				None
			else:
				key = int(abs(X-y))
				if key in Y.keys():
					Y[key].append(y)
				else:
					Y[key] = [y]
		key = min(Y.keys())
		print(min(Y[key]))
resolve()

Submission status: Wrong Answer

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

for i in range(1,200):
  if n[0] - i not in x:
    print(n[0] - i)
    exit()
  elif n[0] + i not in x:
    print(n[0] + i)
    exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-101, 101))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+x)

Submission status: Wrong Answer

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

if N == 0:
    print(X)
else:
    num_list = [i for i in range(-100, 101) if i != 0]

    index1 = -100
    for i in range(X-1,-1,-1):
        if i in num:
            continue
        else:
            index1 = i
            break
            
    index2 = 100
    for i in range(X+1, 101):
        if i in num:
            continue
        else:
            index2 = i
            break
            
    if abs(X - index1) > abs(X - index2):
        print(index2)
    else:
        print(index1)

Submission status: Wrong Answer

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

arr = []

if n == 0:
    print(x)
else:
    tmp = input()
    num = tmp.split(' ')
    num_li = [int(i) for i in num]
    arr.extend(num_li)
    min = x
    max = x

    for i in range(10000):
        
        min -= 1
        max += 1

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if y==0:
  print(x)
else:
  lis=list(map(int,input().split()))
  l=[]
  for i in range(0,101):
    if i not in lis:
      l.append(i)
  
  p=[]
  for i in l:
    p.append(abs(x-i))
  p=sorted(p)

  if p[0]>x:
    print(0)
  
  elif x-p[0] in l:
    print(x-p[0])
  else:
    print(p[0]+x)

Submission status: Wrong Answer

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

if(m==0):
    print(n)
else:
    arr=list(map(int,input().strip().split()))
    j=n
    s1=n
    while(j>=1):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
                break
        if(flag==1):
            j=j-1
        else:
            s1=j
            break
    j=n
    s2=n
    while(j<101):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
                break
        if(flag==1):
            j=j+1
        else:
            s2=j
            break
  

    a=abs(n-s1)
    b=abs(n-s2)
    if(a<=b):
        print(s1)
    elif(a>b ):
        print(s2)