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 sys

X, N = map(int, input().split())
P = list(map(int, input().split()))
NL = [i for i in range(-1000,1000) if i == X or i not in P]

if len(P) == 0:
    print(X)
    sys.exit()

idx = NL.index(X)
if abs(NL[idx + 1]) - X >= abs(NL[idx - 1]) - X ):
    print(NL[idx - 1])
else:
    print(NL[idx + 1])


import sys

X, N = map(int, input().split())
P = list(map(int, input().split()))
NL = [ i for i in range(0, 102) if i == X or i not in P ]

if len(P) == 0 or X not in P:
    print(X)
    sys.exit()

print(NL)
idx = NL.index(X)
if NL[idx + 1] - X >= X - NL[idx-1]:
    print(NL[idx-1])
else:
    print(NL[idx+1])



import sys

X, N = map(int, input().split())
P = list(map(int, input().split()))
NL = [ i for i in range(0, 102) if i == X or i not in P ]

if len(P) == 0 or X not in P:
    print(X)
    sys.exit()

idx = NL.index(X)
if NL[idx + 1] - X >= X - NL[idx-1]:
    print(NL[idx-1])
else:
    print(NL[idx+1])


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
import sys

x, n = map(int, input().split())
if(n==0):
  print(x)
  sys.exit()
p = list(map(int, input().split()))
q = [0]*n
l = 1000
for i in range(n):
  q[i] = abs(p[i]-x)
for j in range(120):
  for k in range(n):
    l = min(abs(q[k]-j),l)
  if(not(l ==0)):
    for m in range(n):
      if(x + j -p[i] == abs(x + j -p[i])):
        print(x-j)
        sys.exit()
      else:
        print(x+j)
        sys.exit()
      

import numpy as np
import sys

x, n = map(int, input().split())
if(n==0):
  print(x)
  sys.exit()
c = 0
b = 0
p = list(map(int, input().split()))
for i in range(102):
  for j in range(n):
    if(p[j] - x + i == 0):
      c+=1
    if(p[j] - x - i==0):
      b+=1
  if(b==0 or c==0):
    if(c==0):
      print(x-i)
      sys.exit()
    else:
      print(x+i)
      sys.exit()
  else:
    b=0
    c=0

Verdicts: Wrong Answer

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

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

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

  if (int(x) not in p):
    print(int(x))
    count=1


  while (count==0):
    for i in range(int(n)):
      if (abs(int(p[i])-int(x)) == add):
        count = count+1
    if (count==2):
        add = add+1
        count=0
    if (count==1):
      if (int(x)-add in p):
        print(int(x)+add)
      else:
        print(int(x)-add)
    if (count==0):
      print(int(x)-add)
      count=1
else:
  print(int(x))

x, n = input().split()

if (int(n)>0):
  add = 1
  count = 3
  p = list(map(int,input().split()))

  if (int(x) not in p):
    print(int(x))
    count=1


  while (count==3):
    count = 0
    for i in range(int(n)):
      if (abs(int(p[i])-int(x)) == add):
        count = count+1
    if (count==2):
        add = add+1
        count=3
    if (count==1):
      if (int(x)-add in p):
        print(int(x)+add)
      else:
        print(int(x)-add)
    if (count==0):
      print(int(x)-add)
else:
  print(int(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):
import copy
x,n = list(map(int, input("").split()))
p = list(map(int, input("").split()))

mina =101
y = []
minc = []

for x not in p:
    print(x)
    exit()

for i in range(1,101):
    y.append(i)

if n == 0:
    print(x)
else:
    for j in range(n):
        y.remove(p[j])

    z = copy.copy(y)

    for k in range(len(y)):
        if abs(x - y[k]) < mina:
            mina = abs(x - y[k])
            minb = y[k]
            z.remove(minb)

    minc.append(minb)
    mina = 101

    for m in range(len(z)):
        if abs(x - z[m]) < mina:
            mina = abs(x - z[m])
            minb = z[m]

    minc.append(minb)

    print(min(minc))

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

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

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

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

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


Verdicts: Time Limit Exceeded

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

MAX = 0
for i in range(N):
  if MAX < X - p[i]:
    MAX = X - p[i]
    
for i in range(MAX):
  if X - i not in p:
    ans = X - i
    break
for i in range(MAX):
  if X + i not in p:
    ans = min(X - ans, ans - X) + X
    break
print(ans)

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

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Verdicts: Runtime Error

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

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

def minusx(f):
    return f-x

if n !=0:
    plist =list(map(int,input().split(" ")))
    # print(x,n)
    # print(plist)
    plistx = list(map(minusx,plist))
    # print(plistx)
    plisty = list(map(abs,plistx))
    # print(plisty)
    plisty_max = max(plisty)
    print(plisty_max)

    if plisty_max == 0:
        plisty_max =1
    
    print(plisty_max)

    newlist = list(range(x-plisty_max,x+plisty_max+1))
    print(newlist)
    pset_diff = set(plist) ^ set(newlist)
    plist_diff = list(pset_diff)
    print(plist_diff)
    plist_plus = [i for i in plist_diff if i>0 and i<=100]
    print(plist_plus)

    for i in range(202):
        if x-i in plist_plus:
            print(x-i)
            break
        elif x+i in plist_plus:
            print(x+i)
            break
else:
    print(x)

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

def minusx(f):
    return f-x

if n !=0:
    plist =list(map(int,input().split(" ")))
    for i in range(100):
        if x-i not in plist:
            print(x-i)
            break
        elif x+i not in plist:
            print(x+i)
            break
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):
if __name__=="__main__":
    
    X, N = map(int, (input().split(' ')))
    if N > 0:
        P = map(int, input().split(' '))
        P_max = max(P)
        P_min = min(P)
        if X in P:
            for i in range(0, 100):
                if (X-i) not in P:
                    print(X-i)
                    break

                elif (X+i) not in P:
                    print(X+i)
                    break
        elif X not in P:
            print(X)
    else:
        print(X)

    X, N = map(int, (input().split(' ')))
    if N > 0:
        P = sorted(map(int, input().split(' ')))
        P_max = max(P)
        P_min = min(P)
        if X in P:
            for i in range(1, max(P_max-X + 1 , X-P_min +1)):
                if (X-i) not in P:
                    print(X-i)
                    break

                elif (X+i) not in P:
                    print(X+i)
                    break
        elif X not in P:
            print(X)
        else:
            print(" ")
    else:
        print(" ")



if __name__=="__main__":
    
    X, N = map(int, (input().split(' ')))
    if N > 0:
        P = sorted(map(int, input().split(' ')))
        P_max = max(P)
        P_min = min(P)
        if X in P:
            for i in range(100):
                if (X-i) not in P:
                    print(X-i)
                    break

                elif (X+i) not in P:
                    print(X+i)
                    break
        elif X not in P:
            print(X)
    else:
        print(X)

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,y=map(int,input().split())
if x*2>y:
    print('No')
else:
  if y%2==1 :
    print('No')
  else:
    if x*4<y :
      print('No')
    else:
      print('Yes')

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

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()))
if n == 0:
    print(x)
elif not(x in l):
     print(x)   
else:
    for i in range(n//2):
        if not(x - i in l):
            print(x-i)
            break
        elif not (x+i in l):
            print(x+i)
            break
            

x, n =map(int, input().split())
l = list(map(int, input().split()))
if n == 0:
    print(x) 
else:
    for i in range(n//2 + 2):
        if not(x - i in l):
            print(x-i)
            break
        elif not (x + i in l):
            print(x+i)
            break
            

Verdicts: Wrong Answer

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

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

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


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


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

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


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

P.sort()
olp=lowp=min(P)-2
ohp=hip=max(P)+2
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        if olp<x :
            lowp=x
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )


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

P.sort()
olp=lowp=min(P)-2
ohp=hip=max(P)+2
l=len(P)-1
for i in range(len(P)):
    if P[i]>x :
        if olp<x :
            lowp=x
        break
    if P[i]-olp>1:
        lowp = P[i]-1
    olp=P[i]

for i in range(len(P)):
    if P[l-i]<x :
        break
    if ohp-P[l-i]>1:
        hip = P[l-i]+1
    ohp=P[l-i]

# print( lowp, hip, x )

ans = lowp
if x-lowp > hip-x :
    ans = hip
print( ans )

Verdicts: Wrong Answer

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

Submission attempts (in order):
x, n = map(int, input().split())
p = map(int, input().split())
p_list = sorted(list(p), reverse=False)
dist_list = list(map(lambda y: abs(y-x), p_list))
all_list = [[]]
ans = 0
for i in range(n):
  all_list.append([p_list[i], dist_list[i]])
del all_list[0] 
sort_list = sorted(all_list, key=lambda z:(z[1],z[0]))
ans = int(sort_list[0][0])
print(ans)

x,n = map(int,input().split())
if n == 0:
  ans = x
else:
  p = [int(i.strip()) for i in input().split()]
  for i in range(n):
    ch_1 = x-i
    ch_2 = x+i
    if p.count(ch_1) == 0:
      ans = ch_1
      break
    elif p.count(ch_2) == 0:
      ans = ch_2
      break
    else:
      ans = x
print(p)

x, n = map(int, input().split())
p = map(int, input().split())
p_list = sorted(list(p), reverse=False)
dist_list = list(map(lambda y: abs(y-x), p_list))
all_list = [[]]
ans = 0
for i in range(n):
  all_list.append([p_list[i], dist_list[i]])
del all_list[0] 
sort_list = sorted(all_list, key=lambda z:(z[1],z[0]))
ans = int(sort_list[0][0])
print(ans)

x, n = map(int, input().split())
p = map(int, input().split())
p_list = sorted(list(p), reverse=False)
dist_list = list(map(lambda y: abs(y-x), p_list))
all_list = [[]]
for i in range(n):
  all_list.append([p_list[i], dist_list[i]])
del all_list[0] 
sort_list = sorted(all_list, key=lambda z:(z[1],z[0]))
print(sort_list)

x,n = map(int,input().split())
if n == 0:
  ans = x
else:
  p = [int(i.strip()) for i in input().split()]
  for i in range(n+1):
    ch_1 = x-i
    ch_2 = x+i
    if p.count(ch_1) == 0:
      ans = ch_1
      break
    elif p.count(ch_2) == 0:
      ans = ch_2
      break
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

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

Submission attempts (in order):
import collections
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
p=list(map(lambda i:abs(x-i),p))
c=collections.Counter(p)
p.sort()

for i in range(len(p)):
  if p[i]!=(i+1)//2:
    if p[i-1]==p[i-2]:
      if x-p[i-1]-1 in p:
        print(x-p[i-1]+1)
      else:
        print(x-p[i-1]-1)
      sys.exit()
    elif i==1:
      if x-1 in p:
        print(x+1)
      else:
        print(x-1)
      sys.exit()
    elif i==0:
      print(x)
      sys.exit()
    else:
      if x-p[i] in p:
        print(x+p[i])
      else:
        print(x-p[i])
      sys.exit()
print(x)

import sys
x,n=map(int,input().split())
q=list(map(int,input().split()))
q=q+[100000000]
p=list(map(lambda i:abs(x-i),q))

p.sort()
if n==0:
  print(x)
  sys.exit()
for i in range(len(p)):
  if p[i]!=(i+1)//2:
    if i==0:
      print(x)
      sys.exit()
    elif i==1:
      print(x-1)
      sys.exit()
    elif p[i-1]==p[i-2]:
      print(x-p[i-1]-1)
      sys.exit()
    else:
      if x-p[i-1] in q:
        print(x+p[i-1])
      else:
        print(x-p[i-1])
      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):
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(n):
      if i in a:
        continue
      else:
        cnt=i
    print(cnt)

# coding: utf-8
# Your code here!
n,m=map(int,input().split())
a=list(map(int,input().split()))
if len(a)==0:
  print(n)
else:
  a.sort()
  if n not in a:
    print(n)
  else:
    cnt=0
    for i in range(102):
      if i in a:
        continue
      elif abs(cnt-n)>abs(i-n):
        cnt=i
    print(cnt)



Verdicts: Wrong Answer

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

Submission attempts (in order):
X, Y = map(int, input().split())


def myfunc(X, Y):
    for tsuru in range(X+1):
        turtle = X - tsuru
        legs = turtle * 4 + tsuru * 2

        if legs == Y:
            return "Yes"

    return "No"

print(myfunc(X,Y))

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

not_p = set(range(102)) - set(P)

min_value = 200
min_list = []

for v in not_p:
    dist = abs(X-v)

    if dist < min_value:
        min_value = dist
        min_list = [v]

    if dist == min_value:
        min_list.append(v)

print(min(min_list))


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 = [map(int, input().split())]
a = 0
while True:
  if X-a in A:
    if X+a in A:
    a += 1
    else:
      print(X+a)
      break
  else:
    print(X-a)
    break

X, N = map(int, input().split())
A = [map(int, input().split())]
a = 0
while True:
  if X-a not in A:
      print(X-a)
      break
  if X+a not in A:
      print(X+a)
      break
  a += 1


X, N = map(int, input().split())
A = [map(int, input().split())]
a = 0
while True:
  if X-a in A:
    if X+a in A:
    a +=1
    else:
      print(X+a)
      exit()
  else:
    print(X-a)
    exit()

X, N = map(int, input().split())
A = [int(input()) for i in range(N)]
a = 0
while True:
  if X-a in A:
    if X+a in A:
    a +=1
    else:
      print(X+a)
      exit()
  else:
    print(X-a)
    exit()


X, N = map(int, input().split())
A = list(map(int, input().split()))
a = 0
while True:
  if X-a not in A:
      print(X-a)
      break
  if X+a not in A:
      print(X+a)
      break
  a += 1

Verdicts: Runtime Error

Wrong Answer

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,*p=map(int,open(i:=0).read().split())
while x in p:x+=i*-1**i;i+=1
print(x)

x,n,*p=map(int,open(i:=0).read().split())
while x in p:x+=(-1)**i*i;i+=1
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):
from bisect import bisect_left
x, n = map(int, input().split())
if n != 0:
    P = list(map(int, input().split()))
    P = sorted(P)
else:
    P = []

flag = False
ans = []
if x not in P or n == 0:
    ans.append(x)
else:
    idx = bisect_left(P, x)
    for i in range(n):
        for_num = P[idx] + 1
        bac_num = P[idx] - 1
        if for_num not in P:
            ans.append(for_num)
            flag = True
        if bac_num not in P:
            ans.append(bac_num)
            flag = True
        if flag:
            break

print(min(ans))

from bisect import bisect_left
x, n = map(int, input().split())
if n != 0:
    P = list(map(int, input().split()))
    P = sorted(P)
else:
    P = []

flag = False
ans = []
if x not in P or n == 0:
    ans.append(x)
else:
    idx = bisect_left(P, x)
    for i in range(1, 110):
        for_num = P[idx] + i
        bac_num = P[idx] - i
        if for_num not in P:
            ans.append(for_num)
            flag = True
        if bac_num not in P:
            ans.append(bac_num)
            flag = True
        if flag:
            break

print(min(ans))

Verdicts: Runtime Error

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

Submission attempts (in order):
x, n = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(1, 101) if i not in P]

ans = notP[0]
for p in notP:
  delta = abs(x - p)
  if delta<ans:
    ans = p
    
print(ans)

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

import sys

if n==0:
  print(x)
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(0, 102) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
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 collections

N = int(input())
h = list(map(int, input().split()))
h.sort(reverse = True)
l = []
for i in range(0, N):
    d = []
    for j in range(0, max(0, len(l))):
        if l[j] % h[i] == 0:
            d.append(l[j])
    for k in range(0, len(d)):
        l.remove(d[k])
    l.append(h[i])
if len(collections.Counter(h)) == 1:
    l.clear()
print(len(l))

X, N = map(int, input().split())
h = list(map(int, input().split()))
ans = []
for i in range(0, N+1):
    if X+i not in h:
        ans.append(X+i)
    if X-i not in h:
        ans.append(X-i)
    if ans != []:
        break
print(min(ans))

Verdicts: Runtime Error

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

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

ans_enable = [True] * 102
for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)

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

ans_enable = [True] * 102

for pi in p:
    ans_enable[pi] = False

diff = 0

check_ok = ans_enable[X]

ans_small = True

while not check_ok:
    diff += 1
    if ans_enable[X - diff]:
        check_ok = True
        ans_small = True
    elif ans_enable[X + diff]:
        check_ok = True
        ans_small = False

print(X - diff if ans_small else X + diff)

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()))
A = []
try:
  P = list(map(int, input().split()))
  list_int = [x for x in range(0, 102)]
  list_int_d = list(set(list_int) - set(P))
  list_int_d.sort()
  print(list_int_d)
  for i in list_int_d:
    A.append(abs(X - i))
  if 0 in A:
    print(X)
  else:
    Index = A.index(min(A))
    print(list_int_d[Index])
except EOFError:
  print(X)

x, n = map(int, input().split())
try:
  list_P = [int(p) for p in input().split()]
  list_not_P = [x for x in range(102) if not x in list_P]
  list_abs = [abs(x - i) for i in list_not_P]
  Index = list_abs.index(min(list_abs))
  print(list_not_P[Index])
except EOFError:
  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()
b = input()
t = int(a.split(" ")[0])
lst = [int(x) for x in b.split(" ")]
x = len(lst)
if not x:
  print(t)
for i in range(x):
  if t - x not in lst:
    print(t - x)
    break
  if t + x not in lst:
    print(t + x)
    break


a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(c+2):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + 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):
def forbidden(x,p):
    res = []
    for num in range(101):
        if x!=num:
            res.append(abs(x-num))
    if x-min(res) not in p:
        return x-min(res)
    return x+min(res)

if __name__ == "__main__":
    x,n = map(int,input().split())
    p = list(map(int,input().split()))
    if n==0:
        print(x)
        exit()
    print(forbidden(x,p))

x,n = map(int,input().split())
p = list(map(int,input().split()))
if x not in p:
    print(x)
    exit()
a,b = x,x
while True:
    a+=1
    b-=1
    if b not in p:
        print(b)
        break
    elif a not in p:
        print(a)
        break

Verdicts: Wrong Answer

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

Submission attempts (in order):
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = []
for i in range(101):
    if i not in p:
        ans.append([i - x,i])
ans.sort()
print(ans[0][1])

x,n = map(int,input().split())
p = list(map(int,input().split()))
i = 0
while True:
    if x - i not in p:
        print(x-i)
        exit()
    elif x + i not in p:
        print(x+i)
        exit()
    i += 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):
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)


N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)

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

p = set(p)
i=0
while i<101:
  n = X-i
  if not(n in p):
    ans = n
    break
  n = X+i
  if not(n in p):
    ans = n
    break
  i+=1

print(ans)

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp
  ret = i
  tmp = abs(x-i)
print(ret)

x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp:
    ret = i
    tmp = abs(x-i)
print(ret)


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:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
    return sorted(numbers_array, key=abs)

    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0])

x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(1, 100))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0])


x, n = map(int, input().split())
if n==0:
  print(x)
else:
    l1 = list(map(int,input().split()))	
    l2 = list(range(-150, 200))
    diff = set(l1) ^ set(l2)
    diff = list(diff)
    def sorting(numbers_array):
      return sorted(numbers_array, key=abs)
    sl = map(lambda a: a - x, diff)
    print(sorting(sl)[0]+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):
xin = input().split()
X, N = list(map(int, xin))


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

dist_min=1000
min_value=1000

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

print(min_value)


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


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

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


dist_min=N
min_value=X

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


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

print(min_value)


Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys

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

if(len(arr) == 0):
    print(x)
    sys.exit()

if(x in arr):
    print(x)
    sys.exit()

i = 1
while True:
    if(not (x - i in arr)):
        print(x - i)
        sys.exit()
    
    if(not (x + i in arr)):
        print(x + i)
        sys.exit()
    i += 1


import sys

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

if(len(arr) == 0):
    print(x)
    sys.exit()

if(not(x in arr)):
    print(x)
    sys.exit()

i = 1
while True:
    if(not (x - i in arr)):
        print(x - i)
        sys.exit()
    
    if(not (x + i in arr)):
        print(x + i)
        sys.exit()
    i += 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())
i = list(map(int, input().split()))

if n ==0:
  print(x)
  
if x not in i:
  print(x)
  
  else:
    p = 1
    while True:
      z = x - p
      if z not in i:
        print(z)
        break
        
      z = x + p
      if z not in i:
        print(z)
        break
        
      p = p +1
        
      
        
      
      
      
    
  
  



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


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

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

if n ==0:
  print(x)
  
if x not in i:
  print(x)
  
  else:
    p = 1
    while True:
      z = x - p
      if z not in i:
        print(z)
        break
        
      z = x + p
      if z not in i:
        print(z)
        break
        
      p = p +1
        
      
        
      
      
      
    
  
  



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

if n ==0:
  print(x)
  
if x not in i:
  print(x)
  
  else:
    p = 1
    while True:
      z = x - p
      if z not in i:
        print(z)
        break
        
      z = x + p
      if z not in i:
        print(z)
        break
        
      p = p +1
        
      
        
      
      
      
    
  
  



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


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

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
x,n = map(int,input().split())
p = list(map(int,input().split()))
print(p)
for i in range(100):
    for j in p:
        if j == (x - i):
            break
    else:
        print(x - i)
        break
    for j in p:
        if j == (x + i):
            break
    else:
        print(x + i)
        break

x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
    
p = input().split()
for i in range(100):
    for j in p:
        if int(j) == x - i:
            break
    else:
        print(x - i)
        break
    for j in p:
        if int(j) == x + i:
            break
    else:
        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())
if N == 0:
  print(X)
  exit()
A = list(map(int,input().split()))
for i in range(N):
  if (X - i) not in A:
    print(X-i)
    exit()
  elif (X + i ) not in A:
    print(X+i)

X,N = map(int,input().split())
if N == 0:
  print(X)
  exit()
A = list(map(int,input().split()))
for i in range(N*2):
  if (X - i) not in A:
    print(X-i)
    exit()
  elif (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):
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  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):
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)
    
    

N,M = map(int,input().split())
if M == 0:
  print(N)
else:
  c=list(map(int, input().split()))
  for i in range(N+1):
    for s in [-1,1]:
      a = N+s*i
      if c.count(a)==0:
      	print(a)
      	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):
if N == 0:
    P = []
else:
    P = [int(x) for x in input().split()]

for i in range(100):
    q = X - i
    if q not in P:
        print(q)
        break
    q = X + i
    if q not in P:
        print(q)
        break

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

if N == 0:
    P = []
else:
    P = [int(x) for x in input().split()]

for i in range(100):
    q = X - i
    if q not in P:
        print(q)
        break
    q = X + i
    if q not in P:
        print(q)
        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())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(1,101):
  if i not in p:
    ans=min(ans,abs(x-i))
    
    
if x-ans not in p and (x-ans)>0 and (x-ans)<=x:
  print(x-ans)
  
elif x-ans not in p and (x-ans)<=0:
  print(x+ans)

x,n=map(int,input().split())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(300):
  if i not in p:
    ans=min(ans,abs(x-i))
    
 
if x-ans not in p :
  print(x-ans)

else:
  print(x+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 exit

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

from sys import exit

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 + d*s
        if p.count(a) == 0:
            print(a)
            exit()

Verdicts: Runtime Error

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

Submission attempts (in order):
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 101

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 100)
    if low:
        print(low)
        break
    elif high:
        print(high)
        break


x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 102

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 101)
    if flag[low]:
        print(low)
        break
    elif flag[high]:
        print(high)
        break


Verdicts: Wrong Answer

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

Submission attempts (in order):
import sys

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

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

min_abs = 101
min_e = 0
for i in p[1:]:
  if abs(x-i) < min_abs:
    min_abs = abs(x-i)
    min_e = i

for i in range(1, int(len(p)/2)):
  if min_e - i not in p:
    print(min_e - i)
    break
  if min_e + i not in p:
    print(min_e + i)
    break

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

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

  min_abs = 101
  min_e = 0
  for i in p:
    if abs(x-i) < min_abs:
      min_abs = abs(x-i)
      min_e = i

  if min_abs == 0 and min_e not in p:
      print(min_e)
      return

  for i in range(1, 101):
    if min_e - i not in p:
      print(min_e - i)
      return
    if min_e + i not in p:
      print(min_e + i)
      return
    
main()

Verdicts: Wrong Answer

Accepted