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: Accepted

Solution code:
s = input()
K = int(input())
Kinds = set(s)
sort_s = sorted(list(Kinds))
cand = set([]) | set(sort_s)
for h in sort_s:
    first_i = [i for i, c in enumerate(s) if c == h]
    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: Accepted

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

n = len(s)
a = []
for i in range(n+1):
    for j in range(6):
        if len(s[i:i+j]) >=1:
            if not s[i:i+j] in a:
                a.append(s[i:i+j])
a.sort()
print(a[k-1])

Submission status: Accepted

Solution code:
s = raw_input()
k = int(raw_input())
l = len(s)
ls = []
for a in range(l):
    for b in range(a+1,min(a+k+1,l+1)):
        if ls.count(s[a:b]) == 0:
            ls.append(s[a:b])
ls.sort()
print ls[k-1]

Submission status: Accepted

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

sub = set()
for k in range(1, 6):
    for i in range(len(s)):
        sub.add(s[i:i+k])

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

Submission status: Accepted

Solution code:
# cook your dish here
# from math import * 
#for _ in range(int(input().strip())):

s = input()
k = int(input())
var = 0
sub = set()
size = 0
for var in range(97,123):
    if len(sub)>k:
        break
    for i in range(len(s)):
        size=0
        if s[i]==chr(var):
            for j in range(i,len(s)):
                if size>=k:
                    break
                sub.add(s[i:(j+1)])
                size+=1 
l = list(sub)
l.sort()
print(l[k-1])

Submission status: Accepted

Solution code:

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

array = []
max_length = 6
if(len(s) < 5):
    max_length = len(s) + 1
for l in range(1, max_length):
    for i in range(len(s)):
        if i + l > len(s):
            continue
        array.append(s[i:i+l])
        
array = list(set(array))
array.sort()
print(array[k-1])

Submission status: Accepted

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

l = sorted(set(l))

print(l[k-1])

Submission status: Accepted

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from numba import njit
@njit("i8(i8)")

def solve(s,k):
  l=[i for i in s]
  ans=l
  mae=[]
  for i in range(len(s)-1):
    nlen=i+1
    for j in range(len(l)-1):
      lj=l[j+1]
      now=l[j]+lj[nlen-1:]
      mae.append(now)

    ans.extend(mae)
    l=mae
    mae=[]

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


s=input()
k=int(input())
solve(s,k)

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
a = []

for i in range(5):
    for j in range(i+1, len(s)):
        if j - i >= 5: break
        a.append(s[i:j])

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

Submission status: Runtime Error

Solution code:
S = input().rstrip()
N = len(S)
K = int(input())
A = set()
if N == 1:
    print(S)
    exit()
for i in range(N-1):
    A.add(S[i:])
A = list(A)
A.sort()
print(A)
cnt, i = 0, 0
while cnt + len(A[i]) < K:
    cnt += len(A[i])
    i += 1
print(A[i][:K-cnt])

Submission status: Runtime Error

Solution code:
def main2():
    S=list(input())
    K=int(input())
    N=len(S)

    P=sorted(S)
    l=[]
    k=0
    while len(l)<=5:
        for n in range(N):
            if S[n]==P[k]:
                for i in range(1,6):
                    if n+i<N-1:
                        tmp="".join(S[n:n+i])
                        if tmp not in l:
                            l.append(tmp)
        k+=1
    l.sort()
    print(l[K-1])

if __name__=="__main__":
    main2()

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
li = []
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        li += [s[i:j]]
li2 = set(li)
li3 = sorted(li2)
print(li3[k-1]

Submission status: Runtime Error

Solution code:
s = input()
n = len(s)
k = int(input())
substr = []
for j in range(1, k+1):
    for i in range(n-j):
        sub = s[i:i+j]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])

Submission status: Runtime Error

Solution code:
import collections

s = input()
k = int(input())
b = collections.Counter(s)
c = sorted(b.items())
con = []
n = 0
while True:
    con.append(c[n][0])
    if len(con) == k:
        break
    for i in range(len(c)):
        check = c[n][0] + c[i][0]
        if check in s:
            con.append(check)
            if len(con) >= k:
                break
            for i_2 in range(len(c)):
                check_2 = check + c[i_2][0]
                if check_2 in s:
                    con.append(check_2)
                    if len(con) >= k:
                        break
                    for i_3 in range(len(c)):
                        check_3 = check_2 + c[i_3][0]
                        if check_3 in s:
                            con.append(check_3)
                            if len(con) >= k:
                                break
                            for i_4 in range(len(c)):
                                check_4 = check_3 + c[i_4][0]
                                if check_4 in s:
                                    con.append(check_4)
                                    if len(con) >= k:
                                        break
    if len(con) == k:
        break                              
    n +=1
print(con[k-1])

Submission status: Runtime Error

Solution code:
import collections

s = input()
k = int(input())
b = collections.Counter(s)
c = sorted(b.items())
con = []
n = 0
while True:
    con.append(c[n][0])
    if len(con) == k:
        break
    for i in range(len(c)):
        check = c[n][0] + c[i][0]
        if check in s:
            con.append(check)
            if len(con) >= k:
                break
            for i_2 in range(len(c)):
                check_2 = check + c[i_2][0]
                if check_2 in s:
                    con.append(check_2)
                    if len(con) >= k:
                        break
                    for i_3 in range(len(c)):
                        check_3 = check_2 + c[i_3][0]
                        if check_3 in s:
                            con.append(check_3)
                            if len(con) >= k:
                                break
                            for i_4 in range(len(c)):
                                check_4 = check_3 + c[i_4][0]
                                if check_4 in s:
                                    con.append(check_4)
                                    if len(con) >= k:
                                        break
                                    break
                                break
                            break
                        break
                    break
                break
            break
        break
    n +=1
print(con[k-1])

Submission status: Runtime Error

Solution code:
import collections

s = input()
k = int(input())
b = collections.Counter(s)
c = sorted(b.items())
con = []
n = 0
while True:
    con.append(c[n][0])
    if len(con) >= k:
        break
    for i in range(len(c)):
        check = c[n][0] + c[i][0]
        if check in s:
            con.append(check)
            if len(con) >= k:
                break
            for i_2 in range(len(c)):
                check_2 = check + c[i_2][0]
                if check_2 in s:
                    con.append(check_2)
                    if len(con) >= k:
                        break
                    for i_3 in range(len(c)):
                        check_3 = check_2 + c[i_3][0]
                        if check_3 in s:
                            con.append(check_3)
                            if len(con) >= k:
                                break
                            for i_4 in range(len(c)):
                                check_4 = check_3 + c[i_4][0]
                                if check_4 in s:
                                    con.append(check_4)
                                    if len(con) >= k:
                                        break
    n +=1
print(con[k-1])

Submission status: Runtime Error

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

S_=set([])
for s in tqdm.tqdm_notebook(range(len(S))):
    s_temp=S[s]
    S_.add(s_temp)
    S_temp_list=[s_temp,'']
    for e in range(s+1,len(S)):
        if e-s > K+2:
            break
        S_temp_list[1]=S[e]
        s_temp=''.join(S_temp_list)
        S_.add(s_temp)
        S_temp_list[0]=s_temp
        
S_=list(set(S_))
S_.sort()
# print(S_)
print(S_[K-1])

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
t=int(input())
if t==1:
    print(s)
    exit()
ans=set()
for l in range(n-1):
    for r in range(1,min(t,n-l)):
        ans.add(s[l:r])
aa=list(ans)
aa.sort()
print(aa[t-1])

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
t=int(input())
if t==1:
    print(s)
    exit()
ans=set()
for l in range(n-1):
    for r in range(l+1,n+1):
        ans.add(s[l:min(l+t,r)])
aa=list(ans)
aa.sort()
print(aa[t-1])

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
t=int(input())
if t==1:
    print(s)
    exit()
ans=set()
for l in range(n-1):
    for r in range(l+1,n+1):
        ans.add(s[l:min(l+k,r)])
aa=list(ans)
aa.sort()
print(aa[t-1])

Submission status: Runtime Error

Solution code:
s=input()
n=len(s)
t=int(input())
if t==1:
    print(s)
    exit()
ans=set()
for l in range(n-1):
    for r in range(l+1,n+1):
        ans.add(s[l:r])
aa=list(ans)
aa.sort()
print(aa[t-1])

Submission status: Runtime Error

Solution code:
def calc( s , k , n):

	bruh = {}
	for i  in range(1, n + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	print( another[k - 1])

s = raw_input()

k = int(raw_input())

n = len(s)
 
calc( s , k , n)

Submission status: Runtime Error

Solution code:
def calc( s , k , n):

	bruh = {}
	for i  in range(1, n + 1): # length
		for j in range( n - ( i - 1)): # start 
			bruh[s[j: j + i:]] = 0
	another = bruh.keys()
	another = sorted(another)
	return another[k - 1]

s = raw_input()

k = int(raw_input())

n = len(s)
 
print( calc( s , k , n))

Submission status: Runtime Error

Solution code:
s = raw_input()

k = int(raw_input())

n = len(s)
bruh = {}
for i  in range(1, n + 1): # length
	for j in range( n - ( i - 1)): # start 
		bruh[s[j: j + i:]] = 0
another = bruh.keys()
another = sorted(another)
print(another[k - 1])

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
from heapq import *
def input(): return sys.stdin.readline().strip()


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

    initial = []
    for i, c in enumerate(s):
        heappush(initial, (c, i))

    appeared = set([])
    string =[]
    cnt = 0
    while True:
        c, i = heappop(initial)
        for j in range(i + 1, L + 1):
            heappush(string, s[i:j])
        while initial[0][0] == c:
            c, i = heappop(initial)
            for j in range(i + 1, L + 1):
                heappush(string, s[i:j])
        while string:
            ans = heappop(string)
            #print(ans)
            if ans not in appeared:
                cnt += 1
                appeared.add(ans)
            if cnt == K:
                print(ans)
                return


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    s = input()
    N = len(s)
    K = ii()

    if N <= 50:
        A = set()
        for i in range(N):
            for j in range(i, N):
                A.add(s[i:j+1])
        A = list(A)
        A.sort()
        print(A[K-1])
    else:
        c = sorted(list(s))[0]
        A = set()
        for i in range(N):
            if s[i] == c:
                for j in range(5):
                    A.add(s[i:i+j+1])
        A = sorted(list(A))
        print(A[K-1])



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    s = input()
    N = len(s)
    K = ii()

    if N <= 50:
        A = set()
        for i in range(N):
            for j in range(i, N):
                A.add(s[i:j+1])
        A = list(A)
        A.sort()
        print(A[K-1])
    else:
        A = list(s)
        A.sort()
        c = A[0]
        l = []
        for i in range(N):
            if s[i] == c:
                l.append(i)
        x = set()
        for v in l:
            for i in range(len(s[v:v+5])):
                x.add(s[v:v+i+1])
        x = list(x)
        x.sort()
        print(x[K-1])



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
#import sys
#import numpy as np
import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
s=input()
k=int(input())
n=len(s)
a=[chr(i) for i in range(ord('a'),ord('z')+1)]
ans=set()
for i in a:
    if i not in s:
        continue
    if len(ans)>=5:
        break
    for c in range(n):
      if s[c]==i:
          l=c
          r=c
          ans.add(s[l])
          while True:
            if  r>n or s[r]==i:
                break
            ans.add(s[l:r+1])
            r+=1
ans=list(ans)
ans.sort()
print(ans[k-1])

Submission status: Runtime Error

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

chars = sorted(set(S))
checked = set()


def dfs(s):
    for c in chars:
        next_s = s + c
        if next_s not in checked and next_s in S:
            checked.add(next_s)
            if len(checked) == K:
                print(next_s)
                return
            elif len(next_s) <= len(S):
                dfs(next_s)


dfs('')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000)

def main():
    s = readline().rstrip().decode()
    K = int(readline())
    #sに含まれる文字を一文字ずつ抽出する.
    #ここで抽出した文字を組み合わせて辞書順に文字列を構成していく
    #K<=5だから高々26^5個の文字列を構成することになる
    l = sorted(list(set(s)))
    #cnd:=構成した文字列を辞書順に格納するリスト
    cnd = []
    #f(sub):=subから構成可能なK文字以下のSの部分文字列を構成する関数
    def f(sub):
        cnd.append(sub)
        if len(sub) < K: 
            #lから選んでsubに一文字追加する
            for i in l:
                nx = sub+i
                if nx in s:
                    f(nx)
    for i in l:
        f(i) 
    print(cnd[K-1j])
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
n = len(s)
# print(s,k,n)

c = set()
for i in range(n-1):
    for j in range(i+1, n+1):
        c.add(s[i:j])

c=list(c)
# print(c)
c.sort()
# print(c)

if len(c) > 0: print(c[k-1])
else: print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()
k=int(input())
l=[]
for i in range(n):
  for j in range(i:n):
    a=s[i:j+1]
    l.append(a)
l=set(l)
l.sort()
print(l[k-1])

Submission status: Runtime Error

Solution code:
s = list(input())
k =  int(input())
s.append((''))
Dict = {}
dict_keys = []
for left in range(len(s)):
    for right in range(left+1,len(s)):
        string = ''.join(s[left:right])
        if len(string)>k:
            brak
        if string not in Dict.keys():
            Dict[string] = True
Dict = sorted(Dict.keys())
print(Dict[k-1])

Submission status: Runtime Error

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
k=I()
n=len(s)
u=sorted(list(s))[0]
#print(s)
strs=[]
if n>=5:
    for i in range(n):
        if s[i]==u:
            for j in range(1,6):
                strs.append(s[i:i+j])
    #print(strs)
    #print(sorted(set(strs))[k-1])
else:
    for i in range(n):
        for j in range(i+1,n+1):
            #print(i,j)
            #print(s[i:j])
            strs.append(s[i:j])
#print(strs)
print(sorted(set(strs))[k-1])

Submission status: Runtime Error

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

cands = []
for i in range(len(s) -k+1):
  for j in range(k):
    cands.append(s[i:j+2])
cands = list(set(cands))
cands.sort()
print(cands[k-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
l = len(s)
print(sorted(set(s[i:j] for i, j in combinations(range(l+1), 2) if j - i <= k))[k-1])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
from collections import defaultdict #d = defaultdict(int) d[key] += value
import itertools #list(accumulate(A))

#S = input()
S = 'abcdefghijklmnopqrstuvwxyz'*200
K = ii()
N = len(S)
'''
N = len(S)
d = defaultdict(int)
for i in range(N+1):
    for j in range(N-i+1):
        d[S[j:j+i+1]] += 1
l = sorted(d.keys())
#print(l)
print(l[K])
'''

alphabets = list('abcdefghijklmnopqrstuvwxyz')

#print(len(alphabets))
l = []
for alpha in alphabets:
    for i, m in enumerate(S):
        if m == alpha:
            for j in range(1, N-i+1):
                l.append(S[i:i+j])

    l = sorted(set(l))
    if len(l) >= K:
        print(l[K-1])
        exit()

Submission status: Runtime Error

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

ans = set()

for i in range(len(S)):
    for j in range(len(S)+1):
        if (j-i)>=5:
            break
        if i==j:
            ans.add(S[i])
            continue
        if S[i:j]=="":
            continue
        ans.add(S[i:j])
ans = sorted(list(ans))
print(ans[K-1])

Submission status: Runtime Error

Solution code:
s=list(input())
k=int(input())
S=s
l=s
s=' '.join(s)
l=sorted(l)
m=l[0]
j=1
s=s.replace(m,str(j))
for i in range(1,len(l)):
    if l[i]!=l[i-1]:
        j += 1
        m=l[i]
        s=s.replace(m,str(j))
s=list(map(str,s.split()))

L1=[]
L2=[]
for i in range(len(s)):
    if s[i]=='1':
        for j in range(i,len(s)):
            n=s[i:j+1]
            n=''.join(n)
            if n not in L1:
                L1.append(n)
    if s[i]=='2':
        for j in range(i,len(s)):
            n=s[i:j+1]
            n=''.join(n)
            if n not in L2:
                L2.append(n)
            
if len(L1)>=k:
    L1.sort()
    ans=L1[k-1]
else:
    k=k-len(L1)
    L2.sort()
    ans=L2[k-1]
st=[]
ansL=[x for x in ans]
for i in range(len(ansL)):
    ind=s.index(ansL[i])
    st.append(S[ind])

print(''.join(st))

Submission status: Runtime Error

Solution code:
def solve():
    S = input()
    K = int(input())

    N = len(S)

    st = set()

    for left in range(N):
        for right in range(left+1,N):
            if right - left > K:
                break
            st.add(S[left:right])
    
    tmp = list(st)
    tmp.sort()
    print(tmp[K-1])

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
def solve():
    S = input()
    K = int(input())

    N = len(S)

    st = set()

    for left in range(N-1):
        for right in range(left+1,N+1):
            if right - left > K:
                break
            st.add(S[left:right])
    
    tmp = list(st)
    tmp.sort()
    print(tmp[K-1])

if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
n = len(list(s))
kouho = set()
for i in range(n):
    for d in range(1, k + 1):
        if i + d < n:
            kouho.add(s[i : i + d])
ans = list(kouho)
ans.sort()
print(ans[k - 1])

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10000)
def resolve():
    s = input()
    K = int(input())
    mem = []
    kinds = list(set(s)).sort()
    skips = []
    if len(kinds) > K:
        skips = kinds[K+1:]
    for j in range(len(s)): # window starts at
        if s[j] in skips:
            continue
        for i in range(1, len(s)+1): # window size
            subs = s[j:j+i]
            mem.append(subs)
    mem = sorted(list(set(mem)))
    # print(mem)
    print(mem[K-1])


if '__main__' == __name__:
    resolve()

Submission status: Runtime Error

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

N = len(s)
word = []
for i in range(N-k+1):
    j = i+1
    for _ in range(k):
        word.append(s[i:j])
        j += 1
word.sort()

from collections import Counter
c = Counter(word)
keys, values = zip(*c.most_common())
ans = []
for i in range(len(keys)):
    ans.append(keys[i])
ans.sort()
print(ans[k-1])

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    k = int(input())

    array = []
    for i in range(len(S)):
        for j in range(i+1,len(S)+1):
            if j-i < k:
                array.append(S[i:j])
    array = list(set(array))
    array.sort()
    print(array[k-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    k = int(input())

    array = []
    for i in range(len(S)):
        for j in range(i+1,len(S)+1):
            if j-i < len(S):
                array.append(S[i:j])
    array = list(set(array))
    array.sort()
    print(array[k-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    S = input()
    k = int(input())

    array = []
    for i in range(len(S)):
        for j in range(i+1,len(S)+1):
            array.append(S[i:j])
    array = list(set(array))
    array.sort()
    print(array[k-1])


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
s_list = []
for i in range(len(s)):
  s_list.append(s[i:i+k])
s_list = sorted(list(set(s_list)))
if len(s_list[0]) == k:
  print(s_list[0])
else:
  n = len(s_list[0]) + len(s_list[1])
  if n == k:
    print(s_list[2][0])
  elif n < k:
    print(s_list[2][0:k-n+1])
  else:
    print(s_list[1][0:n-k+1])

Submission status: Runtime Error

Solution code:
def main():
    s = input()
    k = int(input())
    ss = set()
    if len(s) <= 5:
        for i in range(len(s)):
            for j in range(i+1, len(s)+1):
                ss |= {s[i:j]}
    else:
        m = sorted(s)[0]
        for i in range(len(s)):
            if s[i] == m:
                for j in range(i+1, len(s)+1):
                    ss |= {s[i:j]}
    print(sorted(ss)[k-1])

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

S=[]
n=len(s)
for i in range(n):
  for j in range(i+1,n+1):
    S.append(s[i:j])
S=list(set(S))
S.sort()
print(S[K-1])

Submission status: Runtime Error

Solution code:
S=input()
K=int(input())
l = []
for i in range(len(S)):
  for j in range(i,len(S)):
    sub_s = S[i:j]
    l.append(sub_s)
ans = sorted(list(set(l)))
ans.remove('')
print(ans[K-1])

Submission status: Runtime Error

Solution code:
s = input()
k = int(input())
t = sorted(s)[k-1]
data = []
for i in range(len(s)):
    if s[i] <= t:
        data.append(s[i:])
data.sort()
if len(data) > k:
    data = data[:k]

ndata = []
for ss in data:
    for i in range(len(ss)):
        ndata.append(ss[:i+1])
ndata = list(set(ndata))
ndata.sort()
print(ndata[k-1])

Submission status: Runtime Error

Solution code:
prime = [2,3,5,7,11,13,17,19,23,29,31]
pow = [1]
for p in prime:
  i=1
  while p**i<=1000:
    pow.append(p**i)
    i += 1
X = int(input())
x = X
while x>0:
  if x in pow:
    ans = x
    break
  x -= 1
print(ans)

Submission status: Runtime Error

Solution code:
def dfs(s):
    global K, cnt, ans, S
    if cnt == K:
        ans = s
        return
    for c in alpha:
        if S.count(s + c) > 0:
            cnt += 1
            dfs(s + c)


S = input()
K = int(input())
cnt = 0
alpha = [chr(ord('a') + i) for i in range(26)]
ans = ''
dfs('')
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(20000000)

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


def calculate(str, k):
    if len(str) > 5:
        criterion = ["a", "b", "c", "d", "e"]
    else:
        criterion = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
                     "u", "v", "w", "x", "y", "z"]
    objs = {}
    for index, s in enumerate(str):
        if s in criterion:
            for i in range(index+1,len(str)+1):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)

Submission status: Runtime Error

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


def calculate(str, k):
    if len(str) > 5:
        criterion = ["a", "b", "c", "d", "e"]
    else:
        criterion = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
                     "u", "v", "w", "x", "y", "z"]

    objs = {}
    for index, s in enumerate(str):
        if s in criterion:
            for i in range(index+1,len(str)+1):
                objs.__setitem__(str[index:i],True)

    arr = sorted(objs.keys())

    print(arr[k-1])

calculate(s, K)

Submission status: Runtime Error

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


def calculate(s, k):
    if len(s) > 5:
        ignoreCriterion = ["f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
                           "y", "z"]
    else:
        ignoreCriterion = []

    length = len(s)

    objs = {}
    for i in range(1, length + 1):
        for j in range(0, length + 1 - i):
            if s[j] in ignoreCriterion:
                continue
            objs.__setitem__(s[j:j + i], True)

    s = sorted(objs.keys())

    print(s[k-1])


calculate(s, K)

Submission status: Runtime Error

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

l = []
for i in range(len(s)-1):
    for y in range(i+1,len(s)+1):
        if not ''.join(s[i:y]) in l:
            l.append(''.join(s[i:y]))

l.sort()
if len(s) == 1:
    print(s[0])
else:
    print(l[k-1])

Submission status: Runtime Error

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

l = []
for i in range(len(s)-1):
    for y in range(i+1,len(s)+1):
        if not str(s[i:y]) in l:
            l.append(str(s[i:y]))

l.sort()
if len(s) == 1:
    print(s)
else:
    print(l[k-1])

Submission status: Runtime Error

Solution code:
S = input()
K = int(input())
target = []
def func(split_range):
    for i in range(0,len(S)-split_range+1):
        #print(S[0:0])
        #print(S[0:1])
        #print(S[i:i+split_range])
        #print(S[i:i+split_range])
        target.append(S[i:i+split_range])

for i in range(1,len(S)+1):
    #print(i)
    func(i)
#print(target)
print(sorted(set(target))[K-1]

Submission status: Runtime Error

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

Submission status: Runtime Error

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

ans = []
now = ""

for index, i in enumerate(s):
  now = i
  ans.append(i)

  for indexs, k in enumerate(s):
    if indexs <= index:
      continue

    if s[indexs] == now[-1]:
      break

    now += k
    ans.append(now)
    
ans = list(set(ans))
ans.sort()

print(ans[K-1])

Submission status: Runtime Error

Solution code:
x = int(input())
 
ans=0
for i in range(1,x):
    for j in range(2,x):
        if i**j<=x:
            ans=i**j
        else:
            break
print(ans)