Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

L = []
for i in range(len(s)):
    L.append(s[i])
    
L.sort()
word_list = []
idx = 0
if len(s) >= 18:
    while idx < len(s):
        if s[idx] == L[0]:
            for j in range(1, K+1):
                word_list.append(s[idx:idx+j])
        idx += 1
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            word_list.append(s[i:j])
    
word_set = set(word_list)
word_list = list(word_set)
word_list.sort()
print(word_list[K-1])

Fixed submission:
s = input()
K = int(input())

L = []
for i in range(len(s)):
    L.append(s[i])
    
L.sort()
cnt = 0
for i in range(len(L)):
    if L[i] == L[0]:
        cnt += 1

word_list = []
idx = 0
if len(s) >= 20:
    if cnt <= 5:
        while idx < len(s):
            if s[idx] == L[0] or s[idx] == L[cnt]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
    else:
        while idx < len(s):
            if s[idx] == L[0]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            word_list.append(s[i:j])
    
word_set = set(word_list)
word_list = list(word_set)
word_list.sort()
print(word_list[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

word_list = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        word_list.append(s[i:j])
    
word_set = set(word_list)
L = list(word_set)
L.sort()
print(L[K-1])

Fixed submission:
s = input()
K = int(input())

L = []
for i in range(len(s)):
    L.append(s[i])
    
L.sort()
cnt = 0
for i in range(len(L)):
    if L[i] == L[0]:
        cnt += 1

word_list = []
idx = 0
if len(s) >= 20:
    if cnt <= 5:
        while idx < len(s):
            if s[idx] == L[0] or s[idx] == L[cnt]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
    else:
        while idx < len(s):
            if s[idx] == L[0]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            word_list.append(s[i:j])
    
word_set = set(word_list)
word_list = list(word_set)
word_list.sort()
print(word_list[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())

word_list = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        word_list.append(s[i:j])
    
word_set = set(word_list)
L = list(word_set)
L.sort()
print(L[K-1])

Fixed submission:
s = input()
K = int(input())

L = []
for i in range(len(s)):
    L.append(s[i])
    
L.sort()
cnt = 0
for i in range(len(L)):
    if L[i] == L[0]:
        cnt += 1

word_list = []
idx = 0
if len(s) >= 20:
    if cnt <= 5:
        while idx < len(s):
            if s[idx] == L[0] or s[idx] == L[cnt]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
    else:
        while idx < len(s):
            if s[idx] == L[0]:
                for j in range(1, K+1):
                    word_list.append(s[idx:idx+j])
            idx += 1
else:
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            word_list.append(s[i:j])
    
word_set = set(word_list)
word_list = list(word_set)
word_list.sort()
print(word_list[K-1])