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: Wrong Answer

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

length = len(s)
substring_list = []
for i in range(length):
    for j in range(1,k+1):
        substring_list.append(s[i:i+j])
result = set(reversed(substring_list))

print(list(result)[k-1])

Submission status: Wrong Answer

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

length = len(s)
substring_list = []
for i in range(length):
    for j in range(1, k+1):
        substring_list.append(s[i:i+k])
substring_list.sort()
print(substring_list[k-1])

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

def main():
    s = input()
    K = int(input())

    a = set()

    for i in range(len(s)):
        for j in range(K):
            a.add(s[i:i+j+1])
            if i + j > len(s):
                break
    a_list = list(a)
    a_list.sort()
    print(a_list[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=input()
K=int(input())


def calc(s, K):
    a = defaultdict(list)
    for i, c in enumerate(s):
        a[c].append(i)
    result = set()
    for k, v in sorted(a.items(), key=lambda x: x[0]):
        if len(result) >= K:
            return sorted(result)[K-1]
        for i in v:
            for j in range(i+1, len(s)+1):
                result.add(s[i:j])

print(calc(s, K))

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s=input()
K=int(input())

a = defaultdict(list)

for i, c in enumerate(s):
    a[c].append(i)


result = set()
for k, v in sorted(a.items(), key=lambda x: x[0]):
    if len(result) > K:
        break
    for i in v:
        if len(result) > K:
            break
        for j in range(i+1, len(s)+1):
            result.add(s[i:j])
            if len(result) > K:
                break

print(sorted(result)[K-1])

Submission status: Wrong Answer

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

list = []
i = 0
while i < len(s):
  j = i+1
  while j < len(s)+1:
    tmp = s[i:j]
    if len(list)>=K:
      if tmp>list[-1]:
        i += 1
        j = i+1
      else:
        if not tmp in list:
          list.append(tmp)
          list.sort()
          list = list[:K]
    else:
      if not tmp in list:
        list.append(tmp)
        list.sort()
        if len(list)>K:
          list = list[:K]
    j += 1
  i += 1

print(list[K-1])

Submission status: Wrong Answer

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

l =[]

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

l2 = list(dict.fromkeys(l))

ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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

l =[]

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

l2 = list(dict.fromkeys(l))

ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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

l =[]

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

l2 = list(dict.fromkeys(l))
print(l2)
ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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

l =[]

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

l2 = list(set(l))

ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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

l =[]
l2 = []

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

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

ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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

l =[]
l2 = []

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

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

ans = l2[K - 1]

print(ans)

Submission status: Wrong Answer

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)

max_len = 0
for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        if(j > i+5): break
        tmp += s[j]
        if(len(tmp)<12):
            l.append(tmp)
            max_len = max(max_len, len(tmp))
        else: break


for i in range(len(l)):
    is_multi = 0
    while True:
        if len(l[i]) == max_len: break
        l[i] += '0'
    l[i] = int(l[i])
    for j in l2:
        if l[i] == j:
            is_multi = 1
            break
    if is_multi == 0:
        l2.append(l[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
ans =''
while i < len(l3):
    tmp = chr(int(l3[i] + l3[i+1]) - 11 + ord('a'))
    ans += tmp
    i += 2

print(ans)

Submission status: Wrong Answer

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)

max_len = 0
for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        if(len(tmp)<12):
            l.append(tmp)
            max_len = max(max_len, len(tmp))
        else: break


for i in range(len(l)):
    is_multi = 0
    while True:
        if len(l[i]) == max_len: break
        l[i] += '0'
    l[i] = int(l[i])
    for j in l2:
        if l[i] == j:
            is_multi = 1
            break
    if is_multi == 0:
        l2.append(l[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: Wrong Answer

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)

max_len = 0
for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        tmp += s[j]
        if(len(tmp)<12):
            l.append(tmp)
            max_len = max(max_len, len(tmp))
        else: break


for i in range(len(l)):
    while True:
        if len(l[i]) == max_len: 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: Wrong Answer

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)

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


for i in range(len(l)):
    while True:
        if len(l[i]) == max_len: 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: Wrong Answer

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)<12):
            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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
 
ans=[]
ans.append(s)
 
 
for i in range(len(s)-1):
 for j in range(len(s)-i):
  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: Wrong Answer

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

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


for i in range(97,123):
  if len(list(set(substlist))) > 5:
    break
  arglist = []
  for c in range(len(slist)):
    if slist[c] == chr(i):
      arglist.append(c)
      substlist.append(chr(i))
    for k in arglist:
      for j in range(1,5):
        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)

Submission status: Wrong Answer

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

def decompose(s):
    l = []
    N = len(s)
    i = 0
    while i < N:
        j = i
        while j <= N:
            l.append(s[i:j])
            j += 1
        i += 1
    l = list(set(l))
    l.sort()
    return l

def answer(slist,smin,k):
    indices = [i for i, x in enumerate(slist) if x == smin]
    ans = []
    for ind in indices:
        ans.extend(decompose(s[ind:min(ind+k,len(s))]))
    ans = list(set(ans))
    ans.sort()
    if len(ans) >= k:
        return ans[k]
    else:
        s_temp = slist.copy()
        k -= len(ans)
        for r in range(len(indices)):
            s_temp.remove(min(slist))
        smin = min(s_temp)
        answer(slist,smin,k)

print(answer(list(s),min(list(s)),k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
arr = set()
arr.add(s)
for i in range(len(s)-1):
    if i > 5:
        break
    for j in range(0, len(s)):
        arr.add(s[j:j+i+1])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for idx in range(K):
    ss = S[0:idx + 1]
    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 ss > topk[-1]:
            break
        else:
            topk[-1] = ss
            topk.sort()

print(topk[K-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
if len(s)<=50:
 sset=set()
 for i in range(len(s)):
     for j in range(i+1,len(s)+1):
         sset.add(s[i:j])
 slist=list(sset)
 slist.sort()
 print(slist[int(input())-1])

Submission status: Wrong Answer

Solution code:
s=input()
K=int(input())
listA=[]


for j in range(1,K+1):
    for i in range(len(s)):
        listA.append(s[i:i+j])
listA.sort()
x=""
count=0
for i in range(len(listA)):
    if(x!=listA[i]):
        count+=1
        x=listA[i]
    if(count==K):
        print(x)
        break;
print(listA)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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



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

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

Submission status: Wrong Answer

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



for i in range(len(li)):
    indexx=[f for f,x in enumerate(s) if x==li[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])
    if len(result)>=N:
        result.sort()
        break

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

Submission status: Wrong Answer

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



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

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

Submission status: Wrong Answer

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=len(li)
for i in range(a):
    index=s.index(li[i])
    for scope in range(1,l+1):
        if not s[index:index+l-scope+1] in result:
            result.append(s[index:index+l-scope+1])
print(result)
result.sort()
print(result[N-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
N = int(input())
l = len(s)
li=sorted(s)
result=[]
for i in range(l):
    index=s.index(li[i])
    for scope in range(1,l+1):
        if not s[index:index+l-scope+1] in result:
            result.append(s[index:index+l-scope+1])

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

Submission status: Wrong Answer

Solution code:
import re

str = input()
k = int(input())

strl = list(set([c for c in str]))
strl.sort()

substring = []
for h in strl:
	compiled = re.compile(h)

	st = 0
	m = compiled.search(str, st)
	while m:
		sub = m.start()
		for i in range(sub, len(str)):
			t = str[sub:i+1]
			if(not (t in substring)):
				substring.append(t)
		if(len(substring)-len(strl) >= k-1):
			break
	else:
		st = sub + 1
		m = compiled.search(str, st)
		continue
	break


substring.sort()
print(substring[k-1])

Submission status: Wrong Answer

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

n_substrings = {}
for i in range(len(s)):
    if s[i] in n_substrings:
        if (len(s) - i) > n_substrings[s[i]]:
            n_substrings[s[i]] = len(s) - i
    else:
        n_substrings[s[i]] = len(s) - i
n_substrings = sorted(n_substrings.items(), key=lambda x: x[1], reverse=True)

k = 0
strs = []
for str, i in n_substrings:
    if k < K:
        strs.append(str)
        k += i
# print(strs)

substrings = []
for i in range(len(s)):
    if not s[i] in strs:
        continue
    for j in range(len(s)-i+1):
        # print('i={}, i+j={}, s[i:i+j]={}'.format(i, i+j, s[i:i+j]))
        if s[i:i+j] != '':
            substrings.append(s[i:i+j])
substrings = sorted(set(substrings))
# print(substrings)
print(substrings[K-1])

Submission status: Wrong Answer

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

strl = []
for c in str:
    if(not (c in strl)):
        strl.append(c)
strl.sort()

substring = []
for h in strl:
	sub = str.find(h)
	for i in range(sub, len(str)):
		t = str[sub:i+1]
		if(not (t in substring)):
			substring.append(t)
	substring.sort()
	if(len(substring)-len(strl) >= k-1):
		break

substring.sort()
print(substring[k-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input();print(sorted([s[i:i+j]for i in range(len(s))for j in range(6)])[int(input())])

Submission status: Wrong Answer

Solution code:
s=input();print(sorted(s[i:i+j]for i in range(len(s))for j in range(6))[int(input())])

Submission status: Wrong Answer

Solution code:
#K-th Substring

#入力
s = input()
k = int(input())
 
 #計算
subs = set()
count = 0

for i in range(len(s)):
	if count > 6:
		i = int(len(s)/2)
	for j in range(i+1, len(s)+1):
		subs.add(s[i:j])
		count += 1

subs = list(subs) 
subs.sort()

#出力
print(subs[k-1])

Submission status: Wrong Answer

Solution code:
s = input()
k = int(input())
array = ""
dict_s = {}

for i in range(len(s)):
    for word in s[i:]:
        array += word
        dict_s[array] = 1
        dict_s[word] = 1
    print(array)
    array = ""
print(dict_s)
a = list(sorted(dict_s))
print(a[k-1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# s = input()
# K = int(input())
s = "atcoderandatcodeer"
K = 5


def substring(s, K):
    substrings = []
    length = len(s)
    for i in range(length):
        for j in range(1, K+1):
            if i + j > length:
                break
            substrings.append(s[i:i + j])
    unique_substrings = list(set(substrings))
    unique_substrings.sort()
    return unique_substrings[K - 1]


print(substring(s, K))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# s = input()
# K = int(input())
s = "aba"
K = 4


def substring(s, K):
    substrings = []
    length = len(s)
    for i in range(length):
        for j in range(1, K+1):
            if i + j > length:
                break
            substrings.append(s[i:i + j])
    unique_substrings = list(set(substrings))
    unique_substrings.sort()
    return substrings[K - 1]


print(substring(s, K))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# s = input()
# K = int(input())
s = "aba"
K = 4


def substring(s, K):
    substrings = [s]
    length = len(s)
    for i in range(length):
        for j in range(1, K+1):
            if i + j >= length:
                break
            substrings.append(s[i:i + j])
    unique_substrings = list(set(substrings))
    unique_substrings.sort()
    return substrings[K - 1]


print(substring(s, K))

Submission status: Wrong Answer

Solution code:
s = input().replace(' ', '')
number = int(input())
l = []
for n in range(0, len(s)):
  l.extend([s[n:n+1], s[n:n+2], s[n:n+3], s[n:n+4], s[n:n+5]])

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

sub = []
for i in range(1,int(len(s))+1):
    for j in range(0,6):
        if s[j:j+i] in sub:
            pass
        else:
            sub.append(s[j:j+i])

sub=sorted(sub)
print(sub[K-1])

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
L = len(s)
cand = []

if L > 5:
    c = []
    order = sorted(list(s))
    for i in range(L):
        if order[i] in c:
            pass
        else:
            c.append(order[i])
            if len(c) == 3:
                break
else:
    c = list(s)

for i in range(L):
    if s[i] in c:
        for j in range(i+1,min(i+K+1,L+1)):
            cand.append(s[i:j])
cand.sort()

i = 0
if len(cand) == 1:
    print(cand[0])
    exit()

while True:
    if i+1 < L:
        if cand[i] == cand[i+1]:
            i+=1
            continue
    K-=1
    i+=1
    if K == 0:
        print(cand[i-1])
        break

Submission status: Wrong Answer

Solution code:
s=input()
s=list(s)
k=int(input())
li=[]
st=[]
for i in range(len(s)):
    st=""
    for j in range(len(s)-i):
        st += s[i+j]
        li.append("".join(st))
li=list(set(li))
li=sorted(li)
print(li)
print(li[k-1])

Submission status: Wrong Answer

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

M=k*2
sss=set()
for i in range(M):
    for j in range(i+1,M+1):
        tmp = s[i:j]
        sss.add(tmp)
l = list(sss)
l.sort()
print(l[k-1])

Submission status: Wrong Answer

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

M=k
sss=set()
for i in range(M):
    for j in range(i+1,M+1):
        tmp = s[i:j]
        sss.add(tmp)
l = list(sss)
l.sort()
print(l[k-1])

Submission status: Wrong Answer

Solution code:
s = "atcoderandatcoder"#input()
k = 5#int(input())
def ss(s,k):
    M=len(s)
    sss=set()
    for i in range(M):
        for j in range(i+1,M+1):
            tmp = s[i:j]
            sss.update(tmp)
    l = list(sss)
    l.sort()
    #print(l)
    ret = l[k-1]
    return(ret)
 
res=ss(s,k)
print(res)

Submission status: Wrong Answer

Solution code:
import math

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

init = sorted(set(list(s)))[:K]
print(init)
n=0
z=[]
while(n<len(s)):
    x=[]
    for i in range(len(s)-n):
        if s[i] in init:
            x.append(s[i:i+n+1])
    y = sorted(set(x+z))
    z = y[:K]
    #z += y[:K]
    n += 1
print(sorted(set(z))[K-1])

Submission status: Wrong Answer

Solution code:
import math

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

n=0
z=[]
while(n<len(s)):
    x=[]
    for i in range(len(s)-n):
        x.append(s[i:i+n+1])
    y = sorted(set(x))
    z += y[:K]
    n += 1
print("a")

Submission status: Wrong Answer

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

subs = set()

for i in range(len(s)):
  for j in range(i+1, min(5+i+1, len(s)+1)):
    print(s[i:j])
    subs.add(s[i:j])
subs = list(subs) 
subs.sort()
print(subs[k-1])

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
l = []
x = []
y = []
for i in range(0,len(s)):
	for j in range(i+1,len(s)+1):
		l.append(s[i:j])
sum = 0
for i in range(0,len(l)):
	for j in range(0,len(l[i])):
		sum = sum + ord(l[i][j])
	x.append(sum)
	y.append(sum)
x.sort()
t = x[K-1]

for i in range(0,len(y)):
	if(y[i]==t):
		t = i

print(l[t])

Submission status: Wrong Answer

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

strs = set()
for i in range(len(s)):
    for j in range(K + 1):
        if i >= j:
            continue

        strs.add(s[i:j])

strs = sorted(strs)
print (strs[K - 1])

Submission status: Wrong Answer

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

u = [s[i:i+j+1] for i in range(len(s)) for j in range(k+1)]

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

Submission status: Wrong Answer

Solution code:
s = input()
K = int(input())
listS = list(s)
revS = sorted(set(listS))[0:5]
ans = []
for i in revS:
    if len(ans) >= 5:
        break
    n = listS.count(i)
    m = 0
    # 同じ文字の2文字目以降対応
    for j in range(n):
        if m + j >= n:
            break

        m = listS[m + j:].index(i) + m + j
        for k in range(len(listS[m + j:m + j + K])):
            ans.append("".join(listS[m: m + k + 1]))

ans = sorted(set(ans))
print(ans[K - 1])

Submission status: Wrong Answer

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

u = [s]
i = 0
while i < k:
    for j in range(len(s) - i):
        u.append(s[j:j+i+1])
    i += 1

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

Submission status: Wrong Answer

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


list_pair = []
i = 0
while i <= len(s):
    for j in range(i+1,min(len(s)+1,k+1)):
        list_pair.append(s[i:j])
    i = i + 1

list_pair = list(set(list_pair))

list_pair.sort()
print(list_pair[k-1])

Submission status: Wrong Answer

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

u = set()
i = 0
while i < k:
    for j in range(len(s) - i):
        u.add(s[j:j+i+1])
    i += 1

a = list(u)
sorted(a)
print(a[k-1])

Submission status: Wrong Answer

Solution code:
def alf(a):
    A = "abcdefghijklmnopqrstuvwxyz"
    return A.index(a)
 
def main():
    s = input()
    K = int(input())
    List = []
    for i in range(len(s)):
        for j in range(i+1, len(s)+1):
            if (s[i:j] in List) == False:
                List.append(s[i:j])
    List.sort()
    return List[K-1]+"adsfdaaf"
 
if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s = input()
k = int(input())
sb_str = []
for i in range(len(s)+1):
    for j in range(1+i,len(s)+1):
        if i < j:
            sb_str.append(s[i:j])
        if j > 5:
            break

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

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python3

s = input()
k = int(input())

alphabets = 'abcdefghijklmnopqrstuvwxyz'

dic = []

for char in alphabets:
    
    index = 0
    ss = []
    while index != -1:
        index = s.find(char, index)

        if index != -1:
            tmp = s[index:index + 5]
            print(tmp)
            isSubstring = False
            for sss in ss:
                if sss.find(tmp) == 0:
                    isSubstring = True
                    break
            if isSubstring == False:
                ss.append(tmp)

            index += 1

    if  len(ss) > 0:
        ss.sort()
        for x in ss:
            for i in range(len(x)):
                if x[0:i+1] not in dic:
                    dic.append(x[0:i+1])
                    if len(dic) >= k:
                        break
        if len(dic) >= k:
            break

print(dic[k-1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

e = list(input())
num =int(input())


alpha = list("abcdefghijklmnopqrstuvwxyz")
n = len(e)
a=[0]*(n+5)
#print(alpha)
for t in range(n) :
    for k in range(26):
        if alpha[k] == e[t]:
            a[t] = k
            break
#print(a)

ma = [-1]*5
mlen = 1

b= [1]*n
for k in range(n):
    b[k]= a[k]
ma[0] = np.argmin(b)

#print(ma[0],e[ma[0]])

for i in range(1,num):
#    print(b, ma[i-1], n, mlen)
    if ma[i-1] < (n-mlen):
        for k in range(n-mlen):
            b[k]= b[k] * 26 + a[k+mlen] 
        mlen += 1
    b[n-i]= 26 ** 5

    ma[i] = np.argmin(b)

#    for j in range(1,mlen+1):
#        print(e[ma[i]+j-1],end='')
#    print("")

for j in range(1,mlen+1):
    print(e[ma[num-1]+j-1],end='')
print("")

Submission status: Wrong Answer

Solution code:
s =input()
k =int(input())
a =[]
if len(s)==1:
    a.append(s)
else:
    for i in range(len(s)):
        for j in range(i,len(s)):
            if i!=j:
                a.append(s[i:j])
            else:
                a.append(s[i])
a.sort()
temp=""
cnt,i=0,0
for i in range(len(a)):
    if temp != a[i]:
        cnt += 1
        if cnt ==k:
            break
    temp = a[i]
print(a[i])

Submission status: Wrong Answer

Solution code:
s=input()
k=int(input())
l=len(s)
a={s[i:i+j+1] for i in range(l) for j in range(k+1)}
a=list(a)
print(a)
a.sort()
print(a)
print(a[k-1])

Submission status: Wrong Answer

Solution code:
s_list = list(input())
k = int(input())
s_sort = sorted(s_list)
a_list = []
for i, s in enumerate(s_sort):
    if i == 5:
        break
    idx = s_list.index(s)
    for i in range(1, 6):
        a_list.append("".join(s_list[idx:idx+i]))
    s_list[idx] = "@"
a = list(set(a_list))
for i, s in enumerate(a):
    if "@" in s:
        a[i] = s.replace("@", s_sort[0])
a = sorted(a)
print(a[k - 1])