Language: C++

#include <stdio.h>
#include <map>

int main() {
  int ans = 0, n = 0;
  scanf("%d", &n);
  std::map<int, int> val;
  for (int i = 0; i < n; i++) {
  	int x;
    scanf("%d", &x);
    x = -x;
    auto iter = val.upper_bound(x);
    if (iter == val.end()) {
      val[x] = 1;
    } else {
      iter->second--;
      if (iter->second == 0) {
        val.erase(iter);
      }
      if (val.find(x) == val.end) {
        val[x] = 1;
      } else {
        val[x] += 1;
      }
    }
  }
  printf("%d\n", val.size());
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:23: error: no match for 'operator==' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and '<unresolved overloaded function type>')
   20 |       if (val.find(x) == val.end) {
      |           ~~~~~~~~~~~ ^~ ~~~~~~~
      |                   |          |
      |                   |          <unresolved overloaded function type>
      |                   std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator}
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/bits/stl_tree.h:64,
                 from /usr/include/c++/14/map:62,
                 from a.cc:2:
/usr/include/c++/14/bits/new_allocator.h:215:9: note: candidate: 'template<class _Up> bool std::operator==(const __new_allocator<pair<const int, int> >&, const __new_allocator<_Tp>&)'
  215 |         operator==(const __new_allocator&, const __new_allocator<_Up>&)
      |         ^~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:215:9: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   mismatched types 'const std::__new_allocator<_Tp>' and 'std::map<int, int>::const_iterator (std::map<int, int>::*)() const noexcept' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::const_iterator (std::map<int, int>::*)() const noexcept'}
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
a.cc:20:30: note:   mismatched types 'const std::__new_allocator<_Tp>' and 'std::map<int, int>::iterator (std::map<int, int>::*)() noexcept' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator (std::map<int, int>::*)() noexcept'}
a.cc:20:30: note:   couldn't deduce template parameter '_Up'
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/stl_tree.h:63:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_Tp1>&, const allocator<_T2>&)'
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::allocator<_Tp1>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
In file included from /usr/include/c++/14/bits/stl_map.h:63,
                 from /usr/include/c++/14/map:63:
/usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_Args1 ...>&, const tuple<_Elements ...>&)'
 2558 |     operator==(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2558:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::tuple<_Args1 ...>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/stl_map.h:1512:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const map<_Key, _Tp, _Compare, _Allocator>&, const map<_Key, _Tp, _Compare, _Allocator>&)'
 1512 |     operator==(const map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1512:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::map<_Key, _Tp, _Compare, _Allocator>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1134:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator==(const multimap<_Key, _Tp, _Compare, _Allocator>&, const multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1134 |     operator==(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_multimap.h:1134:5: note:   template argument deduction/substitution failed:
a.cc:20:30: note:   'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::multimap<_Key, _Tp, _Compare, _Allocator>'
   20 |       if (val.find(x) == val.end) {
      |                              ^~~
/usr/include/c++/14/bits/stl_tree.h:311:7: note: candidate: 'bool std::operator==(const _Rb_tree_iterator<pair<const int, int> >::_Self&, const _Rb_tree_iterator<pair<const int, int> >::_Self&)'
  311 |       operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:311:49: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const std::_Rb_tree_iterator<std::pair<const int, int> >::_Self&'
  311 |       operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
      |                                    ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:392:7: note: candidate: 'bool std::operator==(const _Rb_tree_const_iterator<pair<const int, int> >