Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  set<int> a, b, c;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    a.insert(x);
  }
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    b.insert(x);
  }
  for (int i = 0; i < n; i++) {
    int x; cin >> x;
    c.insert(x);
  }
  
  int ans = 0;
  for (auto ea: a) {
    auto itb = b.upper_bound(a);
    if (itb == b.end()) break;
    auto itc = c.upper_bound(*itb);
    if (itc == c.end()) break;
    else {
      ans++;
      b.erase(itb);
      c.erase(itc);
    }
  }
  
  cout << ans << endl;
  return 0;
}	

Compiler output:
a.cc: In function 'int main()':
a.cc:25:29: error: no matching function for call to 'std::set<int>::upper_bound(std::set<int>&)'
   25 |     auto itb = b.upper_bound(a);
      |                ~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:871:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_upper_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::upper_bound(const _Kt&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  871 |         upper_bound(const _Kt& __x)
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:871:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<int>::iterator)(((std::set<int>*)this)->std::set<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(__x))) std::set<int>::upper_bound(const _Kt&) [with _Kt = std::set<int>]':
a.cc:25:29:   required from here
   25 |     auto itb = b.upper_bound(a);
      |                ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:872:52: error: no matching function for call to 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(const std::set<int>&)'
  872 |         -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
      |                              ~~~~~~~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152:
/usr/include/c++/14/bits/stl_tree.h:1347:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_upper_bound_tr(const _Kt&) [with _Req = _Kt; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
 1347 |         _M_upper_bound_tr(const _Kt& __k)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1347:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<int>; _SfinaeType = std::set<int>]':
/usr/include/c++/14/bits/stl_tree.h:1345:9:   required by substitution of 'template<class _Kt> decltype ((std::set<int>::iterator)(((std::set<int>*)this)->std::set<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(__x))) std::set<int>::upper_bound(const _Kt&) [with _Kt = std::set<int>]'
 1345 |                typename _Req = __has_is_transparent_t<_Compare, _Kt>>
      |                ^~~~~~~~
a.cc:25:29:   required from here
   25 |     auto itb = b.upper_bound(a);
      |                ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<int>, std::set<int>, void>'
 1427 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<int>::iterator)(((std::set<int>*)this)->std::set<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(__x))) std::set<int>::upper_bound(const _Kt&) [with _Kt = std::set<int>]':
a.cc:25:29:   required from here
   25 |     auto itb = b.upper_bound(a);
      |                ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:1356:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_upper_bound_tr(const _Kt&) const [with _Req = _Kt; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
 1356 |         _M_upper_bound_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1356:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h:877:9: note: candidate: 'template<class _Kt> decltype ((std::set<_Key, _Compare, _Alloc>::iterator)(((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_upper_bound_tr(__x))) std::set<_Key, _Compare, _Alloc>::upper_bound(const _Kt&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  877 |         upper_bound(const _Kt& __x) const
      |         ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:877:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h: In substitution of 'template<class _Kt> decltype ((std::set<int>::iterator)(((const std::set<int>*)this)->std::set<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(__x))) std::set<int>::upper_bound(const _Kt&) const [with _Kt = std::set<int>]':
a.cc:25:29:   required from here
   25 |     auto itb = b.upper_bound(a);
      |                ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:878:52: error: no matching function for call to 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_upper_bound_tr(const std::set<int>&) const'
  878 |         -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
      |                              ~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1347:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_upper_bound_tr(const _Kt&) [with _Req = _Kt; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
 1347 |         _M_upper_bound_tr(const _Kt& __k)
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1347:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1356:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_upper_bound_tr(const _Kt&) const [with _Req = _Kt; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
 1356 |         _M_upper_bound_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1356:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_set.h:861:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::upper_bound(const key_type&) [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; key_type = int]'
  861 |       upper_bound(const key_type& __x)
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:861:35: note:   no known conversion for argument 1 from 'std::set<int>' to 'const std::set<int>::key_type&' {aka 'const int&'}
  861 |       upper_bound(const key_type& __x)
      |                   ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:865:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::upper_bound(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator; key_type = int]'
  865 |       upper_bound(const key_type& __x) const
      |       ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:865:35: note:   no known conversion for argument 1 from 'std::set<int>' to 'const std::set<int>::key_type&' {aka 'const int&'}
  865 |       upper_bound(const key_type& __x) const
      |                   ~~~~~~~~~~~~~~~~^~~