Buggy python submission (verdict: Time Limit Exceeded):

value = list(input())
res = 0
while len(value) != 1 and len(value) != 0:
    zero = value[0]
    one = value[-1]
    if zero == one:
        value.pop(0)
        value.pop()
    else:
        if zero != "x" and one != "x":
            res = -1
            break
        value.extend("x") if zero == "x" else value.insert(0, "x")
        value.pop(0)
        value.pop()
        res += 1
print(res)


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
value = list(input())
res = 0
while len(value) != 1 and len(value) != 0:
    if value[0] == value[-1]:
        value.pop(0)
        value.pop()
    else:
        if value[0] != "x" and value[-1] != "x":
            res = -1
            break
        value.extend("x") if value[0] == "x" else value.insert(0, "x")
        value.pop(0)
        value.pop()
        res += 1
print(res)


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
value = list(input())
res = 0
while True:
    if len(value) == 1 or len(value) == 0:
        break
    elif value[0] != value[-1] and value[0] != "x" and value[-1] != "x":
        res = -1
        break
    elif value[0] == value[-1]:
        value.pop(0)
        value.pop()
    else:
        value.extend("x") if value[0] == "x" else value.insert(0, "x")
        value.pop(0)
        value.pop()
        res += 1
print(res)


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def calc(value):
    res = 0
    while True:
        if len(value) == 1 or len(value) == 0:
            break
        elif value[0] != value[-1] and value[0] != "x" and value[-1] != "x":
            res = -1
            break
        elif value[0] == value[-1]:
            value.pop(0)
            value.pop()
        else:
            value.extend("x") if value[0] == "x" else value.insert(0, "x")
            value.pop(0)
            value.pop()
            res += 1
    return res


def main():
    value = list(input())
    print(calc(value))


if __name__ == '__main__':
    main()


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)

Buggy python submission (verdict: Runtime Error):
def calc(value):
    res = 0
    while True:
        if len(value) == 1:
            break
        elif value[0] != value[-1] and value[0] != "x" and value[-1] != "x":
            res = -1
            break
        elif value[0] == value[-1]:
            value.pop(0)
            value.pop()
        else:
            value.extend("x") if value[0] == "x" else value.insert(0, "x")
            value.pop(0)
            value.pop()
            res += 1
    return res


def main():
    value = list(input())
    print(calc(value))


if __name__ == '__main__':
    main()


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)

Buggy python submission (verdict: Runtime Error):
def calc(value):
    res = 0
    while True:
        if len(value) == 1:
            break
        elif value[0] != value[-1] and value[0] != "x" and value[-1] != "x":
            res = -1
            break
        elif value[0] == value[-1]:
            value.pop(0)
            value.pop()
        else:
            value.extend("x") if value[0] == "x" else value.insert(0, "x")
            res += 1
    return res


def main():
    value = list(input())
    print(calc(value))


if __name__ == '__main__':
    main()


Fixed submission:
s = input()
ns = s.replace('x', '')
if s == s[::-1]:
    print(0)
elif ns != ns[::-1]:
    print(-1)
else:
    cnt = 0
    i = 0
    j = len(s)-1
    while(i<j):
        if s[i]=='x' and s[j]!='x':
            cnt += 1
            j += 1
        elif s[i]!='x' and s[j]=='x':
            cnt += 1
            i -= 1
        i += 1
        j -= 1
    print(cnt)