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# (Mono 4.6.2.0) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ARC081E
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var A = NS;
            var toList = new long[26];
            for (var i = 0; i < 26; i++)
            {
                toList[i] = A.Length;
            }
            var vtxToList = new long[A.Length][];
            for (var i = A.Length - 1; i >= 0; i--)
            {
                vtxToList[i] = new long[26];
                for (var j = 0; j < 26; j++)
                {
                    vtxToList[i][j] = toList[j];
                }
                toList[A[i] - 'a'] = i;
            }
            var kouhoList = Repeat(0, A.Length + 1).Select(e => new List<byte>()).ToArray();
            for (var i = 0; i <= A.Length; i++)
            {
                var vtx = i - 1;
                if (vtx == -1)
                {
                    for (var j = 0; j < 26; j++)
                    {
                        if (kouhoList[toList[j]].Count == 0)
                        {
                            kouhoList[toList[j]].Add((byte)j);
                        }
                    }
                }
                else
                {
                    if (kouhoList[vtx].Count > 0)
                    {
                        for (var j = 0; j < 26; j++)
                        {
                            var to = vtxToList[vtx][j];
                            if (kouhoList[to].Count == 0 || kouhoList[to].Count > kouhoList[vtx].Count + 1)
                            {
                                kouhoList[to] = new List<byte>(kouhoList[vtx]);
                                kouhoList[to].Add((byte)j);
                            }
                            else if (kouhoList[to].Count == kouhoList[vtx].Count + 1)
                            {
                                var ok = true;
                                var tmp = new List<byte>(kouhoList[vtx]);
                                tmp.Add((byte)j);
                                for (var k = 0; k < tmp.Count; k++)
                                {
                                    if (tmp[k] > kouhoList[to][k])
                                    {
                                        break;
                                    }
                                    else if (tmp[k] < kouhoList[to][k])
                                    {
                                        ok = false;
                                        break;
                                    }
                                }
                                if (!ok)
                                {
                                    kouhoList[to] = tmp;
                                }
                            }
                        }
                        kouhoList[vtx] = null;
                    }
                }
            }
            var ans = kouhoList.Last();
            Console.WriteLine(new string(ans.Select(e => (char)(e + 'a')).ToArray()));
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}