func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace red {   inline long long read() {     long long x = 0;     char ch, f = 1;     for (ch = getchar(); (ch <  0  || ch >  9 ) && ch !=  - ; ch = getchar())       ;     if (ch ==  - ) f = 0, ch = getchar();     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return f ? x : -x;   }   const long long N = 1e6 + 10, inf = 1e9 + 7, base = 131, mod = 1e9 + 7;   long long n, m, t, ret;   char a[N], b[N], s[N];   long long nxt[N], f[N], g[N];   long long pw[N], ha[N], hs[N];   inline void prepare(char *a, long long *f) {     long long len = max(n, m);     for (long long i = pw[0] = 1; i <= len; ++i) pw[i] = pw[i - 1] * base % mod;     for (long long i = 1; i <= n; ++i) ha[i] = (ha[i - 1] * base + a[i]) % mod;     for (long long i = 1; i <= m; ++i) hs[i] = (hs[i - 1] * base + s[i]) % mod;     for (long long i = 1; i <= n; ++i) {       long long l = i, r = n;       while (l <= r) {         long long t1 = (ha[((l + r) >> 1)] -                         ha[i - 1] * pw[((l + r) >> 1) - i + 1] % mod + mod) %                        mod;         long long t2 = hs[((l + r) >> 1) - i + 1];         if (t1 == t2)           f[i] = ((l + r) >> 1) - i + 1, l = ((l + r) >> 1) + 1;         else           r = ((l + r) >> 1) - 1;       }       f[i] = min(f[i], m - 1);     }   }   struct BIT {     long long tr[N];     BIT() { memset(tr, 0, sizeof(tr)); }     inline void update(long long p, long long k) {       for (p++; p < N; p += p & (-p)) tr[p] += k;     }     inline long long query(long long p) {       long long ret = 0;       for (p++; p; p -= p & (-p)) ret += tr[p];       return ret;     }   } bit[2];   inline void main() {     n = read(), m = read();     scanf( %s%s%s , a + 1, b + 1, s + 1);     prepare(a, f);     reverse(s + 1, s + m + 1);     reverse(b + 1, b + n + 1);     prepare(b, g);     reverse(g + 1, g + n + 1);     for (long long i = n; i; --i) {       bit[0].update(g[i], 1);       bit[1].update(g[i], g[i]);       if (i + m - 1 <= n) {         bit[0].update(g[i + m - 1], -1);         bit[1].update(g[i + m - 1], -g[i + m - 1]);       }       if (!f[i]) continue;       long long v = m - f[i];       ret += bit[1].query(m) - bit[1].query(v - 1);       ret -= (bit[0].query(m) - bit[0].query(v - 1)) * (v - 1);     }     printf( %lld n , ret);   }   }  // namespace red   signed main() {     red::main();     return 0;   }   