Language: C++

#include <stdio.h>
#include <algorithm>
using namespace std;
int n, ptr, ret, a[200000], b[200000], prev[200001];
int main() {
	scanf("%d", &n); ret = n;
	for(int i = 0; i < n; i++) scanf("%d", &a[i]), b[i] = a[i];
	sort(b, b + n);
	for(int i = 0; i < n; i++) ptr = lower_bound(b, b + n, a[i]), a[i] = ptr + 1;
	for(int i = 1; i <= n; i++) prev[i] = -1;
	for(int i = 0; i < n; i++) {
		if(prev[a[i]] != -1) {
			for(int j = i - 1; j >= prev[a[i]]; j--) {
				if(a[j] < a[i]) break;
				if(a[j] == a[i]) { ret--; break; }
			}
		}
		prev[a[i]] = i;
	}
	printf("%d\n", ret);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:53: error: invalid conversion from 'int*' to 'int' [-fpermissive]
    9 |         for(int i = 0; i < n; i++) ptr = lower_bound(b, b + n, a[i]), a[i] = ptr + 1;
      |                                          ~~~~~~~~~~~^~~~~~~~~~~~~~~~
      |                                                     |
      |                                                     int*
a.cc:10:37: error: reference to 'prev' is ambiguous
   10 |         for(int i = 1; i <= n; i++) prev[i] = -1;
      |                                     ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:4:40: note:                 'int prev [200001]'
    4 | int n, ptr, ret, a[200000], b[200000], prev[200001];
      |                                        ^~~~
a.cc:12:20: error: reference to 'prev' is ambiguous
   12 |                 if(prev[a[i]] != -1) {
      |                    ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:4:40: note:                 'int prev [200001]'
    4 | int n, ptr, ret, a[200000], b[200000], prev[200001];
      |                                        ^~~~
a.cc:13:49: error: reference to 'prev' is ambiguous
   13 |                         for(int j = i - 1; j >= prev[a[i]]; j--) {
      |                                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:4:40: note:                 'int prev [200001]'
    4 | int n, ptr, ret, a[200000], b[200000], prev[200001];
      |                                        ^~~~
a.cc:18:17: error: reference to 'prev' is ambiguous
   18 |                 prev[a[i]] = i;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:4:40: note:                 'int prev [200001]'
    4 | int n, ptr, ret, a[200000], b[200000], prev[200001];
      |                                        ^~~~