Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = [ord(c) - 97 for c in S()]
    l = len(a)
    r = []
    t = [0] * l
    s = set()
    u = [[] for _ in range(26)]
    k = 1
    sl = 0
    for i in range(l-1,-1,-1):
        c = a[i]
        u[c].append(i)
        t[i] = k
        if c not in s:
            if sl == 25:
                k += 1
                s = set()
                sl = 0
            else:
                sl += 1
                s.add(c)
    t.append(1)
    for i in range(26):
        u[i].reverse()

    def bs(i,c):
        t = u[c]
        if not t or t[-1] <= i:
            return -1
        ma = len(t) - 1
        mi = 0
        mm = (ma+mi) // 2
        while ma > mi:
            mm = (ma+mi) // 2
            if t[mm] > i:
                ma = mm
            else:
                mi = mm + 1
        return t[mm]

    j = -1
    while j < l:
        for c in range(26):
            bi = bs(j,c)
            if bi < 0:
                r.append(c)
                j = l
                break
            if t[bi] < k:
                r.append(c)
                k = t[bi]
                j = bi
                break

    return ''.join([chr(c+97) for c in r])

print(main())





Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = S()
    l = len(a)
    t = {}
    for c in string.ascii_lowercase:
        t[c] = l
    b = [(1,0,0) for _ in range(l)]
    b.append((1,'a',l))
    b.append((0,'',l+1))

    for c,i in reversed(list(zip(a,range(l)))):
        t[c] = i
        b[i] = min([(b[t[d]+1][0] + 1,d,t[d]+1) for d in string.ascii_lowercase])

    r = ''
    i = 0
    while i < l:
        r += b[i][1]
        i = b[i][2]
    return r

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = [ord(c) - 97 for c in S()]
    l = len(a)
    r = []
    t = [0] * l
    s = set()
    u = [[] for _ in range(26)]
    k = 1
    for i in range(l-1,-1,-1):
        c = a[i]
        u[c].append(i)
        s.add(c)
        t[i] = k
        if len(s) == 26:
            k += 1
            s = set()
    t.append(1)
    for i in range(26):
        u[i].reverse()

    def bs(i,c):
        t = u[c]
        if not t or t[-1] <= i:
            return -1
        ma = len(t) - 1
        mi = 0
        mm = (ma+mi) // 2
        while ma > mi:
            mm = (ma+mi) // 2
            if t[mm] > i:
                ma = mm
            else:
                mi = mm + 1
        return t[mm]

    j = -1
    while j < l:
        for c in range(26):
            bi = bs(j,c)
            if bi < 0:
                r.append(c)
                j = l
                break
            if t[bi] < k:
                r.append(c)
                k = t[bi]
                j = bi
                break

    return ''.join([chr(c+97) for c in r])

print(main())





Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = S()
    l = len(a)
    t = {}
    for c in string.ascii_lowercase:
        t[c] = l
    b = [(1,0,0) for _ in range(l)]
    b.append((1,'a',l))
    b.append((0,'',l+1))

    for c,i in reversed(list(zip(a,range(l)))):
        t[c] = i
        b[i] = min([(b[t[d]+1][0] + 1,d,t[d]+1) for d in string.ascii_lowercase])

    r = ''
    i = 0
    while i < l:
        r += b[i][1]
        i = b[i][2]
    return r

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = [ord(c) - 97 for c in S()]
    l = len(a)
    r = []
    t = [0] * l
    s = set()
    u = [[] for _ in range(26)]
    k = 1
    for i in range(l-1,-1,-1):
        c = a[i]
        u[c].append(i)
        s.add(c)
        t[i] = k
        if len(s) == 26:
            k += 1
            s = set()
    t.append(1)
    for i in range(26):
        u[i].reverse()

    def bs(i,c):
        t = u[c]
        if not t or t[-1] <= i:
            return -1
        ma = len(t) - 1
        mi = 0
        mm = (ma+mi) // 2
        while ma > mi:
            mm = (ma+mi) // 2
            if t[mm] > i:
                ma = mm
            else:
                mi = mm + 1
        return t[mm]

    j = -1
    while j < l:
        for c in range(26):
            bi = bs(j,c)
            if bi < 0:
                r.append(c)
                j = l
                break
            if t[bi] < k:
                r.append(c)
                k = t[bi]
                j = bi
                break

    return ''.join([chr(c+97) for c in r])

print(main())





Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = S()
    l = len(a)
    t = {}
    for c in string.ascii_lowercase:
        t[c] = l
    b = [(1,0,0) for _ in range(l)]
    b.append((1,'a',l))
    b.append((0,'',l+1))

    for c,i in reversed(list(zip(a,range(l)))):
        t[c] = i
        b[i] = min([(b[t[d]+1][0] + 1,d,t[d]+1) for d in string.ascii_lowercase])

    r = ''
    i = 0
    while i < l:
        r += b[i][1]
        i = b[i][2]
    return r

print(main())

Buggy python submission (verdict: Time Limit Exceeded):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    s = S()
    l = len(s)

    fm = {}
    def f(i):
        if i in fm:
            return fm[i]
        t = set()
        r = 0
        for j in range(i, l):
            t.add(s[j])
            if len(t) == 26:
                t = set()
                r += 1
        fm[i] = r + 1
        return r + 1

    r = []
    def g(i):
        t = set()
        m = inf
        k = set()
        for j in range(i, l):
            if s[j] not in t:
                ji = f(j+1)
                if m > ji:
                    m = ji
                    k = set([(s[j], j)])
                elif m == ji:
                    k.add((s[j], j))
                t.add(s[j])
                if len(t) == 26:
                    break
        if len(t) < 26:
            for k in string.ascii_lowercase:
                if k not in t:
                    r.append(k)
                    break
        else:
            tr = sorted(list(k))[0]
            r.append(tr[0])
            g(tr[1]+1)

    g(0)

    return ''.join(r)

print(main())



Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**10
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = S()
    l = len(a)
    t = {}
    for c in string.ascii_lowercase:
        t[c] = l
    b = [(1,0,0) for _ in range(l)]
    b.append((1,'a',l))
    b.append((0,'',l+1))

    for c,i in reversed(list(zip(a,range(l)))):
        t[c] = i
        b[i] = min([(b[t[d]+1][0] + 1,d,t[d]+1) for d in string.ascii_lowercase])

    r = ''
    i = 0
    while i < l:
        r += b[i][1]
        i = b[i][2]
    return r

print(main())