ZhenlongDai/ACPR huggingface dataset:
Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

def gcd(a,b):
    if b==0:return a
    return gcd(b, a%b)

L = A.copy()
R = A.copy()
for i in range(1, N):
    L[i] = gcd(L[i-1], L[i])

for i in reversed(range(0, N-1)):
    R[i] = gcd(R[i+1], R[i])

result = max(L[1],L[-2])

for i in range(1, N-1):
    result = max(result, gcd(L[i-1],R[i+1]))
print(result)


Failing test case input:
2
0101101100 0110101101

Expected output:
110101101


Actual output:
101101100


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

def gcd(a,b):
    if b==0:return a
    return gcd(b, a%b)

L = A.copy()
R = A.copy()
for i in range(1, N):
    L[i] = gcd(L[i-1], L[i])

for i in reversed(range(0, N-1)):
    R[i] = gcd(R[i+1], R[i])

result = max(R[1],L[-2])

for i in range(1, N-1):
    result = max(result, gcd(L[i-1],R[i+1]))
print(result)

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[int(i) for i in input().split()]
def GCD(x,y):
	if x>y:
		a=x
		b=y
	else:
		a=y
		b=x
	while(True):
		c=a%b
		if c==0:
			return b
		else:
			a,b=b,c
 

if N==2:
	print(max(A))
else:
	B=[]
	a0=A[-1]
	for aa in A[0:-1]:
		B.append(GCD(aa,a0))
	gomikamo=B.index(min(B))+1
	g0=A[0]
	for i in range(0,N-1):
		g0=GCD(A[i],g0)
	del A[gomikamo]
	g1=A[0]
	for i in range(N-1):
		g1=GCD(A[i],g1)
	print(max(g0,g1))

Failing test case input:
3
12 15 18

Expected output:
6

Actual output:
3


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(i) for i in input().split()]
def GCD(x,y):
	if x>y:
		a=x
		b=y
	else:
		a=y
		b=x
	while(True):
		c=a%b
		if c==0:
			return b
		else:
			a,b=b,c
 

if N==2:
	print(max(A))
else:
	B=[]
	a0=A[-1]
	for aa in A[0:-1]:
		B.append(GCD(aa,a0))
	gomikamo=B.index(min(B))
	g0=A[0]
	for i in range(0,N-1):
		g0=GCD(A[i],g0)
	del A[gomikamo]
	g1=A[0]
	for i in range(N-1):
		g1=GCD(A[i],g1)
	print(max(g0,g1))

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

n = int(input())
a = list(map(int, input().split()))
left, right = [0] * (n+1), [0] * (n+1)
print(left, right)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for i in reversed(range(n)):
    right[i] = gcd(right[i+1], a[i])
ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))
print(ans)

Failing test case input:
2
0010101110 0110001011

Expected output:
110001011


Actual output:
[0, 0, 0] [0, 0, 0]
110001011


Fixed submission (verdict: Accepted):
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
n = int(input())
a = list(map(int, input().split()))
left, right = [0] * (n+1), [0] * (n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
for i in reversed(range(n)):
    right[i] = gcd(right[i+1], a[i])
ans = 0
for i in range(n):
    l = left[i]
    r = right[i+1]
    ans = max(ans, gcd(l, r))
print(ans)
Problem: p03061
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
if N==2: print(max(A));exit()
from math import gcd
L = {}
R = {}
L[0] = A[0]
R[N-1] = A[-1]
ans = 0
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
for i in range(2,N):
    ans = max(ans,gcd(L[i-2],R[i]))
ans = max(ans,R[1])
ans = max(ans,L[N-1])
print(ans)

Failing test case input:
3
36 36 10

Expected output:
36


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
if N==2: print(max(A));exit()
from math import gcd
L = {}
R = {}
L[0] = A[0]
R[N-1] = A[-1]
ans = 0
for i in range(1,N):
    L[i] = gcd(L[i-1],A[i])
    R[N-i-1] = gcd(R[N-i],A[N-i-1])
for i in range(2,N):
    ans = max(ans,gcd(L[i-2],R[i]))
ans = max(ans,R[1])
ans = max(ans,L[N-2])
ans = max(ans,R[0])
print(ans)

Problem: p03061
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N = int(input())
A = list(map(int, input().split()))

L = [0]*(N+1)
R = [0]*(N+1)

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

M = []
for i in range(N-1):
    M.append(gcd(L[i],R[i+1]))
    
print(max(M))

Failing test case input:
2
1110000101 1001100000

Expected output:
1110000101


Actual output:
1001100000


Fixed submission (verdict: Accepted):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N = int(input())
A = list(map(int, input().split()))

L = [0]*(N+1)
R = [0]*(N+1)

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])
    
M = []
for i in range(N):
    M.append(gcd(L[i],R[i+1]))

print(max(M))

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def gcd(a, b):
    if b > a:
        tmp = a
        a = b
        b =tmp
    while b != 0:
        a, b = b, a % b
    return a

N = int(input())
A = list(map(int, input().split()))

L = [0 for i in range(N+1)]
for i in range(0,N):
    L[i + 1] = gcd(L[i], A[i])
    
R = [0 for i in range(N+1)]
for i in range(N,0,-1):
    R[i-1] = gcd(R[i],A[i-1]) 

ans = []
for i in range(1,N):
    ans.append(gcd(L[i-1], R[i]))
print(max(ans))

Failing test case input:
2
1111000110 0011000101

Expected output:
1111000110


Actual output:
11000101


Fixed submission (verdict: Accepted):
def gcd(a, b):
    if b > a:
        tmp = a
        a = b
        b =tmp
    while b != 0:
        a, b = b, a % b
    return a

N = int(input())
A = list(map(int, input().split()))

L = [0 for i in range(N+1)]
for i in range(0,N):
    L[i + 1] = gcd(L[i], A[i])
    
R = [0 for i in range(N+1)]
for i in range(N,0,-1):
    R[i-1] = gcd(R[i],A[i-1]) 

ans = []
for i in range(1,N+1):
    ans.append(gcd(L[i - 1], R[i]))

print(max(ans))
Problem: p03061
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(n)]
r=[0 for i in range(n)]
l[0]=a[0]
r[0]=a[-1]
for i in range(n-1):
    l[i+1]=gcd(l[i],a[i+1])
for i in range(n-1):
    r[i+1]=gcd(r[i],a[-2-i])
ans=[0 for i in range(n)]
for i in range(1,n-1):
    ans[i]=gcd(l[i-1],r[-i+n-2])
ans[0]=r[n-1]
ans[n-1]=l[n-1]
print(max(ans))

    


Failing test case input:
2
1101000000 1000001100

Expected output:
1101000000


Actual output:
300


Fixed submission (verdict: Accepted):
from math import gcd
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(n)]
r=[0 for i in range(n)]
l[0]=a[0]
r[0]=a[-1]
for i in range(n-1):
    l[i+1]=gcd(l[i],a[i+1])
for i in range(n-1):
    r[i+1]=gcd(r[i],a[-2-i])

ans=[0 for i in range(n)]

for i in range(1,n-1):
    ans[i]=gcd(l[i-1],r[-i+n-2])
ans[0]=r[n-2]
ans[n-1]=l[n-2]

print(max(ans))

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    for i in range(1, N - 1):
        v1 = reduce(gcd, A[:i])
        v2 = reduce(gcd, A[i + 1:])

        max_gcd = max(max_gcd, gcd(v1, v2))

    print(reduce(gcd, A))

    print(max_gcd)


if __name__ == "__main__":
    main()


Failing test case input:
2
1000010000 1000000000

Expected output:
1000010000


Actual output:
10000
1000010000


Fixed submission (verdict: Accepted):
from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    left = [1] * N
    left[0] = A[0]
    for i in range(1, N):
        left[i] = gcd(A[i], left[i - 1])

    right = [1] * N
    right[N-1] = A[N-1]
    for i in range(N - 2, -1, - 1):
        right[i] = gcd(A[i], right[i + 1])

    
    

    max_gcd = max(right[1], left[N-2])
    for i in range(1, N - 1):
        max_gcd = max(max_gcd, gcd(left[i - 1], right[i + 1]))

    print(max_gcd)


if __name__ == "__main__":
    main()
Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while x%y > 0:
        x, y = y, x%y
    return y

a = sorted(a)
ans = [gcd(a[0], a[1]), a[0]]
for i in range(2, n):
    ans_0, ans_1 = ans
    ans_0_new = gcd(ans_0, a[i])
    ans_1_new = max(ans_0, gcd(ans_1, a[i]))
    ans = [ans_0_new, ans_1_new]
print(max(ans))


Failing test case input:
3
36 36 10

Expected output:
36


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

def gcd(x, y):
    x, y = max(x, y), min(x, y)
    while x%y > 0:
        x, y = y, x%y
    return y

a = sorted(a)
ans = [gcd(a[0], a[1]), a[0]]
for i in range(2, n):
    ans_0, ans_1 = ans
    ans_0_new = gcd(ans_0, a[i])
    ans_1_new = max(ans_0, gcd(ans_1, a[i]))
    ans = [ans_0_new, ans_1_new]
ans_2 = a[1]
for i in range(2, n):
    ans_2 = gcd(ans_2, a[i])
print(max(ans+[ans_2]))

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy

N = int(input())
A = list(map(int, input().split()))
ans = 0

def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  if x%y == 0:
    return y
  else:
    while x%y!=0:
      z = x%y
      x = y
      y = z
    else:
      return z


for i in range(N):
  B = copy.copy(A)
  tmp = gcd(B[0], B[1])
  B.pop(i)
  for i in range(N-2):
    tmp = gcd(B[i], B[i+1])
    B[i+1] = tmp
  ans = max(tmp, ans)
print(ans)

Failing test case input:
2
1110001110 1011000101

Expected output:
1110001110


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
ans = 1

def gcd(m, n):
  x = max(m, n)
  y = min(m, n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x % y
      x = y
      y = z
    else:
      return z

L, R = {}, {}
for i in range(N):
  if i == 0:
    L[0] = A[0]
    R[N-(i+1)] = A[N-(i+1)]
  else:
    L[i] = gcd(L[i-1], A[i])
    R[N-(i+1)] = gcd(R[N-i], A[N-(i+1)])

for i in range(N):
  if i == 0:
    tmp = R[1]
  elif i == N-1:
    tmp = L[N-2]
  else:
    tmp = gcd(L[i-1], R[i+1])
  ans = max(tmp, ans)

print(ans)

Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))

def gcd(x,y):
  while y:
    x, y = y, x%y
  return x

ll, lr = [0]*n, [0]*n
ll[0], lr[n-1] = a[0], a[n-1]
for i in range(1,n):
  ll[i] = gcd(ll[i-1], a[i])
  lr[n-i-1] = gcd(lr[n-i], a[n-i-1])

print(max(ll[n-1], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-1], lr[2:])]))

Failing test case input:
2
1110100001 1101101101

Expected output:
1110100001


Actual output:
1101101101


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))

def gcd(x,y):
  while y:
    x, y = y, x%y
  return x

ll, lr = [0]*n, [0]*n
ll[0], lr[n-1] = a[0], a[n-1]
for i in range(1,n):
  ll[i] = gcd(ll[i-1], a[i])
  lr[n-i-1] = gcd(lr[n-i], a[n-i-1])

print(max(ll[n-2], lr[1], *[gcd(l,r) for l,r in zip(ll[:n-2], lr[2:])]))
Problem: p03061
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
arr = sorted(list(map(int,input().split())), reverse = True)

dp = [[0]*2 for i in range(n)]
dp[0][0] = arr[0]
dp[0][1] = arr[1]
def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    if x%y:
        return gcd(y,x%y)
    else:
        return y
for i in range(n-1):
    dp[i+1][0] = gcd(dp[i][0],arr[i+1])
    dp[i+1][1] = max(dp[i][0],gcd(dp[i][1],arr[i+1]))
print(max(dp[-1]))

Failing test case input:
3
9 28 18

Expected output:
9


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
arr = sorted(list(map(int,input().split())))
arr1 = arr[::-1]
dp = [[0]*2 for i in range(n)]
dp1 = [[0]*2 for i in range(n)]

dp[0][0] = arr[0]
dp[0][1] = arr[1]
dp1[0][0] = arr1[0]
dp1[0][1] = arr1[1]

def gcd(a,b):
    x = max(a,b)
    y = min(a,b)
    if x%y:
        return gcd(y,x%y)
    else:
        return y
for i in range(n-1):
    dp[i+1][0] = gcd(dp[i][0],arr[i+1])
    dp[i+1][1] = max(dp[i][0],gcd(dp[i][1],arr[i+1]))
    dp1[i+1][0] = gcd(dp1[i][0],arr1[i+1])
    dp1[i+1][1] = max(dp1[i][0],gcd(dp1[i][1],arr1[i+1]))
print(max(dp[-1][0],dp[-1][1],dp1[-1][0],dp1[-1][1]))
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
x, n = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()

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

ans = 1 << 60
cnt = 1
while True:
    lower = x - cnt
    upper = x + cnt
    if lower not in arr:
        ans = min(ans, lower)
    if upper not in arr:
        ans = min(ans, upper)
    if ans < 1 << 60:
        break
    cnt += 1

print(ans)

Failing test case input:
18 1
10 9 2 6 5

Expected output:
18


Actual output:
17


Fixed submission (verdict: Accepted):
import sys
x, n = map(int, input().split())
arr = list(map(int, input().split()))

arr.sort()

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

ans = 1000
cnt = 0
while True:
    lower = x - cnt
    upper = x + cnt
    if lower not in arr:
        ans = min(ans, lower)
    if upper not in arr:
        ans = min(ans, upper)
    if ans != 1000:
        break
    cnt += 1

print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = (int(each) for each in input().split())
if n == 0:
    print(x)
else:
    p = [int(each) for each in input().split()]
    candidate = 0
    for i in range(max(p)):
        if i not in p and abs(i-x) < abs(candidate-x):
            candidate = i
            
    print(candidate)

Failing test case input:
62 1
1 1 2 16 18

Expected output:
62


Actual output:
17


Fixed submission (verdict: Accepted):
x, n = (int(each) for each in input().split())
if n == 0:
    print(x)
else:
    p = [int(each) for each in input().split()]
    candidate = 0
    for i in range(210):
        j = i - 105
        if j not in p and abs(j-x) < abs(candidate-x):
            candidate = j
            
    print(candidate)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 0:
    print(x)

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


Failing test case input:
12 1
2 12 0 16 13

Expected output:
11


Actual output:

Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = set(map(int, input().split()))
if n == 0:
    print(x)
else:
    for i in range(101):
        if x - i not in p:
            print(x - i)
            break
        elif x + i not in p:
            print(x + i)
            break

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x,n=map(int,input().split())
a = list(map(int,input().split()))
if n==0:
    print(int(x))
    exit()
    
for i in range(n):
    if x+i not in a:
        print(i+x)
        exit()
    elif x-i not in a:
        print(x-i)
        exit()


Failing test case input:
6 2
4 7 10 6 5

Expected output:
8


Actual output:

Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
a = list(map(int,input().split()))
if n==0:
    print(int(x))
    exit()

for i in range(n):
    if x-i not in a:
        print(x-i)
        exit()
    elif x+i not in a:
        print(x+i)
        exit()
print(x-(n
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10000000)

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

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


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

l=[0] * 100

for i in p:
    l[i-1] =1

diff=min(101-x,x)
ans=-1 if x < 51 else 101
for i in range(100):
    if l[i] == 0 and diff > abs(x-(i+1)):
        diff= abs(x-(i+1))
        ans=i+1

print(ans)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10000000)

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

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


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

l=[0] * 102

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(0,102):
    if l[i] == 0 and diff > abs(x-i):
        diff= abs(x-i)
        ans=i

print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
if(N != 0):
    p = set(list(map(int, input().split())))
else:
    print(X)
    exit()

result = []

for i in range(max(p)):
    result.append(i)

ans = set(result)-p
ans1 = 1*10**50


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])


Failing test case input:
15 3
7 5 3 10 5

Expected output:
15


Actual output:
9


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
if(N != 0):
    p = set(list(map(int, input().split())))
else:
    print(X)
    exit()

result = []

for i in range(102):
    result.append(i)

ans = set(result)-p
ans1 = 1*10**50


for count, i in enumerate(ans):
    if (ans1 > abs(i-X)):
        ans1 = abs(i-X)
        index = count

print(list(ans)[index])

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]

dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(dec_num)
            break

Failing test case input:
7 2
4 7 10 6 5

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
from sys import stdin
 
input_num = stdin.readline().strip().split(" ")

X = int(input_num[0])
N = int(input_num[1])
num_list = []
if N != 0:
    num_list = [int(x) for x in stdin.readline().strip().split(" ")]


dec_num = X
inc_num = X
if N == 0:
    print(X)
elif X not in num_list:
    print(X)
else:
    while True:
        dec_num += -1
        inc_num += 1
        if dec_num not in num_list:
            print(dec_num)
            break
        if inc_num not in num_list:
            print(inc_num)
            break
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = input().split()
n = [int(i) for i in n]
if not n[1] == 0:
	m = input().split()
	m = [int(i) for i in m]
else:
  	m =[0]

ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[0])
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    if len(ans) > 0:
        break
        
print(min(ans))

Failing test case input:
2 0
4 5 1 4 0

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n = input().split()
n = [int(i) for i in n]
if not n[1] == 0:
	m = input().split()
	m = [int(i) for i in m]
else:
  	m =[0]

ans_1 = n[0]
ans_2 = n[0]
ans = []
while True:
    if n[1] == 0:
        ans.append(n[0])
    if not n[0] in m:
      ans.append(n[0])
    if len(ans) > 0:
        break    
        
    ans_1 += 1
    ans_2 -= 1
    if not ans_1 in m:
        ans.append(ans_1)
    if not ans_2 in m:
        ans.append(ans_2)
    
    
        
print(min(ans))

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if N == 0:
    print(X)
else:
    i = 1
    while True:
        if X - i not in lst:
            print(X - i)
            exit()
        elif X + i not in lst:
            print(X + i)
            exit()
        i += 1


Failing test case input:
80 3
3 0 1 45 0

Expected output:
80


Actual output:
79


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
lst = [int(x) for x in input().split()]
if N == 0 or X not in lst:
    print(X)
else:
    i = 1
    while True:
        if X - i not in lst:
            print(X - i)
            exit()
        elif X + i not in lst:
            print(X + i)
            exit()
        i += 1

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

def main():
  x, n = list(map(int, input().split()))
  if n == 0:
    print(x)
  pp = list(map(int, input().split()))
  
  i = 0
  while True:
    if x-i not in pp:
      print(x-i)
      exit()
    if x+i not in pp:
      print(x+i)
      exit()
    i += 1
  
  
if __name__ == "__main__":
  main()


Failing test case input:
6 0
4 8 11 16 7

Expected output:
6


Actual output:
6
6


Fixed submission (verdict: Accepted):

def main():
  x, n = list(map(int, input().split()))
  if n == 0:
    print(x)
    exit()
  pp = list(map(int, input().split()))
  
  i = 0
  while True:
    if x-i not in pp:
      print(x-i)
      exit()
    if x+i not in pp:
      print(x+i)
      exit()
    i += 1
  
  
if __name__ == "__main__":
  main()
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
X, N = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
ans = -1
tmp = 1000
for i in range(1, 101):
    if i in P: continue
    if abs(X-i) < tmp:
        ans = i
        tmp = abs(X-i)
print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = [int(x) for x in input().split()]
P = [int(x) for x in input().split()]
ans = -1
tmp = 1000
for i in range(0, 102):
    if i in P: continue
    if abs(X-i) < tmp:
        ans = i
        tmp = abs(X-i)
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X,N=map(int, input().split())
p=list(map(int, input().split()))

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

for i in range(N):
    if p.count(X-i)==0:
        if X-i != 0:
            print(X-i)
            exit()
    if p.count(X+i)==0:
        print(X+i)
        exit()


Failing test case input:
6 2
4 7 10 6 5

Expected output:
8


Actual output:

Fixed submission (verdict: Accepted):
X,N=map(int, input().split())
p=list(map(int, input().split()))

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

for i in range(N+1):
    if p.count(X-i)==0:
        print(X-i)
        exit()
    if p.count(X+i)==0:
        print(X+i)
        exit()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
if N == 0:
    print(X)
    quit()
p = set(map(int, input().split()))
not_p = sorted(set(range(1, 101)) - p)
ans = 0
minval = 101
for i in not_p:
    if minval > abs(X - i):
        minval = abs(X - i)
        ans = i
print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
if N == 0:
    print(X)
    quit()
p = set(map(int, input().split()))
not_p = sorted(set(range(0, 102)) - p)
ans = 0
minval = 101
for i in not_p:
    if minval > abs(X - i):
        minval = abs(X - i)
        ans = i
print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],101):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -100, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    
    print(min(ans))
   
   

Failing test case input:
6 5
4 7 10 6 5

Expected output:
8

Actual output:
3


Fixed submission (verdict: Accepted):
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],102):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -100, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    print(ans[ans2.index(min(ans2))])

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 0:
	print(x)
	exit()
p = list(map(int, input().split()))
mind = abs(x - p[0])
pos = [p[0]]
s = set(p)
p = []
for x1 in range(-100, 200):
	if x1 in s:
		continue
	else:
		p.append(x1)
for q in p:
	if abs(x - q) < mind:
		mind = abs(x - q)
		pos = [q]
	elif abs(x - q) == mind:
		pos.append(q)
pos.sort()
print(pos[0])

Failing test case input:
6 5
4 7 10 6 5

Expected output:
8

Actual output:
4


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
if n == 0:
	print(x)
	exit()
p = list(map(int, input().split()))

s = set(p)
p = []
for x1 in range(-100, 200):
	if x1 in s:
		continue
	else:
		p.append(x1)
mind = abs(x - p[0])
pos = [p[0]]
for q in p:
	if abs(x - q) < mind:
		
		mind = abs(x - q)
		pos = [q]
	elif abs(x - q) == mind:
		pos.append(q)
pos.sort()
print(pos[0])

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = list(map(int, input().split()))
if N == 0:
    print(X)
    exit()
p = list(map(int, input().split()))

i = 1
while True:
    if X - i not in (p):
        print(X-i)
        exit()
    if X + i not in (p):
        print(X+i)
        exit()
    i += 1


Failing test case input:
6 2
5 7 15 16 2

Expected output:
6


Actual output:
4


Fixed submission (verdict: Accepted):
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))

i = 0
while True:
    if X - i not in (p):
        print(X-i)
        exit()
    if X + i not in (p):
        print(X+i)
        exit()
    i += 1
Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


def ans(P, X):
    P = set(P)
    for i in range(200):
        if X + i not in P:
            return X+i
        if X - i not in P:
            return X-i 

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

    print(ans(P, X))

Failing test case input:
10 3
4 7 10 6 5

Expected output:
9


Actual output:
11


Fixed submission (verdict: Accepted):


def ans(P, X):
    P = set(P)
    for i in range(200):
        if X - i not in P:
            return X-i 
        if X + i not in P:
            return X+i

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

    print(ans(P, X))

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
else:
  P = [int(x) for x in input().split()]
  P.sort()
  if X in P:
    a = P.index(X)
    for j in range(1,N):
      if a-j<0:
        print(X-j)
        exit()
      elif a+j>=N:
        print(X+j)
        exit()
      elif (a-j>=0 and P[a-j]==X-j) and (a+j<N and P[a+j]==X+j):
        continue
      elif a-j>=0 and P[a-j]<X-j:
        print(X-j)
        exit()
      elif a+j<N and P[a+j]>X+j:
        print(X+j)
        exit()
  else:
    print(X)
    
	
  

Failing test case input:
10 3
1 7 10 6 5

Expected output:
9


Actual output:
11


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
else:
  P = [int(x) for x in input().split()]  
  if X in P:
    i = 1
    while True:
      if (X-i in P) and (not X+i in P):
        print(X+i)
        exit()
      elif (not X-i in P) and (X+i in P):
        print(X-i)
        exit()
      elif (X-i in P) and (X+i in P):
        i+=1
      elif (not X-i in P) and (not X+i in P):
        print(X-i)
        exit()
  else:
    print(X)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
p_list = list(map(int, input().split()))

if not p_list:
    print(x)
    exit()

i = 1
while True:
    low_x = x - i
    if low_x not in p_list:
        print(low_x)
        break
    
    high_x = x + i
    if high_x not in p_list:
        print(high_x)
        break

    i += 1

Failing test case input:
17 2
4 4 11 1 10

Expected output:
17


Actual output:
16


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p_list = list(map(int, input().split()))

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

i = 1
while True:
    low_x = x - i
    if low_x not in p_list:
        print(low_x)
        break
    
    high_x = x + i
    if high_x not in p_list:
        print(high_x)
        break

    i += 1
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):









import os
import sys




def main():
    x,n = map(int,input().split())
    if n==0:
        print(x)
        return
    p = list(map(int,input().split()))
    for i in range(1,max(p)-min(p)):
        if not x-i in p:
            print(x-i)
            return 
        if not x+i in p:
            print(x+i)
            return
            


if __name__ == "__main__":
    main()


Failing test case input:
12 1
2 5 3 16 11

Expected output:
12


Actual output:
13


Fixed submission (verdict: Accepted):









import os
import sys




def main():
    x,n = map(int,input().split())
    p = list(map(int,input().split()))    
    if n==0:
        print(x)
        return
 
    for i in range(0,200):
        if not x-i in p:
            print(x-i)
            return 
        if not x+i in p:
            print(x+i)
            return
            


if __name__ == "__main__":
    main()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int,input().split())
p = list(map(int,input().split()))
if n==0:
    print(x)
a,b = x,x
while True:
    a+=1
    b-=1
    if a not in p:
        print(a)
        break
    elif b not in p:
        print(b)
        break

Failing test case input:
6 0
4 8 2 16 7

Expected output:
6


Actual output:
6
5


Fixed submission (verdict: Accepted):
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

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
  
for i in range(100):
  if N-i not in A:
    print(N-i)
    exit()
  elif N+i in A and N+i!=N-i:
    print(N+i)
    exit()

Failing test case input:
6 5
3 7 10 6 5

Expected output:
4


Actual output:
7


Fixed submission (verdict: Accepted):
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
  
for i in range(100):
  if N-i not in A:
    print(N-i)
    exit()
  elif N+i not in A and N+i!=N-i:
    print(N+i)
    exit()

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
count=1
x,y=0,0
while True:
  if X-count not in P:
    print(X-count)
    break
  if X+count not in P:
    print(X+count)
    break
  count+=1
    

Failing test case input:
15 1
2 5 3 16 11

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
P=list(map(int,input().split()))
count=0
while True:
  if X-count not in P:
    print(X-count)
    break
  if X+count not in P:
    print(X+count)
    break
  count+=1
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from bisect import bisect

x, n = map(int, input().split())
ls = list(map(int, input().split()))
mx = [True] * 100
for i in ls:
	mx[i - 1] = False
r = x - 1
ans1 = 10000000
ans2 = 10000000
while r < 100:
	if mx[r]:
		ans1 = r + 1
		break
	r += 1
l = x - 1
while l >= 0:
	if mx[l]:
		ans2 = l + 1
		break
	l -= 1
if x - ans2 < ans1 - x:
	print(ans2)
elif x - ans2 > ans1 - x:
	print(ans1)
else:
	print(ans2)


Failing test case input:
3 2
4 2 1 8 3

Expected output:
5


Actual output:
10000000


Fixed submission (verdict: Accepted):
from bisect import bisect

x, n = map(int, input().split())
ls = list(map(int, input().split()))
mx = [True] * 101
for i in ls:
	mx[i - 1] = False
r = x - 1
ans1 = 101
ans2 = 0
while r < 100:
	if mx[r]:
		ans1 = r + 1
		break
	r += 1
l = x - 1
while l >= 0:
	if mx[l]:
		ans2 = l + 1
		break
	l -= 1

if x - ans2 < ans1 - x:
	print(ans2)
elif x - ans2 > ans1 - x:
	print(ans1)
else:
	print(ans2)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

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



def main(X, N):
  if N == 0:
    print(X)
    return
     
  p = list(map(int, input().strip().split()))
  if not X in p:
    print(X)
    return
    
  for i in range(math.ceil((N-1)/2)):
    a = X-i-1
    b = X+i+1
    if not a in p:
      print(X-i-1)
      return
    if not b in p:
      print(X+i+1)
      return
   
  
main(X, N)

Failing test case input:
12 1
2 12 0 16 13

Expected output:
11


Actual output:

Fixed submission (verdict: Accepted):
import math

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



def main(X, N):
  if N == 0:
    print(X)
    return
     
  p = list(map(int, input().strip().split()))
  if not X in p:
    print(X)
    return
    
  for i in range(math.ceil((N-1)/2)+1):
    a = X-i-1
    b = X+i+1
    if not a in p:
      print(X-i-1)
      return
    if not b in p:
      print(X+i+1)
      return
   
  
main(X, N)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import defaultdict

x,n = map(int,input().split())
if n==0:
    print(x)
else:
    dd = defaultdict(int)
    arr = list(map(int,input().split()))
    for i in range(len(arr)):
        dd[x-arr[i]]+=1
    
    print(dd)

    for i in range(101):
        if dd[i]==0:
            print(x-i)
            break
        elif dd[-i]==0:
            print(x+i)
            break




Failing test case input:
15 1
1 5 3 16 11

Expected output:
15


Actual output:
defaultdict(<class 'int'>, {14: 1, 10: 1, 12: 1, -1: 1, 4: 1})
15


Fixed submission (verdict: Accepted):
from collections import defaultdict

x,n = map(int,input().split())
if n==0:
    print(x)
else:
    dd = defaultdict(int)
    arr = list(map(int,input().split()))
    for i in range(len(arr)):
        dd[x-arr[i]]+=1

    for i in range(101):
        if dd[i]==0:
            print(x-i)
            break
        elif dd[-i]==0:
            print(x+i)
            break
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
P = set(map(int, input().split()))
U = set(range(1, 101))
diff = list(U - P)

ans = 0
tmp = float('inf')
for i in diff:
    if tmp > abs(X - i):
        tmp = abs(X - i)
        ans = i
print(ans)

Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
P = set(map(int, input().split()))
U = set(range(-200, 201))
diff = sorted(list(U - P))

ans = 0
tmp = float('inf')
for i in diff:
    if tmp > abs(X - i):
        tmp = abs(X - i)
        ans = i
print(ans)

Problem: p02641
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x,n=map(int,input().split())
p=set(map(int,input().split()))

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

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


Failing test case input:
33 9
4 0 9 23 8

Expected output:
33


Actual output:
32


Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
p=set(map(int,input().split()))

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

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

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n, = map(int,input().split())
p = list(map(int,input().split()))

i = 0
ans = []
flag = 0
while True:
    if (x + i) not in p:
        ans += [x+i]
        print(ans)
        flag = 1
    if (x - i) not in p:
        ans += [x-i]
        print(ans)
        flag = 1
    if flag == 0:
        i += 1
        print(ans)
    else:
        break

print(min(ans))


Failing test case input:
7 1
4 5 17 16 10

Expected output:
7


Actual output:
[7]
[7, 7]
7


Fixed submission (verdict: Accepted):
x,n, = map(int,input().split())
p = list(map(int,input().split()))

i = 0
ans = []
flag = 0
while True:
    if (x + i) not in p:
        ans += [x+i]
        flag = 1
    if (x - i) not in p:
        ans += [x-i]
        flag = 1
    if flag == 0:
        i += 1
    else:
        break

print(min(ans))

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n,*a=map(int,open(0).read().split())
b=[1]*101
for i in a:
    b[i]=0
c=1000 
ans=0
for i in range(101):
    if b[i] and c>=abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

Failing test case input:
6 5
3 7 10 6 5

Expected output:
4


Actual output:
8


Fixed submission (verdict: Accepted):
x,n,*a=map(int,open(0).read().split())
b=[1]*103
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n = map(int,input().split())
p = list(map(int,input().split()))

if n == 0:
    print(x)

else:
    i = 1
    while True:
        t = x-i
        s = x+i
        if t not in p:
            if t != 0:
                print(t)
                break
        if s not in p:
            print(s)
            break
        i +=1

Failing test case input:
10 3
4 7 3 6 5

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
x,n = map(int,input().split())
p = list(map(int,input().split()))

if n == 0:
    print(x)

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

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0
if n ==100:
    print(0)
    sys.exit()
for i in range(101):
    if x!=i:
        if p.count(i)==0:
            if abs(x-i)<wk:
                an =i
                wk = abs(x-i)
            else:
                print(an)
                sys.exit()
print(an)

Failing test case input:
22 4
7 5 3 19 5

Expected output:
22


Actual output:
21


Fixed submission (verdict: Accepted):
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0

 
  
for i in range(102):
    
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
x,n = map(int,input().split())

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

p,f = x-1,x+1
bans = set(map(int,input().split()))
while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1

Failing test case input:
80 3
3 0 1 45 0

Expected output:
80


Actual output:
79


Fixed submission (verdict: Accepted):
import sys
x,n = map(int,input().split())
    
p,f = x-1,x+1
bans = set(map(int,input().split()))

if n == 0 or x not in bans:
    print(x)
    sys.exit()

while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x,n=map(int,input().split())
if n>0:
    a=list(map(int,input().split()))     
    z=x+1
    y=x-1    
    while True:
        if y not in a:
            print(y)
            break
        elif z not in a:
            print(z)
            break
        z+=1
        y-=1
        
else:
    print(x)


Failing test case input:
15 3
7 5 3 6 5

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
x,n=map(int,input().split())
if n>0:
    
    a=list(map(int,input().split()))
        
    z=x+1
    y=x-1
    if x not in a:
        print(x)
    else:
        while True:
            if y not in a:
                print(y)
                break
            elif z not in a:
                print(z)
                break
        
            z+=1
            y-=1
        
else:
    print(x)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
m, n = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
diff = 10000
d = {}
if n == 0:
  print(m)
else:
  for a in arr:
    if diff > abs(m - a):
      diff = abs(m - a)
    d[a] = 1
  n = 0
  while True:
    if d.get(m + diff + n, 0) == 0 and d.get(m - diff - n, 0) == 0:
      print(min((m - diff - n, m + diff + n )))
      break
    if d.get(m + diff + n, 0) == 0:
      print(m + diff + n)
      break
    elif d.get(m - diff - n, 0) == 0:
      print(m - diff - n)
      break
    n += 1

Failing test case input:
19 5
4 7 10 6 5

Expected output:
19


Actual output:
28


Fixed submission (verdict: Accepted):
m, n = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
diff = 10000
d = {}
if n == 0:
  print(m)
else:
  for a in arr:
    if diff > abs(m - a):
      diff = abs(m - a)
    d[a] = 1
  n = 0
  while True:
    if d.get(m + n, 0) == 0 and d.get(m  - n, 0) == 0:
      print(min((m  - n, m  + n )))
      break
    if d.get(m  + n, 0) == 0:
      print(m + n)
      break
    elif d.get(m - n, 0) == 0:
      print(m - n)
      break
    n += 1

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)


Failing test case input:
41 3
3 0 1 45 0

Expected output:
41


Actual output:
42


Fixed submission (verdict: Accepted):
X, N = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(X - ans) and i not in p:
        ans = i
print(ans)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b = map(float,input().split())
p = list(map(int,input().split()))

t = 10000
for i in range(101,0,-1):
    if i not in p:
        if abs(a-i)<= t:
            ans = i
            t = abs(a-i)
        
print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
a,b = map(float,input().split())
p = list(map(int,input().split()))

t = 10000
for i in range(103,-1,-1):
    if i not in p:
        if abs(a-i)<= t:
            ans = i
            t = abs(a-i)
        
print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 0:
    print(x)

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


Failing test case input:
2 0
3 6 1 8 -1

Expected output:
2


Actual output:
2
2


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
p = set(map(int, input().split()))
if n == 0:
    print(x)
else:
    for i in range(101):
        if x - i not in p:
            print(x - i)
            break
        elif x + i not in p:
            print(x + i)
            break

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x, n = map(int, input().split())
if n == 0:
    print(x)
    quit()

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

min_near = 0
big_near = 0

m = x
while min_near == 0:
    m -= 1
    if not m in ps:
        min_near = m

b = x
while big_near == 0:
    b += 1
    if not b in ps:
        big_near = b


min_diff = x - min_near
big_diff = big_near - x

if (min_diff > big_diff):
    
    print(big_near)
else:
    
    print(min_near)


Failing test case input:
10 3
7 7 3 6 5

Expected output:
10


Actual output:
9


Fixed submission (verdict: Accepted):
x, n = map(int, input().split())
if n == 0:
    print(x)
    quit()

ps = list(map(int, input().split()))
if not x in ps:
    print(x)
    quit()

m_diff = 0
b_diff = 0

m = x
while m in ps:
    m_diff += 1
    m -= 1

b = x
while b in ps:
    b_diff += 1
    b += 1

if (m_diff > b_diff):
    print(b)
else:
    print(m)
Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys






























fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())



x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x+i not in s):
		print(x+i)
		break
	elif(x-i not in s):
		print(x-i)
		break
	else:
		i+=1

Failing test case input:
10 3
1 7 10 6 5

Expected output:
9


Actual output:
11


Fixed submission (verdict: Accepted):
import sys






























fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())



x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x-i not in s):
		print(x-i)
		break
	elif(x+i not in s):
		print(x+i)
		break
	else:
		i+=1

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import collections
import itertools as it
import math

 


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




li = []
for i in range(1, 101):
    if not i in p:
        li.append(i)

ans = 1000
min_ = 1000
for i, l in enumerate(li):
    if min_ > abs(x - l):
        min_ = abs(x - l)
        ans = l

print(ans)


Failing test case input:
0 2
4 7 10 8 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):

import collections
import itertools as it
import math

 


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




li = []
for i in range(-1000, 1001):
    if not i in p:
        li.append(i)

ans = 1000
min_ = 1000
for i, l in enumerate(li[::-1]):
    if min_ >= abs(x - l):
        min_ = abs(x - l)
        ans = l

print(ans)

Problem: p02641
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X, N= list(map(int, input().split()))
P = list(map(int, input().split()))
if N == 0:
    print(X)
else:
    for i in range(1, 51):
        try:
            P.index(X - i)
        except Exception:
            print(X - i)
            break

        try:
            P.index(X + i)
        except Exception:
            print(X + i)
            break

Failing test case input:
6 2
4 7 10 8 2

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
X, N= list(map(int, input().split()))
P = list(map(int, input().split()))
for i in range(0, 51):
    try:
        P.index(X - i)
    except Exception:
        print(X - i)
        break

    try:
        P.index(X + i)
    except Exception:
        print(X + i)
        break