Language: C++

#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
char s[MAXN];
int ok[MAXN],last[28],dp[MAXN];
int next[MAXN][28],len=INF,arr[5];
bool subset(){
	int pos=1;
	for(int i=1;i<=len;i++){
		if(next[pos][arr[i]])
			pos=next[pos][arr[i]]+1;
		else
			return 0;
	}return 1;
}
void rec(int pos){
	if(pos>len){
		if(subset())
			return;
		for(int i=1;i<=len;i++)
			printf("%c",char(97+arr[i]));
		puts("");exit(0);	
	}
	for(int i=0;i<26;i++)
		arr[pos]=i,rec(pos+1);
}
int main(){
    //~ freopen("file.in", "r", stdin);
    scanf("%s",s+1);
    int n=strlen(s+1),mask=0;
    for(int i=n;i>=1;i--){
		ok[i]=1;
		mask|=1<<(s[i]-'a');
		if(mask==67108863)
			break;
		if(i==1){
			for(int j=0;j<26;j++)
				if(!(mask>>j&1))
					return 0*printf("%c",char(j+97));
		}
	}
	for(int i=n;i>=1;i--){
		next[i][s[i]-'a']=i;
		for(int j=0;j<26;j++)
			if(s[i]-'a'!=j)
				next[i][j]=next[i+1][j];
	}
	for(int i=1;i<=n;i++){
		dp[i]=INF;
		for(int j=last[s[i]-'a'];j<i;j++)
			umin(dp[i],dp[j]+1);	
		last[s[i]-'a']=i;
		if(ok[i])
			umin(len,dp[i]+1);
	}rec(1);
	return 0;
}


Compiler output:
a.cc: In function 'bool subset()':
a.cc:26:20: error: reference to 'next' is ambiguous
   26 |                 if(next[pos][arr[i]])
      |                    ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:22:5: note:                 'int next [100009][28]'
   22 | int next[MAXN][28],len=INF,arr[5];
      |     ^~~~
a.cc:27:29: error: reference to 'next' is ambiguous
   27 |                         pos=next[pos][arr[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:22:5: note:                 'int next [100009][28]'
   22 | int next[MAXN][28],len=INF,arr[5];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:59:17: error: reference to 'next' is ambiguous
   59 |                 next[i][s[i]-'a']=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:22:5: note:                 'int next [100009][28]'
   22 | int next[MAXN][28],len=INF,arr[5];
      |     ^~~~
a.cc:62:33: error: reference to 'next' is ambiguous
   62 |                                 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:22:5: note:                 'int next [100009][28]'
   22 | int next[MAXN][28],len=INF,arr[5];
      |     ^~~~
a.cc:62:44: error: reference to 'next' is ambiguous
   62 |                                 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:22:5: note:                 'int next [100009][28]'
   22 | int next[MAXN][28],len=INF,arr[5];
      |     ^~~~