Language: C++

#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait() {}
inline void dout(const char *arg, ...) {}
#endif

//template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;

int ValList[10010];

void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h<N; ++i) { if ((order_ascending&&ar[i]>ar[i + h]) || (!order_ascending&&ar[i]< ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h>1)h = int(h / 1.3); } }
int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = min(ar[n], ar[n + 1]); break; }if (ar[n]>ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } }return ar[N - 1]; }
template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
	int i, flag;
	int h = N / 1.3;
	while (true) {
		flag = 0;
		for (i = 0; i + h<N; ++i) {
			if (
				order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
				!order_ascending && ar[i].SortValue < ar[i + h].SortValue
				) {
				swap<T>(ar[i], ar[i + h]);
				flag = 1;
			}
		}
		if (h > 1) {
			h /= 1.3;
			if (h == 9 || h == 10) h = 11;
		}
		else {
			if (!flag) break;
		}
	}
}

signed main() {

	int i, j, k, l;
	char S[200020];

	gc(S);
	int len = strlen(S);
	fi(10) {
		S[len + i] = 'Z';
	}

	int map_A[200020], ptr = 0;
	fi(len) {
		if (S[i] == 'A') {
			map_A[ptr++] = i;
		}
	}

	int cnt = 0;
	fn(ptr) {
		if (n < 0) continue;
		i = map_A[n];
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			cnt++;
			S[i] = 'B'; S[i + 1] = 'C'; S[i + 2] = 'A';
			i -= 2;
			map_A[n] += 2;
			n -= 2;
		}
	}

	ans(cnt);

	wait();

	return 0;
}

#ifdef _WIN32
#define DEBUG	1
#endif

#define _CRT_SECURE_NO_WARNINGS
#define MATH_PI 3.14159265358979323846264338327950288419716939
#include <iostream>
#include <string.h>
#include <fstream>
#include <math.h>
using namespace std;

#ifdef DEBUG
#include "include.h"
#else
inline void wait() {}
inline void dout(const char *arg, ...) {}
#endif

//template<typename T>inline void swap(T a, T b){T t = a; a = b; b = t;}

#define CLIP(ptr, min, max) {if((min)<=(max)){if(ptr<(min)){ptr=(min);}if(ptr>(max)){ptr=(max);}}}
#define max(a, b) a > b ? a : b;
#define min(a, b) a > b ? b : a;
#define Sin(deg) sin((deg)*MATH_PI/180)
#define Cos(deg) cos((deg)*MATH_PI/180)
#define Tan(deg) tan((deg)*MATH_PI/180)
#define Rad(deg) ((deg)*MATH_PI/180)
#define ff(param, num) for(int param=0 ; param<num ; ++param)
#define fi(num) for(int i=0 ; i<num ; ++i)
#define fj(num) for(int j=0 ; j<num ; ++j)
#define fk(num) for(int k=0 ; k<num ; ++k)
#define fl(num) for(int l=0 ; l<num ; ++l)
#define fn(num) for(int n=0 ; n<num ; ++n)
#define ffr(param, num) for(int param=num-1 ; param>=0 ; --param)
#define fir(num) for(int i=num-1 ; i>=0 ; --i)
#define fjr(num) for(int j=num-1 ; j>=0 ; --j)
#define fkr(num) for(int k=num-1 ; k>=0 ; --k)
#define flr(num) for(int l=num-1 ; l>=0 ; --l)
#define fnr(num) for(int n=num-1 ; n>=0 ; --n)
#define gi(p) Scanf("%d", p)
#define gi2(p1, p2) Scanf2("%d %d", p1, p2)
#define gi3(p1, p2, p3) Scanf3("%d %d %d", p1, p2, p3)
#define gi4(p1, p2, p3, p4) Scanf4("%d %d %d %d", p1, p2, p3, p4)
#define gll(p) Scanf("%lld", p)
#define gll2(p1, p2) Scanf2("%lld %lld", p1, p2)
#define gll3(p1, p2, p3) Scanf3("%lld %lld %lld", p1, p2, p3)
#define gll4(p1, p2, p3, p4) Scanf4("%lld %lld %lld %lld", p1, p2, p3, p4)
#define gf(p) Scanf("%f", p)
#define gf2(p1, p2) Scanf2("%f %f", p1, p2)
#define gf3(p1, p2, p3) Scanf3("%f %f %f", p1, p2, p3)
#define gf4(p1, p2, p3, p4) Scanf4("%f %f %f %f", p1, p2, p3, p4)
#ifdef DEBUG
#define gc(buf) fscanf(local_in.fp, "%s", buf)
#define Scanf(expr, p) fscanf(local_in.fp, expr, &p)
#define Scanf2(expr, p1, p2) fscanf(local_in.fp, expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) fscanf(local_in.fp, expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) fscanf(local_in.fp, expr, &p1, &p2, &p3, &p4)
#else
#define gc(buf) Scanf("%s", buf)
#define Scanf(expr, p) scanf(expr, &p)
#define Scanf2(expr, p1, p2) scanf(expr, &p1, &p2)
#define Scanf3(expr, p1, p2, p3) scanf(expr, &p1, &p2, &p3)
#define Scanf4(expr, p1, p2, p3, p4) scanf(expr, &p1, &p2, &p3, &p4)
#endif
#define ans(p) cout << p << endl;

int ValList[10010];

void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h<N; ++i) { if ((order_ascending&&ar[i]>ar[i + h]) || (!order_ascending&&ar[i]< ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h>1)h = int(h / 1.3); } }
int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = min(ar[n], ar[n + 1]); break; }if (ar[n]>ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } }return ar[N - 1]; }
template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
	int i, flag;
	int h = N / 1.3;
	while (true) {
		flag = 0;
		for (i = 0; i + h<N; ++i) {
			if (
				order_ascending && ar[i].SortValue > ar[i + h].SortValue ||
				!order_ascending && ar[i].SortValue < ar[i + h].SortValue
				) {
				swap<T>(ar[i], ar[i + h]);
				flag = 1;
			}
		}
		if (h > 1) {
			h /= 1.3;
			if (h == 9 || h == 10) h = 11;
		}
		else {
			if (!flag) break;
		}
	}
}

signed main() {

	int i, j, k, l;
	char S[200020];

	gc(S);
	int len = strlen(S);
	fi(10) {
		S[len + i] = 'Z';
	}

	int map_A[200020], ptr = 0;
	fi(len) {
		if (S[i] == 'A') {
			map_A[ptr++] = i;
		}
	}

	int cnt = 0;
	fn(ptr) {
		if (n < 0) continue;
		i = map_A[n];
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') {
			cnt++;
			S[i] = 'B'; S[i + 1] = 'C'; S[i + 2] = 'A';
			i -= 2;
			map_A[n] += 2;
			n -= 2;
		}
	}

	ans(cnt);

	wait();

	return 0;
}

Compiler output:
a.cc:149:13: error: redefinition of 'void wait()'
  149 | inline void wait() {}
      |             ^~~~
a.cc:16:13: note: 'void wait()' previously defined here
   16 | inline void wait() {}
      |             ^~~~
a.cc:150:13: error: redefinition of 'void dout(const char*, ...)'
  150 | inline void dout(const char *arg, ...) {}
      |             ^~~~
a.cc:17:13: note: 'void dout(const char*, ...)' previously defined here
   17 | inline void dout(const char *arg, ...) {}
      |             ^~~~
a.cc:201:5: error: redefinition of 'int ValList [10010]'
  201 | int ValList[10010];
      |     ^~~~~~~
a.cc:68:5: note: 'int ValList [10010]' previously declared here
   68 | int ValList[10010];
      |     ^~~~~~~
a.cc:203:6: error: redefinition of 'void CombSort(int, int*, int)'
  203 | void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h<N; ++i) { if ((order_ascending&&ar[i]>ar[i + h]) || (!order_ascending&&ar[i]< ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h>1)h = int(h / 1.3); } }
      |      ^~~~~~~~
a.cc:70:6: note: 'void CombSort(int, int*, int)' previously defined here
   70 | void CombSort(int N, int *ar, int order_ascending = 1) { int h = int(N / 1.3); int flag; int i; while (true) { flag = 0; for (i = 0; i + h<N; ++i) { if ((order_ascending&&ar[i]>ar[i + h]) || (!order_ascending&&ar[i]< ar[i + h])) { swap<int>(ar[i], ar[i + h]); flag = 1; } }if (h == 1 && !flag)break; if (h == 9 || h == 10) h = 11; if (h>1)h = int(h / 1.3); } }
      |      ^~~~~~~~
a.cc:204:5: error: redefinition of 'int EuclideanAlgorithm(int, int*)'
  204 | int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = min(ar[n], ar[n + 1]); break; }if (ar[n]>ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } }return ar[N - 1]; }
      |     ^~~~~~~~~~~~~~~~~~
a.cc:71:5: note: 'int EuclideanAlgorithm(int, int*)' previously defined here
   71 | int EuclideanAlgorithm(int N, int *ar) { fn(N - 1) { while (true) { if (ar[n] % ar[n + 1] == 0 || ar[n + 1] % ar[n] == 0) { ar[n + 1] = min(ar[n], ar[n + 1]); break; }if (ar[n]>ar[n + 1]) { ar[n] %= ar[n + 1]; } else { ar[n + 1] %= ar[n]; } } }return ar[N - 1]; }
      |     ^~~~~~~~~~~~~~~~~~
a.cc:205:26: error: redefinition of 'template<class T> void CombSort(int, T*, int)'
  205 | template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
      |                          ^~~~~~~~
a.cc:72:26: note: 'template<class T> void CombSort(int, T*, int)' previously declared here
   72 | template<typename T>void CombSort(int N, T *ar, int order_ascending = 1) {
      |                          ^~~~~~~~
a.cc:229:8: error: redefinition of 'int main()'
  229 | signed main() {
      |        ^~~~
a.cc:96:8: note: 'int main()' previously defined here
   96 | signed main() {
      |        ^~~~