Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
const int mod=1e9+7;
int next[Maxn<<1][26];
int dp[Maxn<<1];
char str[Maxn<<1];
int main()
{
	//input;output;
	while(~scanf("%s",str))
	{
		memset(dp,inf,sizeof(dp));
		memset(next,0,sizeof(next));
		int len=strlen(str);
		for(int i=0;i<26;i++)
			next[len][i]=len;
		dp[len+1]=0;
		for(int i=len-1;i>=0;i--)
			for(int j=0;j<26;j++)
			{
				next[i][j]=str[i]=='a'+j?i:next[i+1][j];
				dp[i]=min(dp[i],dp[next[i][j]+1]+1);
			}
		int pos=0;
		while(pos<len)
		{
			for(int i=0;i<26;i++)
			{
				if(dp[pos]==dp[next[pos][i]+1]+1)
				{
					pos=next[pos][i]+1;
					putchar('a'+i);
					break;
				}
			}
		}
		puts("");
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:24: error: reference to 'next' is ambiguous
   38 |                 memset(next,0,sizeof(next));
      |                        ^~~~
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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:38:38: error: reference to 'next' is ambiguous
   38 |                 memset(next,0,sizeof(next));
      |                                      ^~~~
/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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:41:25: error: reference to 'next' is ambiguous
   41 |                         next[len][i]=len;
      |                         ^~~~
/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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:46:33: error: reference to 'next' is ambiguous
   46 |                                 next[i][j]=str[i]=='a'+j?i: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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:46:60: error: reference to 'next' is ambiguous
   46 |                                 next[i][j]=str[i]=='a'+j?i: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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:47:52: error: reference to 'next' is ambiguous
   47 |                                 dp[i]=min(dp[i],dp[next[i][j]+1]+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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:54:48: error: reference to 'next' is ambiguous
   54 |                                 if(dp[pos]==dp[next[pos][i]+1]+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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~
a.cc:56:45: error: reference to 'next' is ambiguous
   56 |                                         pos=next[pos][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:29:5: note:                 'int next [200010][26]'
   29 | int next[Maxn<<1][26];
      |     ^~~~