Language: C++

//author: hitch_hiker42;
#include<bits/stdc++.h>
using namespace std;
 
//solution:
#define int int64_t
#define block(i) i / B
constexpr int N = 100'000, B = 316, p = 31, mod = 1000'000'009;
string a[N]; int ans[N];
 
struct query {
    int s, lo, hi, idx;
    query() {}
    query(int lo, int hi, int idx): lo(lo), hi(hi), idx(idx) {}
    bool operator < (const query& q) {
        return block(lo) < block(q.lo) || (block(lo) == block(q.lo) and hi < q.hi);
    }
} q[N];
 
signed main() {
    int n, m; cin >> n >> m;
    for(int i = 0; i < n; ++i) cin >> a[i];
    for(int i = 0; i < m; ++i) {
        cin >> q[i].lo >> q[i].hi >> q[i].s;
        q[i].lo--; q[i].hi--; q[i].idx = i;
    }
    sort(q, q + m);
    unordered_map<int, int> f;
    auto insert = [&](int i, int s) {
        f[a[i]]++;
    };
    auto remove = [&](int i, int s) {
        f[a[i]]--;
    };
    int l = 0, r = -1;
    for(int i = 0; i < m; ++i) {
        int lo = q[i].lo, hi = q[i].hi;
        int s = q[i].s;
        while(lo < l) insert(--l);
        while(r < hi) insert(++r);
        while(lo > l) remove(l++);
        while(r > hi) remove(r--);
        ans[q[i].idx] = f[s];
    }
    for(int i = 0; i < m; ++i) cout << ans[i] << "\n";
    return 0;
} //farewell, until we meet again..

Compiler output:
a.cc: In lambda function:
a.cc:30:10: error: no match for 'operator[]' (operand types are 'std::unordered_map<long int, long int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   30 |         f[a[i]]++;
      |          ^
In file included from /usr/include/c++/14/unordered_map:41,
                 from /usr/include/c++/14/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:2:
/usr/include/c++/14/bits/unordered_map.h:987:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long int; _Tp = long int; _Hash = std::hash<long int>; _Pred = std::equal_to<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  987 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:987:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::unordered_map<long int, long int>::key_type&' {aka 'const long int&'}
  987 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:991:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = long int; _Tp = long int; _Hash = std::hash<long int>; _Pred = std::equal_to<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  991 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:991:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::unordered_map<long int, long int>::key_type&&' {aka 'long int&&'}
  991 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc: In lambda function:
a.cc:33:10: error: no match for 'operator[]' (operand types are 'std::unordered_map<long int, long int>' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   33 |         f[a[i]]--;
      |          ^
/usr/include/c++/14/bits/unordered_map.h:987:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = long int; _Tp = long int; _Hash = std::hash<long int>; _Pred = std::equal_to<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  987 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:987:34: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const std::unordered_map<long int, long int>::key_type&' {aka 'const long int&'}
  987 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:991:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = long int; _Tp = long int; _Hash = std::hash<long int>; _Pred = std::equal_to<long int>; _Alloc = std::allocator<std::pair<const long int, long int> >; mapped_type = long int; key_type = long int]'
  991 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:991:29: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::unordered_map<long int, long int>::key_type&&' {aka 'long int&&'}
  991 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:39:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t&)'
   39 |         while(lo < l) insert(--l);
      |                       ~~~~~~^~~~~
a.cc:29:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   29 |     auto insert = [&](int i, int s) {
      |                   ^
a.cc:29:19: note:   candidate expects 2 arguments, 1 provided
a.cc:40:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t&)'
   40 |         while(r < hi) insert(++r);
      |                       ~~~~~~^~~~~
a.cc:29:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   29 |     auto insert = [&](int i, int s) {
      |                   ^
a.cc:29:19: note:   candidate expects 2 arguments, 1 provided
a.cc:41:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t)'
   41 |         while(lo > l) remove(l++);
      |                       ~~~~~~^~~~~
a.cc:32:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   32 |     auto remove = [&](int i, int s) {
      |                   ^
a.cc:32:19: note:   candidate expects 2 arguments, 1 provided
a.cc:42:29: error: no match for call to '(main()::<lambda(int64_t, int64_t)>) (int64_t)'
   42 |         while(r > hi) remove(r--);
      |                       ~~~~~~^~~~~
a.cc:32:19: note: candidate: 'main()::<lambda(int64_t, int64_t)>'
   32 |     auto remove = [&](int i, int s) {
      |                   ^
a.cc:32:19: note:   candidate expects 2 arguments, 1 provided