Problem p03353 (python)

Fixed submission:
s = input()
l = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[l-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
char = []
if len(s) == 1:
    print(1)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            if abs(i-j) <= 5 and i != j:
                s_part = s[i:j]
                if s_part not in set(sl):
                    sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            if abs(i-j) <= 5 and i != j:
                s_part = s[i:j]
                if s_part not in set(sl):
                    sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            if abs(i-j) <= 5:
                s_part = s[i:j]
                if s_part not in sl and s_part != "":
                    sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            s_part = s[i:j]
            if s_part not in set(sl) and s_part != "" and len(s_part)<= 5:
                sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            s_part = s[i:j]
            if s_part not in set(sl) and s_part != "":
                sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
sl = []
if len(s) > 1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            s_part = s[i:j]
            if s_part not in set(sl) and s_part != "":
                sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

Buggy submission (verdict: Runtime Error):
s = input()
k =int(input())
sl = []
if len(s) >1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            s_part = s[i:j]
            if s_part not in sl and s_part != "":
                sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)