func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, deg[8010], type[8010], in[8010];   long long ans = 0;   bool e[8010][8010];   char s[8010];   queue<int> q;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= n / 4; j++) {         int k = (s[j] <=  9  && s[j] >=  0 ) ? s[j] -  0  : s[j] -  A  + 10;         for (int l = 0; l < 4; l++) e[i][j * 4 - l] = (k >> l) & 1;       }     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (e[i][j]) deg[j]++;     for (int i = 1; i <= n; i++)       if (!deg[i]) q.push(i);     int tmp = n;     while (!q.empty()) {       int now = q.front();       q.pop();       tmp--;       type[now] = 3;       ans += (614ll * n + 1) * tmp;       for (int i = 1; i <= n; i++)         if (e[now][i]) {           deg[i]--;           if (!deg[i]) q.push(i);         }     }     if (!tmp) return printf( %lld n , ans), 0;     int pos = -1, mx = 0;     for (int i = 1; i <= n; i++)       if (deg[i] > mx) mx = deg[i], pos = i;     for (int i = 1; i <= n; i++)       if (type[i] != 3) type[i] = (i == pos || e[i][pos]) ? 1 : 2;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (i != j && type[i] != 3 && type[j] != 3 && type[i] != type[j] &&             e[i][j])           in[j]++;     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++)         if (type[i] != 3 && type[j] != 3)           ans += 3 + (type[i] == type[j] && in[i] == in[j]);     printf( %lld n , ans);   }   