Language: C++

#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
inline T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
inline T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n, q; string s;
	cin >> n >> q >> s;
	vector<int> index;
	
	int margin = 0;
	while (true)
	{
		if (margin >= n - 1) { break; }

		if (s[margin] == 'A')
		{
			if (s[margin + 1] == 'C')
			{
				index.emplace_back(margin);
			}
		}
		margin++;
	}

	for (int i = 0; i < q; i++)
	{
		int first, last; cin >> first >> last;
		int num = 0;

		for (auto it : index)
		{
			if (first - 1 <= it && it + 1 <= last-1)
			{
				num++;
			}
		}

		cout << num << endl;
	}

	return 0;
}#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

//最大公約数
template<class T>
inline T GCD(T m, T n)
{
	T temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
template<class T>
inline T LCM(T m, T n)
{
	return m * n / GCD(m, n);
}



int main()
{
	int n, q; string s;
	cin >> n >> q >> s;
	vector<int> index;
	
	int margin = 0;
	while (true)
	{
		if (margin >= n - 1) { break; }

		if (s[margin] == 'A')
		{
			if (s[margin + 1] == 'C')
			{
				index.emplace_back(margin);
			}
		}
		margin++;
	}

	for (int i = 0; i < q; i++)
	{
		int first, last; cin >> first >> last;
		int num = 0;

		for (auto it : index)
		{
			if (first - 1 <= it && it + 1 <= last-1)
			{
				num++;
			}
		}

		cout << num << endl;
	}

	return 0;
}

Compiler output:
a.cc:89:2: error: stray '#' in program
   89 | }#include <iostream>
      |  ^
a.cc:89:3: error: 'include' does not name a type
   89 | }#include <iostream>
      |   ^~~~~~~
a.cc:118:10: error: redefinition of 'template<class T> T GCD(T, T)'
  118 | inline T GCD(T m, T n)
      |          ^~~
a.cc:30:10: note: 'template<class T> T GCD(T, T)' previously declared here
   30 | inline T GCD(T m, T n)
      |          ^~~
a.cc:132:10: error: redefinition of 'template<class T> T LCM(T, T)'
  132 | inline T LCM(T m, T n)
      |          ^~~
a.cc:44:10: note: 'template<class T> T LCM(T, T)' previously declared here
   44 | inline T LCM(T m, T n)
      |          ^~~
a.cc:139:5: error: redefinition of 'int main()'
  139 | int main()
      |     ^~~~
a.cc:51:5: note: 'int main()' previously defined here
   51 | int main()
      |     ^~~~