CodeEff/ECCO huggingface dataset:
# Original solution
s=input().strip()
K=int(eval(input()))
sorteds=sorted(set(s))
ct=0
subsset=set()
for c in sorteds:
    ct+=1
    ixs=[]
    ss=s
    ix=0
    while len(ss):
        ii=ss.find(c)
        if ii==-1:break
        ixs.append(ix+ii)
        ix=ix+ii
        ss=ss[ii:]
        for i in range(len(ss)):
            subsset.add(ss[:1+i])
        ss=ss[1:]
    if len(subsset)>=K:
        break
print((sorted(list(subsset))[K-1]))

# Optimized solution
s=input().strip()
K=int(eval(input()))
sorteds=sorted(set(s))
ct=0
subsset=set()
for c in sorteds:
    ct+=1
    ixs=[]
    ss=s
    ix=0
    while len(ss):
        ii=ss.find(c)
        if ii==-1:break
        ixs.append(ix+ii)
        ix=ix+ii
        ss=ss[ii:]
        for i in range(min(len(ss),K)):
            subsset.add(ss[:1+i])
        ss=ss[1:]
    if len(subsset)>=K:
        break
print((sorted(list(subsset))[K-1]))
# Original solution

def main():
    s = input().strip()
    k = int(input().strip())

    ss = []
    for i in range(0, len(s)):
        for j in range(i, len(s)+1):
            if i == j:
                continue
            if len(ss) == 8:
                if ss[-1] > s[i:j]:
                    ss[-1] = s[i:j]
                    ss = list(set(ss))
                    ss.sort()
            else:
                ss.append(s[i:j])
                ss = list(set(ss))
                ss.sort()

    print((ss[k-1]))

if __name__ == '__main__':
    main()


# Optimized solution

def main():
    s = input().strip()
    k = int(input().strip())

    ss = []
    for i in range(0, len(s)):
        for j in range(i, i + k + 1):
            if i == j:
                continue
            if len(ss) == 6:
                if ss[-1] > s[i:j]:
                    ss[-1] = s[i:j]
                    ss = list(set(ss))
                    ss.sort()
            else:
                ss.append(s[i:j])
                ss = list(set(ss))
                ss.sort()

    print((ss[k-1]))

if __name__ == '__main__':
    main()
# Original solution
str = input()
K = int(input())

#print str, K,  len(str)

dic = []

i = 1

while i <= len(str):
    idx = 0
    while True:
        head = idx
        tail = i + idx
        if tail > len(str):
            break
        else:
            dic.append(str[head:tail])
            idx = idx + 1

    i = i + 1


dic_set = list(set(dic))
dic_set.sort()
#print dic_set


print(dic_set[K-1])


# Optimized solution
str = input()
K = int(input())

#print str, K,  len(str)

#dic = []
dic = set()

i = 1

while i <= len(str):
    idx = 0
    while True:
        head = idx
        tail = i + idx
        if tail > len(str):
            break
        else:
#            dic.append(str[head:tail])
            dic.add(str[head:tail])
            idx = idx + 1

    i = i + 1


#dic_set = list(set(dic))
#dic_set.sort()
#print dic_set

dic_set = list(dic)
dic_set.sort()


print(dic_set[K-1])
# Original solution
#!/usr/bin/env python3
from collections import Counter
import sys

try:
    from typing import Set
except ImportError:
    pass


def f(s: "Set[str]", p: int, i: int):
    bins = Counter(sj[p:p + 1] for sj in s)
    cum = 0
    key = ""
    cnt = 0
    for key, cnt in sorted(bins.items()):
        cum += cnt
        if cum > i:
            break
    else:
        raise IndexError(i)
    new_s = {sj for sj in s if sj[p:p + 1] == key}
    if len(new_s) == 1:
        return list(new_s)[0]
    return f(new_s, p + 1, i - cum + cnt)


def solve(s: str, K: int):
    n = len(s)
    ss = {
        s[i:j]
        for i in range(n)
        for j in range(i + 1, n + 1)
    }
    print((f(ss, 0, K - 1)))


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()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):
    n = len(s)
    ss = {
        s[i:j]
        for i in range(n)
        for j in range(i + 1, min(n + 1, i + K + 1))
    }
    print((sorted(ss)[K - 1]))
 

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()
# Original solution
#                         author:  kagemeka 
#                         created: 2019-11-07 13:42:36(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())
    n = len(s)

    substrings = []
    for i in range(1, n+1):
        for j in range(n-i+1):
            substring = s[j:j+i]
            substrings.append(substring)
            
    substrings = sorted(list(set(substrings)))
    print((substrings[k-1]))


if __name__ == "__main__":
    # execute only if run as a script
    main()


# Optimized solution
#                         author:  kagemeka 
#                         created: 2019-11-07 13:42:36(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())
    n = len(s)
    
    substrings = []
    for i in range(1, k+1):
        for j in range(n-i+1):
            substring = s[j:j+i]
            substrings.append(substring)
    substrings = sorted(list(set(substrings)))
    print((substrings[k-1]))


if __name__ == "__main__":
    # execute only if run as a script
    main()
# Original solution
import sys

s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline().rstrip())
n = len(s)

def main():
    res = set()
    for i in range(n):
        for j in range(i, n):
            res.add(s[i:j+1])
    return sorted(res)[k-1]

if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline().rstrip())
n = len(s)

def main():
    res = set()
    for l in range(n):
        for r in range(l, min(l+k, n)):
            res.add(s[l:r+1])

    return sorted(res)[k-1]

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):
    sl = set()

    for i in range(len(s)):
        for j in range(i,len(s)):
            sl.add(s[i:j+1])

    sl = list(sorted(sl))   
    # print(sl)
    print((sl[K-1]))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


# Optimized solution
#!/usr/bin/env python3
import sys


def solve(s: str, K: int):
    sl = set()

    for i in range(len(s)):
        for j in range(i,min(i+K,len(s))):
            sl.add(s[i:j+1])

    sl = list(sorted(sl))   
    # print(sl)
    print((sl[K-1]))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()
# Original solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, max(i+1+k+1, n+1)):
            stq.add(s[i:j]) 
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()
# Original solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    k = int(input().strip())
    n = len(s)
    strs = set()
    for i in range(n):
        for j in range(1, k+1):
            strs.add(s[i:min(i+j, n)])
    strs = list(strs)
    # print(sorted(strs))
    print((sorted(strs)[k-1]))


if __name__ == '__main__':
    main()
# Original solution

import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
##############################

S = input().rstrip()
K = int(eval(input()))

N = len(S)

ret = []
for nums in range(1, N+1):
    for i in range(N):
        s = S[i:i+nums]
        ret.append(s)

ret = sorted(set(ret))

print((ret[K-1]))

# Optimized solution

import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline
##############################

S = input().rstrip()
K = int(eval(input()))

N = len(S)

ret = []
for nums in range(1, K+1):
    for i in range(N):
        s = S[i:i+nums]
        ret.append(s)

ret = sorted(set(ret))
print((ret[K-1]))
# Original solution
#!/usr/bin/env python3
import sys
import string
import itertools


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

    part_set = set()
    for c in string.ascii_lowercase:
        for i in range(len(s)):
            if c == s[i]:
                part_set |= set(itertools.accumulate(s[i:]))
        if len(part_set) >= K:
            print((sorted(part_set)[K-1]))
            return
                


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()


# Optimized solution
#!/usr/bin/env python3
import sys
import string
import itertools


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

    part_set = set()
    for c in string.ascii_lowercase:
        for i in range(len(s)):
            if c == s[i]:
                part_set |= set(itertools.accumulate(s[i:min(i+K,len(s))]))
        if len(part_set) >= K:
            print((sorted(part_set)[K-1]))
            return
                


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()
# Original solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
k = I()
L = []
for i in range(len(s)):
    for j in range(i+1, len(s) + 1):
        L.append(s[i:j])



L = sorted(list(set(L)))
print((L[k - 1]))


# Optimized solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
k = I()
L = []
for i in range(len(s)):
    for j in range(i + 1, i + 1 + k):
        L.append(s[i:j])



L = sorted(list(set(L)))
print((L[k - 1]))
# Original solution
S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,len(S)-i+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print((sorted(now_subset)[K-1]))
    exit()
    

# Optimized solution
S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,min(K,len(S)-i)+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print((sorted(now_subset)[K-1]))
    exit()
# Original solution
s = input()
k = int(input())
arr =[]
for i in range(len(s)):
    for j in range(i,len(s)):
        if s[i:j+1] != '' and s[i:j+1] not in arr:
            arr.append(s[i:j+1])
def print_arr(arr):
    for i in range(len(arr)):
        print(arr[i],sep=" ",end="/")
    print()
   
arr = sorted(arr)
print(arr[k-1])


# Optimized solution
s = input()
k = int(input())
arr =[]
for i in range(len(s)):
    for j in range(i,i+5):
        if s[i:j+1] != '' and s[i:j+1] not in arr:
            arr.append(s[i:j+1])
arr = sorted(arr)
def print_arr(arr):
    for i in range(len(arr)):
        print(arr[i],sep="",end="/")
    print()   
print(arr[k-1])
# Original solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for j in range(len(s)):
    ans.append(s[j])
    if j < len(s)-1:
        t = j+2
        while True:
            ans.append(s[j:t])
            if t == len(s):
                break
            t += 1
l = list(set(ans))
l.sort()
print((l[k-1]))


# Optimized solution
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for i in range(len(s)):
    ans.append(s[i])
    if i < len(s)-1:
        t = i+2
        while True:
            ans.append(s[i:t])
            if t == len(s):
                break
            t += 1
            if t - i > 5:
                break

ans = list(set(ans))
ans.sort()
print((ans[k-1]))
# Original solution
from sys import stdin
from string import ascii_lowercase


def myfind(s, c):
    result = []
    for i, x in enumerate(s):
        if x == c:
            result.append(i)
    return result


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for x in ascii_lowercase:
        idxs = myfind(s, x)
        if not idxs:
            continue
        result.append(x)
        if len(result) >= K:
            break
        temp = sorted(list(set([s[x:] for x in idxs])))
        for y in temp:
            for z in range(len(y)):
                foo = y[: z + 1]
                if not foo in result:
                    result.append(foo)
                    if len(result) >= K:
                        break
            if len(result) >= K:
                break
        if len(result) >= K:
            break

    print((result[-1]))


if __name__ == '__main__':
    main()


# Optimized solution
from sys import stdin
from string import ascii_lowercase


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for c in ascii_lowercase:
        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]):
            for i in range(len(text)):
                if not text[:i + 1] in result:
                    result.append(text[:i + 1])
                    if len(result) == K:
                        print((result[-1]))
                        return


if __name__ == '__main__':
    main()
# Original solution
from sys import stdin
from string import ascii_lowercase


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = []
    for c in ascii_lowercase:
        for text in sorted([s[i:] for i, x in enumerate(s) if x == c]):
            for i in range(len(text)):
                if not text[:i + 1] in result:
                    result.append(text[:i + 1])
                    if len(result) == K:
                        print((result[-1]))
                        return


if __name__ == '__main__':
    main()


# Optimized solution
from sys import stdin


def main():
    s = stdin.readline().rstrip()
    K = int(stdin.readline().rstrip())
    result = set()
    for c in sorted(list(set(s))):
        for x in sorted([s[i:] for i, x in enumerate(s) if x == c]):
            for y in [x[:j + 1] for j in range(len(x))]:
                result.add(y)
                if len(result) == K:
                    print((sorted(list(result))[-1]))
                    return


if __name__ == '__main__':
    main()
# Original solution
s=input()
K=eval(input())
l=len(s)

a=set()
for diff in range(1,l+1):
	for i in range(l):
		a.add(s[i:i+diff])
b=list(a)
b.sort()

print(b[K-1])

# Optimized solution
s=input()
K=eval(input())
l=len(s)

a=set()
for diff in range(1,5+1):
	for i in range(l):
		a.add(s[i:i+diff])

b=list(a)
b.sort()

print(b[K-1])
# Original solution
s = input().strip()
k = int(eval(input()))

subset = set()
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        subset.add(s[i:j])

subset = list(subset)
subset.sort()
print((subset[k-1]))

# Optimized solution
from bisect import insort
s = input().strip()
k = int(eval(input()))

sublist = []
for i in range(len(s)):
    if len(sublist)>k:
        sublist = sublist[:k]
    for j in range(i+1,len(s)+1):
        if s[i:j] not in sublist and (len(sublist)<k or sublist[k-1]>s[i:j]):
            insort(sublist,s[i:j])

print((sublist[k-1]))
# Original solution
# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = set()

    pre_check = set()
    for ch in s:
        pre_check.add(ch)
    pre_check = list(pre_check)
    pre_check.sort()
    pre_check = pre_check[:5]

    for i in range(l):
        if not s[i] in pre_check:
            continue
        for j in range(l+1):
            t = s[i:j]
            if len(t):
                substrings.add(t)
    ans = list(substrings)
    ans.sort()
    return ans[K - 1]


def main(args):
    s = input().strip()
    K = int(eval(input()))
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


# Optimized solution
# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = []

    for i in range(l):
        for j in range(l+1):
            t = s[i:j]
            if len(t) and t not in substrings:
                substrings.append(t)
                substrings.sort()
                if len(substrings) > 5 and substrings[-1] == t:
                    substrings.pop()
                    break
    return substrings[K - 1]


def main(args):
    s = input().strip()
    K = int(eval(input()))
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])
# Original solution
# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = []

    for i in range(l):
        for j in range(l+1):
            t = s[i:j]
            if len(t) and t not in substrings:
                substrings.append(t)
                substrings.sort()
                if len(substrings) > 5 and substrings[-1] == t:
                    substrings.pop()
                    break
    return substrings[K - 1]


def main(args):
    s = input().strip()
    K = int(eval(input()))
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])


# Optimized solution
# -*- coding: utf-8 -*-
"""
C - K-th Substring
https://beta.atcoder.jp/contests/abc097/tasks/arc097_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(s, K):
    l = len(s)
    substrings = set()
    for i in range(l):
        for j in range(i+K+1):
            t = s[i:j]
            if len(t):
                substrings.add(t)
    ans = list(substrings)
    ans.sort()
    return ans[K - 1]


def main(args):
    s = input().strip()
    K = int(eval(input()))
    ans = solve(s, K)
    print(ans)

if __name__ == '__main__':
    main(sys.argv[1:])