Buggy python submission (verdict: Time Limit Exceeded):
s = input()

if s == s[::-1]:
    print(0)
    exit()

t = []

for i in range(len(s)):
    if s[i] != 'x':
        t.append(s[i])

if t != t[::-1]:
    print(-1)
    exit()

central_char = t[len(t)//2]

s = list(s)
s.insert(0, '*')
s.append('*')

central_position = 0

for i in range(len(s)):
    if s[i] == central_char:
        central_position = i

left = central_position - 1
right = central_position + 1
x_cnt = 0

while left > 0 or right < len(s)-1:
    if s[max(0, left)] == s[min(len(s)-1, right)]:
        left -= 1
        right += 1
    else:
        x_cnt += 1
        if s[max(0, left)] == 'x':
            left -= 1
        else:
            right += 1

print(x_cnt)

Fixed submission:
s = input()

left = 0
right = len(s) - 1
x_cnt = 0

while left < right:
    if s[left] == s[right]:
        left += 1
        right -= 1
    else:
        if s[left] == 'x':
            x_cnt += 1
            left += 1
        elif s[right] == 'x':
            x_cnt += 1
            right -= 1
        else:
            print(-1)
            exit()

print(x_cnt)

Buggy python submission (verdict: Runtime Error):
s = input()

if s == s[::-1]:
    print(0)
    exit()

t = []

for i in range(len(s)):
    if s[i] != 'x':
        t.append(s[i])

if t != t[::-1]:
    print(-1)
    exit()

central_char = t[len(t)//2]

s = list(s)
s.insert(0, '*')
s.append('*')

central_position = 0

for i in range(len(s)):
    if s[i] == central_char:
        central_position = i

left = central_position - 1
right = central_position + 1
x_cnt = 0

while left > 0 or right < len(s)-1:
    if s[max(0, left)] == s[min(len(s), right)]:
        left -= 1
        right += 1
    else:
        x_cnt += 1
        if s[max(0, left)] == 'x':
            left -= 1
        else:
            right += 1

print(x_cnt)

Fixed submission:
s = input()

left = 0
right = len(s) - 1
x_cnt = 0

while left < right:
    if s[left] == s[right]:
        left += 1
        right -= 1
    else:
        if s[left] == 'x':
            x_cnt += 1
            left += 1
        elif s[right] == 'x':
            x_cnt += 1
            right -= 1
        else:
            print(-1)
            exit()

print(x_cnt)

Buggy python submission (verdict: Runtime Error):
s = input()

if s == s[::-1]:
    print(0)
    exit()

t = []

for i in range(len(s)):
    if s[i] != 'x':
        t.append(s[i])

if t != t[::-1]:
    print(-1)
    exit()

central_char = t[len(t)//2]

s = list(s)
s.insert(0, '*')
s.append('*')

central_position = 0

for i in range(len(s)):
    if s[i] == central_char:
        central_position = i

left = central_position - 1
right = central_position + 1
x_cnt = 0

while left != 0 or right != len(s)-1:
    if s[max(0, left)] == s[min(len(s), right)]:
        left -= 1
        right += 1
    else:
        x_cnt += 1
        if s[max(0, left)] == 'x':
            left -= 1
        else:
            right += 1

print(x_cnt)

Fixed submission:
s = input()

left = 0
right = len(s) - 1
x_cnt = 0

while left < right:
    if s[left] == s[right]:
        left += 1
        right -= 1
    else:
        if s[left] == 'x':
            x_cnt += 1
            left += 1
        elif s[right] == 'x':
            x_cnt += 1
            right -= 1
        else:
            print(-1)
            exit()

print(x_cnt)