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

Fixed submission:
from math import *

def isprime(n):
	if n<10:
		return n in (2,3,5,7)
	for i in range(2,int(sqrt(n)+1)):
		if n%i==0:
			return False
	return True
 
x = int(input())
for d in range(x,x+300):
	if isprime(d):
		print(d)
		break

Buggy submission (verdict: Runtime Error):
def isprime(n):
  if n<10:
    return n in (2,3,5,7)
  for i in range(int(2,sqrt(n)+1)):
    if n%i==0:
      return False
  return True

x = int(input())
for d in range(x,x+300):
  if isprime(d):
    print(d)
    break
Problem p02833 (python)

Fixed submission:
def f(n):
  ans = 0
  while n>0:
    n//=5
    ans+=n
  return ans

x = int(input())
print(0 if x%2 else f(x//2))

Buggy submission (verdict: Runtime Error):
    def f(n):
      d = 2
      ans = 0
      while n>d:
        d*=5
        n//=d
        ans+=n
      return ans
     
    print(f(int(input())))

Buggy submission (verdict: Runtime Error):
def f(n):
  d = 2
  ans = 0
  while n>d:
    d*=5
    n//=d
    ans+=n
  return ans

print(f(int(input()))
Problem p02836 (python)

Fixed submission:
s=input()
ans = 0
for i in range(len(s)//2):
 if s[i] != s[len(s)-1-i]:
  ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
ans = 0
for i in range(len(s)//2+1):
	if s[i] != s[len(s)-1-i]:
    	ans+=1
        
print(ans)
Problem p02570 (python)

Fixed submission:
s = input().split()
d = int(s[0])
t = int(s[1])
s = int(s[2])
if d <= t * s:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = map(int, input().split())
d = s[0]
t = s[1]
s = s[2]
if d >= t * s:
  print("Yes")
else:
  print("No")
Problem p02766 (python)

Fixed submission:
import math

N, K = [int(i) for i in input().split()]
print(int(math.floor(math.log(float(N)/math.pow(K,2), K))) + 1 + 2)

Buggy submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
print(int(math.floor(math.log(float(N)/math.pow(K,2), K))) + 1 + 2)
Problem p02879 (python)

Fixed submission:
x, y = map(int, input().split())

if x < 10 and y < 10:
	print(x * y)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
x = input()
x = int(x)
y = input()
y = int(y)

if x < 10 and y < 10:
	print(x * y)
else:
	print(-1)
Problem p02873 (python)

Fixed submission:
S = input()
INC = '<'
DEC = '>'
icnt = 0
dcnt = 0
mode = DEC
ans = 0
for c in S:
  if mode == DEC:
    if c == DEC:
      dcnt += 1
    elif c == INC:
      if icnt <= dcnt:
        ans += (dcnt + 1) * dcnt // 2
      else:
        ans += icnt + dcnt * (dcnt - 1) // 2
      icnt = 1
      mode = INC
  elif mode == INC:
    if c == INC:
      icnt += 1
    elif c == DEC:
      ans += icnt * (icnt - 1) // 2
      dcnt = 1
      mode = DEC
if mode == INC:
  ans += (icnt + 1) * icnt // 2
elif mode == DEC:
  if icnt <= dcnt:
    ans += (dcnt + 1) * dcnt // 2
  else:
    ans += icnt + dcnt * (dcnt - 1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
m = 1
num = 1
for c in S:
  if c == '<':
    num += 1
  elif c == '>':
    num -= 1
  m = min(num, m)
if m <= 0:
  num += 1 - m
else:
  num = 1
ans += num
for c in S:
  if c == '<':
    num += 1
  elif c == '>':
    num -= 1
  ans += num
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
A, B = [n for n in input().split()]
A = int(A)
B = Decimal(B)

ans = A * B
print(int(ans))

Buggy submission (verdict: Runtime Error):
A, B = [int(n) for n in input().split()]

ans = int(A * B)
print(ans)
Problem p02595 (python)

Fixed submission:
import numpy as np

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

count = 0
for i in range(n):
  x, y = map(int, input().split())
  res = np.sqrt(x**2 + y**2)
  if res <= dis:
    count += 1
  
print("{}".format(count))

Buggy submission (verdict: Runtime Error):
import math

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

count = 0
for i in range(n):
  x, y = map(int, input().split())
  if math.sqrt(x^2 + y^2) <= dis:
    count += 1
  
print("{}".format(count))
Problem p02831 (python)

Fixed submission:
import fractions

if __name__ == '__main__':

	a,b = map(int,input().split())

	print((a * b) // fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math

if __name__ == '__main__':

	a,b = map(int,input().split())

	print((a * b) // math.gcd(a,b))
Problem p02879 (python)

Fixed submission:

if __name__ == '__main__':

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

	if (1 <= A[0] <= 9) and (1 <= A[1] <= 9):
		print(A[0] * A[1])
	else:
		print(-1)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)
	end = n - 1

    for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)
Problem p02881 (python)

Fixed submission:
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':

	n = int(input())
	m = int(n//2)

   	end = n - 1
	for x in range(2,int(n**0.5)+1):
		if n % x == 0:
			y = n // x
			end = min(x+y-2,end)

	print(end)
Problem p02891 (python)

Fixed submission:

if __name__ == '__main__':

	S = input()
	K = int(input())

	leng = len(S)
	ans = 0

	#１文字である場合
	if K == 1:
		ans = 0
	#全部同じ文字である場合
	elif S.count(S[0]) == leng:
		ans = int(leng*K/2)
	else:
		#隣り合った文字はＮ文字で置き換える文字はＭ文字か計算する
		start = ""
		cnt = 0
		rep = 0
		for x,y in enumerate(S):
			if x == 0:
				start = y
			else:
				if start == y:
					cnt += 1
				else:
					#同じ文字あり
					if cnt > 0:
						cnt += 1	#最初を追加
						rep += int(cnt/2)
						cnt = 0	#初期化

					start = y
		#後処理
		if cnt > 0:
			cnt += 1	#最初を追加
			rep += int(cnt/2)

		#先頭と末尾が同じ文字である場合
		if S[0] == S[leng-1]:

			#先頭文字での置き換え文字数
			cnt1 = 1
			smoji = S[0]
			for x in range(1,leng):
				if S[0] == S[x]:
					cnt1 += 1
					smoji += S[0]
				else:
					break
			moto1 = int(cnt1/2)


			#末尾文字での置き換え文字数
			cnt2 = 1
			#文字列反転
			S = S[::-1]
			smoji += S[0]
			for x in range(1,leng):
				if S[0] == S[x]:
					cnt2 += 1
					smoji += S[0]
				else:
					break
			moto2 = int(cnt2/2)

			#先頭と末尾を合わせたものを置き換えた文字数
			slen = len(smoji)
			moto3 = int(slen/2)

			kekka = (moto1 + moto2) - moto3
			kekka = kekka * (K -1)

			ans = rep * K - kekka
		else:
			ans = rep * K

	print(ans)

Buggy submission (verdict: Runtime Error):

if __name__ == '__main__':

	S = input()
	K = int(input())

	leng = len(S)
	cnt = 0

	i = 0
	while i < leng - 1:
		if S[i] == S[i+1]:
			cnt += 1
			i += 2
		else:
			i += 1

	ans = K*cnt

	j = 0
	if (S[j] == S[leng-1]) and (S[j] != S[j+1]) and (S[leng-1] != S[leng-2]):
		ans += 1

	if S.count(S[0]) == leng and leng % 2 == 1:
		ans += 1

	print(ans)
Problem p02793 (python)

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

def Lcm(a,b):
    return (a*b)//gcd(a,b)

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=l[0]
    for i in range(n):
        lcm=Lcm(lcm,l[i])
    ans=0
    mod=1000000007
    for i in range(n):
        ans+=lcm//l[i]
    print(ans%mod)

if __name__ == "__main__":
    dp()

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

def dp():
    n=int(input())
    l=list(map(int,input().split()))
    lcm=1
    for i in l:
        lcm=(lcm*i)//gcd(lcm,i)
    ans=0
    mod=1000000007
    for i in l:
        ans=(ans+(lcm//i))%mod
    print(ans)

if __name__ == "__main__":
    dp()
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

TO_K = []
TREE = []

def dfs(parent, distance):
    for i_node in TREE[parent]:
        child, dd = i_node
        if TO_K[child] != -1:
            continue

        next_dt = distance + dd
        TO_K[child] = next_dt
        dfs(child, next_dt)

    return


def main():
    n = int(input())
    abc = [[int(_) for _ in input().split()] for i in range(n-1)]
    q, k = map(int, input().split())
    xy = [[int(_) for _ in input().split()] for i in range(q)]

    global TO_K
    # index '0' is not used.
    TO_K = [-1]*(n+1)

    global TREE
    # index '0' is not used.
    TREE = [[] for _ in range(n+1)]
    for a, b, c in abc:
        TREE[a].append([b, c])
        TREE[b].append([a, c])

    TO_K[k] = 0
    dfs(k, 0)

    for x, y in xy:
        print(TO_K[x]+TO_K[y])
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys

TO_K = []
TREE = []
DISTANCE = []

def dfs(child, parent):
    for i_node in TREE[parent]:
        if i_node[0] == child:
            TO_K[child] = TO_K[parent] + i_node[1]

    for i_gch in TREE[child]:
        if i_gch[0] == parent:
            TO_K[child] = TO_K[parent] + i_gch[1]
        else:
            dfs(i_gch[0], child)

    return


def main():
    n = int(input())
    abc = [[int(_) for _ in input().split()] for i in range(n-1)]
    q, k = map(int, input().split())
    xy = [[int(_) for _ in input().split()] for i in range(q)]

    global TO_K
    # index '0' is not used.
    TO_K = [0]*(n+1)

    global TREE
    # index '0' is not used.
    TREE = [[] for _ in range(n+1)]
    for a, b, c in abc:
        TREE[a].append([b, c])
        TREE[b].append([a, c])

    dfs(k, 0)

    for x, y in xy:
        print(TO_K[x]+TO_K[y])
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Buggy submission (verdict: Runtime Error):
import sys

TO_K = []
TREE = []
DISTANCE = []

def dfs(child, parent):
    small, big = min(child, parent), max(child, parent)
    for i_distance in DISTANCE[small]:
        if i_distance[0] == big:
            TO_K[child] = TO_K[parent] + i_distance[1]

    for i_gch in TREE[child]:
        if i_gch == parent:
            continue
        dfs(i_gch, child)

    return


def main():
    n = int(input())
    abc = [[int(_) for _ in input().split()] for i in range(n-1)]
    q, k = map(int, input().split())
    xy = [[int(_) for _ in input().split()] for i in range(q)]

    global TO_K
    # index '0' is not used.
    TO_K = [0]*(n+1)

    global TREE
    global DISTANCE
    # index '0' is not used.
    TREE = [[] for _ in range(n+1)]
    DISTANCE = [[] for _ in range(n+1)]
    for a, b, c in abc:
        TREE[a].append(b)
        TREE[b].append(a)
        small, big = min(a,b), max(a, b)
        DISTANCE[small].append([big, c])

    dfs(k, 0)

    for x, y in xy:
        print(TO_K[x]+TO_K[y])
    return


if __name__ == "__main__":
    main()
    sys.exit(0)
Problem p03286 (python)

Fixed submission:
n = int(input())

dp =[0]*40

if n ==0:
    print(0)

elif n >0:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

else:
    x = bin(-n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==0 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))

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

dp =[0]*40

if n ==0:
    print(0)

elif n >0:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))    

else:
    x = bin(n)
    bx = x[2:]
    lx = len(bx)
    for i in range(lx-1,-1,-1):
        dp[i] = int(bx[lx-1-i])
    for i in range(40):
        if i % 2 ==1 and dp[i]==1:
            dp[i+1] +=1
    while max(dp) >1:
        for i in range(40):
            if dp[i] >=2:
                dp[i] -=2
                if dp[i+1] >0:
                    dp[i+1] -=1
                else:
                    dp[i+1] +=1
                    dp[i+2] +=1
    dpr = list(reversed(dp))
    dprs = list(map(lambda x :str(x),dpr))
    dprj = "".join(dprs)
    print(int(dprj))
Problem p03426 (python)

Fixed submission:
h,w,d = map(int, input().split())

dp= [0]*(h*w+1)

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

for i in range(h):
    for j in range(w):
        s = ab[i][j]
        dp[s] =[i,j]
        
dpp= [0]*(h*w+1)

for k in range(d+1,h*w+1):
#    print(k)
    dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])
    
q = int(input())

for x in range(q):
    a,b = map(int, input().split())
    print(dpp[b]-dpp[a])

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

dp= [0]*(h*w+1)

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

for i in range(w):
    for j in range(h):
        s = ab[i][j]
        dp[s] =[i,j]
        
dpp= [0]*(h*w+1)

for k in range(d+1,h*w+1):
#    print(k)
    dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])
    
q = int(input())

for x in range(q):
    a,b = map(int, input().split())
    print(dpp[b]-dpp[a])
Problem p03804 (python)

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

nl = [list(input()) for _ in range(n)]

ml = [list(input()) for _ in range(m)]



for i in range (0,1+n-m):
    for j in range (0,1+n-m):
        if nl[i][j] ==ml[0][0]:
            flag = 1
            for k in range(0,m):
                for l in range(0,m):
                    if nl[i+k][j+l] !=ml[k][l]:
                        flag = 0
            if flag ==1:
                print("Yes")
                exit() 
print("No")

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

nl = [list(input()) for _ in range(n)]

ml = [list(input()) for _ in range(m)]



for i in range (0,n-(n-m)):
    for j in range (0,n-(n-m)):
        if nl[i][j] ==ml[0][0]:
            flag = 1
            for k in range(0,m):
                for l in range(0,m):
                    if nl[i+k][j+l] !=ml[k][l]:
                        flag = 0
            if flag ==1:
                print("Yes")
                exit()
            
print("No")
Problem p02729 (python)

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

print(int(N * (N - 1) / 2 + M * (M - 1) / 2))

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

print(int(N * (N - 1) / 2 + M * (M - 1) / 2))
Problem p02759 (python)

Fixed submission:
N = int(input())

if N%2 == 0:
  print(int(N/2))
else:
  print(int(N/2 + 1))

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

if N%2 == 0
  print(N/2)
else:
  print(N/2 + 1)
Problem p02829 (python)

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

nums = [1, 2, 3]

nums.remove(A)
nums.remove(B)

print(nums[0])

Buggy submission (verdict: Runtime Error):
S = []
S.append(int(input())
S.append(int(input())

nums = [1, 2, 3]

nums = nums - S

print(nums[0])
Problem p02835 (python)

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

total = sum(A)

if total > 21:
  print("bust")
else:
  print("win")

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

total = sum(A)

if total > 22:
  print("bust")
else:
  print("win)

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

total = sum(A)

if A > 22:
  print("bust")
else:
  print("win)
Problem p02847 (python)

Fixed submission:
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for i in range(len(days)):
  if S == days[i]:
    break

print(7 - i)

Buggy submission (verdict: Runtime Error):
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for d in len(days):
  if S == days[d]:
    break

print(6 - d)

Buggy submission (verdict: Runtime Error):
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for d in len(days):
  if S == days[d]:
    break

print(6 - d)

Buggy submission (verdict: Runtime Error):
S = input()

days = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

for d in len(days):
  if S == d:
    break

print(6 - d)
Problem p02859 (python)

Fixed submission:
r = int(input())

print(int(r ** 2))

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

print(int(R ** 2))

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

print(int(R ** 2))

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

print(R ** 2)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = int(input())
s = input()

if a >= 3200:
  print(S)
else:
  print("red")
Problem p03315 (python)

Fixed submission:
S = input()
n = 0

for s in S:
  if s == "+":
    n += 1
  else:
    n -= 1

print(n)

Buggy submission (verdict: Runtime Error):
S = input()
n = 0

for s in S:
  if s == "+"
    n += 1
  else:
    n -= 1

print(n)

Buggy submission (verdict: Runtime Error):
S = input()
n = 0

for s in S:
  if S == "+"
    n += 1
  else:
    n -= 1

print(n)
Problem p02729 (python)

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

ans = N*(N-1)/2 + M*(M-1)/2

print(int(ans))

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

ans = N*(N-1)/2 + M(M-1)/2

print(ans)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
(A, B), = [list(map(int, s.split())) for s in open(0)]
print(int(A * B / gcd(A, B)))

Buggy submission (verdict: Runtime Error):
from math import gcd
(A, B), = [list(map(int, s.split())) for s in open(0)]
print(int(A * B / gcd(A, B)))
Problem p02835 (python)

Fixed submission:
a, b, c = (int(i) for i in input().split())
if a + b + c <= 21:
  print("win")
else:
  print("bust")

Buggy submission (verdict: Runtime Error):
ef main():
    a1, a2, a3 = map(int, input().split())
    if (a1+a2+a3) <= 21:
        print("win")
    else:
        print("bust")

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

Fixed submission:
S = input()
T = input()

ans = 1000000  # 適当に1001以上を初期値にしておきます

# Tが1文字のときlen(S)回、2文字のときlen(S) - 1回 …… なので、
# len(S) - len(T) + 1 回です
for i in range(len(S) - len(T) + 1):
    score = 0
    U = S[i:i + len(T)]  # Sのi文字目から連続するlen(T)文字を、Uとします
    for j in range(len(T)):
        if U[j] != T[j]:
            score += 1
    ans = min(ans, score)

print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
S=[]
c=0
for i in range(len(s)):
    if s[i] in t:
        c+=1
        p=len(t)-1
        q=t.index(s[i])
      
        if q>i or i-q+p+1>len(s):
            pass
        else:
            s1=s[i-q:i+p-q+1]
           
            count=0
            for j in range(len(s1)):
                
                if s1[j]!=t[j]:
                    count+=1
                else:
                    pass
            S.append(count)
    else:
        pass
if c==0:
    print(len(t))
else:
    print(min(S))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
S=[]
c=0
for i in range(len(s)):
    if s[i] in t:
        c+=1
        p=len(t)-1
        q=t.index(s[i])
        if q>i or i-q+p+1>len(s):
            pass
        else:
            s1=s[i-q:i+p-q+1]
            
            count=0
            for j in range(len(s1)):
                if s1[j]!=t[j]:
                    count+=1
                else:
                    pass
            S.append(count)
    else:
        pass
if c==0:
    print(len(t))
else:
    print(min(S))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
S=[]
for i in range(len(s)):
    if s[i] in t:
        p=len(t)-1
        q=t.index(s[i])
        if q>i or i-q+p+1>len(s):
            pass
        else:
            s1=s[i-q:i+p-q+1]
            count=0
            for j in range(len(s1)):
                if s1[j]!=t[j]:
                    count+=1
                else:
                    pass
            S.append(count)
    else:
        pass
print(min(S))

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
S=[]
for i in range(len(s)):
    if s[i] in t:
        p=len(t)-1
        q=t.index(s[i])
        if q>i or i-q+p+1>len(s)-1:
            pass
        else:
            s1=s[i-q:i+p-q+1]
            count=0
            for j in range(len(s1)):
                if s1[j]!=t[j]:
                    count+=1
                else:
                    pass
            S.append(count)
    else:
        pass
print(min(S))
Problem p02862 (python)

Fixed submission:
def prepare(n, MOD):
 
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
     
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return fn, invs
  
mod = int(1e9+7)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    print(0)
else:
    total_steps = (X+Y)//3
    dif_steps = abs(X-Y)
    if dif_steps > total_steps:
        print(0)
    else:
        up_steps = (total_steps - dif_steps)//2
        fn, invs = prepare(total_steps, mod)
        print((fn*invs[up_steps]*invs[total_steps-up_steps])%mod)

Buggy submission (verdict: Runtime Error):
def prepare(n, MOD):
 
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f
     
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return fn, invs
  
  mod = int(1e9+7)
X, Y = map(int, input().split())
if (X+Y)%3 != 0:
    print(0)
else:
    total_steps = (X+Y)//3
    dif_steps = abs(X-Y)
    if dif_steps > total_steps:
        print(0)
    else:
        up_steps = (total_steps - dif_steps)//2
        fn, invs = prepare(total_steps, mod)
        print((fn*invs[up_steps]*invs[total_steps-up_steps])%mod)
Problem p03038 (python)

Fixed submission:
#import sys
#input = sys.stdin.readline
import numpy as np
N, M = map(int, input().split())
C = list(map(int, input().split()))
B = [1 for _ in range(N)]

for i in range(M):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
C = np.array(C)
D = np.argsort(-C)
#print(B, C, D)
S = 0
n = 0
for i in D:
    #print(B[i], N-n, min(B[i], N-n))
    S += C[i] * (min(B[i], N-n))
    n += min(B[i], N-n)
    #print(S, n)
    if n == N:
        break
print(S)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(M):
    B, C = map(int, input().split())
    if C > a[N]:
        a += [C for _ in range(B)]
        a.sort(reverse=True)
        a = a[:N]
print(sum(a))
Problem p03075 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e-a <= k:
  print("Yay!")
  else:
    print(":(")