func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, x[maxn], y[maxn];   int solve(set<pair<int, int> >& a, set<pair<int, int> >& b) {     set<pair<int, int> >::iterator itl = a.begin(), itd = b.begin(), it1;     set<pair<int, int> >::reverse_iterator itr = a.rbegin(), itu = b.rbegin(),                                            it2;     set<pair<int, int> > f, s;     bool chk = false;     for (int i = 0; i < a.size() - 1; ++i) {       if (next(itl)->first > itl->first + 1) {         chk = true;         for (it1 = a.begin(); it1 != next(itl); ++it1) {           f.insert({x[it1->second], it1->second});         }       } else if (next(itd)->first > itd->first + 1) {         chk = true;         for (it1 = b.begin(); it1 != next(itd); ++it1) {           f.insert({x[it1->second], it1->second});         }       } else if (next(itr)->first + 1 < itr->first) {         chk = true;         for (it2 = a.rbegin(); it2 != next(itr); ++it2) {           f.insert({x[it2->second], it2->second});         }       } else if (next(itu)->first + 1 < itu->first) {         chk = true;         for (it2 = b.rbegin(); it2 != next(itu); it2++) {           f.insert({x[it2->second], it2->second});         }       }       if (chk) {         for (auto u : f) {           s.insert({y[u.second], u.second});           b.erase({y[u.second], u.second});           a.erase(u);         }         return solve(a, b) + solve(f, s);       }       itl++;       itr++;       itd++;       itu++;     }     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     set<pair<int, int> > xs, ys;     for (int i = 0; i < n; ++i) {       cin >> x[i] >> y[i];       xs.insert({x[i], i});       ys.insert({y[i], i});     }     cout << solve(xs, ys);     return 0;   }   