func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MXN = 2e5 + 10;   const long long LOG = 21;   const long long MXM = (1LL << LOG);   const long long INF = 1e9;   int n, m, ans;   int dp[MXN], ps[MXN], Best[LOG][MXM];   string S[MXN];   int Cost(int i, int j) {     for (int x = m; x; x--) {       if (S[i].substr(m - x + 1, x) == S[j].substr(1, x)) {         return m - x;       }     }     return m;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     memset(dp, 31, sizeof dp), memset(Best, 31, sizeof Best);     cin >> n, ans = INF;     for (int i = 1; i <= n; i++) {       cin >> S[i], m = (long long)S[i].size();       S[i] =  0  + S[i];     }     ps[1] = dp[1] = m;     for (int i = 2; i <= n; i++) ps[i] = ps[i - 1] + Cost(i - 1, i);     for (int i = 2; i <= n; i++) {       dp[i] = ps[i - 1] + m;       long long mask = 0;       for (int x = 0; x <= m; x++) {         mask = mask * 2 + (S[i][x] -  0 );         if (Best[x][mask] < INF) {           dp[i] = min(dp[i], ps[i - 1] + m - x + Best[x][mask]);         }       }       mask = 0;       for (int x = 0; x <= m; x++) {         if (x && S[i - 1][m - x + 1] ==  1 ) {           mask += (1LL << (x - 1));         }         Best[x][mask] = min(Best[x][mask], dp[i] - ps[i]);       }     }     for (int i = 1; i <= n; i++) ans = min(ans, dp[i] + ps[n] - ps[i]);     cout << ans <<   n ;     return 0;   }   