func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const vector<int> mods = {998244353, 1000000007, 1000000009};   const long long inf = 3e18;   const double pi = acos(-1.0);   const double eps = 0.0000001;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   template <class... K>   using umap = unordered_map<K...>;   template <class... K>   using uset = unordered_set<K...>;   const int N = 1000100;   int n, l[N];   vector<vector<int> > a, ord;   string s;   umap<int, long long> dp;   long long res;   void build(int x) {     vector<int> cur = {};     vector<int> bk;     auto ad = [&](vector<int>& to) {       while (((int)(cur).size())) {         to.push_back(cur.back());         cur.pop_back();       }     };     for (long long i = (0); i < (l[x] - 1); ++i) {       cur.push_back(i);       if (a[x][i] < a[x][i + 1]) ad(ord[x]);       if (a[x][i] > a[x][i + 1]) ad(bk);     }     cur.push_back(l[x] - 1);     ad(ord[x]);     for (int i = ((int)(bk).size()) - 1; i >= 0; i--) ord[x].push_back(bk[i]);   }   int p(int i, int si) { return i + (i >= si); }   bool gt(int i, int si, int j, int sj) {     int pp = 0;     while (p(pp, si) < l[i] && p(pp, sj) < l[j]) {       int ppi = p(pp, si), ppj = p(pp, sj);       if (a[i][ppi] < a[j][ppj]) return 0;       if (a[i][ppi] > a[j][ppj]) return 1;       pp++;     }     long long il = l[i] - (si != l[i] - 1);     long long jl = l[j] - (sj != l[j] - 1);     if (il > jl)       return 1;     else       return 0;   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout.precision(13);     cin >> n;     a.resize(n + 1);     ord.resize(n + 1);     for (long long i = (0); i < (n); ++i) {       cin >> s;       l[i] = s.length() + 1;       for (long long j = (0); j < (l[i] - 1); ++j) a[i].push_back(s[j] -  a );       a[i].push_back(-1);     }     a[n] = {27, -1};     l[n] = 2;     for (long long i = (0); i < (n + 1); ++i) build(i);     dp[0] = 1;     dp[1] = 0;     for (int i = n; i >= 1; i--) {       umap<int, long long> nxdp;       int j = i - 1;       int pi = 0, pj = 0;       long long pre = 0;       while (pi < l[i] || pj < l[j]) {         if (pi >= l[i] || pj < l[j] && gt(j, ord[j][pj], i, ord[i][pi]))           nxdp[pj++] = pre;         else           pre = (pre + dp[pi++]) % mod;       }       dp = move(nxdp);     }     for (auto& d_ : dp) res = (res + d_.second) % mod;     cout << res <<   n ;     return 0;   }   