Problem:
Score : 600 points

Problem Statement

A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.
For example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.

You are given a string A consisting of lowercase English letters.
Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of A.
If there are more than one such string, find the lexicographically smallest one among them.

Constraints

1 \leq |A| \leq 2 \times 10^5

A consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

A

Output

Print the lexicographically smallest string among the shortest strings consisting of lowercase English letters that are not subsequences of A.

Sample Input 1

atcoderregularcontest

Sample Output 1

b

The string atcoderregularcontest contains a as a subsequence, but not b.

Sample Input 2

abcdefghijklmnopqrstuvwxyz

Sample Output 2

aa

Sample Input 3

frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn

Sample Output 3

aca

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 2e5+17;
const int MOD = 1e9+7;
int dp[MAXN],nxt[MAXN][26+3],ocr[26+3];
int main(int argc ,char const *argv[])
{
	#ifdef noob
	freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
	#endif	
	string str;
	cin>>str;
	int n = str.length();
	for (int i = 0; i < 26; ++i)
	{
		ocr[i] = n;
	}
	dp[n]=1;
	for (int i = n-1; i > -1; --i)
	{
		ocr[str[i]-'a'] = i;
		for (int j = 0; j < 26; ++j)
		{
			nxt[i][j] = ocr[j];
		}
		dp[i] = MOD;
		
	}
	// debug(nxt[0][25]);
	for (int i = n-1; i > -1; --i)
	{
		for (int j = 0; j < 26; ++j)
		{
			
			dp[i] = min(dp[i],dp[nxt[i][j]+1]+1);
		// 	if(i==0)
		// 	{

		// 		debug(j);
		// 		debug(dp[i]);
		// 		debug(nxt[i][j]);
		// 	}
		}
		// debug(i);
		// debug(dp[i]);
	}
	// debug(dp[0]);
	for (int i = 0; i < n&&dp[0]; --dp[0])
	{
		for (int j = 0; j < 26; ++j)
		{
			if(dp[i]==dp[nxt[i][j]+1]+1)
			{
				printf("%c",j+'a');
				i = nxt[i][j];
				break;
			}
		}
	}
	return 0;	
}