Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    i = min(i,0)
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i:i+3] = ['B','C','A']
        i -= 2
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    min(i,0)
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i:i+3] = ['B','C','A']
        i -= 2
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i:i+3] = ['B','C','A']
        i -= 2
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i+2] = 'A'
        s[i+1] = 'C'
        s[i] = 'B'
        i -= 2
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i+2] = 'A'
        s[i+1] = 'C'
        s[i] = 'B'
        i -= 2
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
a_count = 0
ans = 0
i = 0
while i < n-2:
    #print("".join(s))
    if s[i:i+3] == ['A','B','C']:
        ans +=  1
        s[i+2] = 'A'
        s[i+1] = 'C'
        s[i] = 'B'
        i -= 2
        a_count = 0
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)

Fixed submission:
s = input()
n = len(s)
s = list(s.replace('BC','D'))
a_count = 0
ans = 0
i = 0
while i < len(s) - 1 :
    if s[i:i+2] == ['A','D']:
        ans += a_count + 1
        s[i+1] = 'A'
        s[i] = 'D'
    else:
        if s[i] == 'A':
            a_count += 1
        else:
            a_count = 0
    i += 1
print(ans)