func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<int> ed[2000];   int sho[1200][1200];   int col[1200];   int n, m;   int makk[1200];   int sp[1200];   void dfs(int v, int ccc) {     sp[v] = ccc;     for (int a = 0; a < ed[v].size(); a++) {       if (sp[ed[v][a]] == -1) dfs(ed[v][a], ccc);     }   }   void getsho(int v) {     int q[3000];     int dp[3000];     int c[3000];     for (int a = 0; a < n; a++) c[a] = -1;     q[0] = v;     dp[0] = 0;     c[v] = 1;     int bb = 0;     int ee = 0;     while (bb <= ee) {       int vx = q[bb];       sho[v][vx] = dp[bb];       for (int a = 0; a < ed[vx].size(); a++) {         if (c[ed[vx][a]] == -1) {           int vu = ed[vx][a];           c[vu] = 1;           ee++;           q[ee] = vu;           dp[ee] = dp[bb] + 1;         }       }       bb++;     }   }   int isok;   void kolo(int v, int c) {     col[v] = c;     for (int a = 0; a < ed[v].size(); a++) {       if (col[ed[v][a]] == c)         isok = 0;       else if (col[ed[v][a]] == -1)         kolo(ed[v][a], 1 - c);     }   }   int main() {     cin >> n >> m;     for (int a = 0; a < 1200; a++) makk[a] = 0;     isok = 1;     int x, y;     for (int a = 0; a < n; a++)       for (int b = 0; b < n; b++) sho[a][b] = 1000000;     for (int a = 0; a < m; a++) {       cin >> x >> y;       ed[x - 1].push_back(y - 1);       ed[y - 1].push_back(x - 1);     }     for (int a = 0; a < 1100; a++) col[a] = -1;     kolo(0, 0);     if (!isok) {       cout << -1;       return 0;     }     for (int a = 0; a < n; a++) sp[a] = -1;     int ccc = -1;     for (int a = 0; a < n; a++) {       if (sp[a] == -1) {         ccc++;         dfs(a, ccc);       }     }     for (int a = 0; a < n; a++) getsho(a);     int mini = 0;     for (int a = 0; a < n; a++) {       for (int b = a + 1; b < n; b++) {         if (sp[a] == sp[b] && sho[a][b] > makk[sp[a]] && sho[a][b] < 100000)           makk[sp[a]] = sho[a][b];       }     }     int ss = 0;     for (int a = 0; a < 1200; a++) ss += makk[a];     cout << ss;     return 0;   }   