rtrt
class shash {
public:
using ll = long long;
vector<ll> pres;
vector<ll> epow;
ll e, p;
shash(string &s, ll e, ll p) {
int n = s.size();
this->e = e;
this->p = p;
pres = vector<ll>(n + 1);
epow = vector<ll>(n + 1);
epow[0] = 1;
for (int i = 0; i < n; i++) {
pres[i + 1] = (pres[i] * e + s[i]) % p;
epow[i + 1] = (epow[i] * e) % p;
}
}
ll operator()(int l, int r) {
ll res = (pres[r + 1] - pres[l] * epow[r - l + 1] % p) % p;
return (res + p) % p;
}
};
int main() {
string s = "abcab";
shash h(s, 2333, 1e9 + 7);
assert(h(0, 1) == h(3, 4));
}