Hash get_hash(int l, int r, Hash h[maxn]) { Hash res = h[r]; if (l != 0) res = res - h[l - 1]; res = res.up(N / 2 - l); return res; }