Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l=["" for _ in range((n*(n+1))//2)]
li=[]
cnt=0
st=""
cnt=0
for i in range(n):
    d.append(s[i])
#print(s,len(s))
for i in range(n):
    buf=deque()
    #print(s[i])
    #piv=ord(s[i])-97
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        st="".join(buf)
        l[cnt]=st
        cnt=cnt+1
    buf.popleft()
    d=buf
l=list(set(l))
l.sort()
#print(l)
print(l[K-1])

Fixed submission:
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l=[{} for _ in range(26)]
li=[]
cnt=0
st=""

for i in range(n):
    d.append(s[i])
#print(s,len(s))
for i in range(n):
    buf=deque()
    #print(s[i])
    piv=ord(s[i])-97
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        st="".join(buf)
        l[piv][st]=cnt
    buf.popleft()
    d=buf
#print(l)
buf=[]
for i in range(26):
    #print(l[i],len(l[i]))
    if len(l[i])<K:
        K=K-len(l[i])
    else:
        buf = list(l[i])
        buf.sort()
        print(buf[K-1])
        break

Fixed submission:
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l=[{} for _ in range(26)]
li=[]
cnt=0
st=""

for i in range(n):
    d.append(s[i])
#print(s,len(s))
for i in range(n):
    buf=deque()
    #print(s[i])
    piv=ord(s[i])-97
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        st="".join(buf)
        l[piv][st]=cnt
    buf.popleft()
    d=buf
#print(l)
buf=[]
for i in range(26):
    buf=list(l[i])
    if len(buf)<K:
        K=K-len(buf)
    else:
        buf.sort()
        print(buf[K-1])
        break

Fixed submission:
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l={}
li=[]
cnt=0
for i in range(n):
    d.append(s[i])
for i in range(n):
    buf=deque()
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        s="".join(buf)
        l[s]=cnt
    buf.popleft()
    d=buf
#print(l)
li=list(l)
li.sort()

#print(l)
print(li[K-1])

Fixed submission:
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=list(input())
n=len(s)
K=int(input())
d=deque()
l=[]
for i in range(n):
    d.append(s[i])
for i in range(n):
    buf=deque()
    for j in range(n-i):
        v=d.popleft()
        buf.append(v)
        l.append("".join((buf)))
    buf.popleft()
    d=buf
l=list(set(l))
l.sort()
#print(l)
print(l[K-1])

Fixed submission:
from collections import deque
s=list(input())
K=int(input())
#max(K)=5でaaaaaはa,aa,aaa,aaaa,aaaaaの順
#よって5文字まで取れば良い
d=deque()
for i in range(len(s)):
    d.append(s[i])
comp=[]
#print(d)
for i in range(len(s)):
    buf=deque()
    for j in range(len(d)):
        v=d.popleft()
        buf.append(v)
        if j<5:
            comp.append("".join(buf))
    d=deque()
    for j in range(len(buf)):
        d.append(buf[j])
    d.popleft()
comp=list(set(comp))
comp.sort()
print(comp[K-1])