func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:268435456 )   using namespace std;   template <typename T>   T sqr(const T &x) {     return x * x;   }   template <typename T>   T my_abs(const T &x) {     return x < 0 ? -x : x;   }   const int INF = (int)1e9;   const long long LINF = (long long)6e18;   const long long INF64 = LINF;   const long long INFLL = LINF;   const long double EPS = 1e-15;   const long double PI = 3.1415926535897932384626433832795;   const long double ME = 1e-5;   const long long MOD2 = (int)1e9 + 21;   const int SQN = 320;   const int LOGN = 17;   const int dx[] = {0, 1, 0, -1};   const int dy[] = {-1, 0, 1, 0};   const int N = (int)5e3 + 10;   const int M = (int)2e6 + 10;   const long long MOD = (int)1e9 + 7;   int z[N][N];   int psum[N][N];   int prv[26][N];   int a[N];   void solve() {     int n;     cin >> n;     string s;     cin >> s;     for (int i = 0; i < int(n); ++i) {       a[i] = s[i] -  a ;     }     memset(prv, -1, sizeof(prv));     for (int i = 0; i < int(26); ++i) {       for (int j = 1; j < int(n); ++j) {         if (a[j - 1] == i) {           prv[i][j] = j - 1;         } else {           prv[i][j] = prv[i][j - 1];         }       }     }     z[0][0] = 1;     for (int j = 1; j < int(n + 1); ++j) {       psum[0][j] = 1;     }     for (int i = 1; i < int(n + 1); ++i) {       for (int j = 0; j < int(n); ++j) {         z[i][j] = (z[i][j] + z[i - 1][j]) % MOD;         z[i][j] =             (z[i][j] + psum[i - 1][j] - psum[i - 1][prv[a[j]][j] + 1] + MOD) %             MOD;         psum[i][j + 1] = (psum[i][j] + z[i][j]) % MOD;       }     }     int ans = 0;     for (int j = 0; j < int(n); ++j) {       ans = (ans + z[n][j]) % MOD;     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     srand((unsigned int)time(NULL));     cout << setprecision(15) << fixed;     solve();     return 0;   }   