Language: C++

#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;
int main()
{
        int N;
        cin >> N;
        vector<int> A(N), B(N), C(N);
        for (int i = 0; i < N; ++i)
        {
                cin >> A.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> B.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> C.at(i);
        }
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        sort(C.begin(), C.end());
        vector<int> can_put(N);
        for (int i = 0; i < N; ++i)
        {
                // can_put.at(i) = binaly_search(A, B.at(i)) + 1;

                auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
                long k1 = Iter1 - A.begin();
                can_put.at(i) = k1;
                // cout << can_put.at(i) << ",";
        }
        for (int i = 1; i < N; ++i)
        {
                can_put.at(i) = can_put.at(i - 1) + can_put.at(i);
        }
        // for (int i = 0; i < N; ++i)
        // {
        //   cout << can_put.at(i) << ",";
        // }
        int ans = 0;
        int num = 0;
        for (int i = 0; i < N; ++i)
        {
                auto Iter2 = lower_bound(B.begin(), B.end(), C[i]);
                long k2 = Iter2 - B.begin() - 1;
                // cout << num;
                if (k2 == -1)
                {
                  continue;
                }
                ans += can_put.at(k2);
        }
        cout << ans << endl;

}
#include <bits/stdc++.h>
// #pragma GCC optimize("Ofast")
using namespace std;
int main()
{
        int N;
        cin >> N;
        vector<int> A(N), B(N), C(N);
        for (int i = 0; i < N; ++i)
        {
                cin >> A.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> B.at(i);
        }
        for (int i = 0; i < N; ++i)
        {
                cin >> C.at(i);
        }
        sort(A.begin(), A.end());
        sort(B.begin(), B.end());
        sort(C.begin(), C.end());
        vector<int> can_put(N);
        for (int i = 0; i < N; ++i)
        {
                // can_put.at(i) = binaly_search(A, B.at(i)) + 1;

                auto Iter1 = lower_bound(A.begin(), A.end(), B[i]);
                long k1 = Iter1 - A.begin();
                can_put.at(i) = k1;
                // cout << can_put.at(i) << ",";
        }
        for (int i = 1; i < N; ++i)
        {
                can_put.at(i) = can_put.at(i - 1) + can_put.at(i);
        }
        // for (int i = 0; i < N; ++i)
        // {
        //   cout << can_put.at(i) << ",";
        // }
        long ans = 0;
        int num = 0;
        for (int i = 0; i < N; ++i)
        {
                auto Iter2 = lower_bound(B.begin(), B.end(), C[i]);
                long k2 = Iter2 - B.begin() - 1;
                // cout << num;
                if (k2 == -1)
                {
                  continue;
                }
                ans += can_put.at(k2);
        }
        cout << ans << endl;

}


Compiler output:
a.cc:61:5: error: redefinition of 'int main()'
   61 | int main()
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main()
      |     ^~~~