TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X,N = map(int,input().split())
p = list(map(int,input().split()))
min = 0
i = 0
count = 0
while True:
    if abs(X - i) == min:
        if i not in p:
            break
        elif min != 0:
            count += 1
            i = 0
            if count == 2:
                min += 1
                count = 0
        else:
            min += 1
            i = 0
    i += 1

print(i)

X,N = map(int,input().split())
p = list(map(int,input().split()))
min = 0
i = 0
while True:
    if abs(X - i) == min:
        if i not in p:
            break
        else:
            min += 1
            i = 0
    i += 1

print(i)

X,N = map(int,input().split())
p = list(map(int,input().split()))
i = X + 1
j = X - 1
if X not in p:
    print(X)
    exit()
    
while True:
    if j not in p:
        print(j)
        break
    elif j in p and i not in p:
        print(i)
        break
    i += 1
    j -= 1


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

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

X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    P = list(map(int, input().split()))
    for i in range(1000):
        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())
if N!=0:
  plist =list(map(int,input().split()))
  maxN = max(plist)
  Anslist =[i for i in range(maxN+1)]
  print (Anslist)
  for i in range(len(plist)):
    Anslist.remove(plist[i])
  Anslist.remove(0)
  print(Anslist)

  ans = 0
  min=100
  for i in range(len(Anslist)):
    if min>abs(X-Anslist[i]):
      min = abs(X-Anslist[i])
      ans = Anslist[i]
  print(ans)
else :print(X)

X,N = map(int,input().split())
if N!=0:
  plist =list(map(int,input().split()))
  print (plist)
  #maxN = max(plist)
  maxN = 100
  Anslist =[i for i in range(X+1)]
  #print (Anslist)
  for i in range(len(plist)):
    Anslist.remove(plist[i])
  Anslist.remove(0)
  #print(Anslist)

  ans = 0
  min=100
  for i in range(len(Anslist)):
    if min>abs(X-Anslist[i]):
      min = abs(X-Anslist[i])
      ans = Anslist[i]
  print(ans)
else :print(X)

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

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(102)]
  anslist.append(-1)
  #anslist.remove(0)
  Plist = sorted(Plist)
  #print (anslist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)

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):
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    for i in range(1, 101):
        if i in p:
            continue

        if i <= x:
            ans = i
        elif x - ans > i - x:
            ans = i
    else:
        print(ans)


if __name__ == '__m

import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    for i in range(1, 101):
        left = right = None
        if x - i in p:
            left = True
        if x + i in p:
            right = True

        if left and right:
            continue
        elif not left:
            ans = x + 1
        elif not right:
            ans = x - 1

    print(ans)


if __name__ == '__main__':
    main()

# import numpy as np
import sys
input = sys.stdin.readline


def main():
    x, n = [int(i) for i in input().split()]
    p = set([int(i) for i in input().split()])

    ans = x
    for i in range(-1, 102):
        if i in p:
            continue

        if i <= x:
            ans = i
        else:
            if x - ans > i - x:
                ans = i
            break

    print(ans)


if __name__ == '__main__':
    main()


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


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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

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

if n==0:
    print(x)
p = list(range(n))
p = list(map(int, input().split()))
p_2 = list(range(n))
for i in range(n):
    p_2[i] = x-p[i]

for i in range(100):
    h = p_2.count(i)
    h_2 = p_2.count(-i)
    if h==0 and h_2!=0:
        print(x-i)
        break
     elif h!=0 and h_2==0:
        print(x+i)
        break
    elif h==0 and h_2==0:
        print(x-i)
        break

x, n = map(int, input().split())
#if n==0:
#    print(x)
p = list(range(n))
p = list(map(int, input().split()))
p_2 = list(range(n))
for i in range(n):
    p_2[i] = x-p[i]
for i in range(100):
    h = p_2.count(i)
    h_2 = p_2.count(-i)
    if h==0 and h_2!=0:
        print(x-i)
        break
    elif h!=0 and h_2==0:
        print(x+i)
        break
    elif h==0 and h_2==0:
        print(x-i)
        break
#if n==0:
#    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):
import sys
import operator

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

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

import sys
import operator

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

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

import sys
import operator

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

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

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())
x,n = map(int, "100 0".split())
# line = list(map(int, input().split()))
line = list(map(int, "".split()))

plus = x
minus = x

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

while True:

    if plus <= 100:
        plus += 1

    if minus >= 0:
        minus -=1


    if not minus in line:
        print(minus)
        exit()

    if not plus in line:
        print(plus)
        exit()

    if plus > 100 and minus < 0:
      exit()


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

plus = x
minus = x

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

while True:

    if plus <= 100:
        plus += 1

    if minus >= 0:
        minus -=1


    if not minus in line:
        print(minus)
        exit()

    if not plus in line:
        print(plus)
        exit()

    if plus > 100 and minus < 0:
      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):
a,b=input().split()
pp=input().split()
a=int(a)
b=int(b)
p=[]
for pa in pp:
    p.append(int(pa))
x=0
y=-1
while:
    if a+x not in p:
        aa=a+x
        break
    elif a+y not in p:
        aa=a+y
        break
    x+=1
    y+=-1
print(aa)

a,b=input().split()
pp=input().split()
a=int(a)
b=int(b)
p=[]
for pa in pp:
    p.append(int(pa))
x=0
y=-1
while True:
    if a+x not in p:
        aa=a+x
        break
    elif a+y not in p:
        aa=a+y
        break
    x+=1
    y+=-1
print(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):
x, n = map(int, input().split(" "))
p = list(map(int, input().split(" ")))

p_under = list(filter(lambda v: v<x, p))
p_upper = list(filter(lambda v: v>x, p))
p_under.sort(reverse=True)
p_upper.sort()

cnt = 0
while(True):
    if x - cnt not in p_under:
        print(x - cnt)
        break
    if x + cnt not in p_upper:
        print(x + cnt)
        break
    cnt += 1


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

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

    p_under = list(filter(lambda v: v<=x, p))
    p_upper = list(filter(lambda v: v>=x, p))
    p_under.sort(reverse=True)
    p_upper.sort()

    cnt = 0
    while(True):
        if x - cnt not in p_under:
            print(x - cnt)
            break
        if x + cnt not in p_upper:
            print(x + cnt)
            break
        cnt += 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):
def abc170_c_1():
    
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        search_range_min = min(min(p), x) - 1
        search_range_max = max(max(p), x) + 1
        search_values = [i for i in range(search_range_min, search_range_max + 1) if i not in p]

        
        ans = min(search_values, key=lambda a: (abs(a - x)), x)

        
        # ans = min(search_values, key=lambda a: abs(a - x))

        return ans

    print(solve())

if __name__ == '__main__':
    abc170_c_1()


def abc170_c_2():
    
    def solve():
        x, n = map(int, input().split(' '))
        if n == 0:
            return x

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

        for i in range(100):
            for s in [-1, +1]:
                a = x + i * s
                if a not in p:
                    return a
    print(solve())

if __name__ == '__main__':
    abc170_c_2()

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

X, N = list(map(int, input().split()))
if N==0:
    print(X)
else:
    ps = list(map(int, input().split()))
    sub_abs = 0
    while True:
        if (X-sub_abs) not in ps:
            print(X-sub_abs)
            break
        if (X+sub_abs) not in ps:
            print(X+sub_abs)
            break
        sub_abs += 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 = [int(i) for i in input().split(" ")]

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(max(p) + 1)}
ranges = all_p - p

print(ranges)

diff = 1e9
ans = 0
for i in ranges:
    if diff > abs(i - X):
        diff = abs(i - X)
        ans = i

print(ans)

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

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

p = {int(i) for i in input().split(" ")}

all_p = {i for i in range(1000)}
ranges = all_p - p

diff = 1e9
for i in ranges:
    if diff > abs(i - X):
        diff = abs(i - X)

ans_1 = X + diff
ans_2 = X - diff

for i in ranges:
    if i == ans_2:
        print(ans_2)
        break
else:
    print(ans_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):
def solve(x, ls):
    y = 0
    m = x
    for i in range(1, 102):
        if i in ls:
            continue
        if abs(x - i) < m:
            y = i
            m = abs(x - i)
    return y


def main(istr, ostr):
    x, n = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(x, ls)
    print(result, file=ostr)


def solve(x, ls):
    y = 0
    m = x
    for i in range(1, 102):
        if i in ls:
            continue
        if abs(x - i) < m:
            y = i
            m = abs(x - i)
    return y


def main(istr, ostr):
    x, n = list(map(int, istr.readline().strip().split()))
    ls = list(map(int, istr.readline().strip().split()))
    result = solve(x, ls)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)


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

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


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

for i in range(x[1]+1):
    for j in [-1,1]:
        if set() == {x[0]+j*i}&y:
            print(x[0]+j*i)
            sys.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())

if N == 0:
  print(X)
  
else:
  P = list(map(int, input().split()))
  A = [0]
  for i in range(1, 102):
    if (i in P) == False:
      A.append(i)
      
  c = 0
  for j in range(len(A)):
    if abs(X - A[j]) < abs(X - c):
      c = A[j]
    else:
      c = c
  print(A)
  
  

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

if N == 0:
  print(X)
  
else:
  P = list(map(int, input().split()))
  A = [0]
  for i in range(1, 102):
    if (i in P) == False:
      A.append(i)
      
  c = 101
  for j in range(len(A)):
    if abs(X - A[len(A)-int(j)-1]) <= abs(X - c):
      c = A[len(A)-int(j)-1]
    else:
      c = c
  print(c)
  
  


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()))
p_bar=[]
for i in range(0,101):
  if i not in p:
    p_bar.append(i)

d_min=1000
for i in p_bar:
  d = abs(X-i)
  if d < d_min:
    d_min = d
if X-d_min >= 0:
  print(X-d_min)
else:
  print(X+d_min)


X,N=map(int,input().split())
p=list(map(int,input().split()))
p_bar=[]
for i in range(0,102):
  if i not in p:
    p_bar.append(i)

d_min=1000
i_min = 0
for i in p_bar:
  d = abs(X-i)
  if d < d_min:
    d_min = d
    i_min = i
print(i_min)


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()))
for d in range(X + 1):
    for s in [-1, +1]:
            a = X + s * d
if p.count(a) == 0:
print(a)
exit(0)


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


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


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


if N == 0:
    print(X)

for i in range(102):
    if X - i not in p:
        print(x - i)
        exit()
    
    if X + i not in p:
        print(x + i)
        exit()


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


if N == 0:
    print(X)

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


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


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

for i in range(102):
    if X - i not in p:
        print(X - i)
        exit()
    
    if X + i not in p:
        print(X + i)
        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):
# coding: utf-8
# Your code here!


x,n = map(int, input().split())
def deflis(n):
    tempn=int(n)
    return tempn-x
num_list = list(map(deflis, input().split()))
num_list.sort()
count=0
maxans=0
minans=0
maxflag=False
minflag=False
minlist=[]
maxlist=[]
for num in num_list:
    if(num<0):
        minlist.append(num)
    else:
        maxlist.append(num)

for mintemp in range(len(minlist)):
    if(minlist[len(minlist)-mintemp-1]==minans):
        minans=minans-1
for maxtemp in maxlist:
    if(maxtemp==maxans):
        maxans=maxans+1

if(abs(minans)>abs(maxans)):
    print(x+maxans)
else:
    print(x+minans)

# coding: utf-8
# Your code here!


x,n = map(int, input().split())
def deflis(n):
    tempn=int(n)
    return tempn-x
num_list = list(map(deflis, input().split()))
num_list.sort()
count=0
maxans=0
minans=0
maxflag=False
minflag=False
minlist=[]
maxlist=[]
for num in num_list:
    if(num<0):
        minlist.append(num)
    elif(num==0):
        minlist.append(num)
        maxlist.append(num)
    else:
        maxlist.append(num)

for mintemp in range(len(minlist)):
    if(minlist[len(minlist)-mintemp-1]==minans):
        minans=minans-1
for maxtemp in maxlist:
    if(maxtemp==maxans):
        maxans=maxans+1

if(abs(minans)>abs(maxans)):
    print(x+maxans)
else:
    print(x+minans)

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:
    p = {int(i) for i in input().split()}
if n == 0:
    print(x)
else:
    if x not in p:
        print(x)
    else:
        flag = True
        abs_diff = 1
        while flag:
            for i in range(1, 3):
                ans = x + (-1)**i * abs_diff
                if ans not in p:
                    flag = False
                    break
            print(ans)
            abs_diff += 1

x, n = map(int, input().split())
if n:
    p = {int(i) for i in input().split()}
if n == 0:
    print(x)
else:
    if x not in p:
        print(x)
    else:
        flag = True
        abs_diff = 1
        while flag:
            for i in range(1, 3):
                ans = x + (-1)**i * abs_diff
                if ans not in p:
                    flag = False
                    print(ans)
                    break
            abs_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):

X, N = map(int, input().split()) 
num_list = list(map(int, input().split())) 
for i in range(len(num_list)):
    num_list[i] = num_list[i]-X
print(num_list)
for i in range(101):
    if (-i in num_list) is False:
        print(X-i)
        break
    if (i in num_list) is False:
        print(X+i)
        break


X, N = map(int, input().split()) 
num_list = list(map(int, input().split())) 
for i in range(len(num_list)):
    num_list[i] = num_list[i]-X
for i in range(101):
    if (-i in num_list) is False:
        print(X-i)
        break
    if (i in num_list) is False:
        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())
a=list(map(int,input().split()))
if n==0:
  print(x)
else:
  for i in range(1,101):
    if i not in a:
      print(i)
      break


x,n=map(int,input().split())
a=list(map(int,input().split()))
if n==0:
  ans=x
else:
  ans=0
  for i in range(101):
    y=x-i
    if y not in a:
      ans=y
      break
    z=x+i
    if z not in a:
      ans=z
      break
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):
from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

memos = [False] * 102

for p in P:
    memos[p] = True

tgt = x
offset = 1
look_down = True
while True:

    if memos[tgt] == False:
        break
    if look_down:
        look_down = False
        tgt = tgt-offset
    else:
        look_down = True
        tgt = offset + offset
        offset += 1

print(tgt)


from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

    memos = [False] * 102

    for p in P:
        memos[p] = True

    tgt = x
    offset = 1
    look_down = True
    while True:

        if memos[tgt] == False:
            break
        if look_down:
            look_down = False
            tgt = tgt-offset
        else:
            look_down = True
            tgt = offset + offset
            offset += 1

    print(tgt)
else:
    print(x)


from sys import stdin

x, n = [int(x) for x in stdin.readline().rstrip().split()]
if n > 0:
    P = [int(x) for x in stdin.readline().rstrip().split()]

    memos = [False] * 102

    for p in P:
        memos[p] = True

    tgt = x
    offset = 1
    look_down = True
    while True:

        if memos[tgt] == False:
            break
        if look_down:
            look_down = False
            tgt = x-offset
        else:
            look_down = True
            tgt = tgt + offset + offset
            offset += 1

    print(tgt)
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):
a,b = map(int, input().split())
if b>0:
	p = list(map(int, input().split()))
else:
	print(a)
	exit()

n = a
m = a

for i in range(b):
	print(n)
	print(m)
	print("")
	if n in p:	a,b = map(int, input().split())
if b>0:
	p = list(map(int, input().split()))
else:
	print(a)
	exit()

n = a
m = a

for i in range(b):
	if n in p:	
		n = n-1
			
	else:
		if n < 1:
			continue
		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()


	
		n = n-1
		if n < 1:
			n = 1
	else:
		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()


	

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

n = a
m = a

for i in range(b):
	print(n)
	print(m)
	print("")
	if n in p:	
		n = n-1
		if n < 1:
			n = 1
	else:
		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()


	

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

n = a
m = a

for i in range(b+1):
	"""
	print(n)
	print(m)
	print("")
	"""
	if n in p:	
		n = n-1			
	else:

		print(n)
		exit()

	if m in p:		
		m = m+1
	else:
		print(m)
		exit()

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 = list(map(int, input().split()))
if N != 0:
    P = list(map(int, input().split()))
    ans = 0
    L = X
    L = X
    for _ in range(N // 2):
        L = L - 1
        H = H + 1
        if L not in P:
            print(L)
            break
        if H not in P:
            print(H)
            break
else:
    print(X)

X, N = list(map(int, input().split()))
if N > 0:
    P = list(map(int, input().split()))
    l = X
    h = X
    while True:
        if l not in P:
            print(l)
            break
        if h not in P:
            print(h)
            break
        l -= 1
        h += 1
else:
    input()
    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()))
i = 0
while True:
    ans = x - i
    if ans in P:
        ans = x + i
        if ans in P:
            continue
        else:
            print(ans)
            break
    else:
        print(ans)
        break
    i = i + 1

x,n = map(int,input().split())
P = list(map(int,input().split()))
i = 0
if not x in P:
    print(x)
else:
    while True:
        ans = x - i
        if not ans in P:
            print(ans)
            break
        else:    
            ans = x + i
            if not ans in P:
                print(ans)
                break
        i = i + 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()
a=input().split()
for i in range(n):
  if x-i not in a:
    print(x-i)
    exit()
  if x+i not in a:
    print(x+i)
    exit()

x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
a=list(map(int,input().split()))
for i in range(n+1):
  if x-i not in a:
    print(x-i)
    exit()
  if x+i not in a:
    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())
p = list(map(int,input().split()))

num = []
for i in range(102):
    num.append(i)
for j in range(n):
    num.remove(p[j])

a = 1000000000000
b = 0
for k in range(102-n):
    if(abs(x-num[k]) < a):
        a = abs(x-num[k])
        b = num[k]

print(b)

print(num)

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

num = []
for i in range(102):
    num.append(i)
for j in range(n):
    num.remove(p[j])

a = 1000000000000
b = 0
for k in range(102-n):
    if(abs(x-num[k]) < a):
        a = abs(x-num[k])
        b = num[k]

print(b)

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):
# abc170_c.py
X , N = map(int,input().split())
P = list(map(int,input().split()))
ans = (X,0)
for i in range(101):
    if P.count(i)==0:
        print(abs(X-i),i,X,ans)
        if ans[0] > abs(X-i):
            ans = (abs(X-i),i)
print(ans[1])



# abc170_c.py
X , N = map(int,input().split())
P = list(map(int,input().split()))
ans = (X,0)
for i in range(1010):
    if P.count(i)==0:
        # print(abs(X-i),i,X,ans)
        if ans[0] > abs(X-i):
            ans = (abs(X-i),i)
print(ans[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):
import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

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

def main():

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

if __name__ == '__main__':
    main()


import argparse
import collections
import logging.config
import sys
import csv
import numpy as np

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

def main():

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


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

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

ans=float("inf")
val=-1
for p in P:
    if abs(p-X)<ans:
        val=p
        ans=abs(p-X)
print(val)


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


diff=float('inf')
ans=-1
for i in range(-100,110):
    if i in P:
        continue
    d = abs(X-i)
    if d<diff:
        ans=i
print(ans)


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


diff=float('inf')
ans=-1
for i in range(-100,110):
    if i in P:
        continue
    d = abs(X-i)
    if d<diff:
        diff=d
        ans=i
print(ans)


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()))
ans = 1000
jugh = 1000
for i in range(0, 150):
    if abs(x-i) <= jugh and i not in p:
        jugh = abs(x-i)
        ans = i
    # print(ans)
print(jugh)


x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 1000
for i in range(0, 150):
    if abs(x-i) <= ans and i not in p:
        ans = abs(x-i)
    # print(ans)
print(ans)


x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 1000
jugh = 1000
for i in range(0, 150):
    if abs(x-i) < jugh and i not in p:
        jugh = abs(x-i)
        ans = i
    # print(ans)
print(ans)


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())
lst = list(map(int,input().split()))
ans = lst[0]

for e in lst:
  if abs(e-n) < abs(e-ans):
    ans = e
   
  elif abs(e-n) == abs(e-ans):
    ans = min(e,ans)
    
  else:
    pass
  
print(ans)

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

ans = x
if ans in lst:
    pass
else:
    print(ans)
    exit()

left,right = ans-1,ans+1

while True:
    if left in lst and right in lst:
        left -=1
        right += 1

    elif left in lst:
        print(right)
        exit()

    else:
        print(left)
        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):
# coding: utf-8
# Your code here!
a,b = map(int, input().split()) 

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

    

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


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


num[0]=False
print(num)

count=0
min_min=100
min_max=100
i=a
#print()
#print(i)

flag_i=0
frag_j=0
if i==100 and num[100]==True:
    print(100)
    exit()
    
#elif i==100 and 100 in num_list:
    
if i==100:
    i=99
    
    
while 1:
    if i-1==99:
        flag_i=1
        min_min=99
        break
    elif num[i-1]==True:
        min_min=i-a
        break
    i+=1
j=a
#print(min_min)
print(i)
count=0

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

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

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

    

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


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


num[0]=False
#print(num)

count=0
min_min=100
min_max=100
i=a
#print()
#print(i)

flag_i=0
frag_j=0
if i==100 and num[100]==True:
    print(100)
    exit()
    
#elif i==100 and 100 in num_list:
    
if i==100:
    i=99
    
    
while 1:
    if i-1==99:
        flag_i=1
        min_min=99
        break
    elif num[i-1]==True:
        min_min=i-a
        break
    i+=1
j=a
#print(min_min)
#print(i)
count=0

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

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

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

if n != 0:
    ps = list(map(int, input().split()))

    ans = 0
    sa = x
    
    for i in range(0, 102):
        if i not in ps and abs(x-i) < sa:
            ans = i
            sa = x-i
            print(ans, sa)
    
    print(ans)
    
else:
    print(x)

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

if n != 0:
    ps = list(map(int, input().split()))

    ans = 0
    sa = x
    
    for i in range(0, 102):
        if i not in ps and abs(x-i) < sa:
            ans = i
            sa = x-i
    
    print(ans)
    
else:
    print(x)

Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

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

	
	

	
	

i=N
j=0
while True:
	if X-j not in p_list:
		print(X+j)
		exit()
	elif X+j not in p_list:
		print(X-j)
		exit()
	else:
		j+=1



X, N =map(int, input().split())
p_list=list(map(int, input().split()))
#i=N

	
	

	
	

i=N
j=0
while True:
	if X-j not in p_list:
		print(X+j)
		exit()
	elif X+j not in p_list:
		print(X-j)
		exit()
	else:
		j+=1



N=int(input())
ans=""
check="abcdefghijklmnopqrstuvwxyz"

while N!=0:
	N-=1
	ans+=check[N%26]
	N=N//26

print(ans[::-1])





X, N =map(int, input().split())
p_list=list(map(int, input().split()))
#i=N

	
	

	
	

i=N
j=0
while True:
	if X-j not in p_list:
		print(X-j)
		exit()
	elif X+j not in p_list:
		print(X+j)
		exit()
	else:
		j+=1



Verdicts: Wrong Answer

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 = input().split()
X = int(X)
N = int(N)

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

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

if X not in P:
    print(X)

flag_p = True
flag_n = True

abs_num = 0
abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False

    if(flag_n == True & flag_p == True):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_n == True & flag_p == False):
        print(abs_num_p)
        break;
    elif(flag_n == False):
        print(abs_num_n)
        break;

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

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

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


flag_p = True
flag_n = True

abs_num = 0
abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False

    if(flag_p == True & flag_n == True):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_n == True & flag_p == False):
        print(abs_num_p)
        break;
    elif(flag_n == False):
        print(abs_num_n)
        break;
    abs_num_p += 1
    abs_num_n -= 1


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

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

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

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


abs_num_p = X + 1
abs_num_n = X - 1
while True:

    if abs_num_p in P:
        flag_p = True
    else:
        flag_p = False

    if abs_num_n in P:
        flag_n = True
    else:
        flag_n = False
    if(  flag_p == True  and flag_n == True ):
        abs_num_p += 1
        abs_num_n -= 1
        continue;
    elif(flag_p == True  and flag_n == False):
        print(abs_num_n)
        break;
    elif(flag_p == False and flag_n == True ):
        print(abs_num_p)
        break;
    elif(flag_p == False and flag_n == False):
        print(abs_num_n)
        break;

    i += 1


Verdicts: Wrong Answer

Wrong Answer

Accepted