Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

inf = float('inf')
p = 2**n
dp = [inf]*p
dp[0] = 0

for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(int(i)-1) for i in list(input().split())])
    for i in range(p):
        dp[i|c] = min(dp[i|c], dp[i] + a)
    
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])


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

n, m = map(int, input().split())

inf = float('inf')
p = 2**n
dp = [inf]*p
dp[0] = 0

for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(i-1) for i in map(int, input().split())])
    for i in range(p):
        if dp[i|c] > dp[i] + a: 
            dp[i|c] = dp[i] + a
    
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, m = map(int, input().split())

inf = float('inf')
p = 2**n
dp = [inf]*p
dp[0] = 0

for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(i-1) for i in map(int, input().split())])
    for i in range(p):
        dp[i|c] = min(dp[i|c], dp[i] + a)
    
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])


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

n, m = map(int, input().split())

inf = float('inf')
p = 2**n
dp = [inf]*p
dp[0] = 0

for _ in range(m):
    a, _ = map(int, input().split())
    c = sum([2**(i-1) for i in map(int, input().split())])
    for i in range(p):
        if dp[i|c] > dp[i] + a: 
            dp[i|c] = dp[i] + a
    
if dp[-1] == inf:
    print(-1)
else:
    print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import bisect
import numpy as np

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)
a = np.array(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

Fixed submission:
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s=='Rainy':
    print('Sunny')
else:
    print('Rainy')
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))

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

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)

'''
    left = 0
    right = n-2
    mid = 0
    while left < right:
        mid = (left + right) // 2
        if a[mid] > temp:
            right = mid - 1
            if right == left:
                a.insert(right+1, temp)
        elif a[mid] < temp:
            left = mid + 1
            if right == left:
                a.insert(right, temp)
        else:
            a.insert(right, temp)
            break
'''
    
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
*a, = map(int, input().split())

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()

    left = 0
    right = n-2
    mid = 0
    while left < right:
        mid = (left + right) // 2
        if a[mid] > temp:
            right = mid - 1
            if right == left:
                a.insert(right+1, temp)
        elif a[mid] < temp:
            left = mid + 1
            if right == left:
                a.insert(right, temp)
        else:
            a.insert(right, temp)
            break
    
    
print(sum(a))

Fixed submission:
import heapq

n, m = map(int, input().split())
*a, = map(int, input().split())

ans = []
for i in range(n):
    heapq.heappush(ans, -a[i])

for i in range(m):
    temp = -heapq.heappop(ans)
    heapq.heappush(ans, -(temp//2))

print(-sum(ans))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n-1):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)
print(ans)

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

cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)
print(ans)

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

cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = int(input())

cnt = 0
for i in range(n):
    if s[i] != s[i+1]:
        cnt += 1
ans = min(count+2*k, n-1)


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

cnt = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        cnt += 1
ans = min(cnt+2*k, n-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
 
sys.setrecursionlimit(200000000)
 
n, q = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n-1)]
px = [list(map(int, input().split())) for _ in range(q)]
 
l = [[] for i in range(n+1)]
for pi in ab:  
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
 
def dfs(graph, start, oya):
    if start != 1:
        graph[start].remove(oya)
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs(graph, i, start)
 
dfs(l, 1, 1)
 
def dfs_2(graph, start, ans, x):
    ans[start] += x
    if len(graph[start]) == 0:
        return
    else:
        for i in graph[start]:
            dfs_2(graph, i, ans, x)
 
ans = [0 for i in range(n+1)]
for p, x in px:
    dfs_2(l, p, ans, x)
        
for i in range(1, n+1):
    print(ans[i], end=' ')
print()

Fixed submission:
a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

mod = 10**9 + 7

N = 13
dp = [0]*N
dp[0] = 1
mul = 1
for i in range(len(s)-1, -1, -1):
    nextDP = [0]*N
    if s[i] == '?':
        for k in range(10):
            for j in range(N):
                nextDP[(k*mul + j)%N] += dp[j]
                nextDP[(k*mul + j)%N] %= mod
    else:
        k = int(s[i])
        for j in range(N):
            nextDP[(k*mul + j)%N] += dp[j]
            nextDP[(k*mul + j)%N] %= mod

    mul = (mul*10)%N
    dp = nextDP

print(dp[5])

Fixed submission:
s = list(input())

mod = 10**9 + 7

N = 13
dp = [0]*N
dp[0] = 1
mul = 1
for i in range(len(s)-1, -1, -1):
    nextDP = [0]*N
    if s[i] == '?':
        for k in range(10):
            for j in range(N):
                nextDP[(k*mul + j)%N] += dp[j]
                nextDP[(k*mul + j)%N] %= mod
    else:
        k = int(s[i])
        for j in range(N):
            nextDP[(k*mul + j)%N] += dp[j]
            nextDP[(k*mul + j)%N] %= mod

    mul = (mul*10)%N
    dp = nextDP

print(dp[5])
Buggy python submission (verdict: Runtime Error):
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, n-k+2):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

Fixed submission:
s = input()

for i in range(4):
    cnt = s.count(s[i])
    if(cnt != 2):
        print('No')
        break
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
import math
from operator import mul
from functools import reduce

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)

Fixed submission:
n = int(input())
*d, = map(int, input().split())

d.sort()

print(d[n//2] - d[n//2-1])
Buggy python submission (verdict: Runtime Error):
import math
mod = 10**9+7

def comb(n, r):
  return (math.factorial(n)) / (math.factorial(n-r)) / (math.factorial(r))

n, k = map(int, input().split())


for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i)%mod * comb(k-1, i-1)%mod
    ans %= mod
  else:
    ans = 0
  print(int(ans))

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

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)

Buggy python submission (verdict: Runtime Error):
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(int(ans))

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

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)

Buggy python submission (verdict: Runtime Error):
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, min(n-k+2, k+1)):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

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

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)

Buggy python submission (verdict: Runtime Error):
import math

def comb(n, r):
  return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  ans = comb(n-k+1, i) * comb(k-1, i-1)
  ans %= mod
  print(int(ans))

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

def comb(n, r):
  r = min(r, n-r)
  if r==0: return 1
  over = reduce(mul, range(n, n-r, -1))
  under = reduce(mul, range(1, r+1))
  return over//under

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k+1):
  if i <= n-k+1:
    ans = comb(n-k+1, i) * comb(k-1, i-1)
    ans %= mod
  else:
    ans = 0
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a = np.array(a)

for b, c in bc:
    a.sort()
    idx = np.where(a<c)[0].size
    idx = b if idx>b else idx
    a[0:idx] = c

print(a.sum(dtype="int64"))

Fixed submission:
n, m = map(int, input().split())
*a, = map(int, input().split())
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(key=lambda x:-x[1])
i = 0

for b,c in bc:
    for j in range(i, min(n, i+b)):
        if a[j]<c:
            a[j] = c
    i = i+b
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a = np.array(a)

for b, c in bc:
    a.sort()
    c_under_cnt = a[a<c].size

    idx = b if b<c_under_cnt else c_under_cnt
    a[0:idx] = [c] * idx

print(a.sum(dtype="int64"))


Fixed submission:
n, m = map(int, input().split())
*a, = map(int, input().split())
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(key=lambda x:-x[1])
i = 0

for b,c in bc:
    for j in range(i, min(n, i+b)):
        if a[j]<c:
            a[j] = c
    i = i+b
print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]



for b, c in bc:
    a.sort()
    for i in range(b):
        if a[i]>=c:
            idx = i
            break
    else:
        idx = b
    a[0:idx] = [c] * idx

print(sum(a))


Fixed submission:
n, m = map(int, input().split())
*a, = map(int, input().split())
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(key=lambda x:-x[1])
i = 0

for b,c in bc:
    for j in range(i, min(n, i+b)):
        if a[j]<c:
            a[j] = c
    i = i+b
print(sum(a))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
uvw = [list(map(int, input().split())) for _ in range(n-1)]

graph = [[] for _ in range(n)]
for i in range(n-1):
    graph[uvw[i][0]-1].append((uvw[i][1]-1, uvw[i][2]))
    graph[uvw[i][1]-1].append((uvw[i][0]-1, uvw[i][2]))

stack = [0]
visited = []
ans = [0]*n
while stack:
    node = stack.pop()
    visited.append(node)
    for child in graph[node]:
        if child[0] not in visited:
            stack.append(child[0])
            if child[1]%2 == 0:
                ans[child[0]] = ans[node]
            else:
                ans[child[0]] = (ans[node]+1)%2

[print(ans[i]) for i in range(n)]


Fixed submission:

n,k = map(int, input().split())
s = input()

s_temp = s.swapcase()

ans = s[:k-1]+s_temp[k-1]+s[k:]

print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = input()

s_temp = s.swapcase()

ans = s[:k]+s_temp[k]+s[k+1:]

print(ans)

Fixed submission:

n,k = map(int, input().split())
s = input()

s_temp = s.swapcase()

ans = s[:k-1]+s_temp[k-1]+s[k:]

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2 ==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))

Fixed submission:
a, b, t = map(int, input().split())
cnt = 0
temp = a
while t+0.5 > temp:
    cnt += 1
    temp += a
print(b*cnt)
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n = int(input())
*a, = map(int, input().split())

import fractions
from functools import reduce
import numpy as np

def gcd_list(a):
    return reduce(fractions.gcd, a)

left = [0]*n
right = [0]*n

for i in range(1, n):
    left[i] = np.gcd.reduce(a[:i])

for i in range(n-2, -1, -1):
    right[i] = np.gcd.reduce(a[i+1:])

ans = 0
for i in range(n):
    ans = max(ans, gcd_list([left[i], right[i]]))
print(ans)

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

n = int(input())
*a, = map(int, input().split())

from fractions import gcd
from functools import reduce
import numpy as np

new_gcd = np.frompyfunc(gcd, 2, 1)

a = np.array(a)
left = new_gcd.accumulate(a, dtype=np.object).astype(np.int)
right = new_gcd.accumulate(a[::-1], dtype=np.object).astype(np.int)[::-1]
left = np.append([0], left[:-1])
right = np.append(right[1:], 0)

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
*a, = map(int, input().split())

import fractions
from functools import reduce

def gcd_list(a):
    return reduce(fractions.gcd, a)

left = [0]*n
right = [0]*n

for i in range(1, n):
    left[i] = gcd_list(a[:i])

for i in range(n-2, -1, -1):
    right[i] = gcd_list(a[i+1:])

ans = 0
for i in range(n):
    ans = max(ans, gcd_list([left[i], right[i]]))
print(ans)

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

n = int(input())
*a, = map(int, input().split())

from fractions import gcd
from functools import reduce
import numpy as np

new_gcd = np.frompyfunc(gcd, 2, 1)

a = np.array(a)
left = new_gcd.accumulate(a, dtype=np.object).astype(np.int)
right = new_gcd.accumulate(a[::-1], dtype=np.object).astype(np.int)[::-1]
left = np.append([0], left[:-1])
right = np.append(right[1:], 0)

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i]))
print(ans)
Buggy python submission (verdict: Runtime Error):
from numpy import *

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

if len(A[A<0])%2 == 0:
    print(sum(abs(A)))
else:
    A = abs(A).sort()
    print(sum(A[1:]) - A[0])

Fixed submission:
n = int(input())
*a, = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))

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

N = int(input())
A = np.array(map(int, input().split()))
if len(A[A<0])%2 == 0:
    ans = sum(abs(A))
else:
    A = sorted(abs(A))
    ans = sum(A[1:])-A[0]
print(ans)



Fixed submission:
n = int(input())
*a, = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))

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

N = int(input())
A = np.array(map(int, input().split()))
if len(A[A<0])%2 == 0:
    ans = sum(abs(A))
else:
    A = sorted(abs(A))
    ans = sum(A[1:] - A[0])
print(ans)

Fixed submission:
n = int(input())
*a, = map(int, input().split())
*a_abs, = map(abs, a)
if len([i for i in a if i<0])%2==0:
    print(sum(a_abs))
else:
    print(sum(a_abs)-2*min(a_abs))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s_split_0 = s.split("1")
s_split_1 = s.split("0")

s_split_1= [len(i) for i in s_split_1 if i!=""]
s_split_0= [len(i) for i in s_split_0 if i!=""]

if s[0]=="1":
    print(max([sum(s_split_0[i:i+k])+sum(s_split_1[i:i+k+1]) for i in range(len(s_split_0)-k+1)]))
else:
    print(max([sum(s_split_0[i:i+k])+sum(s_split_1[i:i+k]) for i in range(len(s_split_1)-k+1)]))


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

n, k = map(int, input().split())
s = input()+'-1'

cnt = 0
cnt_list = []
for i in range(n):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt+1)
        cnt = 0

# print(cnt_list)


l = 0
r = 2*k
ma = 0
su = 0
if s[0] == '0':
    r = 2*k
else:
    r = 2*k+1
su = sum(cnt_list[l:r])
while l < r:
    if ma < su:
        ma = su
    if l == 0 and r == 2*k:
        l += 1
        su -= cnt_list[l-1]
    else:
        l += 2
        su -= sum(cnt_list[l-2:l])
    r += 2
    su += sum(cnt_list[r-2:r])
    if r >= len(cnt_list):
        r = len(cnt_list)
    
print(ma)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
s_split_0 = s.split("1")
s_split_1 = s.split("0")

s_split_1= [len(i) for i in s_split_1 if i!=""]
s_split_0= [len(i) for i in s_split_0 if i!=""]

if s[0]=="1":
    print(max([sum(s_split_0[i:i+k])+sum(s_split_1[i:i+k+1]) for i in range(len(s_split_0)-k+1)]))
else:
    print(max([sum(s_split_0[i:i+k+1])+sum(s_split_1[i:i+k]) for i in range(len(s_split_1)-k+1)]))


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

n, k = map(int, input().split())
s = input()+'-1'

cnt = 0
cnt_list = []
for i in range(n):
    if s[i] == s[i+1]:
        cnt += 1
    else:
        cnt_list.append(cnt+1)
        cnt = 0

# print(cnt_list)


l = 0
r = 2*k
ma = 0
su = 0
if s[0] == '0':
    r = 2*k
else:
    r = 2*k+1
su = sum(cnt_list[l:r])
while l < r:
    if ma < su:
        ma = su
    if l == 0 and r == 2*k:
        l += 1
        su -= cnt_list[l-1]
    else:
        l += 2
        su -= sum(cnt_list[l-2:l])
    r += 2
    su += sum(cnt_list[r-2:r])
    if r >= len(cnt_list):
        r = len(cnt_list)
    
print(ma)
Buggy python submission (verdict: Runtime Error):

a, b, k = map(int, input().split())
temp = a if a>b else b
list =  [i  for i in range(1,temp+1) if a%i==0 and b%i==0]
list = list[::-1]
print(list[k-1]

Fixed submission:

a, b, k = map(int, input().split())
temp = a if a>b else b
list =  [i  for i in range(1,temp+1) if a%i==0 and b%i==0]
list = list[::-1]
print(list[k-1])

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
temp = a if a>b else b
list =  [i  for i in range(1,temp) if a%i==0 and b%i==0]
list = list[::-1]
print(list[k-1])

Fixed submission:

a, b, k = map(int, input().split())
temp = a if a>b else b
list =  [i  for i in range(1,temp+1) if a%i==0 and b%i==0]
list = list[::-1]
print(list[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
*h, = map(int, input().split())

dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]))

print(dp[-1])

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

n, k = map(int, input().split())
*h, = map(int, input().split())

dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    for j in range(1, k+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j]+abs(h[i-j]-h[i]))

print(dp[-1])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
print(dp[-1])

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

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n)]

for i in range(wv[0][0], w+1):
    dp[0][i] = wv[0][1]

for i in range(1, n):
    for j in range(w+1):
        if j-wv[i][0] < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i][0]]+wv[i][1])
print(dp[n-1][w])