Buggy python submission (verdict: Time Limit Exceeded):
ss = list(input())
s = []
for i in ss:
  if i == 'A':
    s.append(1)
  elif i == 'B':
    s.append(2)
  else:
    s.append(3)
n = len(s)
ans = 0
while True:
    b = False
    for i in range(0, n-2):
        if s[i:i+3] == [1, 2, 3]:
            s[i] = 2
            s[i+1] = 3
            s[i+2] = 1
            ans += 1
            b = True
    if not b:
        break
print(ans)


Fixed submission:
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
ans = 0
while True:
    b = False
    for i in range(0, n-2):
        if s[i:i+3] == ['A', 'B', 'C']:
            s[i] = 'B'
            s[i+1] = 'C'
            s[i+2] = 'A'
            ans += 1
            b = True
    if not b:
        break
print(ans)


Fixed submission:
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)

Buggy python submission (verdict: Runtime Error):
from numba import jit
s = list(input())
n = len(s)
ans = 0
@jit
def p(ans):
    for i in range(0, n-2):
        b = True
        if s[i:i+3] == ['A', 'B', 'C']:
            s[i] = 'B'
            s[i+1] = 'C'
            s[i+2] = 'A'
            ans += 1
            b = False
        
    return ans, b
while True:
    ans, b = p(ans)
    if not b:
        break
print(ans)


Fixed submission:
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
ans = 0
while True:
    b = False
    for i in range(0, n-2):
        if s[i:i+3] == ['A', 'B', 'C']:
            s[i] = 'B'
            s[i+1] = 'C'
            s[i+2] = 'A'
            ans += 1
            b = True
    if not b:
        break
print(ans)


Fixed submission:
s = list(input())
li = []
n = len(s)
ans = 0
b = False
for i in range(n-1):
    if b:
        b = False
        continue
    if s[i] + s[i+1] == 'BC':
        li.append('D')
        b = True
    if s[i] == 'B' and s[i+1] != 'C':
        li.append('E')
    if s[i] == 'C':
        li.append('E')
    if s[i] == 'A':
        li.append('A')
cnt = 0
for i in range(len(li)):
    if li[i] == 'A':
        cnt += 1
    elif li[i] == 'E':
        cnt = 0
    else:
        ans += cnt
print(ans)