func_code_string: #include <bits/stdc++.h>   using namespace std;   long long mod = 1000 * 1000 * 1000 + 7;   struct suffix_array {     vector<int> sa;     vector<int> lcp;     vector<vector<int>> st;     vector<int> log2;     vector<int> c;     string str;     int n;     void sort_pairs(vector<pair<pair<int, int>, int>>& a) {       vector<int> beg(n + 20);       for (int i = 0; i < n; i++) {         beg[a[i].first.second + 1]++;       }       for (int i = 0; i < beg.size() - 1; i++) {         beg[i + 1] += beg[i];       }       vector<pair<pair<int, int>, int>> sorted(n);       for (int i = 0; i < n; i++) {         sorted[beg[a[i].first.second]] = a[i];         beg[a[i].first.second]++;       }       beg.assign(beg.size(), 0);       for (int i = 0; i < n; i++) {         beg[sorted[i].first.first + 1]++;       }       for (int i = 0; i < beg.size() - 1; i++) {         beg[i + 1] += beg[i];       }       for (int i = 0; i < n; i++) {         a[beg[sorted[i].first.first]] = sorted[i];         beg[sorted[i].first.first]++;       }     }     suffix_array(string s) {       s +=  $ ;       n = s.length();       str = s;       c.assign(n, 0);       for (int i = 0; i < n; i++) {         if (s[i] >=  0  && s[i] <=  9 ) {           c[i] = (int)(s[i] -  0  + 1);         } else {           c[i] = 0;         }       }       vector<pair<pair<int, int>, int>> pairs(n);       for (int j = 0; (1 << (j - 1)) < n; j++) {         for (int i = 0; i < n; i++) {           pairs[i] = {{c[i], c[(i + (1 << j)) % n]}, i};         }         sort_pairs(pairs);         int cc = 0;         c[pairs[0].second] = cc;         for (int i = 1; i < n; i++) {           if (pairs[i].first != pairs[i - 1].first) cc++;           c[pairs[i].second] = cc;         }       }       sa.assign(n, 0);       for (int i = 0; i < n; i++) {         sa[c[i]] = i;       }       lcp.assign(n, 0);       int k = 0;       for (int i = 0; i < n; i++) {         int a = i;         if (c[i] == n - 1) {           k = 0;           continue;         }         int b = sa[c[i] + 1];         if (k > 0) k--;         while (max(a + k, b + k) < n && s[a + k] == s[b + k]) {           k++;         }         lcp[c[i]] = k;       }       log2.assign(n + 1, 0);       log2[1] = 0;       for (int i = 2; i <= n; i++) {         log2[i] = log2[i / 2] + 1;       }       st.assign(log2[n] + 1, vector<int>(n));       for (int i = 0; i < n; i++) {         st[0][i] = lcp[i];       }       for (int j = 1; j < st.size(); j++) {         for (int i = 0; i + (1 << j) <= n; i++) {           st[j][i] = min(st[j - 1][i], st[j - 1][i + (1 << (j - 1))]);         }       }     }     int compare(int i, int len_i, int j, int len_j) {       if (i == j && len_i == len_j) return 0;       int pos_i = i;       int pos_j = j;       i = c[i];       j = c[j];       if (i > j) swap(i, j);       j--;       int l = log2[j - i + 1];       int lcp_ans = min(st[l][i], st[l][j - (1 << l) + 1]);       int len = min(len_i, len_j);       lcp_ans = min(lcp_ans, len);       if (lcp_ans == len) {         if (len_i == len_j) {           return 0;         } else if (len_i > len_j) {           return 1;         } else {           return -1;         }       } else if (str[pos_i + lcp_ans] > str[pos_j + lcp_ans]) {         return 1;       } else {         return -1;       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     string s;     cin >> s;     suffix_array sa(s);     vector<vector<int>> dp(n + 1, vector<int>(n + 1));     vector<vector<int>> sums(n + 1, vector<int>(n + 1));     dp[0][0] = 1;     dp[1][1] = 1;     sums[0].assign(n + 1, 1);     for (int i = 1; i <= n; i++) {       sums[1][i] = 1;     }     for (int i = 2; i <= n; i++) {       for (int j = 1; j <= i; j++) {         if (s[i - j] ==  0 ) {           dp[i][j] = 0;           sums[i][j] = sums[i][j - 1];           continue;         }         if (j <= i - j && sa.compare(i - j, j, i - j - j, j) > 0) {           dp[i][j] += dp[i - j][j];           dp[i][j] %= mod;         }         dp[i][j] += sums[i - j][j - 1];         dp[i][j] %= mod;       }       for (int j = 1; j <= n; j++) {         sums[i][j] = sums[i][j - 1] + dp[i][j];         sums[i][j] %= mod;       }     }     long long ans = 0;     for (int i = 0; i <= n; i++) {       ans += dp[n][i];       ans %= mod;     }     cout << ans;   }   