Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
vector<ull>hash,power;
void Roliha(string &s){
  ull B=1000000007;
  int sz=s.size();
  hash.assign(sz+1,0);
  power.assign(sz+1,0);
  power[0]=1;
  for(int i=1;i<=sz;i++)power[i]=power[i-1]*B;
  for(int i=1;i<=sz;i++)hash[i]=(hash[i-1]+s[i-1])*B;
}
ull get_hash(int l,int r){return hash[r]-hash[l]*power[r-l];}
int main(){
  int n,m,l=0,r=1;
  string s,t;
  cin>>n>>m>>s;
  set<ull>p;
  Roliha(s);
  while(m--&&cin>>t){
    if(t[0]=='R')t[1]=='+'?r++:r--;
    else t[1]=='+'?l++:l--;
    p.insert(get_hash(l,r));
  }
  cout<<p.size()<<endl;
}

Compiler output:
a.cc: In function 'void Roliha(std::string&)':
a.cc:8:3: error: reference to 'hash' is ambiguous
    8 |   hash.assign(sz+1,0);
      |   ^~~~
In file included from /usr/include/c++/14/string_view:50,
                 from /usr/include/c++/14/bits/basic_string.h:47,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:12: note:                 'std::vector<long long unsigned int> hash'
    4 | vector<ull>hash,power;
      |            ^~~~
a.cc:12:25: error: reference to 'hash' is ambiguous
   12 |   for(int i=1;i<=sz;i++)hash[i]=(hash[i-1]+s[i-1])*B;
      |                         ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:12: note:                 'std::vector<long long unsigned int> hash'
    4 | vector<ull>hash,power;
      |            ^~~~
a.cc:12:34: error: reference to 'hash' is ambiguous
   12 |   for(int i=1;i<=sz;i++)hash[i]=(hash[i-1]+s[i-1])*B;
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:12: note:                 'std::vector<long long unsigned int> hash'
    4 | vector<ull>hash,power;
      |            ^~~~
a.cc: In function 'long long unsigned int get_hash(int, int)':
a.cc:14:34: error: reference to 'hash' is ambiguous
   14 | ull get_hash(int l,int r){return hash[r]-hash[l]*power[r-l];}
      |                                  ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:12: note:                 'std::vector<long long unsigned int> hash'
    4 | vector<ull>hash,power;
      |            ^~~~
a.cc:14:42: error: reference to 'hash' is ambiguous
   14 | ull get_hash(int l,int r){return hash[r]-hash[l]*power[r-l];}
      |                                          ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
   59 |     struct hash;
      |            ^~~~
a.cc:4:12: note:                 'std::vector<long long unsigned int> hash'
    4 | vector<ull>hash,power;
      |            ^~~~