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

import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
x,n=map(int,stdin.readline().split())
a=set(map(int,stdin.readline().split()))
if(x not in a):
    print(x)
else:
    diff=1
    while(True):
        if(x-diff not in a):
            print(x-diff)
            break
        elif(x+diff not in a):
            print(x+diff)
            break
        diff+=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):
# -*- coding: utf-8 -*-
x, n = map(int, input().split())
aa = 0
if n == 0:
  aa = 1
if aa == 0:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    flg = 0
    dis = []
    while flg == 0:
        if i > 100:
            flg = 1
        if i in p:
            dis.append(5000)
        else:
            dis.append(abs(x-i))
        i += 1
    for i in dis:
        if dis[i] == min(dis):
            print(i)
            break
else:
    print(x)

# -*- coding: utf-8 -*-
x, n = map(int, input().split())
aa = 0
if n == 0:
   aa = 1
if aa == 0:
    p = list(map(int, input().split()))
    p.sort()
    i = 0
    flg = 0
    dis = []
    while flg == 0:
        if i > 100:
            flg = 1
        if i in p:
            dis.append(5000)
        else:
            dis.append(abs(x-i))
        i += 1
    for i in range(len(dis)):
        if dis[i] == min(dis):
            print(i)
            break
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):
a=input()
a=a.split()
x=int(a[0])
p=input()
p=p.split()

i=0
p_1=p+[]



for y in p_1:
  p_1[i]=abs(int(p_1[i])-x)
  i=i+1

p_1.sort()
if p_1[0]==0:
  del p_1[0]

q=p_1[0]
if str(x-q) in p:
  print(x-q)
else:
  print(x+q)






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

for y in range(x+1):
  for b in[-1,1]:
    c=x+y*b
    if a.count(c)==0:
      print(c)
      exit(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())
Q=list(map(int,input().split()))

if n==0:
  print(x);exit()
  
if x in Q:
  print(x) ; exit()

A=[]
for i in range(1,250):
  A.append(-i)
  A.append(i)
  
for i in A:
  if not x+i in Q:
    print(x+i)
    exit()


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

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

A=[]
for i in range(1,107):
  A.append(-i)
  A.append(i)
for i in A:
  if not i in Q:
    print(i)
    exit()

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

if n==0:
  print(x);exit()
  
if not x in Q:
  print(x) ; exit()

A=[]
for i in range(1,250):
  A.append(-i)
  A.append(i)
  
for i in A:
  if not x+i in Q:
    print(x+i)
    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):
def forbidden_list():
    
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    
    min_abs = list()
    
    if N == 0:
        return X
    # X + i
    i = 1
    while True:
        if X + i in P:
            i += 1
        else:
            min_abs.append(X + i)
            break
    # X - i
    i = -1
    while True:
        if X + i in P:
            i -= 1
        else:
            min_abs.append(X + i)
            break
    
    return min(min_abs)

result = forbidden_list()
print(result)

def forbidden_list():
    
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    
    min_abs_list = list()
    
    if N == 0:
        return X
    # X + i
    i = 0
    while True:
        if X + i in P:
            i += 1
        else:
            min_abs_list.append(X + i)
            break
    # X - i
    i = 0
    while True:
        if X + i in P:
            i -= 1
        else:
            min_abs_list.append(X + i)
            break
    
    if abs(X - min_abs_list[0]) > abs(X - min_abs_list[1]):
        return min_abs_list[1]
    elif abs(X - min_abs_list[0]) == abs(X - min_abs_list[1]):
        return min(min_abs_list)
    elif abs(X - min_abs_list[0]) < abs(X - min_abs_list[1]):
        return min_abs_list[0]

result = forbidden_list()
print(result)

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())
i = list(map(int, input().split()))
if X not in i:
    print(X)
else:
    n = 1
    while n <=N+1:
        if X - n not in i:
            print(X - n)
            break
        else:
            if X+n not in i:
                print(X+n)
                break

X, N = map(int, input().split())
i = list(map(int, input().split()))
if X not in i:
    print(X)
else:
    n = 1
    while n <=N+1:
        if X - n not in i:
            print(X - n)
            break
        else:
            if X+n not in i:
                print(X+n)
                break
        n +=1

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = max(num_list[i], X) - min(num_list[i], X)

ans = [i for i,x in enumerate(tmp) if x == min(tmp)]
# print(num_list)
# print(tmp)
# print(ans)
if len(ans) == 2:
    print(min(num_list[ans[0]],num_list[ans[1]]))
else:
    print(num_list[ans])


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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = max(num_list[i], X) - min(num_list[i], X)

ans = [i for i,x in enumerate(tmp) if x == min(tmp)]
# print(num_list)
# print(tmp)
print(ans)
if len(ans) == 2:
    print(min(num_list[ans[0]],num_list[ans[1]]))
else:
    print(num_list[ans[0]])


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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i) for i in range(102)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min[tmp])

print(num_list[ans])


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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i) for i in range(102)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = abs(num_list[i] - X)

ans = tmp.index(min(tmp))

print(num_list[ans])


Verdicts: Runtime Error

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):
def main():
    import copy

    num, quantity = map(int, input().split())
    nums = list(map(int, input().split()))
    nums.sort()
    
    if quantity == 0:
        print(num)
        return
    
    i = 0

    minus_num = copy.copy(num)
    plus_num = copy.copy(num)

    while i = 1
        if num not in nums:
            print(num)
            return
        
        if minus_num not in nums:
            print(minus_num)
            return
        
        if plus_num not in nums:
            print(plus_num)
            return
        
        minus_num = minus_num - 1
        plus_num = plus_num + 1



main()

def main():
    import copy

    num, quantity = map(int, input().split())
    nums = list(map(int, input().split()))
    nums.sort()
    
    if quantity == 0:
        print(num)
        return
    
    i = 0

    minus_num = copy.copy(num)
    plus_num = copy.copy(num)

    while i < len(nums)
        if num not in nums:
            print(num)
            return
        
        if minus_num not in nums:
            print(minus_num)
            return
        
        if plus_num not in nums:
            print(plus_num)
            return
        
        minus_num = minus_num - 1
        plus_num = plus_num + 1
        i = i + 1

main()

def main():
    import copy

    num, quantity = map(int, input().split())
    nums = list(map(int, input().split()))
    nums.sort()
    
    if quantity == 0:
        print(num)
        return
    
    i = 0

    minus_num = copy.copy(num)
    plus_num = copy.copy(num)

    while i < len(nums):
        if num not in nums:
            print(num)
            return
        
        if minus_num not in nums:
            print(minus_num)
            return
        
        if plus_num not in nums:
            print(plus_num)
            return
        
        minus_num = minus_num - 1
        plus_num = plus_num + 1

main()

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(0)
p = list(map(int, input().split()))
a = [i for i in range(1,101)]
b = list(set(a) - set(p))
for i in range(len(b)):
  if x < b[i]:
    if abs(b[i-1]-x) <= abs(b[i]-x):
      print(b[i-1])
      break
    else:
      print(b[i])
      break
print(x-b[-1])

x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(101)]
b = sorted(list(set(a) - set(p)))
print(b)
min_v = 1000
min_id = 0
for i in range(len(b)):
  if abs(x - b[i]) < min_v:
    min_v = abs(x - b[i])
    min_id = i
print(b[min_id])

x, n = map(int, input().split())
if n == 0:
  print(x)
  exit(0)
p = list(map(int, input().split()))
a = [i for i in range(201)]
b = sorted(list(set(a) - set(p)))
min_v = 1000
min_id = 0
for i in range(len(b)):
  if abs(x - b[i]) < min_v:
    min_v = abs(x - b[i])
    min_id = i
print(b[min_id])

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):
X, N = map(int, input().split())
p = list(map(int, input().split()))
S = []

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

print(min(S))

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

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

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 numpy

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

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

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

print(nmap)

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

print(nmap)

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


import numpy

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

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

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

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

ans = numpy.argmin(nmap)
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):
ans = None
for r in range(100):
    for i in [-r, r]:
        if (X + i) not in p:
            ans = X+i
            break

    if ans is not None:
        break


print(ans)

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

ans = None
for r in range(100):
    for i in [-r, r]:
        if (X + i) not in p:
            ans = X+i
            break

    if ans is not None:
        break

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


for i in range(0,100+1):
    
    for j in range(0,100+1):
        if i + j > X:
            break
        if (i*2 + j*4) == Y and (i+j) == X:
            print('Yes')
            exit()

print('No')


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

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

if X in P:
    for i in range(1,100):

        if not X - i in P:
            print(X - i)
            exit()
        if not X + i in P:
                print(X + i)
                exit()
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):
a = input().split()
b = int(a[0])
c = int(a[1])
d = [int(i) for i in input().split()]
e = sorted(d)


f = int(e[0]-1)
g = int(e[-1]+1)


h = int(g-f)

X = []
for I in range(int(h+1)):
    J = int(f+I)
    if e.count(J) == 0:
        X.append(J)

Y = len(X)
H = []
for S in range(Y):
    Q = X[S]
    if Q>=b:
        g = Q-b
        H.append(g)
    else:
        g = b-Q
        H.append(g)
P = sorted(H)
F = P[0]
O = H.index(F)


print(X[O])
print(X)
print(H)
print(O)

a = input().split()
b = int(a[0])
c = int(a[1])
if c == 0:
    print(b)
    
else:
    d = [int(i) for i in input().split()]
    e = sorted(d)


    f = int(e[0]-1)
    g = int(e[-1]+1)


    h = int(g-f)

    X = []
    for I in range(int(h+1)):
        J = int(f+I)
        if e.count(J) == 0:
            X.append(J)

    Y = len(X)
    H = []
    for S in range(Y):
        Q = X[S]
        if Q>=b:
            g = Q-b
            H.append(g)
        elif Q<=b:
            g = b-Q
            H.append(g)
    
    P = sorted(H)
    F = P[0]
    O = H.index(F)


    print(X[O])

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

a = input().split()
for i in range(len(a)):
  a[i] = int(a[i])

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

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

a = input().split()
for i in range(len(a)):
  a[i] = int(a[i])

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


Verdicts: 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):
X,N=map(int,input().split())
p=[]
if N>0:
  p=list(map(int,input().split()))
  L=[abs(X-i) for i in P]
  l=min(L)
  if X-l in P:
    print(X-l)
  else:
    print(X+l)
else:
  print(X)

X,N=map(int,input().split())
if N>0:
  P=list(map(int,input().split()))
  L=[abs(X-i) for i in P]
  l=min(L)
  if X-l in P:
    print(X-l)
  else:
    print(X+l)
else:
  print(X)

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

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

x = a[0]
n = a[1]
d = list(map(int,input().split()))

if (n == 0):
    print(x)
else:
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]SSS
    if (x < min_int or max_int < x):
        print(x)
    else:
        p = []
        for var in range(min_int,max_int):
            if var not in d:
                p.append(var)
            else:
                continue
        ans = []
        for pp in p:
            ans.append(np.abs(pp - x))
        ans = np.array(ans)
        print(p[np.argmin(ans)])


import numpy as np
a = list(map(int,input().split()))

x = a[0]
n = a[1]

if (n == 0):
    print(x)
else:
    d = list(map(int,input().split()))
    min_int = d[np.argmin(d)]
    max_int = d[np.argmax(d)]
    if (x < min_int or max_int < x):
        print(x)
    else:
        p = []
        for var in range(min_int - 10,max_int + 10):
            if var not in d:
                p.append(var)
            else:
                continue
        ans = []
        for pp in p:
            ans.append(np.abs(pp - x))
        ans = np.array(ans)
        print(p[np.argmin(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 = set(list(map(int, input().split())))

for diff in range(1000):
  if X - diff not in P:
    print(X - diff)
  elif X + diff not in P:
    print(X + diff)


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

for diff in range(1000):
  if X - diff not in P:
    print(X - diff)
    break
  elif X + diff not in P:
    print(X + diff)
    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
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
list_n = [0, -1, 1]
for i in range(2, 50):
  list_n.append(-i)
  list_n.append(i)
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
x = [0] * N
for i in range(0, N):
    x[i] = p[i] - X
for i in list_n:
    if my_index(x, i) == False:
        print(X+i)
        break

import sys
def my_index(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default
list_n = [0, -1, 1]
for i in range(2, 101):
  list_n.append(-i)
  list_n.append(i)
X, N = map(int, input().split())
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))
x = [0] * N
for i in range(0, N):
    x[i] = p[i] - X
for i in list_n:
    if my_index(x, i) == -1:
        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 = input().split()
y = input().split()

if len(y) == 0:
    print(x[0])
    sys.exit()
a=[]
b=[]
for n in range(-1,102):
    b.append(n)
   
for nn in range(len(y)):
    
    b.remove(int(y[nn]))
for m in range(len(b)):  
    d = b[m] - int(x[0])
    if d < 0:
        c = d*(-1)
    if d >= 0:
        c = d
    a.append(c)
mm = min(a)
if (int(x[0]) - mm) in y:
    print(int(x[0]) + mm)
else:
    print(int(x[0]) - mm)

import sys
x = input().split()
y = input().split()

if len(y) == 0:
    print(x[0])
    sys.exit()
a=[]
b=[]
for n in range(-1,102):
    b.append(n)
   
for nn in range(len(y)):
    
    b.remove(int(y[nn]))
for m in range(len(b)):  
    d = b[m] - int(x[0])
    if d < 0:
        c = d*(-1)
    if d >= 0:
        c = d
    a.append(c)
mm = min(a)
if str((int(x[0]) - mm)) in y:
    print(int(x[0]) + mm)
else:
    print(int(x[0]) - mm)

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

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

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

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

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 iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    print(min(abs(x-ans[0]),abs(x-ans[1])))
    return 0

if __name__ == "__main__":
    solve()

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    print(min(ans))
    return 0

if __name__ == "__main__":
    solve()

def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    print(min(abs(x-ans[0]),abs(x-ans[1])))
    return 0

if __name__ == "__main__":
    solve()


def iput(): return int(input())
def mput(): return map(int, input().split())
def lput(): return list(map(int, input().split()))

def solve():
    x, n = mput()
    p = lput()
    ans = []
    for i in range(x, x-n-1, -1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    for i in range(x, x+n+1):
        boo = i in p
        if boo != True:
            ans.append(i)
            break
    if abs(x-ans[0]) <= abs(x-ans[1]):
        print(ans[0])
    else:
        print(ans[1])
    return 0

if __name__ == "__main__":
    solve()

Verdicts: 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):
for i in range(100):
    plus_abs=X+i
    minus_abs=X-i

    for j in range(N):
        if plus_abs == int(list2[j]):
           plus_abs=1000


    for k in range(N):
        if minus_abs == int(list2[k]):
            minus_abs=1000

    if plus_abs !=1000 or minus_abs!=1000:
        if plus_abs >= minus_abs:
            result = minus_abs
        else:
            result = plus_abs

        print(result)
        break

list1= input().split(" ")
list2= input().split(" ")
X=int(list1[0])
N=int(list1[1])
plus_abs =1000
minus_abs=1000
result=0

for i in range(100):
    plus_abs=X+i
    minus_abs=X-i

    for j in range(N):
        if plus_abs == int(list2[j]):
           plus_abs=1000


    for k in range(N):
        if minus_abs == int(list2[k]):
            minus_abs=1000

    if plus_abs !=1000 or minus_abs!=1000:
        if plus_abs >= minus_abs:
            result = minus_abs
        else:
            result = plus_abs

        print(result)
        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):
z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(z[0])
else:
  p = list(map(int, input().split()))
  count = 0
  l = []
  for i in range(1, 101):
    l.append(i)
  for i in p:
    l.remove(i)
  print(l)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  print(ans)

z = list(map(int, input().split()))
x = z[0]
if z[1] == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  l = []
  for i in range(-1, 102):
    l.append(i)
  for i in p:
    l.remove(i)
  t = 200
  for i in l:
    e = abs(x-i)
    if e >= t:
      break
    t = e
    ans = i
  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 sys
if n == 0:
  print(x)
  sys.exit()
x, n = map(int, input().split())
lst = list(map(int, input().split()))
for i in range(250):
  if x - i not in lst:
    print(x + i)
    sys.exit()
  if x + i not in lst:
    print(x + i)
    sys.exit()

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

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

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):
#the program is to find the nearest number which is not included in N, and if more than 1 number, it will take the smallest one

#we will declare the x and n integer
x, n = map(int, input().split())

#declare the pi
p = list(map(int, input().split()))


for a in range(x + 1):
for b in [-1, +1]:
result = X + b * a
if p.count(result) == 0:
print(result)


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

check = 1000000
ans = 0

N = list(range(102))

for i in range(1, 101):
    if i in p:
        N.remove(i)

for i in range(len(N)):
    if check > abs(N[i]-x):
        check = abs(N[i]-x)
        ans = N[i]
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 = (int(i) for i in input().split())
    if n > 0:
        p = [int(i) for i in input().split()]
    else:
        p = []

    mask = [0] * 101 
    for pe in p:
        mask[pe] = 1

    b, e = x, x

    while True:
        if b >= 1 and mask[b] == 0:
            break
        b -= 1
        if e <= 100 and mask[e] == 0:
            break
        e += 1

    if mask[b] == 0:
        print(b)
    else:
        print(e)

main()

def main():
    # x in [1, 100]
    # n in [0, 100]
    
    x, n = (int(i) for i in input().split())
    if n > 0:
        p = set(int(i) for i in input().split())
    else:
        p = set() 

    b, e = x, x
    while b not in p and e not in p:
        b -= 1
        e += 1

    if b in p:
        print(b)
    else:
        print(e)


main()


def main():
    # x in [1, 100]
    # n in [0, 100]
    
    x, n = (int(i) for i in input().split())
    if n > 0:
        p = set(int(i) for i in input().split())
    else:
        p = set() 

    b, e = x, x
    while b in p and e in p:
        b -= 1
        e += 1

    if b not in p:
        print(b)
    else:
        print(e)


main()


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):
from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    


main()




from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt
import math

import bisect
import re
import heapq


from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


yes = "Yes"
no = "No"


def main():
    x,n = mi()
    p = li()

    for i in range(100):
        if x-i not in p:
            print(x-i)
            exit()
        elif x+i not in p:
            print(x+i)
            exit()



main()




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()
q = input().split()
p = sorted(abs(int(i)-x) for i in q)
for i in range(n):
    if i != p[i]:
        if x - i not in q:
            print(x - i)
        else:
            print(x + i)
        exit()

x,n,*p = map(int,open(0).read().split())
for i in range(101):
    if x - i not in p:
        print(x - i)
        exit()
    elif x + i not in p:
        print(x + i)
        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):
x, n = map(int,input().split())
l = list(map(int,input().split()))
a = 0
ab = 0
for i in range(100):
    if x - i not in l:
        ans = x - i
        a = i + 1
        print(ans)
        break
for i in range(100):
    if x + i not in l:
        ansb = x + i
        ab = i + 1
        print(ansb)
        break
if a > ab:
    print(ansb)
else:
    print(ans)


x, n = map(int,input().split())
l = list(map(int,input().split()))
a = 0
ab = 0
for i in range(100):
    if x - i not in l:
        ans = x - i
        a = i + 1
        break
for i in range(100):
    if x + i not in l:
        ansb = x + i
        ab = i + 1
        break
if a > ab:
    print(ansb)
else:
    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 || N==100):
  print(X)

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

  p.sort()
  q=list(range(1,max(p)+1))

  for i in p:
    q.remove(i)

  Z=1000
  ans=-1
  for i in q:
    if( abs(X-i)<Z):
      Z=abs(X-i)
      ans=i
  
  print(ans)

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

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

  p.sort()
  q=list(range(-5,102))

  for i in p:
    q.remove(i)

  Z=1000
  for i in q:
    if( abs(X-i)<Z):
      Z=abs(X-i)
      ans=i
  
  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:
    print(x)
else:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if x - small > large - x:
        print(large)
    else:
        print(small)


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

if n == 0:
    input()
    print(x)
else:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if x - small > large - x:
        print(large)
    else:
        print(small)


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

if n == 0:
    # input()
    print(x)
else:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if x - small > large - x:
        print(large)
    else:
        print(small)


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

if n == 0:
    # input()
    print(x)
else:
    l = list(map(int, input().split()))
    l.sort()
    small = x
    large = x
    while small in l and large in l:
        small -= 1
        large += 1
    if small in l:
        print(large)
    elif large in l:
        print(small)
    elif x - small > large - x:
        print(large)
    else:
        print(small)


Verdicts: 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(map(int, input().split()))
if N == 0:
    print(100)

else:
    min_abs = 100
    min_abs = min([abs(X-i) for i in range(100) if not i in P])
    min_abs


    ans_candi = [i+X for i in range(-min_abs, min_abs+1) if not i in P]
    ans = min(ans_candi)
    print(ans)

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

delta, notP = [], []
for i in range(0, 102):
    if not i in P:
        delta.append(abs(X-i))
        notP.append(i)

i = delta.index(min(delta))
print(notP[i])

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):
k,n=map(int,input().split())
if(n==0):
    print(k)
else:
  l=sorted(list(map(int,input().split())))
  a=[]
  a.append(k)
  for i in range(1,n):
    a.append(k-i)
    a.append(k+i)
  if(n%2==0):
    a.pop(-1)
  for i in range(n):
    if(l[i] in a):
        continue
    else:
         if(i!=n-1):
             print(min(a[i],a[i+1]))
             break
         else:
             print(a[i])
             break

k,n=map(int,input().split())
if(n==0):
    print(k)
else:
  l=list(map(int,input().split()))
  c=0
  d=0
  while(d==0):
        if(k-c not in l):
            print(k-c)
            break
        if(k+c not in l):
            print(k+c)
            break
        c=c+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())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(-100, 101))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[min_index])

X, N = map(int, input().split())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(0, 101))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[min_index])

import numpy as np
X, N = map(int, input().split())
p_list = set([int(i) for i in input().split()])
set_all = set(np.arange(-201, 201))
ex_list = set_all-p_list
ex_list = list(ex_list)
diff_list = [np.abs(i-X) for i in ex_list]
min_index = np.argmin(diff_list)
print(ex_list[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):
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
p = 0
counter = n
for i in range(n):
    if i>0 and lis[i] == lis[i-1]:
        counter -=1
    elif i>0 and lis[i]<lis[0]*2:
        p += 1
    else:
        for j in range(n):
            if i != j and lis[i]%lis[j] ==0:
                counter -=1
                break
print(counter)


x, n = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
if n == 0:
    print(x)
else:
    for i in range(lis[n-1]+2):
        
        if i < x and i not in lis:
            a = i
        if i >= x and i not in lis:
            b = i
            if abs(a-x) <= abs(b-x):
                print(a)
            else:
                print(b)
            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):
XN = list(map(int, input().split()))

if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(1, XN[1] + 1):
    if not XN[0] + d in p:
      print(XN[0] + d)


XN = list(map(int, input().split()))
 
if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(XN[1] + 1):
    if not XN[0] - d in p:
      print(XN[0] - d)
    if not XN[0] + d in p:
      print(XN[0] + d)

XN = list(map(int, input().split()))
 
if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(XN[1] + 1):
    if not XN[0] - d in p:
      print(XN[0] - d)
    elif not XN[0] + d in p:
      print(XN[0] + d)

XN = list(map(int, input().split()))
 
if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(1, XN[1] + 1):
    if not XN[0] - d in p:
      print(XN[0] - d)
    if not XN[0] + d in p:
      print(XN[0] + d)

XN = list(map(int, input().split()))
 
if XN[1] == 0:
  print(XN[0])
else:
  p = list(map(int, input().split()))
  for d in range(XN[1] + 1):
    if not XN[0] - d in p:
      print(XN[0] - d)
      break
    if not XN[0] + d in p:
      print(XN[0] + d)
      break

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

ls = sorted(ls)
d = 10**3
ans = 0
for p in ls:
  if abs(x-p)<d:
    d = abs(x-p)
    ans = p
print(ans)

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

ls = sorted(ls)
d = 10**3
ans = 0
for i in range(ls[0]-1,ls[-1]+2):
  if i in ls:
    continue
  if d>abs(i-x):
    d = abs(i-x)
    ans = i
print(ans)



Verdicts: Wrong Answer

Accepted