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

Fixed submission:
from collections import deque

N, M = map(int, input().split())
g = [[int(i) for i in input().split()] for j in range(M)]

G = [[] for i in range(N)]
for i in range(M):
    a, b = g[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

marks = [-1 for i in range(N)]
node = deque([[0, 0]])
while len(node) > 0:
    v = node.popleft()
    if marks[v[0]] == -1:
        marks[v[0]] = v[1]
        for i in G[v[0]]:
            if marks[i] == -1:
                node.append([i, v[0]])

if -1 not in marks:
    print("Yes")
    for i in range(1, N):
        print(marks[i]+1)
else:
    print("No")

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

G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

def dfs(v, u, depth):

    depth_min[v] = depth
    memo[v] = u

    for next_v in G[v]:
        if next_v == 0:
            continue
        if depth_min[next_v] > depth+1:
            dfs(next_v, v, depth+1)

depth_min = [float("inf")] * N
memo = [-1] * N
dfs(0, 0, 0)
if -1 in memo:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(memo[i]+1)

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

G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

def dfs(v, u, depth):

    depth_min[v] = depth
    memo[v] = u

    for next_v in G[v]:
        if depth_min[next_v] > depth+1:
            dfs(next_v, v, depth+1)

depth_min = [float("inf")] * N
memo = [-1] * N
dfs(0, 0, 0)
if -1 in memo:
    print("No")
else:
    print("Yes")
    for i in range(1, N):
        print(memo[i]+1)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays >= 0:
    print(holidays)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
day_cost = [int(i) for i in input().split()]
holidays = N-sum(day_cost)

if holidays > 0:
    print(holidays)
else:
    print-1
Problem p02713 (python)

Fixed submission:
# 最大公約数を格納するリストを初期化
max_codiv = []
 
# 繰り返す数を入力
n = int(input())
 
import math
# 1からkまでの総当たりで最大公約数を調べる
for i in range(1, n+1):
	for j in range(1, n+1):
		i_j = math.gcd(i, j)
		for k in range(1, n+1):
			i_j_k = math.gcd(i_j, k)
			max_codiv.append(i_j_k)
print(sum(max_codiv))

Buggy submission (verdict: Runtime Error):
# 最大公約数を格納するリストを初期化
max_codiv = []
 
# 繰り返す数を入力
n = int(input())
 
import math
# 1からkまでの総当たりで最大公約数を調べる
for i in range(1, n+1):
    for j in range(1, n+1):
    	i_j = math.gcd(i, j)
        for k in range(1, n+1):
            i_j_k = math.gcd(i_j, k)
            max_codiv.append(i_j_k)
print(sum(max_codiv))
Problem p02714 (python)

Fixed submission:
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Buggy submission (verdict: Runtime Error):
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (i-j)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Buggy submission (verdict: Runtime Error):
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (i-j)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)
Problem p02730 (python)

Fixed submission:
S = input()
S_rvs = S[::-1]
N = len(S)
left = int((N-1)/2)
right = int((N+3)/2-1)

if S == S_rvs and S[:left] == S_rvs[right:] and S[right:] == S_rvs[:left]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
S_rvs = S[::-1]
N = len(S)

if N >= 7 and S == S_rvs and S[:(N-1)/2] == S_rvs[(N+3)/2:] and S[(N+3)/2:] == S_rvs[:(N-1)/2]:
    print("Yes")
else:
    print("No")
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
q = [[i for i in input().split()] for j in range(Q)]

f = ""
l = ""
count = 0
for i in range(Q):
    if q[i][0] == "1":
        count += 1
    elif q[i][0] == "2":
        if count % 2 == 0:
            if q[i][1] == "1":
                f = q[i][2] + f
            else:
                l = l + q[i][2]
        else:
            if q[i][1] == "1":
                l = l + q[i][2]
            else:
                f = q[i][2] + f
        
if count % 2 == 0:
    print(f+S+l)
else:
    print((f+S+l)[::-1])

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

S = input()
Q = int(input())
q = np.array([[i for i in input().split()] for j in range(Q)])

for i in range(Q):
    if q[i,0] == "1":
        S = S[::-1]
    elif q[i,0] == "2":
        if q[i,1] == "1":
            S = q[i,2] + S
        else:
            S = S + q[i,2]
            
print(S)
Problem p02789 (python)

Fixed submission:
N, M = map(int, input().split())
if M == N:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(input().split())
if M == N:
    print("Yes")
else:
    print("No")
Problem p02801 (python)

Fixed submission:
al = list("abcdefghijklmnopqrstuvwxyz")
C = input()
print(al[al.index(C)+1])

Buggy submission (verdict: Runtime Error):
al = list("abcdefghijklmn")
C = input()
print(al[al.index(C)+1])
Problem p02936 (python)

Fixed submission:
from collections import deque

N, Q = map(int, input().split())

ab = [[int(i) for i in input().split()] for j in range(N-1)]
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = ab[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

q = [[int(i) for i in input().split()] for j in range(Q)]
count = [0 for i in range(N)]
for i in range(Q):
    p, x = q[i]
    count[p-1] += x

ls = deque([0])
seen = [0 for i in range(N)]
while len(ls) > 0:
    root = ls.popleft()
    seen[root] = 1

    for next_v in G[root]:
        if not seen[next_v]:
            count[next_v] += count[root]
            ls.append(next_v)

for i in range(N):
    print(count[i], end=" ")

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

N, Q = map(int, input().split())

g = [[int(i) for i in input().split()] for j in range(N-1)]
G = [[] for i in range(N)]
for i in range(N-1):
    a, b = g[i]
    G[a-1].append(b-1)
    G[b-1].append(a-1)

q = [[int(i) for i in input().split()] for j in range(Q)]
count = [0 for i in range(N)]
for i in range(Q):
    p, x = q[i]
    count[p-1] += x

def dfs(v, p):
    if p != -1:
        count[v] += count[p]
    for next_v in G[v]:
        if next_v == p: continue
        dfs(next_v, v)

dfs(0, -1)
for i in range(N):
    print(count[i], end=" ")
Problem p03044 (python)

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

N = int(input())
G = [[] for i in range(N)]
temp = sys.stdin.readlines()
for line in temp:
    u, v, d = map(int, line.split())
    G[u-1].append([v-1, d])
    G[v-1].append([u-1, d])
    
def dfs(v, G, cur=0):
    # 色をメモ
    color[v] = cur
        
    # 隣接するノードの色を調べる
    for next_v in G[v]:
        # 隣接ノードが探索済みなら、色が正しいか確かめる
        if color[next_v[0]] != -1:
            continue
            
        # 隣接ノードが未探索なら、正しい色に更新して再帰的に探索
        if next_v[1] % 2 == 0:
            dfs(next_v[0], G, cur)
        else:
            dfs(next_v[0], G, 1-cur)

color = [-1 for i in range(N)]
dfs(0, G)
for i in range(N):
    print(color[i])

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
G = [[] for i in range(N)]
temp = sys.stdin.readlines()
for line in temp:
    u, v, d = map(int, line.split())
    G[u-1].append([v-1, d])
    G[v-1].append([u-1, d])
    
def dfs(v, G, cur=0):
    # 色をメモ
    color[v] = cur
        
    # 隣接するノードの色を調べる
    for next_v in G[v]:
        # 隣接ノードが探索済みなら、色が正しいか確かめる
        if color[next_v[0]] != -1:
            continue
            
        # 隣接ノードが未探索なら、正しい色に更新して再帰的に探索
        if next_v[1] % 2 == 0:
            dfs(next_v[0], G, cur)
        else:
            dfs(next_v[0], G, 1-cur)

color = [-1 for i in range(N)]
dfs(0, G)
for i in range(N):
    print(color[i])
Problem p03160 (python)

Fixed submission:
# 最小値に置き換える関数
def chmin(a, b):
    if a > b:
        a = b
        return True
    
    return False

# 入力
N = int(input())
H = [int(i) for i in input().split()]

# dpテーブルの生成
dp = [float("inf") for i in range(N)]
# 初期条件のセット(足場1)
dp[0] = 0

# N番目の足場までのループ
# i = 1のときはi-2がないことに注意
for i in range(N):
    # ノードi-1からの遷移を計算
    dp[i] = min(dp[i], dp[i-1]+abs(H[i] - H[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2]+abs(H[i] - H[i-2]))

# dpテーブルの末尾が答え
print(dp[N-1])

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

# 入力
N = int(input())
H = [int(i) for i in input().split()]

# メモ用のDPテーブルを生成
dp = [float("inf") for i in range(N)]

# 足場iにたどり着く最初コストを返す
def rec(i):
    # ベースケースをセット
    if i == 0:
        return 0
    
    # メモをチェック
    if dp[i] < float("inf"):
        return dp[i]
    
    # i-1から遷移する場合
    cost = rec(i-1) + abs(H[i] - H[i-1])
    # i-2から遷移する場合
    if i > 1:
        cost = min(cost, rec(i-2) + abs(H[i] - H[i-2]))
    
    # 結果をメモしてから返す
    dp[i] = cost
    return cost

print(rec(N-1))

Buggy submission (verdict: Runtime Error):
# 入力
N = int(input())
H = [int(i) for i in input().split()]

# メモ用のDPテーブルを生成
dp = [float("inf") for i in range(N)]

# 足場iにたどり着く最初コストを返す
def rec(i):
    # ベースケースをセット
    if i == 0:
        return 0
    
    # メモをチェック
    if dp[i] < float("inf"):
        return dp[i]
    
    # i-1から遷移する場合
    cost = rec(i-1) + abs(H[i] - H[i-1])
    # i-2から遷移する場合
    if i > 1:
        cost = min(cost, rec(i-2) + abs(H[i] - H[i-2]))
    
    # 結果をメモしてから返す
    dp[i] = cost
    return cost

print(rec(N-1))

Buggy submission (verdict: Runtime Error):
# 足場iにたどり着く最初コストを返す
def rec(i):
    # ベースケースをセット
    if i == 0:
        return 0
    
    # i-1から遷移する場合
    cost = rec(i-1) + abs(H[i] - H[i-1])
    
    if i > 1:
        # i-2から遷移する場合
        cost = min(cost, rec(i-2) + abs(H[i] - H[i-2]))
    
    return cost

# 入力
N = int(input())
H = [int(i) for i in input().split()]

print(rec(N-1))
Problem p03161 (python)

Fixed submission:
import numpy as np

# 入力
N, K = map(int, input().split())
H = np.array([int(i) for i in input().split()])

# ndarray型のDPテーブルを生成
dp = np.zeros(N, dtype=int)
# 初期値をセット
dp[0] = 0

# 各足場へたどり着く最小コストを調べる
for i in range(1, N):
    s = max(0, i-K)
    dp[i] = min(dp[s:i] + np.abs(H[i] - H[s:i])) # iより前の足場のコストに足す

print(dp[N-1])

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

N, K = map(int, input().split())
H = np.array([int(i) for i in input().split()])

dp = np.full(N, np.inf, int)
dp[0] = 0
for i in range(1, N):
    dp[i] = min(dp[max(i-K, 0):i]+np.abs(H[max(i-K, 0):i]-H[i]))
    
print(dp[N-1])
Problem p03273 (python)

Fixed submission:
H, W = map(int, input().split())
field = [[i for i in input()] for j in range(H)]

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[row][column])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[i][j], end="")
    print()

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
field = [[i for i in input()] for j in range(H)]

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[column][row])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[i][j], end="")
    print()
Problem p03447 (python)

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

b = (X - A) // B

print(X-A-B*b)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0

for i in range(A+1):
    for j in range(B+1):
        i_j = 500*i + 100*j
        for k in range(C+1):
            if i_j + 50*k == X:
                result += 1

print(result)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
X = int(input())

result = 0

for i in range(A+1):
    for j in range(B+1):
        i_j = 500*i + 100*j
        for k in range(C+1):
            if i_j + 50*k == X:
                result += 1

print(result)
Problem p03457 (python)

Fixed submission:
N = int(input())
route = [[int(i) for i in input().split()] for j in range(N)]

arrive = True
pre_spot = [0, 0, 0]
for spot in route:
    cost = abs(spot[1] - pre_spot[1]) + abs(spot[2] - pre_spot[2])
    time = spot[0] - pre_spot[0]
    if (time - cost < 0) or ((time - cost) % 2 != 0):
        arrive = False
        break

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

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

pre = [0, 0, 0]
match = True
for i in range(N):
    dist = abs(plan[i][1] - pre[1]) + abs(plan[i][2] - pre[2])
    dt = plan[i][0] - pre[0]
    
    if dt < dist:
        can = False
    if dt % 2 != dist % 2:
        can = False
        break
    pre = plan[i]
        
if can:
    print("Yes")
else:
    print("No")
Problem p03543 (python)

Fixed submission:
S = input()

if S[0] == S[1] == S[2]:
    print("Yes")
elif S[1] == S[2] == S[3]:
    print("Yes")
else:
    print("No")

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

if S[0] == S[1] == S[2]:
    print("Yes")
elif S[1] == S[2] == S[3]:
    print("Yes")
else:
    print("No")
Problem p03545 (python)

Fixed submission:
ticket = [int(i) for i in input()]
sum_list = [[] for i in range(len(ticket))]
sum_list[0] = [ticket[0]]
sign_list = [[] for i in range(len(ticket))]
sign_list[0] = [""]

for i in range(len(ticket)-1):
    for j in range(len(sum_list[i])):
        sum_list[i+1].append(sum_list[i][j] + ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "+")
        sum_list[i+1].append(sum_list[i][j] - ticket[i+1])
        sign_list[i+1].append(sign_list[i][j] + "-")

for i in range(2**len(ticket)):
    if sum_list[len(ticket)-1][i] == 7:
        sign = sign_list[len(ticket)-1][i]
        break

for i in range(len(ticket)-1):
    print(str(ticket[i]) + sign[i], end="")
print(str(ticket[-1]) + "=7")

Buggy submission (verdict: Runtime Error):
def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            sys.exit()
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)
    
    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]))
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]))

ticket_sum(1, S, int(S[0]))

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

def ticket_sum(i, s, num, memo):
    if i == len(S):
        if num == 7:
            memo.append(s+"=7")
            return
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)
    
    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]), memo)
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]), memo)

    return memo[0]
    
memo = []
print(ticket_sum(1, S, int(S[0]), memo))
Problem p03607 (python)

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

pre = sorted_A[0]
ans = 0
if len(sorted_A) == 1:
    print(1)
else:
    count = 1
    for i in range(1, len(sorted_A)):
        if sorted_A[i] == pre:
            count += 1
            if i == len(sorted_A)-1:
                if count % 2 == 1:
                    ans += 1
        else:
            if i == len(sorted_A)-1:
                ans += 1
            if count % 2 == 1:
                ans += 1
            pre = sorted_A[i]
            count = 1
    print(ans)

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

pre = sorted_A[0]
if len(sorted_A) == 1:
    print(1)
else:
    count = 0
    for i in range(1, len(sorted_A)):
        if sorted_A[i] == pre:
            count += 1
        else:
            if count % 2 == 1:
                ans += 1
            pre = sorted_A[i]
            count = 1
    print(ans)

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

pre = sorted_A[0]
if len(sorted_A) == 1:
    print(1)
else:
    count = 0
    for i in range(1, len(sorted_A)):
        if sorted_A[i] == pre:
            count += 1
        else:
            if count % 2 == 1:
                ans += 1
            pre = sorted_A[i]
            count = 1
print(ans)

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

A_count = [0] * max(A)
for i in A:
    A_count[i-1] += 1

ans = 0
for count in A_count:
    if count % 2 == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A_count = [0] * max(A)

for i in A:
    A_count[i-1] += 1

ans = 0
for count in A_count:
    if count % 2 == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A_count = [0] * max(A)

for i in A:
    if A_count[i-1] == 0:
        A_count[i-1] = 1
    elif A_count[i-1] == 1:
        A_count[i-1] = 0

print(sum(A_count))
Problem p03697 (python)

Fixed submission:
A, B = map(int, input().split())
ans = A + B
if ans < 10:
    print(ans)
else:
    print("error")

Buggy submission (verdict: Runtime Error):
N = int(input())
S_dict = {}
for i in range(N):
    s = input()
    if s not in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1
        
max_poll = max(S_dict.values())
ans_list = []
for key, poll in S_dict.items():
    if poll == max_poll:
        ans_list.append(key)

for ans in sorted(ans_list):
    print(ans)
Problem p03796 (python)

Fixed submission:
N = int(input())

for i in range(1, N+1):
    if i == 1:
        ans = 1
    else:
        ans = ans * i % (10**9 + 7)

print(ans)

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

def power(n):
    if n == 1:
        p = 1
    else:
        p = power(n-1) * n
    
    return p % (10**9 + 7)

print(power(N))
Problem p03944 (python)

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

white = [0, W, 0, H]

points = [[int(i) for i in input().split()] for j in range(N)]

for point in points:
    if point[2] == 1:
        if point[0] > white[0]:
            white[0] = point[0]
    if point[2] == 2:
        if point[0] < white[1]:
            white[1] = point[0]
    if point[2] == 3:
        if point[1] > white[2]:
            white[2] = point[1]
    if point[2] == 4:
        if point[1] < white[3]:
            white[3] = point[1]

w = white[1] - white[0]
h = white[3] - white[2]

if w > 0 and h > 0:
    print(w * h)
else:
    print(0)

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

white = [0, W, 0, H]

points = [[int(i) for i in input().split()] for j in range(N)]

for point in points:
    if point[2] == 1:
        if point[0] > white[0]:
            white[0] = point[0]
    if point[2] == 2:
        if point[0] < white[1]:
            white[1] = point[0]
    if point[2] == 3:
        if point[1] > white[2]:
            white[2] = point[1]
    if point[2] == 4:
        if point[1] < white[3]:
            white[3] = point[1]

w = white[1] - white[0]
h = white[3] - white[2]

if w > 0 and h > 0:
    print(result)
else:
    print(0)
Problem p02802 (python)

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

is_solved = [False] * N
wa_count = [0] * N
wa_total = 0

for _ in range(M):
    p, s = list(input().split())
    p = int(p) - 1

    if s == 'AC':
        if not is_solved[p]:
            is_solved[p] = True
            wa_total += wa_count[p]
    else:
        wa_count[p] += 1

print(sum(is_solved), wa_total)

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

questions = [False] * N
ac_count = penalty_count = 0
P = []
S = []

for _ in range(M):
    p, s = list(input().split())
    p = int(p) - 1

    P.append(p)
    S.append(s)

    if s == 'AC':
        questions[p] = True

for i in range(M):
    if S[P[i]] == 'WA' and questions[P[i]]:
        penalty_count += 1

print(sum(questions), penalty_count)

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

questions = [False] * N
ac_count = penalty_count = 0
P = []
S = []

for _ in range(M):
    p, s = list(input().split())
    p = int(p) - 1

    P.append(p)
    S.append(s)

    if s == 'AC':
        questions[p] = True

for i in range(M):
    if S[P[i]] == 'WA' and questions[P[i]]:
            penalty_count += 1

print(sum(questions), penalty_count)
Problem p02917 (python)

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

N = int(readline())
B = list(map(int, readline().split()))

B.append(float('inf'))

mins = [B[0]]

for i in range(1, N):
    mins.append(min(B[i-1], B[i]))

print(sum(mins))

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

N = int(readline())
B = list(map(int, readline().split()))

B.append(float('inf'))

mins = [min(B[0])]

for i in range(1, N):
    mins.append(min(B[i-1], B[i]))

print(sum(mins))

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

N = int(readline())
B = list(map(int, readline().split()))

B.append(float('inf'))

mins = [min(B[0]]

for i in range(1, N):
    mins.append(min(B[i-1], B[i]))

print(sum(mins))
Problem p02923 (python)

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

N = int(readline())
H = list(map(int, readline().split()))

if N == 1:
    print(0)
    exit()

dp = [0] * N

for i in range(N-2, -1, -1):
    if H[i] >= H[i+1]:
        dp[i] = 1 + dp[i+1]

print(max(dp))

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

if N == 1:
    print(0)
    exit()

dp = [0] * N

for i in range(N-2, -1, -1):
    if H[i] >= H[i+1]:
        dp[i] = 1 + dp[i+1]

print(max(dp))
Problem p02981 (python)

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

print(min(N * A, B))

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

ans = 2019

for i in range(L, R):
    for j in range(i+1, R+1):
        ans = min(ans, (i*j) % 2019)
        if ans == 0:
            print('0')
            exit()

print(ans)