Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]
    flag = True
    while flag:
        flag = False
        for a in arr:
            tmp = 0
            for i in a:
                tmp += i
                if i is 0:
                    cnt += tmp
                    
    return cnt


if __name__ == '__main__':
    print(main())


Fixed submission:
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]
    flag = True
    while flag:
        flag = False
        for a in arr:
            tmp = 0
            for i in a:
                i = int(i)
                tmp += i
                if i is 0:
                    cnt += tmp

    return cnt


if __name__ == '__main__':
    print(main())

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]

    flag = True
    while flag:
        flag = False
        for a in arr:

            for i in range(len(a)-1):
                if a[i] > a[i + 1]:
                    a[i], a[i + 1] = a[i+1], a[i]
                    cnt += 1
                    flag = True
    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]
    flag = True
    while flag:
        flag = False
        for a in arr:
            tmp = 0
            for i in a:
                i = int(i)
                tmp += i
                if i is 0:
                    cnt += tmp

    return cnt


if __name__ == '__main__':
    print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]

    flag = True
    while flag:
        flag = False
        for a in arr:

            for i in range(len(a)-1):
                if a[i] > a[i + 1]:
                    a[i], a[i + 1] = a[i+1], a[i]
                    cnt += 1
                    flag = True
    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import math
import numpy as np
import re


def inputs(): return [int(s) for s in input().split()]


def main():
    s = input()
    cnt = 0
    s = s.replace('A', '1').replace('BC', '0')
    arr = re.split('[A-C]', s)
    arr = [list(x) for x in arr]
    flag = True
    while flag:
        flag = False
        for a in arr:
            tmp = 0
            for i in a:
                i = int(i)
                tmp += i
                if i is 0:
                    cnt += tmp

    return cnt


if __name__ == '__main__':
    print(main())