func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T, class L>   bool smax(T &x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   bool smin(T &x, L y) {     return y < x ? (x = y, 1) : 0;   }   const int maxn = 1e5 + 17, S = 1e9 + 1, maxfen = S * 2;   map<int, vector<pair<int, int>>> xs, ys;   int n;   unordered_map<int, int> iman;   struct eve {     int x, y, v;   };   vector<eve> event;   void make(vector<pair<int, int>> &vec) {     vector<pair<int, int>> ans;     sort(vec.begin(), vec.end());     int mxr = vec[0].second;     ans.push_back({vec[0].first, -1});     for (int i = 1; i < vec.size(); i++) {       if (mxr < vec[i].first)         ans.back().second = mxr + 1, ans.push_back({vec[i].first, -1});       smax(mxr, vec[i].second);     }     ans.back().second = mxr + 1;     vec = ans;   }   void majid(long long p, int v) {     for (p += S; p < maxfen; p += p & -p) iman[p] += v;   }   int hamid(int p) {     int ans = 0;     for (p += S; p; p ^= p & -p) ans += iman[p];     return ans;   }   int hamid(int l, int r) { return hamid(r - 1) - hamid(l - 1); }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n;     for (int x1, y1, x2, y2, i = 0; i < n; i++) {       cin >> x1 >> y1 >> x2 >> y2;       if (x1 == x2)         xs[x1].push_back(minmax(y1, y2));       else         ys[y1].push_back(minmax(x1, x2));     }     long long ans = 0;     for (auto &v : ys) {       make(v.second);       for (auto x : v.second) {         ans += x.second - x.first;         event.push_back({v.first, x.first, 1});         event.push_back({v.first, x.second, -1});       }     }     sort(event.begin(), event.end(), [](eve &a, eve &b) { return a.y < b.y; });     int ptr = 0;     for (auto &v : xs) {       make(v.second);       while (ptr < event.size() && event[ptr].y <= v.first)         majid(event[ptr].x, event[ptr].v), ptr++;       for (auto x : v.second) {         ans += x.second - x.first;         ans -= hamid(x.first, x.second);       }     }     cout << ans <<   n ;     return 0;   }   