func_code_string: #include <bits/stdc++.h>   using namespace std;   const int Mod = (int)1e9 + 7;   const int MX = 1073741822;   const long long MXLL = 4e18;   const int Sz = 1110111;   inline void Read_rap() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   inline void randomizer3000() {     unsigned int seed;     asm( rdtsc  :  =A (seed));     srand(seed);   }   void files(string problem) {     if (fopen((problem +  .in ).c_str(),  r )) {       freopen((problem +  .in ).c_str(),  r , stdin);       freopen((problem +  .out ).c_str(),  w , stdout);     }   }   void localInput(const char in[] =  s ) {     if (fopen(in,  r )) {       freopen(in,  r , stdin);     } else       cerr <<  Warning: Input file not found  << endl;   }   int n;   const int N = 302;   int pref[N][N];   int dp[N][N];   int a[N];   int plen[N], len[N];   int main() {     Read_rap();     cin >> n;     for (int i = 1; i <= n; i++) {       static string s;       cin >> s;       static map<string, int> id;       if (!id.count(s)) id[s] = (int)(id.size());       a[i] = id[s];       len[i] = (int)(s.size());     }     for (int i = n; i >= 1; i--)       for (int j = n; j >= 1; j--)         if (a[i] == a[j]) pref[i][j] = pref[i + 1][j + 1] + 1;     for (int i = 1; i <= n; i++) plen[i] = plen[i - 1] + len[i];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= i; j++) {         int len = i - j + 1;         for (int p = len; p < j; p++) {           int q = p - len + 1;           if (pref[j][q] >= len) dp[i][j] = max(dp[i][j], dp[p][q] + 1);         }       }     }     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= i; j++) {         int len = i - j + 1;         if (dp[i][j]) {           int cost = len - 1 + plen[i] - plen[j - 1] - len;           ans = max(ans, cost * (dp[i][j] + 1));         }       }     }     int sum = accumulate(len + 1, len + n + 1, 0) + n - 1;     cout << sum - ans;     return 0;   }   