Buggy python submission (verdict: Time Limit Exceeded):
from string import ascii_lowercase


def solve(s):
    d = [('', 0)]
    while True:
        e = []
        for ds, di in d:
            max_ci = -1
            for c in ascii_lowercase:
                ci = s.find(c, di) + 1
                ns = ds + c
                if not ci:
                    return ns
                if max_ci >= ci:
                    continue
                max_ci = ci
                e.append((ns, ci))
        d = e


print(solve(input().strip()))


Fixed submission:
from string import ascii_lowercase
from bisect import bisect


def solve(s):
    pos = [[] for _ in range(26)]
    offset = ord('a')
    for i, c in enumerate(s):
        c = ord(c) - offset
        pos[c].append(i)
    for l in pos:
        l.append(len(s))

    all_char_sequence_start_pos = []
    pos_i = [len(l) - 1 for l in pos]
    while all(pi >= 0 for pi in pos_i):
        i = min(l[pi] for pi, l in zip(pos_i, pos))
        all_char_sequence_start_pos.append(i)
        for j in range(26):
            while pos_i[j] >= 0 and pos[j][pos_i[j]] >= i:
                pos_i[j] -= 1
    all_char_sequence_start_pos.reverse()
    ans = []
    curr = -1
    for i in all_char_sequence_start_pos:
        for c in range(26):
            cj = bisect(pos[c], curr)
            j = pos[c][cj]
            if j >= i:
                ans.append(c)
                curr = j
                break
    return ''.join(chr(c + offset) for c in ans)


print(solve(input().strip()))

Buggy python submission (verdict: Time Limit Exceeded):
from string import ascii_lowercase


def solve(s):
    d = {c: {0: ''} for c in ascii_lowercase}
    while True:
        e = {}
        ans = set()
        for c in ascii_lowercase:
            f = {}
            for dc, dd in d.items():
                for di, ds in dd.items():
                    ci = s.find(c, di) + 1
                    ns = ds + c
                    if not ci:
                        ans.add(ns)
                        continue
                    if ci in f and ns > f[ci]:
                        continue
                    f[ci] = ns
            e[c] = f
        if ans:
            return min(ans)
        d = e


print(solve(input().strip()))


Fixed submission:
from string import ascii_lowercase
from bisect import bisect


def solve(s):
    pos = [[] for _ in range(26)]
    offset = ord('a')
    for i, c in enumerate(s):
        c = ord(c) - offset
        pos[c].append(i)
    for l in pos:
        l.append(len(s))

    all_char_sequence_start_pos = []
    pos_i = [len(l) - 1 for l in pos]
    while all(pi >= 0 for pi in pos_i):
        i = min(l[pi] for pi, l in zip(pos_i, pos))
        all_char_sequence_start_pos.append(i)
        for j in range(26):
            while pos_i[j] >= 0 and pos[j][pos_i[j]] >= i:
                pos_i[j] -= 1
    all_char_sequence_start_pos.reverse()
    ans = []
    curr = -1
    for i in all_char_sequence_start_pos:
        for c in range(26):
            cj = bisect(pos[c], curr)
            j = pos[c][cj]
            if j >= i:
                ans.append(c)
                curr = j
                break
    return ''.join(chr(c + offset) for c in ans)


print(solve(input().strip()))