Buggy python submission (verdict: Time Limit Exceeded):
s = list(input().strip())
K = int(input())
C = {}
for i in range(len(s)):
    if s[i] not in C:
        C[s[i]] = []
    C[s[i]].append(i)
D = set()
for a in C:
    for i in C[a]:
        x=s[i]
        D.add(x)
        for j in range(i+1,len(s)):
            x += s[j]
            D.add(x)
D = sorted(list(D))
print(D[K-1])

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
C = {}
for i in range(len(s)):
    if s[i] not in C:
        C[s[i]] = []
    C[s[i]].append(i)
D = {}
for a in C:
    for i in C[a]:
        x = s[i]
        if x not in D:
            D[x] = 0
        D[x] += 1
        for j in range(i+1,len(s)):
            x += s[j]
            if x not in D:
                D[x] = 0
            D[x] += 1
D = sorted(list(D.keys()))
print(D[K-1])

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
C = {}
for i in range(len(s)):
    if s[i] not in C:
        C[s[i]] = []
    C[s[i]].append(i)
D = {}
for a in C:
    for i in C[a]:
        for j in range(i+1,len(s)+1):
            if s[i:j] not in D:
                D[s[i:j]] = 0
            D[s[i:j]] += 1
D = sorted(list(D.keys()))
print(D[K-1])

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
K = int(input())
C = {}
for i in range(len(s)):
    if s[i] not in C:
        C[s[i]] = []
    C[s[i]].append(i)
if len(C)==1:
    a = s[0]
    print(a*K)
else:
    A = []
    for a in C:
        for i in C[a]:
            for j in range(i+1,len(s)+1):
                A.append(s[i:j])
    A = sorted(list(set(A)))
    print(A[K-1])

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = input().strip()
N = len(S)
K = int(input())
A = [ord(S[i]) for i in range(N)]
cnt = 0
a0 = 96
while True:
    amin = 1000
    for i in range(N):
        if a0<A[i]<=amin:
            amin = A[i]
    Ind = []
    for i in range(N):
        if A[i]==amin:
            Ind.append(i)
    a0 = amin
    B = []
    for i in Ind:
        for j in range(i,N):
            x = S[i:j+1]
            if x not in B:
                B.append(x)
    B = sorted(B)
    k = K-cnt
    if len(B)>=k:
        ans = B[k-1]
        break
    else:
        cnt += len(B)
print(ans)

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input().strip()
N = len(s)
K = int(input())
Ind = {chr(i):[] for i in range(97,123)}
for i in range(N):
    Ind[s[i]].append(i)
C = {}
cnt = 0
flag = 0
for j in range(97,123):
    for ind in Ind[chr(j)]:
        for i in range(ind+1,N+1):
            if s[ind:i] not in C:
                C[s[ind:i]] = 1
                cnt += 1
    if cnt>=K:break
A = sorted(list(C.keys()))
print(A[K-1])

Fixed submission:
S = input().strip()
N = len(S)
K = int(input())
A = []
for k in range(1,min(6,N+1)):
    for i in range(N-k+1):
        x = S[i:i+k]
        if x not in A:
            A.append(x)
A = sorted(A)
print(A[K-1])