Buggy python submission (verdict: Time Limit Exceeded):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    for i in range(len(S) - 1):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = [i for i in S if i < 2]
    check(S)

S = list(map(int, list(input())))
base_S_length = len(S)
check(S)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    for i in range(len(S) - 1):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = [i for i in S if i != 2]
    check(S)

S = list(map(int, list(sys.stdin.readline())))
base_S_length = len(S)
check(S)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    S_length = len(S) - 1
    for i in range(S_length):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = [i for i in S if i != 2]
    check(S)

S = list(map(int, list(input())))
base_S_length = len(S)
check(S)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    for i in range(len(S) - 1):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = [i for i in S if i != 2]
    #S = list(filter(lambda a: a != 2, S))
    check(S)

S = list(map(int, list(input())))
base_S_length = len(S)
check(S)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    for i in range(len(S) - 1):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = list(filter(lambda a: a != 2, S))
    check(S)

S = list(map(int, list(input())))
base_S_length = len(S)
check(S)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def check(S, cnt, start_idx):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(start_idx, len(S) - 1):
        if S[i] != S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt, i - 1)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0, start_idx = 0)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.input
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def check(S, cnt):
    stop = True
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] ^ S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] ^ S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()