Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substring = []
loong = False
for i in range(len(s)):
    for j in range(i, len(s)):
        if len(s[i:j+1]) <= 5:
            substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

Fixed submission:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substring = []
loong = False
for i in range(len(s)):
    for j in range(i, len(s)):
        if len(substring) <= 5:
            substring.append(s[i: j + 1])
            substring = list(set(substring))
            substring.sort()
            if len(substring) == 5:
                loong = True
        elif loong and substring[-1] > s[i: j + 1] and not s[i:j+1] in substring :
            substring[-1] = s[i: j + 1]
            substring.sort()

                
print(substring[K-1])

Fixed submission:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substring = []
loong = False
for i in range(len(s)):
    for j in range(i, len(s)):
        if len(substring) <= 5:
            substring.append(s[i: j + 1])
            substring = list(set(substring))
            substring.sort()
            if len(substring) == 5:
                loong = True
        elif loong and substring[-1] > s[i: j + 1] and not s[i:j+1] in substring :
            substring[-1] = s[i: j + 1]
            substring.sort()

                
print(substring[K-1])

Fixed submission:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, len(s)):
        if len(substring) <= 5:
            substring.append(s[i: j + 1])
            substring = list(set(substring))
            substring.sort()
        elif substring[-1] > s[i: j + 1] and not s[i:j+1] in substring :
            bisect.insort_left(substring, s[i: j + 1])

                
print(substring[K-1])

Fixed submission:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i,len(s)):
        substring.append(s[i:j+1])
ans = sorted(list((set(substring))))
print(ans[K-1])

Fixed submission:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
    for j in range(i, i+5):
        substring.append(s[i: j + 1])
substring = list(set(substring))
substring.sort()                
print(substring[K-1])