Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02885 (python)

Fixed submission:
a, b = map(int, input().split())

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part < 0:
  uncovered_part = 0
  
print(str(uncovered_part))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part < 0:
  uncovered_part = 0
  
print str(uncovered_part)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part > 0:
  return
else:
  uncovered_part = 0
  
print str(uncovered_part)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

horizontal_length = b * 2

uncovered_part = a - horizontal_length

if uncovered_part > 0:
  return
else:
  uncovered_part = 0
  
print uncovered_part
Problem p02886 (python)

Fixed submission:
n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
del = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
del = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(str(sum))

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(str(sum))

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))

sum = 0
i = 0


print(sum)

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0


print(sum)

Buggy submission (verdict: Runtime Error):
del = [int(d) for d in input().split()]
n = len(del)
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(sum)

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(sum)

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
  i += 1
  
print(str(sum))

Buggy submission (verdict: Runtime Error):
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
 
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
    
  i += 1
  
print(str(sum))

Buggy submission (verdict: Runtime Error):
del = list(map(int, input(),split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
 
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
    
  i += 1
  
print(str(sum))
Problem p02947 (python)

Fixed submission:
# 2019-11-16 14:51:41(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
from functools import reduce
import operator as op
# from scipy.misc import comb # float
# import numpy as np
# import heapq
# import array


def nCr(n, r):
    r = min(r, n - r)
    upper = reduce(op.mul, range(n, n-r, -1), 1)
    lower = reduce(op.mul, range(r, 0, -1), 1)
    return upper // lower

def main():
    n = int(sys.stdin.readline().rstrip())

    sorted_letters = [''.join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)]
  
    count = 0
    for c in collections.Counter(sorted_letters).values():
        if c >= 2:
            count += nCr(c, 2)
            
    print(count)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# 2019-11-16 14:51:41(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r, insort_left as in_l
# import itertools
# from functools import reduce
# import operator as op
from scipy.special import comb # comb(n, r, exact=True)
# import numpy as np
# import heapq
# import array


def main():
    n = int(sys.stdin.readline().rstrip())

    sorted_letters = [''.join(sorted(sys.stdin.readline().rstrip())) for _ in range(n)]
  
    count = 0
    for c in collections.Counter(sorted_letters).values():
        if c >= 2:
            count += comb(c, 2, exact=True)

    print(count)


if __name__ == "__main__":
    main()
Problem p03076 (python)

Fixed submission:
# 2019-11-12 22:40:44(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    dishes = [int(x) for x in sys.stdin.read().split()]
    

    total = 0
    for i in range(5):
        if dishes[i] % 10 != 0:
            total += (dishes[i] // 10 + 1) * 10
        else:
            total += dishes[i]
    

    remainder = [dishes[i] % 10 for i in range(5) if dishes[i] % 10 != 0]
    if remainder:
        ans = total - (10 - min(remainder))
    else:
        ans = total
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
import numpy as np

def main():
    dish = np.array(sys.stdin.read().split())

    minute = [int(dish[i][-1]) for i in range(5)]
    m = min(x for x in minute if x > 0) if 0 in minute else 10

    res = (np.ceil(dish.astype(np.int64) / 10) * 10).sum() - 10 + m

    print(int(res))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
import numpy as np

def main():
    dish = np.array(sys.stdin.read().split())

    minute = [int(dish[i][-1]) for i in range(5) ]
    m = min(x for x in minute if x > 0)

    res = (np.ceil(dish.astype(np.int64) / 10) * 10).sum() - 10 + m

    print(int(res))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# 2019-11-12 22:40:44(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    dishes = [int(x) for x in sys.stdin.read().split()]
    min_first_digit = min(dishes[i] % 10 for i in range(5) if dishes[i] % 10 != 0) | 0

    total = 0
    for i in range(5):
        if dishes[i] % 10 != 0:
            total += (dishes[i] // 10 + 1) * 10
        else:
            total += dishes[i]
    
    ans = total - (10 - min_first_digit)
    print(ans)

if __name__ == "__main__":
    main()
Problem p03085 (python)

Fixed submission:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    b = sys.stdin.readline().rstrip()
    if b == 'A':
        ans = 'T'
    elif b == 'T':
        ans = 'A'
    elif b == 'G':
        ans = 'C'
    else:
        ans = 'G'
    
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

bond = dict(('A', 'T'), ('T', 'A',), ('C', 'G'), ('G', 'C'))

def main():
    b = sys.stdin.readline().rstrip()
    print(bond[b])

if __name__ == "__main__":
    main()
Problem p03086 (python)

Fixed submission:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    all_words = []
    for i in range(1, len(s) + 1):
        for letters in itertools.product('ATCG', repeat=i):
            word = ''.join(letters)
            all_words.append(word)
    
    for i in range(len(all_words)-1, 0-1, -1):
        if all_words[i] in s:
            print(len(all_words[i]))
            sys.exit()
    print(0)




if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    permitted = 'ACGT'
    continuous_count = []
    count = 0

    for i in range(len(s)):
        char = s[i]
        if char in permitted:
            count += 1
        else:
            continuous_count.append(count)
            count = 0
    
    print(max(continuous_count))



if __name__ == "__main__":
    main()
Problem p03111 (python)

Fixed submission:
import sys
from itertools import product

inf = float('inf')

n, *target = map(int, sys.stdin.readline().split())
target = [None] + target
*l,  = map(int, sys.stdin.read().split())

def main():
    costs = []
    for p in product(range(4), repeat=n):
        tmp = [[] for _ in range(4)]
        p = list(p)
        for i in range(n):
            tmp[p[i]].append(l[i])

        cost = [0] * 4
        for i in range(1, 4):
            if not tmp[i]:
                break
            cost[i] += 10 * (len(tmp[i]) - 1)
            cost[i] += abs(target[i] - sum(tmp[i]))
        else:
            costs.append(sum(cost))

    return min(costs)

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

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache
inf = float('inf')

n, A, B, C, *l = map(int, sys.stdin.read().split())

@lru_cache
def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1))

def main():
    print(cost(0, 0, 0, 0, 0))

if __name__ ==  '__main__':
    main()
Problem p03241 (python)

Fixed submission:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

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

Buggy submission (verdict: Runtime Error):
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i, n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())


def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
Problem p03260 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if (a * b) % 2 != 0:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if (a * b) % 2 !- 0:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()
Problem p03261 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            print('No')
            exit()
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            sys.exit('No')
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()
Problem p03266 (python)

Fixed submission:
import sys
from functools import reduce
from operator import mul
import math

def nCr(n, r):
    r = min(r, n-r)
    upper = reduce(mul, range(n, n-r, -1), 1)
    lower = reduce(mul, range(r, 0, -1), 1)
    return upper // lower


def oddCaseK(n, k):
    cand = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand += 1
    
    number_of_possibles = 0
    if cand >= 1:
        number_of_possibles += cand
    if cand >= 2:
        number_of_possibles += nCr(cand, 2) * nCr(2, 1) * 3
    if cand >= 3:
        number_of_possibles += nCr(cand, 3) * math.factorial(3)
    
    return number_of_possibles

    

def evenCaseK(n, k):
    cand1 = 0
    cand2 = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand1 += 1
        elif x % k == k // 2:
            cand2 += 1
    
    number_of_possibles = 0
    number_of_possibles = 0
    if cand1 >= 1:
        number_of_possibles += cand1
    if cand1 >= 2:
        number_of_possibles += nCr(cand1, 2) * nCr(2, 1) * 3
    if cand1 >= 3:
        number_of_possibles += nCr(cand1, 3) * math.factorial(3)

    if cand2 >= 1:
        number_of_possibles += cand2
    if cand2 >= 2:
        number_of_possibles += nCr(cand2, 2) * nCr(2, 1) * 3
    if cand2 >= 3:
        number_of_possibles += nCr(cand2, 3) * math.factorial(3)

    return number_of_possibles


def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    if k % 2 == 0:
        ans = evenCaseK(n, k)
    else:
        ans = oddCaseK(n, k)
    
    print(ans)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    c1 = n // k
    c2 = n // (k // 2)
    if (k & 1): cnt = pow(c1, 3)
    else: cnt = pow(c1, 3) + pow(c2 - c1, 3)
    print(cnt)

if __name__ ==  '__main__':
    main()
Problem p03283 (python)

Fixed submission:
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)
    
    np.add.at(res, (1, r), 1)
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (1, n+1), -1)
    np.add.at(res, (l+1, n+1), 1)
    res = np.cumsum(res, axis=0)
    res = np.cumsum(res, axis=1)

    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)

    np.add.at(res, (np.full(m, 1), r), 1)
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (np.full(m, 1), np.full(m, n+1)), -1)
    np.add.at(res, (l+1, np.full(m, n+1)), 1)
    res = np.cumsum(res, axis=0)
    res = np.cumsum(res, axis=1)
    
    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')
Problem p03288 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-08 18:39:24(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version)  
# imort numpy as np 

def main():
    r = int(sys.stdin.readline().rstrip())
    if r < 1200:
        ans = 'ABC'
    elif r < 2800:
        ans = 'ARC'
    else:
        ans = 'AGC'

    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
import sys

r = map(int, sys.stdin.readline().rstrip())

def main():
    if r < 1200:
        return 'ABC'
    elif r < 2800:
        return 'ARC'
    else:
        return 'AGC'

if __name__ == '__main__':
    ans = main()
    print(ans)
Problem p03292 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-08 15:54:47(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version)  

def main():
    *n, = (int(x) for x in sys.stdin.readline().split())
    n.sort()
    print(n[-1] - n[0])


if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
import sys

*a = map(int, sys.stdin.readline().split())

def main():
    return max(a) - min(a)

if __name__ == '__main__':
    ans = main()
    print(ans)
Problem p03330 (python)

Fixed submission:
import sys
import numpy as np 
from itertools import permutations

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, C = I[:2]
cost = I[2:2+C**2].reshape(C, C)
color = I[2+C**2:].reshape(n, n) - 1

def main():
    mod_3 = (np.arange(1, n+1)[:, None] + np.arange(1, n+1)) % 3
    c0 = np.bincount(color[mod_3 == 0], minlength=C)
    c1 = np.bincount(color[mod_3 == 1], minlength=C)
    c2 = np.bincount(color[mod_3 == 2], minlength=C)

    ans = float('inf')
    for i, j, k in permutations(range(C), 3):
        res = np.sum(c0 * cost[:, i])
        res += np.sum(c1 * cost[:, j])
        res += np.sum(c2 * cost[:, k])
        ans = min(ans, res)
    return ans

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

Buggy submission (verdict: Runtime Error):
import sys
from itertools import permutations, combinations

n, c = map(int, sys.stdin.readline().split())
d = [[int(x) for x in sys.stdin.readline().split()] for _ in range(c)]
grid = [[int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(n)]

cost = [[0] * 3 for _ in range(c)]
for i in range(n):
  for j in range(n):
    k = (i + j) % 3
    for l in range(c):
      cost[k][l] += d[grid[i][j]][l]
  
def main():
  res = []
  for comb in combinations(range(c), 3):
    for i, j, k in permutations(comb):
      res.append(cost[0][i] + cost[1][j] + cost[2][k])
  print(min(res))

if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
import sys
from itertools import permutations

n, c = map(int, sys.stdin.readline().split())
d = [[int(x) for x in sys.stdin.readline().split()] for _ in range(c)]
grid = [[int(x) - 1 for x in sys.stdin.readline().split()] for _ in range(n)]

cost = [[0] * 3 for _ in range(c)]
for i in range(n):
  for j in range(n):
    k = (i + j) % 3
    for l in range(c):
      cost[k][l] += d[grid[i][j]][l]
  
def main():
  res = []
  for i, j, k in permutations(range(c), 3):
    res.append(cost[0][i] + cost[1][j] + cost[2][k])
  print(min(res))

if __name__ == '__main__':
  main()
Problem p03339 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n = int(sys.stdin.readline().rstrip())
    s = sys.stdin.readline().rstrip()

    opposite = collections.Counter(s)
    opposite['W'] = 0
    minimum = n
    for i in range(n):
        if s[i] == 'E':
            opposite['E'] -= 1
        minimum = min(minimum, sum(opposite.values()))
        if s[i] == 'W':
            opposite['W'] += 1
    print(minimum)




if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = cnt
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res = min(res, cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()
Problem p03353 (python)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-07 13:42:36(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    s = sys.stdin.readline().rstrip()
    k = int(sys.stdin.readline().rstrip())
    n = len(s)
    
    substrings = []
    for i in range(1, k+1):
        for j in range(n-i+1):
            substring = s[j:j+i]
            substrings.append(substring)
    substrings = sorted(list(set(substrings)))
    print(substrings[k-1])


if __name__ == "__main__":
    # execute only if run as a script
    main()

Buggy submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline().rstrip()
k = int(sys.stdin.readline().rstrip())
n = len(s)

def main():
    res = set()
    for i in range(n):
        for j in range(i, i+4):
            res.add(s[i:j+1])
    
    return sorted(res)[k-1]

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