Language: C++

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;


template <typename T>
T bfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs 

function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    queue<T> q;
    q.emplace(source);
    vis.at(source) = true;
    while(!q.empty())
    {
        T top = q.front();
        q.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            q.emplace(tem);
            element_num++;
        }
    }
    return element_num;
}

template <typename T>
T dfs(vector<vector<T> > a, vector<bool> vis, T source)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs 

function can only be in type \"int\" or \"long long int\"!\n");
    T element_num = 1;
    stack<T> s;
    s.push(source);
    vis.at(source) = true;
    while(!s.empty())
    {
        T top = s.top();
        s.pop();
        for(T i = 0; i < (T)a.at(top).size(); i++)
        {
            T tem = a.at(top).at(i);
            if(vis.at(tem)) continue;
            vis.at(tem) = true;
            s.emplace(top);
            s.emplace(tem);
            element_num++;
            break;
        }
    }
    return element_num;
}

template <typename T>
vector<vector<T> > input_graph(T array_num, T edge_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this 

input_graph function can only be in type \"int\" or \"long long int\"!\n");
    vector<vector<T> > a(array_num, vector<T>());
    for(T i = 0; i < edge_num; i++)
    {
        T d1, d2;
        cin >> d1 >> d2;
        a.at(d1-1).emplace_back(d2-1);
        a.at(d2-1).emplace_back(d1-1);
    }

    return a;
}

template <typename T>
vector<T> input_vector(T array_num)
{
    static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this 

input_vector function can only be in type \"int\" or \"long long int\"!\n");
    vector<T> a(array_num, 0);
    for(T i = 0; i < array_num; i++)
    {
        cin >> a.at(i);
    }

    return a;
}

ll inf = 1e9+7;


int main() {
    int n, k, d;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> a;
    bool is_a = false;
    for(int i = 0; i < s.size(); i++)
    {
        if(is_a)
        {
            if(s[i] == 'C')
            {
                a.at(i-1)++;
            }
            is_a = false;
        }
        if(s[i] == 'A')
        {
            is_a = true;
        }
    }
    for(int i = 1; i < n; i++)
    {
        a.at(i) += a.at(i-1);
    }
    for(int i = 0; i < k; i++)
    {
        int d1, d2;
        cin >> d1 >> d2;
        if(d1 < 2)
        {
            cout << a.at(d2-2) << endl;
        }
        else
        {
            cout << (a.at(d2-2) - a.at(d1-2)) << endl;
        }
    }

    return 0;
}


Compiler output:
a.cc:10:68: warning: missing terminating " character
   10 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs
      |                                                                    ^
a.cc:10:68: error: missing terminating " character
   10 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs
      |                                                                    ^~~~~~~~~ 
a.cc:12:30: error: stray '\' in program
   12 | function can only be in type \"int\" or \"long long int\"!\n");
      |                              ^
a.cc:36:68: warning: missing terminating " character
   36 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs
      |                                                                    ^
a.cc:36:68: error: missing terminating " character
   36 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs
      |                                                                    ^~~~~~~~~ 
a.cc:38:30: error: stray '\' in program
   38 | function can only be in type \"int\" or \"long long int\"!\n");
      |                              ^
a.cc:64:68: warning: missing terminating " character
   64 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                                                    ^
a.cc:64:68: error: missing terminating " character
   64 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                                                    ^~~~~ 
a.cc:66:42: error: stray '\' in program
   66 | input_graph function can only be in type \"int\" or \"long long int\"!\n");
      |                                          ^
a.cc:82:68: warning: missing terminating " character
   82 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                                                    ^
a.cc:82:68: error: missing terminating " character
   82 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                                                    ^~~~~ 
a.cc:84:43: error: stray '\' in program
   84 | input_vector function can only be in type \"int\" or \"long long int\"!\n");
      |                                           ^
a.cc: In function 'T bfs(std::vector<std::vector<_Tp> >, std::vector<bool>, T)':
a.cc:12:1: warning: 'static_assert' with non-string message only available with '-std=c++2c' or '-std=gnu++2c' [-Wc++26-extensions]
   12 | function can only be in type \"int\" or \"long long int\"!\n");
      | ^~~~~~~~
a.cc:12:10: error: missing template arguments before 'can'
   12 | function can only be in type \"int\" or \"long long int\"!\n");
      |          ^~~
a.cc:12:9: error: expected ')' before 'can'
   12 | function can only be in type \"int\" or \"long long int\"!\n");
      |         ^~~~
      |         )
a.cc:10:18: note: to match this '('
   10 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this bfs
      |                  ^
a.cc: In function 'T dfs(std::vector<std::vector<_Tp> >, std::vector<bool>, T)':
a.cc:38:1: warning: 'static_assert' with non-string message only available with '-std=c++2c' or '-std=gnu++2c' [-Wc++26-extensions]
   38 | function can only be in type \"int\" or \"long long int\"!\n");
      | ^~~~~~~~
a.cc:38:10: error: missing template arguments before 'can'
   38 | function can only be in type \"int\" or \"long long int\"!\n");
      |          ^~~
a.cc:38:9: error: expected ')' before 'can'
   38 | function can only be in type \"int\" or \"long long int\"!\n");
      |         ^~~~
      |         )
a.cc:36:18: note: to match this '('
   36 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this dfs
      |                  ^
a.cc: In function 'std::vector<std::vector<_Tp> > input_graph(T, T)':
a.cc:66:1: warning: 'static_assert' with non-string message only available with '-std=c++2c' or '-std=gnu++2c' [-Wc++26-extensions]
   66 | input_graph function can only be in type \"int\" or \"long long int\"!\n");
      | ^~~~~~~~~~~
a.cc:66:12: error: expected ')' before 'function'
   66 | input_graph function can only be in type \"int\" or \"long long int\"!\n");
      |            ^~~~~~~~~
      |            )
a.cc:64:18: note: to match this '('
   64 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                  ^
a.cc:66:75: error: overloaded function with no contextual type information
   66 | input_graph function can only be in type \"int\" or \"long long int\"!\n");
      |                                                                           ^
a.cc:64:42: error: 'static_assert' message must be a string literal or object with 'size' and 'data' members
   64 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'std::vector<_Tp> input_vector(T)':
a.cc:84:1: warning: 'static_assert' with non-string message only available with '-std=c++2c' or '-std=gnu++2c' [-Wc++26-extensions]
   84 | input_vector function can only be in type \"int\" or \"long long int\"!\n");
      | ^~~~~~~~~~~~
a.cc:84:13: error: expected ')' before 'function'
   84 | input_vector function can only be in type \"int\" or \"long long int\"!\n");
      |             ^~~~~~~~~
      |             )
a.cc:82:18: note: to match this '('
   82 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                  ^
a.cc:84:76: error: overloaded function with no contextual type information
   84 | input_vector function can only be in type \"int\" or \"long long int\"!\n");
      |                                                                            ^
a.cc:82:42: error: 'static_assert' message must be a string literal or object with 'size' and 'data' members
   82 |     static_assert(is_same<T, int>::value || is_same<T, ll>::value, "this
      |                                    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~