criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
    ll ans = 0;
    string s;
    cin >> s;
    vector <char> v;
    
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'B' && s[i+1] == 'C' && i + 1 < (int)s.size()){
            v.push_back('D');
            i++;
            continue;
        }
        v.push_back(s[i]);
        
    }
    
    int size = (int)v.size();
    for(int i = 0; i < size; i++){
        if(v[i]=='B' || v[i] == 'C'){
            int last = i-1;
            int j = i-1;
            while(v[j]!='C' && v[j] != 'B' && j >= 0){
                if(v[j]=='A'){
                    ans += last-j;
                    last--;
                }
                j--;
            }
        }
        
        if(i==size-1 && (v[i]!='B' && v[i] != 'C')){
            int last = i;
            int j = i;
            while(v[j]!='C' && v[j] != 'B' && j >= 0){
                if(v[j]=='A'){
                    ans += last-j;
                    //cout << last << " " << j << '\n';
                    last--;
                }
                j--;
            }
        }
    }
    // int cnt = 0;
    // for(int i = (int)v.size(); i >= 0; i--){
    //     if(v[i]=='A'){
    //         ans+=cnt;
    //     }
    //     else if(v[i]=='D'){
    //         cnt++;
    //     }
    //     else{
    //         cnt=0;
    //     }
    // }
    cout << ans << '\n';
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'll' was not declared in this scope
    5 |     ll ans = 0;
      |     ^~
a.cc:27:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |                     ans += last-j;
      |                     ^~~
      |                     abs
a.cc:39:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   39 |                     ans += last-j;
      |                     ^~~
      |                     abs
a.cc:59:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |     cout << ans << '\n';
      |             ^~~
      |             abs
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
#define int long long 

int main(){
    string S;
    cin>>S;
    int a = 0;
    int b = 0;
    int c = 0;
    int m = 0;

    if(S[0]=='A'){
        a = 1;
    }
    

    REP(i, 1, S.size()){
        auto x = S[i-1];
        auto y = S[i];

        

        if(x == 'A'){
            if(y == 'A'){
                ++a;
            }else if (y =='B'){
            }else if (y == 'C'){
                a = 0;
            }
        }else if (x =='B'){
            if(y == 'A'){
                a = 1;
            }else if (y =='B'){
                a = 0;
            }else if (y == 'C'){
                m += a;
            }
        }else if (x == 'C'){
            if(y == 'A'){
                ++a;
            }else if (y =='B'){
                if(i>=2){
                    if(S[i-2]!='B'){
                        a = 0;
                    }
                }
            }else if (y == 'C'){
                a = 0;
            }
        }

        // MSG(x);
        // MSG(y);
        // MSG(a);
        // MSG(m);
    }

    cout << m << endl;
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>

using namespace std;

int main(){
    char s[200001]
    int Aswi=0,ans=0;

  	scanf("%s",s);
	  
    for(int i=0;i<=strlen(s)-1;i++){
        if(s[i]=='B' && s[i+1]=='C'){
            s[i]='D';
            s[i+1]='E';
        }
    }
    for(int i=0;i<=strlen(s)-1;i++){
        if(s[i]=='A') Aswi++;
        else if(s[i]=='D') ans+=Aswi;
        else if(s[i]=='B' || s[i]=='C') Aswi=0;
    }
    printf("%d",ans);

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: expected initializer before 'int'
    7 |     int Aswi=0,ans=0;
      |     ^~~
a.cc:9:20: error: 's' was not declared in this scope
    9 |         scanf("%s",s);
      |                    ^
a.cc:18:23: error: 'Aswi' was not declared in this scope
   18 |         if(s[i]=='A') Aswi++;
      |                       ^~~~
a.cc:19:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   19 |         else if(s[i]=='D') ans+=Aswi;
      |                            ^~~
      |                            abs
a.cc:19:33: error: 'Aswi' was not declared in this scope
   19 |         else if(s[i]=='D') ans+=Aswi;
      |                                 ^~~~
a.cc:20:41: error: 'Aswi' was not declared in this scope
   20 |         else if(s[i]=='B' || s[i]=='C') Aswi=0;
      |                                         ^~~~
a.cc:22:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |     printf("%d",ans);
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;

	if(s.size()<=2){
		cout << ans << endl;
		return 0;
	}

	ll ans=0;
	ll acnt = 0;
	
	rep(i,0,s.size()-1){
		if(s[i]=='B' && s[i+1]=='C'){
			ans += acnt;
			i++;
		}
		else if(s[i]=='A'){
			acnt++;
		}
		else{
			acnt=0;
		}
	}
	
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   21 |                 cout << ans << endl;
      |                         ^~~
      |                         abs
Language: C++

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
char s[maxn];
int vis[maxn];
int n,a,b,c,d;
int main()
{


    scanf("%s",s+1);
    int len=strlen(s+1);
    int pos=1;
    ll ans=0;
    if(len<3)
     puts("0");
   else{
    for(int i=1;i<=len-2;i++)
    {
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
        {
             ans++;
            swap(s[i],s[i+1]);
            swap(s[i+1],s[i+2]);
             pos=i-1;
             while(pos>=1&&s[pos]=='A')
             {
                  ans++;
                 swap(s[pos],s[pos+1]);
                 swap(s[pos+1],s[pos+2]);
                    pos--;
             }
             i++;
        }

       // cout<<s+1<<endl;
    }printf("%lld\n",ans);
   }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:5: error: 'll' was not declared in this scope
   14 |     ll ans=0;
      |     ^~
a.cc:22:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |              ans++;
      |              ^~~
      |              abs
a.cc:37:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   37 |     }printf("%lld\n",ans);
      |                      ^~~
      |                      abs
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
using namespace std;

string s;
vector<char> a;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n-1 ; i++)
    {
        // cout<<s<<endl;
        if(s[i]=='B'&&s[i+1]=='C')
        {
            a.push_back('X');
            i++;
        }
        else a.push_back(s[i]);
    }
    int t=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A') t++;
        else if(a[i]=='X') ans+=t;
        else t=0;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:9:1: error: 'vector' does not name a type
    9 | vector<char> a;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:21:13: error: 'a' was not declared in this scope
   21 |             a.push_back('X');
      |             ^
a.cc:24:14: error: 'a' was not declared in this scope
   24 |         else a.push_back(s[i]);
      |              ^
a.cc:29:12: error: 'a' was not declared in this scope
   29 |         if(a[i]=='A') t++;
      |            ^
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <string.h>
#pragma GCC optimize(2)
using namespace std;

string s;
vector<char> a;
int main()
{
    ios::sync_with_stdio(false);
    cin>>s;
    int n = s.size();
    int ans = 0;
    for (int i = 0; i < n-1 ; i++)
    {
        // cout<<s<<endl;
        if(s[i]=='B'&&s[i+1]=='C')
        {
            a.push_back('X');
            i++;
        }
        else a.push_back(s[i]);
    }
    int t=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='A') t++;
        else if(a[i]=='X') ans+=t;
        else t=0;
    }
    cout<<ans<<endl;
    return 0;
}

Compiler output:
a.cc:10:1: error: 'vector' does not name a type
   10 | vector<char> a;
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:22:13: error: 'a' was not declared in this scope
   22 |             a.push_back('X');
      |             ^
a.cc:25:14: error: 'a' was not declared in this scope
   25 |         else a.push_back(s[i]);
      |              ^
a.cc:30:12: error: 'a' was not declared in this scope
   30 |         if(a[i]=='A') t++;
      |            ^
Language: Java

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        char[] s = new char[n];
        for (int i = 0; i < n; i++) {
            s[i] = str.charAt(i);
        }
        
        int curACount = 0;
        int AjumpedCount = 0;
        
        for (int i = 0; i < n; i++) {
            boolean meetsA = s[i] == 'A'
            boolean canJump = i + 1 < n && s[i] == 'B' && s[i + 1] == 'C';
            
            if (meetsA) {
                curACount++;
            } else if (canJump) {
                AjumpedCount += curACount;
                i++;
            } else {
                curACount = 0;
            }
        }
        
        System.out.println(AjumpedCount);
    }
}


Compiler output:
Main.java:18: error: ';' expected
            boolean meetsA = s[i] == 'A'
                                        ^
1 error
Language: Java

import java.util.Scanner;

public class B {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String s2 = s.replace("BC", "D");
		char[] c = s2.toCharArray();
		int i;
		int count=0;
		int t;
		for(i=0;i<c.length-1;i++) {

			if(c[i]=='A') {
			for(t=i+1;t<c.length;t++)

				if(c[t]=='D')
						count++;
			}
		}

			/*
			if(c[i]=='A'&&c[i+1]=='D') {
				//swap
				c[i]=c[i+1];
				c[i+1]='A';
				count++;
				//i=0
				if(i==0){
				}
				else if(c[i-1]=='A') {
					i=i-2;
				}
			}
			*/
		System.out.println(count);
	}

}


Compiler output:
Main.java:3: error: class B is public, should be declared in a file named B.java
public class B {
       ^
1 error
Language: C

#include <stdio.h>
#include <string.h>

int main(void){
	int i,n=0,ans=0;
	
	char s[200001];
	
	scanf("%s",s);
	
	for(i=0;i<string(s);i++){
		if(s[i]=='A'){
			n++;
		}else if(s[i]=='B'&&s[i+1]=='C'){
			ans+=n;
			i++;
		}else{
			n=0;
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:11:19: error: implicit declaration of function 'string'; did you mean 'stdin'? [-Wimplicit-function-declaration]
   11 |         for(i=0;i<string(s);i++){
      |                   ^~~~~~
      |                   stdin
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;



int main() {
    string ss;
    int n;
    cin >> s;
    n = (int)s.length();
    int cnt = 0;
    int ans = 0;
    for(int i=0; i<n; i++){
        if(s[i]=='A') cnt++;
        else if(s[i]=='B'&&s[i+1]=='C'){
            ans+=cnt;
            i++;
        }else{
            cnt=0;
        }
    }
    cout << ans;

    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:12: error: 's' was not declared in this scope
   11 |     cin >> s;
      |            ^
Language: C++

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

#define int long long

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    int cnt = 0;
    int n_of_A = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A') n_of_A++;
        else if (i < s.size() - 1 && s.at(i) == 'B' && s.at(i + 1) == 'C') {
            cnt += n_of_A;
            i++;
        } else n_of_A = 0;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
a.cc:13:5: warning: first argument of 'int main(long long int, const char**)' should be 'int' [-Wmain]
   13 | int main(int argc, const char * argv[]) {
      |     ^~~~
Language: C++

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

#define int int64_t

int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;
    
    int cnt = 0;
    int n_of_A = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == 'A') n_of_A++;
        else if (i < s.size() - 1 && s.at(i) == 'B' && s.at(i + 1) == 'C') {
            cnt += n_of_A;
            i++;
        } else n_of_A = 0;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Compiler output:
a.cc:11:13: error: '::main' must return 'int'
   11 | #define int int64_t
      |             ^~~~~~~
a.cc:13:1: note: in expansion of macro 'int'
   13 | int main(int argc, const char * argv[]) {
      | ^~~
a.cc:13:5: warning: first argument of 'int main(int64_t, const char**)' should be 'int' [-Wmain]
   13 | int main(int argc, const char * argv[]) {
      |     ^~~~
Language: C++

// AtCoder-Template.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second
#define FOR(i,N) for(auto i=0; i<N; ++i)
#define FORREV(i,N,_cnt) for(auto i=N-1,cnt=_cnt; cnt > 0; --i, --cnt)
#define ALL(x) x.begin(), x.end()

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T& a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T& a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int subF(string& s)
{
	vector<int> BCIndex;
	vector<int> AIndex;
	FOR(i, s.size()-1) {
		auto c = s[i];
		if (c == 'A') {
			AIndex.push_back(i);
		}
		if (c == 'B' and s[i + 1] == 'C') {
			BCIndex.push_back(i);
		}
	}
	int ai = 0;
	int bi = 0;
	int nowA = 0;
	int ans = 0;
	int nokoriBC = BCIndex.size();
	while (ai <= AIndex.size() and bi < BCIndex.size()) {
		if (ai < AIndex.size() and AIndex[ai] < BCIndex[bi]) {
			nowA += 1;
			ai += 1;
		}
		else {
			ans += nowA * nokoriBC;
			nokoriBC -= 1;
			nowA = 0;
			bi += 1;
			if (nokoriBC == 0) break;
		}
	}
	return ans;


}

int main() {
#ifdef DEBUG
	ifstream ifs("in.txt");
	cin.rdbuf(ifs.rdbuf());
#endif
	vector<char> changedS;
	string s;
	cin >> s;
	FOR(i, s.size()) {
		auto c = s[i];
		if (i + 1 < s.size() and c == 'B' and s[i + 1] == 'C') {
			changedS.push_back('K');
			i += 1;
		}
		else {
			changedS.push_back(c);
		}
	}
	int ans = 0;
	int nowA = 0;
	int nokoriBC = 0;

	vector<int> BCruiseki(changedS.size(), 0);
	int prev = 0;
	FOR(i, changedS.size()) {
		auto j = changedS.size() - i - 1;
		if (changedS[j] == 'K') {
			prev += 1;
			BCruiseki[j] = prev;
		}
		else if (j - 1 >= 0 and ( changedS[j] == 'C' or changedS[j] == 'B') ) {   
			prev = 0;
			BCruiseki[j] = prev;
		}
		else {
			BCruiseki[j] = prev;
		}
	}
	
	const int M = changedS.size();
	FOR(i, M) {
		auto c = changedS[i];
		if (c == 'A') {
			nowA += 1;
		}
		else if (c == 'K') {
			ans += nowA * BCruiseki[i];
			//nowA = 0;
			nowA = 0;
		} else {
			nowA = 0;
		}
		if (BCruiseki[j] == 0) break;

	}

	cout << ans << endl;
	

	

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:128:31: error: 'j' was not declared in this scope
  128 |                 if (BCruiseki[j] == 0) break;
      |                               ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
long long main(void){
  string str;
  cin >> str;
  long long count = 0;
  long long length = str.length();
  for(long long i=0;i<length-2;i++){
    if(str[i+2] == 'C'){
      if(str[i+1] == 'B'){
        if(str[i] == 'A'){
          str[i] = 'B';
          str[i+1] = 'C';
          str[i+2] = 'A';
          count++;
          if(i == 0){
            //
          }else{
            i -= 2;
          }
        }else{
          i += 2;
        }
      }else{
        i += 2;
      }
    }else{
      //なし
    }
  }
  cout << count;
  return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

s=gets.chomp.reverse
s.gsub!('CB', 'D')
i = 0
n=0
r=0
while i = s.index('A', i)
  n=0
  ii = i
  while s[ii-1] == 'D'
    ii -= 1
    n+=1
    break if ii < 0
  end
  r+=n
  s.slice!(i)
end
p r

Compiler output:
a.cc:2:9: warning: multi-character character constant [-Wmultichar]
    2 | s.gsub!('CB', 'D')
      |         ^~~~
a.cc:1:1: error: 's' does not name a type
    1 | s=gets.chomp.reverse
      | ^
Language: C++

#include<iostream>
#include<vector>
#include <cmath>
#include<string>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repv(i,s,n) for(int i = (s); i < (int)(n); i++)

using namespace std;

int main(){
    string S;
    int count =0;
    int lastD =0;
    cin >> S;
    repv(i,1,S.size()){
        if((S[i]=='C')&&(S[i-1]=='B')){
            S.replace(i-1,2,"D");
            int tmp = i;
            while(((tmp-1)>lastD)&&(S[tmp-1]=='A')){
                count++;
                tmp--;
            }
            if(tmp != i){
                S[tmp]='D';
                S[i]='A';
                lastD = tmp;
            }
    }
    cout << count << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:2: error: expected '}' at end of input
   32 | }
      |  ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include<iostream>
#include<string>
using namespace std;
int cnt[200200];
int main(){
	string s; cin >>s;
	int n=s.size();
	ll ans=0;
	for(int i=0;i<200200;i++){
		cnt[i]=0;
	}
	for(int i=0;i<n-2;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans+=cnt[i]+1;
			cnt[i+2]+=cnt[i];
			s[i]='C'; s[i+2]='A';
		}
		else if(s[i]=='A'){
			cnt[i+1]=cnt[i]+1;
		}
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'll' was not declared in this scope
    8 |         ll ans=0;
      |         ^~
a.cc:14:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   14 |                         ans+=cnt[i]+1;
      |                         ^~~
      |                         abs
a.cc:22:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: Java

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }


    private int count;
    private byte[] s;

    private void run() {
        count = 0;
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next().replace("BC", "D");
        s = S.getBytes();
//        a 65 b 66 c 67 d 68
        if (s.length < 3) {
            System.out.println("0");
            return;
        }
        for (int i = 0; i < s.length - 2; i++) {
            if (s[i] == 65) {
                checkStr(i);
            }
        }
        System.out.println(count);

    }

    private int checkStr(int i) {
        if (i < 0 || i > s.length - 3) {
            return 0;
        }
        if (s[i] == 65 && s[i + 1] == 68) {
            count++;
            s[i] = 68;
            s[i + 1] = 65;
            checkStr(i - 1);
            return 0;
        }
        return 0;
    }
}

Compiler output:
Main.java:12: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:12: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#!/usr/bin/env python3
import sys

def conv2num(c):
    if c == "A":
        return 1
    else:
        return 2

def solve(s: str):

    res = 0

    s = s.replace("BC","D")
    s = [ conv2num(c) for c in s ]
    i = 0
    endi = len(s) - 1
    while i < endi:
        if s[i] == 1 and s[i+1] == 2:
            ai = i
            for j in range(i-1,-1,-1):
                if s[j] == 1 and j >=0 :
                    ai = j 
                else:
                    break
            s[ai]   = 2
            s[ai+1] = 1
            res += 1

            st = ai+2
            ed = i +2
            if st != ed:
                for k in range(st,ed):
                    s[k] = 1
                    res += 1
            i += 1
        i += 1

    print(res)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    solve(s)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python3
      |  ^
a.cc:44:3: error: invalid preprocessing directive #Generated
   44 | # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
      |   ^~~~~~~~~
a.cc:51:23: error: stray '#' in program
   51 |     s = next(tokens)  # type: str
      |                       ^
a.cc:54:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   54 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import sys
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

def snum(S):
    # bcの数
    origS = S[:]
    bccnt = 0
    i = 0
    bcIndex = []
    base = 0
    while "BC" in S[i:]:
        S = S[i:]
        bcIndex.append( S.find("BC")  + base)
        i = S.find("BC") + 2
        base += i
 
 
    aIndex = []
    i = 0
    base = 0
    S = origS[:]
    while "A" in S[i:]:    
        S = S[i:]
        aIndex.append(S.find("A") + base)
        i = S.find("A") + 1
        base += i
 
 
    ans = 0
    ai = 0
    bc = 0
    nokoriBC = len(bcIndex)
    nowA = 0
 
    subS = [0] * len(origS)
    for a in aIndex:
        subS[a] = 1
    for b in bcIndex:
        subS[b] = 2
 
    for i in range(len(origS)):
        if subS[i]  == 1:
            nowA += 1
        elif subS[i] == 2:
            ans += nowA * nokoriBC
            nowA = 0
            nokoriBC -= 1
            if (nokoriBC == 0): break
    return ans
    return (aIndex, bcIndex)
 
S = input()
pos = []
i = 0
while "CC"  in S[i:] or "BB" in S[i:] or "CB" in S[i:]:
    S = S[i:]
    # a = min( S.find("CC"), S.find("BB"))
    c = (S.find("CC"))
    b = S.find("BB")
    a = 0
    if ( c != -1 and b != -1) :
        a = min(b,c)
    elif b == -1:
        a = c
    else :
        a = b
 
    pos.append( S[i:a+1]  )
    i = a+2
pos.append(S[i:])
# print(kpos)
ans = 0
for p in pos:
    tmp = snum(p)
    ans += tmp
print(ans)
 

Compiler output:
a.cc:2:7: error: invalid preprocessing directive #bc\U0000306e\U00006570
    2 |     # bcの数
      |       ^~~~~~
a.cc:54:7: error: invalid preprocessing directive #a
   54 |     # a = min( S.find("CC"), S.find("BB"))
      |       ^
a.cc:68:3: error: invalid preprocessing directive #print
   68 | # print(kpos)
      |   ^~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def snum(S):
      | ^~~
Language: C++

#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <stdio.h>

using namespace std;
int main(){
    string str;
    cin >> str;
    int str_size= str.size();
    int count=0;
    int i=0;
    vector<int> vec1;
     //   cout << "while1 ";
        while(i < str_size){
        //    cout << "while2 ";
            if(str[i]=='A'){
                i++;
                if(str[i]=='B'){
                    i++;
                    if(str[i]=='C'){
                        count++;
                        str[i-2]='B';
                        str[i-1]='C';
                        str[i]='A';
                        vec1.push_back(i);
                    }else{continue;}
                }else{
                    vec1.push_back(i-1);
                    continue;
                }
            }
            i++;
        }    
        int vec1_size=vec1.size();
        
       while(1){　
            bool hantei=0;
            for(int i=0; i < vec1_size; i++){
                int j=vec1[i]+1;
                if(str[j]=='B'){
                    j++;
                    if(str[j]=='C'){
                        count++;
                   //     cout <<"yatta ";
                        hantei = 1;
                        str[j-2]='B';
                        str[j-1]='C';
                        str[j]='A';
                        vec1[i]=j;
                    }else{continue;}
                }else{
                    continue;
                }
                
            }
              
             if(hantei==0)break;  
        }    
        
        
    
    
    cout << count << endl;
    
}

Compiler output:
a.cc:39:17: error: extended character 　 is not valid in an identifier
   39 |        while(1){　
      |                 ^
a.cc: In function 'int main()':
a.cc:39:17: error: '\U00003000' was not declared in this scope
   39 |        while(1){　
      |                 ^~
a.cc:48:25: error: 'hantei' was not declared in this scope
   48 |                         hantei = 1;
      |                         ^~~~~~
a.cc:60:17: error: 'hantei' was not declared in this scope
   60 |              if(hantei==0)break;
      |                 ^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  si = S.size();
  vector<char>A();
  int Ai = 0;
  for (int i = 0; i < si - 1;) {
    if(S[i] == 'B' && S[i + 1] == 'C') {
      A.push_back('D');
      i ++;
    }
    else A.push_back(S[i]);
    Ai ++;
    i ++;
  }
  int Anum = 0;
  int ans = 0;
  for (int i = 0; i < Ai; i ++) {
    if (A[i] == 'A') Anum ++;
    if (A[i] == 'D') ans += Anum;
    if (A[i] != 'A' && A[i] != 'D') Anum = 0;
  }
  cout << ans << endl;
}
      
  

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'si' was not declared in this scope; did you mean 'sin'?
    6 |   si = S.size();
      |   ^~
      |   sin
a.cc:7:16: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
    7 |   vector<char>A();
      |                ^~
a.cc:11:9: error: request for member 'push_back' in 'A', which is of non-class type 'std::vector<char>()'
   11 |       A.push_back('D');
      |         ^~~~~~~~~
a.cc:14:12: error: request for member 'push_back' in 'A', which is of non-class type 'std::vector<char>()'
   14 |     else A.push_back(S[i]);
      |            ^~~~~~~~~
a.cc:21:12: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   21 |     if (A[i] == 'A') Anum ++;
      |            ^
a.cc:21:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   21 |     if (A[i] == 'A') Anum ++;
      |         ~~~~~^~~~~~
a.cc:22:12: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   22 |     if (A[i] == 'D') ans += Anum;
      |            ^
a.cc:22:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   22 |     if (A[i] == 'D') ans += Anum;
      |         ~~~~~^~~~~~
a.cc:23:12: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |     if (A[i] != 'A' && A[i] != 'D') Anum = 0;
      |            ^
a.cc:23:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |     if (A[i] != 'A' && A[i] != 'D') Anum = 0;
      |         ~~~~~^~~~~~
a.cc:23:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   23 |     if (A[i] != 'A' && A[i] != 'D') Anum = 0;
      |                           ^
a.cc:23:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   23 |     if (A[i] != 'A' && A[i] != 'D') Anum = 0;
      |                        ~~~~~^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <stdio.h>

using namespace std;
int main(){
    string str;
    cin >> str;
    int str_size= str.size();
    int count=0;
    int i=0;
    vector<int> vec1;
     //   cout << "while1 ";
        while(i < str_size){
        //    cout << "while2 ";
            if(str[i]=='A'){
                i++;
                if(str[i]=='B'){
                    i++;
                    if(str[i]=='C'){
                        count++;
                        str[i-2]='B';
                        str[i-1]='C';
                        str[i]='A';
                        vec1.push_back(i);
                    }else{continue;}
                }else{
                    vec1.push_back(i-1);
                    continue;
                }
            }
            i++;
        }    
        cout << "AAA "<< endl;
        int vec1_size=vec1.size();
        
       while(1){　
            bool hantei=0;
            for(int i=0; i < vec1_size; i++){
                int j=vec1[i]+1;
                if(str[j]=='B'){
                    j++;
                    if(str[j]=='C'){
                        count++;
                   //     cout <<"yatta ";
                        hantei = 1;
                        str[j-2]='B';
                        str[j-1]='C';
                        str[j]='A';
                        vec1[i]=j;
                    }else{continue;}
                }else{
                    continue;
                }
                
            }
              
             if(hantei==0)break;  
        }    
        
        
    
    
    cout << count << endl;
    
}

Compiler output:
a.cc:40:17: error: extended character 　 is not valid in an identifier
   40 |        while(1){　
      |                 ^
a.cc: In function 'int main()':
a.cc:40:17: error: '\U00003000' was not declared in this scope
   40 |        while(1){　
      |                 ^~
a.cc:49:25: error: 'hantei' was not declared in this scope
   49 |                         hantei = 1;
      |                         ^~~~~~
a.cc:61:17: error: 'hantei' was not declared in this scope
   61 |              if(hantei==0)break;
      |                 ^~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
using namespace std;
int main(){
    string str;
    cin >> str;
    int str_size= str.size();
    int count=0;
    int i=0;
    vector<int> vec1;
     //   cout << "while1 ";
        while(i < str_size){
        //    cout << "while2 ";
            if(str[i]=='A'){
                i++;
                if(str[i]=='B'){
                    i++;
                    if(str[i]=='C'){
                        count++;
                        str[i-2]='B';
                        str[i-1]='C';
                        str[i]='A';
                        vec1.push_back(i);
                    }else{continue;}
                }else{
                    vec1.push_back(i-1);
                    continue;
                }
            }
            i++;
        }    
        cout << "AAA "<< endl;
        int vec1_size=vec1.size();
        
       while(1){　
            bool hantei=0;
            for(int i=0; i < vec1_size; i++){
                int j=vec1[i]+1;
                if(str[j]=='B'){
                    j++;
                    if(str[j]=='C'){
                        count++;
                   //     cout <<"yatta ";
                        hantei = 1;
                        str[j-2]='B';
                        str[j-1]='C';
                        str[j]='A';
                        vec1[i]=j;
                    }else{continue;}
                }else{
                    continue;
                }
                
            }
              
             if(hantei==0)break;  
        }    
        
        
    
    
    cout << count << endl;
    
}

Compiler output:
a.cc:42:17: error: extended character 　 is not valid in an identifier
   42 |        while(1){　
      |                 ^
a.cc: In function 'int main()':
a.cc:42:17: error: '\U00003000' was not declared in this scope
   42 |        while(1){　
      |                 ^~
a.cc:51:25: error: 'hantei' was not declared in this scope
   51 |                         hantei = 1;
      |                         ^~~~~~
a.cc:63:17: error: 'hantei' was not declared in this scope
   63 |              if(hantei==0)break;
      |                 ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s; 
    vector<int> v;
    int n=s.length();
    int ans=0;
    bool maki=false;
    for(int i=0;i<n;i++){
        if(s[i]=='A'){
            v.pb(0);
        }
        else if(s[i]=='B'&& i<n-1&&s[i+1]=='C'){
            v.pb(1);
        }
        else{
            v.pb(-1);
        }
        /*if(s[i]=='A'){
            if(maki){
                maki=false;
                v.pb(-1);
            }
            v.pb(0);
        }
        else if(s[i]=='B'){
            if(maki)v.pb(-1);
            maki=true;
        }
        else{
            if(maki){
                v.pb(1);
                maki=false;
            }
            else{
                v.pb(-1);
            }
        }*/
    }
    int m=v.size();
    
    int index=1;
    for(int i=1;i<=m;i++){
        if(index<=i){
            index++;
            while(index<=m && (d[index]-d[index-1])!=-1){
                index++;
            }
        }
        if(d[i]-d[i-1]==0){
            //cout << (d[index-1]-d[i])<<endl;
            if((d[index-1]-d[i])>0)ans+=(d[index-1]-d[i]);
        }
    }
    cout << ans<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:56:32: error: 'd' was not declared in this scope
   56 |             while(index<=m && (d[index]-d[index-1])!=-1){
      |                                ^
a.cc:60:12: error: 'd' was not declared in this scope
   60 |         if(d[i]-d[i-1]==0){
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

//vector…可変長、データの大きさに合わせてサイズを変える
//list…双方向リスト、要素を挿入、削除の多いとき
//forward_list
//array…固定長配列
//set…集合
//multiset
//bitset…2進数、固定長ビット列
//map…連想配列、キーと値を関連付ける
//multimap
//deque
//stack…FILO
//queue…FIFO
//priority_queue…格納された最大値から順に取り出す
//pair…二つの値を一組
//tuple…複数の値を一組

template<typename T>
void remove(std::vector<T>& vector, char index) {
    vector.erase(vector.begin() + index);
}

template<class T>
T ma(std::vector<T> &v) {
    T maxi = 0;
    for(auto &i:v) maxi = max(maxi, i);
    return maxi;
}

template<class T>
T mi(std::vector<T> &v) {
    T mini = 0;
    for(auto &i:v) mini = min(mini, i);
    return mini;
}

template <class T>
T pow(T x, T y, T n = numeric_limits<T>::max()) {
    if(y == 0) return 1;
    if(y % 2 == 0) return pow((x * x) % n, y / 2);
    return (x * pow(x, y - 1)) % n;
}

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;
typedef unsigned long long ull;

ull ans = 0;
/*
int gcd(int x, int y) {
    if (x < y) swap(x, y);
    return !y ? x : gcd(x % y, y);
}
*/
int main() {
    string s;
    cin >> s;
    int flg = 0;

    int i = 0; 

    while (i < n-2) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            if (flg)
                ans += flg;
            ans++;
            s[i+2] = 'A';
            i++;
        } else if (s[i] == 'A')
            flg++;
        else
            flg = 0;
        i++
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:16: error: 'n' was not declared in this scope
   66 |     while (i < n-2) {
      |                ^
a.cc:77:12: error: expected ';' before '}' token
   77 |         i++
      |            ^
      |            ;
   78 |     }
      |     ~
Language: C++

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

a = 0
cnt = 0
for s in S:
    if s != 'A' and s != '*':
        a = 0
    elif s == 'A':
        a += 1
    elif s == '*':
        cnt += a

print(cnt)


Compiler output:
a.cc:1:21: warning: multi-character character constant [-Wmultichar]
    1 | S = input().replace('BC', '*')
      |                     ^~~~
a.cc:1:1: error: 'S' does not name a type
    1 | S = input().replace('BC', '*')
      | ^
Language: C++

#include <iostream>

using namespace std;

int main(){
  string s;
  int ans = 0,cnt = 0,flag = 0;
  cin >> s;
  int i = 0;
  if(s.size() < 3){cout << '0'; return 0;}
  while(i < s.size()-2){
    if(s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      int flagg = 0;
      if(cnt == 0) ans+=1;
      else {
        cnt++;
        ans += cnt;
        flagg = 1;
      }
      s[i] = 'B';
      s[i+1] = 'C';
      s[i+2] = 'A';
      if(flagg) {
        i += 2;
      }
      //if(i!= 0 && s[i-1] == 'A') i--;
    }
    else {
      if(s[i] == 'A'){
        cnt++;
      }
      else cnt = 0;
      i++;
    }
  }
  cout << ans;
  return 0;
}

AABC
ABCA
BCAA

AABC BC
BCAA BC
BC BC AA


Compiler output:
a.cc:40:1: error: 'AABC' does not name a type
   40 | AABC
      | ^~~~
Language: C++

#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	
	string s;
	cin >> s;
	
	int ans = 0;
	int abcbc = 0;
	int aabc = 0;
	int tmpcnta = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if(s.at(i) == 'A'){
			abcbc = 1;
			//手前がabcbcだった場合の処理が必要だが
			//実装が思いつかない
			tmpcnta++;
		} else if (s.at(i) =='B'){
			if(abcbc == 1) {
				//Aのつづき、カウント続行
				abcbc = 2;
			} else if( abcbc == 0){
				//何の続きでもない、棄却
				//ここまでで0,1の可能性はすでにない
			} else if(abcbc % 2 == 1) {
				//aまたはabcまで見つけたあとのB、カウント続行
				abcbc++;
			} else {
				//何の続きでもない、ゼロに戻す
				abcbc = 0;
			}
			if(tmpcnta > 0){
				//Aの後のB、カウント続行
				aabc++;
			} else {
				//Aの後じゃない、ゼロに戻す
				aabc = 0;
			}
		} else { //Cの場合
			if (abcbc < 2){
				//ABの続きじゃない、ゼロに戻す
				abcbc = 0;
			} else if (abcbc % 2 == 0){
				//abcのcを発見
				ans++;
				abcbc++;
			} else {
				//続きじゃない、ゼロに戻す
				abcbc = 0;
			}
			if(tmpcnta > 0){
				if(aabc == 1){
					//aabの続き、aabc成立
					//abcbcと重複カウントしているので-1
					ans += tmpcnta-1;
					tmpcnta = 0;
					aabc = 0;
				}
			aabc = 0;
		}
	}
	
	cout << ans << endl;
	
		
		
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:75:2: error: expected '}' at end of input
   75 | }
      |  ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C

#include <stdio.h>
#include <stdlib.h>
int main(){
    int abesi,count,l=0;
    char s[200000];
    scanf("%c",s);
    while(1){
        if('A'==s[l]){
            if('B'==s[l+1]){
                if('C'==s[l+2]){
                    s[l]='B';
                    s[l+1]='C';
                    s[l+2]='A';
                    l=l+3;
                }else{
                    l++;
                }
            }else{
                l++
            }
        }else{
            l++;
        }
        if(l==200000){
            break;
        }
    }
    return 0;
}

Compiler output:
main.c: In function 'main':
main.c:19:20: error: expected ';' before '}' token
   19 |                 l++
      |                    ^
      |                    ;
   20 |             }
      |             ~
Language: C++

#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	
	string s;
	cin >> s;
	
	int ans = 0;
	int abcbc = 0;
	int aabc = 0;
	int tmpcnta = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if(s.at(i) == 'A'){
			abcbc = 1;
			//手前がabcbcだった場合の処理が必要だが
			//実装が思いつかない
			tmpcnta++;
		} else if (s.at(i) =='B'){
			if(abcbc == 1) {
				//Aのつづき、カウント続行
				abcbc = 2;
			} else if( abcbc == 0){
				//何の続きでもない、棄却
				//ここまでで0,1の可能性はすでにない
			} else if(abcbc % 2 == 1) {
				//aまたはabcまで見つけたあとのB、カウント続行
				abcbc++;
			} else {
				//何の続きでもない、ゼロに戻す
				abcbc = 0;
			}
			if(tmpcnta > 0){
				//Aの後のB、カウント続行
				aabc++;
			} else {
				//Aの後じゃない、ゼロに戻す
				aabc = 0;
			}
		} else { //Cの場合
			if (abcbc < 2){
				//ABの続きじゃない、ゼロに戻す
				abcbc = 0;
			} else (abcbc % 2 == 0){
				//abcのcを発見
				ans++;
				abcbc++;
			} else {
				//続きじゃない、ゼロに戻す
				abcbc = 0;
			}
			if(tmpcnta > 0){
				if(aabc == 1){
					//aabの続き、aabc成立
					//abcbcと重複カウントしているので-1
					ans += tmpcnta-1;
					tmpcnta = 0;
					aabc = 0;
				}
			aabc = 0;
		}
	}
	
	cout << ans << endl;
	
		
		
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:48: error: expected ';' before '{' token
   50 |                         } else (abcbc % 2 == 0){
      |                                                ^
      |                                                ;
a.cc:54:27: error: 'else' without a previous 'if'
   54 |                         } else {
      |                           ^~~~
a.cc:75:2: error: expected '}' at end of input
   75 | }
      |  ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(){

  	string str;
  
  	int tmp,count=0;
  	cin >> str;
  
  	while((tmp=str.find("ABC"))!=-1){
    	str.replace(tmp,3,"BCA");
      	if(tmp1-1<0&&str[tmp-1]!='A'){
          str=str.substr(tmp);
        }
      
    	count++;
    }
	
  	cout<<count;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: 'tmp1' was not declared in this scope; did you mean 'tmp'?
   15 |         if(tmp1-1<0&&str[tmp-1]!='A'){
      |            ^~~~
      |            tmp
Language: C++

#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef unsigned long ul;
using namespace std;


int main() {
	string s;
	int i,j;
	int count=0;
    int achain=0;
    int flag=0

	cin >> s;
	for(i=0; i<s.length(); i++){
		if(s[i]=='A' && s[i+1] == 'B' && s[i+2] == 'C'){
			s[i] = 'B';
			s[i+1] = 'C';
			s[i+2] = 'A';
			count++;
			j = i;
			while(s[j-1] == 'A'){
				if(j==0) break;
                if(jflag == i-2){
                    count += achain;
                    break;
                }else{
                    achain=0;
                }
				count++;
                achain++;
				s[j-1] = 'B';
				s[j] = 'C';
				s[j+1] = 'A';
				j--;
			}
            jflag = i;
		}
	}
	cout << count << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:9: error: expected ',' or ';' before 'cin'
   22 |         cin >> s;
      |         ^~~
a.cc:32:20: error: 'jflag' was not declared in this scope; did you mean 'flag'?
   32 |                 if(jflag == i-2){
      |                    ^~~~~
      |                    flag
a.cc:45:13: error: 'jflag' was not declared in this scope; did you mean 'flag'?
   45 |             jflag = i;
      |             ^~~~~
      |             flag
Language: C++

/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string s; cin >> s;
  int ans = 0;
  for (int j = 0; j < 1000; ++i){
  for (int i = 0; i < (int) s.size() - 2; ++i) {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      s[i] = 'B'; s[i + 1] = 'C'; s[i + 2] = 'A'; ++ans;
    }
  }
  }


  print(ans);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:31: error: 'i' was not declared in this scope
   58 |   for (int j = 0; j < 1000; ++i){
      |                               ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
int m;
vector<int> a, bc, abc;
bool connected(int i) {
  if (abc[i] + 2 * bc[i] + 3 == abc[i + 1] - a[i + 1])
    return true;
  else
    return false;
}

signed main() {
  string s;
  cin >> s;
  int n = s.size();

  rep(i, n - 2) if (s.substr(i, 3) == "ABC") abc.push_back(i);
  for (auto&& u : abc) {
    int i = u, cnt = 0;
    while (i >= 0 && s[i] == 'A') {
      i--;
      cnt++;
    }
    a.push_back(cnt);
  }
  for (auto&& u : abc) {
    int i = u + 3, cnt = 0;
    while (i < n - 2 && s.substr(i, 2) == "BC") {
      i += 2;
      cnt++;
    }
    bc.push_back(cnt);

    m = abc.size();
    int ans = 0;
    int M = 0;
    for (int i = 0; i < m; i++) {
      M += a[i] + 1;
      ans += M * (bc[i] + 1);
      if (i < m - 1) {
        if (!connected(i)) M = 0;
      }
    }
    cout << ans << endl;
  }

Compiler output:
a.cc: In function 'int main()':
a.cc:49:4: error: expected '}' at end of input
   49 |   }
      |    ^
a.cc:16:15: note: to match this '{'
   16 | signed main() {
      |               ^