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: Time Limit Exceeded

Solution code:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

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

    chars = sorted(set(s))

    num_substr = 0
    for char in chars:
        substrs = set()
        for i in range(len(s)):
            if s[i] == char:
                for j in range(i, len(s)):
                    substrs.add(s[i:j + 1])
        
        if num_substr + len(substrs) < k:
            num_substr += len(substrs)
            # len_substr -= 1
            continue
        else:
            print(sorted(list(substrs))[k - num_substr - 1])
            break




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N=len(s)
S=set()
for i in range(N):
    for j in range(i+1,N+1):
        S.add(s[i:j])
l=sorted(list(S))
print(l[K-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

x = sorted(list(set(r)))
print(x[K-1])

Submission status: Time Limit Exceeded

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

ss = sorted(list(set(s)))

def f(s, c):
    indexes = []
    # r = []
    st = set()
    for i, si in enumerate(s):
        if si == c:
            indexes.append(i)
    for i in indexes:
        for j in range(i, len(s)):
            x = s[i:j+1]
            # r.append(x)
            st.add(x)
    # return r
    return sorted(list(st))

# st = set()
r = []
for ssi in ss:
    x =  f(s, ssi)
    r += x
    if len(r) > 5:
        break


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

Submission status: Time Limit Exceeded

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

ss = sorted(list(set(s)))

def f(s, c):
    indexes = []
    # r = []
    st = set()
    for i, si in enumerate(s):
        if si == c:
            indexes.append(i)
    for i in indexes:
        for j in range(i, len(s)):
            x = s[i:j+1]
            # r.append(x)
            st.add(x)
    # return r
    return st

# print(f('abcab', 'a'))

st = set()
for ssi in ss:
    x =  f(s, ssi)
    st = st.union(x)
    if len(st) > 5:
        break

x = sorted(list(st))
ans = x[K-1]
print(ans)

Submission status: Time Limit Exceeded

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

S = []
for len_i in range(1,len(s)+1):
	for left_j in range(len(s)-len_i+1):
		cur_s = s[left_j:left_j+len_i]
		if cur_s not in S:
			S.append(s[left_j:left_j+len_i])
S.sort()
# print(S)
print(S[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
K = int(input())
lst = []
for end in range(1, len(s)+1):
    start = 0
    while end < len(s)+1:
        if s[start:end] not in lst:
            lst.append(s[start:end])
        start += 1
        end += 1
lst.sort()
print(lst[K-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]

  for i in index_list:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)
  if len(s)-min(index_list) >=k:
    break

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)
  if len(index) >= k:
    break

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break

print(sorted(list(set(substrings)))[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
substrings = []
index = []
for ss in sorted(list(set(s))):
  index_list = [n for n, v in enumerate(s) if v == ss]
  index.append(index_list)

for ind in index:
  for i in ind:##初期位置
    for j in range(1,len(s)-i+1):##長さ
      substrings.append(s[i:i+j])
  if len(set(substrings)) >= k:
    break
  

print(sorted(list(set(substrings)))[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
substrings = []
for i in range(len(s)):##初期位置
  for j in range(1,len(s)-i+1):##長さ
    substrings.append(s[i:i+j])
print(sorted(list(set(substrings)))[k-1])

Submission status: Time Limit Exceeded

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

dic={}
for i in range(len(s)):
    dic[s[i]]=1
    
dic=sorted(dic,key=lambda x:x[0])
check=0
se=set()
for i in dic:
    for j in range(len(s)):
        if s[j]!=i:
            continue
        k=j+1
        se.add(i)
        sss=i
        while k<len(s):
            sss+=s[k]
            se.add(sss)
            k+=1
    if len(se)>=kk:
        break
se=sorted(list(se))
print(se[kk-1])

Submission status: Time Limit Exceeded

Solution code:
s=str(input())
K=int(input())
tmp=0
dic={}
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    if s[i:j] not in dic.values():
      dic[tmp]=s[i:j]
      tmp+=1
new_dic=sorted(dic.values())
print(new_dic[K-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string



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


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



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

Submission status: Time Limit Exceeded

Solution code:
S = input()
N = len(S)
K = int(input())
Data = set()

for s in range(N):
    for e in range(s+1,N+1):
        Data.add(S[s:e])
print(sorted(Data)[K-1])

Submission status: Time Limit Exceeded

Solution code:
import heapq
s = input()
K = int(input())
h = []

for i in range(1,len(s)+1):
    for j in range(len(s)-i+1):
        t = s[j:j+i]
        if len(h) < K:
            if t not in h:
                heapq.heappush(h,t)
        else:
            if t not in h:
                tmp = []
                for _ in range(K-1):
                    tmp.append(heapq.heappop(h))
                x = heapq.heappop(h)
                
                if t < x:
                    heapq.heappush(h,t)
                else:
                    heapq.heappush(h,x)
                for e in tmp:
                    heapq.heappush(h,e)
for i in range(K-1):
    x = heapq.heappop(h)
print(heapq.heappop(h))

Submission status: Time Limit Exceeded

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

# Sのsubstring全列挙を行う
ans = []

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

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

Submission status: Time Limit Exceeded

Solution code:
s = list(input())
k = int(input())
n = len(s)
substring = []

for i in range(n):
    tmp = ""
    for l in s[i::]:
        tmp += l
        if tmp in substring:
            continue

        else:
            substring.append(tmp)

substring.sort()

print(substring[k - 1])

Submission status: Time Limit Exceeded

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

s_set = set()

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
s=input()
k=int(input())
copy=s[:]
lists=list(s)
orderlists=[]
for i in range(len(s)):
    for j in range(i,len(s)):
        if  "".join(lists[i:j+1]) not in orderlists:
            orderlists.append("".join(lists[i:j+1])) 
        else:
            continue

anslists=sorted(orderlists)
print(anslists[k-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

set_ = set()

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

res = sorted(list(set_))[k-1]
print(res)

Submission status: Time Limit Exceeded

Solution code:
# ABC097 C - K-th Substring
s = input()
k = int(input())

n = len(s)
d = set()
l = []

for i in range(n):
    for j in range(n-i):
        d.add(s[j:j+i+1])
l = list(d)
l.sort()

print(l[k-1])

Submission status: Time Limit Exceeded

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

unigram = sorted(set(S))

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

Submission status: Time Limit Exceeded

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

se=set()
for i in range(97,123):
    for j in range(len(s)):
        if s[j]==chr(i):
            for l in range(j+1,len(s)+1):
                se.add(s[j:l])
    if len(se)>=k:
            break
    
se=sorted(se)

print(se[k-1])

Submission status: Time Limit Exceeded

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

dic={}
for i in range(97,123):
    for j in range(len(s)):
        if s[j]==chr(i):
            for l in range(j+1,len(s)+1):
                dic[s[j:l]]=1
    if len(dic)>=k:
            break
    
dic=sorted(dic.items(),key=lambda x:x[0])

print(dic[k-1][0])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

N = len(s)
Ans = ["z"*5000]*5
for i in range(N):
    for j in range(i,N):
        tmp = s[i:j+1]
        for k in range(5):
            if Ans[k] > tmp:
                if not (tmp in Ans):
                    for l in range(4-k):
                        Ans[4-l] = Ans[3-l]
                    Ans[k] = tmp
                    break       
print(Ans[K-1])

Submission status: Time Limit Exceeded

Solution code:
import bisect

def main():
    s = input()
    k = int(input())
    n = len(s)
    dp = []
    for l in range(n):
        for r in range(l + 1, n + 1):
            t = s[l:r]
            i = bisect.bisect_right(dp, t)
            if i>0:
                if t == dp[i-1]: continue
            if len(dp) < k:
                bisect.insort(dp, t)
            elif t < dp[-1]:
                dp.pop()
                bisect.insort(dp, t)
    print(dp[-1])

main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

def main():
    s = input()
    k = int(input())
    n = len(s)
    dp = []
    for l in range(n):
        for r in range(l + 1, n + 1):
            t = s[l:r]
            if t in dp: continue
            if len(dp) < k:
                bisect.insort(dp, t)
            elif t < dp[-1]:
                dp.pop()
                bisect.insort(dp, t)
    print(dp[-1])

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline()))
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

s =  sys.stdin.readline().rstrip()
K =  int(sys.stdin.readline())


current = s[0]
cnt = 0
L = []
for stride in range(1, len(s) + 1):
    for i in range(len(s) - stride + 1):
        L.append(s[i:i + stride])

print(sorted(list(set(L)))[K - 1])

Submission status: Time Limit Exceeded

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

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

f = defaultdict(lambda : 0)
s = input()
k = I()
n = len(s)
for i in range(n):
    for j in range(i+1,n+1):
        f[s[i:j]] = 1
f = sorted(f.items())
print(f[k-1][0])

Submission status: Time Limit Exceeded

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

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Time Limit Exceeded

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

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc097/tasks/arc097_a
# C - K-th Substring

s = input().split()[0]
K = int(input().split()[0])

sub_s_list = []

for i in range(len(s)):
    for j in range(len(s)):
        sub_s = s[i:i+j+1]
        sub_s_list.append(sub_s)

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    s = input()
    K = int(input())
    starts = sorted(list(set(list(s))))
    count = 0
    ind = {}
    for start in starts:
        for i in range(len(s)):
            if s[i] == start:
                for j in range(i+1, len(s)+1):
                    if s[i:j] not in ind:
                        count += 1
                        ind[s[i:j]] = 1
        if count >= K:
            break
    # print(ind)
    ind = sorted(list(ind))
    print(ind[K-1])

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

candidate=set()

for i in range(1, len(S)+1):
    for j in range(len(S)-i+1):
        candidate.add(S[j:j+i])

candidate=sorted(list(candidate))
print(candidate[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin

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

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, i+k+1):
        t = s[i:j+1]
        if t not in li:
            li.append(s[i:j+1])
li.sort()
print(li[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin

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

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, len(s)):
        t = s[i:j+1]
        if t not in li:
            li.append(s[i:j+1])
li.sort()
print(li[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys

stdin = sys.stdin

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

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i:j+1] not in li:
            li.append(s[i:j+1])
li.sort()
print(li[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
from collections import  Counter
import statistics
import math

stdin = sys.stdin

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

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i:j+1] not in li:
            li.append(s[i:j+1])
li.sort()
print(li[k-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import deque
from collections import  Counter
import statistics
import math

stdin = sys.stdin

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

s = input()
k = ni()
li = []
for i in range(len(s)):
    for j in range(i, len(s)):
        li.append(s[i:j+1])
li = list(set(li))
li.sort()
print(li[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
n = len(s)
heads = []
d = set()
for c in s:
    d.add(c)

for key in d:
    heads.append(key)

heads.sort()
ind = 0
ans = []
while True:
    if ind > len(heads)-1:
        break
    head = heads[ind]
    p = set()
    for i in range(len(s)):
        if s[i] == head:
            p.add(i)
    # print(head)
    ext = 0
    while True:
        flag = False
        dis = -1
        for key in p:
            if key+ext > n-1:
                flag = True
                dis = key
        if flag:
            p.discard(dis)
            # print(ext)
            # print(p)
        if not p:
            break
        for key in p:
            temp = s[key]
            for j in range(1,ext+1):
                temp += s[key+j]
            # print(temp)
            if temp not in ans:
                ans.append(temp)
        ext += 1
        if len(ans) >= 500:
            break
    if len(ans) >= 500:
        break
    else:
        ind += 1

# print(ans)
ans.sort()
print(ans[k-1])

# for i in range(len(s)):
#     if

Submission status: Time Limit Exceeded

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

#時間計測テスト

s = str(input())
K = I()
n = len(s)

a = []
for i in range(n):
    for j in range(i+1,n+1):
        a.append(s[i:j])

a.sort()
num = 0
used = []
for i in range(len(a)):
    if a[i] in used:
        continue
    else:
        num += 1
        used.append(a[i])
        if num == K:
            print(a[i])
            exit()

Submission status: Time Limit Exceeded

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

s = str(input())
K = I()
n = len(s)

a = []
for i in range(n):
    for j in range(i+1,n+1):
        a.append(s[i:j])

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

Submission status: Time Limit Exceeded

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

s = str(input())
K = I()
n = len(s)

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

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

Submission status: Time Limit Exceeded

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


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

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

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

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    s = input()
    k = int(input())
    l = len(s)
    subs = []
    for i in range(l):
        for j in range(i + 1, l + 1):
            sub = s[i:j]
            if sub not in subs:
                subs.append(sub)
    print(sorted(set(subs))[k - 1])


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    s = input()
    k = int(input())
    l = len(s)
    subs = []
    for i in range(l):
        for j in range(i + 1, l + 1):
            sub = s[i:j]
            subs.append(sub)
    print(sorted(set(subs))[k - 1])


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    s = input()
    k = int(input())
    l = len(s)
    subs = set(s)
    for i in range(l):
        for j in range(i + 1, l + 1):
            sub = s[i:j]
            subs.add(sub)
    print(sorted(subs)[k - 1])


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:

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

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

N = len(S)

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

ret = sorted(set(ret))

print(ret[K-1])

Submission status: Time Limit Exceeded

Solution code:

import sys
input = sys.stdin.readline
##############################

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

N = len(S)

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

ret.sort()

print(ret[K-1])

Submission status: Time Limit Exceeded

Solution code:
import collections
def main():
    s = input()
    K = int(input())
    d = collections.defaultdict(set)
    n = len(s)
    for i in range(n):
        for l in range(1, n-i+1):
            d[s[i]].add(s[i:i+l])
    for c in sorted(d.keys()):
        if len(d[c]) < K:
            K -= len(d[c])
        else:
            d[c] = sorted(d[c])
            return d[c][K-1]

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

Submission status: Time Limit Exceeded

Solution code:
#辞書順で小さい文字から考えていく。まずｓ内を構成する文字で辞書順で小さいものを列挙。
#辞書順降順でその文字から始まる部分文字列を全列挙。その数がｋに達したら打ち切り。
s = input()
k = int(input())
substr = set()
for i in range(len(s)):
    substr.add(s[i])
check = sorted(list(substr))
x = 0
while True:
    for i in range(len(s)):
        if s[i] == check[x] and i < len(s) - 1:
            for j in range(i+1,len(s)+1):
                substr.add(s[i:j])
    if len(substr) >= k:
        break
    x += 1
lis_substr = sorted(list(substr))
print(lis_substr[k-1])

Submission status: Time Limit Exceeded

Solution code:
s = input()
k = int(input())
x = 0
substr = set()
while x < len(s):
    x += 1
    for i in range(len(s) - x + 1):
        if s[i:i+x] not in substr:
            substr.add(s[i:i+x])
substr = list(substr)
substr.sort()
print(substr[k-1])

Submission status: Time Limit Exceeded

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

substring = []
for i in range(len(s)):
    for j in range(i,len(s)):
        if not("".join(s[i:j+1]) in substring):
            substring.append("".join(s[i:j+1]))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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


a.sort()

print(''.join(a[k-1]))

Submission status: Time Limit Exceeded

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

s2 = ''.join(sorted(set(list(s))))

l = []

for i in range(len(s2)):
  if len(set(l)) >= K:
    #print(i)
    break
  else:
    for j in range(len(s)):
      if s2[i] == s[j]:
        for k in range(j+1, len(s)+1):
          l.append(s[j:k])
l = list(set(l))
l.sort()
#print(l)
print(l[K-1])

Submission status: Time Limit Exceeded

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

s2 = ''.join(sorted(set(list(s))))

l = []

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

Submission status: Time Limit Exceeded

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

subList = set([])

for front in range(0, len(S)):
    for length in range(1, len(S) + 1):
        subList.add(S[front: front + length])

subList = list(subList)
subList.sort()

print(subList[K - 1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#部分点とは？
s = input()
k = int(input())
can = []
for l in range(len(s)):
  for w in range(len(s)):
    try:
      now = s[l:l+w+1]
      if now in can:
        pass
      else:
        can.append(now)
    except:
      pass
can.sort()
print(can[k-1])