Buggy python submission (verdict: Time Limit Exceeded):

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
##    if len(S) >= K:
##        min_s = "zzzzzzz"
##        for i in range(len(S) - K):
##            if S[i : i + K]< min_s:
##                min_s = S[i : i + K]
##        print min_s
##        return
##    else:
    sub_list = set([])
    for i in range(len(S)):
        for j in range(i + 1, len(S) + 1):
            sub_list.add(S[i:j])

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


if __name__ == '__main__':
    main()


Fixed submission:

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
##    if len(S) >= K:
##        min_s = "zzzzzzz"
##        for i in range(len(S) - K):
##            if S[i : i + K]< min_s:
##                min_s = S[i : i + K]
##        print min_s
##        return
##    else:
    sub_list = set([])
    for i in range(len(S)):
        for j in range(i + 1, i + 6):
            sub_list.add(S[i:j])

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


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
##    if len(S) >= K:
##        min_s = "zzzzzzz"
##        for i in range(len(S) - K):
##            if S[i : i + K]< min_s:
##                min_s = S[i : i + K]
##        print min_s
##        return
##    else:
    sub_list = set([])
    for i in range(len(S)):
        for j in range(i + 1, len(S)):
            sub_list.add(S[i:j])

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


if __name__ == '__main__':
    main()


Fixed submission:

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
##    if len(S) >= K:
##        min_s = "zzzzzzz"
##        for i in range(len(S) - K):
##            if S[i : i + K]< min_s:
##                min_s = S[i : i + K]
##        print min_s
##        return
##    else:
    sub_list = set([])
    for i in range(len(S)):
        for j in range(i + 1, i + 6):
            sub_list.add(S[i:j])

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


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
import copy


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [s] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]

    sub_s_list = [""]
    for i in range(K):
        min_str = "z" * 5000
        for j in range(len(s)):
            sub = ""
            for k in range(j, len(s)):
                if sub in sub_s_list:
                    sub += s[k]
                if sub not in sub_s_list and sub < min_str:
                    min_str = sub
        sub_s_list.append(min_str)
    print sub_s_list[K]
                


if __name__ == '__main__':
    main()

Fixed submission:

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [int(input_raw[0])]
##    if len(S) >= K:
##        min_s = "zzzzzzz"
##        for i in range(len(S) - K):
##            if S[i : i + K]< min_s:
##                min_s = S[i : i + K]
##        print min_s
##        return
##    else:
    sub_list = set([])
    for i in range(len(S)):
        for j in range(i + 1, i + 6):
            sub_list.add(S[i:j])

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


if __name__ == '__main__':
    main()