func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<vector<int> > a(n, vector<int>(n));     vector<int> b(n * n), q(n * n);     for (int i = 0; i < n * n; ++i) {       cin >> b[i];       q[i] = i;     }     do {       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j) a[i][j] = b[q[n * i + j]];       int s = a[0][0];       if (n == 3) {         s = a[0][0] + a[0][1] + a[0][2];         if (s != a[1][0] + a[1][1] + a[1][2]) continue;         if (s != a[2][0] + a[2][1] + a[2][2]) continue;         if (s != a[0][0] + a[1][0] + a[2][0]) continue;         if (s != a[0][1] + a[1][1] + a[2][1]) continue;         if (s != a[0][2] + a[1][2] + a[2][2]) continue;         if (s != a[0][0] + a[1][1] + a[2][2]) continue;         if (s != a[0][2] + a[1][1] + a[2][0]) continue;       }       if (n == 2) {         s = a[0][0] + a[0][1];         if (s != a[1][0] + a[1][1]) continue;         if (s != a[0][0] + a[1][0]) continue;         if (s != a[0][1] + a[1][1]) continue;         if (s != a[0][0] + a[1][1]) continue;         if (s != a[0][1] + a[1][0]) continue;       }       cout << s << endl;       for (int i = 0; i < n; ++i) {         for (int j = 0; j < n; ++j) cout << a[i][j] <<    ;         cout << endl;       }       break;     } while (next_permutation(q.begin(), q.end()));     return 0;   }   