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: Runtime Error)

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5, L = 400;

int n;
char s[N];
bool all[L][N];
int nxt[N][26];

void solve(int len) {
	int pos = 1;
	for(; len; --len) {
		for(int j = 0; j < 26; ++j) {
			if(!nxt[pos][j]) {
				for(; len; --len) {
					cout << char(j + 'a');
				}
				exit(0);
			} else {
				int go = nxt[pos][j];
				if(!all[len][go]) {
					pos = go + 1;
					cout << char(j + 'a');
					break;
				}
			}
		}
	}
}
int main() {
   // freopen("ghiozdan.in", "r", stdin);
	cin >> (s + 1);
	n = strlen(s + 1);
	for(int i = n; i; --i) {
		for(int j = 0; j < 26; ++j) {
			if(s[i] - 'a' == j) nxt[i][j] = i;
			else nxt[i][j] = nxt[i + 1][j];
		}
	}

	for(int i = 1; i <= n; ++ i) {
		all[1][i] = 1;
	}

	for(int i = 0; i < 26; ++i) if(!nxt[1][i]) {
			cout << char(i + 'a');
			exit(0);
		}

	for(int l = 2; l <= n; ++l) {
		int offs = 0;
		for(int i = n; i; --i) {
            all[l][i] = 1;
			for(int j = 0; j < 26; ++j) {
				int gg = nxt[i + 1][j];
				if(!gg || !all[l - 1][gg]) all[l][i] = 0;
			}
		}
		for(int j = 0; j < 26; ++j)
		{
		    int gg = nxt[1][j];
		    if(!all[l][gg])
            {
                solve(l);
                exit(0);
            }
		}
	}

}