Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
  for j in range(b+1):
    if j > i:
        A.append(s[i:j])
B = A
if K == 1:
  ans = min(B)
if K == 2:
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  ans = (min(B))
if K == 3:
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  ans = (min(B))
if K == 4:
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  ans = (min(B))
if K == 5:
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  F = B.count(min(B))
  for i in range(F):
    B.remove(min(B))
  ans = (min(B))
print(ans)

Fixed submission:
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
  for j in range(b+1):
    if j > i:
      if s[i:j] in A:
        continue
      else:
        A.append(s[i:j])
B = A
if K == 1:
  ans = min(B)
if K == 2:
  B.remove(min(B))
  ans = (min(B))
if K == 3:
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
if K == 4:
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
if K == 5:
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
print(ans)

Fixed submission:
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
  for j in range(b+1):
    if j > i:
      A.append(s[i:j])
for i in range(b):
  A.append(s[i])
B = set(A)
B = list(B)
if K == 1:
  ans = min(B)
if K == 2:
  B.remove(min(B))
  ans = (min(B))
if K == 3:
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
if K == 4:
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
if K == 5:
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  B.remove(min(B))
  ans = (min(B))
print(ans)

Fixed submission:
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

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

Fixed submission:
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())
A =[]
for i in range(len(s)):
  for j in range(len(s)):
    if j > i:
      A.append(s[i:j])
for i in range(len(s)):
  A.append(s[i])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])

Fixed submission:
s = input()
K = int(input())
A =[]
b = len(s)
for i in range(b+1):
      if i+1 < b+1:
        A.append(s[i:i+1])
      if i+2 < b+1:
        A.append(s[i:i+2])
      if i+3 < b+1:
        A.append(s[i:i+3])
      if i+4 < b+1:
        A.append(s[i:i+4])
      if i+5 < b+1:
        A.append(s[i:i+5])
B = set(A)
B = list(B)
B = sorted(B)
print(B[K-1])