Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

vector<string>split(string s, char delim){
  int len = s.length();
  string currStr = "";
  vector<string>retVec;
  for(int i = 0;i<len;i++){
    char ch = s[i];
    if(ch==delim){
      retVec.push_back(currStr);
      currStr = "";
    }else{
      currStr += ch;
    }
  }
  retVec.push_back(currStr);
  return retVec;
}


vector<string>strToStrVec(string s){
  int len = s.length();
  //  s = s.substr(1,len-2);
  vector<string>strVec = split(s,' ');
  return strVec;

class CountABC{
public:
  int ctOps(string s){
    long long nOps = 0LL;
    /*    bool hasOps = true;
    while(hasOps){
      hasOps = false;
      int newOps = pass(s);
      if(newOps>0){
	hasOps = true;
      }
      nOps += newOps;
      }
    */
    //    bool isDelta = true;
    //    while(isDelta){
      long long startOps = nOps;
      //isDelta = false;
      ///      nOps += processABCConsec(s);
      nOps += processLeadAs(s);
      //      nOps += processTrailBCs(s);
      //      if(nOps>startOps){
      //	isDelta = true;
      //      }
      //    }
    return nOps;
  }

  long long processLeadAs(string&s){
    int len = s.length();
    long long nAsPrior = 0LL;
    long long retV = 0LL;
    //    printf("processLeadAs entry, s %s, len %d\n",s.c_str(),len);
    for(int i=0;i<(len-1);i++){
      //printf("processLeadAs, i %d\n",i);
      if((s[i]=='B')&&(s[i+1]=='C')){
	if(nAsPrior>0LL){
	  retV +=  nAsPrior;
	  s[i-nAsPrior] = 'B';
	  s[i-nAsPrior+1] = 'C';
	  s[i+1] = 'A';
	  //printf("processLeadAs, nAsPrior %lld, i %d, i+1 %d, len %d\n",nAsPrior,i,i+1,len);	  
	  if(nAsPrior>1LL)s[i] = 'A';
	  //nAsPrior = 0;
	}
	i++;
	//	i++;
      }else if(s[i]=='A'){
	nAsPrior++;
      }else{
	nAsPrior = 0LL;
      }
      //cout<<"bottom of leadas for, s "<<s<<endl;
    }
    return retV;
  }

  //right to left
  long long processTrailBCs(string&s){
    printf("processTrailBCs entry, s %s\n",s.c_str());
    int len = s.length();
    int nBC = 0;
    long long retV = 0LL;
    for(int i=(len-1);i>1;i--){
      if((s[i]=='C')&&(s[i-1]=='B')){
	nBC++;
	if(s[i-2]=='A'){
	  retV += nBC;
	  subBC(s,i-2,nBC);
	  //	  i -= 2;
	  nBC = 0;
	}else{
	  //	  i--;
	}
      }else{
	nBC = 0;
      }
    }
    //cout<<"processTrailBC end, s "<<s<<endl;
    return retV;
  }

  void subBC(string&s, int sInd, int nBC){
    int ind = sInd;
    for(int i=0;i<nBC;i++){
      ind = sInd+2*i;
      s[ind] = 'B';
      s[ind+1] = 'C';
      //printf("subBC, ind %d, ind+1 %d\n",ind,ind+1);
    }
    ind += 2;
    //printf("subBC, ind %d\n",ind);    
    s[ind] = 'A';
  }
  /*
  int pass(string&s){
    int nFound = 0;
    for(int i=0;i<s.length();i++){
      if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')){
	nFound++;
	s[i] ='B';
	s[i+1] = 'C';
	s[i+2] = 'A';
      }
    }
    return nFound;
  }
  */

  
  long long processABCConsec(string &s){
    //printf("processABCConsec entry, s %s\n",s.c_str());
    int len = s.length();
    int nFound = 0;
    long long retOps = 0LL;
    int startInd = 0;
    int endInd = 0;
    for(int i=0;i<len-2;i++){
      if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')){
	nFound++;
	i+=2;
      }else{
	endInd = i-1;
	retOps += nFound*(nFound+1)/2;
	nFound = 0;
	updateSABC(startInd,endInd,s);
	startInd = i+1;
      }
    }
    endInd = len-1;
    retOps += (long long)nFound*(nFound+1LL)/2LL;
    updateSABC(startInd,endInd,s);
    return retOps;
  }

  void updateSABC(int startInd, int endInd, string &s){
    int len = 0;
    if(endInd>startInd){
      len = endInd-startInd+1;
    }
    int nReps = len/3;
    int ind = startInd;
    //printf("updateSABC, nReps %d\n",nReps);
    for(int i=0;i<nReps;i++){
      ind = startInd +2*i;
      //      printf("updateSABC, ind %d, ind+1 %d, s %s\n",ind,ind+1,s.c_str());
      s[ind] = 'B';
      s[ind+1] = 'C';
    }
    ind +=2;
    int origInd = ind;
    //printf("updateSABC, before second for, ind %d\n",ind);
    for(int i=0;i<nReps;i++){
      ind = origInd+i*1;
      s[ind] = 'A';
      //      printf("updateSABC A append, ind %d, s %s\n",ind,s.c_str());      
    }
  }
};

int main(int argc, const char*argv[]){
  CountABC ca;
  string s;
  getline(cin,s);
  vector<string>strVec = strToStrVec(s)
  long long nOps = ca.ctOps(strVec[0]);
  cout<<nOps<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'std::vector<std::__cxx11::basic_string<char> > strToStrVec(std::string)':
a.cc:194:38: error: a function-definition is not allowed here before '{' token
  194 | int main(int argc, const char*argv[]){
      |                                      ^
a.cc:202:2: error: expected '}' at end of input
  202 | }
      |  ^
a.cc:28:36: note: to match this '{'
   28 | vector<string>strToStrVec(string s){
      |                                    ^