TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
x, n, *P = map(int, open(0).read().split())
A = list(range(102))
P = set(P)
B = []
m = 10**4
for a in A:
    if a not in P:
        if abs(x-a) < m:
            m = abs(x-a)
            B.append((m, a))
print(min([k for v, k in B if v == B[0][0]]))

x, n, *P = map(int, open(0).read().split())
P = set(P)
for i in range(51):
    Q = {x-i, x+i} - P
	if Q:
		print(min(Q))
		break

x, n, *P = map(int, open(0).read().split())
P = set(P)
for i in range(51):
    Q = {x-i, x+i} - P
    if Q:
        print(min(Q))
        break

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
xn = input().split()
data = input().split()
data_2 = []

x = xn[0] 
data.sort() 



a = x-1
while True:
    #check
    for i in range(len(data)):
        if data[i] == a:
            a = a - 1
            break
        else:
            data_2.append(a)
            break
    if a == data_2[0]:
        break


b = x + 1
while True:
    #check
    for i in range(len(data)):
        if data[i] == a:
            a = a + 1
            break
        else:
            data_2.append(a)
            break
    if b == data_2[1]:
        break


if a < b:
    print(a)
else:
    print(b)

xn = input().split()
data_2 = []
x = int(xn[0]) 

if int(xn[1]) == 0:
    print(x)
else:
    data_str = input().split()
    data = [int(s) for s in data_str] 
    
    
    a = int(xn[0])
    #check
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != a:
                    continue
                else:
                    a -= 1
                    break 
            else:
                data_2.append(a)
                break 

        if len(data_2) == 1: 
            break 


    
    b = int(xn[0])
    while True: #while1
        while True: #while2
            for i in range(len(data)):
                if data[i] != b:
                    continue
                else:
                    b += 1
                    break 
            else:
                data_2.append(b)
                break 

        if len(data_2) == 2: 
            break 


    
    if abs(x-a) <= abs(b-x):
        print(a)
    else:
        print(b)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()

p = np.array(list(map(int, input().split())))
for i in range(100):
    if not x-i in p:
        print(x-i)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()

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

p = list(map(int, input().split()))
for i in range(100):
    if not x-i in p:
        print(x-i)
        exit()
    elif not x+i in p:
        print(x+i)
        exit()


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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


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 :
    # if len(abslis[1])==0:
    #     print()
    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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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

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

        if min not in arr:
            print(min)
            break

        if max not in arr:
            print(max)
            break
                
        min -= 1
        max += 1

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
A = list(map(int, input().split()))
if N == 0:
  print(X)
else:
    while X in A:
        if X + 1 is A:
            print(X+2)
        elif X-1 is A:
            print(X+1)

X, N = map(int, input().split())
A = list(map(int, input().split()))
if N == 0:
  print(X)
else:
    while X in A:
        if X + 1 in A:
            print(X+2)
        elif X-1 in A:
            print(X+1)

x, y = map(int, input().split())
p = list(map(int, input().split()))
if x not in p:
  print(x)
else:
  d = 1
  while True:
    if x - d not in p:
      print(x - d)
      break
    if x + d not in p:
      print(x + d)
      break
    d += 1

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N = map(int,input().split())
P = list(map(int,input().split()))


P_n = [i for i in range(105) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(0,110,1) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(109) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(1,110,1) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(110) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(101) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

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


P_n = [i for i in range(102) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
p_list = [int(i) for i in input().split()]

if N == 0:
    print(X)
else:
    check_list = []
    for i in range(1, 105+1):
        check_list.append(X-i)
        check_list.append(X+i)
    
    print(check_list)

    for el in check_list:
        if el not in p_list:
            break

    print(el)

X, N = map(int, input().split())
p_list = [int(i) for i in input().split()]

if N == 0:
    print(X)
elif X not in p_list:
    print(X)
else:
    check_list = []
    for i in range(1, 105+1):
        check_list.append(X-i)
        check_list.append(X+i)

    for el in check_list:
        if el not in p_list:
            break

    print(el)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
p = list(map(int, input().split()))

candidates = []

x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x += 1
x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x -= 1

print(min(candidates))


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

candidates = []

x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x += 1
x = X
while(True):
    if not x in p:
        candidates.append(x)
        break
    else:
        x -= 1

if abs(X-candidates[0]) == abs(X-candidates[1]):
    print(min(candidates))
elif abs(X-candidates[0]) > abs(X-candidates[1]):
    print(candidates[1])
else:
    print(candidates[0])


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n=map(int,input().split())
a=list(map(int,input().split()))

i=0

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

import sys

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

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

if x not in p:
    print(x)
    sys.exit()
    
q=list(i for i in range(p[0]-1,p[-1]+2))

for i in p:
    q.remove(i)

ans=[]
c=x+n
for i in q:
    if c>abs(x-i):
        c=abs(x-i)
        ans.clear()
        ans.append(i)
    if c==abs(x-i):
        ans.append(i)

print(min(ans))

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*100
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,50):
        if(list_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(list_io[(x-1)+i] == 0):
            print(x+i)
            break



x,n = map(int,input().split())
nump = list(map(int,input().split()))
nump.sort()
x_ind = -1
nump_io = [0]*103
for i in range(n):
    nump_io[nump[i]-1] = 1
    if(nump[i]==x):
        x_ind = i
if(x_ind == -1):
    print(x)
else:            
    for i in range(1,51):
        if(nump_io[(x-1)-i] == 0):
            print(x-i)
            break
        if(nump_io[(x-1)+i] == 0):
            print(x+i)
            break
# print(nump_io)



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

not_in_p = [i for i in range(0, 102) if i not in p]
nip_temp = list(map(lambda s: abs(x - s), not_in_p))

address = nip_temp.index(min(nip_temp))
print(p[address])


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)

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(abs(x-i))
    else:
        not_in_p.append(102)

address = not_in_p.index(min(not_in_p))
print(not_in_p[address])

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(i)
    else:
        not_in_p.append(102)

address = not_in_p.index(min(not_in_p))
print(not_in_p[address])

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

p.sort()
pMax = max(p)
not_in_p = [-1]
for i in range(102):
    if i not in p:
        not_in_p.append(i)

j = 0
for k in not_in_p:
    if k - x == 0:
        print(k)
        sys.exit()

    else:
        not_in_p[j] -= x
    j += 1


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

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(i)

nip_temp = []
for i in not_in_p:
    nip_temp.append(abs(x-i))

address = nip_temp.index(min(nip_temp))
print(not_in_p[address])


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_100 = list(range(1, 101))

for num in num_list:
    numbers = num_100.remove(num)

numbers1 = np.array(numbers)
numbers2 = numbers - x
numbers3 = np.abs(numbers)
min_index = numbers.argmin()
print(numbers1[min_index])

import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_list = sorted(num_list)
num_100 = list(range(1, 101))

for num in num_list:
    numbers = num_100.remove(num)

numbers1 = np.array(numbers)
numbers2 = numbers - x
numbers3 = np.abs(numbers)
min_index = numbers.argmin()
print(numbers1[min_index])

import numpy as np
x, n = map(int, input().split())
num_list = list(map(int,input().split()))
num_list = sorted(num_list)
num_100 = list(range(-100, 102))

if n ==0:
    print(x)
else:
 for num in num_list:
     num_100.remove(num)

 numbers1 = np.array(num_100)
 numbers2 = numbers1 - x
 numbers3 = np.abs(numbers2)
 min_index = numbers3.argmin()
 print(numbers1[min_index])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
X,N = map(int, input().split())
if N ==0:
  print(X)
  exit() 
if N ==0:
  print(X)
  exit() 
if p.count(X) == 0:
  print(X)
  exit()
for a in range(1000):
  if p.count(X-a) ==0:
    print(X-a)
    exit()
  elif p.count(X+a) ==0:
    print(X+a)
    exit()


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


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)


import sys
readline=sys.stdin.readline

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

x = X
while x in P:
  x -= 1
minX = x

x = X
while x in P:
  x += 1
maxX=x

if abs(minX - X) <= abs(maxX - X):
  print(minX)
else:
  print(maxX)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
lists = list(input().split())
for i in range(n):
  lists[i] = int(lists[i])
for i in range(n):
  lists[i] = lists[i] - x
loop = True
number = x
while True:
  if number in lists:
    number = number - 1
  else:
    break
number_2 = x
while True:
  if number in lists:
    number = number + 1
  else:
    break
if abs(number - x) > abs(number_2 - x):
  print(number_2)
else:
  print(number)

x, n = map(int, input().split())
lists = list(input().split())
for i in range(n):
  lists[i] = int(lists[i])
loop = True
number = x
while True:
  if number in lists:
    number = number - 1
  else:
    break
number_2 = x
while True:
  if number_2 in lists:
    number_2 = number_2 + 1
  else:
    break
if abs(number - x) > abs(number_2 - x):
  print(number_2)
elif abs(number - x) == abs(number_2 - x):
  print(number)
else:
  print(number)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):


x, n = map(int, input().split())
try:
	p_li = list(map(int, input().split()))
except:
	print(x)
	exit()

for i in range(1000):
	
	if not((x - i) in p_li):
		print(x - i)
		break
	
	if not((x - i) in p_li):
		print(x - i)
		break

x, n = map(int, input().split())
try:
	p_li = list(map(int, input().split()))
except:
	print(x)
	exit()

for i in range(100000):
	
	if not((x - i) in p_li):
		print(x - i)
		break
	
	if not((x + i) in p_li):
		print(x + i)
		break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
X,N = map(int,input().split())
zettai = 10000
ans = 0
if N == 0:
    print(X)
    sys.exit()
    
a = list(map(int,input().split()))

print(a)

for i in range(101,1,-1):
    b = abs(X-i)
    if i in a:
        continue
    elif b <= zettai:
        zettai = b
        ans = i

print(ans)

import sys
X,N = map(int,input().split())
zettai = 10000
ans = 0
if N == 0:
    print(X)
    sys.exit()
    
a = list(map(int,input().split()))



for i in range(102,-1,-1):
    b = abs(X-i)
    if i in a:
        continue
    elif b <= zettai:
        zettai = b
        ans = i

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    print(n_lis)
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort()
print(P)

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

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

print(X)

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

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x,y=map(int,input().split())
a=0
s=0
if y/x>=2:
    for i in range(x+1):
        for k in range(x-i+1):
            a=4*i+2*k

            if a==y:
                s+=1
else:pass

if s>=1:
    print("Yes")

else:
    print("No")


x,n=map(int,input().split())
import sys

if n>=1:
    p=list(map(int,input().split()))
else:
    print(x)
    sys.exit()
s=[]
d={}
l={}
for i in range(-105,200):
    if i not in p:
        s.append(i)


for k in s:

    d[k]=abs(x-k)


l=[m[0] for m in d.items() if m[1]==min(d.values())]
print(min(l))


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X, N = map(int, input().split())
judge = 102*[1]
if N==0: # if n == 0 exit
	print(X)
	exit()
 
P = list(map(int, input().split())) # peratte the p into a list
for i in range(N):
	judge[P[i]] = 0
 
upcnt = 0 # initalize the count
while judge[X+upcnt]==0:
	upcnt+=1 #increament the count
 
downcnt = 0

# Time complixity O(N)

X, N = map(int, input().split())        #asking for input
p = list(map(int, input().split()))     #asking for input
for d in range(X + 1):                  #doing loop
    for s in [-1, +1]:
        a = X + s * d
        if p.count(a) == 0:
             print(a)
             exit(0)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(map(int,P.split())),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

if N == 100:
  if X <=50:
    ans = 0
  else:
    ans = 101
else:
  for i in range(100,-1,-1):
    #print(i,min_val,min_val)
    if not i in P:
      if abs(X-i) <= min_diff and min_val >i:
      	min_diff = abs(X-i)
      	min_val = i
  ans = min_val
print(ans)

X,N,*P = map(int,open(0).read().split())
if P != []:
  P = sorted(list(P),reverse=True)
else:
  print(X)
  exit()

min_diff = 101
min_val = 101

for i in range(101,-1,-1):
  #print(i,min_val,min_val)
  if not i in P:
    if abs(X-i) <= min_diff and min_val >=i:
      min_diff = abs(X-i)
      min_val = i
  ans = min_val
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
X,N=map(int, input().split())
p=list(map(int,input().split()))
p.sort()    
for k in range(0,51):
    if not X-k in p:
        print(X-k)
        break 
    elif not X+k in p_list:
        print(X+k)
        break

X,N=map(int, input().split())
p=list(map(int,input().split()))   
if N==0:
    print(X)
else:
    for k in range(0,58):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p_list:
            print(X+k)
            break

X,N=map(int, input().split())
p=list(map(int,input().split()))
p.sort()    
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p_list:
            print(X+k)
            break

X,N=map(int, input().split())
p=list(map(int,input().split()))
p.sort()    
for k in range(0,51):
    if not X-k in p:
        print(X-k)
        break 
    elif not X+i in p_list:
        print(X+i)
        break
        

X,N=map(int, input().split())
p=list(map(int,input().split()))   
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p_list:
            print(X+k)
            break

X,N=map(int, input().split())
p=list(map(int,input().split()))   
if N==0:
    print(X)
else:
    for k in range(0,51):
        if not X-k in p:
            print(X-k)
            break 
        elif not X+k in p:
            print(X+k)
            break

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x,n  = map(int,input().split())
if(n==0):
    print(x)
    return

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i

print(ans)

def resolve():
x,n  = map(int,input().split())
if(n==0):
    print(x)
    exit

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

l = list(range(min(p),max(p)+1))

rl =  set(l) - set(p)
m = max(p)
for i in  rl:
    if(abs(i-x) < m):
        m = abs(i-x)
        ans = i
print(ans)

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


m = 100
ans=100

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

    elif(abs(i-x) < m):
        m = abs(i-x)
        ans = i

print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, n = input().split(' ')
line = input()
if line == '':
    print(x)
    exit()

x = int(x)

alist = line.split(' ')
for i in range(int(n)):
    alist[i] = int(alist[i])
if not x in alist:
    print(x)
    exit()

blist = [i for i in range(1,101)]
bset = set(blist)
aset = set(alist)
cset = bset-aset
clist = list(cset)
clist.append(x)
clist.sort()

count = 0
for i,v in enumerate(alist):
    if v == int(x):
        count = i
if count == 0:
    print(alist[1])
elif count == 99:
    print(alist[-2])
else:
    minx = x - alist[count-1]
    maxx = alist[count+1]-x
    if minx > maxx:
        print(alist[count+1])
    else:
        print(alist[count-1])

x, n = input().split(' ')
line = input()
if line == '':
    print(x)
    exit()

x = int(x)

alist = line.split(' ')
for i in range(int(n)):
    alist[i] = int(alist[i])
if not x in alist:
    print(x)
    exit()

blist = [i for i in range(1,101)]
bset = set(blist)
aset = set(alist)
cset = bset-aset
clist = list(cset)
clist.append(x)
clist.sort()

count = 0
for i,v in enumerate(clist):
    if v == x:
        count = i
        print(len(clist),i,v,x)
if count == 0:
    print(clist[1])
elif count == len(clist)-1:
    print(clist[-2])
else:
    minx = x - clist[count-1]
    maxx = clist[count+1]-x
    if minx > maxx:
        print(clist[count+1])
    else:
        print(clist[count-1])

x, n = input().split(' ')
line = input()
if line == '':
    print(x)
    exit()

x = int(x)

alist = line.split(' ')
for i in range(int(n)):
    alist[i] = int(alist[i])
if not x in alist:
    print(x)
    exit()

blist = [i for i in range(0,102)]
bset = set(blist)
aset = set(alist)
cset = bset-aset
clist = list(cset)
clist.append(x)
clist.sort()

count = 0
for i,v in enumerate(clist):
    if v == x:
        count = i
if count == 0:
    print(clist[1])
elif count == len(clist)-1:
    print(clist[-2])
else:
    minx = x - clist[count-1]
    maxx = clist[count+1]-x
    if minx > maxx:
        print(clist[count+1])
    else:
        print(clist[count-1])

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x,n = map(int,input().split())
P = list(map(int,input().split()))


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    #print(diff,diff_now)
    memo = diff_now
    
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
#print(k_list)
int(max(k_list))

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


all_l = [i for i in range(1,101)]
for p in P:
    all_l.remove(p)

ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    #print(diff,diff_now)
    memo = diff_now
    
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
#print(k_list)
max(k_list)

#c
x,n = map(int,input().split())
p_list = list(map(int,input().split()))

dis = 1000
for i in range(-100,102):
    if i not in p_list:
        sub = abs(x-i)
        dis = min(dis,sub)
            
if x-dis in p_list:
    print(x+dis)
else:
    print(x-dis)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

def run(x, n, num_array):
    '''
    '''
    if len(num_array) == 0:
        print(x)
        return
    
    i = 0
    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)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
a = list(map(int,input().split()))
x = a[0]
n = a[1]
if n>0:
  b = list(map(int,input().split()))
  c = list(range(0,101))
  for i in range(n):
    if b[i] in c:
      c.remove(b[i])
      k = 1000
      kn = 0
  for i in range(100-n):
    if k>abs(x-c[i]):
      k = x-c[i]
      kn = c[i]
    print(kn)
else:
  print(x)
  

a = list(map(int,input().split()))
x = a[0]
n = a[1]
if n>0:
  b = list(map(int,input().split()))
  c = list(range(-n,101+n))

  
  for i in range(n):
    if b[i] in c:
      c.remove(b[i])

  
  k = 1000
  kn = 0

  for i in range(len(c)):
    if k>abs(x-c[i]):
      k = x-c[i]
      kn = c[i]
  print(kn)
else:
  print(x)
  

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
lis =  []

if n == 0:
  print(x)
else:
  lis = list(map(int, input().split()))
  if x not in lis:
    print(x)
  else:
    y = x + 1
    z = x - 1
    while True:
      print(y,z)
      if y in lis and z in lis:
        y += 1
        z -= 1
      elif z not in lis:
        print(z)
        break
      elif y not in lis:
        print(y)
        break
  


x, n = map(int, input().split())
lis =  []

if n == 0:
  print(x)
else:
  lis = list(map(int, input().split()))
  if x not in lis:
    print(x)
  else:
    y = x + 1
    z = x - 1
    while True:
      if y in lis and z in lis:
        y += 1
        z -= 1
      elif z not in lis:
        print(z)
        break
      elif y not in lis:
        print(y)
        break
  


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
if n==0:
    print(x)
    quit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    quit()
p.sort()
ans=[]

for i in range(p[0],p[-1]+1):
    if i not in p:
        ans.append(i)
ans.append(100000000)
for i in range(len(ans)):
    if ans[i]>x:
        if abs(x-ans[max(i-1,0)]) <= abs(x-ans[i]):
            print(ans[max(i-1,0)])
        else:
            print(ans[i])
        quit()

x,n=map(int,input().split())
if n==0:
    print(x)
    quit()
p=list(map(int,input().split()))
if x not in p:
    print(x)
    quit()
i=0
while True:
    if x-i not in p:
        print(x-i)
        quit()
    elif x+i not in p:
        print(x+i)
        quit()
    i+=1

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from bisect import bisect_left

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

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

    l = bisect_left(p, x)
    print(l,p[l])
    
    for i in range(1,1000):
        #print(p[l]+i)
        if p[l]+i in p:
            pass
        else:
            a = p[l]+i
            break

    for i in range(1, -1000, -1):
        if p[l]-i in p:
            pass
        else:
            b = p[l]-i
            break
    print(min(a,b))
else:
    print(x)

import sys

x,n = map(int, input().split())
p = sorted(list(map(int, input().split())))
res = [x,-1]
for i in range(101):
    a = x - i
    b = x + i
    if a not in p:
        print(a)
        sys.exit()
    if b not in p:
        print(b)
        sys.exit

import sys

x,n = map(int, input().split())
p = sorted(list(map(int, input().split())))
res = [x,-1]
for i in range(101):
    a = x - i
    b = x + i
    if a not in p:
        print(a)
        sys.exit()
    if b not in p:
        print(b)
        sys.exit()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  list_ = list(map(int, input().split()))

diff = 0
while True:
  if x-diff not in list_:
    print(x-diff)
    break
  if x+diff not in list_:
    print(x-diff)
    break
  diff+=1

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

  diff = 0
  while True:
    if x-diff not in list_:
      print(x-diff)
      break
    if x+diff not in list_:
      print(x+diff)
      break
    diff+=1

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
x, y = map(int, input().split())
p = list(map(int, input().split()))
ans_s = x
ans_l = x
count_s = 0
count_l = 0

while count_s == 0:
    if ans_s in p:
        ans_s -= 1 
        count_s = 1
        print(ans_s)
    else:
        count_s = 0 

while count_l == 0:
    if ans_l in p:
        ans_l += 1
        count_l = 1
        print(ans_l)
    else:
        count_l = 0
if abs(x - ans_s) < abs(ans_l - x):
    print(ans_s-1)
else:
    print(ans_l+1)

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

counter = 0

for i in range(1, 101):
    if x in p:
        if counter == 0:
            x -= i
            counter = 1
        else:
            x += i
            counter = 0
    else:
        exit
print(x)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
target = input().split()
target = [int(i) for i in target]
arr = input().split()
arr = [int(i) for i in arr]

if len(arr)==0:
  print(target[0])
else:
  i=0
  while(1):
    if target[0]-i in arr:
      i+=1
    else:
      print(target[0]-i)
      break

target = input().split()
target = [int(i) for i in target]
try:
  arr = input().split()
  arr = [int(i) for i in arr]
except:
  arr = []

if len(arr)==0:
  print(target[0])
else:
  i=0
  while(1):
    if target[0]-i in arr and target[0]+i in arr:
      i+=1
    elif target[0]-i not in arr:
      print(target[0]-i)
      break
    elif target[0]+i not in arr:
      print(target[0]+i)
      break

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x,y = IL()
    bit = 2**x
    for i in range(bit):
        tmp = 0
        for j in range(x):
            if (i>>j)&1:
                tmp += 2
            else:
                tmp += 4
            if y<tmp:
                continue
        if tmp == y:
            print('Yes')
            exit()
    print('No')
    return

if __name__=='__main__':
    main()

import sys 
from collections import deque
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def main():
    x,n = IL()
    p = LI()
    i=0
    while True:
        if i==0:
            if not x in p:
                print(x)
                exit()
        else:
            if not x-i in p:
                print(x-i)
                exit()
            if not x+i in p:
                print(x+i)
                exit()
        i+=1
    return

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Accepted