func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 10009;   const int D = 5001;   int n;   vector<vector<pair<int, int>>> hs(N, vector<pair<int, int>>());   vector<vector<pair<int, int>>> vs(N, vector<pair<int, int>>());   vector<vector<int>> ds(N, vector<int>());   class FenwickTree {    public:     FenwickTree(int n) { arr.assign(n + 1, 0); }     int rsq(int a) {       int res = 0;       for (; a; a -= LSOne(a)) {         res += arr[a];       }       return res;     }     int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }     void update(int a, int c) {       for (; a < arr.size(); a += LSOne(a)) {         arr[a] += c;       }     }       private:     vector<int> arr;     int LSOne(int a) { return ((a) & (-a)); }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       x1 += D;       x2 += D;       y1 += D;       y2 += D;       if (x1 == x2) {         vs[x1].emplace_back(min(y1, y2), max(y1, y2));       } else {         hs[y1].emplace_back(min(x1, x2), max(x1, x2));       }     }     long long res = 0;     for (int i = 1; i < N; ++i)       for (auto h : hs[i]) {         int l = h.first;         int r = h.second;         for (int j = 0; j < N; ++j) ds[j].clear();         FenwickTree ft(N);         for (int x = l; x <= r; ++x)           for (auto v : vs[x]) {             if (v.first <= i && v.second > i) {               ft.update(x, 1);               ds[v.second].push_back(x);             }           }         for (int y = i + 1; y < N; y++) {           for (auto h : hs[y]) {             int s = ft.rsq(h.first, h.second);             res += (s * (s - 1)) / 2ll;           }           for (int v : ds[y]) {             ft.update(v, -1);           }         }       }     cout << res << endl;     return 0;   }   