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()]
array = [int(x) for x in input().split()]
plus = X
minus = X
if N == 0:
    print(X)
    exit()
while True:
    plus += 1
    minus -= 1

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

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
    print(plus)
    print(minus)
    if minus not in array:
        print(minus)
        exit()
    if plus not in array:
        print(plus)
        exit()

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(N)
    exit()
while True:
    plus += 1
    minus -= 1
    print(plus)
    print(minus)
    if minus not in array:
        print(minus)
        exit()
    if plus not in array:
        print(plus)
        exit()

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
while True:
    plus += 1
    minus -= 1
    if minus not in array:
        print(minus)
        exit()
    if plus not in array:
        print(plus)
        exit()

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
while True:
    if minus not in array and minus != X:
        print(minus)
        exit()
    if plus not in array and plus != X:
        print(plus)
        exit()
    plus += 1
    minus -= 1

Submission status: Wrong Answer

Solution code:
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
x,n=map(int,stdin.readline().split())
a=set(map(int,stdin.readline().split()))
if(x not in a):
    print(x)
else:
    diff=1
    while(True):
        if(x-diff not in a):
            print(x-diff)
            break
        elif(x+diff not in a):
            print(diff)
            break
        diff+=1

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
p = input()
p = p.split()
p = [int(c) for c in p]
print(p)
Y = Z = X
flug = 0
if X not in p:
    print(X)
if X in p:    
    for i in range(1,100):
        Y = Y - 1
        Z = Z + 1
        if Y not in p:
            print(Y, end = " ")
            flug = 1
        elif Z not in p:
            print(Z)
            flug = 1
        if flug == 1:
            break

Submission status: Wrong Answer

Solution code:
X,N = map(int, input().split())
p = input()
p = p.split()
p = [int(c) for c in p]
print(p)
Y = Z = X
flug = 0
if X not in p:
    print(X)
if X in p:    
    for i in range(1,100):
        Y = Y - 1
        Z = Z + 1
        if Y not in p:
            print(Y, end = " ")
            flug = 1
        if Z not in p:
            print(Z)
            flug = 1
        if flug == 1:
            break

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if(n==0):
  print(x)
  exit(0)
a=list(map(int,input().split()))
f=set(a)
mi=1000000
r=100000000
for i in range(-100,101):
  if(i in f):
    continue
  if(abs(x-i)<mi):
    mi=abs(x-i)
    r=i
print(r)

Submission status: Wrong Answer

Solution code:
xn = input().split()
X = int(xn[0])
N = int(xn[1])
A = [int(x) for x in input().split()]
li = [x for x in range(1,102)] 
li2 = list(x for x in li if x not in A )
d_tmp = 1200
ans_tmp = -1
for i in li2:
    d = abs(X-i)
    if d < d_tmp:
        d_tmp = d
        ans_tmp = i
print(ans_tmp)

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if x + df > 0 and not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df -= 1

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if df > 0 and not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df -= 1

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    if x + df > 0 and not (x + df) in lst:
        print(x + df)
        exit()
    df = -df
    df += 1

Submission status: Wrong Answer

Solution code:
x, n = map(int,input().split())
lst = set(map(int,input().split()))
df = 0
while True:
    if not (x + df) in lst: 
        print(x + df)
        exit()
    df = -df
    if not (x + df) in lst: 
        print(x + df)
        exit()
    df = -df
    df += 1

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
result = []
for i in range(101):
    if i in p:
        continue
    else:
        result.append([abs(i-x), i])
result.sort()
print(result[0][1])

Submission status: Wrong Answer

Solution code:
x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
 
for i in range(x+1):
 for s in [-1,+1]:
   a=x+s*i
   if a not in p:
     print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x + i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

Submission status: Wrong Answer

Solution code:
y,n = map(int, input().split())
list = []
list = map(int, input().split())
sum = 100
ans = 100

for i in list:
    if i > y:
        if i - y < sum:
            sum = i - y
            if ans > i:
                ans = i
    elif i < y:
        if y - i < sum:
            sum = y - i
            if ans > i:
                ans = i
    else:
        if ans > i:
            ans = i
            break

print(ans+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
  print(x)
  exit()
lst = list(map(int, input().split()))
i = 0
while True:
  if x + i not in lst:
    if x - i not in lst:
      print(x - i)
      exit()
    else:
      print(x + i)
      exit()
  i += 1

Submission status: Wrong Answer

Solution code:
def run(x, n, num_array):
    '''
    '''
    if len(num_array) == 0:
        print(x)
        return
    
    i = 1
    while True:
        if x - i not in num_array:
            print(x - i)
            return
        elif x + i not in num_array:
            print(x + i)
            return
        i += 1
        

if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    num_array = list(map(int, input().split()))
    run(x, n, num_array)

Submission status: Wrong Answer

Solution code:
def run(x, n, num_array):
    '''
    '''
    if len(num_array) == 0:
        print(x)
        return
    
    i = 1
    while True:
        if x - i not in num_array:
            print(x - i)
            return
        if x + i not in num_array:
            print(x + i)
            return
        i += 1
        

if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    num_array = list(map(int, input().split()))
    run(x, n, num_array)

Submission status: Wrong Answer

Solution code:
def run(x, n, num_array):
    '''
    '''
    if len(num_array) == 0:
        print(x)
        return
    
    i = 1
    while True:
        if x - i not in num_array:
            print(x - i)
            print('x-i: x={}, i={}'.format(x, i))
            return
        if x + i not in num_array:
            print(x + i)
            print('x+i: x={}, i={}'.format(x, i))
            return
        i += 1
        

if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    num_array = list(map(int, input().split()))
    run(x, n, num_array)

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

print(p)

for i in range(100):
    a = X - i
    if a not in p:
        print(a)
        sys.exit(0)
    a = X + i
    if a not in p:
        print(a)
        sys.exit(0)

Submission status: Wrong Answer

Solution code:
import sys

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

print(p)

for i in range(100):
    a = X - i
    if a not in p:
        print(a)
        sys.exit(0)
    a = X + i
    if a not in p:
        print(a)
        sys.exit(0)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
P = list(map(int, input().split()))
 
for i in range(X+1):
  for d in [-1, +1]:
    if not X+i*d in P:
      print(X+i*d)
      break

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

diff_prev = 10**10
for i in range(101):
    if i in P:
        continue

    diff_now = abs(X - i)
    if diff_prev <= diff_now:
        break
    else:
        diff_prev = diff_now
        i_prev = i

print(i_prev)

Submission status: Wrong Answer

Solution code:
import sys
x,n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
data = [int(i) for i in input().split()]
diffs = []
for index,val in enumerate(data):
  diffs.append(data[index] - x)
diffs = sorted(diffs)

for dif in range(100):
  if dif not in diffs:
    print(x - dif  if x - dif not in data else x + dif)
    break

Submission status: Wrong Answer

Solution code:
import sys
x,n = map(int, input().split())
if n == 0:
  print(x)
  sys.exit()
data = [int(i) for i in input().split()]
diffs = []
for index,val in enumerate(data):
  diffs.append(data[index] - x)
diffs = sorted(diffs)

for dif in range(100):
  if dif not in diffs:
    print(x - dif  if x - dif not in diffs else x + dif)
    break

Submission status: Wrong Answer

Solution code:
import numpy as np
[x, N] = list(map(int, input().split()))
if N != 0:
  P = list(map(int, input().split()))
  if x < 50:
    X = list(range(2 * x + 1))
  else:
    th = 2 * x - 101
    X = [i for i in range(th, 100)]
    P = [p for p in P if p >= th]
  X = np.delete(X, P)
  delta = [np.abs(x - p) for p in X]
  ind = delta.index(min(delta))
  ans = X[ind]
else:
  ans = x
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
L = list(map(int, input().split()))

if N not in L:
  print(N)
else:
  for i in range(N,10000000000):
    i +=1
    if i not in L:
      box = i
      break
  for j in reversed(range(-10000000000, N)):
    j -=1
    if j not in L:
      boxm = j
      break
  if (N - abs(box)) >= (N - abs(boxm)):
    print(boxm)
  else:
    print(box)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split(" "))
v = [i+1 for i in range(100)]
min_val = 100
ans_index = 0

if n != 0:
    p = list(map(int, input().split(" ")))    
    for index in p:
        v[index - 1] = 101


for v_val in v:
    if(min_val > abs(v_val - x)):
        ans_index = v_val
        min_val = min(min_val, abs(v_val - x))
    #print(abs(v_val - x), end=" ")


#print("")
print(ans_index)

Submission status: Wrong Answer

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


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

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


dist_min=N
min_value=X

#p2 = range(X+N,X-N,-1)


for i in range(X+N,X-N,-1):
	flag=False
	for j in range(N):
		if(i==p[j]):
			flag=True
	if( flag == True):
		continue
	
	
	dist = abs(X-i)
	
	if ( dist==dist_min ):
		if(i<min_value):
			min_value = i
	elif ( dist < dist_min):
		dist_min = dist
		min_value = i

print(min_value)

Submission status: Wrong Answer

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

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


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

dist_min=N
min_value=X

#p2 = range(X+N,X-N,-1)


for i in range(X+N,X-N,-1):
	flag=False
	for j in range(N):
		if(i==p[j]):
			flag=True
	if( flag == True):
		continue
	
	
	dist = abs(X-i)
	
	if ( dist==dist_min ):
		if(i<min_value):
			min_value = i
	elif ( dist < dist_min):
		dist_min = dist
		min_value = i

print(min_value)

Submission status: Wrong Answer

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


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

dist_min=1000
min_value=1000

for i in range(N):
	dist = abs(X-p[i])
	if ( dist==dist_min ):
		if(p[i]<min_value):
			min_value = p[i]
	elif ( dist < dist_min):
		dist_min = dist
		min_value = p[i]

print(min_value)

Submission status: Wrong Answer

Solution code:
def fac(l,li):
    for i in range(len(li)):
        if l-i not in li:
            return(l-i)
        if l+i not in li:
            return(l+i)

l,n = map(int,input().split())
if n>0:
    li = list(map(int,input().split()))
    print(fac(l,li))
else:
    print(l)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 15:49:43 2020

@author: naoki
"""

X,N = map(int,input().split()) # input X and N 
p = list(map(int,input().split())) # input the row of integer 
p.sort() # sorting the row "p"
p1 = [ i for i in range(-100,101)] # making the other row of integer -100<= i <= 100 
gap = 201
row = []
for i in range(N):
    p1.remove(p[i]) # removing the number which is same to p[i]

for i in p1:
    if gap >= abs(X-i):
        gap = abs(X-i)
 
num2 = X-gap
num1 = X+gap

if num1 in p1:
    print(num1)
elif num2 in p1:
    print(num2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 20 15:49:43 2020

@author: naoki
"""

X,N = map(int,input().split()) # input X and N 
p = list(map(int,input().split())) # input the row of integer 
p.sort() # sorting the row "p"
p1 = [ i for i in range(-100,101)] # making the other row of integer -100<= i <= 100 
gap = 201
row = []
for i in range(N):
    p1.remove(p[i]) # removing the number which is same to p[i]

for i in p1:
    if gap >= abs(X-i):
        gap = abs(X-i)
 
num1 = X-gap
num2 = X+gap

if num1 in p1:
    print(num1)
elif num2 in p1:
    print(num2)

Submission status: Wrong Answer

Solution code:
n = input().split()
n = [int(i) for i in n]
if not n[1] == 0:
	m = input().split()
	m = [int(i) for i in m]
else:
  	m =[0]

ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[0])
    if len(ans) > 0:
        break    
        
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    
        
print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

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

p.sort()

set_p = set(p)

up = down = X
while True:
    up = up+1
    down = down-1

    if down not in set_p:
        print(down)
        exit()
    if up not in set_p:
        print(up)
        exit()

Submission status: Wrong Answer

Solution code:
n = input().split()
n = [int(i) for i in n]
if not n[1] == 0:
	m = input().split()
	m = [int(i) for i in m]
else:
  	m =[0]

ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[0])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Wrong Answer

Solution code:
n = input().split()
n = [int(i) for i in n]
if not n[1] == 0:
	m = input().split()
	m = [int(i) for i in m]
else:
  	m =[0]

ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[1])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Wrong Answer

Solution code:
n = input().split()
n = [int(i) for i in n]
m = input().split()
m = [int(i) for i in m]
 
ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[1])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Wrong Answer

Solution code:
n = input().split()
n = [int(i) for i in n]
m = input().split()
m = [int(i) for i in m]
 
ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[1])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
        
    elif not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Wrong Answer

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


ans_1 = n[0]
ans_2 = n[0]

ans = []
while True:
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
        
    elif not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Submission status: Wrong Answer

Solution code:
import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(0, 102) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L)

Submission status: Wrong Answer

Solution code:
import sys
import operator

readline = sys.stdin.buffer.readline
a, b = map(int, readline().split())
c = set(map(int, readline().split()))

L = [(i, abs(i - a)) for i in range(1, 100) if i not in c]
L.sort(key=operator.itemgetter(1))
print(L)

Submission status: Wrong Answer

Solution code:
import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

def tester(x, y, p):
    c = []
    c.append(x)
    for i in range(y):
        c.append(int(x+(i//2+1)*(1-i%2-0.5)*-2))
    for i in range(y):
        if not(c[i] in p):
            return(c[i])
            break

def main():

    sa = input().split()
    sb = input().split()
    print (sa)
    print (sb)
    x = int(sa[0])
    y = int(sa[1])
    p = []
    for d in sb:
        p.append(int(d))
    print (tester(x,y,p))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
P=list(map(int,input().split()))
S=[0]*(102);a=1000;b=1000;c=10000
for i in range(N):
  S[P[i]]=1
#print(S)
if N==0:
  print(X)
else:
  i=X-1
  while i>=0:
    if S[i]==0:
      a=i
      break
    i=i-1
  i=X+1
  while i<=101:
    if S[i]==0:
      b=i
      break
    i=i+1
    #print(a,b)
  if abs(a-X)>abs(b-X):
    c=b
  else:
    c=a
  print(c)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
a=list(map(int,input().split()))
m=1000
idx=-1
for i in range(101):
  k=abs(x-i)
  if(i in a): continue
  else:
    if m>k:
      m=k
      idx=i
print(idx)

Submission status: Wrong Answer

Solution code:
import numpy

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

nmap = [i for i in range(0, 102)]

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

print(nmap)

for (i, v) in enumerate(pList):
  nmap[v] = 102

print(nmap)

ans = numpy.argmin(nmap)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy

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

nmap = [i for i in range(1, 101)]

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

for (i, v) in enumerate(pList):
  nmap[v-1] = 101

ans = numpy.argmin(nmap) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy
import sys
mn = sys.maxsize

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

nmap = [i for i in range(1, 101)]

for (i, v) in enumerate(pList):
  nmap[v-1] = mn

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

ans = numpy.argmin(nmap) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy

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

nmap = [i for i in range(1, 101)]

for (i, v) in enumerate(pList):
  nmap[v-1] = 101

for (i, v) in enumerate(nmap):
  nmap[i] = abs(v-x)

ans = numpy.argmin(nmap) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(x, n, p):
    S = set(p)
    for d in range(n):
        for y in [x-d, x+d]:
            if not y in S:
                return y
    return x

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

Submission status: Wrong Answer

Solution code:
def solve(x, n, p):
    S = set(p)
    for d in range(n):
        for y in [x-d, x+d]:
            if not y in S:
                return y

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

Submission status: Wrong Answer

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

hukuro = set()
p = [hukuro.add(int(x)) for x in input().split()]
for i in range(100):
    if (not X-i in hukuro) and X-i >= 1:
        print(X-i)
        exit()
    elif not X+i in hukuro and X+1 <= 100:
        print(X+i)
        exit()
print(0)

Submission status: Wrong Answer

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

hukuro = set()
p = [hukuro.add(int(x)) for x in input().split()]
for i in range(100):
    if (not X-i in hukuro) and X-i >= 1:
        print(X-i)
        break
    elif not X+i in hukuro and X+1 <= 100:
        print(X+i)
        break

Submission status: Wrong Answer

Solution code:
x = input().split()
for i in range(2):
  x[i] = int(x[i])
list = []
ans = 0
d = x[0]
if x[1] == 0:
  print(x[0])
else:
  if x[1] % 2 == 0:
    for i in range(x[1]):
      list.append(x[0]+i-x[1]/2)
    ans = x[0] + x[1]/2
  else:
    for i in range(x[1]+1):
      list.append(x[0]+i-(x[1]+1)/2)
    ans = x[0] + (x[1]+1)/2
  line = input().split()
  for i in range(x[1]):
    line[i] = int(line[i])
    if line[i] in list:
      list.remove(line[i])
  if len(list) == 0:
    print(int(ans))
  else:
    for i in list:
      if abs(x[0] - i) < d:
        ans = i
        d = x[0] - i
    print(int(ans))

Submission status: Wrong Answer

Solution code:
x = input().split()
for i in range(2):
  x[i] = int(x[i])
list = []
ans = 0
d = x[0]
if x[1] == 0:
  print(x[0])
else:
  if x[1] % 2 == 0:
    for i in range(x[1]):
      list.append(x[0]+i-x[1]/2)
    ans = x[0] + x[1]/2
  else:
    for i in range(x[1]+1):
      list.append(x[0]+i-(x[1]+1)/2)
    ans = x[0] + (x[1]+1)/2
  line = input().split()
  for i in range(x[1]):
    line[i] = int(line[i])
    if line[i] in list:
      list.remove(line[i])
  if len(list) == 0:
    print(ans)
  else:
    for i in list:
      if abs(x[0] - i) < d:
        ans = i
        d = x[0] - i
    print(int(ans))

Submission status: Wrong Answer

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

for i in range(x[1]):
    for j in [-1,1]:
        if set() == {x[0]+j*i}&y:
            print(x[0]+j*i)
            sys.exit()

Submission status: Wrong Answer

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

for i in range(x[1]):
        if set() == {x[0]-i}&y:
            print(x[0]-i)
            sys.exit()
        elif set() == {x[0]+i}&y:
            print(x[0]+i)
            sys.exit()
print(x[0])

Submission status: Wrong Answer

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

for i in range(1, x[1]):
        if set() == {x[0]-i}&y:
            print(x[0]-i)
            sys.exit()
        elif set() == {x[0]+i}&y:
            print(x[0]+i)
            sys.exit()
print(x[0])

Submission status: Wrong Answer

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

for i in range(101):
  if i in p:
    S.append(101)
  else:
    S.append(abs(i-X))
 
print(S.index(min(S)))

Submission status: Wrong Answer

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

for i in range(101):
  if i in p:
    S.append(100)
  else:
    S.append(abs(i-X))
 
print(S.index(min(S)))

Submission status: Wrong Answer

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

if x[1] == 0:
    print(x[0])
else:
    for i in range(1, x[1]):
        if set() == {x[0]-i}&y:
            print(x[0]-i)
            sys.exit()
        elif set() == {x[0]+i}&y:
            print(x[0]+i)
            sys.exit()

Submission status: Wrong Answer

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

if x[1] == 0:
    min = x[0]
else:
    for i in range(1, x[1]):
        if set() == {x[0]-i}&y:
            print(x[0]-i)
            exit()
        elif set() == {x[0]+i}&y:
            print(x[0]+i)
            exit()

Submission status: Wrong Answer

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

if x[1] == 0:
    min = x[0]
else:
    for i in range(1, x[1]):
        if (set() == {x[0]-i}&y) and (x[0]-i >= 0):
            print(x[0]-i)
            exit()
        elif set() == {x[0]+i}&y:
            print(x[0]+i)
            exit()

Submission status: Wrong Answer

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

if x[1] == 0:
    min = x[0]
else:
    for i in range(1, x[1]):
        if (set() == {x[0]-i}&y) and (x[0]-i >= 0):
            min = x[0]-i
            break;
        elif set() == {x[0]+i}&y:
            min = x[0]+i
            break;

Submission status: Wrong Answer

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

if x[1] == 0:
    min = x[0]
else:
    for i in range(1, x[1]):
        if (set() == {x[0]-i}&y) and (x[0]-i > 0):
            min = x[0]-i
            break;
        elif set() == {x[0]+i}&y:
            min = x[0]+i
            break;
    
print(min)

Submission status: Wrong Answer

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

if x[1] == 0:
    min = x[0]
else:
    for i in range(1, x[1]):
        if set() == {x[0]-i}&y:
            min = x[0]-i
            break;
        elif set() == {x[0]+i}&y:
            min = x[0]+i
            break;
    
print(min)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if N == 0:
    print(X)
else:
    i = 1
    while True:
        if X - i not in lst:
            print(X - i)
            exit()
        elif X + i not in lst:
            print(X + i)
            exit()
        i += 1

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n <= 0:
    print(x)
else:
    tbl = [0 for i in range(102)]
    data_in = input().split()
    for num in data_in:
        tbl[int(num)] = 1
    for i in range(1, 101, 1):
        if (x-i >= 0) and (tbl[x-i] == 0):
            print(x-i)
            break
        if (x+i <= 101) and (tbl[x+i] == 0):
            print(x+i)
            break

Submission status: Wrong Answer

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

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

readline = sys.stdin.readline

def proc():
    x,n = map(int, readline().rstrip().split())
    a = list(map(int, readline().rstrip().split()))
    hash_map = {}
    for i in a:
        hash_map[i] = True
    
    if not n:
        return x
    
    p,q = x-1, x+1
    while 1:
        if p not in hash_map and q not in hash_map:
            return p
        elif p not in hash_map:
            return p
        elif q not in hash_map:
            return q
        
        p-=1
        q+=1
    

#for _ in range(int(readline())):
print(proc())

Submission status: Wrong Answer

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

    ans = -1
    ans_d = 101
    for c in range(101):
        if c in p:
            continue

        if abs(x - c) < ans_d:
            ans_d = abs(x - c)
            ans = c
    
    print(ans)
    

if __name__ == "__main__":
    submit()

Submission status: Wrong Answer

Solution code:
X,N = list(map(int,input().split()))
try:
  P_i = list(map(int,input().split()))
  P_i.sort()
  not_p = [i for i in range(101) if i not in P_i]

  mins = 100
  results = []
  for n_p in not_p:
    if mins > abs(n_p-X):
      mins = abs(n_p-X)
      results.append(n_p)
  print(min(results))
except EOFError as e:
  print(X)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if x*2>y:
    print('No')
else:
  if y%2==1 :
    print('No')
  else:
    if x*4<y :
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
X,N = list(map(int,input().split()))
try:
  P_i = list(map(int,input().split()))
  P_i.sort()
  not_p = [i for i in range(101) if i not in P_i]

  mins = 100
  for n_p in not_p:
    if mins > abs(n_p-X):
      mins = abs(n_p-X)
      result = n_p
  print(result)
except EOFError as e:
  print(X)

Submission status: Wrong Answer

Solution code:
import sys

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

for d in range(X + 1):
    for s in [-1, +1]:
        a = X + s * d
        print(a," = ",X ," + ",s," * ",d)
        if p.count(a) == 0:
            print(a)
            sys.exit(0)