Language: C++

#include <bits/stdc++.h>
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[i];
     for (int i = 0; i < N; i++) cin >> B[i];
     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 ans = 0;

     for (int i = 0; i < N; i++) {
         int b = B[i];
         int *pos_a, *pos_c, dis_a, dis_c;

         pos_a = lower_bound(A.begin(), A.end(), b);
         pos_c = upper_bound(C.begin(), C.end(), b);

         dis_a = distance(A.begin(), pos_a);
         dis_c = distance(pos_c, C.end());

         ans += dis_a * dis_c;
     }

     cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:29: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in assignment
   21 |          pos_a = lower_bound(A.begin(), A.end(), b);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                             |
      |                             __gnu_cxx::__normal_iterator<int*, std::vector<int> >
a.cc:22:29: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in assignment
   22 |          pos_c = upper_bound(C.begin(), C.end(), b);
      |                  ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
      |                             |
      |                             __gnu_cxx::__normal_iterator<int*, std::vector<int> >
a.cc:24:26: error: no matching function for call to 'distance(std::vector<int>::iterator, int*&)'
   24 |          dis_a = distance(A.begin(), pos_a);
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note: candidate: 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:   template argument deduction/substitution failed:
a.cc:24:26: note:   deduced conflicting types for parameter '_InputIterator' ('__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'int*')
   24 |          dis_a = distance(A.begin(), pos_a);
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/filesystem:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_path.h:1431:1: note: candidate: 'std::ptrdiff_t std::distance(filesystem::__cxx11::path::iterator, filesystem::__cxx11::path::iterator)'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
/usr/include/c++/14/bits/fs_path.h:1431:37: note:   no known conversion for argument 1 from 'std::vector<int>::iterator' to 'std::filesystem::__cxx11::path::iterator'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:25:26: error: no matching function for call to 'distance(int*&, std::vector<int>::iterator)'
   25 |          dis_c = distance(pos_c, C.end());
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note: candidate: 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator)'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: note:   template argument deduction/substitution failed:
a.cc:25:26: note:   deduced conflicting types for parameter '_InputIterator' ('int*' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
   25 |          dis_c = distance(pos_c, C.end());
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/fs_path.h:1431:1: note: candidate: 'std::ptrdiff_t std::distance(filesystem::__cxx11::path::iterator, filesystem::__cxx11::path::iterator)'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      | ^~~~~~~~
/usr/include/c++/14/bits/fs_path.h:1431:37: note:   no known conversion for argument 1 from 'int*' to 'std::filesystem::__cxx11::path::iterator'
 1431 | distance(filesystem::path::iterator __first, filesystem::path::iterator __last)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~