func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   char s[5010];   long long dp[5010][5010];   bool vis[5010][5010];   long long f(int i, int ind, int n) {     if (vis[i][ind]) return dp[i][ind];     if (i > n) {       if (ind == 0) return 1;       return 0;     }     long long ans = 0;     vis[i][ind] = true;     if (s[i] ==  f )       ans = f(i + 1, ind + 1, n);     else {       ans = f(i + 1, ind, n);       if (ind > 0) ans = (ans + f(i, ind - 1, n)) % mod;     }     dp[i][ind] = ans;     return ans;   }   int main() {     int i, j, n;     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf(  %c , &s[i]);     printf( %lld n , f(1, 0, n));     return 0;   }   