Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
def divisor_enumetarion(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.remove(n)
    return divisors
    
n,k=map(int,input().split())


dp=[0]*k


ans=0
for i in range(k,0,-1):
    toori=(k//i)**n

    dp[i-1]+=toori

    x=divisor_enumetarion(i)
    for j in x:
        dp[j-1]-=dp[i-1]

    ans+=dp[i-1]*i
#    print(dp)
#    print(i,dp[i-1])
print(ans%(10**9+7))

Fixed submission:
def divisor_enumetarion(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.remove(n)
    return divisors
    
n,k=map(int,input().split())

dp=[0]*k
mod=10**9+7

ans=0
for i in range(k,0,-1):
    toori=pow(k//i,n,mod)

    dp[i-1]+=toori

    x=divisor_enumetarion(i)
    for j in x:
        dp[j-1]-=dp[i-1]%mod

    ans+=(dp[i-1]*i)%mod
#    print(dp)
#    print(i,dp[i-1])
print(ans%mod)

#gcdがiの時だけを考え通りを引いて1を足す

Buggy python submission (verdict: Time Limit Exceeded):
def divisor_enumetarion(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.remove(n)
    return divisors
    
n,k=map(int,input().split())


dp=[0]*k


ans=0
for i in range(k,0,-1):
    toori=(k//i)**n

    dp[i-1]+=toori

    x=divisor_enumetarion(i)
    for j in x:
        dp[j-1]-=dp[i-1]

    ans+=dp[i-1]*i
#    print(dp)
#    print(i,dp[i-1])
print(ans%(10**9+7))

Fixed submission:
def divisor_enumetarion(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.remove(n)
    return divisors
    
n,k=map(int,input().split())

dp=[0]*k
mod=10**9+7

ans=0
for i in range(k,0,-1):
    toori=pow(k//i,n,mod)

    dp[i-1]+=toori

    x=divisor_enumetarion(i)
    for j in x:
        dp[j-1]-=dp[i-1]%mod

    ans+=(dp[i-1]*i)%mod
#    print(dp)
#    print(i,dp[i-1])
print(ans%mod)

#gcdがiの時だけを考え通りを引いて1を足す
Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
n,*a=map(int,open(0).read().split())
b=Counter(a)
for i in range(n):
    c=(b-Counter([a[i]]))
    print(sum([v*(v-1)//2 for k,v in c.items()if v>=2]))

Fixed submission:
from collections import*
n,*a=map(int,open(0).read().split())

b=Counter(a)

ans=sum(v*(v-1)//2 for k,v in b.items())

for i in range(n):
    x=b[a[i]]
    print(ans-x*(x-1)//2+(x-1)*(x-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import*
n,*a=map(int,open(0).read().split())
b=Counter(a)
for i in range(n):
    c=(b-Counter([a[i]]))
    print(sum([v*(v-1)//2 for k,v in c.items()if v>=2]))

Fixed submission:
from collections import*
n,*a=map(int,open(0).read().split())

b=Counter(a)

ans=sum(v*(v-1)//2 for k,v in b.items())

for i in range(n):
    x=b[a[i]]
    print(ans-x*(x-1)//2+(x-1)*(x-2)//2)
Buggy python submission (verdict: Runtime Error):
from decimal import *
a,b,c=map(int,input().split())
if Decimal(a).sqrt()+Decimal(a).sqrt(b)<Decimal(a).sqrt(c):
  print("Yes")
else:
  print("No")

Fixed submission:
from decimal import *
a,b,c=map(int,input().split())
if Decimal(a).sqrt()+Decimal(b).sqrt()<Decimal(c).sqrt():
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
def d(s):
    if len(s)==n:print(s)
    else:for i in range(97,ord(max(s))+2):d(s+chr(i))
d("a")

Fixed submission:


def dfs(string,n):
    if len(string)==n:
        print(string)
    else:
        s=string
        for i in range(97,max([ord(j)for j in string])+2):
            dfs(string+chr(i),n)
        

dfs("a",int(input()))
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
from time import* 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline
input=sys.stdin.readline
t=time()

def main():
    n,m=map(int,input().split())
    x=[tuple(map(int,input().split()))for i in range(m)]
    y=sorted(x)
    start=set()
    for s,t,r in y:
        if s==1:
            start.add((1,t,r))
    ans=set([-1])
    substart=set()
    while 1:
        while start:
            qp,p,q=start.pop()
            for s,t,r in y:
                if t==n:
                    ans.add(q)
                elif s<=p and p<=t and s!=qp:
                    substart.add((p,t,q+r))
                    
        start=substart
        if time()-t>6:
            if len(ans)!=1:
                print(min(i for i in ans if i!=-1))
            else:
                print(-1)
            exit()
if __name__ == '__main__':
    main()


Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline

def main():
    n=int(input())
    ans=0
    for i in range(1,n):
        if (i!=n-i and i<n-i):
            ans+=1
        elif i>n-1:
            break
    print(ans)
    
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def main():
    n,k=map(int,input().split())
    a=sorted(map(int,input().split()))
    b=sorted(map(int,input().split()),reverse=1)
    #print(a,b)
    ok=max(a)*max(b)
    ng=-1
    
    
            
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if sum(a[i]-mid//b[i]for i in range(n) if a[i]*b[i]>mid)<=k:
            ok=mid
        else:
            ng=mid
    print(ok)

if __name__ == '__main__':
    main()


Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    if a<10 and b< 10:
        print(a*b)
    else:
        print(-1)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    k=int(input())
    ans=0
    
#    print(x)
    if s[0]!=s[-1]:
        y=[len(list(v))//2 for k,v in groupby(s)]
        print(sum(y)*k)
    else:
        while 1:
            print()
        x=[len(list(v))//2 for k,v in groupby(s)]
        #print(x)
        if len(x)!=1:
            ans+=x[0]+x[-1]
#            print(ans)
            ans+=sum(x[1:-1])*k
#            print(ans)
            ans+=(k-1)*(x[0]+x[-1])
            print(ans)
        else:
            print(len(s)*k//2)
        
    


if __name__ == '__main__':
    main()

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    k=int(input())
    ans=0
    n=[len(list(v)) for k,v in groupby(s)]
#    print(x)
    if s[0]!=s[-1]:
        y=[len(list(v))//2 for k,v in groupby(s)]
        print(sum(y)*k)
    else:
        x=[len(list(v))//2 for k,v in groupby(s)]
#        print(x)
        if len(x)!=1:
            ans+=x[0]+x[-1]
#            print(ans)
            ans+=sum(x[1:-1])*k
#            print(ans)
            ans+=(k-1)*((n[0]+n[-1])//2)
            print(ans)
        else:
            print(len(s)*k//2)
        
    


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    *a,=map(int,input().split())
    *b,=map(int,input().split())
    *c,=map(int,input().split())
    t=sum(b)
    for i in range(len(a)-1):
        if a[i]+1==a[i+1]:
            t+=c[i+1]
    print(t)

            
if __name__ == '__main__':
    main()

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    *a,=map(int,input().split())
    *b,=map(int,input().split())
    *c,=map(int,input().split())
    t=sum(b)
    for i in range(len(a)-1):
        if a[i]+1==a[i+1]:
            t+=c[a[i]-1]
    print(t)

            
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import*
from numpy import*
def section_sum(numbers,separate):
    sep1=array(numbers[separate:],dtype=int)
    sep2=array(numbers[:-separate],dtype=int)
    sep3=sum(numbers[:separate])
    return insert(sep3+cumsum(sep1-sep2),0,sep3)
    
    
n,k,a=open(0).read().split()
n,k=int(n),int(k)
ar=[len(list(v))for k,v in groupby(a)]

#print(ar)
if n<=k:
    print(sum(ar)-1)
else:
    ar2=[i-1 for i in ar]
    s=cumsum(ar2[::2])
    t=cumsum(ar2[1::2])
    mae=[0]+[t[i//2] if i%2 else s[i//2] for i in range(len(ar))]+[0,0,0]
    p=cumsum(ar2[::2][::-1])[::-1]
    q=cumsum(ar2[1::2][::-1])[::-1]
    usiro=[0]+[q[i//2] if i%2 else p[i//2] for i in range(len(ar))]+[0,0,0]
#    print(mae,usiro)
#    print([[[kk,kk+2*k+2],mae[kk],usiro[kk+2*k+2],vv] for kk,vv in enumerate(section_sum(ar,k*2+1))])
    print(max(mae[kk]+usiro[kk+2*k+2]+vv for kk,vv in enumerate(section_sum(ar,k*2+1)))-1)

Fixed submission:
from itertools import*

a,b=map(int,input().split())
s=input()
n=[len(list(v)) for k,v in groupby(s)]
print(min(sum(n)-len(n)+min(len(n)-1,b)*2,a-1))
Buggy python submission (verdict: Runtime Error):
N=int(input());print(~-N*N//2)

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    t=input()
    ans=0
    for i in range(3):
        if s[i]==t[i]:
            ans+=1
    print(ans)
    
    
    
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    t=input()
    ans=0
    for i in range(3):
        if s[i]==t[i]:
            ans+=1
    print(ans)
    
    
    
    
if __name__ == '__main__':
    main()

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    if b>1:
        if b<=a:
            print(1)
        else:
            b-=a
            print((b-1)//(a-1)+2)
    else:
        print(0)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from copy import*
from collections import*

d=defaultdict(deque)
s=input()
x=len(s)
t=input()
for k,v in enumerate(s):
    d[v].append(k)
dsub=deepcopy(d)
#print(*d)
if (set(s)>=set(t)):
#    print(d)
    pre=-1
    ans=0
    for i in t:
        if len(d[i])==0:
            d=deepcopy(dsub)
            pre=d[i].popleft()
            ans+=1
        else:
            p=d[i].popleft()
            if p>pre:
                pre=p
            else:
                d=deepcopy(dsub)
                ans+=1
                pre=p
#        print(d.values())
    print(ans*x+pre+1)
else:
    print(-1)
    


Fixed submission:
from bisect import*
s=input()
t=input()
if set(t)<=set(s):
    d={}
    for k,j in enumerate(s*2):
        if j in d:
            d[j].append(k)
        else:
            d[j]=[k]
    #print(d)
    now=-1
    ans=0
    for _,i in enumerate(t):
        nex=d[i][bisect_right(d[i],now)]
        ans+=nex-now

        #print(i,_,now,nex,ans)
        
        if nex>=len(s):
            now=nex-len(s)
        else:
            now=nex
    print(ans)

else:
    print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import*
from collections import*

d=defaultdict(deque)
s=input()
x=len(s)
t=input()
for k,v in enumerate(s):
    d[v].append(k)
dsub=deepcopy(d)
#print(*d)
if (set(s)>=set(t)):
#    print(d)
    pre=-1
    ans=0
    for i in t:
        if len(d[i])==0:
            d=deepcopy(dsub)
            pre=d[i].popleft()
            ans+=1
        else:
            p=d[i].popleft()
            if p>pre:
                pre=p
            else:
                d=deepcopy(dsub)
                ans+=1
                pre=p
#        print(d.values())
    print(ans*x+pre+1)
else:
    print(-1)
    


Fixed submission:
from bisect import*
s=input()
t=input()
if set(t)<=set(s):
    d={}
    for k,j in enumerate(s*2):
        if j in d:
            d[j].append(k)
        else:
            d[j]=[k]
    #print(d)
    now=-1
    ans=0
    for _,i in enumerate(t):
        nex=d[i][bisect_right(d[i],now)]
        ans+=nex-now

        #print(i,_,now,nex,ans)
        
        if nex>=len(s):
            now=nex-len(s)
        else:
            now=nex
    print(ans)

else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
 
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmin(vector) *min_element(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)
#define bisect_left(vector,a) lower_bound(vector.begin(),vector.end(),a)
#define bisect_right(vector,a) upper_bound(vector.begin(),vector.end(),a)

using namespace std;
long floatinf=-10000000;



int main(void){
    map<long,vector<long>> defaultdict;
    long n,m,p;
    long tmp1,tmp2,tmp3;
    cin>>n,m,p;
    
    for(int i=0  ;i<m  ;i++){
        cin>>tmp1>>tmp2>>tmp3;
        defaultdict[tmp1]={tmp2,tmp3};
    }
    vector<long> BELLMANFORD(long point, long d, long p);{
        vector<long long> cost=vector<long long>(n+1,-floatinf);
    }
    for(int i=0  ;i<n-1  ;i++){
        for(int j=0  ;j<n-1  ;j++){
            
        }
    }

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    a,b=map(int,input().split())
    d=defaultdict(list)
    for i in range(a):
        c,e=map(int,input().split())
        d[c].append(-e)
    for k,v in d.items():
        v=sorted(v)
    ans=[]
    anss=0
    for i in range(1,b+1):
        if i in d.keys():
            for j in d[i]:
                heappush(ans,j)
        if ans:
            anss+=heappop(ans)
    print(-anss)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,*a=map(int,open(0))
*l,=range(1,n+1)
c=0
for i in range(n):
    if a[i]!=l[i]:
        c+=1
if c<=2:
    print("YES")
else:
    print("NO")
    

Fixed submission:
n,*a=map(int,open(0).read().split())
*l,=range(1,n+1)
c=0
for i in range(n):
    if a[i]!=l[i]:
        c+=1
if c<=2:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from copy import *
from collections import*
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
l=[]
for i in range(n):
    q=deepcopy(p)
    a,b=q.pop(i)
#    print(a,q)
    l.extend([(s-a,t-b)for s,t in q])
print(n-(Counter(l).most_common()[0][1]+1)+1)

Fixed submission:
from copy import *
from collections import*
n=int(input())
if n==1:
    print(1)
    exit()
p=[list(map(int,input().split()))for i in range(n)]
l=[]
for i in range(n):
    q=deepcopy(p)
    a,b=q.pop(i)
#    print(a,q)
    l.extend([(s-a,t-b)for s,t in q])
print(n-(Counter(l).most_common()[0][1]+1)+1)
Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input().replace("BC","X")
#    print(s)
    c=0
    while "AX" in s:
        c+=s.count("AX")
        s=s.replace("AX","XA")
    print(c)    
if __name__ == '__main__':
    main()

Fixed submission:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input().replace("BC","X")
#    print(s)
    c=0
    d=0
    for i in s:
        if i=="A":
            c+=1
        elif i=="X":
            d+=c
        else:
            c=0
    print(d)
#    while "AX" in s:
#        s=s.replace("AX","XA")
#        print(s)
if __name__ == '__main__':
    main()