func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, a[22], b[22], d[22][44], mat[44][44], res[44][44], t[44][44];   void calc(int x[44][44], int y[44][44], int z[44][44]) {     for (int i = 0; i <= 2 * n; ++i)       for (int j = 0; j <= 2 * n; ++j) {         t[i][j] = (int)(2e9);         for (int k = 0; k <= 2 * n; ++k) {           if (x[i][k] != (int)(2e9) && y[k][j] != (int)(2e9))             t[i][j] = min(t[i][j], x[i][k] + y[k][j]);         }       }     for (int i = 0; i <= 2 * n; ++i)       for (int j = 0; j <= 2 * n; ++j) {         z[i][j] = t[i][j];       }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) cin >> b[i];     for (int start = 0; start <= 2 * n; ++start) {       for (int i = 0; i <= n; ++i)         for (int j = 0; j <= 2 * n; ++j) d[i][j] = (int)(2e9);       d[0][start] = 0;       for (int i = 0; i < n; ++i)         for (int j = 0; j <= 2 * n; ++j) {           if (d[i][j] != (int)(2e9)) {             if (j > 0) d[i + 1][j - 1] = min(d[i + 1][j - 1], d[i][j] + b[i]);             if (j < 2 * n) d[i + 1][j + 1] = min(d[i + 1][j + 1], d[i][j] + a[i]);           }         }       for (int j = 0; j <= 2 * n; ++j) mat[start][j] = d[n][j];     }     for (int i = 0; i <= 2 * n; ++i)       for (int j = 0; j <= 2 * n; ++j) res[i][j] = (int)(2e9);     res[0][0] = 0;     while (m) {       if (m & 1) calc(res, mat, res);       calc(mat, mat, mat);       m >>= 1;     }     cout << res[0][0];   }   