Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC97 C

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

f = defaultdict(lambda : 0)
s = input()
k = I()
n = len(s)
for i in range(n):
    for j in range(i+1,n+1):
        f[s[i:j]] = 1
f = sorted(f.items())
print(f[k-1][0])


Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC97 C

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

f = defaultdict(lambda : 0)
s = input()
k = I()
n = len(s)
for i in range(n):
    for j in range(i+1,n+1):
        f[s[i:j]] = 1
f = sorted(f.items())
print(f[k-1][0])


Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC97 C

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

lst = []
s = input()
k = I()
n = len(s)
for i in range(n):
    for j in range(i+1,n+1):
        lst.append(s[i:j])
lst = list(set(lst))
lst.sort()
print(lst[k-1])


Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC91 D

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

lst = []
s = input()
k = I()
n = len(s)
for i in range(n):
    for j in range(i+1,n+1):
        lst.append(s[i:j])
lst = list(set(lst))
lst.sort()
print(lst[k-1])


Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])

Buggy python submission (verdict: Runtime Error):
    for i in range(1, n + 1):
        if a <= sum(list(map(int, list(str(i))))) <= b:
           ans += i
    print(ans) 

Fixed submission:
#!usr/bin/env python3
s = input()
K = int(input())

l = {s}
for n in range(1, K+1):
    for i in range(0, len(s)-n+1):
        l.add(s[i:i+n])
l = list(l)

l.sort()

print(l[K-1])