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

Fixed submission:
counters = {
    'hon': {2, 4, 5, 7, 9},
    'pon': {0, 1, 6, 8},
    'bon': {3},
}

N = input()
for k, v in counters.items():
    if int(str(N)[-1]) in v:
        print(k)
        break

Buggy submission (verdict: Runtime Error):
import sys
def input(itr=iter(sys.stdin.readlines())):  # pylint: disable= redefined-builtin
    return next(itr).rstrip('\n\r')
###############################################################################

import collections
import math as m
from fractions import Fraction

MOD = 1000000007

N = int(input())
Sardine = collections.namedtuple("Sardine", "A B")
sardines = [Sardine(*map(int, input().split())) for _ in range(N)]

def slope(sardine):
    if sardine.A == sardine.B == 0:
        return None
    elif sardine.B == 0:
        return m.inf
    else:
        return Fraction(sardine.A, sardine.B)

def perpendicular(slope):
    if slope == 0:
        return m.inf
    elif slope == m.inf:
        return 0
    else:
        return -1 / slope

groups = collections.Counter(slope(s) for s in sardines)
if groups[None]:
    zeroes = groups[None]
    del groups[None]
else:
    zeroes = 0

ways = 1
while groups:
    slope, count = groups.popitem()
    perp_slope = perpendicular(slope)
    perp_count = groups[perp_slope]

    ways *= (pow(2, count, MOD) + pow(2, perp_count, MOD) - 1) % MOD
    ways %= MOD

    del groups[perp_slope]

output = (ways-1 + zeroes) % MOD
print(output)
Problem p02584 (python)

Fixed submission:
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(abs(x-d*k))
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (k-t)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) == abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (k-t-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))

Buggy submission (verdict: Runtime Error):
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(x-d*k)
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (t-k)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif abs(x-d*t) = abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (t-k-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))

Buggy submission (verdict: Runtime Error):
x,k,d = [int(x) for x in input().split()]
t = abs(int(x/d))
if x < 0:
    d = -d
if t >= k:
    print(x-d*k)
elif t == 0:
    if k % 2 == 0:
        print(abs(x))
    else:
        print(min(abs(x-d),abs(x+d)))
elif t < k:
    if abs(x-d*t) < abs(x-d*t-d):
        if (t-k)%2==0:
            print(abs(x-d*t))
        else:
            print(min(abs(x-d*t+d),abs(x-d*t-d)))
    elif  abs(x-d*t) = abs(x-d*t-d):
        print(abs(x-d*t))
    else:
        if (t-k-1)%2==0:
            print(abs(x-d*t-d))
        else:
            print(min(abs(x-d*t),abs(x-d*t-2*d)))
Problem p02585 (python)

Fixed submission:
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
#P = list(map(int,input().split()))
P = list(map(lambda x : int(x) - 1, input().split())) #ひとつづつずらす
C = list(map(int,input().split()))
SCORE = [0]*(n+1)

max_score = -10**12
for i in range(n):
  x = i
  TEMPMAX = [-10**9] * (n+1)
  for j in range(1, n+1):
    SCORE[j] = SCORE[j-1] + C[P[x]]
    TEMPMAX[j]= max(TEMPMAX[j-1], SCORE[j])
    x = P[x]
    if x == i:
      break
  if j >= k:
    max_score = max(max_score,TEMPMAX[k])
  elif SCORE[j] < 0:
    max_score = max(max_score, TEMPMAX[j])
  else:
    m = k//j
    a = SCORE[j] *(m-1) + TEMPMAX[j]
    b = SCORE[j] *m + TEMPMAX[k % j]
    max_score = max(max_score, a, b)
print(max_score)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n, k = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = [-10**12] * n
#print(ans)

q = k // n
mod = k % n

POINT = [[-10**12 for i in range(n)] for j in range(k)]
PLACE = [[0 for i in range(n)] for j in range(k)]
for i in range(n):
  POINT[0][i] = C[P[i]-1]  
  PLACE[0][i] = P[i]-1 #P[i]は1スタートなのでずれる

tempmax= max(POINT[0])

z = min(k,n)

for j in range(1,z): #日付
  for i in range(n):
    PLACE[j][i]=P[PLACE[j-1][i]]-1
    POINT[j][i]=POINT[j-1][i] + C[PLACE[j][i]]
    tempmax = max(tempmax,POINT[j][i])

tt = -10**-12
if k <= n:
  answer = tempmax
else:
  for i in range(n):
    ans[i] = q * POINT[n][i]
    for j in range(mod):
      tt = max(tt, POINT[j][i])
    ans[i] += tt
print(max[answer])
Problem p02952 (python)

Fixed submission:
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

N=int(input())
count=0

for i in range(N+1):
    if i==0:
        continue
    if i<10:
        count +=1
    if i<100:
        continue
    elif i<1000:
        count +=1
    elif i<10000:
        continue
    elif i<100000:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
import sys    #インタプリタや実行環境に関する情報を扱うためのライブラリ
import os     #フォルダやファイルを操作
import math

N=input()
count=0

for i in range(N):
    if i==0:
        continue
    if i<10:
        count +=1
    elif i<1000:
        count +=1
    elif i<100000:
        count+=1

print(count)
input()
Problem p03436 (python)

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

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1


if type(MAP[h-1][w-1]) == int:
  ans = h*w -MAP[h-1][w-1]-sharp
else:
  ans = -1
    
print(ans)

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

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1

ans = h*w -MAP[h-1][w-1]-sharp
#print(MAP)
print(ans)

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

h,w = map(int,input().split())
MAP = [list(input().rstrip()) for i in range(h)]  #rstripで最後の/nを省ける
sharp = 0
for i in range(h):
  sharp += MAP[i].count("#")
#print(sharp)

#必要なもの MAP(list), MOVE(list), STACK(deque)
MAP[0][0]=1
MOVE = [[1,0],[-1,0],[0,1],[0,-1]]
STACK = deque([(0,0)])
while STACK:
  y, x = STACK.popleft()
  for dy,dx in MOVE:
    ny = y + dy
    nx = x + dx
    if not(0 <= ny < h) or not(0 <= nx < w) or MAP[ny][nx]!='.':
      continue
    else:
      STACK.append((ny,nx))
      MAP[ny][nx] = MAP[y][x] + 1

ans = h*w -MAP[h-1][w-1]-sharp
#print(MAP)
print(ans)
Problem p02613 (python)

Fixed submission:
n = int(input())
c0, c1, c2, c3 = [0 for i in range(4)]
for j in range(n):
  judge = input()
  if judge == "AC":
    c0 += 1
  elif judge == "WA":
    c1 += 1
  elif judge == "TLE":
    c2 += 1
  else:
  	c3 += 1

print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))

Buggy submission (verdict: Runtime Error):
n = int(input())
c0, c1, c2, c3 = [0 for i in range(4)]
for j in range(n):
  judge = input()
  c0 += 1 if judge == "AC" else c1 += 1 if judge == "WA" else c2 += 1 if judge == "TLE" else c3 += 1

print("AC x " + str(c0))
print("WA x " + str(c1))
print("TLE x " + str(c2))
print("RE x " + str(c3))
Problem p02641 (python)

Fixed submission:
import math
X, N = list(map(lambda n : int(n), input().split(" ")))
if N == 0:
  print(X)
else:
  P = list(map(lambda p : int(p), input().split(" ")))
  Q = list(map(lambda p : [p, abs(X-p)], P))
  Q.sort(key=lambda q: (q[1], q[0]))

  cand = []
  for i in range(N):
    if i == 0 and Q[0][1] != 0:
      cand.append(X)
      break
    else:
      if Q[i][1] != math.ceil(i/2):
        cand.append(X + math.ceil(i/2))
        cand.append(X - math.ceil(i/2))
        break
  if len(cand) == 0:
    if N % 2 == 0:
      cand.append(X + int(N/2))
      cand.append(X - int(N/2))
    else:
      cand.append(X + int((N+1)/2))
      cand.append(X - int((N+1)/2))

  print(min(list(filter(lambda c: c not in P, cand))))

Buggy submission (verdict: Runtime Error):
import math
X, N = list(map(lambda n : int(n), input().split(" ")))
P = list(map(lambda p : int(p), input().split(" ")))
Q = list(map(lambda p : [p, abs(X-p)], P))
Q.sort(key=lambda q: (q[1], q[0]))

cand = []
for i in range(N):
  if i == 0 and Q[0][1] != 0:
    cand.append(X)
    break
  else:
    if Q[i][1] != math.ceil(i/2):
      cand.append(X + math.ceil(i/2))
      cand.append(X - math.ceil(i/2))
      break
if len(cand) == 0:
  if N % 2 == 0:
    cand.append(X + int(N/2))
    cand.append(X - int(N/2))
  else:
    cand.append(X + int((N+1)/2))
    cand.append(X - int((N+1)/2))

print(min(list(filter(lambda c: c not in P, cand))))
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(lambda a : int(a), input().split(" ")))
ans = 1
if A.count(0) > 0:
  ans = 0

for i in range(len(A)):
  ans *= A[i]
  if ans > 10 ** 18:
    ans = -1
    print("-1")
    break
 
if ans != -1:
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(lambda a : int(a), input().split(" ")))
ans = 1
print i in range(len(A)):
  ans *= A[i]

print(ans) if ans <= 10 ** 18 else print("-1")
Problem p02678 (python)

Fixed submission:
def main():
	N, M = [int(x) for x in input().split(" ")]
	route = [[] for i in range(N)]
	for i in range(M):
		A, B = [int(y) for y in input().split(" ")]
		route[A - 1] += [B]
		route[B - 1] += [A]

	checked = [1] + [0] * (N - 1)
	to_check = [{"src" : s, "dst" : 1} for s in route[0]]
	signal = [-1] + [0] * (N - 1)

	for r in route[0]:
		checked[r - 1] = 1

	while len(to_check) > 0:
		checking = to_check.pop(0)
		src = checking["src"]
		signal[src - 1] = str(checking["dst"])
		rooms = route[src - 1]
		for r in rooms:
			if checked[r - 1] == 0:
				to_check.append({"src": r, "dst": src})
				checked[r - 1] = 1

	if signal.count(0) > 0:
		print("No")
	else:
		print("Yes")
		print("\n".join(signal[1:]))

main()

Buggy submission (verdict: Runtime Error):
def main():
	N, M = [int(x) for x in input().split(" ")]
	route = [[] for i in range(N)]
	for i in range(M):
		A, B = [int(y) for y in input().split(" ")]
		route[A - 1] += [B]
		route[B - 1] += [A]

	checked = [1] + [0] * (N - 1)
	to_check = [{"src" : s, "dst" : 1} for s in route[0]]
	signal = [-1] + [0] * (N - 1)
	signal_cnt = 0

	while len(to_check) > 0:
		checking = to_check.pop(0)
		src = checking["src"]
		if checked[src - 1] == 0:
			checked[src - 1] = 1
			signal[src - 1] = str(checking["dst"])
			signal_cnt += 1
			rooms = route[src - 1]
			for r in rooms:
				if checked[r - 1] == 0:
					to_check.append({"src": r, "dst": src})
	if signal_cnt != N - 1
		print("No")
	else:
		print("Yes")
		print("\n".join(signal[1:]))

main()
Problem p02681 (python)

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

if T.startswith(S) and len(T) == len(S) + 1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
tmp = input().split("\n")
S = tmp[0]
T = tmp[1]

if T.startwith(S) and len(T) + len(S) == 1:
  print("Yes")
else:
  print("No")
Problem p02719 (python)

Fixed submission:
N, K = list(map(lambda n: int(n), input().split(" ")))
 
while N > int(K/2):
  N = min([abs(N-K), N % K])

print(N)

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

while N <= int(K/2):
  N = min([abs(N-K), N % K])

print(N)
Problem p02783 (python)

Fixed submission:
import math
tmp = input().split(" ")
 
HP = int(tmp[0])
attack = int(tmp[1])
 
print(math.ceil(HP/attack))

Buggy submission (verdict: Runtime Error):
tmp = input().split(" ")

HP = int(tmp[0])
attack = int(tmp[1])

print(math.ceil(HP/attack))
Problem p02791 (python)

Fixed submission:
N = int(input())
P = list(map(lambda p : int(p), input().split(" ")))
left_min = P[0]
cnt = 0
for i in range(len(P)):
  if left_min >= P[i]:
    cnt += 1
    left_min = P[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(lambda p : int(p), input().split(" ")))
left_min = P[0]
cnt = 0
for i in range(P):
  if left_min >= P[i]:
    cnt += 1
    left_min = P[i]
print(cnt)
Problem p02801 (python)

Fixed submission:
C = input()
 
ary = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")
 
print(ary[ary.index(C) + 1])

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

ary = "abcdefghijklmnopqrstuvwxyz".split("")

print(ary[ary.index(C) + 1])
Problem p02811 (python)

Fixed submission:
tmp = input().split(" ")
 
N = int(tmp[0])
X = int(tmp[1])
 
if X <= 500 * N:
  print("Yes")
else:
  print("No")

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

N = int(tmp[0])
X = int(tmp[1])

if X <= 500 * N:
  print("Yes")
else:
  print("No")
Problem p02885 (python)

Fixed submission:
tmp = input().split(" ")
A = int(tmp[0])
B = int(tmp[1])

print(max([A - 2 * B, 0]))

Buggy submission (verdict: Runtime Error):
tmp = input().split(" ")
A = int(tmp[0])
B = int(tmp[1])

import math
print(math.max(A - 2 * B, 0))
Problem p02898 (python)

Fixed submission:
N, K = list(map(lambda n: int(n), input().split(" ")))
h = list(map(lambda x: int(x), input().split(" ")))
print(len(list(filter(lambda height: height >= K, h))))

Buggy submission (verdict: Runtime Error):
N, K = list(map(lambda n: int(n), input().split(" ")))
h = list(map(lambda x: int(n), input().split(" ")))
print(len(list(filter(lambda height: height >= K, h))))
Problem p02910 (python)

Fixed submission:
str = input()
ans = "Yes"
for i in range(len(str)):
  if (i + 1) % 2 == 0 and str[i] not in ('L', 'U', 'D'):
    ans = "No"
  if (i + 1) % 2 == 1 and str[i] not in ('R', 'U', 'D'):
    ans = "No"
 
print(ans)

Buggy submission (verdict: Runtime Error):
str = input()
ans = "Yes"
for i in len(str):
  if (i + 1) % 2 == 0 and str[i] not in ('L', 'U', 'D'):
    ans = "No"
  if (i + 1) % 2 == 1 and str[i] not in ('R', 'U', 'D'):
    ans = "No"

print(ans)
Problem p02911 (python)

Fixed submission:
N, K, Q = list(map(lambda n: int(n), input().split(" ")))
point = [K - Q] * N
for i in range(Q):
  c = int(input())
  point[c - 1] += 1

print("\n".join(["Yes" if p > 0 else "No" for p in point]))

Buggy submission (verdict: Runtime Error):
N, K, Q = list(map(lambda n: int(n), input().split(" ")))
point = [K - Q] * N
for i in range(N):
  c = int(input())
  point[c - 1] += 1

print("\n".join(["YES" if p > 0 else "NO" for p in point]))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
cnt = 0
loop = 0
for i in S:
  if i == T[loop]:
    cnt += 1
  loop += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
cnt = 0
for i in S:
  if S[i] == T[i]:
    cnt += 1
print(cnt)
Problem p02946 (python)

Fixed submission:
K, X = list(map(lambda n: int(n), input().split(" ")))
print(" ".join(list(map(lambda s: str(s), list(range(X - K + 1, X + K))))))

Buggy submission (verdict: Runtime Error):
K, X = list(map(lambda n: int(n), input().split(" ")))
print(" ".join(list(range(K - X + 1, K + X - 1))))
Problem p02993 (python)

Fixed submission:
str = input()

flag = False
for i in range(len(str) - 1):
  if str[i] == str[i+1]:
    flag = True

print("Bad") if flag else print("Good")

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

flag = False
for i in range(len(str)) - 1:
  if str[i] == str[i+1]:
    flag = True

print("Bad") if flag else print("Good")
Problem p02994 (python)

Fixed submission:
N, L = list(map(lambda x: int(x), input().split(" ")))
 
S = int(N * (N-1) / 2) + L * N
 
if L >= 0:
  print(S - L)
elif L + N - 1 <= 0:
  print(S - L - N + 1)
else:
  print(S)

Buggy submission (verdict: Runtime Error):
L, L+1, L+2, ..., L+N-1
N, L = list(map(lambda x: int(x), input().split(" ")))

S = int(N * (N-1) / 2) + L * N

if L >= 0:
  print(S - L)
elif L + N - 1 <= 0:
  print(S - L - N + 1)
else:
  print(S)
Problem p03001 (python)

Fixed submission:
W, H, x, y = list(map(lambda n: int(n), input().split(" ")))
 
S = W * H / 2

print(S, end=" ")
print(1) if W == 2 * x and H == 2 * y else print(0)

Buggy submission (verdict: Runtime Error):
W, H, x, y = list(map(lambda n: int(n), input().split(" ")))

S = W * H / 2
flag = 1 if W == 2 * x and H == 2 * y else flag = 0
print(S, end=" ")
print(flag)
Problem p03338 (python)

Fixed submission:
N = int(input())
s = list(input())
a = []
for i in range(1, N):
  a.append(len(list(set(s[0:i]) & set(s[i:]))))
print(max(a))

Buggy submission (verdict: Runtime Error):
N = int(input())
s = list(input())
a = []
for i in range(1, N - 1):
  a.append(len(list(set(s[0:i]) & set(s[i:]))))
print(max(a))
Problem p03379 (python)

Fixed submission:
import copy

def main():
	N = int(input())
	X = [int(x) for x in input().split(" ")]
	sortedX = copy.deepcopy(X)
	sortedX.sort()
	cand = [sortedX[int(N / 2) - 1], sortedX[int(N / 2)]]

	for xi in X:
		if xi <= cand[0]:
			print(cand[1])
		else:
			print(cand[0])

main()

Buggy submission (verdict: Runtime Error):
// inputに入力データ全体が入る
function Main(input) {
	var line = input.split("\n");
	var N = Number(line[0]);
	var X = line[1].split(" ");

	var Y = X.slice().sort(function(a, b){
		return Number(a) - Number(b)
	});

	var median = [Number(Y[(N/2 - 1)]), Number(Y[N/2])];
	var ret = [];

	for(var i = 0; i < X.length; i++){
		if(median[1] <= Number(X[i])){
			console.log(median[0] + "\n");
		}else{
			console.log(median[1] + "\n");
		}
	}
	return 0;

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
Problem p03544 (python)

Fixed submission:
N = int(input())
 
L = [2, 1]
 
if N == 1:
  print(1)
else:
  i = 1
  while i < N:
    L.append(L[i] + L[i-1])
    i += 1
  print(L[-1])

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

L = [2, 1]

if N == 1:
  print(1)
else:
  i = 1
  while i < N:
    L.append(L[i] + L[i-1])
    i += 1
  print(L[-1])
Problem p03609 (python)

Fixed submission:
tmp = input().split(" ")
 
print(max([int(tmp[0]) - int(tmp[1]), 0]))

Buggy submission (verdict: Runtime Error):
tmp = input().split(" ")

print(max([tmp[0] - tmp[1], 0]))
Problem p03611 (python)

Fixed submission:
import collections

def main():
  N = int(input())
  A = [int(a) for a in input().split(" ")]
  CA = collections.Counter(A)
  minA = min(A)
  maxA = max(A)
  X = [CA[i] for i in range(minA, maxA + 1)]
  if len(X) == 1:
    print(X[0])
    return 0
  if len(X) == 2:
    print(X[0] + X[1])
    return 0
    
  Y = [X[j] + X[j+1] + X[j+2] for j in range(len(X) - 2)]
  print(max(Y))

main()

Buggy submission (verdict: Runtime Error):
import collections

def main():
  N = int(input())
  A = [int(a) for a in input().split(" ")]
  CA = collections.Counter(A)
  minA = min(A)
  maxA = max(A)
  X = [CA[i] for i in range(minA, maxA + 1)]
  if len(X) == 1:
    print(X[0])
    return 0
  if len(X) == 2:
    print(X[0] + X[1])
    
  Y = [X[j] + X[j+1] + X[j+2] for j in range(len(X) - 2)]
  print(max(Y))

main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  A = [int(a) for a in input().split(" ")]
  minA = min(A)
  maxA = max(A)
  X = [A.count(i) for i in range(minA, maxA + 1)]
  if len(X) == 1:
    print(X[0])
    return 0
  if len(X) == 2:
    print(X[0] + X[1])
    
  Y = [X[j] + X[j+1] + X[j+2] for j in range(len(X) - 2)]
  print(max(Y))

main()
Problem p03671 (python)

Fixed submission:
ary = list(map(lambda n: int(n), input().split(" ")))
ary.sort()
print(ary[0] + ary[1])

Buggy submission (verdict: Runtime Error):
ary = list(map(lambda n: int(n), input().split(" "))).sort()
print(ary[0] + ary[1])
Problem p03681 (python)

Fixed submission:
def main():
  N, M = [int(n) for n in input().split(" ")]

  if abs(N - M) >= 2:
    print(0)
  elif abs(N - M) == 1:
    print((factorial(N) * factorial(M)) % 1000000007)
  else:
    print((factorial(N) * factorial(M) * 2) % 1000000007)

def factorial(n):
  ret = 1
  for i in range(1, n + 1):
    ret = (ret * i) % 1000000007
  return ret
    
main()

Buggy submission (verdict: Runtime Error):
def main():
  N, M = [int(n) for n in input().split(" ")]

  if abs(N - M) > 2:
    print(0)
  elif abs(N - M) == 1:
    print((factorial(N) * factorial(M)) % 1000000007)
  else:
    print((factorial(N) * factorial(M) * 2) % 1000000007)

def factorial(n):
  if n > 1:
    return (n * factorial(n - 1)) % 1000000007
  else:
    return 1
    
main()

Buggy submission (verdict: Runtime Error):
def main():
  N, M = [int(n) for n in input().split(" ")]

  if abs(N - M) > 2:
    print(0)
  elif abs(N - M) == 1:
    print((factorial(N) * factorial(M)) % 1000000007)
  else:
    print((factorial(N) * factorial(M) * 2) % 1000000007)

def factorial(n):
  if n > 1:
    return (n * factorial(n - 1)) % 1000000007
  else:
    return 1
    
main()
Problem p03711 (python)

Fixed submission:
g = [31,28,31,30,31,30,31,31,30,31,30,31]
 
tmp = input().split(" ")
print("Yes") if g[int(tmp[0]) - 1] == g[int(tmp[1]) - 1] else print("No")

Buggy submission (verdict: Runtime Error):
g = [31,28,31,30,31,30,31,31,30,31,30,31]
 
tmp = input().split(" ")
print("Yes") if g[int(tmp[0])] == g[int(tmp[1])] else print("No")

Buggy submission (verdict: Runtime Error):
g = [31,28,31,30,31,30,31,31,30,31,30,31]
 
tmp = input().split(" ")
print("Yes") if g[int(tmp[0])] == g[int(tmp[1])] else print("No")

Buggy submission (verdict: Runtime Error):
g = [31,28,31,30,31,30,31,31,30,31,30,31]

tmp = input().split(" ")
print("Yes") if g[tmp[0]] == g[tmp[1]] else print("No")
Problem p03721 (python)

Fixed submission:
N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  e = elm[i]
  placed += e["count"]
  if placed >= K:
    print(e["element"])
    break

Buggy submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split(" ")]
 
placed = 0
elm = []
for i in range(N):
  a, b = input().split(" ")
  elm.append({
    "order": i + 1,
    "element": int(a),
    "count": int(b)
  })

elm.sort(key=lambda e: (e["element"], e["order"]))
for i in range(len(elm)):
  placed = e["count"]
  if placed >= K:
    print(e["element"])
    break
Problem p03814 (python)

Fixed submission:
s = input()
 
posA = 0
posZ = 0
 
for i in range(len(s)):
  if s[i] == "A":
    posA = i
    break
for j in range(len(s)):
  if s[-j-1] == "Z":
    posZ = len(s) - 1 - j
    break
 
print(posZ - posA + 1)

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

posA = 0
posZ = 0

for i in range(len(s)):
  if s[i] == "A":
    posA = i
    break
for j in range(len(s)):
  if s[-j-1] == "Z":
    posZ = N - 1 - j
    break

print(posZ - posA + 1)