func_code_string: #include <bits/stdc++.h>   using namespace std;   std::vector<int> Edge[510];   std::vector<int> Current[510];   int Right[510];   int Left[510];   int Vis[510];   int N, M;   bool dfs(int idx) {     if (Vis[idx]) return false;     Vis[idx] = 1;     for (int i = 0; i < Current[idx].size(); i++) {       int v = Current[idx][i];       if (Left[v] == -1 || dfs(Left[v])) {         Left[v] = idx;         Right[idx] = v;         return true;       }     }     return false;   }   int bpm() {     int Ans = 0;     memset(Left, -1, sizeof(Left));     memset(Right, -1, sizeof(Right));     for (int i = 0; i < N; i++) {       memset(Vis, false, sizeof(Vis));       Ans += dfs(i);     }     return Ans;   }   int main() {     cin >> N >> M;     int u, v;     for (int i = 0; i < M; i++) {       cin >> u >> v;       u -= 1, v -= 1;       Edge[u].push_back(v);     }     int Ans = 1e9;     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) Current[j].clear();       int cnt = 0, other = 0;       for (int j = 0; j < N; j++) {         for (int k = 0; k < Edge[j].size(); k++) {           if (j == i || Edge[j][k] == i) {             cnt += 1;             continue;           }           other += 1;           Current[j].push_back(Edge[j][k]);         }       }       int max_match = bpm();       Ans = min(Ans, 2 * N - 1 + other - cnt - 2 * max_match + N - 1);     }     cout << Ans << endl;     return 0;   }   