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

Fixed submission:
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def solve(N, M, A):
    while A[0] % 2 == 0:
        for idx, a in enumerate(A):
            if a % 2 != 0:
                return 0
            A[idx] //= 2
        M //= 2

    for a in A:
        if a % 2 == 0:
            return 0

    cur_lcm = 1
    for a in A:
        cur_lcm = lcm(cur_lcm, a)
        if M < cur_lcm:
            return 0
    return (M // cur_lcm + 1) // 2

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = list((map(int, input().split())))
    A = [a // 2 for a in A]
    print(solve(N, M, A))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
A = list((map(int, input().split())))

cur_lcm = lcm(A[0], A[1])

for a in A[1:]:
    cur_lcm = lcm(cur_lcm, a)

if M < cur_lcm / 2:
    print(0)
else:
    print(M // cur_lcm + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
A = list(set(map(int, input().split())))

if len(A) == 1:
    if M < A[0] // 2 or A[0] % 2 != 0:
        print(0)
    else:
        print(M // A[0] + 1)
    exit()

cur_lcm = lcm(A[0], A[1])

for a in A[1:]:
    cur_lcm = lcm(cur_lcm, a)

if M < cur_lcm / 2 or cur_lcm % 2 != 0:
    print(0)
else:
    print(M // cur_lcm + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
A = list(set(map(int, input().split())))
cur_lcm = lcm(A[0], A[1])

for a in A[1:]:
    cur_lcm = lcm(cur_lcm, a)

if M < cur_lcm / 2:
    print(0)
else:
    print(M // cur_lcm + 1)
Problem p02855 (python)

Fixed submission:
import numpy as np

def solve():
    ret = np.array([[1 for _ in range(W)] for _ in range(H)])
    row_groups = np.array([0 for _ in range(H)])
    row_group_set = set()
    prev_row = 0
    for row in range(H):
        if '#' in s[row]:
            row_groups[prev_row: row + 1] = row
            row_group_set.add(row)
            prev_row = row + 1
    row_groups[prev_row: ] = prev_row - 1

    cur_group_num = 1
    for row in row_group_set:
        prev_col = 0
        for col in range(W):
            if s[row][col] == '#':
                ret[row][prev_col: col + 1] = cur_group_num
                cur_group_num += 1
                prev_col = col + 1
            ret[row][prev_col: ] = cur_group_num - 1

    for row, row_group_num in enumerate(row_groups):
        if row in row_group_set:
            continue
        for col in range(W):
            ret[row][col] = ret[row_group_num][col]

    for row in ret:
        print(' '.join(map(str, row.tolist())))

if __name__ == "__main__":
    H, W, K = map(int, input().split())
    s = []
    for row in range(H):
        s.append(list(input()))
    solve()

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

def solve():
    ret = np.array([[1 for _ in range(W)] for _ in range(H)])
    row_groups = np.array([0 for _ in range(H)])
    row_group_set = set()
    prev_row = 0
    for row in range(H):
        if '#' in s[row]:
            row_groups[prev_row: row + 1] = row
            row_group_set.add(row)
            prev_row = row + 1
    row_groups[prev_row: ] = prev_row - 1

    cur_group_num = 1
    for row in row_group_set:
        prev_col = 0
        for col in range(W):
            if s[row][col] == '#':
                ret[row][prev_col: col + 1] = cur_group_num
                cur_group_num += 1
                prev_col = col + 1
            ret[row][prev_col: ] = cur_group_num - 1

    for row, row_group_num in enumerate(row_groups):
        if row in row_group_set:
            continue
        for col in range(W):
            ret[row][col] = ret[row_group_num][col]

    for row in ret:
        print(' '.join(map(str, row.tolist())))

if __name__ == "__main__":
    H, W, K = map(int, input().split())
    s = []
    for row in range(H):
        s.append(list(input()))
    solve()
Problem p02882 (python)

Fixed submission:
import math

a, b, x = map(int, input().split())
ret = (b - x / a**2) * 2 / a if a**2 * b <= 2 * x else  a * b**2 / (2 * x)
print(math.degrees(math.atan(ret)))

Buggy submission (verdict: Runtime Error):
N = int(input())
ret = 1 - 1 + N - 1
for div in range(2, int(N ** 0.5) + 1):
    if N % div != 0: continue
    ret = min(ret, div - 1 + N // div - 1)
print(ret)
Problem p02885 (python)

Fixed submission:
if __name__ == '__main__':
    A, B = map(int, input().split())
    if A <= 2 * B:
        print(0)
    else:
        print(A - 2 * B)

Buggy submission (verdict: Runtime Error):
from bisect import *
if __name__ == '__main__':
    N = int(input())
    L = sorted(map(int, input().split()))
    print(sum(jdx - bisect(L, a - L[jdx], 0, jdx) for idx, a in enumerate(L) for jdx in range(idx)))

Buggy submission (verdict: Runtime Error):
def lowerBound(nums, target):
    if nums[-1] < target: return -1
    lp = 0
    rp = len(nums) - 1
    mp = lp + rp >> 1
    while lp <= rp:
        mp = lp + rp >> 1
        if nums[mp] == target:
            return mp
        if nums[mp] < target:
            lp = mp + 1
        else:
            rp = mp - 1
    return mp if target < nums[mp] else -1

if __name__ == '__main__':
    N = int(input())
    L = [int(l) for l in input().split()]
    L.sort()
    ret = 0
    for idx in range(len(L) - 1, 1, -1):
        for jdx in range(idx - 1, 0, -1):
            c = L[idx] - L[jdx] + 1
            ldx = lowerBound(L[:jdx], c)
            if ldx == -1: continue
            ret += jdx - ldx
    print(ret)
Problem p02888 (python)

Fixed submission:
from bisect import *
if __name__ == '__main__':
    N = int(input())
    L = sorted(map(int, input().split()))
    print(sum(jdx - bisect(L, a - L[jdx], 0, jdx) for idx, a in enumerate(L) for jdx in range(idx)))

Buggy submission (verdict: Runtime Error):
def lowerBound(nums, target):
  	if nums[-1] < target: return -1
    lp = 0
    rp = len(nums) - 1
    mp = lp + rp >> 1
    while lp <= rp:
        mp = lp + rp >> 1
        if nums[mp] == target:
            return mp
        if nums[mp] < target:
            lp = mp + 1
        else:
            rp = mp - 1
    return mp if target < nums[mp] else -1

if __name__ == '__main__':
    N = int(input())
    L = [int(l) for l in input().split()]
    L.sort()
    ret = 0
    for idx in range(len(L) - 1, 1, -1):
        for jdx in range(idx - 1, 0, -1):
            c = L[idx] - L[jdx] + 1
            ldx = lowerBound(L[:jdx], c)
            if ldx == -1: continue
            ret += jdx - ldx
    print(ret)
Problem p02936 (python)

Fixed submission:
from collections import deque

if __name__ == '__main__':
    N, Q = map(int, input().split())
    count = [0] * (N + 1)
    tree = [[] for _ in range(N + 1)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        idx, val = map(int, input().split())
        count[idx] += val

    q = deque()
    q.append(1)

    is_valid = [1] * (N + 1)
    while q:
        idx = q.pop()
        is_valid[idx] = 0
        for t in tree[idx]:
            if is_valid[t] == 0: continue
            count[t] += count[idx]
            q.append(t)
    print(*count[1:])

Buggy submission (verdict: Runtime Error):
class TreeNode(object):
    def __init__(self, val):
        self.container = []
        self.val = val
        self.counter = 0

    def concatenate(self, node):
        self.container.append(node)

    def getNodes(self):
        return self.container

def traverseAndIncrement(root, val):
    if root:
        root.counter += val
        for node in root.getNodes():
            traverseAndIncrement(node, val)

if __name__ == '__main__':
    N, Q = map(int, input().split())
    tree = {}
    for i in range(N):
        tree[i + 1] = TreeNode(i + 1)

    for _ in range(N - 1):
        parent, child = map(int, input().split())
        tree[parent].concatenate(tree[child])

    for _ in range(Q):
        root_idx, val = map(int, input().split())
        traverseAndIncrement(tree[root_idx], val)

    for idx in range(N):
        print(tree[idx + 1].counter, end=' ')
Problem p03469 (python)

Fixed submission:
s=input()
print(s[0:3]+"8"+s[4:])

Buggy submission (verdict: Runtime Error):
s=input()
s[3]="8"
print(s)
Problem p02641 (python)

Fixed submission:
X ,N = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))

    add_minus = -1
    while True:
        add_minus += 1
        if (X - add_minus) not in p:
            print(X - add_minus)
            break
        elif (X + add_minus) not in p:
            print(X+add_minus)
            break

Buggy submission (verdict: Runtime Error):
X ,N = map(int,input().split())
if N == 0:
    print(X)
else:
    p = list(map(int,input().split()))

    X_u = X - 1
    X_l = X + 1
    while judge:
        X_u += 1
        X_l -= 1
        if X_u not in p and X_l not in p:
            print(X_l)
            break
        elif X_u not in p:
            print(X_u)
            break
        elif X_l not in p:
            print(X_l)
            break
        else:
            if X_u == X_l:
                p.remove(X_u)
            else:
                p.remove(X_u)
                p.remove(X_l)
Problem p02730 (python)

Fixed submission:
S = input()
N = len(S)
judge = True
for i in range(len(S)//2):
    if S[i] != S[len(S) - i - 1]:
        judge = False
        break


if judge:        
    for i in range(int((len(S)-1)/2)):
  
        if S[i] != S[int((len(S)-1)/2)- 1 - i]:
            judge = False
            break
        elif S[int((N+3)/2)-1 + i] != S[N-1-i]:
            judge = False
            break

if judge:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
judge = True
for i in range(len(S)//2):
    if S[i] != S[len(S) - i - 1]:
        judge = False
        break


if judge:        
    for i in range(int((len(S)-1)/2)):
  
        if S[i] != S[int((len(S)-1)/2)- 1 - i]:
            judge = False
            break
        elif S[int((N+3)/2)-1 + i] != S[N-1-i]:
            judge = False
            break

if judge:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
judge = True
for i in range(len(S)//2 + 2):
    if S[i] != S[len(S) - i - 1]:
        judge = False
        break


if judge:        
    for i in range(int((len(S)-1)/2)):
  
        if S[i] != S[int((len(S)-1)/2)- 1 - i]:
            judge = False
            break
        elif S[int((N+3)/2)-1 + i] != S[N-1-i]:
            judge = False
            break

if judge:
    print("Yes")
else:
    print("No")
Problem p02975 (python)

Fixed submission:
import numpy as np

N = int(input())
a = list(map(int,input().split()))

a = np.array(a)




def make_Xor(a,b):
	d_ = []
	for i in range(len(a)):
		if a[i] == b[i]:
			d_.append("0")
		else:
			d_.append("1")
	return d_


def judge_of_3(a):
	a_ = []
	a_.append(list(format(a[0],'b')))
	a_.append(list(format(a[1],'b')))
	a_.append(list(format(a[2],'b')))
	max_len = max(len(a_[0]),len(a_[1]),len(a_[2]))
	for i in range(3):
		while len(a_[i]) < max_len:
			a_[i].insert(0,'0')
	if make_Xor(a_[0],a_[1]) == a_[2]:
		return True
	else:
		return False
	
	
judge = True

if N % 3 == 0:
	a_1 = np.unique(a)
	if len(a_1) <= 3:
		a = list(a)
		a.sort()
		div_3 = N // 3
		for i in range(3):
			if a[i * div_3] != a[(i+1) * div_3 - 1]:
				judge = False
		a_1 = [a[0],a[div_3],a[2*div_3]]
		if judge:
			if judge_of_3(a_1):
				judge = True
			else:
				judge = False
	else:
		judge = False
else:
	a_1 = np.unique(a)
	a_1 = list(a_1)
	if len(a_1) != 1:
		judge = False
	if a_1[0] != 0:
		judge = False

if judge:
	print("Yes")
else:
	print("No")

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

N = int(input())
a = list(map(int,input().split()))

a = np.array(a)




def make_Xor(a,b):
	d_ = []
	for i in range(len(a)):
		if a[i] == b[i]:
			d_.append("0")
		else:
			d_.append("1")
	return d_


def judge_of_3(a):
	a_ = []
	a_.append(list(format(a[0],'b')))
	a_.append(list(format(a[1],'b')))
	a_.append(list(format(a[2],'b')))
	max_len = max(len(a_[0]),len(a_[1]),len(a_[2]))
	for i in range(3):
		while len(a_[i]) < max_len:
			a_[i].insert(0,'0')
	if make_Xor(a_[0],a_[1]) == a_[2]:
		return True
	else:
		return False
	
	


if N % 3 == 0:
	a_1 = np.unique(a)
	for a_1_ in a_1:	
		if np.count_nonzero(a == a_1_) != int(N // 3):
			judge = False
		else:
			if judge_of_3(a_1):
				judge = True
			else:
				judge = False
else:
	a_1 = np.unique(a)
	a_1 = list(a_1)
	if len(a_1) != 0:
		judge = False
	if a_1[0] != 0:
		judge = False

if judge:
	print("Yes")
else:
	print("No")
Problem p02995 (python)

Fixed submission:
import math
A,B,C,D = map(int,input().split())

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


lcm_C_D = (C * D) // gcd(C, D)
rem_C = lcm_C_D // C
rem_D = lcm_C_D // D

lcm_count = rem_C + rem_D - 1


rem_A = A % lcm_C_D
if rem_A != 0:
	dif_A = lcm_C_D - rem_A
	count_A_C = dif_A // C
	count_A_D = dif_A // D
	before_count = count_A_C + count_A_D + 1
else:
	before_count = 1
	dif_A = 0



dif_B = B % lcm_C_D
if dif_B != 0:
	count_B_C = dif_B // C
	count_B_D = dif_B // D
	after_count = count_B_C + count_B_D 
else:
	after_count = 0
	


syou_A = (A + dif_A) // lcm_C_D
syou_B = (B - dif_B) // lcm_C_D
between_count = (syou_B - syou_A) * lcm_count


print(B - A + 1 - (after_count + between_count + before_count))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())

def lcm(C, D):
    return (C * D) // math.gcd(C, D)

lcm_C_D = lcm(C,D)
rem_C = lcm_C_D // C
rem_D = lcm_C_D // D

lcm_count = rem_C + rem_D - 1


rem_A = A % lcm_C_D
dif_A = lcm_C_D - rem_A
count_A_C = dif_A // C
count_A_D = dif_A // D
before_count = count_A_C + count_A_D + 1



dif_B = B % lcm_C_D
count_B_C = dif_B // C
count_B_D = dif_B // D
after_count = count_B_C + count_B_D 


syou_A = (A + dif_A) // lcm_C_D
syou_B = (B - dif_B) // lcm_C_D
between_count = (syou_B - syou_A) * lcm_count


print(B - A + 1 - (after_count + between_count + before_count))
Problem p03001 (python)

Fixed submission:
W , H , x , y = map(int,input().split())
if x == 0 or x == W:
	x_on_line = True
else:
	x_on_line = False
if y == 0 or y == H:
	y_on_line = True
else:
	y_on_line = False


if x_on_line or y_on_line:
	pattern = 0
	S = W * H / 2
else:
	if (W / 2) == float(x):
		x_half_point = True
	else:
		x_half_point = False
	if (H / 2) == float(y):
		y_half_point = True
	else:
		y_half_point = False
	if x_half_point and y_half_point:
		pattern = 1
		S = W * H / 2
	elif x_half_point or y_half_point:
		pattern = 0
		S = W * H / 2	
	else:
		S = W * H / 2
		pattern = 0
print(S,pattern)

Buggy submission (verdict: Runtime Error):
W , H , x , y = map(int,input().split())
if x == 0 or x == W:
	x_on_line = True
else:
	x_on_line = False
if y == 0 or y == H:
	y_on_line = True
else:
	y_on_line = False


if x_on_line or y_on_line:
	pattern = 0
	S = W * H / 2
else:
	if (W / 2) == float(x):
		x_half_point = True
	else:
		x_half_point = False
	if (H / 2) == float(y):
		y_half_point = True
	else:
		y_half_point = False
	if x_half_point and y_half_point:
		pattern = 1
		S = W * H / 2
	elif x_half_point or y_half_point:
		pattern = 0
		S = W * H / 2	
	else:
		min_x = (x,W - x)
		min_y = (y,H - y)
		S = max((min_x * H,min_y * W))
		pattern = 0
print(S,pattern)
Problem p03049 (python)

Fixed submission:
N = int(input())
s = []
temp_sum = 0
A_or_B_count = [0,0]
AB_count = 0
for i in range(N):
	aaa = input()
	temp_sum += aaa.count("AB")
	if aaa[0] == "B" and aaa[-1] == "A":
		AB_count += 1
	elif aaa[-1] == "A":
		A_or_B_count[0] += 1
	elif aaa[0] == "B":
		A_or_B_count[1] += 1
A_or_B_count.sort()
if A_or_B_count[0] + AB_count > A_or_B_count[1]:
	if A_or_B_count[1] == 0:
		print(temp_sum + min(N-1,AB_count - 1))
	else:
		AB_count -= (A_or_B_count[1] - A_or_B_count[0])
		print(temp_sum + min(N-1,AB_count + A_or_B_count[1]))
else:
	print(temp_sum + min(N - 1,A_or_B_count[0] + AB_count))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = []
temp_sum = 0
A_or_B_count = [0,0]
AB_count = 0
for i in range(N):
	aaa = input()
	temp_sum += aaa.count("AB")
	if aaa[0] == "B" and aaa[-1] == "A":
		AB_count += 1
	elif aaa[-1] == "A":
		A_or_B_count[0] += 1
	elif aaa[0] == "B":
		A_or_B_count[1] += 1
A_or_B_count.sort()
if A_or_B_count[0] + AB_count > A_or_B_count[1]:
	if A_or_B_count[0] == 0:
		print(temp_sum + min(N-1,AB_count - 1)
	else:
		AB_count -= (A_or_B_count[1] - A_or_B_count[0])
		print(temp_sum + min(N-1,AB_count + A_or_B_count[1]))
else:
	print(temp_sum + min(N - 1,A_or_B_count[0] + AB_count))
Problem p03076 (python)

Fixed submission:
time = []
for i in range(5):
	time.append(int(input()))
remain = [0]
for i in range(5):
	if time[i] % 10 != 0:
		remain.append(10 - time[i] % 10)
sum = 0
for i in range(5):
	if time[i] % 10 == 0:
		sum += time[i]
	else:
		sum += (time[i] // 10 + 1) * 10

print(sum - max(remain))

Buggy submission (verdict: Runtime Error):
time = []
for i in range(5):
	time.append(int(input()))
remain = []
for i in range(5):
	if time[i] % 10 != 0:
		remain.append(10 - time[i] % 10)
sum = 0
for i in range(5):
	if time[i] % 10 == 0:
		sum += time[i]
	else:
		sum += (time[i] // 10 + 1) * 10

print(sum - max(remain))
Problem p03125 (python)

Fixed submission:
A,B = map(int,input().split())
if B % A == 0:
	print(A+B)
else:
	print(B-A)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
K_A = []
for i in range(N):
	K_A.append(list(map(int,input().split())))

l = []

for i in range(N):
	del K_A[i][0]
	for j in range(len(K_A[i])):
		l.append(K_A[i][j])
		
count = 0

for i in range(K+1):
	if l.count(i) == N:
		count  += 1

print(count)
Problem p03131 (python)

Fixed submission:
K,A,B = map(int,input().split())
if A+2 >= B:
	print(1+K)
elif K <= A:
	print(1+K)
else:
	new_K = K-A
	if new_K % 2 == 1:
		temp_K = int((new_K+1)/2)
		print((temp_K*B - (temp_K-1)*A))
	else:
		temp_K = int(new_K/2)
		print((int(temp_K*B - (temp_K-1)*A + 1)))

Buggy submission (verdict: Runtime Error):
K,A,B = map(int,input().split())
if A+2 >= B:
	print(1+K)
elif K <= A:
	print(1+K)
else:
	new_K = K-A
	if new_K % 2 == 1:
		temp_K = int((new_K+1)/2)
		print((temp_K*B - (temp_K-1)*A))
	else:
		temp_K = int(new_K/2)
		print(int(temp_K*B - (temp_K-1)*A + 1)))
Problem p03401 (python)

Fixed submission:

N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
dif = []
for i in range(N + 1):
	dif.append((abs(A[i+1] - A[i])))

temp_sum = sum(dif)
for i in range(N):
	print(temp_sum - dif[i] - dif[i+1] + abs(A[i+2] - A[i]))

Buggy submission (verdict: Runtime Error):

N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A.append(0)
dif = []
for i in range(N + 1):
	dif.append((abs(A[i+1] - A[i])))

temp_sum = sum(dif)
for i in range(N):
	print(sum - dif[i] - dif[i+1] + abs(A[i+2] - A[i]))
Problem p03607 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))

A.sort()

i = 0

ans = 0

while i != len(A):
	num = A[i]
	count = 0
	j = i
	while A[j] == num:
		count += 1
		j += 1
		if j == len(A):
			break

	if count % 2 == 1:
		ans += 1
	i += count
	
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
	A.append(int(input()))

max_A = max(A)

num = [0] * (max_A + 1)

for i in range(N):
	num[A[i]] += 1

sum = 0
for i in range(len(num)):
	if num[i] % 2 == 1:
		sum += 1

print(sum)
Problem p03625 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A.sort()
judge = 0
side = []
while judge != 2 and len(A) > 1:
	MAX_A = A[len(A) -1]
	if MAX_A == A[len(A) - 2]:
		side.append(MAX_A)
		judge += 1
		del A[len(A) - 2]
		del A[len(A) - 1]
	else:
		del A[len(A) -1]

if judge == 2:
	print(side[0] * side[1])
else:
	print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A.sort()
judge = 0
side = []
while judge != 2 and len(A) > 1:
	MAX_A = A[len(A) -1]
	if MAX_A == A[len(A) - 2]:
		side.append(MAX_A)
		judge += 1
		del A[len(A) - 1]
		del A[len(A) - 2]
	else:
		del A[len(A) -1]

print(side[0] * side[1])
Problem p03844 (python)

Fixed submission:
A , op , B = input().split()
if op == "+":
	print(int(A) + int(B))
else:
	print(int(A) - int(B))

Buggy submission (verdict: Runtime Error):
A , op , B = input().split()
if op == "+":
	print(int(A) + int(B))
else:
	print(int(A) - int(B)

Buggy submission (verdict: Runtime Error):
A , op , B = map(int,input().split())
if op == "+":
	print(int(A) + int(B))
else:
	print(int(A) - int(B))
Problem p02683 (python)

Fixed submission:
N, M , X = list(map(int,input().split()))

c = [[]]*N
a = [[[]]*M]*N

for n in range(N):
    temp = list(map(int,input().split()))
    c[n] = temp[0]
    a[n] = temp[1:M+1]


ans = 10**7

for i in range(2 ** N):
    price = 0
    intelligence = [0 for _ in range(M)]
    for j in range(N):
        if ((i >> j) & 1):
            price += c[j]
            for k in range(M):
                intelligence[k] += a[j][k]
    flag = 1
    for k in range(M):
        if intelligence[k] < X:
            flag = 0
    if flag == 1:
        ans = min(ans,price)

if ans == 10**7:
    print(-1)
else:
    print(ans)

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

c = [[]]*N
a = [[[]]*M]*N

for n in range(N):
    temp = list(map(int,input().split()))
    c[n] = temp[0]
    a[n] = temp[1:N+1]


ans = 10**7

for i in range(2 ** N):
    price = 0
    intelligence = [0 for _ in range(M)]
    for j in range(N):
        if ((i >> j) & 1):
            price += c[j]
            for k in range(M):
                intelligence[k] += a[j][k]
    flag = 1
    for k in range(M):
        if intelligence[k] < X:
            flag = 0
    if flag == 1:
        ans = min(ans,price)

if ans == 10**7:
    print(-1)
else:
    print(ans)
Problem p02787 (python)

Fixed submission:
H,N = list(map(int,input().split()))

a = [0]*N
b = [0]*N

for i in range(N):
	a[i],b[i] = list(map(int,input().split()))

inf = float("inf")
dp = [inf]*(H+1)
dp[0] = 0
dp[1] = min(b)

for h in range(1,H+1):
	for n in range(N):
		h_temp = h-a[n]
		if h_temp <= 0:
			dp[h] = min(dp[h],b[n])
		else:
			dp[h] = min(dp[h],dp[h_temp]+b[n])
print(dp[H])

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

a = [0]*N
b = [0]*N

for i in range(N):
	a[i],b[i] = list(map(int,input().split()))

inf = float("inf")
dp = [inf]*(H+1)
dp[0] = 0
dp[1] = min(b)

for h in range(1,H+1):
	for n in range(N):
		h_temp = h-a[n]
		dp[h] = min(dp[h],dp[h_temp]+b[n])
print(dp[H])
Problem p02923 (python)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))

high = []

for i in range(N-1):
	if h[i] < h[i+1]:
		high.append(i+1)
ans = 0
temp = 0
if len(high) == 0:
	print(len(h)-1)
	exit()

for i in high:
	ans = max(i-temp-1,ans)
	temp = i
temp = N
ans = max(N-high[-1]-1,ans)
print(ans)

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

high = []

for i in range(N-1):
	if h[i] < h[i+1]:
		high.append(i+1)
ans = 0
temp = 0
for i in high:
	ans = max(i-temp-1,ans)
	temp = i
temp = N
ans = max(N-high[-1]-1,ans)
print(ans)
Problem p02924 (python)

Fixed submission:
import numpy as np
N = int(input())
print((N*(N-1))//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(range(1,N+1))
b = list(range(2,N+2))
b[N-1] = 1

sum = 0
for i in range(N):
	sum += a[i]%b[i]
print(sum)
Problem p03050 (python)

Fixed submission:
import math
N = int(input())
ans = 0
n_max = int(math.sqrt(N))
for n in range(1,n_max+1):
	if N%n == 0:
		a = N//n
		if a+1 < n:
			ans += n-1
		elif n+1 < a:
			ans += a-1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for m in range(N):
	if N//m == N%m:
		ans += 1

print(ans)