Language: C++

#include <bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define INF (ll)9999999999999999

#define eb emplace_back
#define all(x) begin(x), end(x)
#define len(x) ((int)(x).size())
#define exist(a, x) (a.find(x) != end(a))
#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i,a,b) for (int i = (int)a; i >= (int)b; --i)
#define loop(i,a,b) for(int i = (int)(a); i < (int)(b); ++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;


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

	vi a(n),b(n),c(n);

	rep(i,n) cin>>a[i];
	rep(i,n) cin>>b[i];
	rep(i,n) cin>>c[i];
	sort(all(a)), sort(all(c));

	ll x, i1, i2, c1, c2, cnt = 0;
	rep (i, n) {
		x = b[i];
		i1 = min(distance(begin(a), upper_bound(all(a), x-1)), n-1);
		i2 = distance(begin(c), lower_bound(all(c), x+1));
		while (a[i1]>=x && i1>0) --i1;

		if (a[i1] < x and x < c[i2]) {
			c1 = i1+1;
			c2 = n-i2;
			cnt += c1 * c2;
		}
	}

	log(cnt);

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:25: error: no matching function for call to 'min(std::__iterator_traits<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, void>::difference_type, int)'
   35 |                 i1 = min(distance(begin(a), upper_bound(all(a), x-1)), n-1);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included 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_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:35:25: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
   35 |                 i1 = min(distance(begin(a), upper_bound(all(a), x-1)), n-1);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:35:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   35 |                 i1 = min(distance(begin(a), upper_bound(all(a), x-1)), n-1);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~