Problem p03378 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

sm = l[2]
la = l[2]
while(True):
    if sm == 0:
        print 0
    if la == l[0]:
        print 0
    sm = sm - 1
    la = la + 1
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
        ix = ix / 2 + 0.5
        break
    if sm in A:
        ix = A.index(sm) + 0.5
	break
    if la in A:
	ix = A.index(la) - 0.5
	break
M = l[1] - ix - 1
if M > ix:
    print int(math.ceil(ix))
else:
    print int(math.ceil(M))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

sm = l[2]
la = l[2]
while(True):
    sm = sm - 1
    la = la + 1
    if sm == 0:
        print 0
    if la == l[0]:
        print 0
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
        ix = ix / 2 + 0.5
        break
    if sm in A:
        ix = A.index(sm)
		break
    if la in A:
		ix = A.index(la)
		break
M = l[1] - ix - 1
if M > ix:
    print int(math.ceil(ix))
else:
    print int(math.ceil(M))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

sm = l[2]
la = l[2]
while(True):
    sm = sm - 1
    la = la + 1
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
        ix = ix / 2 + 0.5
        break
    if sm in A:
        ix = A.index(sm)
	break
    if la in A:
	ix = A.index(la)
	break
    if sm = 0:
        print 0
    if la = l[0]:
        print 0
M = l[1] - ix - 1
if M > ix:
    print int(math.ceil(ix))
else:
    print int(math.ceil(M))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

if l[2] in A:
    M = l[1] - A.index(l[2])
    if M > A.index(l[2]):
        print A.index(l[2])
    else:
        print M
sm = l[2]
la = l[2]
while(TRUE):
    sm = sm - 1
    la = la + 1
    if sm in A and la in A:
    	ix = A.index(sm) + A.index(la)
	ix = ix / 2
	break
    if sm in A:
    	ix = A.index(sm)
	break
    if la in A:
	ix = A.index(la)
	break
M = l[1] - ix
if M > ix:
    print math.floor(ix)
else:
    print M

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

if l[2] in A:
    M = l[1] - A.index(l[2])
    if M > A.index(l[2]):
		print A.index(l[2])
	else:
		print M
sm = l[2]
la = l[2]
while(TRUE):
	sm = sm - 1
	la = la + 1
	if sm in A and la in A:
		ix = A.index(sm) + A.index(la)
		ix = ix / 2
		break
	if sm in A:
		ix = A.index(sm)
		break
	if la in A:
		ix = A.index(la)
		break
M = l[1] - ix
if M > ix:
	print math.floor(ix)
else:
	print M

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

if l[2] in A:
    M = l[1] - A.index(l[2])
    if M > A.index(l[2]):
		print A.index(l[2])
	else:
		print M
sm = l[2]
la = l[2]
while true:
	sm = sm - 1
	la = la + 1
	if sm in A and la in A:
		ix = A.index(sm) + A.index(la)
		ix = ix / 2
		break
	if sm in A:
		ix = A.index(sm)
		break
	if la in A:
		ix = A.index(la)
		break
M = l[1] - ix
if M > ix:
	print math.floor(ix)
else:
	print M

Buggy submission (verdict: Runtime Error):
import math

l = map(int, raw_input().split())
A = map(int, raw_input().split())

if l[2] in A:
	M = l[1] - A.index(l[2])
	if M > A.index(l[2]):
		print A.index(l[2])
	else:
		print M
sm = l[2]
la = l[2]
while true:
	sm = sm - 1
	la = la + 1
	if sm in A and la in A:
		ix = A.index(sm) + A.index(la)
		ix = ix / 2
		break
	if sm in A:
		ix = A.index(sm)
		break
	if la in A:
		ix = A.index(la)
		break
M = l[1] - ix
if M > ix:
	print math.floor(ix)
else:
	print M