Problem p03073 (python)

Fixed submission:
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if  len(s)>=2 and s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2 and len(s)>=4:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
elif len(s)%2==0 and len(s)>=4:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
else:
    pass
if s[0]==s[1]:
    s = list(s)
    s[1] = str(abs(int(s[0])-1))
    s = "".join(s)
    cnt +=1
if len(s)%2:
    for i in range(0,len(s)+1,2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)
else:
    for i in range(0,len(s),2):
        if s[i] != s[0]:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != s[1]:
            cnt +=1
    print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()
fst = s[0]
scd = s[1]
cnt = 0
if len(s) ==1:
    print("0")
elif len(s) ==2:
    if len(set(s))==1:
        print("1")
    else:
        print("0")
elif len(s) ==3:
    if len(set(s)) == 1:
        print("1")
    else:
        if s[0] == s[2]:
            print("0")
        else:
            print("1")
elif len(s)%2:
    for i in range(0,len(s)+1,2):
        if s[i] != fst:
            cnt +=1
    for i in range(1,len(s),2):
        if s[i] != scd:
            cnt +=1
    print(cnt)
else:
    for i in range(0,len(s),2):
        if s[i] != fst:
            cnt +=1
    for i in range(1,len(s)+1,2):
        if s[i] != scd:
            cnt +=1
    print(cnt)