Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	ll A[114514], B[114514], C[114514];

	cin >> N;
	REP(i, N){
		cin >> A[i];
	}
	REP(i, N)
		cin >> B[i];
	REP(i, N)
		cin >> C[i];

	sort(A, A+N);
	sort(B, B+N);
	sort(C, C+N);

	ll cnt[114514] = {};
	for(int i = N-1;i >= 0;i--){
		cnt[i] = cnt[i+1]+(N-min((ll)(upper_bound(C, C+N, B[i])-C), N));
	}
	ll res = 0;
	for(int i = N-1;i >= 0;i--){
		res += cnt[upper_bound(B, B+N, A[i])-B];
	}
	cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:41: error: no matching function for call to 'min(ll, int&)'
   51 |                 cnt[i] = cnt[i+1]+(N-min((ll)(upper_bound(C, C+N, B[i])-C), N));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:51:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |                 cnt[i] = cnt[i+1]+(N-min((ll)(upper_bound(C, C+N, B[i])-C), N));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:51:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |                 cnt[i] = cnt[i+1]+(N-min((ll)(upper_bound(C, C+N, B[i])-C), N));
      |                                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~