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 <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1000;
char a[N];
int vis[30];
struct point {
	int p;
	int id;
	bool operator < (const point& w) const {
		return p < w.p;
	}
}pos[30];

int main() {
	//freopen("i.txt","r",stdin);
	cin>>a;
	int len = strlen(a);
	memset(vis,0,sizeof(vis));
	int cnt = 0, l, r;
	
	for(int i=0;i<26;i++)pos[i].id = i;
	for(int i=0;i<len;i++) {
		if(!vis[a[i] - 'a'])vis[a[i] - 'a']	= 1, pos[a[i] - 'a'].p = i, cnt ++;
		if(cnt == 26)break;
	}
	if(cnt < 26) {
		for(int i=0;i<26;i++)
			if(!vis[i]) {
				printf("%c\n",'a' + i);
				break;
			}
		return 0;
	}
	sort(pos,pos+26);
	int ans1 = 50; char ans2;
	bool flag = false;
	cnt = 0, l = 0, r = 25;
	memset(vis,0,sizeof(vis));
	for(int i=len-1;i>=0;i--) {
		if(r >= 0 && i <= pos[r].p) {
			flag = true;
			if(ans1 > pos[r].id) {
				ans1 = pos[r].id;
				for(int j=0;j<26;j++)
					if(!vis[j]) {
						ans2 = 'a' + j;
						break;
					}
			}
			r--;
		}
		if(!vis[a[i] - 'a'])vis[a[i] - 'a']	= 1, cnt ++;
		if(cnt == 26) {
			if(flag)break;
			memset(vis,0,sizeof(vis));
			cnt = 0, l ++;
		}
	}
	
	printf("%c%c",ans1+'a',ans2);
	for(int i=0;i<l;i++)printf("a");
	printf("\n");
	return 0;
}