func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T>   T gcd(T a, T b) {     return b ? gcd(b, a % b) : a;   }   const double EPS = 1e-9;   const double PI = acos(-1.);   const int INF = 1e8;   const int MAXN = 505;   const long long MOD = 1e9 + 7;   int v[MAXN];   int dp[MAXN][MAXN];   void solve() {     int n, i, j, k, lim, fl;     scanf( %d , &n);     for ((i) = (0); (i) < (int)(n); (i)++) {       scanf( %d , &v[i]);     }     for ((i) = (0); (i) < (int)(n); (i)++) {       for ((j) = (0); (j) < (int)(n); (j)++) {         dp[i][j] = INF;       }     }     for (i = n - 1; i >= 0; i--) {       dp[i][i] = 1;       if (i < n - 1) {         dp[i][i + 1] = 2;         if (v[i] == v[i + 1]) {           dp[i][i + 1] = 1;         }       }       for (j = i + 2; j < n; j++) {         for (k = i; k < j; k++) {           dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);         }         if (v[i] == v[j]) {           dp[i][j] = min(dp[i][j], dp[i + 1][j - 1]);         }       }     }     printf( %d n , dp[0][n - 1]);   }   int main() {     int t = 1;     while (t--) {       solve();     }   }   