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

Fixed submission:
A = input()
B = input()

if A == B[:len(A)]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):

A, B, C, K = map(int, input().split())

backup = K
AB = A + B
flag = False
ans = 0
if K <= A:
    print(K)
    # print("hogeD")
else:
    if A < K:
        K = K - A
        ans = ans + (A * 1)
        # print(1)

    if B <= K:
        K = K - B
        flag = True

    if K > 0 and flag:
        ans = ans + (-1) * (backup - AB)
        # print(3)

    print(ans)
Problem p02713 (python)

Fixed submission:
import math
from functools import reduce

K = int(input())

sum = 0
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            sum += reduce(math.gcd, (i, j, k))

print(sum)

Buggy submission (verdict: Runtime Error):
import numpy as np
import functools
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

# def euclid(a, b):
#     if b == 0:
#         return a
#     else:
#         return euclid(b, a%b)

# def gcd(nums):
#     return functools.reduce(euclid, nums)


K = int(input())

hoge = []
for i in range(1, K + 1):
    for j in range(1, K + 1):
        for k in range(1, K + 1):
            hoge.append(gcd(i, j, k))

print(sum(hoge))
Problem p02801 (python)

Fixed submission:
print(chr(ord(input())+1))

Buggy submission (verdict: Runtime Error):
n,k,m=map(int, input().split())
for i in range(n-1):
  a[i]=int(input()) 
  Sum+=a[i]
if (Sum+k)/n<m:
  print(-1)
  break
else:
  print(n＊m-Sum)
Problem p02885 (python)

Fixed submission:
a,b=map(int, input().split())
if a-2*b>0:
  print(a-2*b)
else: 
  print(0)

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a-2b>0:
  print(a-2b)
else: 
  print(0)

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
if a-2b>0:
  print(a-2b)
else:
   print(0)
Problem p02921 (python)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(len(s)):
  if s[i]==t[i]:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
ans=0
for i in range(len(s)):
  if s[i]=t[i]:
    ans+=1
print(ans)
Problem p02981 (python)

Fixed submission:
n,a,b=map(int, input().split())
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
print(min(n*a,b)
Problem p02639 (python)

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

if(a==0):
    print("1")

elif(b==0):
    print("2")

elif(c==0):
    print("3")

elif(d==0):
    print("4")
    
elif(e==0):
    print("5")

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

if(a==0):
    print("1")

elif(b==0):
    print("1")

elif(c==0):
    print("1")

elif(d==0):
    print("1")
Problem p02641 (python)

Fixed submission:
x, n = list(map(int, input().split(" ")))
if n != 0:

    p = list(map(int, input().split(" ")))

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        b = start + v + 1
        if (a not in p) and (b in p):
            ans = a
            break

        elif (a in p) and (b not in p):
            ans = b
            break
            
        elif (a not in p) and (b not in p):
            if a > b:
                ans = b
                break
            else:
                ans = a
                break
                
else:
    ans = x
    
print(ans)

Buggy submission (verdict: Runtime Error):
x, n = list(map(int, input().split(" ")))
if n != 0:

    p = list(map(int, input().split(" ")))

    p_ = [abs(x - n) for n in p]

    m_p_ = p_.index(min(p_))

    start = p[m_p_]

    for v in range(100):
        a = start - v - 1
        if a not in p:
            ans = a
        b = start + v + 1
        if b not in p:
            if ans > b:
                ans = b
            break
            
else:
    ans = x
    
print(ans)
Problem p02677 (python)

Fixed submission:
import numpy as np
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

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

a, b, h, m = list(map(int, input().split(" ")))

h_a = (h + m/60) * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = np.sqrt(a**2 + b**2 - 2 * a * b * np.cos(angle))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = h * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(angle))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

a, b, h, m = list(map(int, input().split(" ")))

h_a = h * 30
m_a = m * 6
angle = abs(h_a - m_a)
if angle > 180:
    angle = 360 - angle

if angle == 0:
    ans = abs(a-b)
else:
    angle = angle * np.pi / 180
    ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(angle))

print(ans)
Problem p03284 (python)

Fixed submission:
n, k = list(map(int, input().split(" ")))
ans = n % k
if ans > 0:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())

c = n // 4

ans = 0

for i in range(c+1):
    d = (n - i*4) // 7
    for v in range(d+1):
        buy = i*4 + v*7
        check = buy - n
        
        if check == 0:
            ans = "Yes"
        
if ans == "Yes":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())

c = n // 4

ans = 0

for i in range(c+1):
    d = (n - i*4) // 7
    for v in range(d+1):
        buy = i*4 + v*7
        check = buy - n
        
        if check == 0:
            ans = "Yes"
            break
    if ans == "Yes":
        break
        

if ans == "Yes":
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())

c = n // 4

ans = 0

for i in range(c+1):
    d = (n - i*4) // 7
    for v in range(d+1):
        buy = i*4 + v*7
        check = buy - n
        
        if check == 0:
            ans = "Yes"
            break
    if ans == "Yes":
        break
        

if ans == "Yes":
    print("Yes")
else:
    print("No")
Problem p02657 (python)

Fixed submission:
S = input().split()

A = int(S[0])
B = int(S[1])

print(A*B)

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

answer = A[0]
overl = False

for i in range(N-1):
    answer *= A[i+1]
    if answer > 10**18:
        overl = True
        break

if overl:
    print("-1")
else:
    print(answer)
Problem p02675 (python)

Fixed submission:
N = int(input())

if N%10==2 or N%10==4 or N%10==5 or N%10==7 or N%10==9:
    print('hon')
elif N%10==0 or N%10==1 or N%10==6 or N%10==8:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
import math
 
A,B,H,M=map(int,input().split(" "))
 
hour=[A*math.cos(math.radians(H*30+M/2)),A*math.sin(math.radians(H*30+M/2))]
minute =[B*math.cos(math.radians(M*6)),B*math.sin(math.radians(M*6))]
if (hour[0]>=0 and minute[0]>=0) or (hour[0]<0 and minute[0]<0):
    a=minute[0]-hour[0]
else:
    a=abs(minute[0])+abs(hour[0])
    
if (hour[1]>=0 and minute[1]>=0) or (hour[1]<0 and minute[1]<0):
    b=minute[1]-hour[1]
else:
    b=abs(minute[1])+abs(hour[1])    
print('{:.16f}'.format(math.sqrt(pow(a,2)+pow(b,2))))

Buggy submission (verdict: Runtime Error):
N = int(input())

if N%10==2 orN%10==4 or N%10==5 or N%10==7 or N%10==9:
    print('hon')
elif N%10==0 orN%10==1 or N%10==6 or N%10==8:
    print('pon')
else:
    print('bon')
Problem p02702 (python)

Fixed submission:
import collections
import math

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

def naive(s):
	cnt = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			k = int(s[i:j])
			if k % 2019 == 0 and k != 0:
				#print(i, j)
				cnt += 1
	return cnt

def main(s):
	nums = [0]
	cur = 0
	p = 0.1
	for i in range(len(s)):
		p = int(p * 10) % 2019
		cur = (cur + int(s[len(s) - 1 - i]) * p) % 2019
		nums.append(cur)
	d = dict(collections.Counter(nums))
	a = [val for key, val in d.items() if val >= 2]
	return sum([comb(x, 2) for x in a])	

s = input()
print(main(s))

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

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

def naive(s):
	cnt = 0
	for i in range(len(s)):
		for j in range(i + 1, len(s) + 1):
			k = int(s[i:j])
			if k % 2019 == 0 and k != 0:
				#print(i, j)
				cnt += 1
	return cnt

def main(s):
	nums = [0]
	cur = 0
	p = 0.1
	for i in range(len(s)):
		p = int(p * 10) % 2019
		cur = (cur + int(s[len(s) - 1 - i]) * p) % 2019
		nums.append(cur)
	d = dict(collections.Counter(nums))
	a = [val for key, val in d.items() if val >= 2]
	return sum([comb(x, 2) for x in a])	

s = input()
print(main(s))
Problem p02741 (python)

Fixed submission:
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input()) - 1])

Buggy submission (verdict: Runtime Error):
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())])
Problem p02761 (python)

Fixed submission:
import sys
n, m = list(map(int, input().split()))
res = [list(map(int, input().split())) for _ in range(m)]

ans = [-1 for _ in range(n)]



if n == 1:
	tmp = 0
	for i in range(m):
		tmp += res[i][1]
	if tmp == 0:
		print(0)
		sys.exit()

for r in res:
	if ans[r[0] - 1] >= 0:
		if ans[r[0] - 1] != r[1]:
			print(-1)
			sys.exit()
	ans[r[0] - 1] = r[1]

#print(res)
#print(ans)
flag = 0
for i in range(n):
	if ans[i] == -1:
		if flag:
			ans[i] = 0
		else:
			ans[i] = 1
	if i == 0 and ans[i] == 0:
		print(-1)
		sys.exit()
	else:
		flag = 1


print("".join([str(a) for a in ans]))

Buggy submission (verdict: Runtime Error):
import sys
n, m = list(map(int, input().split()))
res = [list(map(int, input().split())) for _ in range(m)]

ans = [-1 for _ in range(n)]

for r in res:
	if ans[r[0] - 1] >= 0:
		if ans[r[0] - 1] != r[1]:
			print(-1)
			sys.exit()
	ans[r[0] - 1] = r[1]

flag = 0
for i in range(3):
	if ans[i] == -1:
		if flag:
			ans[i] = 0
		else:
			ans[i] = 1
	else:
		flag = 1


print("".join([str(a) for a in ans]))
Problem p02845 (python)

Fixed submission:
mod = 10 ** 9 + 7
n = int(input())
nums = list(map(int, input().split()))

n_colors = [0, 0, 0]

cnt = 1
for x in nums:
	cnt = (cnt * len([y for y in n_colors if x == y])) % mod
	if cnt == 0:
		break
	n_colors[n_colors.index(x)] += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
n = int(input())
nums = list(map(int, input().split()))

n_colors = [0, 0, 0]

cnt = 1
for x in nums:
	cnt = (cnt * len([y for y in n_colors if x == y])) % mod
	n_colors[n_colors.index(x)] += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
mod = 10 ** 9 + 7

n = int(input())
nums = list(map(int, input().split()))

# import numpy.random as rd
# n = 1000
# raw_nums = list(rd.randint(low=0, high=3, size=n))
# print(raw_nums)
# nums = [0] + [len([x for x in raw_nums[:i] if x == raw_nums[i]]) for i in range(1, n)]

# print(n, raw_nums, nums)

n_colors = [0, 0, 0]

cnt = 1
for x in nums:
	cnt = (cnt * collections.Counter(n_colors)[x]) % mod
	n_colors[n_colors.index(x)] += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
mod = 1000000007

n = int(input())
nums = list(map(int, input().split()))

n_colors = [0, 0, 0]

cnt = 1
for x in nums:
	cnt = (cnt * collections.Counter(n_colors)[x]) % mod
	n_colors[n_colors.index(x)] += 1

print(cnt)
Problem p02949 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000000)

def dfs(i):
	if i in use:
		return 
	use.add(i)
	for e in edges_r[i]:
		dfs(e)

def bf():
	d = [float('inf') for _ in range(n + 1)]
	d[1] = 0
	for _ in range(n):
		f = False
		for e in edges_f:
			if d[e[1]] > d[e[0]] + e[2]:
				d[e[1]] = d[e[0]] + e[2]
				f = True	
		if not f:
			return max(0, -1 * d[n])
	return -1

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

edges_f = []
edges_r = [[] for i in range(n + 1)]
for _ in range(m):
	a, b, c = list(map(int, input().split()))
	edges_f.append([a, b, -1 * (c - p)])
	edges_r[b].append(a)

use = set()
dfs(n)

edges_f = [e for e in edges_f if e[0] in use and e[1] in use]
print(bf())

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000000000)

def dfs(i):
	if i in use:
		return 
	use.add(i)
	for e in edges_r[i]:
		dfs(e)

def bf():
	d = [float('inf') for _ in range(n + 1)]
	d[1] = 0
	for _ in range(n):
		f = False
		for e in edges_f:
			if d[e[1]] > d[e[0]] + e[2]:
				d[e[1]] = d[e[0]] + e[2]
				f = True	
		if not f:
			return max(0, -1 * d[n])
	return -1

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

edges_f = []
edges_r = [[] for i in range(n + 1)]
for _ in range(m):
	a, b, c = list(map(int, input().split()))
	edges_f.append([a, b, -1 * (c - p)])
	edges_r[b].append(a)

use = set()
dfs(n)

edges_f = [e for e in edges_f if e[0] in use and e[1] in use]
print(bf())

Buggy submission (verdict: Runtime Error):
def dfs(i):
	if i in use:
		return 
	use.add(i)
	for e in edges_r[i]:
		dfs(e)

def bf():
	d = [float('inf') for _ in range(n + 1)]
	d[1] = 0
	for _ in range(n):
		f = False
		for e in edges_f:
			if d[e[1]] > d[e[0]] + e[2]:
				d[e[1]] = d[e[0]] + e[2]
				f = True
		if not f:
			return max(0, -1 * d[n])
	return -1

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

edges_f = []
edges_r = [[] for i in range(n + 1)]
for _ in range(m):
	a, b, c = list(map(int, input().split()))
	edges_f.append([a, b, -1 * (c - p)])
	edges_r[b].append(a)

use = set()
dfs(n)

edges_f = [e for e in edges_f if e[0] in use and e[1] in use]
print(bf())
Problem p02981 (python)

Fixed submission:
n,a,b=list(map(int,input().split()))
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print min(n*a,b)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
from decimal import *

a, b, c, d = list(map(Decimal, input().split()))
e = c * d / gcd(c, d)
print(int(b - a + 1 - ((b // c + b // d - b // e) - ((a - 1) // c + (a - 1) // d - (a - 1) // e))))

Buggy submission (verdict: Runtime Error):
n, l = list(map(int, input().split()))
ts = [l + i - 1 for i in range(1, n + 1)]
print(sum(ts) + min([abs(x) for x in ts]))
Problem p03006 (python)

Fixed submission:
from collections import defaultdict

n = int(input())
if n == 1:
	print(1)
else:
	balls = [list(map(int, input().split())) for _ in range(n)]

	d = defaultdict(lambda: 0)
	for x in range(n):
		for y in range(n):
			d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

	del d[(0, 0)]
	print(n - max(d.values()))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

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

d = defaultdict(lambda: 0)
for x in range(n):
	for y in range(n):
		d[(balls[x][0] - balls[y][0], balls[x][1] - balls[y][1])] += 1

del d[(0, 0)]
print(n - max(d.values()))
Problem p03008 (python)

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

rates_list = [[],[]]
for i in range(3):
	if aa[i] > bb[i]:
		rates_list[1].append([bb[i], aa[i]])
	else:
		rates_list[0].append([aa[i], bb[i]])

max_d = n
for j in range(2):
	rates = rates_list[j]
	if len(rates) == 1:
		max_d = (max_d // rates[0][0]) * rates[0][1] + max_d % rates[0][0]
	elif len(rates) == 2:
		val = [rates[0][1] * i for i in range(max_d // rates[0][0] + 1)]
		rest = [max_d - rates[0][0] * i for i in range(max_d // rates[0][0] + 1)]
		val = [val[i] + rates[1][1] * (rest[i] // rates[1][0]) + (rest[i] % rates[1][0]) if rest[i] > 0 else val[i] for i in range(len(val))]
		max_d = max(val)
	elif len(rates) == 3:
		dp = [(d // rates[0][0]) * rates[0][1] + d % rates[0][0] for d in range(max_d + 1)]
		for d in range(1, max_d + 1):
			dp[d] = max([dp[d]] + [dp[d - rates[i][0]] + rates[i][1] if d - rates[i][0] >= 0 else d for i in range(1, len(rates))])
		max_d = dp[-1]
print (max_d)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates_1 = []
rates_2 = []
for i in range(3):
	if aa[i] > bb[i]:
		rates_2.append([bb[i], aa[i]])
	else:
		rates_1.append([aa[i], bb[i]])

def dp(rest, obtained, memo, rates):
	#print(rest, obtained)
	if rest < 0:
		return -10000

	if memo[rest] != -1:
		return memo[rest]

	memo[rest] = max([dp(rest - x[0],  obtained + x[1], memo, rates) for x in rates_1] + [rest + obtained])
	return memo[rest]


if len(rates_1) > 0:
	memo_1 = [-1 for _ in range(n + 1)]
	m = dp(n, 0, memo_1, rates_1)
else:
	m = n

if len(rates_2) > 0:
	memo_2 = [-1 for _ in range(n + 1)]
	ans = dp(m, 0, memo_2, rates_2)
else:
	ans = m

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))

rates = []
for i in range(3):
	if aa[i] > bb[i]:
		rates.append([bb[i], aa[i]])
	else:
		rates.append([aa[i], bb[i]])

memo = [-1 for _ in range(n + 1)]

#print(rates)

def dp(rest, obtained):
	#print(rest, obtained)
	if rest < 0:
		return -10000

	if memo[rest] != -1:
		return memo[rest]

	ans = max([dp(rest - rates[i][0],  obtained + rates[i][1]) for i in range(3)] + [rest + obtained])
	memo[rest] = ans
	return ans

print(dp(n, 0))
#print(memo)
Problem p03014 (python)

Fixed submission:
import numpy as np

h, w = list(map(int, input().split()))
d = {".":1, "#":0}
ss = np.array([list(input()) for _ in range(h)]) == "."
ss_t = ss.transpose()

ls, rs, us, ds = [np.zeros((h, w), dtype=int) for _ in range(4)]

ls, rs = ls.transpose(), rs.transpose()

ls[0] = ss_t[0]
rs[w-1] = ss_t[w-1]
us[0] = ss[0]
ds[h-1] = ss[h-1]

for i in range(1, w):
	ls[i] = ss_t[i] * (ls[i - 1] + 1)

for i in reversed(range(w - 1)):
	rs[i] = ss_t[i] * (rs[i + 1] + 1)

for i in range(1, h):
	us[i] = ss[i] * (us[i - 1] + 1)

for i in reversed(range(h - 1)):
	ds[i] = ss[i] * (ds[i + 1] + 1)

# print(ss)
# print(ls)
# print(rs)
# print(us)
# print(ds)
print(max(np.amax((ls.transpose() + rs.transpose() + us + ds) - 3), 0))

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

h, w = list(map(int, input().split()))
d = {".":0, "#":1}
ss = np.array([list(input()) for _ in range(h)])
ss = np.array([[d[x] for x in s] for s in ss])

ans = 0
ws = np.zeros((h, w))
hs = np.zeros((h, w))

i = 0
while i < h:
	j = 0
	while j < w:
		if ss[i, j] == 0:
			end = w
			for k in range(j + 1, w):
				if ss[i, k] == 1:
					end = k
					break
			ws[i, j:end] = end - j
			j = end + 1
		else:
			j += 1
	i += 1

j = 0
while j < w:
	i = 0
	while i < h:
		if ss[i, j] == 0:
			end = h
			for k in range(i + 1, h):
				if ss[k, j] == 1:
					end = k
					break
			hs[i:end, j] = end - i
			i = end + 1
		else:
			i += 1
	j += 1

# print(ss)
# print(ws)
# print(hs)
print(max(int(np.amax(ws + hs) - 1), 0))
Problem p03103 (python)

Fixed submission:
import numpy as np
import bisect

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

drinks.sort(key = lambda x: x[0])
prices = np.array([x[0] for x in drinks])
vols = np.array([x[1] for x in drinks])
cum_vols = np.cumsum(vols)
idx = bisect.bisect_left(cum_vols, m) #このidxは1 ~ vols[idx]を使う

#print(idx)
l = 0 if idx == 0 else sum(vols[:idx])

vols[idx] = m - l
print(np.dot(vols[:(idx+1)], prices[:(idx+1)]))

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

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

drinks.sort(key = lambda x: x[0])
prices = np.array([x[0] for x in drinks])
vols = np.array([x[1] for x in drinks])
cum_vols = np.cumsum(vols)
idx = bisect.bisect_right(cum_vols, m) #このidxは1 ~ vols[idx]を使う

vols[idx] = m - sum(vols[:idx])
print(np.dot(vols[:(idx+1)], prices[:(idx+1)]))
Problem p03281 (python)

Fixed submission:
def main():
	n = int(input())

	if n <= 104:
		print(0)
	elif n <= 134:
		print(1)
	elif n <= 164:
		print(2)
	elif n <= 188:
		print(3)
	elif n <= 194:
		print(4)
	else:
		print(5)


if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
def main():
	n = int(input())

	if n <= 104:
		print(0):
	elif n <= 134:
		print(1)
	elif n <= 188:
		print(2)
	else:
		print(3)


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

Fixed submission:
import fractions

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = fractions.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import math

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = math.gcd(d, b)
		i = - 10
		while True:
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				
	print("Yes")
	return
	
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
# encoding:utf-8
import math

def main():
	t = int(input())
	qs = [list(map(int, input().split())) for _ in range(t)]
	for q in qs:
		sub(q)

def sub(q):
	a, b, c, d = q
	if d - b < 0:
		print("No")
		return
	
	if a - b < 0:
		print("No")
		return

	if b > c:
		gcd_bd = math.gcd(d, b)
		i = - 10
		while True:
			#print(i)
			#print(gcd_bd, gcd_bd * i + (a - c))
			if 0 < gcd_bd * i + (a - c) % gcd_bd < b - c:
				print("No")
				return
			elif gcd_bd * i + (a - c) % gcd_bd >= b - c:
				print("Yes")
				return
			i += 1
				

	print("Yes")
	return
	
if __name__ == '__main__':
	main()
Problem p03614 (python)

Fixed submission:
# encoding:utf-8
def main():
	n = int(input())
	nums = list(map(int, input().split()))

	counter = 0
	for i in range(n - 1):
		if nums[i] == i + 1:
			nums[i], nums[i + 1] = nums[i + 1], nums[i]
			counter += 1

	if nums[n - 1] == n:
		counter += 1

	print(counter)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
# encoding:utf-8
def main():
	n = int(input())
	nums = list(map(int, input().split()))

	counter = 0
	for i in range(n):
		if nums[i] == i + 1:
			nums[i], nums[i + 1] = nums[i + 1], nums[i]
			counter += 1

	print(counter)

if __name__ == '__main__':
	main()