Language: C++

#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
using namespace std;
using ll=long long;

int main(){
	const int m=100010;
	int n,tmp=m;
	ll a[m],b[m],c[m],count=0;
	bool f;

	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)cin>>b[i];
	sort(b,b+n);
	for(int i=0;i<n;i++)cin>>c[i];
	sort(c,c+n);

	for(int i=n-1;i>=0;i--){//c
		if(tmp==0)break;
		for(int j=0;j<n;j++){//b
			if(c[i]<=b[j]){
				tmp=j;
				break;
			}
			auto itr = upper_bound(c[0],b[n-1],b[j]);
			count+=itr;
		}
	}
	cout<<count<<endl;
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = long long int; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Val_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:2028:32:   required from '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = long long int; _Tp = long long int]'
 2028 |       return std::__upper_bound(__first, __last, __val,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 2029 |                                 __gnu_cxx::__ops::__val_less_iter());
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:26:   required from here
   30 |                         auto itr = upper_bound(c[0],b[n-1],b[j]);
      |                                    ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1984:9: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>'
 1984 |         _DistanceType;
      |         ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1986:42: error: no matching function for call to 'distance(long long int&, long long int&)'
 1986 |       _DistanceType __len = std::distance(__first, __last);
      |                             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h: In substitution of 'template<class _InputIterator> constexpr typename std::iterator_traits< <template-parameter-1-1> >::difference_type std::distance(_InputIterator, _InputIterator) [with _InputIterator = long long int]':
/usr/include/c++/14/bits/stl_algo.h:1986:42:   required from '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = long long int; _Tp = long long int; _Compare = __gnu_cxx::__ops::_Val_less_iter]'
 1986 |       _DistanceType __len = std::distance(__first, __last);
      |                             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2028:32:   required from '_FIter std::upper_bound(_FIter, _FIter, const _Tp&) [with _FIter = long long int; _Tp = long long int]'
 2028 |       return std::__upper_bound(__first, __last, __val,
      |              ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 2029 |                                 __gnu_cxx::__ops::__val_less_iter());
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:26:   required from here
   30 |                         auto itr = upper_bound(c[0],b[n-1],b[j]);
      |                                    ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:148:5: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>'
  148 |     distance(_InputIterator __first, _InputIterator __last)
      |     ^~~~~~~~