Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
  int num_golem,num_spell;
  cin>>num_golem>>num_spell;
  string golem;
  cin>>golem;
  unordered_map<char,vector<int>> m;
  for(int i=0;i<golem.size();++i){
    m[golem].push_back(i);
  }
  vector<int> count(golem.size(),1);
  for(int i=0;i<num_spell;++i){
    char type, operator;
    cin>>type>>operator;
    for(int j=0;j<m[type].size();++j){
      if(operator=='L'){
        if(m[type][j]!=0){
          m[type][j-1]+=m[type][j];
        }
        m[type][j]=0;
      } 
      if(operator=='R'){
        if(m[type][j]!=golem.size()-1){
          m[type][j+1]+=m[type][j];
        }
        m[type][j]=0;
      } 
    }
  }
  cout<<accumulate(count.begin(), count.end(), 0);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:6: error: no match for 'operator[]' (operand types are 'std::unordered_map<char, std::vector<int> >' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   15 |     m[golem].push_back(i);
      |      ^
In file included from /usr/include/c++/14/unordered_map:41,
                 from a.cc:4:
/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 = char; _Tp = std::vector<int>; _Hash = std::hash<char>; _Pred = std::equal_to<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; mapped_type = std::vector<int>; key_type = char]'
  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<char, std::vector<int> >::key_type&' {aka 'const char&'}
  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 = char; _Tp = std::vector<int>; _Hash = std::hash<char>; _Pred = std::equal_to<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; mapped_type = std::vector<int>; key_type = char]'
  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<char, std::vector<int> >::key_type&&' {aka 'char&&'}
  991 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
a.cc:19:24: error: expected type-specifier before ';' token
   19 |     char type, operator;
      |                        ^
a.cc:20:24: error: expected type-specifier before ';' token
   20 |     cin>>type>>operator;
      |                        ^
a.cc:22:20: error: expected ')' before 'L'
   22 |       if(operator=='L'){
      |         ~          ^~~
      |                    )
a.cc:22:23: error: cannot resolve overloaded function 'operator==' based on conversion to type 'bool'
   22 |       if(operator=='L'){
      |                       ^
a.cc:28:20: error: expected ')' before 'R'
   28 |       if(operator=='R'){
      |         ~          ^~~
      |                    )
a.cc:28:23: error: cannot resolve overloaded function 'operator==' based on conversion to type 'bool'
   28 |       if(operator=='R'){
      |                       ^
a.cc:36:9: error: 'accumulate' was not declared in this scope
   36 |   cout<<accumulate(count.begin(), count.end(), 0);
      |         ^~~~~~~~~~