TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=list(input())
l=[]
f=0
for i in range(len(s)-1):
    if s[i]=="A":
        l.append("A")
        f=0
    elif s[i]=="B":
        if s[i+1]=="C":
            l.append("D")
            f=1
        else:
            l.append("B")
            f=0
    else:
        if f:
            f=0
            continue
        else:
            l.append("C")
ac=0
ans=0
print("".join(l))
for i in range(len(l)):
    if l[i]=="A":
        ac+=1
    elif l[i]=="D":
        ans+=ac
    else:
        ac=0
print(ans)


s=list(input())
l=[]
f=0
for i in range(len(s)-1):
    if s[i]=="A":
        l.append("A")
        f=0
    elif s[i]=="B":
        if s[i+1]=="C":
            l.append("D")
            f=1
        else:
            l.append("B")
            f=0
    else:
        if f:
            f=0
            continue
        else:
            l.append("C")
ac=0
ans=0
for i in range(len(l)):
    if l[i]=="A":
        ac+=1
    elif l[i]=="D":
        ans+=ac
    else:
        ac=0
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
    print(s)
print(ans)

s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()

ans = 0
i = 0

while i < len(s) :
    if s[i] == 'A' :
        if s[i+1] == 'B' and s[i+2] == 'C' : 
            j = 1
            for j in range(1,i+1) :
                if not s[i-j] == 'A' : 
                    break
            k = 0
            for k in range(0,len(s)) :
                ans += j - 1 + k
                if not s[i+k] == 'A' :
                    break
            i += k + 3
    i += 1

print(ans + 1)

S = input()
S = S.replace('BC', 'D')

cnt = 0
ans = 0
for i, s in enumerate(S):
    if s == 'D':
        ans += cnt
    elif s == 'A':
        cnt += 1
    else:
        cnt = 0
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
	S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        ans += 1
        if flag:
            ans += flag
        if ABCflag:
            ans += ABCflag
            ABCflag = 0
        i += 2
        ABCflag += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0
        if S[i]+S[i+1] == 'BC':
            if ABCflag:
                ans += ABCflag
                ABCflag = 0
            i += 1
        else:
            ABCflag = 0
    i += 1

print(ans)


S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        if flag:
            ans += flag
        ans += 1
        S[i+2] = 'A'
        i += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0

    i += 1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
from sys import stdin
s = (stdin.readline().rstrip())
s = s.replace("BC","D")
ans = 0
acc = 0

for i in s:
    if i == "B" or i == "C":
        acc = 0
        continue
        
    if i == "A":
        acc += 1
    
    if i == "D":
        ans += acc

print(acc)

from sys import stdin
s = (stdin.readline().rstrip())
s = s.replace("BC","D")
ans = 0
acc = 0

for i in s:
    if i == "B" or i == "C":
        acc = 0
        continue
        
    if i == "A":
        acc += 1
    
    if i == "D":
        ans += acc

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s='ABCACCBABCBCAABCB'
s=s.replace('BC','D')
a=0
ans=0
for i in s:
  if i=='A':
    a+=1
  elif i=='D':
    ans+=a
  else:
    a=0
print(ans)

s=input()
s=s.replace('BC','D')
a=0
ans=0
for i in s:
  if i=='A':
    a+=1
  elif i=='D':
    ans+=a
  else:
    a=0
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input().replace('BC','D')
n = len(s)
 
count = 0
res = 0
 
for i in range(n):
    if s[i] == 'A':
        count += 1
    elif s[i] == 'D':
        res += count
    else:
        count = 0
 
print(ans)

s = input().replace('BC','D')
n = len(s)
 
count = 0
res = 0
 
for i in range(n):
    if s[i] == 'A':
        count += 1
    elif s[i] == 'D':
        res += count
    else:
        count = 0
print ans

s = input().replace('BC','D')
n = len(s)
 
count = 0
res = 0
 
for i in range(n):
    if s[i] == 'A':
        count += 1
    elif s[i] == 'D':
        res += count
    else:
        count = 0
print(res)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
w=list(input())
now=0
num=len(w)
w.append(" ")
count=0
while now<num:
  if w[now]!="A":
    now+=1
  else:
    if w[now+1]!="B":
      now+=1
    else:
      if w[now+2]!="C":
        now+=1
      else:
        w[now]="B"
        w[now+1]="C"
        w[now+2]="A"
        count+=1
        back=now-1
        b=True
        while back>0 and b=True:
          if w[back]!="A":
            b=False
          else:
            w[back]="B"
            w[back+1]="C"
            w[back+2]="A"
            count+=1
            back-=1
print(count)
            

w=input()
count=0
num=len(w)
w1=""
w+=" "
while count<num:
  if w[count]=="A":
    w1+="A"
    count+=1
  elif w[count]=="B":
    if w[count+1]=="C":
      w1+="D"
      count+=2
    else:
      w1+="B"
      count+=1
  else:
    w1+="C"
    count+=1
counta=0
ans=0
num=len(w1)
for i in range(num):
  if w1[i]=="A":
    counta+=1
  elif w1[i]=="D":
    ans+=counta
  else:
    counta=0
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()

s = s.replace('BC', 'D')
a_count = 0
count = 0
print(s)
for c in s:
    if c == 'A':
        a_count += 1
    elif c == 'D':
        count += a_count
    else:
        a_count = 0

print(count)

s = input()

s = s.replace('BC', 'D')
a_count = 0
count = 0
for c in s:
    if c == 'A':
        a_count += 1
    elif c == 'D':
        count += a_count
    else:
        a_count = 0

print(count)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        si = s[index]
        # print(index)
        # print(si)
        # print(a_stock)
        # print(b_stock)
        # print(ope_num)
        # print()
        if si == "A":
            if b_stock > 0:
                b_stock = 0
                a_stock = 1
            else:
                a_stock = 1
        elif si == "B" and a_stock > 0 and b_stock == 0:
            b_stock.append(si)
        elif si == "C" and a_stock > 0 and b_stock > 0:
            ope_num = ope_num + 1
            s[index - 2] = "B"
            s[index - 1] = "C"
            s[index] = "A"
            a_stock = 0
            b_stock = 0
            if index - 4 >= -1:
                index = index - 4
            else:
                index = index - 1
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)











def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    ope_num = 0
    index = 0
    a_stock = 0
    b_stock = 0
    s = list(s)
    while index < len(s):
        # print(s)
        # print(index)
        # print(ope_num)
        # print()
        si = s[index]
        if si == "A":
            if b_stock > 0:
                a_stock = 1
            else:
                a_stock = a_stock + 1
            b_stock = 0
        elif a_stock > 0:
            if b_stock == 0:
                if si == "B":
                    b_stock = 1
                else:
                    a_stock = 0
                    b_stock = 0
            elif si == "C":
                ope_num = ope_num + a_stock
                # s[index - 2 - a_stock + 1] = "B"
                # s[index - 1 - a_stock + 1] = "C"
                # s[index] = "A"
                
                a_stock = a_stock
                b_stock = 0
            else:
                a_stock = 0
                b_stock = 0
        else:
            a_stock = 0
            b_stock = 0
        index = index + 1
    print(ope_num)











Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()
N = len(S)
a = 0
ans = 0
for i in range(N):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
        else:
            a = 0
    else:
        a = 0
print(ans)

S = input()
N = len(S)
a = 0
ans = 0
f = 0
for i in range(N-1):
    if S[i] == 'A':
        a += 1
    elif S[i] == 'B':
        if S[i+1] == 'C':
            ans += a
            f = 1
        else:
            a = 0
    else:
        if f != 1:
            a = 0
        else:
            f = 0
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input()
n=len(s)

cnt=0
ans=0

for i in range(n-2):
    if s[i]=="A":
        cnt+=1
    elif s[i:i+2]=="BC":
        ans+=cnt
    elif i>0 and s[i-1:i+1]=="BC":
        pass
    else:
        cnt=0

print(ans)
    

s=input()
n=len(s)

cnt=0
ans=0

for i in range(n-1):
    if s[i]=="A":
        cnt+=1
    elif s[i:i+2]=="BC":
        ans+=cnt
    elif i>0 and s[i-1:i+1]=="BC":
        pass
    else:
        cnt=0

print(ans)
    

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b-1:b+2]!="..." and m[b+1:d+1].find("..")<0:
        print( "No" )
        exit()
#

flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "No" )
    exit()
#

ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "No" )
    exit()
#
print( "Yes" )


#!/usr/bin/env python

import sys
import re

s= sys.stdin.readline().strip()
s= s.replace("BC","D")
s= re.sub("[BC]+"," ",s).split()

t= 0
for seg in s:
    a= 0
    for c in seg:
        if c=="A": a+=1
        elif c=="D": t+= a
#
print( t )


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
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)


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)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input().replace("BC", "D")
print(s)
ans = 0
a = 0
for i in range(len(s)):
    if s[i] == "A":
        a += 1
    elif s[i] == "D":
        ans += a
    else:
        a = 0
print(ans)

s = input().replace("BC", "D")
ans = 0
a = 0
for i in range(len(s)):
    if s[i] == "A":
        a += 1
    elif s[i] == "D":
        ans += a
    else:
        a = 0
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
N, A, B, C, D = [int(i) for i in input().split()]
S = input()

def solve():
    ac, bd = S[A - 1:C], S[B - 1:D]
    if A < B < D < C:
        bd = S[B - 2:D + 1]
        return ("..." in bd and "##" not in ac)
    else:
        return ("##" not in ac and "##" not in bd)

if solve():
    print("Yes")
else:
    print("No")

def main():
    S = input().replace("BC", "D")

    ans = a = 0
    for s in S:
        if s == "A":
            a += 1
        elif s == "D":
            ans += a
        else:
            a = 0

    print(ans)

main()

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,input().split())

s=input()
s=s.replace("BC","D")
print(s)
acnt=0
dcnt=0
ans=0
for i in s[::-1]:
    if i=="D":
        ans+=acnt*dcnt
        acnt=0
        dcnt+=1
    elif i=="A":
        acnt+=1
    else:
        ans += acnt * dcnt
        acnt=0
        dcnt=0
ans+=acnt*dcnt
print(ans)

import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,input().split())

s=input()
s=s.replace("BC","D")
acnt=0
dcnt=0
ans=0
for i in s[::-1]:
    if i=="D":
        ans+=acnt*dcnt
        acnt=0
        dcnt+=1
    elif i=="A":
        acnt+=1
    else:
        ans += acnt * dcnt
        acnt=0
        dcnt=0
ans+=acnt*dcnt
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input()
a=s.replace("BC","D")[::-1]
ans=0
i=0
while i<len(a):
  if a[i]=="D":
    k=1
    while True:
      try:
        if a[i+k]=="A" or a[i+k]=="D":
          ans+=1;k+=1
        else:
          i+=k-1
          break
      except:break
  i+=1
print(ans)

s=input()
ans=0
while "ABC" in s:
  s.replace("ABC","BCA",1)
  ans+=1
print(ans)

s=input()
t=""
i=0
while i<len(s):
    if s[i:i+2]=="BC":
        t+="T"
        i+=2
    else:
        t+=s[i]
        i+=1
ans=0
Acnt=0
for i in t:
    if i=="A":
        Acnt+=1
    elif i=="T":
        ans+=Acnt
    else:
        Acnt=0
print(ans)


Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()
idx = 0
a_cnt = 0
cnt = 0
len_s = len(S)
while idx < len_s:
  if S[idx:idx+3] == 'ABC':
    cnt += 1 + a_cnt
    idx += 3
    a_cnt = 0
    bc_cnt = 0
    while idx < len(S):
      if S[idx:idx+2] == 'BC':
        bc_cnt += 1
        idx += 2
      else:
        break
    cnt += bc_cnt
  else:
    if S[idx] == 'A':
      a_cnt += 1
    idx += 1
print(cnt)

S = input()
idx = 0
a_cnt = 0
cnt = 0
len_s = len(S)
while idx < len_s:
  if S[idx:idx+3] == 'ABC':
    cnt += 1 + a_cnt
    idx += 3
    a_cnt += 1
    bc_cnt = 0
    while idx < len(S):
      if S[idx:idx+2] == 'BC':
        cnt += a_cnt
        idx += 2
      else:
        break
  else:
    if S[idx] == 'A':
      a_cnt += 1
    else:
      a_cnt = 0
    idx += 1
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):

def bubble_sort(A):
    cnt = 0
    for i in range(len(A)):
        for j in range(len(A)-1, i, -1):
            if A[j] == 'D' and A[j-1] == 'A':
                A[j], A[j-1] = A[j-1], A[j]
                cnt += 1
    return cnt

s = input()
total = 0
new_s = s.replace("BC", "D")
new_s_list = list(new_s).append("G")
tmp_start = 0
for i in range(len(new_s_list)):
  if new_s_list[i] in {'B', 'C', 'G'}:
    total += bubble_sort(new_s_list[tmp_start:i])
    tmp_start = i

print(total)

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
def minus(n):
  return 128-n

s = input()
total = 0
new_s = s.replace("BC", "D")
new_s_list = list(new_s)
new_s_list.append("G")
tmp_start = 0
for i in range(len(new_s_list)):
  if new_s_list[i] in {'B', 'C', 'G'}:
    ppp = list(map(minus, map(ord, new_s_list[tmp_start:i])))
    bit = Bit(128)
    ans = 0
    for j, p in enumerate(ppp):
      bit.add(p, 1)
      ans += j + 1 - bit.sum(p)
    total += ans
    tmp_start = i+1

print(total)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re
import sys
input = sys.stdin.readline

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

print(s)


for kk in s:
  if not kk:
    continue
  while 'AD' in kk:
    res += kk.count('AD')
    kk = kk.replace('AD', 'DA')
    
print(res)

import re
import sys
input = sys.stdin.readline

s = input()
s = s.replace('BC', 'D')
s = re.split('[BC]', s)
res = 0

for kk in s:
  if not kk:
    continue
  d = 0
  for a in kk[::-1]:
    if a == 'D':
      d += 1
    else:
      res += d
    
print(res)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re

S = str(input())
k=int(0)


while () :
#while S.find('ABC')>=0:
#    S = S[:S.rfind('ABC')] + 'BCA' + S[(S.rfind('ABC')+3):]

    matchedList = re.findall("ABC",S)
    a = len(matchedList)
    k += a
    if a==-1 : break
    S = S.replace('ABC', 'BCA')

ans = (int(k))

print(ans)

import re

S = str(input())
k=int(0)


while () :
#while S.find('ABC')>=0:
#    S = S[:S.rfind('ABC')] + 'BCA' + S[(S.rfind('ABC')+3):]

    matchedList = re.findall("ABC",S)
    a = len(matchedList)
    k += a
    if a==0 : break
    S = S.replace('ABC', 'BCA')

ans = (int(k))

print(ans)

import re

S = str(input())
k=int(0)

for i in range(2000):
#while S.find('ABC')>=0:
#    S = S[:S.rfind('ABC')] + 'BCA' + S[(S.rfind('ABC')+3):]

    matchedList = re.findall("ABC",S)
    k += len(matchedList)
    S = S.replace('ABC', 'BCA')

ans = (int(k))

import re

S = str(input())
k=int(0)


while () :
#while S.find('ABC')>=0:
#    S = S[:S.rfind('ABC')] + 'BCA' + S[(S.rfind('ABC')+3):]

    matchedList = re.findall("ABC",S)
    a = len(matchedList)
    k += a
    S = S.replace('ABC', 'BCA')
    if a==0 : break

ans = (int(k))

print(ans)

s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    
    
    ans = 0
    len_s = len(s)
    for i in range(len_s):
        cnt = 0
        if s[i] == 'A':
            cnt += 1
        elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':
            ans += cnt
        else:
            cnt = 0
            
    print(ans)

if __name__ == '__main__':
    resolve()


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    s = SS()

    
    
    ans = 0
    len_s = len(s)
    cnt = 0
    i = 0
    while i < len_s:
        if s[i] == 'A':
            cnt += 1
            i += 1
        elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':
            ans += cnt
            i += 2
        else:
            cnt = 0
            i += 1
            
    print(ans)

if __name__ == '__main__':
    resolve()


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
# -*- coding: utf-8 -*-
qS = input()


def replace(s, count):
    fi = s.find('ABC')
    if fi >= 0:
        newS = 'A' + s[fi+3:]
        return replace(newS, count + 1)
    else:
        return count


print(replace(qS, 0))


# -*- coding: utf-8 -*-
s = input()
s = s.replace('BC', 'D')

a_num = 0
ans = 0
for c in s:
    if c == 'A':
        a_num += 1
    elif c == 'D':
        ans += a_num
    else:
        a_num = 0

print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = list(input())
count = 0
for i in range(len(s)):
    if s[-i-1] == 'A':
        tmp = -i-1
        while tmp <= -3 and s[tmp+1] == 'B' and s[tmp+2] == 'C':
            s.pop(tmp)
            s.insert(tmp+2, 'A')
            count += 1
            tmp += 2
print(count)

inp = input()
changed_input = inp.replace('BC', 'D')
A_count = 0
total_ans = 0
for st in changed_input:
    if st == 'A':
        A_count += 1
    elif st == 'D':
        total_ans += A_count
    else:
        A_count = 0
print(total_ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
S = input()

BC_str = ""
A_index_lst = []
for i in range(len(S)):
    if S[i] == "A":
        A_index_lst.append(len(BC_str))
    else:
        BC_str += S[i]


print(A_index_lst)
print(BC_str)


ans = 0
i = 0
running_A_count = 0
while i + 1 < len(BC_str):
    if i in A_index_lst:
        running_A_count += A_index_lst.count(i)
    if BC_str[i] == "B" and BC_str[i+1] == "C":
        ans += running_A_count
        i += 1
    else:
        running_A_count = 0
    
    i += 1






print(ans)

S = input()


ans = 0
i = 0
running_A_count = 0
while i + 1 < len(S):
    if S[i] == "A":
        running_A_count += 1
    elif S[i] == "B" and S[i+1] == "C":
        ans += running_A_count
        i += 1
    else:
        running_A_count = 0
    
    i += 1






print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import re

s = input()
s = s[::-1]
ans = 0
for i in range(s.count('A')):
    a = re.search('(CB)+A', s)
    ans += (a.end()-a.start()-1)//2
    s = s.replace('A', '', 1)
    print((a.end()-a.start()),s,ans)
print(ans)

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = '?' + read().rstrip().decode()[::-1]
ans = 0
cnt = 0
index = 0
for _ in range(len(s) + 1):
    if s[index] == 'C' and s[index + 1] == 'B':
        cnt += 1
        index += 1
    elif s[index] == 'A':
        ans += cnt
    else:
        cnt = 0
    index += 1
    if index >= len(s) - 1:
        break
if s[-1] == 'A':
    ans += cnt
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
def check(list,a,b,c,d):
    if c==d:
        return False
    i=a
    counter1=0
    while i<b:
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    counter1=0
    check2,counter2=0,0
    i+=1
    while i<min(c,d):
        if list[i]=='#':
            counter1+=1
            counter2=0
        else:
            counter2+=1
            counter1=0
        if counter1>=2:
            return False
        if counter2>=3:
            check2+=1
        i+=1
    i+=1
    counter1=0
    while i<max(c,d):
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    if d>c:
        return True
    else:
        if check2>=1:
            return True
        else:
            return False
m=list(map(int,input().strip().split()))
l=list(input())
if check(l,m[1],m[2],m[3],m[4]):
    print('Yes')
else:
    print('No')


def give(list):
    i=0
    count=0
    count1=0
    while i<len(list)-2:
        if list[i]=='A':
            count1+=1
            if list[i]=='A' and list[i+1]=='B' and list[i+2]=='C':
                list[i+2]='A'
                
                i+=2
                count+=count1
                count1-=1
                
            else:
                i+=1
        else:
            count1=0
            i+=1
    return count
s=list(input())
print(give(s))


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
s = s.replace("BC", "D")
print(s)
acnt = 0
mode = 1
ans = 0

for i in range(len(s)):
	if s[i] == "A":
		acnt += 1
	elif s[i] == "D":
		ans += acnt
	else:
		acnt = 0
print(ans)

s = input()
s = s.replace("BC", "D")
acnt = 0
mode = 1
ans = 0

for i in range(len(s)):
	if s[i] == "A":
		acnt += 1
	elif s[i] == "D":
		ans += acnt
	else:
		acnt = 0
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
import import re

s = str(input())
find_s = 'ABC'
count = 0
while True:
    s_n = re.sub(r"ABC", "BCA", s)
    l_find = len(re.findall(r"ABC", s))
    count += l_find

    if l_find == 0:
        print(count)
        break
    else:
        s = s_n

import re

s = input()
s = s.replace('BC', 'D')

count = 0
count_a = 0
for string in s:
    if string == 'A':
        count_a += 1
    elif string == 'D':
        count += count_a
    else:
        count_a = 0

print(count)


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
pos = 0
cnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+3] == "ABC":
            s = s[:pos] + "BCA" + s[pos+3:]
            if pos > 0:
                pos -= 1
            cnt += 1
        else:
            if s[pos+1:pos+3] == "AB":
                pos += 1
            elif s[pos+2:pos+3] == "A":
                pos += 2
            else
                pos += 3
        if pos >= len(s)-2:
            break
    print(cnt)


s = input()
pos = 0
cnt = 0
acnt = 0
if len(s) < 3:
    print(0)
else:
    while(True):
        if s[pos:pos+2] == "BC" and acnt > 0:
            pos += 2
            cnt += acnt
            # print(s, s[pos:pos+2], cnt, pos)
        else:
            if s[pos] == "A":
                acnt += 1
            else:
                acnt = 0
            pos += 1
        if pos >= len(s)-1:
            break
    print(cnt)



Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input().replace("BC", "X")
indA = [i for i in range(len(s)) if s[i] == "A"]

ans = 0
for i in indA:
    while s[i] != "B" and s[i] != "C":
        ans += (s[i] == "X")
print(ans)


s = input().replace("BC", "D")
ans, cnt = 0, 0
for i in range(len(s)):
	if s[i] == "A":
		cnt += 1
	elif s[i] == "D":
		ans += cnt
	else:
		cnt = 0
print(ans)


Verdicts: Time Limit Exceeded

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
# coding: utf-8
# Your code here!
s=input()
s=list(s.replace('BC','Z'))
ans=0
print(s)
 
def seisan(list):
    count=0
    N=len(list)-1
    for index,content in enumerate(list):
        if content=="A":
            count+=(N-index)
            N-=1
    return count

temp=[]
while s:
    this=s.pop(0)
    if this=="B" or this=="C":
        ans+=seisan(temp)
        temp.clear()
    else:
        temp.append(this)

print(ans+seisan(temp))


# coding: utf-8
# Your code here!
s=input()

temp=0
ans=0
while s:
    if len(s)>=3:
        if s[0]+s[1]+s[2]=='ABC':
            temp+=1
            del s[0:2]
            continue
    
    ans+=(temp*(temp+1))/2
    temp=0
    
    s_chi=s.pop(0)
    if s_chi="A":
        if 
        temp+=1
    elif s_chi="B":
        if 
    elif s_chi="C":
        


# coding: utf-8
# Your code here!
s=list(input().replace("BC","Z"))[::-1]
ans=0

def seisan(list):
    count=0
    N=len(list)-1
    for index,content in enumerate(list):
        if content=="A":
            count+=(N-index)
            N-=1
    return count

temp=[]
while s:
    this=s.pop(-1)
    if this=="B" or this=="C":
        ans+=seisan(temp)
        temp.clear()
    else:
        temp.append(this)

print(ans+seisan(temp))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
# -*- coding: utf-8 -*-
s = input()
count = 0
a_flg = 0
b_flg = 0
for idx, char in enumerate(s):
    if char == "A":
        a_flg = 1
    elif a_flg == 1 and char == "B":
        b_flg = 1
    elif a_flg == 1 and b_flg == 1 and char == "C":
        count += 1
    else:
        a_flg = 0
        b_flg = 0
print(count)

# -*- coding: utf-8 -*-
import sys
s = input()
count = 0
count += s.count('ABC')
while count != 0:
    s = s.replace("ABC", "BCA")
    count += s.count('ABC')
print(count)

# -*- coding: utf-8 -*-
s = input()
s = s.replace("BC", "X")
count = 0
a_stack = 0
for idx, char in enumerate(s):
    if char == "A":
        a_stack += 1
    elif char == "X":
        count += a_stack
    else:
        a_stack = 0
print(count)

Verdicts: Wrong Answer

Time Limit Exceeded

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input()
ans=0
for i in range(len(s)-2):
  if s[i]+s[i+1]+s[i+2]=="ABC":
    ans+=1
    if i > 1:
      if s[i-2]+s[i-1]=="AB":
        ans+=1
    if i<len(s)-4:
      if s[i+3]+s[i+4]=="BC":
        ans+=1
print(ans)

s = input()
ans = 0
count = 0

for x in s.replace("BC", "Z"):
    if x == "A":
        count += 1
        continue
    elif x == "Z":
        ans += count
    else:
        count = 0
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()

match = ["ABC", "ABCBC", "AABC", "ABCBCAABC", "AABCABCBC"]

ans = 0
for x in match:
    ans += s.count(x)

print(ans)

s = input()
s = s.replace('BC', 'X')

cnt = 0
ans = 0


for x in s:
    if x == 'A':
        cnt += 1
    elif x == 'X':
        ans += cnt
    else:
        cnt = 0

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
count = 0
k = len(s)//2
for i in range(k):
        if 'ABC' in s:
                count = s.count('ABC')
                s = s.replace('ABC','BCA')
        else:
                break
print(count)

a = input()
b = []
count = 0
a = a.replace('BC','D')
for i in range(1,len(a)+1):
    if a[-i] == 'D':
        count += 1
    elif a[-i] == 'A':
        b.append(count)
    else:
        count = 0
print(sum(b))

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = list(input())

cnt = 0
# print(s, cnt)

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

print(cnt)

s = input()
t = s.replace('BC', 'D')

a = 0 
ans = 0 

for i in t:
    if i == 'A':
        a += 1
    elif i == 'D':
        ans += a
    else:
        a = 0

print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in len(s):
        if s[a]=='D':
            max+=acount
        elif s[a]=='A':
            acount+=1
        else:
            acount=0
    print(max)



start=time.time();
main()
#print(time.time()*1000-start*1000)

# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in s:
        if a=='D':
            max+=acount
        elif a=='A':
            acount+=1
        else:
            acount=0
    print(max)
start=time.time();
main()
print(time.time()*1000-start*1000)

# coding: utf-8
import os
import time
import re
import math

def main():
    s=input().replace("BC","D")
    max=0
    acount=0
    for a in range(len(s)):
        if s[a]=='D':
            max+=acount
        elif s[a]=='A':
            acount+=1
        else:
            acount=0
    print(max)



start=time.time();
main()
#print(time.time()*1000-start*1000)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s=input().replace("BC","D")

A=[]
word=""
for i in s:
    if i=="A" or i=="D":
        word +=i
    else:
        A.append(word)
        word=""

cnt=0
for i in A:
    a=0
    for j in i:
        if j=="A":a +=1
        else:cnt +=a

print(cnt)

s=input().replace("BC","D")+"E"

A=[]
word=""
for i in s:
    if i=="A" or i=="D":word +=i
    else:A.append(word);word=""

cnt=0
for i in A:
    a=0
    for j in i:
        if j=="A":a +=1
        else:cnt +=a

print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
#%%
s = list(input())
ans = 0
i = 0

while True:
    if i < 0 :
        i += 1
    elif len(s)-2 <= i:
        break
    else:
        if s[i] == 'A'
            if s[i+1] == 'B' and s[i+2] == 'C':
                ans += 1
                s[i], s[i+1], s[i+2] = 'B', 'C', 'A'
                i -= 1
            else:
                i += 1
        else:
            i += 1

print(ans)


#%%
s = list(input())
i = 0
ss = ''

while True:
    if i <= len(s) - 2:
        if s[i] == 'B' and s[i+1] == 'C':
            ss += 'D'
            i += 2
        else:
            ss += s[i]
            i += 1          
    else:
        ss += s[i]
        i += 1
    if i >= len(s):
        break
#print(ss)

a = 0
ans = 0
for i in range(len(ss)):
    if ss[i] == 'A':
        a += 1
    elif ss[i] == 'D':
        ans += a
    else:
        a = 0
print(ans)

#%%


Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)

import re
s = input()
s_ = s.replace("BC", "D")
group = re.findall(r"[AD]+", s_)
ans = 0
for grp in group:
    a = 0
    for g in grp:
        if g=="A":
            a += 1
        if g=="D":
            ans += a
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
def f(ss):
  n=len(ss)
  ct,res=0,0
  for i in range(n):
    if ss[i]=="x":
      ct+=1
    else:
      res+=ct
  return res
s=input()
s=s.replace("BC","y")
s=s.replace("A","x")
ans=0
chk=""
for i in range(len(s)):
  if s[i]=="x" or s[i]=="y":
    chk+=s[i]
  else:
    ans+=f(chk)
    chk=""
print(ans)


def f(ss):
  n=len(ss)
  ct,res=0,0
  for i in range(n):
    if ss[i]=="x":
      ct+=1
    else:
      res+=ct
  return res
s=input()
s=s.replace("BC","y")
s=s.replace("A","x")
s+="z"
ans=0
chk=""
for i in range(len(s)):
  if s[i]=="x" or s[i]=="y":
    chk+=s[i]
  else:
    ans+=f(chk)
    chk=""
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: You are given a string s consisting of `A`, `B` and `C`.  Snuke wants to perform the following operation on s as many times as possible:    * Choose a contiguous substring of s that reads `ABC` and replace it with `BCA`.  Find the maximum possible number of operations.

Submission attempts (in order):
from sys import stdin
s = stdin.readline().rstrip()
s = s.replace("BC","D")
point = 0
count = 0
for i in s:
    if i == "A":
        count += 1
    elif i == "D":
        point += count
    else:
        count = 0
    print(count)
print(point)

from sys import stdin
s = stdin.readline().rstrip()
s = s.replace("BC","D")
point = 0
count = 0
for i in s:
    if i == "A":
        count += 1
    elif i == "D":
        point += count
    else:
        count = 0
print(point)

Verdicts: Wrong Answer

Accepted