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


def solve(s: str, K: int):

    index_dict = {}
    for i in range(len(s)):
        if index_dict.get(s[i]) == None:
            index_dict[s[i]] = [i]
        else:
            index_dict[s[i]].append(i)

    value_list = sorted(set(list(s)))
    candidate = set()
    for string in value_list:
        index = index_dict[string]
        for i in index:
            tmp_s = ""
            for j in range(i,len(s)):
                tmp_s += s[j]
                candidate.add(tmp_s)
        if len(candidate) >= K:
            break
    candidate = list(candidate)
    candidate.sort()
    print(candidate[K-1])

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()


Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]

  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]

  for i in index_list:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)
  if len(s)-min(index_list) >=k:
    break

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)
  if len(index) >= k:
    break

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
  

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(substrings) >= k:
    break
  

print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
k = int(input())
substrings = []
for i in range(len(s)):##初期位置
  for j in range(1,len(s)-i+1):##長さ
    substrings.append(s[i:i+j])
print(sorted(list(set(substrings)))[k-1])

Fixed submission:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  for i in index_list:##初期位置
    for j in range(1,min(k+1,len(s)-i+1)):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
print(sorted(list(set(substrings)))[k-1])