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

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    max_a = max(a)
    count = [0 for _ in range(max_a+1)]
    c = collections.Counter(a)
    c = list(c.items())

    if len(c) == 1:
        print(c[0][1])

    elif len(c) == 2:
        if abs(c[0][0]-c[1][0]) <= 2:
            print(c[0][1]+c[1][1])
        else:
            print(max(c[0][1],c[1][1]))

    else:
        for i in range(len(c)):
            count[c[i][0]] = c[i][1]

        sum_list = [0 for _ in range(len(count)-2)]
        for i in range(len(count)-2):
            sum_list[i] = count[i]+count[i+1]+count[i+2]
        print(max(sum_list))

if __name__ == "__main__":
    main()

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    max_a = max(a)
    count = [0 for _ in range(max_a)]
    c = collections.Counter(a)
    c = list(c.items())

    if len(c) == 1:
        print(c[0][1])

    elif len(c) == 2:
        if abs(c[0][0]-c[1][0]) <= 2:
            print(c[0][1]+c[1][1])
        else:
            print(max(c[0][1],c[1][1]))

    else:
        for i in range(len(c)):
            count[c[i][0]-1] = c[i][1]

        sum_list = [0 for _ in range(len(c)-2)]
        for i in range(len(c)-2):
            sum_list[i] = count[i]+count[i+1]+count[i+2]
        print(max(sum_list))

if __name__ == "__main__":
    main()

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

def main():
    N = int(input())
    a = list(map(int,input().split()))
    max_a = max(a)
    count = [0 for _ in range(max_a)]
    c = collections.Counter(a)
    c = list(c.items())

    if len(c) == 1:
        print(c[0][1])

    elif len(c) == 2:
        if abs(c[0][0]-c[1][0]) <= 2:
            print(c[0][1]+c[1][1])
        else:
            print(max(c[0][1],c[1][1]))

    else:
        for i in range(len(c)):
            count[c[i][0]-1] = c[i][1]

        sum_list = [0 for _ in range(len(c)-2)]
        for i in range(len(c)-2):
            sum_list[i] = count[i]+count[i+1]+count[i+2]
        print(sum_list)

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

Fixed submission:
import sys
input = sys.stdin.readline
def main():
	N = int(input())
	a = list(map(int,input().split()))
	a.sort()
	sum_list = [a[0]]
	for i in range(N-1):
		sum_list.append(sum_list[i]+a[i+1])
	count = 0
	for i in range(N-1):
		if 2*sum_list[i] < a[i+1]:
			count = i+1

	print(N-count)

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
	N = int(input())
	a = list(map(int,input().split()))
	a.sort(reverse=True)
	sum_list = [a[0]]
	for i in range(N-1):
		sum_list.append(sum_list[i]+a[i+1])
	count = 1
	sum(a) = A
	for i in range(N):
		if (A-sum_list[i])*2 >= a[i]:
			count += 1
		else:
			break

	print(count)

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

Fixed submission:
import sys
#input = sys.stdin.buffer.readline
sys.setrecursionlimit(20000+1)

def main():
    s = "".join(list(reversed(str(input()))))
    b = True
    
    while len(s) != 0:
        if len(s) >= 5:
            use = ["maerd","esare"]
            if s[:5] in use:
                s = s[5:]
            elif (len(s) >= 6 and s[:6] == "resare"):
                s = s[6:]
            elif (len(s) >= 7 and s[:7] == "remaerd"):
                s = s[7:]
            else:
                b = False
                break
        else:
            b = False
            break
            
    if b:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()

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

def main():
    S = str(input())
    five = ["dream","erase"]
    def dream(s):
        if len(s) == 0:
            return True
        elif len(s) < 5:
            return False
        else:
            if s[:5] not in five:
                return False
            else:
                if s[:5] == "dream":
                    sf = s[5:]
                    if s[:7] == "dreamer":
                        se = s[7:]
                        return (dream(sf) or dream(se))
                    else:
                        return dream(sf)
                if s[:5] == "erase":
                    sf = s[5:]
                    if s[:6] == "eraser":
                        ss = s[6:]
                        return (dream(sf) or dream(ss))
                    else:
                        return dream(sf)
                
    if dream(S):
        print("YES")
    else:
        print("NO")

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

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

def main():
	
	class BinaryIndexedTree:
		
		# 初期化
		def __init__(self, size, default):
			self.size = size
			self.default = default
			self.BIT = [default]*(self.size+1)

		# function(max, min, plus, minus, etc...)
		def BIT_segfunc(self, x, y):
			return max(x, y)

		def BIT_query(self, idx):
			ret = self.default
			while idx > 0:
				ret = self.BIT_segfunc(ret, self.BIT[idx])
				idx -= idx&(-idx)
			return ret

		# update
		def BIT_update(self, idx, x):
			while idx <= self.size:
				self.BIT[idx] = self.BIT_segfunc(self.BIT[idx], x)
				idx += idx&(-idx)
			return

		def BIT_range(self, x, y):
			return self.BIT_query(y)-self.BIT_query(x)

		# seg確認用
		def BIT_print(self):
			print(self.BIT)
		
	N = int(input())
	a = list(map(int,input().split()))
	l = [0]*N;r = [0]*N
	left_bit = BinaryIndexedTree(N, 0)
	for i, num in enumerate(a):
	    l[num-1] = i + 1 - left_bit.BIT_query(num)
	    left_bit.BIT_update(num, i+1)
	right_bit = BinaryIndexedTree(N, 0)
	for i, num in enumerate(a[::-1]):
	    r[num-1] = i + 1 - right_bit.BIT_query(num)
	    right_bit.BIT_update(num, i+1)
	
	print(sum(l[i]*r[i]*(i+1) for i in range(N)))

if __name__ == "__main__":
	main()

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

def main():
	
	# SegmentTree Class
	class SegmentTree:
		
		# 初期化
		def __init__(self, size, default):
			self.size = 2**(size-1).bit_length()
			self.default = default
			self.seg = [default]*(2*self.size)

		# function(max, min, plus, minus, etc...)
		def segfunc(self,x,y):
			return max(x,y)

		# update
		def update(self,k,x):
			k += self.size
			self.seg[k] = x
			while k:
				k = (k-1)//2
				self.seg[k] = self.segfunc(self.seg[2*k+1],self.seg[2*k+2])

		# query([p,q)のsegfunc)
		def query(self,p,q):
			if q <= p:
				return self.default
			p += self.size-1;q += self.size-2
			ret = self.default
			while q-p > 1:
				if p&1 == 0:
					ret = self.segfunc(ret,self.seg[p])
				if q&1 == 1:
					ret = self.segfunc(ret,self.seg[q])
					q -= 1
				p = p//2
				q = (q-1)//2
			ret = self.segfunc(self.segfunc(ret,self.seg[p]),self.seg[q])
			return ret

		# seg確認用
		def seg_print(self):
			print(self.seg)
		
	N = int(input())
	a = list(map(int,input().split()))
	ans=[i+1 for i in range(N)]
	left_seg = SegmentTree(N, 0)
	for i, num in enumerate(a):
	    ans[num-1] *= i + 1 - left_seg.query(0,num)
	    left_seg.update(num-1, i+1)
	right_seg = SegmentTree(N, 0)
	for i, num in enumerate(a[::-1]):
	    ans[num-1] *= i + 1 - right_seg.query(0,num)
	    right_seg.update(num-1, i+1)
	
	print(sum(ans))

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

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

def main():
    N,x = map(int,input().split())
    a = list(map(int,input().split()))
    b = a.copy()
    
    ans = 10**15
    for i in range(N):
        time = i*x+sum(b)
        ans = min(ans,time)
        for now in range(N):
            b[now] = min(b[now],a[(now-i-1+N)%N])

    print(ans)

if __name__ == "__main__":
    main()

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

def main():
    N,x = map(int,input().split())
    a = list(map(int,input().split()))
    b = a.copy()
    
    ans = 10**15
    for i in range(N):
        time = i*x+sum(b)
        ans = min(ans,time)
        for now in range(N):
            b[now] = min(b[now],a[(now-i-1+N)%N])

    print(ans)

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

Fixed submission:
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
import numpy as np

def main():
	N,A = map(int,input().split())
	x = list(map(int,input().split()))
	for i in range(N):
		x[i] -= A

	base = 50*50
	dp = np.zeros(base*2+1,dtype=int)
	dp[base] = 1
	for num in x:
		if num == 0:
			use = dp.copy()
			dp += use
		elif num > 0:
			use = dp[:-num].copy()
			dp[num:] += use
		else:
			use = dp[-num:].copy()
			dp[:num] += use

	print(dp[base]-1)

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

Fixed submission:
from sys import stdin
from collections import deque

n,m=map(int,input().split())
ab=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,stdin.readline().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
queue=[0]
ans=[-1]*n
ans[0]=0
while len(queue)!=0:
    now_check=queue.pop(0)
    for i in ab[now_check]:
        if ans[i]==-1:
            queue.append(i)
            ans[i]=now_check
print('Yes')
for i in range(1,n):
    print(ans[i]+1)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import deque

n,m=map(int,input().split())
ab=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,readline().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
queue=[0]
ans=[-1]*n
ans[0]=0
while len(queue)!=0:
    now_check=queue.pop(0)
    for i in ab[now_check]:
        if ans[i]==-1:
            queue.append(i)
            ans[i]=now_check
print('Yes')
for i in range(1,n):
    print(ans[i]+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[[] for _ in range(m)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    ab[a].append(b)
    ab[b].append(a)
queue=[0]
ans=[-1]*n
ans[0]=0
while queue:
    now_check=queue.pop(0)
    for i in ab[now_check]:
        if ans[i]==-1:
            queue.append(i)
            ans[i]=now_check
print('Yes')
for i in range(1,n):
    print(ans[i]+1)
Problem p02900 (python)

Fixed submission:
def gcd(a, b):
	return gcd(b, a % b) if b else a

A, B = map(int, input().split())
c = gcd(A, B)
d = set()
i = 2
while i * i <= c:
	while c % i == 0:
		c /= i
		d.add(i)
	i += 1
if c != 1:
	d.add(c)
print(len(d) + 1)

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())
c = math.gcd(A, B)
d = set()
i = 2
while i * i <= c:
	while c % i == 0:
		c /= i
		d.add(i)
	i += 1
if c != 1:
	d.add(c)
print(len(d) + 1)
Problem p02585 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-


def main():
  n, k = map(int, input().strip().split())
  lp = list(map(lambda p:int(p)-1, input().strip().split()))
  lc = list(map(int, input().strip().split()))

  used = [0] * n
  loops = []
  for i in range(n):
    if used[i] == 1:
      continue
      
    ic = i
    loop = []
    while used[ic] == 0:
      loop.append(lc[ic])
      used[ic] = 1      
      ic = lp[ic]
      
    if len(loop) > 0:
      loops.append(loop)
    
  def loop_score(loop, k):
    return (k // len(loop)) * sum(loop)
  
  def path_score(loop, k):
    score = 0
    for i in range(len(loop)):
      cumsum = 0
      for j in range(k):
        cumsum += loop[(i+j) % len(loop)]
        score = max(score, cumsum)
    return score
  
  def calc_score(loop, k):
    if max(loop) < 0:
      return max(loop)
    
    if k < len(loop):
      return path_score(loop, k)
    if k >= len(loop):
      k -= len(loop)
      score = 0
      if sum(loop) > 0:
        score += loop_score(loop, k)
      k %= len(loop)
      k += len(loop)
      score += path_score(loop, k)

    return score
  
  print(max([calc_score(loop, k) for loop in loops]))

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().strip().split())
  lp = list(map(lambda c:int(c)-1, input().strip().split()))
  lc = list(map(int, input().strip().split()))
  used = [0] * n
  loops = []
  for i in range(n):
    if used[i] == 1:
      continue
      
    ic = i
    loop = []
    while True:
      loop.append(lc[ic])
      used[ic] = 1      
      ic = lp[ic]
      if used[ic] == 1:
        break
    if len(loop) > 0:
      loops.append(loop)
    
    
  def f(loop, k):
    if max(loop) < 0:
      return max(loop)
    
    score = 0
    if sum(loop) > 0:
      score += (k // len(loop)) * sum(loop)
      k = k % len(loop)
    k = min(k, len(loop)-1)
    loop = 2 * loop
    score += max([sum(loop[i:i+ik]) for i in range(len(loop)//2) for ik in range(1, k+1)])
    return score
  
  print(max([f(loop, k) for loop in loops]))

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

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**18
MIN = -MAX

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()

  Ans, Aps, Azs = [], [], []
  for A in As:
    if A > 0:
      Aps.append(A)
    elif A == 0:
      Azs.append(A)
    else:
      Ans.append(A)

  def count(xs, ys, ub):
    c = 0
    r = len(ys) - 1
    for l in range(len(xs)):
      while  r >= 0 and xs[l] * ys[r] > ub:
        r -= 1
      c += r+1
    return c 

  def bs(l, r):
    while True:
      mid = (l+r) // 2
      if r - l <= 1:
        return r
      
      tot = 0      
      tot += count(Aps, Aps, mid) - sum([1 for A in Aps if A**2 <= mid])
      tot += count(Ans[::-1], Ans[::-1], mid) - sum([1 for A in Ans if A**2 <= mid])
      tot //= 2

      if mid >=0:
        tot += (len(Aps) + len(Ans)) * len(Azs) + (len(Azs) * (len(Azs) - 1)) // 2
      tot += count(Aps[::-1], Ans, mid)
      
      if tot < k:
        l = mid
      else:
        r = mid
  
  print(bs(MIN-1, MAX+1))
    
    
if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**18
MIN = -MAX

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()

  Ans, Aps, Azs = [], [], []
  for A in As:
    if A > 0:
      Aps.append(A)
    elif A == 0:
      Azs.append(A)
    else:
      Ans.append(A)

  def count(xs, ys, ub):
    c = 0
    r = len(ys) - 1
    for l in range(len(xs)):
      while xs[l] * ys[r] > ub and r >= 0:
        r -= 1
      c += r+1
    return c 

  def bs(l, r):
    while True:
      mid = (l+r) // 2
      if r - l <= 1:
        return r
      tot = 0
      
      tot += count(Aps, Aps, mid) - sum([1 for A in Aps if A**2 <= mid])
      tot += count(Ans[::-1], Ans[::-1], mid) - sum([1 for A in Ans if A**2 <= mid])
      tot //= 2

      if mid >=0:
        tot += (len(Aps) + len(Ans)) * len(Azs) + (len(Azs) * (len(Azs) - 1)) // 2
      tot += count(Aps[::-1], Ans, mid)
      
      if tot < k:
        l = mid
      else:
        r = mid
  
  print(bs(MIN-1, MAX+1))
    
    
if __name__=='__main__':
  main()
Problem p02775 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = input().strip()[::-1]
  dp = [[0, 0] for _ in range(len(n))]
  dp[0][0] = int(n[0])
  dp[0][1] = 10 - int(n[0])
  for i, d in enumerate(map(int, n[1:]), 1):
    dp[i][0] = min(dp[i-1][0] + d,      dp[i-1][1] + 1 + d)
    dp[i][1] = min(dp[i-1][0] + 10 - d, dp[i-1][1] + 10 - (d + 1))
  print(min(dp[-1][0], dp[-1][1]+1))  

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n = input().strip()[::-1]
  dp = numpy.zeros((len(n), 2), dtype=numpy.int)
  dp[0][0] = int(n[0])
  dp[0][1] = 10 - int(n[0])
  for i, d in enumerate(map(int, n[1:]), 1):
    dp[i][0] = min(dp[i-1][0] + d,      dp[i-1][1] + 1 + d)
    dp[i][1] = min(dp[i-1][0] + 10 - d, dp[i-1][1] + 10 - (d + 1))
  print(min(dp[-1][0], dp[-1][1]+1))  

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

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import random

MAX = 10**9 + 7

def pow_mod_p(n, k, p):
  x = 1
  while k > 0:
    if k % 2 == 1:
      x *= n
      x %= p
    n **= 2
    n %= p
    k >>= 1
  return x

def comb_mod_p(n, k, p):
  x = 1
  for ik in range(k):
    x *= ((n-ik) * pow_mod_p(ik+1, p-2, p))
    x %= p
  return x

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()
  min = 0
  max = 0
  x = comb_mod_p(n-1, k-1, MAX)
  for i in range(n-k+1):
    min += As[i]      * int(x)
    min %= MAX
    max += As[-(i+1)] * int(x)
    max %= MAX
    x *= (pow_mod_p(n-(i+1), MAX-2, MAX) * (n-(i+1)-(k-1)))
    x %= MAX
  print((max - min) % (MAX))

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import factorial

def main():
  n, k = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  As.sort()
  min = 0
  max = 0
  for i in range(n-k+1):
    x = (factorial(n-(i+1)) / factorial(k-1) / factorial((n-(i+1)) - (k-1)))
    min += As[i]      * int(x)
    max += As[-(i+1)] * int(x)
  print((max - min) % (10**9 + 7))

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

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def gcd(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def lcm(a, b):
  return int(a * b // gcd(a, b))


def main():
  n, m = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  x = 1
  for i in range(len(As)):
    x = lcm(x, As[i])
    if m/x < 0.5:
      print(0)
      return
  if sum([(x//A)%2 == 1 for A in As]) == len(As):
    print(int(m/x-0.5+1))
  else:
    print(0)

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def lcm(a, b):
  if a > b:
    a, b = b, a
  while True:
    a, b = b%a, a
    if a == 0:
      return b

def gcm(a, b):
  return int(a * b / lcm(a, b))


def main():
  n, m = map(int, input().strip().split())
  As = list(map(int, input().strip().split()))
  x = 1
  for i in range(len(As)):
    x = gcm(x, As[i])
  if sum([(x//A)%2 == 1 for A in As]) == len(As):
    print(int(m/x-0.5)+1)
  else:
    print(0)

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

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n  = int(input())
  Ls = list(map(int, input().strip().split())) + [2*10**3+1]
  Ls.sort()
  def bs(l, r, x):
    while r - l > 1:
      mid = (r+l)//2
      if Ls[mid] >= x:
        r = mid
      if Ls[mid] <  x:
        l = mid
    return r
  
  count = 0
  for i in range(n-2):
    for j in range(i+1, n-1):
      r = bs(j, len(Ls), Ls[i]+Ls[j])
      count += (r - 1  - j)
  print(count)
  
if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy
from math import ceil, floor

def main():
  n  = int(input())
  Ls = list(map(int, input().strip().split()))
  Ls = numpy.sort(numpy.array(Ls))
  counts  = numpy.zeros(2*10**3+1, dtype=numpy.int)
  for L in Ls:
    counts[:L+1] += 1
    
  count =0 
  for i in range(n-2):
    for j in range(i+1, n-1):
      if Ls[i] == Ls[j]:
        x = 2
      else:
        x = 1
      count +=  max((counts[Ls[j]]-x) - counts[Ls[i]+Ls[j]], 0)
  print(count,'x')
  
if __name__=='__main__':
  main()
Problem p02901 (python)

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = [MAX] * (2 ** 13)
  dp[0] = 0
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(len(dp)):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1)

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

import numpy

def main():
  n, m = map(int, input().split())
  la, lb = [], []
  lc = []
  MAX = 10**9
  dp = numpy.zeros(2 ** 13).astype(numpy.int32)
  dp[1:] = MAX
  
  for _ in range(m):
    a, b = map(int, input().split())
    la.append(a)
    lb.append(b)
    lc.append(sum([1 << c for c in map(int, input().split())]))
    
  for a, c in zip(la, lc):
    for ic in range(dp.shape[0]):
      dp[c | ic] = min(a + dp[ic], dp[c | ic])
  if dp[2**(n+1)-2] != MAX:
    print(dp[2**(n+1)-2])
  else:
    print(-1)

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

Fixed submission:
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  boxes = [0 for _ in range(len(liA))]
  index = []
  for i in range(len(liA))[::-1]:
    sumBoxes = sum([boxes[j] for j in range(i, len(boxes), i+1)])
    if sumBoxes % 2 != liA[i]:
      boxes[i] += 1
      index += [i+1]
  print(len(index))
  print(' '.join(map(str, index)))
  pass

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[j] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
# /usr/bin/python3

def main():
  N = int(input())
  liA = list(map(int, input().strip().split(' ')))
  liB = []
  for i, a in enumerate(liA[::-1]):
    i = len(liA) - i
    sumA = sum([liA[i] for j in range(i, len(liA), i+1)])
    if sumA % 2 != a:
      liA[i] += 1
      liB += [i]
  print(len(liB))
  print(' '.join(map(str,liB)))
  pass

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

Fixed submission:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  s = input().strip()
  sz, ez = [], []
  i = 0
  while i < n:
    if s[i] == '0':
      sz.append(i)
      while i < n and s[i] == '0': i += 1
      ez.append(i)
    else:
      i += 1
  
  if k >= len(sz):
    print(len(s))
    return 
  max = -1
  for i in range(len(sz)-k+1):
    if i==0:
      score = sz[i+k] - 0
    elif i==len(sz)-k:
      score = n - ez[i-1]
    else:
      score = sz[i+k] - ez[i-1]
    if max < score:
      max = score
  print(max)
      

if __name__=='__main__':
  main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, k = map(int, input().split())
  s = input().strip()
  sz, ez = [], []
  i = 0
  while i < n:
    if s[i] == '0':
      sz.append(i)
      while i < n and s[i] == '0': i += 1
      ez.append(i)
    else:
      i += 1
  
  if k >= len(sz):
    print(len(s))
    return 
  max = -1
  for i in range(k+1):
    if i==0:
      score = sz[i+k] - 0
    elif i==k:
      score = n - ez[i-1]
    else:
      score = sz[i+k] - ez[i-1]
    if max < score:
      max = score
  print(max)
      

if __name__=='__main__':
  main()