func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   class FenwickTree {    private:     vector<T> bit;     int M;       public:     FenwickTree(int M) : bit(vector<T>(M + 1, 0)), M(M) {}     int sum(int i) {       if (!i) return 0;       return bit[i] + sum(i - (i & -i));     }     void add(int i, T x) {       if (i > M) return;       bit[i] += x;       add(i + (i & -i), x);     }   };   int main() {     ios::sync_with_stdio(false);     int N;     cin >> N;     vector<int> X1(N), X2(N), Y1(N), Y2(N);     map<int, int> Yc;     set<int> Ys;     vector<int> YI;     map<int, vector<int>> Ha, He;     map<int, vector<pair<int, int>>> V, H;     set<int> cand;     YI.push_back(-1 << 30);     for (int i = 0; i < N; ++i) {       int x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       if (x2 < x1) swap(x1, x2);       if (y2 < y1) swap(y1, y2);       YI.push_back(y1 - 1);       YI.push_back(y1);       YI.push_back(y1 + 1);       YI.push_back(y2 - 1);       YI.push_back(y2);       YI.push_back(y2 + 1);       X1[i] = x1, X2[i] = x2, Y1[i] = y1, Y2[i] = y2;     }     sort((YI.begin()), (YI.end()));     YI.erase(unique(YI.begin(), YI.end()), YI.end());     for (int i = 0; i < N; ++i) {       Y1[i] = lower_bound((YI.begin()), (YI.end()), Y1[i]) - YI.begin();       Y2[i] = lower_bound((YI.begin()), (YI.end()), Y2[i]) - YI.begin();       if (X1[i] == X2[i]) {         V[X1[i]].push_back({Y1[i], Y2[i]});         cand.insert(X1[i]);       } else {         Ha[X1[i]].push_back(Y1[i]);         He[X2[i]].push_back(Y1[i]);         H[Y1[i]].push_back({X1[i], X2[i]});         cand.insert(X1[i]);         cand.insert(X2[i]);       }     }     FenwickTree<signed long long> bt(YI.size());     signed long long ret = 0;     for (auto cx : cand) {       for (auto y : Ha[cx])         if (Yc[y]++ == 0) bt.add(y, 1);       if (V.count(cx)) {         vector<pair<int, int>>& T = V[cx];         sort((T.begin()), (T.end()));         int ma = -1 << 30;         for (auto r : T) {           r.first = max(r.first, ma + 1);           if (r.first > r.second) continue;           ret += YI[r.second] - YI[r.first] + 1;           ret -= bt.sum(r.second) - bt.sum(r.first - 1);           ma = r.second;         }       }       for (auto y : He[cx])         if (--Yc[y] == 0) bt.add(y, -1);     }     for (auto hy : H) {       vector<pair<int, int>>& T = hy.second;       sort((T.begin()), (T.end()));       int ma = -1 << 30;       for (auto r : T) {         r.first = max(r.first, ma + 1);         if (r.first > r.second) continue;         ret += r.second - r.first + 1;         ma = r.second;       }     }     cout << ret << endl;   }   