func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100, LEN = 21, M = 1 << LEN, inF = N * 30;   int n, len, ps[N], dp0[N], dp1[N], mini[M][LEN];   string s[N];   void _min(int &a, int b) { a = min(a, b); }   int same(string a, string b) {     int A = 0, B = 0, res = 0;     for (int i = 0; i < len; i++) {       A |= (a[len - i - 1] -  0 ) << i;       B = (B << 1) | (b[i] -  0 );       if (A == B) res = i + 1;     }     return res;   }   int dif(string a, string b) { return len - same(a, b); }   void add(int dex) {     _min(mini[0][0], dp1[dex] - ps[dex] + len - 0);     int val = 0;     for (int i = 1; i <= len; i++)       val |= (s[dex - 1][len - i] -  0 ) << (i - 1),           _min(mini[val][i], dp1[dex] - ps[dex] + len - i);   }   void find_dp() {     dp0[0] = dp1[0] = len;     for (int i = 1; i < n; i++) {       dp0[i] = min(dp0[i - 1], dp1[i - 1]) + dif(s[i - 1], s[i]);       dp1[i] = min((i == 1 ? len << 1 : dp1[i - 1] + dif(s[i - 2], s[i])),                    ps[i - 1] + len);       int val = 0;       _min(dp1[i], mini[val][0] + ps[i - 1]);       for (int j = 1; j <= len; j++)         val = (val << 1) | (s[i][j - 1] -  0 ),         _min(dp1[i], mini[val][j] + ps[i - 1]);       if (i != n - 1) add(i);     }   }   int main() {     for (int i = 0; i < M; i++) fill(mini[i], mini[i] + LEN, inF);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s[i];       ps[i] = (i ? ps[i - 1] + dif(s[i - 1], s[i]) : len = s[i].length());     }     find_dp();     cout << min(dp0[n - 1], dp1[n - 1]);     return 0;   }   