Language: C++

#include <iostream>
#include <string>
#include <algorithm>

int main(){
  int N, Q;
  std::cin>>N>>Q;
  std::vector<int> l(Q, 0);
  std::vector<int> r(Q, 0);
  std::string str;
  std::cin>>str;

  for(int i = 0 ; i < Q ; i++ ){
    std::cin>>l[i]>>r[i];
  }

  std::vector<int> rem;
  bool checkA = false;

  for(int i = 0 ; i < N ; i++ ){
    if(str[i]=='A' && checkA == false) checkA = true;
    if(checkA == true && str[i+1] == 'C'){
      rem.push_back(i+1);
      checkA = false;
    }else{
      checkA = false;
    }
  }
  for(int i = 0 ; i < Q ; i++ ){
    auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
    std::cout<<count<<std::endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:8: error: 'vector' is not a member of 'std'
    8 |   std::vector<int> l(Q, 0);
      |        ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    3 | #include <algorithm>
  +++ |+#include <vector>
    4 | 
a.cc:8:15: error: expected primary-expression before 'int'
    8 |   std::vector<int> l(Q, 0);
      |               ^~~
a.cc:9:8: error: 'vector' is not a member of 'std'
    9 |   std::vector<int> r(Q, 0);
      |        ^~~~~~
a.cc:9:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:9:15: error: expected primary-expression before 'int'
    9 |   std::vector<int> r(Q, 0);
      |               ^~~
a.cc:14:15: error: 'l' was not declared in this scope
   14 |     std::cin>>l[i]>>r[i];
      |               ^
a.cc:14:21: error: 'r' was not declared in this scope
   14 |     std::cin>>l[i]>>r[i];
      |                     ^
a.cc:17:8: error: 'vector' is not a member of 'std'
   17 |   std::vector<int> rem;
      |        ^~~~~~
a.cc:17:8: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:17:15: error: expected primary-expression before 'int'
   17 |   std::vector<int> rem;
      |               ^~~
a.cc:23:7: error: 'rem' was not declared in this scope
   23 |       rem.push_back(i+1);
      |       ^~~
a.cc:30:32: error: 'rem' was not declared in this scope
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                ^~~
a.cc:30:61: error: 'l' was not declared in this scope
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                             ^
a.cc:30:64: error: 'r' was not declared in this scope
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                ^
a.cc: In lambda function:
a.cc:30:84: error: 'l' is not captured
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                                    ^
a.cc:30:65: note: the lambda has no capture-default
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                 ^
a.cc:30:61: note: '<typeprefixerror>l' declared here
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                             ^
a.cc:30:97: error: 'r' is not captured
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                                                 ^
a.cc:30:65: note: the lambda has no capture-default
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                 ^
a.cc:30:64: note: '<typeprefixerror>r' declared here
   30 |     auto count = std::count_if(rem.begin(), rem.end(), [&i,&l,&r](int a){return a>=l[i] && a+1<=r[i];});
      |                                                                ^