Language: C++

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N;
    cin >> N;

    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    vector<int> B(N);
    for (int i = 0; i < N; ++i) cin >>B[i];

    vector<int> C(N);
    for (int i = 0; i < N; ++i) cin >>C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    int result = 0;
    for (int b : B) {
        int i = lower_bound(A.begin(), A.end(), b) - A.begin();

         int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();

         result += i * j;
    }

    cout << result << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:20: error: no match for 'operator-' (operand types are 'int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   28 |          int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();
      |                  ~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                  |              |
      |                  int            __gnu_cxx::__normal_iterator<int*, std::vector<int> >
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:28:55: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'int'
   28 |          int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:28:55: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'int'
   28 |          int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> decltype ((__lhs.base() - __rhs.base())) __gnu_cxx::operator-(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
 1312 |     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1312:5: note:   template argument deduction/substitution failed:
a.cc:28:55: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' and 'int'
   28 |          int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();
      |                                                       ^
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note: candidate: 'template<class _Iterator, class _Container> typename __gnu_cxx::__normal_iterator<_Iterator, _Container>::difference_type __gnu_cxx::operator-(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
 1325 |     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1325:5: note:   template argument deduction/substitution failed:
a.cc:28:55: note:   mismatched types 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' and 'int'
   28 |          int j = N - upper_bound(C.begin(), C.end(), b) - C.begin();
      |                                                       ^