Problem p02641 (python)

Fixed submission:
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  out=0
  for j in range(n):
    if slist[j]==x-i:
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==x+i:
      out=1
  if out !=1:
    print(x+i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flaga=1
    if slist[j]==x+i:
        flagb=1
            
  if flaga=1 and flagb=1:
    flaga=0
    flagb=0
  elif flagb==0:
    print(x-i)
    exit()
  elif flaga==0:
    print(x+i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
s=list(map(int,input().split()))
slist=sorted(s)

  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n+1):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

for i in range(0,100):
  for j in range(n):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

Buggy submission (verdict: Runtime Error):
x,n=map(int,input().split())
s=list(map(int,input().split()))

dist=0
for i in range(0,100):
 if abs(x-i)>=0:
  for j in s:
    if s[j]==i:
    else:
      print(i)

Buggy submission (verdict: Runtime Error):
c=[]
d=0
e=[]

a,b=map(int,input().split())
c=int(input().split())
if c!=null:
 for i in range(c):
  d=a-c
  e.append(abs(d))
print(min(e))