3
static const int N = 2005;6
long long h[N], p[N], invp[N];7
int modexp(int x, int y) {10
if (y & 1) res = ((long long)res * x) % mod;11
x = ((long long)x * x) % mod;16
int sub_hash(int l, int r) {18
if (l > 0) ans = ((ans + mod - h[l - 1]) * invp[l] * 1LL) % mod;21
int distinctEchoSubstrings(string text) {26
for (int i = 1; i < 2005; i++) {27
p[i] = (p[i - 1] * B) % mod;29
for (int i = 1; i < N; i++) {30
invp[i] = (invp[i - 1] * modexp(B, mod - 2)) % mod;33
h[0] = (text[0] - 'a' + 1);34
for (int i = 1; i < n; i++) {35
h[i] = (h[i - 1] + ((text[i] - 'a' + 1) * p[i]) * 1LL) % mod;37
for (int len = 1; len <= n / 2; len++) {38
for (int i = 0; i < n + 1 - 2 * len; i++) {39
int a = sub_hash(i, i + len - 1);40
int b = sub_hash(i + len, i + 2 * len - 1);42
if (res.find(a) == res.end()) {