Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 200001
#include<cstring>
using namespace std;
char s[N],ans[N];
int next[N][26];
int d[N*10],from[N*10];
int n;
int main(){
	scanf(" %s",s+1);
	n=strlen(s+1);
	for (int i=n-1;i>=0;i--){
		for (int j=0;j<26;j++)next[i][j]=next[i+1][j];
		next[i][s[i+1]-'a']=i+1;
	}
	int l=0,r=1;
	while (1){
		l++;
		for (int i=0;i<26;i++)
			if (!next[d[l]][i]){
				int tot=0;
				ans[++tot]=i+'a';
				while (l!=1){
					ans[++tot]=s[d[l]];
					l=from[l];
				}
				while (tot)printf("%c",ans[tot--]);
				return 0;
			}else
				d[++r]=next[d[l]][i],from[r]=l;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:39: error: reference to 'next' is ambiguous
   15 |                 for (int j=0;j<26;j++)next[i][j]=next[i+1][j];
      |                                       ^~~~
In file included from /usr/include/c++/14/string:47,
                 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_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [200001][26]'
    8 | int next[N][26];
      |     ^~~~
a.cc:15:50: error: reference to 'next' is ambiguous
   15 |                 for (int j=0;j<26;j++)next[i][j]=next[i+1][j];
      |                                                  ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [200001][26]'
    8 | int next[N][26];
      |     ^~~~
a.cc:16:17: error: reference to 'next' is ambiguous
   16 |                 next[i][s[i+1]-'a']=i+1;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [200001][26]'
    8 | int next[N][26];
      |     ^~~~
a.cc:22:30: error: reference to 'next' is ambiguous
   22 |                         if (!next[d[l]][i]){
      |                              ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [200001][26]'
    8 | int next[N][26];
      |     ^~~~
a.cc:32:40: error: reference to 'next' is ambiguous
   32 |                                 d[++r]=next[d[l]][i],from[r]=l;
      |                                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int next [200001][26]'
    8 | int next[N][26];
      |     ^~~~