func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 850;   int capacity[N][N], p[N], visit[N], n, source, sink, max_flow;   pair<int, int> a[N];   vector<int> adj[N];   double f[N], cost[N][N], res;   double dis(pair<int, int> a, pair<int, int> b) {     return sqrt((a.first - b.first) * (a.first - b.first) +                 (a.second - b.second) * (a.second - b.second));   }   void add(int u, int v, int cap, double c) {     adj[u].push_back(v);     adj[v].push_back(u);     capacity[u][v] = cap;     cost[u][v] = c;     cost[v][u] = -c;   }   int bfs() {     for (int i = 0; i <= 2 * n + 1; i++) {       visit[i] = 2;       f[i] = 1e9;     }     f[source] = 0;     deque<int> q;     q.push_back(source);     int check = 0;     while (!q.empty()) {       int u = q.front();       q.pop_front();       visit[u] = 0;       if (u == sink) check = 1;       for (int v : adj[u])         if (capacity[u][v] > 0 && f[v] > f[u] + cost[u][v]) {           f[v] = f[u] + cost[u][v];           p[v] = u;           if (visit[v] == 1) continue;           if (visit[v] == 2)             q.push_back(v);           else             q.push_front(v);         }     }     return check;   }   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     source = 0;     sink = 2 * n + 1;     for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;     for (int i = 1; i <= n; i++) add(source, i, 2, 0);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (a[i].second > a[j].second) add(i, j + n, 1, dis(a[i], a[j]));     for (int i = n + 1; i <= 2 * n; i++) add(i, sink, 1, 0);     while (bfs()) {       int flow_path = 1e9, v = sink;       while (v != source) {         flow_path = min(flow_path, capacity[p[v]][v]);         v = p[v];       }       v = sink;       max_flow += flow_path;       res += flow_path * f[sink];       while (v != source) {         capacity[p[v]][v] -= flow_path;         capacity[v][p[v]] += flow_path;         v = p[v];       }     }     cout << fixed << setprecision(9);     if (max_flow != n - 1)       cout << -1;     else       cout << res;   }   