Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)

count = 0
for l in S_li:
    a = l.find('0')
    bc = l.rfind('1')
    if 0 <= a < bc:
        count += (bc-a)
        while True:
            i = a+1
            a = l[:bc].find('0',i)
            bc = l[:bc].rfind('1',i)
            if 0 <= a < bc:
                count += (bc-a)
            else:
                break
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)

count = 0
for l in S_li:
    while True:
        a = l.find('0')
        bc = l.rfind('1')
        if 0 <= a < bc:
            count += (bc-a)
            l = l[a+1:bc]
        else:
            break

print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    if len(l):
        while True:
            a = l.find('0')
            if a<0:
                break
            bc = l.rfind('1')
            if a < bc:
                l = l[a+1:bc]
                count += (bc-a)
            else:
                break
 
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)

count = 0
for l in S_li:
    if len(l):
        while True:
            a = l.find('0')
            if a<0:
                break
            bc = l.rfind('1')
            if a < bc:
                l = l[a+1:bc]
                count += (bc-a)
            else:
                break

print(str(count))


Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Runtime Error):
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('[BC]')

count = 0
for l in S_li:
    if len(l):
        while True:
            a = l.find('0')
            if a<0:
                break
            bc = l.rfind('1')
            if a < bc:
                l = l[a+1:bc]
                count += (bc-a)
            else:
                break

print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):

S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = N1.split('B')

count = 0
for bigstr in S_li:
    if len(bigstr):
        li = bigstr.split('C')
        for l in li:
            if len(l):
                while True:
                    a = l.find('0')
                    if a<0:
                        break
                    bc = l.rfind('1')
                    if a < bc:
                        l = l[a+1:bc]
                        count += (bc-a)
                    else:
                        break

print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
N1 = re.subn('A','0',S)
N2 = re.subn('BC','1',N1[0])
S_li = N2[0].split('B')

count = 0
for bigstr in S_li:
    if len(bigstr):
        li = bigstr.split('C')
        for l in li:
            if len(l):
                while True:
                    a = l.find('0')
                    bc = l.rfind('1')
                    if a<0 or bc<0:
                        break
                    if a < bc:
                        l = l[a+1:bc]
                        count += (bc-a)
                    else:
                        break

print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
s = [S]
count = 0
while True:
#    s = re.subn('ABCBC','BCABC',s[0])
#    count += s[1]
#    s = re.subn('AABC','ABCA',s[0])
#    count += s[1]
    s = re.subn('ABC','BCA',s[0])
    if s[1]:
        count += s[1]
    else:
        break
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
s = [S]
count = 0
while True:
    s = re.subn('ABCBC','BCABC',s[0])
    count += s[1]
    s = re.subn('AABC','ABCA',s[0])
    count += s[1]
    s = re.subn('ABC','BCA',s[0])
    if s[1]:
        count += s[1]
    else:
        break
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()

count = 0
while True:
    if 'ABCBC' in S:
        s = re.subn('ABCBC','BCABC',S)
        S = s[0]
        count += s[1]
    if 'AABC' in S:
        s = re.subn('AABC','ABCA',S)
        S = s[0]
        count += s[1]
        continue
    if 'ABC' in S:
        s = re.subn('ABC','BCA',S)
        S = s[0]
        count += s[1]
    else:
        break
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))

Buggy python submission (verdict: Time Limit Exceeded):

S = input()

count = 0
while 'ABC' in S:
    if 'ABCBC' in S:
        S = S.replace('ABCBC','BCABC',1)
        count += 1
        continue
    if 'AABC' in S:
        S = S.replace('AABC','ABCA',1)
        count += 1
        continue
    else:
        S = S.replace('ABC','BCA',1)
        count += 1
print(str(count))

Fixed submission:
import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))