Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
vector<ull>hash,power;
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=0;i<sz;i++)power[i+1]=power[i]*B;
  for(int i=0;i<sz;i++)hash[i+1]=(hash[i]+s[i])*B;
}
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--;
    //cout<<get_hash(l,r)<<endl;
    p.insert(get_hash(l,r));
  }
  cout<<p.size()<<endl;
}

Compiler output:
a.cc:5:1: error: ISO C++ forbids declaration of 'Roliha' with no type [-fpermissive]
    5 | Roliha(string &s){
      | ^~~~~~
a.cc: In function 'int 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:24: error: reference to 'hash' is ambiguous
   12 |   for(int i=0;i<sz;i++)hash[i+1]=(hash[i]+s[i])*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:35: error: reference to 'hash' is ambiguous
   12 |   for(int i=0;i<sz;i++)hash[i+1]=(hash[i]+s[i])*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:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
   13 | }
      | ^
a.cc: At global scope:
a.cc:14:1: error: ISO C++ forbids declaration of 'get_hash' with no type [-fpermissive]
   14 | get_hash(int l,int r){return hash[r]-hash[l]*power[r-l];}
      | ^~~~~~~~
a.cc: In function 'int get_hash(int, int)':
a.cc:14:30: error: reference to 'hash' is ambiguous
   14 | 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:38: error: reference to 'hash' is ambiguous
   14 | 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;
      |            ^~~~