Problem:


Score : 300 points

Problem Statement

You are given a string s.
Among the different substrings of s, print the K-th lexicographically smallest one.

A substring of s is a string obtained by taking out a non-empty contiguous part in s.
For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not.
Also, we say that substrings are different when they are different as strings.

Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.

Constraints

1 ≤ |s| ≤ 5000

s consists of lowercase English letters.

1 ≤ K ≤ 5

s has at least K different substrings.

Partial Score

200 points will be awarded as a partial score for passing the test set satisfying |s| ≤ 50.

Input

Input is given from Standard Input in the following format:

s
K

Output

Print the K-th lexicographically smallest substring of K.

Sample Input 1

aba
4

Sample Output 1

b

s has five substrings: a, b, ab, ba and aba.
Among them, we should print the fourth smallest one, b.
Note that we do not count a twice.

Sample Input 2

atcoderandatcodeer
5

Sample Output 2

andat

Sample Input 3

z
1

Sample Output 3

z



Sample input:
aba
4


Sample output:
b

Submission status: Runtime Error

Solution code:
p = str(input())
s = list(p)
k = int(input())

zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]

    zisyo.append(st)
    onelist = list(sorted(list(set(zisyo))))
    
    if onelist[st] > 6:
        continue
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort)

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
subs = []
for i in range(len(s)):
    for j in range(len(s)):
        if j > i:
            if j - i > 5:
                break
            if s[i:j] not in subs:
                subs.append(s[i:j])
            # print(i,j)
if len(s) <= 5:
    subs.append(s)
# print(sorted(subs))
print(sorted(subs)[k-1])

Submission status: Runtime Error

Solution code:
s=raw_input()
K=int(raw_input())

def main():
  d=[]
  for i in range(len(s)):
    for j in range(i,len(s)+1):
      d.append(s[i:j])

  d=list(set(d))
  d.sort()

  print d[K]

main()

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
LIST = []
for i in range(len(s)-1):
    j=i+1
    while j<=len(s):
        if s[i:j] not in LIST:
            LIST.append(s[i:j])
        j+=1
LIST.sort()
print(LIST[K-1])

Submission status: Runtime Error

Solution code:
from collections import deque
def solve():
    
    s = input()
    K = int(input())
    l =deque()
    for i in range(len(s)):
        for j in range(i, len(s)-i+1):
            if s[i:j+1] not in l:
                 l.append(s[i:j+1])
    l.sort()
    print(l[K-1])
    
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
p = str(input())
s = list(p)
k = int(input())

zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]
    zisyo.append(st)
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort[k-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
subs = []
for i in range(len(s)):
    for j in range(len(s)):
        if j > i:
            if s[i:j] not in subs:
                subs.append(s[i:j])
            # print(i,j)

subs.append(s)

print(sorted(subs)[k-1])

Submission status: Runtime Error

Solution code:
p = str(input())
s = list(p)
k = int(input())

zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]
    zisyo.append(st)
    
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort[k-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
Kinds = set(s)
sort_s = sorted(list(Kinds))
cand = set([]) | set(sort_s)

first_i = [i for i, c in enumerate(s) if c == sort_s[0]]
for i in first_i:
    for j in range(1, 5):
        if i+j+1 <= len(s):
            cand.add(s[i:i+j+1])

sort_res = sorted(list(cand))

print(sort_res[K-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
n = len(s)
l2 = sorted([s[i:i+2] for i in range(n-1)])
l3 = sorted([s[i:i+3] for i in range(n-2)])
l4 = sorted([s[i:i+4] for i in range(n-3)])
l5 = sorted([s[i:i+5] for i in range(n-4)])
out = sorted([min(s),l2[0],l2[1],l2[2],l2[3],l3[0],l3[1],l3[2],l4[0],l4[1],l5[0]])
print(out[k-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
S = []
for i in range(1, len(s) + 1):
    k = 0
    while True:
        if len(s) - k - i < 0:
            break
        a = []
        for j in range(0, i):
            a.append(s[j + k])
        S.append(a)
        k += 1

keylist = []
for i in range(len(S)):
    for j in range(len(S)):
        if S[i] == S[j] and i != j and i > j:
            keylist.append(i)

for i in keylist:
    del S[i]
S.sort()
print(''.join(S[K - 1]))

Submission status: Runtime Error

Solution code:
s = list(str(input()))
k = int(input())

zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]
    zisyo.append(st)
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort[k-1])

Submission status: Runtime Error

Solution code:
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])

Submission status: Runtime Error

Solution code:
s = list(str(input()))
k = int(input())
zisyo = []
for i in range(len(s)):
    count = 0
    st = s[i]
    zisyo.append(st)
    while count <= n:
        count = count + 1
        try:
            st = st + s[i + count]
            zisyo.append(st)
        except:
            pass
    
zisyosort = list(sorted(list(set(zisyo))))
print(zisyosort[k-1])