Buggy python submission (verdict: Runtime Error):
s = raw_input()
def test(s):

	res = 0
	aAdd = 0
	last = ''
	s1 = s
	tmp = ''
	for i in xrange(len(s)-2):
		if tmp and tmp > i:
			continue
		if s1[i] == 'A' and (not last or last == 'A'):
			aAdd += 1
		else:
			aAdd = 0
			last = s1[i]

		if s1[i:i+3] == 'ABC':
			print s1
			print aAdd
			res = res + aAdd
			last = 'A'
			aAdd -= 1
			tmp = i + 2
			s1 = s1[:i] + 'BCA' + s1[i+3:]

	return res
print test(s)

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = raw_input()
n = 0

def mul(s):
    if len(s) < 3:
        return 0
    n = 0
    _res = 0
    j = 0
    while j <= (len(s) - 2):
        j = j + _res
        if j < 0:
            j = 0
        _res = 0
        str = s[j:(j + 3)]
        if str == "ABC":
            n = n + 1
            _res = -2
            s = s[:j] + "BCA" + s[j + 3:]
        else:
             j = j + 1
    return n
print mul(s)

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = raw_input()
n = 0

def mul(s):
    if len(s) < 3:
        return 0
    n = 0
    _res = 0
    j = 0
    while j <= (len(s) - 2):
        j = j + _res
        if j < 0:
            j = 0
        _res = 0
        str = s[j:(j + 3)]
        if str == "ABC":
            n = n + 1
            _res = -2
            s = s[:j] + "BCA" + s[j + 3:]
        j = j + 1
    return n
print mul(s)

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = raw_input()
n = 0

def mul(s):
    if len(s) < 3:
        return 0
    n = 0
    _res = 0
    j = 0
    while j < (len(s) - 2):
        j = j + _res
        if j < 0:
            j = 0
        _res = 0
        str = s[j:(j + 3)]
        if str == "ABC":
            n = n + 1
            _res = -2
            s = s[:j] + "BCA" + s[j + 3:]
    return n
print mul(s)

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
# s = list('ABCABC')
# s = list('ABCACCBABCBCAABCB')

# count = 0
#
# if len(s) < 3:
# 	print(0)
ccc = 0
# while :

i = 0
if len(s) >= 3:
    while i + 2 < len(s):
        if s[i] == 'A':
            if s[i + 1] == 'B' and s[i + 2] == 'C':
                s[i: i + 3] = ['B', 'C', 'A']
                ccc += 1
                if i - 1 >= 0 and s[i - 1] == 'A':
                    i -= 1
                else:
                    i = 0
            else:
                i += 1
        else:
            i += 1
        # print(s)
        # print(i)

        # print(i)
        # print(s)
# print(s)
print(ccc)



Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Runtime Error):
s = raw_input()
# a, b = s.split(' ')
# a, b = int(a), int(b)
n = 0

def mul(s, n):
    if len(s) < 3:
        return 0
    for i in range(len(s) - 2):
        str = s[i:(i+3)]
        if str == "ABC":
            n = n + 1
            print(s[:i] + "BCA"+ s[i+3:])
            return mul(s[:i] + "BCA"+ s[i+3:], n)
            # _str[i:i+3] = "BCA"+ _str[i+3:]
    return n
print(mul(s,n))

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):

s = input()
# s = 'ABCABC'

count = 0

while True:
    idx = s.find('ABC')
    if idx == -1:
        break
    s = s[:idx] + 'BCA' + s[idx+3:]
    count += 1
    # print(s)


print(count)
# print(idx)
# print(s)

Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)

Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
n=len(s)
ans=0
if 'ABC' not in s:
    print(0)
elif 'ABC' in s:
        p=s.count('ABC')
        while n>0:
            s=s.replace('ABC','BCA')
            q=s.count('ABC')
            n=n-1 
            ans=ans+q
            
        print(p+ans)


Fixed submission:
def test(s):

	res = 0
	aAdd = 0
	last = ''
	tmp = ''
	for i in xrange(len(s)):
		if tmp and tmp > i:
			continue
		if s[i] == 'A':
			aAdd += 1
		elif s[i:i+2] == 'BC':
			# print aAdd
			res = res + aAdd
			tmp = i + 2
		else:
			aAdd = 0
			last = s[i]


	return res
s=raw_input()
print test(s)