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: Accepted)

#include <iostream>
#include <vector>
#include <string.h>
using namespace std;
int n, m, i, j, k, l, t, len=0, s=0, appeared[26]={0};
vector<int> cutoff;
char a[200010], temp;
int main(){
	cin>>a;
	n=strlen(a);
	for(i=n-1;i>=0;i--){
		if(appeared[a[i]-'a']==0){
			appeared[a[i]-'a']=1;
			s++;
		}
		if(s==26){
			cutoff.push_back(i);
			for(j=0;j<=25;j++) appeared[j]=0;
			s=0;
			len++;
		} 
	}
	for(i=0;i<=25;i++) appeared[i]=0;
	j=0;
	for(i=len-1;i>=0;i--){
		for(;j<=cutoff[i]-1&&j<=n-1;j++) appeared[a[j]-'a']=1;
		for(k=0;k<=25;k++){
			if(appeared[k]==0){
				temp='a'+k;
				cout<<temp;
				for(l=0;l<=25;l++) appeared[l]=0;
				break;
			}
		}
		for(;;j++) if(a[j]==temp) break;
		j++;
	}
	for(;j<=n-1;j++) appeared[a[j]-'a']=1;
	for(k=0;k<=25;k++){
			if(appeared[k]==0){
				temp='a'+k;
				cout<<temp;
				for(l=0;l<=25;l++) appeared[l]=0;
				break;
			}
		}
	return 0;
}