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;
int main()
{
    string s;
    cin>>s;
    
    long long int len=s.length();
    long long int num=1,now=1;
    string char1,char2,char3;
    string x="";
    set<string>str1;
    set<string>str2;
    set<string>str3;
    set<string>str4;
    set<string>::iterator it;
    if(len<=26)
    {
        for(long long int i=0;i<len;i++)
        {
            x=s[i];
            str1.insert(x);
            x="";
        }
            for(long long int j=0;j<len;j++)
            {
                char1='a'+j;
                x=char1;
                it=str1.find(x);
                
                if(it==str1.end())
                {cout<<x<<endl;x="";return 0;}
                x="";
            }          
    }
    else if (len<=676)
    {
        x=s[len-1];
        str1.insert(x);
        x="";
		for(long long int i=0;i<len-1;i++)
        {
            x=s[i];
            str1.insert(x);
            x=x+s[i+1];
            str2.insert(x);
            x="";
        }
            for(long long int j=0;j<26;j++)
            {
                char1='a'+j;
                x=char1;
                it=str1.find(x);
                if(it==str1.end())
                {cout<<x<<endl;return 0;}
                x="";
            }
            for(long long int j=0;j<26;j++)
            for(long long int l=0;l<26;l++)
            {
                char1='a'+j;
                x=char1;
                char2='a'+l;
                x=x+char2;
                it=str2.find(x);
                if(it==str2.end())
                {cout<<x<<endl;return 0;}
                x="";
            }
                  
    }
    else 
    {
        
        x=s[len-2];
        str1.insert(x);
        x=x+s[len-1];
        str2.insert(x);
        x="";
        x=s[len-1];
        str1.insert(x);
		for(long long int i=0;i<len-2;i++)
        {
            x=s[i];
            str1.insert(x);
            x=x+s[i+1];
            str2.insert(x);
            x=x+s[i+2];
            str3.insert(x);
            x="";
        }
            for(long long int j=0;j<26;j++)
            {
                char1='a'+j;
                x=char1;
                it=str1.find(x);
                if(it==str1.end())
                {cout<<x<<endl;return 0;}
                x="";
            }
            for(long long int j=0;j<26;j++)
            for(long long int l=0;l<26;l++)
            {
                char1='a'+j;
                x=char1;
                char2='a'+l;
                x=x+char2;
                it=str2.find(x);
                if(it==str2.end())
                {cout<<x<<endl;return 0;}
                x="";
            }
            for(long long int j=0;j<26;j++)
            for(long long int l=0;l<26;l++)
            for(long long int y=0;y<26;y++)
            {
                char1='a'+j;
                x=char1;
                char2='a'+l;
                char3='a'+y;
                x=x+char2;
                x=x+char3;
                it=str3.find(x);
                if(it==str3.end())
                {cout<<x<<endl;x="";return 0;}
                x="";
            }
                  
    }
    return 0;
}