Language: C++

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
using namespace std;

const int INF=1e9;

int next[26][200005];
int last[26];
int dp[200005];

string s;

int find(int i){
	if(i>s.length()) return 0;
	if(dp[i]<INF) return dp[i];
	for(int j=0;j<26;j++){
		dp[i]=min(dp[i],find(next[j][i]+1)+1);
	}
return dp[i];
}

int main(){
	fill(last,last+26,INF);
	fill(dp,dp+200005,INF);
	cin>>s;
	for(int i=s.length()-1;i>=0;i--){
		last[s[i]-'a']=i;
		for(int j=0;j<26;j++) next[j][i]=last[j];
	}
	find(0);
	int len=dp[0],pos=0;
	string ans;
	while(len){
		if(len==1){
			for(int i=0;i<26;i++){
				if(next[i][pos]>=s.length()) {
					ans+=char(i+'a');
					break;
				}
			}
		}
		else{
			for(int i=0;i<26;i++){
				if(dp[next[i][pos]+1]+1==dp[pos]){
					pos=next[i][pos]+1;
					ans+=char(i+'a');
					break;
				}
			}
		}
		len--;
	}
	cout<<ans<<endl;
return 0;
}

Compiler output:
a.cc: In function 'int find(int)':
a.cc:34:38: error: reference to 'next' is ambiguous
   34 |                 dp[i]=min(dp[i],find(next[j][i]+1)+1);
      |                                      ^~~~
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:24:5: note:                 'int next [26][200005]'
   24 | int next[26][200005];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:45:39: error: reference to 'next' is ambiguous
   45 |                 for(int j=0;j<26;j++) next[j][i]=last[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:24:5: note:                 'int next [26][200005]'
   24 | int next[26][200005];
      |     ^~~~
a.cc:53:36: error: reference to 'next' is ambiguous
   53 |                                 if(next[i][pos]>=s.length()) {
      |                                    ^~~~
/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:24:5: note:                 'int next [26][200005]'
   24 | int next[26][200005];
      |     ^~~~
a.cc:61:39: error: reference to 'next' is ambiguous
   61 |                                 if(dp[next[i][pos]+1]+1==dp[pos]){
      |                                       ^~~~
/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:24:5: note:                 'int next [26][200005]'
   24 | int next[26][200005];
      |     ^~~~
a.cc:62:45: error: reference to 'next' is ambiguous
   62 |                                         pos=next[i][pos]+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:24:5: note:                 'int next [26][200005]'
   24 | int next[26][200005];
      |     ^~~~