Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    is_prime = hurui(10**6+10)
    i = 1
    c = 0
    while i**2 <= g:
        if g % i == 0:
            if is_prime[i] == 1:
                # print("i: ", i)
                c += 1
            if i != g // i and is_prime[g//i] == 1:
                # print("i: ", i)
                c += 1
        i += 1
    # print(g)
    print(c+1)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def gcd(a, b):
    if a % b != 0:
        return gcd(b, a % b)
    else:
        return b

def hurui(n):
    is_prime = [0] * (n+10)
    for i in range(2, n+1):
        is_prime[i] = 1
    for i in range(2, n+1):
        if is_prime[i] == 1:
            j = i*2
            while j <= n:
                is_prime[j] = 0
                j += i
    return is_prime

def main():
    a, b = list(map(int, input().strip().split()))
    g = gcd(a, b)
    # is_prime = hurui(10**6+10)
    i = 2
    c = 0
    # print(g)
    ans = []
    while i**2 <= g:
        if g % i == 0:
            ans.append([i, 0])
            while g % i == 0:
                g /= i
                ans[-1][1] += 1
        i += 1
    if g != 1:
        ans.append([g, 1])
    # print(ans)
    print(len(ans)+1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from math import factorial

def main():
	n, k = map(int, input().strip().split())
	for i in range(1, k+1):
		c = factorial(k-1)//(factorial(k-i)*factorial(i-1))
		noko = factorial(n-k+1)//(factorial(i) * factorial(n-k-i+1))
		# print(c, noko)
		ans = c * noko
		# print(ans)
		ans %= 10**9+7
		print(ans)


if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline
from math import factorial

def main():
	n, k = map(int, input().strip().split())
	for i in range(1, k+1):
		if i-1 > n - k:
			print(0)
			continue
		c = factorial(k-1)//(factorial(k-i)*factorial(i-1))
		noko = factorial(n-k+1)//(factorial(i) * factorial(n-k-i+1))
		# print(c, noko)
		ans = c * noko
		# print(ans)
		ans %= 10**9+7
		print(ans)


if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def main():
    n = int(input().strip())
    p = []
    for i in range(n):
        x, y = map(int, input().strip().split())
        p.append((x, y))
    vtable = [0] * n**2
    for i in range(n):
        for j in range(n):
            vtable[i * n + j] = (p[i][0] - p[j][0], p[i][1] - p[j][1])
    c = sorted(Counter(vtable).values(), reverse=True)
    print(n - c[1])


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def main():
    n = int(input().strip())
    p = []
    for i in range(n):
        x, y = map(int, input().strip().split())
        p.append((x, y))
    vtable = [0] * n**2
    for i in range(n):
        for j in range(n):
            vtable[i * n + j] = (p[i][0] - p[j][0], p[i][1] - p[j][1])
    c = sorted(Counter(vtable).values(), reverse=True)
    if len(c) == 1:
        print(1)
    else:
        print(n - c[1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000)
N = []
v = []
def rec(n):
	global N
	global v
	if v[n] != -1:
		return v[n]

	if N[n] == 1:
		v[n] = 0
	elif n == 1:
		v[n] = 1
	elif N[n-1] == 1:
		v[n] = rec(n-2)
	else:
		v[n] = rec(n-2) + rec(n-1)
	# print("v:", v[n])
	return v[n]

def main():
	global N, v
	n, m = map(int, input().strip().split())
	N = [0] * (n+1)
	v = [-1] * (n+1)
	v[0] = 1
	for i in range(m):
		a = int(input().strip())
		N[a] = 1
	# print(v)
	# print(N)
	print(rec(n) % (10**9+7))

if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
	n, m = map(int, input().strip().split())
	v = [0] * (n+1)
	v[0] = 1
	v[1] = 1
	N = []
	for i in range(m):
		a = int(input().strip())
		N.append(a)
	N.append(-1)
	j = 0
	for i in range(1, n+1):
		if N[j] == i:
			v[i] = 0
			j += 1
		else:
			if i == 1:
				v[i] = 1
			else:
				v[i] = v[i-1] + v[i-2]
	print(v[n] % (10**9+7))

if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = []
v = []
def rec(n):
	global N
	global v
	if v[n] != -1:
		return v[n]

	if N[n] == 1:
		v[n] = 0
	elif n == 1:
		v[n] = 1
	elif N[n-1] == 1:
		v[n] = rec(n-2)
	else:
		v[n] = rec(n-2) + rec(n-1)
	# print("v:", v[n])
	return v[n]

def main():
	global N, v
	n, m = map(int, input().strip().split())
	N = [0] * (n+1)
	v = [-1] * (n+1)
	v[0] = 1
	for i in range(m):
		a = int(input().strip())
		N[a] = 1
	# print(v)
	# print(N)
	print(rec(n) % (10**9+7))

if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
	n, m = map(int, input().strip().split())
	v = [0] * (n+1)
	v[0] = 1
	v[1] = 1
	N = []
	for i in range(m):
		a = int(input().strip())
		N.append(a)
	N.append(-1)
	j = 0
	for i in range(1, n+1):
		if N[j] == i:
			v[i] = 0
			j += 1
		else:
			if i == 1:
				v[i] = 1
			else:
				v[i] = v[i-1] + v[i-2]
	print(v[n] % (10**9+7))

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def pri(tbl, tbl2, tbl3, tbl4, n, m):
	for i in range(n):
		for j in range(m):
			print("{:2}".format(tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j]), end='')
		print('')
	print('')

def main():
	n, m = map(int, input().strip().split())
	v = []
	for i in range(n):
		v.append(input().strip())
	tbl = [[0] * m for _ in range(n)]
	tbl2 = [[0] * m for _ in range(n)]
	tbl3 = [[0] * m for _ in range(n)]
	tbl4 = [[0] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			if v[i][j] == '#':
				tbl[i][j] = -1
			elif j == 0:
				continue
			else:
				tbl[i][j] = tbl[i][j-1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	for i in range(n):
		for j in range(m-1, -1, -1):
			if v[i][j] == '#':
				tbl2[i][j] = -1
			elif j == m-1:
				continue
			else:
				tbl2[i][j] = tbl2[i][j+1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)

	
	for j in range(m):
		for i in range(n):
			if v[i][j] == '#':
				tbl3[i][j] = -1
			elif i == 0:
				continue
			else:
				tbl3[i][j] = tbl3[i-1][j] + 1
	for j in range(m):
		for i in range(n-1, -1, -1):
			if v[i][j] == '#':
				tbl4[i][j] = -1
			elif i == n-1:
				continue
			else:
				tbl4[i][j] = tbl4[i+1][j] + 1
	# for i in range(n):
	# 	print(tbl[i])
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	ans = 0
	for i in range(n):
		for j in range(m):
			ans = max(ans, tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j])
	print(ans+1)

if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline

def pri(tbl, tbl2, tbl3, tbl4, n, m):
	for i in range(n):
		for j in range(m):
			print("{:2}".format(tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j]), end='')
		print('')
	print('')

def main():
	n, m = map(int, input().strip().split())
	v = []
	for i in range(n):
		v.append(input().strip())
	tbl = [[0] * m for _ in range(n)]
	tbl2 = [[0] * m for _ in range(n)]
	tbl3 = [[0] * m for _ in range(n)]
	tbl4 = [[0] * m for _ in range(n)]
	for i in range(n):
		for j in range(m):
			if v[i][j] == '#':
				tbl[i][j] = -1
			elif j == 0:
				continue
			else:
				tbl[i][j] = tbl[i][j-1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	for i in range(n):
		for j in range(m-1, -1, -1):
			if v[i][j] == '#':
				tbl2[i][j] = -1
			elif j == m-1:
				continue
			else:
				tbl2[i][j] = tbl2[i][j+1] + 1
	# pri(tbl, tbl2, tbl3, tbl4, n, m)

	
	for j in range(m):
		for i in range(n):
			if v[i][j] == '#':
				tbl3[i][j] = -1
			elif i == 0:
				continue
			else:
				tbl3[i][j] = tbl3[i-1][j] + 1
	for j in range(m):
		for i in range(n-1, -1, -1):
			if v[i][j] == '#':
				tbl4[i][j] = -1
			elif i == n-1:
				continue
			else:
				tbl4[i][j] = tbl4[i+1][j] + 1
	# for i in range(n):
	# 	print(tbl[i])
	# pri(tbl, tbl2, tbl3, tbl4, n, m)
	ans = 0
	for i in range(n):
		for j in range(m):
			ans = max(ans, tbl[i][j]+tbl2[i][j]+tbl3[i][j]+tbl4[i][j])
	print(ans+1)

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			gr = set()
			for i in range(n):
				if h[i] != 0:
					H = h[i] + abs(x[i]-s) + abs(y[i]-t)
					gr.add(H)
				else:
					for k in gr:
						if k > abs(x[i]-s) + abs(y[i]-t):
							gr.remove(k)

			if len(gr) == 1:
				h = gr.pop()
				if h >= 0:
					print(s, t, h)
					return

if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline
W = 101
def main():
	n = int(input().strip())
	x = [0] * n
	y = [0] * n
	h = [0] * n
	for i in range(n):
		x[i], y[i], h[i] = map(int, input().strip().split())
	for s in range(W):
		for t in range(W):
			needH = -1
			for i in range(n):
				if h[i] > 0:
					tmp = h[i] + abs(x[i]-s) + abs(y[i]-t)
					if needH == -1:
						needH = tmp
					elif needH != tmp:
						needH = -2
						break
			if needH == -2:
				continue
			for i in range(n):
				if h[i] == 0 and needH > abs(x[i]-s) + abs(y[i]-t):
					needH = -2
					break
			if needH == -2:
				continue
			else:
				print("{} {} {}".format(s, t, needH))

if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][i] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][j] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(w)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][i] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(map(int, input().strip().split()))
	ans = []
	for i in range(h-1):
		for j in range(w):
			if a[i][j] % 2 == 1:
				a[i][j] -= 1
				a[i+1][j] += 1
				ans.append((i+1, j+1, i+2, j+1))

	for j in range(w-1):
		if a[h-1][j] % 2 == 1:
			a[h-1][j] -= 1
			a[h-1][j+1] += 1
			ans.append((h, j+1, h, j+2))
	n = len(ans)
	print(n)
	for i in range(n):
		print("{} {} {} {}".format(ans[i][0], ans[i][1], ans[i][2], ans[i][3]))
if __name__ == '__main__':
	main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, max(i+1+k+1, n+1)):
            stq.add(s[i:j]) 
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, n+1):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    n = len(s)
    stset = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, n+1):
            stset.add(s[i:j])
    print(sorted(stset)[k-1])

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
import heapq

def main():
    s = input().strip()
    n = len(s)
    stq = set()
    k = int(input().strip())
    for i in range(n):
        for j in range(i+1, min(i+1+k+1, n+1)):
            stq.add(s[i:j])
    stq = list(stq)
    heapq.heapify(stq)
    for i in range(k):
        ans = heapq.heappop(stq)
        if i == k-1:
            print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter

tmp = []
tree = []

def dfs(node, depth, fr):
    global tmp, tree
    tree[node] = (fr, depth)
    for i, c in tmp[node]:
        if i != fr:
            dfs(i, depth+c, node)

def main():
    global tmp, tree
    n = int(input().strip())
    tmp = [[] for _ in range(n)]
    tree = [0] * n
    for _ in range(n-1):
        a, b, c = map(int, input().strip().split())
        a -= 1
        b -= 1

        if b > a:
            a, b = b, a
        tmp[a].append((b, c))
        tmp[b].append((a, c))

    q, k = map(int, input().strip().split())
    k -= 1
    dfs(k, 0, -1)
    # print(tmp)
    # print(tree)
    for _ in range(q):
        x, y = map(lambda x: x-1, map(int, input().strip().split()))
        print(tree[x][1] + tree[y][1])


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

tmp = []
tree = []

def dfs(node, depth, fr):
    global tmp, tree
    tree[node] = (fr, depth)
    for i, c in tmp[node]:
        if i != fr:
            dfs(i, depth+c, node)

def main():
    global tmp, tree
    n = int(input().strip())
    tmp = [[] for _ in range(n)]
    tree = [0] * n
    for _ in range(n-1):
        a, b, c = map(int, input().strip().split())
        a -= 1
        b -= 1

        if b > a:
            a, b = b, a
        tmp[a].append((b, c))
        tmp[b].append((a, c))

    q, k = map(int, input().strip().split())
    k -= 1
    dfs(k, 0, -1)
    # print(tmp)
    # print(tree)
    for _ in range(q):
        x, y = map(lambda x: x-1, map(int, input().strip().split()))
        print(tree[x][1] + tree[y][1])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
import itertools

def main():
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(n)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    ans = 0
    for path in itertools.permutations(range(8), 8):
        if all(path[i+1] in lis[path[i]] for i in range(n-1)):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0

def dfs(i, d, fr, used):
    global lis, ans
    if i in used:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            used.append(i)
            # print(i+1 , j+1)
            dfs(j, d+1, i, used)
            used.pop()


def main():
    global lis, n, m, ans
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(8)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1, [])
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from operator import itemgetter
import itertools

def main():
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(n)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    ans = 0
    for path in itertools.permutations(range(8), 8):
        if all(path[i+1] in lis[path[i]] for i in range(n-1)):
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter

lis = []
n = 0
m = 0
ans = 0

def dfs(i, d, fr, used):
    global lis, ans
    if i in used:
        return
    if d == n - 1:
        ans += 1
        return
    for j in lis[i]:
        if j != fr:
            used.append(i)
            # print(i+1 , j+1)
            dfs(j, d+1, i, used)
            used.pop()


def main():
    global lis, n, m, ans
    n, m = map(int, input().strip().split())
    lis = [[] for _ in range(8)]
    for _ in range(m):
        a, b = list(map(lambda x: x-1, map(int, input().strip().split())))
        lis[a].append(b)
        lis[b].append(a)
    # print("##")
    dfs(0, 0, -1, [])
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    k = int(input().strip())
    ans = ""
    for i, c in enumerate(s):
        if i == len(s)-1:
            ans += chr(ord('a') + (ord(c) + k % 26 - ord('a')) % 26)
            break
        d = ord('z') - ord(c) + 1
        if d < k:
            k -= d
            ans += 'a'
        else:
            ans += c
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    ans = list(s[:])
    k = int(input().strip())
    for i in range(len(s)):
        d = (ord('z') - ord(s[i]) + 1) % 26
        if k - d >= 0:
            ans[i] = 'a'
            k -= d
        if i == len(s) - 1:
            # print((ord(ans[i]) + k%26) % 26)
            ans[i] = chr(ord('a') + (ord(ans[i]) - ord('a') + k%26) % 26)
    print(''.join(ans))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x=input()
if x.isupper() is True:
    print(A)
else:
    print(a)


Fixed submission:
x=input()

if x.isupper() is True:
    print("A")
else:
    print("a")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))

i=0
while True:
    if len(p)==1:
        break
    if p[i]<=p[i+1]:
        i+=1
    else:
        a=p[i]
        p[i]=p[i+1]
        p[i+1]=a
        i=0
    if i==len(p)-1:
        break

ans=0
for i in range(k):
    ans+=p[i]
print(ans)


Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))

ans=0
if n!=1:
    for i in range(k):
        min=p[i]
        for j in range(i+1,n):
            if min>p[j]:
                min=p[j]
                p[j]=p[i]
                p[i]=min
        ans+=min
else:
    ans=p[0]
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=int(input().split())
print(a*b)

Fixed submission:
a,b=input().split()
print(int(a)*int(b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

ans=1
for i in range(n):
    ans*=a[i]
if ans>10**18:
        ans=-1
print(ans)


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

ans=1
a.sort()
for i in range(n):
    ans*=a[i]
    if ans>10**18:
        ans=-1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
print(x[n//10])

Fixed submission:
n=int(input())
x=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
print(x[n%10])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))

ans=n

for i in range(m):
    ans-=a[m]
    if ans<0:
        ans=-1
        break
print(ans)


Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))

ans=n

for i in range(m):
    ans-=a[i]
    if ans<0:
        ans=-1
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if S="AAA" or S="BBB":
    print("No")
else:
    print("Yes")

Fixed submission:
S=input()
if S=="AAA" or S=="BBB":
    print("No")
else:
    print("Yes")