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):
# -*- coding: utf-8 -*-

import math

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

if N==0:
    p = []
else:
    p = list(map(int, input().split()))

p = sorted(p)

if X not in p:
    print(X)
else:
    ind = p.index(X)
    pre = p[:ind]
    pre = pre[::-1]
    pre += [100] * 100
    ans_p = math.inf
    for i, pp in enumerate(pre, start=1):
        if X!=(pp+i):
            ans_p = X-i
            break

    aft = p[ind+1:]
    aft += [-1] * 100
    ans_a = math.inf
    for i, pp in enumerate(aft, start=1):
        if X!=(pp-i):
            ans_a = X+i
            break

    print(min(ans_a, ans_p))


# -*- coding: utf-8 -*-

import math

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

if N==0:
    p = []
else:
    p = list(map(int, input().split()))

p = sorted(p)

for i in range(100):
    if X-i not in p:
        print(X-i)
        quit()

    if X+i not in p:
        print(X+i)
        quit()


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()))
sortP = sorted(P)
if N==0:
    print(X)
elif sortP[0]>X:
    print(sortP[0]-1)
elif sortP[N-1]<X:
    print(sortP[N-1]+1)
else:
    for n in range(sortP[0],sortP[N-1]+2):
        if n in sortP:
            continue
        if n ==X:
            print(X)
        elif n>X:
            if X-a<=n-X:
                print(a)
                break
            else:
                print(n)
                break
        a = n

X,N = map(int, input().split())
P = list(map(int, input().split()))
sortP = sorted(P)
if N==0:
    print(X)
elif sortP[0]>X:
    print(X)
elif sortP[N-1]<X:
    print(X)
else:
    for n in range(sortP[0]-2,sortP[N-1]+2):
        if n in sortP:
            continue
        if n ==X:
            print(X)
            break
        elif n>X:
            if X-a<=n-X:
                print(a)
                break
            else:
                print(n)
                break
        a = n

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


def getNearestValue(li, num):
    idx = np.abs(np.array(li) - num).argmin()
    return li[idx]


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


ans = 0
print(p)
i = 0
while True:
    mi = getNearestValue(p, x - i)
    ma = getNearestValue(p, x + i)
    if mi or ma:
        break
    i += 1

print(mi if mi < ma else ma)


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


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

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):
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
  if x not in p:
    print(x)
    exit()
  ans+=[-1,1]
    


import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
    if x not in p:
      print(x)
      exit()
  ans+=[-1,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, N = map(int, input().split())

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

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)
    
print(max(abs_val_dict, key = abs_val_dict.get()))

import operator

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

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

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)

if abs_val_dict != {}:
    print(min(abs_val_dict.items(), key=operator.itemgetter(1))[0])

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())
ans=0
flag=0
if N!=0:

	P=sorted(list(map(int, input().split())))
	pabs=[]
	for p in P:
		pabs.append(abs(X-p))
	
	pabs.sort()
	
	
	cnt=0
	temp=0
	
	print(pabs)
	if 0 in pabs:
		for i in range(1,max(pabs)+1):
			if i in pabs:
				
				if pabs.count(i)==1:
					if X-i not in P:
						ans=X-i
						flag=1
						break
					else:
						ans=X+i
						flag=1
						break
					
				else:
					continue
				
			else:
				ans=X-1
				flag=1
				break
		
		print(X-max(pabs)-1 if flag==0 else ans)
										
	else:
		print(X)
		
else:
	print(X)

X,N=map(int, input().split())
ans=0
flag=0

if N!=0:
	P=sorted(list(map(int, input().split())))
	pabs=[]
	
	for p in P:
		pabs.append(abs(X-p))
	pabs.sort()
	
	if 0 in pabs:
		for i in range(1,max(pabs)+1):
			if i in pabs:
				
				if pabs.count(i)==1:
					if X-i not in P:
						ans=X-i
						flag=1
						break
					else:
						ans=X+i
						flag=1
						break
					
				else:
					continue
				
			else:
				ans=X-i
				flag=1
				break
		
		print(X-max(pabs)-1 if flag==0 else ans)
										
	else:
		print(X)
		
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):
n=int(input())
li = list(map(int,input().split()))
count=0

for i in range(100):
  for j in range(n):
    if i == j:pass
    elif li[i]%li[j] == 0:break
    elif j == n-1:count +=1

print(count)

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

  for i in range(100):
    plus = (x+i)  in li
    minus = (x-i)  in li
  
    if plus == 1 and minus == 1:
      pass  
    elif plus == 1 and minus == 0:
      print(x-i)
      break
    elif plus == 0 and minus == 1:
      print(x+i)
      break
    else:
      print(x-i)
      break
  

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
print(small)
print(big)
print(max(len(big),len(small)))
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-1, X)]
big = [i for i in range(X+1, 101)]
small.reverse()
print(small)
print(big)
print(max(len(big),len(small)))
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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

if len(p) == 0:
    print(X)
    exit()

if not X in p:
    print(X)
    exit()

small = [i for i in range(-101, X)]
big = [i for i in range(X+1, 102)]
small.reverse()
for i in range(max(len(big),len(small))):
    if not small[i] in p:
        print(small[i])
        exit()
    elif not big[i] in p:
        print(big[i])
        exit()

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):
X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input().split()))

P.sort(reverse=True)
P += [-1000]
p_idx = 0
min_difference = 101
ans = 101
for num in range(101, -2, -1):
    if num == P[p_idx]:
        p_idx += 1
    else:
        if abs(X - num) <= min_difference:
            min_difference = abs(X - num)
            ans = num
print(num)

X,N = map(int, input().split())
if N == 0:
    print(X)
    exit()
P = list(map(int, input().split()))
P.sort(reverse=True)

for i in range(105):
    if X - i not in P:
        print(X - i)
        break
    if X + i not in P:
        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):
x,n=map(int,input().split())
s=list(map(int,input().split()))
for i in range(101):
    if n-i not in s:
        print(n-i)
        break
    elif n+i not in s:
        print(n+i)
        break      

x,n=map(int,input().split())
s=list(map(int,input().split()))
for i in range(101):
    if x-i not in s:
        print(x-i)
        break
    elif x+i not in s:
        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):
x,n = map(int, input().split())
p = sorted(map(int, input().split()))
if p == []:
    print(x)
else:
    a = p[-1]
    d =[]
    e = 0
    E = 0
    b = 1000
    c = 0
    for i in range(a):
        d += [e]
        e += 1
    for i in range(n):
        d.remove(p[E])
        E += 1
    for i in range(n):
        b = min((abs,x-d[c]),b)
        c += 1
    if (x-b) in d:
        print(x-b)
    else:
        print(x+b)

x,n = map(int, input().split())
p = set(map(int, input().split()))
for i in range(101):
    if x-i not in p:
        print(x-i)
        break
    if x+i not in p:
        print(x+i)
        break

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())
list = list(map(int, input().split()))

integers = [i for i in range(1, 101)]
for i in list:
    integers.remove(i)

ans = integers[0]
minabs = abs(integers[0] - x)
for i in integers:
    if abs(i - x) < minabs:
        minabs = abs(i - x)
        ans = i
        break

print(ans)

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

ans_list = [300]
for i in range(1, 101):
    if i not in list:
        if abs(x-i) < abs(x-ans_list[-1]):
            ans_list.append(i)

print(ans_list)
ans_list.sort(key=lambda y: abs(x-y))
print(ans_list[0])


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

ans = 300
for i in range(-200, 201):
    if i not in list:
        if abs(x-i) < abs(x-ans):
            ans = i

print(ans)


Verdicts: Runtime Error

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())
if (N==0):
    print(100)
    sys.exit()
p = list(map(int, input()))

n_ans = 1
sa = 100
for k in range(1,100,1):
    if (k in p):
        continue
    if(abs(k-X) < sa):
        n_ans = k
        sa = abs(k-X)
    else:
        break
print(n_ans)

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

n_ans = 0
sa = 200
for k in range(0,102,1):
    if (k in p):
        continue
    if(abs(k-X) < sa):
        n_ans = k
        sa = abs(k-X)
    else:
        break
print(n_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())
ps = list(map(int, input().split()))
pss = [i for i in range(1, 100+1)]
ps = list(set(pss)-set(ps))
ans = x

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

print(ans)

# -*- coding: utf-8 -*-
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0, x):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break


print(ans)


# -*- coding: utf-8 -*-
x, n = map(int, input().split())
ps = list(map(int, input().split()))

for i in range(0, x+100):
    for j in [-1, 1]:
        temp = x + (i*j)
        if ps.count(temp) == 0:
            ans = temp
            break
    else:
        continue
    break


print(ans)


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()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input().split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    print(A)
    if 0 not in A:
        print(X)
    else:
        j = 1
        while A.count(j) == 2:
            j += 1
        if A.count(j) == 0:
            print(X-j)
        else:
            if str(X-j) in p:
                print(X+j)
            else:
                print(X-j)

XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input.split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    j = 0
    while j in A:
        j += 1
    if j == 1:
        print(X-j)
    else:
        if A.count(j-1) == 2:
            print(X-j)
        else:
            if str(X-(j-1)) in p:
                print(X+(j-1))
            else:
                print(X-(j-1))

XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input().split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    print(A)
    j = 0
    while j in A:
        j += 1
    if j == 0:
        print(X)
    elif j == 1:
        print(X-j)
    else:
        if A.count(j-1) == 2:
            print(X-j)
        else:
            if str(X-(j-1)) in p:
                print(X+(j-1))
            else:
                print(X-(j-1))

XN = input().split()
X = int(XN[0])
N = int(XN[1])
if N == 0:
    print(X)
else:
    p = input().split()
    A = [None]*N
    for i in range(N):
        A[i] = abs(int(p[i])-X)
    if 0 not in A:
        print(X)
    else:
        j = 1
        while A.count(j) == 2:
            j += 1
        if A.count(j) == 0:
            print(X-j)
        else:
            if str(X-j) in p:
                print(X+j)
            else:
                print(X-j)

Verdicts: Wrong Answer

Runtime Error

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())
l = list(map(int, input().split()))
min_abs = 51
ans = 0
for i in range(max(X, N)+2):
    if i in l:
        continue
    if abs(i - X) < min_abs:
        min_abs = abs(i - X)
        ans = i
print(ans)

X, N = map(int, input().split())
l = list(map(int, input().split()))
min_abs = 51
ans = 0
for i in range(102):
    if i in l:
        continue
    if abs(i - X) < min_abs:
        min_abs = abs(i - X)
        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):
x,n = map(int,input().split())
p = list(map(int,input.split()))
i = 0
ans = 0
while True:
  if(x-1 in p):
    if(x+1 in p):
      None
    else:
      ans = x+1
      break
  else:
    ans = x-1
    break
  i += 1
print(ans)
    
      

x,n = map(int,input())
p = list(map(int,input.split()))
i = 0
ans = 0
while True:
  if(x-1 in p):
    if(x+1 in p):
      None
    else:
      ans = x+1
      break
  else:
    ans = x-1
    break
  i += 1
print(ans)
    
      

x,n = map(int,input().split())
p = list(map(int,input().split()))
i = 0
ans = 0
while True:
  if(x-i in p):
    if(x+i in p):
      None
    else:
      ans = x+i
      break
  else:
    ans = x-i
    break
  i += 1
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 = map(int,input().split())
p = list(map(int,input().split()))
ans = []
p.sort()

diff_1 = abs(X-p[-1])
diff_2 = abs(X-p[1])
diff = max(diff_1,diff_2)

for x in range(1,diff+1):
	if X+x not in p:
		ans.append(X+x)
		
	if X-x not in p:
		ans.append(X-x)

ans.sort()
print(ans[1])

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

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)

	for x in range(0,diff+1):
		if X-x not in p
			print(X-x)
			break
		if X+x not in p
			print(X+x)
			break

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

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)


	for x in range(diff+2):
		if X-x not in p:
			print(X-x)
			break
		if X+x not in p:
			print(X+x)
			break
		

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 = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(101)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i]
print(ans)



X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i+1 for i in range(100)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i]
print(ans)

X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(102)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i] - X
print(ans + X)

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()))
l = []
if len(l) == 0:
    if X != N:
        print(X)
    else:
        print(X-1)
    exit()
for i in range(-100, max(p)):
    if not i in p:
        l.append(i)
print(l)

ans_n = 100
ans = 0
for i in range(len(l)):
    if ans_n > abs(X-l[i]):
        ans_n = abs(X-l[i])
        ans = l[i]

print(ans)

X, N = map(int, input().split())
p = list(map(int, input().split()))
l = []
if len(p) == 0:
    print(X)
    exit()
for i in range(-1000, 1000):
    if not i in p:
        l.append(i)

ans_n = 1000
ans = 0
for i in range(-1000, 1000):
    if ans_n > abs(X-l[i]):
        ans_n = abs(X-l[i])
        ans = l[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):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if x - i != p[y - i]:
            print(x - i)
            break
        if x + i != p[y + i]:
            print(x + i)
            break
        i =+ 1

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

    p.sort()
    y = 0

    for i in range(n):
        if p[i] <= x:
            y = i
            if i != n-1 and x < p[i+1]:
                break 

    i = 0
    while 1 == 1:
        if y - i < 0:
            print(p[0] - 1)
            break
        elif x - i != p[y - i]:
            print(x - i)
            break
        if n <= y + i:
            print(p[n - 1] + 1)
            break
        elif x + i != p[y + i]:
            print(x + i)
            break
        i = 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):
(X,N) = map(int,input().split())
p = list(map(int,input().split()))
if N == 0:
    print(X)
else:
    for i in range N:
        if (X - i) not in p:
            print(X-i)
            break
        elif(X+i) not in p:
            print(X+i)
            break


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

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())
a = []
for i in range(n):
    a.append(input())
c = -1
b = 0
d = 101
e = 0
for w in range(103):
  if c not in a:
    b = abs(x - c)
    if b < d:
      d = b
      e = c
      c += 1
    else:
      c += 1
  else:
    c += 1
print(e)

x,n = map(int, input().split())
a = []
for i in range(n):
    a.append(input())
c = -1
b = 0
d = 101
e = 0
for w in range(103):
  if c not in a:
	b = abs(x - c)
    if b < d:
      d = b
      e = c
      c += 1
    else:
      c += 1
  else:
    c += 1
print(e)

x,n = map(int, input().split())
a = list(map(int,input().split()))
c = -1
b = 0
d = 101
e = 0
for w in range(103):
  if c not in a:
    b = abs(x - c)
    if b < d:
      d = b
      e = c
      c += 1
    else:
      c += 1
  else:
    c += 1
print(e)

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()
lis = list(map(int,input().split()))
ans = 100000000000
for i in range(0,102):
  if i not in lis:
    ans = min(ans,abs(i-n))
print(ans)

x,n = map(int,input().split())
if n == 0:
  print(x)
  exit()
lis = list(map(int,input().split()))
ans = 100000000000
num = 0
for i in range(102):
    if i not in lis:
        if ans > abs(i-x):
            ans = abs(i-x)
            num = i
print(num)


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 bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
hako=set(P)
kari=[]
if X<P[0]:
    print(X)
    exit()
if X>P[-1]:
    print(X)
    exit()
for i in range(102):
    if i not in hako:
        kari.append(i)
#print(kari)
kari.sort()
tekitpu=kari[bisect.bisect_left(kari,X)]
aho=kari[bisect.bisect_left(kari,X)-1]
#print(tekitpu,aho)
if abs(tekitpu-X)<abs(X-aho):
    print(tekitpu)
else:
    print(aho)


import bisect
X,N=map(int,input().split())
P=list(map(int,input().split()))
P=set(P)
A=[]
for i in range(102):
    if i not in P:
        A.append(i)
zahyo=bisect.bisect_left(A,X)
ans=[]
ans.append([abs(X-A[zahyo]),A[zahyo]])
ans.append([abs(X-A[zahyo-1]),A[zahyo-1]])
ans.sort()
print(ans[0][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):
import copy
import sys
x,n = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
if len(nums) == 0:
    print(x)
    sys.exit()
index = nums.index(x)
ind = copy.deepcopy(index)
ans = 0
while True:
    if ind < 0:
        break
    if nums[ind] != x and  nums[ind+1] - nums[ind] > 2:
        ans = nums[ind+1] - 1
        break
    ind -= 1
ind = copy.deepcopy(index)
while True:
    if ind > n-1:
        break
    if nums[ind] != x and  nums[ind] - nums[ind-1] > 2:
        if abs(ans - x) > abs(nums[ind-1] + 1 - x):
            ans = nums[ind-1] + 1
            break
    ind += 1
if index == 0:
    ans = x - 1
if index == n-1:
    if ans != x - 1
    ans = x + 1
print(ans)


X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [q for q in range(-1, 102) if q not in P]
ans = min(Q, key=lambda q: (abs(q - X), q))
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):
def main():
    x, n = map(int, input().split())
    p_lst = list(map(int, input().split()))

    if n == 0:
        minimum = x
    else:
        if x in p_lst:
            minimum = x

        else:
            lst = []
            flag = False

            while True:
                x1 = x
                x2 = x
                x1 += 1
                x2 -= 1

                if x1 not in p_lst:
                    lst.append(x1)
                    flag = True
                if x2 not in p_lst:
                    lst.append(x2)
                    flag = True

                if flag:
                    break

            minimum = min(lst)

    print(minimum)


if __name__ == '__main__':
    main()

def main():
    x, n = map(int, input().split())
    p_lst = list(map(int, input().split()))

    if n == 0:
        minimum = x
    else:
        if x not in p_lst:
            minimum = x

        else:
            lst = []
            flag = False

            while True:
                x1 = x
                x2 = x
                x1 += 1
                x2 -= 1

                if x1 not in p_lst:
                    lst.append(x1)
                    flag = True
                if x2 not in p_lst:
                    lst.append(x2)
                    flag = True

                if flag:
                    break

            minimum = min(lst)

    print(minimum)


if __name__ == '__main__':
    main()

def main():
    x, n = map(int, input().split())
    p_lst = list(map(int, input().split()))

    if n == 0:
        minimum = x
    else:
        if x not in p_lst:
            minimum = x

        else:
            lst = []
            flag = False
            x1 = x
            x2 = x

            while True:
                x1 += 1
                x2 -= 1

                if x1 not in p_lst:
                    lst.append(x1)
                    flag = True
                if x2 not in p_lst:
                    lst.append(x2)
                    flag = True

                if flag:
                    break

            minimum = min(lst)

    print(minimum)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Time Limit Exceeded

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):
targ, length = map(int, input().split(' '))

banned = [False] * 100

bans = input()
if bans != '':
    for ban in bans.split(' '):
        banned[int(ban) - 1] = True

for dist in range(100):
    if banned[targ - dist - 1]:
        print(targ - dist)
        exit()
    elif banned[targ + dist - 1]:
        print(targ + dist)
        exit()


targ, length = map(int, input().split(' '))

banned = [False] * 100

bans = input()
if bans != '':
    for ban in bans.split(' '):
        banned[int(ban) - 1] = True

for dist in range(100):
    if targ - dist > 0:
        if not banned[targ - dist - 1]:
            print(targ - dist)
            exit()
    else:
        print(targ - dist)
        exit()
    if targ + dist <= 100:
        if not banned[targ + dist - 1]:
            print(targ + dist)
            exit()
    else:
        print(targ + dist)
        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):
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()

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


l = list(range(0,102)) 
flist = []
for i in range(len(l)):
    if p.count(l[i]) == 0:
        flist.append(l[i])


flist.append(X)
anslist = sorted(flist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] 
dist2 = anslist[t+1] - anslist[t] 
    if dist1 <= dist2:
        print(anslist[t-1])
    else:
        print(anslist[t+1])

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

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


l = list(range(0,102)) 
flist = []
for i in range(len(l)):
    if p.count(l[i]) == 0:
        flist.append(l[i])


flist.append(X)
anslist = sorted(flist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] 
dist2 = anslist[t+1] - anslist[t]) 
    if dist1 <= dist2:
        print(anslist[t-1])
    else:
        print(anslist[t+1])

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


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

if flist.count(X) == 0:
    print(X)
    exit()


l = list(range(0,102)) 


plist = []
for i in range(len(l)):
    if flist.count(l[i]) == 0:
        plist.append(l[i])


plist.append(X)
anslist = sorted(plist)
t = anslist.index(X)

dist1 = anslist[t] - anslist[t-1] 
dist2 = anslist[t+1] - anslist[t] 
if dist1 <= dist2:
    print(anslist[t-1])
else:
    print(anslist[t+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):
def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


x, n = read_ints()
p = list(read_ints())
ans = -1
delta = 1000
for i in range(102):
    ok = True
    for j in p:
        if p == i:
            ok = False
            break
    if ok:
        d = abs(x - i)
        if d < delta:
            ans = i
print(ans)


def read_int():
    return int(input())


def read_ints():
    return map(int, input().split(' '))


x, n = read_ints()
p = []
if n > 0:
    p = list(read_ints())
ans = -1
delta = 1000
for i in range(-1, 102):
    ok = True
    for j in p:
        if j == i:
            ok = False
            break
    if ok:
        d = abs(x - i)
        if d < delta:
            ans = i
            delta = d
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())
if n == 0 or 0 not in absolute:
    print(x)
else:
    p = list(map(int,input().split()))
    absolute = list(map(lambda i:abs(i-x),p))
    ab = set(absolute)
    i = 1
    while i < 100:
        if absolute.count(i) == 2:
            i += 1
        else:
            opt = set([x-i,x+i])
            ans = opt - ab
            break

    print(min(ans))


x,n = map(int,input().split())
if n == 0:
    print(x)
else:
    p = list(map(int,input().split()))
    absolute = list(map(lambda i:abs(i-x),p))
    if 0 not in absolute:
        print(x)
    else:
        ab = set(p)
        i = 1
        while i < 100:
            if absolute.count(i) == 2:
                i += 1
            else:
                opt = set([x-i,x+i])
                ans = opt - ab
                break

        print(min(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):
def main():
    x, n = map(int,input().split())
    li = list(map(int,input().split()))
    li2 = []
    ans = 0
    for i in range(102):
        check = True
        for j in li:
            if j == i:
                check = False
        if check:
            li2.append(i)
    for i in li2:
        if abs(ans - x) > abs(i - x):
            ans = i
    print(li2)
    print(ans)
 
 
if __name__ == '__main__':
    main()

def main():
    x, n = map(int,input().split())
    li = list(map(int,input().split()))
    li2 = []
    ans = 0
    for i in range(102):
        check = True
        for j in li:
            if j == i:
                check = False
        if check:
            li2.append(i)
    for i in li2:
        if abs(ans - x) > abs(i - x):
            ans = i
    print(ans)
 
 
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):
def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
x = int(input())
n = int(input())
a = list(map(int,input().split()))
print(serch_1(a,x),serch_2(a,x))
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))

    

def serch_1(b,x):
    i=1
    an=0
    while 1:
        if b.count(x+i)==0:
            an=x+i
            break
        else:
            i=i+1
    return an

def serch_2(b,x):
    i=1
    an=0
    while 1:
	    if b.count(x-i)==0:
		    an=x-i
		    break
	    else:
		    i=i+1
    return an
def hikaku(a,b,x):
    if abs(a-x)>=abs(b-x):
    	return b
    else:
        return a
s = list(map(int,input().split()))
# n = int(input())
a = list(map(int,input().split()))
# print(serch_1(a,x),serch_2(a,x))
x=s[0]
n=s[1]
if a.count(x)==0:
	print(x)
else:
	print(hikaku(serch_1(a,x),serch_2(a,x),x))

    

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())
l = list(map(int, input().split()))

if l == []:
    print(x)
    exit()

for i in range(100):
    x -= 1
    if x not in l:
        print(x)
        exit()

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

if x not in l:
    print(x)
    exit()

x_a = x
for i in range(100):
    x -= 1
    x_a += 1
    if x not in l:
        print(x)
        exit()
    if x_a not in l:
        print(x_a)
        exit()

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):
# arr=input().strip().split(' ')
x,n=[int(i) for i in input().strip().split(' ')]
arr=[int(i) for i in input().strip().split(' ')]


# 	if x-i >0 :
# 		pos.append(x-i)
# 	else:



diff=[]
for i in arr:
	diff.append(x-i)
i=-1
j=1
while i in diff:
	i=i-1
while j in diff:
	j=j+1
print(min(x+i,x+j))

# arr=input().strip().split(' ')
def aa():
    x,n=[int(i) for i in input().strip().split(' ')]
    if n==0:
        print(x)
        return 
    arr=[int(i) for i in input().strip().split(' ')]
    
    
    # 	if x-i >0 :
    # 		pos.append(x-i)
    # 	else:
    
    
    
    
    diff=[]
    for i in arr:

        diff.append(x-i)
    i=-1
    j=0
    while i in diff:
        i=i-1
    while j in diff:
        j=j+1
    if abs(i)<abs(j):
        print(x-i)
    else:
        print(x-j)
    # print(x+)
aa()

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):
n, x = map(int, input().split())
p = set(map(int, input().split()))

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x:
    ans = i
    break
print(ans)

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

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x:
  	ans = i
    break
print(ans)

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

ans = 0
for i in range(1, 102):
  if i in p:
    continue
  if i < x:
    ans = i
  elif x - ans > i - x
  	ans = i
    break
print(ans)

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

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

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

ans = 0
diff = x
for i in range(1, 102):
  if i in p:
    continue
  tmp = abs(i - x)
  if tmp < diff:
    diff = tmp
    ans = i
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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):
10 5
4 7 10 6 5

X, N = list(map(int,input().split()))
if N !=0:
  P = list(map(int,input().split()))
  ab = 100
  for i in range(-100,200):
    if i not in P:
      if abs(X-i)<ab:
        ab = abs(X-i)
        ans = i
  print(ans)
else:
  print(X)

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 = set(P)

for i in range(100):

  if X-i in P:
    continue
  else:
    print(X-i)
    break

  if X+i in P:
    continue
  else:
    print(X+i)
    break



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

for i in range(100):

  if X-i in P:
    pass
  else:
    print(X-i)
    break

  if X+i in P:
    pass
  else:
    print(X+i)
    break


Verdicts: Wrong Answer

Accepted