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:
s = input()
K = int(input())
ans = []
for i in set(s):
    ans.append(i)

if K == 1:
    print(sorted(ans)[0])
else:
    for i in range(2, 6):
        for j in range(len(s) - i + 1):
            ans.append(s[j:j+i])
    ans = set(ans)
    ans.sort()
    print(ans[K - 1])

Submission status: Runtime Error

Solution code:
def 解():
    sS = input().rstrip()
    dsS = set()
    for s in sS:
        if s not in dsS:
            dsS.add(s)
    iK = int(input())
    iL = len(sS)
    iC = 0
    for s in sorted(list(dsS)):
        sDic = set()
        indexes = []
        for i in range(iL):
            if sS[i] == s:
                indexes.append(i)
        if iK < iL // len(indexes) + 1:
            for i in indexes:
                for j in range(1,iK+1):
                    if i+j <= iL:
                        sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            print(aS[iK -1])
            exit()
        for i in indexes:
            for j in range(1,iL -i+1):
                sDic.add(sS[i:i+j])
        aS = sorted(list(sDic))
        iLS = len(aS)
        if iC + iLS < iK:
            iC += iLS
            continue
        else:
            print(aS[iK -iC-1])
            exit()
解()

Submission status: Runtime Error

Solution code:
def 解():
    sS = input().rstrip()
    dsS = set()
    for s in sS:
        if s not in dsS:
            dsS.add(s)
    iK = int(input())
    iL = len(sS)
    iC = 0
    for s in sorted(list(dsS)):
        sDic = set()
        indexes = []
        for i in range(iL):
            if sS[i] == s:
                indexes.append(i)
        if iK < iL // len(indexes):
            for i in indexes:
                for j in range(1,iK+1):
                    sDic.add(sS[i:i+j])
            aS = sorted(list(sDic))
            print(aS[iK -1])
            exit()
        for i in indexes:
            for j in range(1,iL -i+1):
                sDic.add(sS[i:i+j])
        aS = sorted(list(sDic))
        iLS = len(aS)
        if iC + iLS < iK:
            iC += iLS
            continue
        else:
            print(aS[iK -iC-1])
            exit()
解()

Submission status: Runtime Error

Solution code:
import heapq

s=input()
K=int(input())

if(len(s)==1):
    print(s)
else:
    substrings=[]
    for i in range(len(s)-1):
        for j in range(i,len(s)):
            if(i-j>K):
                continue
            str=s[i:(j+1)]
            substrings.append(str)

    substrings=list(set(substrings))
    substrings.sort()

    print(substrings[K-1])

Submission status: Runtime Error

Solution code:
import heapq

s=input()
K=int(input())

if(len(s)==1):
    print(s)
else:
    pq=[]
    for i in range(len(s)-1):
        for j in range(i,len(s)):
            str=s[i:(j+1)]
            flag=False
            for str2 in pq:
                if(str==str2):
                    flag=True
            if(flag):
                continue
            pq.append(str)


    pq.sort()
    print(pq)

    print(pq[K-1])

Submission status: Runtime Error

Solution code:
import heapq

s=input()
K=int(input())

if(len(s)==1):
    print(s)
else:
    pq=[]
    for i in range(len(s)-1):
        for j in range(i,len(s)):
            flag=False
            for l in range(len(pq)):
                if(pq[l]==s[i:(j+1)]):
                    flag=True
                    break
            if(flag):
                continue
            pq.append(s[i:(j+1)])
            pq.sort()
            print(pq)
            if(len(pq)>K):
                pq.pop()

    print(pq[K-1])

Submission status: Runtime Error

Solution code:
import heapq

s=input()
K=int(input())

if(len(s)==1):
    print(s)
else:
    pq=[]
    for i in range(len(s)-1):
        for j in range(i,len(s)+1):
            flag=False
            for l in range(len(pq)):
                if(pq[l]==s[i:(j+1)]):
                    flag=True
                    break
            if(flag):
                continue
            pq.append(s[i:(j+1)])
            pq.sort()
            print(pq)
            if(len(pq)>K):
                pq.pop()

    print(pq[K-1])

Submission status: Runtime Error

Solution code:
import re
s = input()
K = int(input())
def finddict(s, sub, dic):
  for _sub in sorted(set(re.findall(sub+'.', s))):
    dic.append(_sub)
    dic = finddict(s, _sub, dic)
    if len(dic) >= K:
      break
  return dic
dic = []
for i in range(26):
  if s.find(chr(97 + i)) >= 0:
    dic += finddict(s, chr(97 + i), [chr(97 + i)])
  if len(dic) >= K:
    print(dic[K - 1])
    break

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
k = int(input())
l = set()
for t in range(1,k+1):
  for i in range(n):
    if i+t>=n:
      break
    l.add(s[i:i+t])
a = list(l)
a.sort()
print(a[k-1])

Submission status: Runtime Error

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

t = sorted(set(s))[0:K]

l = t.copy()

for i in range(min(K,len(t))):
    w = t[i]
    for j in range(len(s)):
        for k in range(i+2,K+1):
            if s[j]==w:
                l.append(s[j:j+k])

l = sorted(set(l))

print(l[K-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
arr = set()
for i in range(len(s)):
    for j in range(i+1,min(i+1+K,len(s))):
        arr.add(s[i:j])
print(list(sorted(arr))[K-1])

Submission status: Runtime Error

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

subs = [[s[j:i] for i in range(j+1, len(s)+1)] for j in range(len(s))]
subs = list(set([i for inner in subs for i in inner]))
subs.sort()

print(subs[K-1])

Submission status: Runtime Error

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

sub = []

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

sub2 = set(sub)
sub3 = list(sub2)

sub3.sort()

print(sub3[k-1])

Submission status: Runtime Error

Solution code:
import string


def make_string(string, flag_matched=False, N=5000):
    if string[-1] == 'z':
        string = string[:-1]
        flag_matched = False
    if flag_matched == False or len(string) == N:
        string = string[:-1] + chr(ord(string[-1] )+1)
    else:
        string += 'a'
    return(string)


S = input()
k = int(input())

N = len(S)

c = 0
q = 'a'

while True:
    if q in S:
        c += 1
        if c == k:
            break
        else:
            q  = make_string(q, True, N)
    else:
        q  = make_string(q, False, N)

print(q)

Submission status: Runtime Error

Solution code:
s = list(input())
k = int(input())
a = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    a.add(s[i:j + 1])
a = sorted(a)
print(a[k - 1])

Submission status: Runtime Error

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

print(sorted(set([x for x in [s[i: i+n] for n in range(1, len(s) + 1) for i in range(0, len(s)-n+1)]]))[K])

Submission status: Runtime Error

Solution code:
S=input()
K=int(input())
sub_list=[]
for i in range(len(S)+1):
    for j in range(i+1,len(S)+1):
        sub_list.append(S[i:j])
        
sub_list=list(set(sub_list))
sub_list=sorted(sub_list)
print(sub_list[K-1])

Submission status: Runtime Error

Solution code:
s=input()
K=int(input())
sub_list=[]
for i in range(len(S)+1):
    for j in range(i+1,len(S)+1):
        sub_list.append(S[i:j])
        
sub_list=list(set(sub_list))
sub_list=sorted(sub_list)
print(sub_list[K-1])

Submission status: Runtime Error

Solution code:
s = input()
r = []
for i in range(1,6):
  for j in range(len(s)-i):
    r.append(s[j:j+i])
print(sorted((set(r)))[int(input())-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
s_list = []
for i in range(len(s)):
	for j in range(i + 1, i + K + 1):
		s_list.append(s[i:j])
s_set = set(s_list)
ans = list(s_set.sort())
print(ans[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
s_list = []
for i in range(len(s)):
	for j in range(i + 1, K + 1):
		s_list.append(s[i:j])
s_set = set(s_list)
ans = list(s_set.sort())
print(ans[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
s_list = []
for i in range(len(s)):
	for j in range(1, K + 1):
		s_list.append(s[i:j])
s_set = set(s_list)
ans = list(s_set.sort())
print(ans[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
s_list = []
for i in range(len(s)):
	for j in range(1, K):
		s_list.append(s[i:j])
s_set = set(s_list)
ans = list(s_set.sort())
print(ans[K - 1])

Submission status: Runtime Error

Solution code:
from itertools import *
s = input()
k = int(input())

def get_all_substrings(input_string):
  length = len(input_string)
  return [input_string[i:j+1] for i in range(length) for j in range(i,length)]


print(sorted(set(get_all_substrings(s)))[k-1])

Submission status: Runtime Error

Solution code:
from itertools import *
s = input()
k = int(input())

def get_all_substrings(input_string):
  length = len(input_string)
  return [input_string[i:j+1] for i in range(length) for j in range(i,length)]
# print(sorted(set(get_all_substrings(s))))
print(sorted(set(get_all_substrings(s)))[k-1])

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    s = input()
    K = int(input())

    subs = []
    for i in range(len(s)):                                                                                                                                                   for j in range(K):
            try:
                subs.append(s[i:i+j+1])
            except:
                break
    subs = set(subs)
    print(sorted(list(subs))[K-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
	for j in range(len(s)):
		if s[i:j] != '':
			substring.append(s[i:j])
sub_set = set(substring)
ans = list(sub_set)
ans.sort()
if len(s) > 1:
	print(ans[K-1])
else:
	print(s)

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s)):
	for j in range(len(s)):
		if s[i:j] != '':
			substring.append(s[i:j])
sub_set = set(substring)
ans = list(sub_set)
ans.sort()
print(ans[K-1])

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        if(len(tmp)<6):
            l.append(tmp)


for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
            break
    if is_multi == 0:
        l2.append(i)

l2.sort()

l2 = list(str(l2[K-1]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)
if len(l3) % 2 == 1:
    l3.append('0')

i = 0
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]

print(ans)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        l.append(tmp)

for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
    if is_multi == 0:
        l2.append(i)

l2.sort()

l2 = list(str(l2[K-1]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)
if len(l3) % 2 == 1:
    l3.append('0')

i = 0
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]


print(ans)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        l.append(tmp)

for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
    if is_multi == 0:
        l2.append(i)

l2.sort()

l2 = list(str(l2[K-1]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)
if len(l3) % 2 == 1:
    l3.append('0')

i = 0
while i < len(l3)-1:
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]


print(ans)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        l.append(tmp)

for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
    if is_multi == 0:
        l2.append(i)

l2.sort()

l2 = list(str(l2[K-1]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)

i = 0
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]


print(ans)

Submission status: Runtime Error

Solution code:
s = list(input())
K = int(input())
l = []
l2 = []
l3 = []
l4 = []

for i in range(len(s)):
    s[i] = str(ord(s[i])-ord("a")+11)

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        l.append(tmp)

for i in range(len(l)):
    while True:
        if len(l[i]) == len(s)*2: break
        l[i] += '0'

for i in l:
    is_multi = 0
    i = int(i)
    for j in l2:
        if i == j:
            is_multi = 1
    if is_multi == 0:
        l2.append(i)

l2.sort()
l2 = list(str(l2[K]))

tmp = ''
for i in range(len(l2)):
    if l2[i] != '0':
        tmp += l2[i]

l3 = list(tmp)

i = 0
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    l4.append(tmp)
    i += 2

ans =''
for i in range(len(l4)):
    ans += l4[i]


print(ans)

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		substring.append(s[i:j])
substring = list(set(substring))
substring.sort()
print(substring[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		substring.append(s[i:j])
substring = list(set(substring))
substring.sort()
if len(substring) <= 1:
	print(s)
else:
	print(substring[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		substring.append(s[i:j])
substring = list(set(substring))
substring.sort()
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		substring.append(s[i:j])
substring = list(set(substring))
substring.sort()
print(substring)
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		if j == i + 1:
			substring.append(s[i])
		else:
			substring.append(s[i:j])
substring.sort()
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i + 1, len(s) + 1):
		substring.append(s[i:j])
substring.sort()
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i+1, len(s) + 1):
		if j == 0:
			substring.append(s[i])
		else:
			substring.append(s[i:j])
substring.sort()
if K <= 1 or len(s) <= 1:
	print(s)
else:
	print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
substring = []
for i in range(len(s) + 1):
	for j in range(i+1, len(s) + 1):
		if j == 0:
			substring.append(s[i])
		else:
			substring.append(s[i:j])
substring.sort()
print(substring[K + 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
sub = {}
for d in range(1,6):
    for i in range(len(s)-d+1):
        sub |= {s[i:i+d]}
print(sorted(sub)[K-1])

Submission status: Runtime Error

Solution code:
s=input()
K=int(input())
 
ans=[]
ans.append(s)
 
 
for i in range(len(s)):
 for j in range(len(s)-i):
  cut_s=s[i:i+j+1]
  if cut_s not in ans:
   ans.append(cut_s)
   ans.sort()
   if len(ans)>K:
    if cut_s==s[K]:
      ans.pop()
      break;
    ans.pop()
 
answer=ans[K-1]
print(answer)

Submission status: Runtime Error

Solution code:
s=input()
K=int(input())
 
ans=[]
ans.append(s)
 
 
for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  if cut_s not in ans:
   ans.append(cut_s)
   ans.sort()
  if len(ans)>K:
    ans.pop()
 
answer=ans[K-1]
print(answer)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans=[]
ans.append(s)


for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  if cut_s not in ans:
   ans.append(cut_s)
   ans.sort()

answer=ans[K-1]
print(answer)

Submission status: Runtime Error

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

ans=[]
ans.append(s)


for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  ans.append(cut_s)
  ans=sorted(set(ans))
  if len(ans)>K:
   ans.pop()
  print(ans)
    


answer=ans[K-1]
print(answer)

Submission status: Runtime Error

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

ans=[]
ans.append(s)
si=[]
count=0


for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  if cut_s not in ans:
   ans.append(cut_s)
   ans.sort()
   if len(ans)>K:
    ans.pop()

answer=ans[K-1]
print(answer)

Submission status: Runtime Error

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

ans=[]
ans.append(s)
count=0


for i in range(len(s)-1):
 for j in range(i+1):
  cut_s=s[j:j+len(s)-i-1]
  if cut_s not in ans:
   ans.append(cut_s)
    
ans.sort()

answer=ans[K-1]
print(answer)

Submission status: Runtime Error

Solution code:
s = input()
po = int(input())

slist = list(s)
n = len(s)
substlist = []


for i in range(97,122):
  if len(list(set(substlist))) > 5:
    break
  arglist = []
  for c in range(len(slist)):
    if slist[c] == chr(i):
      arglist.append(c)
    for k in arglist:
      for j in range(6):
        if k + j <= n:
          substlist.append(s[k:k+j+1])
        
while substlist.count("")>0:
  substlist.remove("")

hoge = list(set(substlist))
hoge.sort()
print(hoge[po-1])

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
t=set(s)
t.append(s)
n=len(s)-1
for i in range(n):
  t.append(s[i:i+2])
  if i == n:
    break
  t.append(s[i:i+3])
  if i == n-1:
    continue
  t.append(s[i:i+4])
t.sort()
print(t[k])

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
t=set(s)
t.append(s)
for i in range(len(s)-1):
  t.append(s[i:i+1])
  if i == len(s)-1:
    break
  t.append(s[i:i+2])
  if i == len(s)-2:
    continue
  t.append(s[i:i+3])
t.sort()
print(t[k])

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
t=set(s)
t.append(s)
for i in range(len(s)-1):
  t.append(s[i]+s[i+1])
  if i == len(s)-1:
    break
  t.append(s[i]+s[i+1]+s[i+2])
  if i == len(s)-2:
    continue
  t.append(s[i]+s[i+1]+s[i+2]+s[i+3])
t.sort()
print(t[k])

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
t=set(s)
t.apprnd(s)
for i in range(len(s)-1):
  t.append(s[i]+s[i+1])
  if i == len(s)-1:
    break
  t.append(s[i]+s[i+1]+s[i+2])
  if i == len(s)-2:
    continue
  t.append(s[i]+s[i+1]+s[i+2]+s[i+3])
t.sort()
print(t[k])

Submission status: Runtime Error

Solution code:
s,K = input(),int(input())

subList = []
N = len(s)
repNum = 0

while N - repNum >= 1:
        for i in range(repNum+1):
                subList.append(s[i:N-repNum+i])
        repNum += 1
subListUniq = list(set(subList))
subListUniq.sort()
print(subListUniq[K-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
arr = set()
arr.add(s)
for i in range(len(s)-1):
    for j in range(1, len(s)):
        arr.add(s[j:j+i+1])
arr = list(arr)
arr.sort()
print(arr[k-1])

Submission status: Runtime Error

Solution code:
import string


lowercase = string.ascii_lowercase

s = input()
K = int(input())

substrings = []

stack = list(lowercase)[::-1]

while len(substrings) < 5:
    # print(stack)
    v = stack.pop()
    if v in s:
        substrings.append(v)
        for c in list(lowercase)[::-1]:
            stack.append(v+c)

print(substrings[K-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
l = []
for i in range(1,k):
    for j in range(len(s)-i+1):
        l.append(s[j:j+i])


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

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
l = len(S)
topk = []
vocab = set()

for i in range(l):
    for j in range(i + 1, i + K + 1):
        if j > l - 1:
            break
        ss = S[i: j]
        vocab.add(ss)

print(sorted(list(vocab))[K-1])

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
l = len(S)
topk = []
vocab = set()

for idx in range(K):
    ss = S[0:idx + 1]
    if ss in vocab:
        continue
    topk.append(ss)
    vocab.add(ss)
for idx in range(1, l):
    sblen = 0
    for sblen in range(1, l - idx):
        ss = S[idx: idx + sblen]
        if ss in vocab:
            continue
        vocab.add(ss)
        if len(topk) < K:
            topk.append(ss)
            continue

        if ss > topk[-1]:
            break
        else:
            topk[-1] = ss
            topk.sort()

print(topk[K-1])

Submission status: Runtime Error

Solution code:
s=input()
K=int(input())
sub=[]
for i in range(len(s)):
    c=0
    max=[len(x) for x in sub]
    if len(max):
        max.sort()
        max=max[K]
    else:
        max=len(s)
    for j in range(len(s)):
        if sub.count(s[i:i+j+1])==0 and s[i:i+j+1]!="":
            sub.append(s[i:i+j+1])
            c+=1
        if c>K or j+1>max:
            break
sub.sort()
print(sub[K-1])

Submission status: Runtime Error

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

words = set()

l = len(s)

for i in range(1,k+1):
    for j in range(l-k):
        words.add(s[j:i+j])

sort_word = sorted(words)
print(sort_word[k-1])

Submission status: Runtime Error

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

sub = set()

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

ans = list(sorted(sub))

print(sub[K - 1])

Submission status: Runtime Error

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

set_substring = set()
for i in range(0,len(s)):
	for j in range(0,len(s)):
		if(i<=j):
			str1 = s[i:j]
			str2 = s[j+1:]

			set_substring.add(str1)
			set_substring.add(str2)


set_substring.remove("")

list_substring=list(set_substring)
list_substring.sort()

print(list_substring[K-1])

Submission status: Runtime Error

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

set_substring = set()
for i in range(0,len(s)):
	for j in range(0,len(s)):
		if(i<=j):
			str1 = s[i:j]
			str2 = s[j+1:]

			set_substring.add(str1)
			set_substring.add(str2)


set_substring.remove("")

list_substring=list(set_substring)
list_substring.sort()
print(list_substring)
print(list_substring[K-1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
alphabet = list("abcdefghijklmnopqrstuvwxyz")
result = []

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(i + 1, min(i + K + 1, len(s) + 1)):
                result.append(s[i:j])
    if len(result) > K:
        break

result = list(set(result))
result.sort()
# print(result)
# print(len(result))
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
subs = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")
result = []

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(i + 1, min(i + K + 1, len(s) + 1)):
                result.append(s[i:j])


subs = list(set(subs))
subs.sort()
print(subs[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(i + 1, min(i + K + 1, len(s) + 1)):
                result.append(s[i:j])
    if len(result) > K:
        break

result = list(set(result))
result.sort()
# print(result)
# print(len(result))
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(min(K, len(s) - i)):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break

result = list(set(result))
result.sort()
# print(result)
# print(len(result))
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(min(K, len(s) - i)):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break
result = list(set(result))
result.sort()
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(K):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break
result = list(set(result))
result.sort()
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(len(s) - i):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break
result = list(set(result))
result.sort()
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
result = []
alphabet = list("abcdefghijklmnopqrstuvwxyz")

for u in alphabet:
    for i in range(len(s)):
        if s[i] == u:
            for j in range(len(s) - i):
                result.append(s[i:i + j + 1])
    if len(result) > K:
        break
result = list(set(result))
result.sort()
print(result)
print(result[K - 1])

Submission status: Runtime Error

Solution code:
s = input()
K = int(input())
subs = []
for i in range(0, len(s)):
    for j in range(i+1, len(s)+1):
        subs.append(s[i:j])
subs = list(set(subs))
subs.sort()
print(subs[K-1])

Submission status: Runtime Error

Solution code:
def get_shaos(s):
    shaos=[]
    shao=97
    for i in range(26):
        r=s.find(chr(shao))
        if r >-1:
            shaos.append(chr(shao))
        shao+=1
    return shaos

def f(s,old_shao):
    global c
    shaos=get_shaos(s)
    for shao in shaos:
        new = get_s(s, old_shao+shao)
        #print(old_shao+shao,new)
        if new is not None:
            re=old_shao+shao
            c += 1
            #print(c,re)
            if k == c:
                print(re)
                return 1
            else:
                r=f(new,old_shao+shao)
                if r ==1:
                    return 1
        else:
            pass
    return 0
if __name__=='__main__':
    c = 0
    s=input()
    k=int(input())
    f(s,'')

Submission status: Runtime Error

Solution code:
"""
TODO
"""


def substring(s):
    ss = []
    for ss_len in range(1, len(s) + 1):
        for ofs in range(0, len(s) - ss_len + 1):
            c = s[ofs:ss_len + ofs]
            if c not in ss:
                ss.append(c)
    return sorted(ss)


def nth_largest(s, n):
    ss = substring(s)
    return ss[n - 1]


if __name__ == "__main__":
    s, K = input().rstrip().spilt(' ')
    K = int(K)
    print(nth_largest(s, K))

Submission status: Runtime Error

Solution code:
s = input()
N = int(input())
l = len(s)
result=[]
for first in range(l):
  for scope in range(1,1+l-first):
    if not s[first:first+scope]:
      result.append(s[first:first+scope])
result.sort()
print(result[N-1])

Submission status: Runtime Error

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

array = []
for i in range(0, k):
    for j in range(0, len(s)-i):
        array.append(s[j:j+i+1])
print(sorted(set(array))[4])

Submission status: Runtime Error

Solution code:
s = input()
N = int(input())
l = len(s)
li=list(set(s))
li.sort()
result=[]

if len(li)>5:
    a=5
else:
    a=l-1
for i in range(a):
    indexx=[f for f,x in enumerate(s) if x==s[i]]
    for index in indexx:
        for scope in range(1,l+1):
            if not s[index:index+scope] in result:
                result.append(s[index:index+scope])
                result.sort()


print(result)
print(result[N-1])

Submission status: Runtime Error

Solution code:
s = input()
N = int(input())
l = len(s)
li=list(set(s))
li.sort()
result=[]
print(li)
if len(li)>5:
    a=5
else:
    a=l-1
for i in range(a):
    index=s.index(li[i])
    for scope in range(1,l+1):
        if not s[index:index+scope] in result:
            result.append(s[index:index+scope])
result.sort()
print(result)
print(result[N-1])