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 numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                if X-maxn>a[i]+1-X
                maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))


import numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                if X-maxn>a[i]+1-X:
                    maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))


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):
# C
x, n = map(int, input().split())
p = list(map(int, input().strip().split()))
print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
        if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)


# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n = 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)

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

# C
x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
ans = 0
if n == 0:
    print(x)
elif x not in p:
    print(x)
else:
    for i in range(102):
        if i not in p:
            if abs(x - i) < abs(x - ans):
                ans = i
    print(ans)


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):
import bisect
x, n = map(int, input().split())
pN = list(map(int, input().split()))
plus_flag = 1
minus_flag = 1
pN.sort()
key_index = bisect.bisect(pN, x) - 1
plus_index = key_index
minus_index = key_index
if n == 0:
    print(x)
else:
    while(1):
        if minus_flag == 1:
            if pN[key_index] - 1 != pN[key_index-1]:
                print(pN[key_index] - 1)
                break
            else:
                minus_index = minus_index + 1

        if minus_index == 0:
            minus_flag = 0



        if plus_flag == 1:
            if pN[key_index] + 1 != pN[key_index+1]:
                print(pN[key_index] + 1)
                break
            else:
                plus_index = plus_index + 1

        if plus_index == n:
            plus_flag = 0

import bisect
x, n = map(int, input().split())
pN = list(map(int, input().split()))
plus_flag = 1
minus_flag = 1
pN.sort()
key_index = bisect.bisect(pN, x) - 1
plus_index = key_index
minus_index = key_index
print(key_index)
if n == 0:
    print(x)
else:
    while(1):
        if minus_index <= 0:
            minus_flag = 0
            
        if minus_flag == 1:
            if pN[minus_index] - 1 != pN[minus_index-1]:
                print(pN[minus_index] - 1)
                break
            else:
                minus_index = minus_index - 1

        

        if plus_index >= n:
                    plus_flag = 0

        if plus_flag == 1:
            if pN[plus_index] + 1 != pN[plus_index+1]:
                print(pN[plus_index] + 1)
                break
            else:
                plus_index = plus_index + 1

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

pN.sort()

diff = 0

if n == 0:
    print(x)
else:
    while(1):
        if x-diff not in pN:
            print(x-diff)
            exit()
        elif x+diff not in pN:
            print(x+diff)
            exit()
        diff+=1

Verdicts: Runtime Error

Runtime Error

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

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

abs_min = int(1e5)
ans = -1
for i in range(0, 102):
    if abs(x - i) < abs_min:
        abs_min = abs(x - i)
        ans = i
print(ans)

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

abs_min = int(1e5)
ans = -1
for i in range(0, 102):
    if i in a:
        continue
    if abs(x - i) < abs_min:
        abs_min = abs(x - i)
        ans = i
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
X,N = int(input().split())
list = [int(x) for x in input().split()]

min_num = 150

for a in range(-10,110):
    counter = 0
    A = abs(X - a)
    for b in list:
        if a == b:
            counter = 1
        else:
            continue
    if counter == 1:
        continue
    else:
        if A == abs(X - a):
            min_num = (a, min_num)
        elif A > abs(X - a):
            min_num = a
        else:
            continue

print(min_num)

X,N = int(input().split())
list = [int(x) for x in input().split()]

min_num = 150

for a in range(X - N - 2, X + N + 3):
    counter = 0
    A = abs(X - a)
    for b in list:
        if a == b:
            counter = 1
        else:
            continue
    if counter == 1:
        continue
    else:
        if A == abs(X - a):
            min_num = (a, min_num)
        elif A > abs(X - a):
            min_num = a
        else:
            continue

print(min_num)

X,N = input().split()
list = [int(x) for x in input().split()]

min_num = [300, abs(int(X) - 300)]

for a in range(0,102):
    A = abs(int(X) - a)
    
    if a in list:
        continue
        
    else:
        if A > min_num[1]:
            continue
            
        elif A == min_num[1]:
            min_num[0] = min(a,min_num[0])
            min_num[1] = abs(int(X) - min_num[0])
            
        elif A < min_num[1]:
            min_num[0] = a
            min_num[1] = abs(int(X) - min_num[0])
            
print(min_num[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, = map(int, input().split())
cand = set(range(101)) - set(P)
ans, temp = None, 10**10
for c in cand:
    t = abs(X - c)
    if t < temp:
        temp = t; ans = min(ans, c)
print(ans)

X, N = map(int, input().split())
*P, = map(int, input().split())
cand = set(range(-50, 151)) - set(P)
cand = sorted([c for c in cand], key=lambda x: (abs(X - x), x))
print(cand[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):
def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        print(tmp)
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_list()

def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_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())
p = list(map(int, input().split()))
ans=X


min= 1000

p.sort()

for i in range(100):
  if (i not in p ) and len(p) > 0:
    a = abs(i-X)
    if a<min:
      min=a
      ans = i


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


min= 100

p.sort()

for i in range(-200, 201):
  if (i not in p ) and len(p) > 0:
    a = abs(i-X)
    if a<min:
      min=a
      ans = i
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
X, num = [int(i) for i in input().split(" ")]
l = [int(i) for i in input().split(" ")]

if num == 0:
  print(X)
else:
  for i in range(num):
    if X-i not in l:
      print(X-i):
      exit()
    elif X+i not in l:
      print(X+i)
      exit()
  print(X-num)

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

 
if num == 0:
  print(X)
else:
  l = [int(i) for i in input().split(" ")]
  for i in range(num):
    if X-i not in l:
      print(X-i)
      exit()
    elif X+i not in l:
      print(X+i)
      exit()
  print(X-num)

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):
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  int X,N; cin >>X >>N;
  if (N==0) {cout <<X <<endl; return 0;}
  vector<int> p(N);
  rep(i,0,N) cin >>p[i];
  sort(p.begin(),p.end());
  int ans=0;
  int check=INT_MAX;
  rep_eq(i,p[0],p[N-1]) {
    bool check_flag=true;
    rep(j,0,N) {
      if (i==p[j]) {check_flag=false; break;}
    }
    if (check_flag) {
      if (abs(X-i)<check) {check=abs(X-i); ans=i;}
    }
  }
  cout <<ans <<endl;
  return 0;
}


X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
p=list(map(int,input().split()))
ans=0
check=100
for i in range(101+1):
  if i in p:
    continue
  if abs(X-i)<check:
    check=abs(X-i)
    ans=i
print(ans)


Verdicts: Runtime Error

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

Submission attempts (in order):
X,N = map(int,input().split())
P = list(map(int,input().split()))
ans = 100000000
l = 1000000
for i in range(1,101):
    if P.count(i) == 0:
        #print(i)
        if abs(i-X) < l:
            l = abs(i-X)
            ans = min(i,ans)
            #print(ans,i,l)
print(ans)

X,N = map(int,input().split())
P = list(map(int,input().split()))
ans = 100
l = 101
for i in range(0,102):
    if P.count(i) == 0:
        if abs(i-X) < l:
            #print(i)
            l = abs(i-X)
            ans = i
print(ans)


Verdicts: Wrong Answer

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

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

try:
  p = set(map(int, input().split()))
  num = set(range(-100,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref)
  print(mem)
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

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

try:
  p = set(map(int, input().split()))
  num = set(range(-1,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref)
  print(mem)
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

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

try:
  p = set(map(int, input().split()))
  num = set(range(-100,201))
  mem = []

  ref = sorted(list(num - p))

  for item in ref:
    mem.append(abs(item - X))
  
  print(ref[mem.index(min(mem))])

except EOFError:
  print(X)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import numpy as np

x,n = [int(i) for i in input().split()]
table = [int(i) for i in input().split()]
table.sort()
min = min(table)

a = np.array(table)
a = a - x
a = np.abs(a)
a = np.sort(a)
#print(a)

for i in range(n):
  if a[0] > 0:
    print(x)
    break
  elif a[i+1]-a[i]>1 and i>0:
    if a[i] > 0 and a[i] == a[i-1]:
      if x-a[i]-1 in b or x-a[i]-1 < min:
        print(x+a[i]+1)
        break
      else:
        print(x-a[i]-1)
        break
    else:
      if x-a[i] in b or x-a[i] < min:
        print(x+a[i])
        break
      else:
        print(x+a[i])
        break
      
    




def main():
  x,n = [int(i) for i in input().split()]
  table = list(map(int, input().split()))
  
  for i in range(101):
    if x - i not in table:
      print(x-i)
      exit()
    elif x + i not in table:
      print(x+1)
      exit()
    	
if __name__ == "__main__":
  main()

def main():
  x,n = [int(i) for i in input().split()]
  table = list(map(int, input().split()))
  
  for i in range(101):
    if x - i not in table:
      print(x-i)
      exit()
    elif x + i not in table:
      print(x+i)
      exit()
    	
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:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  　　print(ans)


X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(-100,1000)
  ans=X

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(ans)
  else:
    for j in range(1000):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  print(ans)

X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(-100,1000)
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(ans)
  else:
    for j in range(1000):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
  print(ans)

X,N=map(int,input().split())
if N==0:
  print(X)
else:
  p=list(map(int,input().split()))
  numbers=list(range(102))
  ans=0

  for i in range(len(p)):
    numbers.remove(p[i])

  if numbers.count(X)==1:
    print(X)
  else:
    for j in range(100):
      if numbers.count(X-j)==1:
        ans=X-j
        break
      elif numbers.count(X+j)==1:
        ans=X+j
        break
    print(ans)

Verdicts: 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):
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

X,N = I()
p = l()
p.sort()
for i in range(N):
    if p[i] > X:
        if abs(p[i]-X) > abs(p[i-1]-X):
            print(p[i-1])
            exit()
        else:
            print(p[i])
            exit()
print(p[-1])

import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
import bisect
X,N = I()
if N == 0:
    print(X)
    exit()
p = l()
A = [i for i in range(-1,102)]
for i in range(N):
    if p[i] in A:
        A.remove(p[i])
i = bisect.bisect_left(A,X)
if abs(A[i-1]-X) > abs(A[i]-X):
    print(A[i])
else:
    print(A[i-1])

Verdicts: Runtime Error

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

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

for i in range(X + 1):
    for j in [-1, +1]:
        ans = X + i * j

        if p.count(ans) == 0:
            print(ans)
            break
    else:
        continue
    break


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

for i in range(X + 1):
    for j in [-1, +1]:
        ans = X + i * j

        if p.count(ans) == 0:
            print(ans)
            break
    else:
        continue
    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())
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
  
int_list = [i for i in range(102)]
forbidden_list = sorted(list(set(int_list) - set(p)))
num_X = int_list.index(X)
c = 10000000
 
if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b >= a:
      print(forbidden_list[i])
      break
    elif b < a:
      print(forbidden_list[i + 1])
      break
  else:
    if a < b:
      print(forbidden_list[i])
    else:
      print(forbidden_list[i + 1])

X,N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except EOFError:
  p = []
  
int_list = [i for i in range(102)]
forbidden_list = sorted(list(set(int_list) - set(p)))
num_X = int_list.index(X)
c = 10000000
 
if X in forbidden_list:
  print(X)
else:
  for i in range(len(forbidden_list) - 1):
    a = abs(X - forbidden_list[i])
    b = abs(X - forbidden_list[i + 1])
    if a == b:
      print(forbidden_list[i])
      break
    elif c > a:
      c = a
    elif c <= a and b >= a:
      print(forbidden_list[i - 1])
      break
    elif b < a:
      print(forbidden_list[i])
      break
  else:
    if a < b:
      print(forbidden_list[i])
    else:
      print(forbidden_list[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())
try:
  a=list(map(int,input().split()))
  
  
  a=sorted(a)

  if x<a[0]:
    print(x)
  elif x>a[-1]:
    print(x)
  else:
    bb=list(range((a[0]-1),(a[-1])))
    b=list(range((a[0]-1),(a[-1])+n))
    for n in range(n):
      b.remove(a[n])
  
    f=len(b)


    d=abs(x-int(b[0]))
    ans=b[0]

    for n in range(f):
      c=abs(x-int(b[n]))
      if d>c:
        ans=b[n]
        d=c
  
    print(ans)

    print(bb)
except:
  print(x)

x,n=map(int,input().split())
try:
  a=list(map(int,input().split()))
  
  
  a=sorted(a)
  ff=a[-1]-a[0]+1

  if x<a[0]:
    print(x)
  elif x>a[-1]:
    print(x)
  else:
    bb=list(range((a[0]-1),(a[-1])))
    b=list(range((a[0]-1),(a[-1])+ff))
    for n in range(n):
      b.remove(a[n])
  
    f=len(b)


    d=abs(x-int(b[0]))
    ans=b[0]

    for n in range(f):
      c=abs(x-int(b[n]))
      if d>c:
        ans=b[n]
        d=c
  
    print(ans)

    print(bb)
except:
  print(x)


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

  if x<a[0]:
    print(x)
  elif x>a[-1]:
    print(x)
  else:
    bb=list(range((a[0]-1),(a[-1]+1)))
    b=list(range((a[0]-1),(a[-1])))
    for n in range(n):
      b.remove(a[n])
  
    f=len(b)


    d=abs(x-int(b[0]))
    ans=b[0]

    for n in range(f):
      c=abs(x-int(b[n]))
      if d>c:
        ans=b[n]
        d=c
  
    print(ans)

    print(bb)
except:
  print(x)



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

  if x<a[0]:
    print(x)
  elif x>a[-1]:
    print(x)
  else:
    bb=list(range((a[0]-1),(a[-1]+1)))
    b=list(range((a[0]-1),(a[-1]+2)))
    for n in range(n):
      b.remove(a[n])
  
    f=len(b)


    d=abs(x-int(b[0]))
    ans=b[0]

    for n in range(f):
      c=abs(x-int(b[n]))
      if d>c:
        ans=b[n]
        d=c
  
    print(ans)

    print(bb)
except:
  print(x)



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

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

  for i in range(100):
    if x-i not in a:
      ans=x-i
      break
    elif x+i not in a:
      ans=x+i
      break
    
  print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

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

for i in range(N):
    if not (X-i in p):
        print(X-i)
    elif not (X+i in p):
         print(X+i)

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

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

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

x,n=map(int,input().split())
l=sorted(list(map(int,input().split())))
ans=0
for i in range(102):
    if abs(x-i)<abs(x-ans) and i not in l:
        ans=i
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
x,n = map(int,input().split())
p = list(map(int,input().split()))
dic = {}
lis = []
for i in range(0,102):
    if i not in p:
        dic[i] = abs(x-i)
        lis.append(i)
print(lis)

mini = min(dic.values())
for j in lis:
    if mini == dic[j]:
        print(j)
        break

x,n = map(int,input().split())
p = list(map(int,input().split()))
dic = {}
lis = []
for i in range(0,102):
    if i not in p:
        dic[i] = abs(x-i)
        lis.append(i)

mini = min(dic.values())
for j in lis:
    if mini == dic[j]:
        print(j)
        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 bisect

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

p.sort()

index = bisect.bisect_left(p,x)

if n==0:
    print(x)
else:
    for i in range(n):
        print(index-i, index+i)
        if p[index-i] != x-i:
            print(x-i)
            break
        elif p[index+i] != x+i:
            print(x+i)
            break

import bisect

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

p.sort()

index = bisect.bisect_left(p,x)

if n==0:
    print(x)
else:
    p= p+[p[n-1]+2]
    for i in range(n):
        # print(index-i, index+i)
        if p[max(index-i,0)] != x-i:
            print(x-i)
            break
        elif p[min(index+i,n)] != x+i:
            print(x+i)
            break
    else:
        print(p[0]-1)


Verdicts: Runtime Error

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

Submission attempts (in order):

import copy
n = int(input())
list_a = list(map(int, input().split()))  

list_a = list(set(list_a))
list_a.sort(reverse=True)
# print(list_a)

count = 0
if len(list_a) == 1:
    print(0)
else:
    for i in range(len(list_a)):
        ai = list_a[i] 
        new_list = list_a[i+1:]  
#         print(new_list)
        data2 = []
        booler = True
        for j in range(len(new_list)):
            aj = new_list[-j]
#             print(ai, aj, ai%aj)
            if ai % aj == 0:

                booler = False
                break
        if booler == True:
            count += 1


    print(count)

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


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


Verdicts: Runtime Error

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

Submission attempts (in order):
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
tmp=0
if n==0:
    print(x)
    sys.exit()
for i in range(1,101):
    ans=x-i
    if not ans in p:
        print(ans)
        sys.exit()
    

import sys
import numpy as np

X,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
    print(X)
    sys,exit()
pp = list(map(lambda x: abs(x-X), p))
pp.sort()
for i in range(1,100):
    tmp=X-pp[0]-i
    if not tmp in p:
        print(tmp)
        sys.exit()
    tmpp=X-pp[0]+i
    if not tmpp in p:
        print(tmpp)
        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,x=map(int,input().split())
l=list(map(int,input().split()))
p=0
if x==0:
  print(n)
elif n not in l:
  print(n)
else:
  for i in range(101):
    if abs(x-i)>abs(x-p) and i not in p:
      p=i
  print(p)

x,n=map(int,input().split())
l=list(map(int,input().split()))
p=0
if n==0:
  print(x)
elif x not in l:
  print(x)
else:
  for i in range(101):
    if i not in l:
      if abs(x-i)>abs(x-p):
          p=i
  print(p)

x,n=map(int,input().split())
l=list(map(int,input().split()))
if x not in l:
    print(x)
elif n==0:
    print(x)
else:
    a=101
    p1=0
    for i in range(102):
        if i not in l:
            if abs(x-i)<a:
                a=abs(x-i)
                p1=i

    print(p1)


Verdicts: Runtime Error

Wrong Answer

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

Submission attempts (in order):
X,N = map(int, input().split())
P = map(list,int(input.split()))
direction = -1
i = 0
while True:
    dist = i * direction

    if not (dist + X in P):
        print(dist + X)
        break
    i += 1
    if direction < 0: direction = 1
    else : direction = -1

X,N = map(int, input().split())
if N > 0: 
    P = list(map(int,input().split()))
    direction = -1
    i = 1
    if not X in P:
        print(X)
    else:
        while True:
            dist = i * direction
            val = dist+X
            if not (val in P):
                print(val)
                break
            if direction < 0: direction = 1
            else : 
                direction = -1
                i+=1
else: 
    print(X)

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys

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

comp = 101

for i in range(1, 101):
    x = abs(X - i)
    if x == comp:
        sys.exit()
    if comp > x and i not in p and:
        comp = x
        result = i

print(result)

import sys

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

comp = 101

for i in range(1, 101):
    x = abs(X - i)
    if x == comp:
        break
    if comp > x and i not in p and:
        comp = x
        result = i

print(result)

import sys

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

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

comp = 101
for i in range(102):
    x = abs(X - i)
    if comp > x and i not in p:
        comp = x
        result = i

print(result)


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):
#!/usr/bin/env python3
# atcoder 


import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(n/2+4):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


#!/usr/bin/env python3
# atcoder 


import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(n/2+1):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


#!/usr/bin/env python3
# atcoder 


import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(x, n, p_liste):
    if n == 0:
        return x
    
    if x not in p_liste:
        return x
    chikai = x-1
    plus = x + 1

    for _ in range(0,101):
        #print(p_liste)
        if chikai not in p_liste:
            return chikai
        elif plus not in p_liste:
            return plus
        else: 
            plus += 1
            chikai -= 1
    return "問題"

def çözmek():
    X,N = map(int,sys.stdin.readline().split())
    P_liste = list(map(int, sys.stdin.readline().split()))

   
    res = []
    res.append(関数(X,N,P_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


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):
from collections import deque

X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = X
queue = deque()
queue.append(X)
done_list = []
ans = []
while queue:
    print(queue)
    var = queue.popleft()
    if var in p:
        done_list.append(var)
        if var - 1 not in done_list:
            queue.append(var-1)
        if var + 1 not in done_list:
            queue.append(var+1)
        continue
    else:
        ans = var
        break
print(ans)

from collections import deque

X, N = map(int, input().split())
p = list(map(int, input().split()))
ans = X
queue = deque()
queue.append(X)
done_list = []
ans = []
while queue:
    var = queue.popleft()
    if var in p:
        done_list.append(var)
        if var - 1 not in done_list:
            queue.append(var-1)
        if var + 1 not in done_list:
            queue.append(var+1)
        continue
    else:
        ans = var
        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):
X, N = map(int, input().split())
listp = list(set(map(int, input().split())))


def f(X, N, listp):

    if N == 0:
        return X
    if X not in listp:
        return X

    up_list = []
    down_list = []
    for p in listp:
        if p > X:
            up_list.append(p)
        if p < X:
            down_list.append(p)

    up_list = sorted(up_list)
    down_list = sorted(down_list, reverse=True)


    up_res = 10000
    for i, p in enumerate(up_list):
        if p != X+i+1:
            up_res = X+i+1
            break
    if up_res == 10000:
        up_res = X+1

    down_res = -10000
    for i, p in enumerate(down_list):
        if p != X-i-1:
            down_res = X-i-1
            break
    if down_res == -10000:
        down_res = X-1
    

    if abs(X - up_res) < abs(X - down_res):
        return up_res
    else:
        return down_res


print(f(X, N, listp))     

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


def f(X, N, listp):

    if N == 0:
        return X
    if X not in listp:
        return X

    up_list = []
    down_list = []
    for p in listp:
        if p > X:
            up_list.append(p)
        if p < X:
            down_list.append(p)

    up_list = sorted(up_list)
    down_list = sorted(down_list, reverse=True)


    up_res = 10000
    for i, p in enumerate(up_list):
        if p != X+i+1:
            up_res = X+i+1
            break
    if up_res == 10000:
        up_res = X+1

    down_res = -10000
    for i, p in enumerate(down_list):
        if p != X-i-1:
            down_res = X-i-1
            break
    if down_res == -10000:
        down_res = X-1
    

    if abs(X - up_res) < abs(X - down_res):
        return up_res
    else:
        return down_res


print(f(X, N, listp))     

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


def f(X, N, listp):
    if N == 0:
        return X
    if X not in listp:
        return X

    index = listp.index(X)
    
    downres = 1000
    for i,p in enumerate(listp):
        if index - i >= 0:
            if listp[index-i] != X-i:
                downres = X-i
                break
    if downres == 1000:
        downres = X - index -1

    upres = 1000
    l = len(listp)
    for i,p in enumerate(listp):

        if index + i < l:
            if listp[index+i] != X+i:
                upres = X+i
                break
    if upres == 1000:
        upres = X + l - index

    if abs(upres - X) < abs(downres - X):
        return upres
    else:
        return downres


print(f(X, N, listp))

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

x,n = list(map(int, input().split()))
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    hoge = [i for i in range(x - n, x + n + 1)]
    sabun = list(set(hoge) - set(p))
    min_ = 300
    index_ = 0
    for i, v in enumerate(sabun):
        if abs(x - v) < min_:
            min_ = abs(x - v)
            index_ = i
    print(sabun[index_])

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

def main():
    if len(p) == 0:
        print(x)
        return

    ans_l = list(range(x-10, x+10))
    print(ans_l)

    diff_l = list(set(p) ^ set(ans_l))
    print(diff_l)

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        # print(check)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

main()

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

def main():
    if n == 0:
        print(x)
        return

    ans_l = list(range(-100, 201))

    diff_l = list(set(p) ^ set(ans_l))
    diff_l.sort()

    cnt = 100
    ans = 100
    for i in range(0, len(diff_l)):
        check = abs(diff_l[i]-x)
        if check < cnt:
            cnt = check
            ans = diff_l[i]
    print(ans)
    return

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

X, N = (int(x) for x in input().split())
if N != 0:
  p = [int(x) for x in input().split()]
else:
  print(X)
  sys.exit()

ans = X
for i in range(0, 101, -1):
    if X + i not in p:
        ans = X + i
    if X - i not in p:
        ans = X - i
print(ans)

import sys

X, N = (int(x) for x in input().split())
if N != 0:
  p = [int(x) for x in input().split()]
else:
  print(X)
  sys.exit()
i = 0
ans = X
flag = False
while True:
  if X + i in p: continue
  ans = X + i
  flag = True
  if X - i in p: continue
  ans = X - i
  flag = True
  if flag: break
  i += 1
pritn(ans)

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

    if x not in p:
        print(x)
    else:
        for i in range(1, 200):
            if x - i not in p:
                print(x - i)
                break
            if x + i not in p:
                print(x + i)
                break

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Runtime Error

Accepted