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

Fixed submission:
import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  G = [['#' == x for x in input()] for _ in range(H)]
 
  black = deque([(i, j) for i in range(H) for j in range(W) if G[i][j]])
 
  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not G[bi - 1][bj]:
        G[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not G[bi][bj - 1]:
        G[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not G[bi + 1][bj]:
        G[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not G[bi][bj + 1]:
        G[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import copy
from collections import deque
def main():
  H, W = map(int, input().split())
  G = [['#' == x for x in input()] for _ in range(H)]
 
  black = deque([(i, j) for i in range(H) for j in range(W) if M[i][j]])
 
  ans = 0
  while True:
    ans += 1
    next_black = deque()
    while black:
      bi, bj = black.popleft()
      if bi > 0 and not M[bi - 1][bj]:
        G[bi - 1][bj] = True
        next_black.append((bi - 1, bj))
      if bj > 0 and not M[bi][bj - 1]:
        G[bi][bj - 1] = True
        next_black.append((bi, bj - 1))
      if bi < H - 1 and not M[bi + 1][bj]:
        G[bi + 1][bj] = True
        next_black.append((bi + 1, bj))
      if bj < W - 1 and not M[bi][bj + 1]:
        G[bi][bj + 1] = True
        next_black.append((bi, bj + 1))
    if next_black:
       black = copy.copy(next_black)
    else:
       break
  print(ans - 1)
  
if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
from collections import deque
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def main():
  H, W = map(int, input().split())
  M = [['#' == x for x in input()] for _ in range(H)]
  que = deque([[i, j] for i in range(H) for j in range(W) if M[i][j]])
  ans = 0
  while que:
    qq = []
    ans += 1
    for nh, nw in que:
      if nw+1<=W-1 and not M[nh][nw+1]:
        qq.append([nh,nw+1])
        M[nh][nw+1] = True
      if  0<=nw-1 and not M[nh][nw-1]:
        qq.append([nh,nw-1])
        M[nh][nw-1] = True
      if nh+1<=H-1 and not M[nh+1][nw]:
        qq.append([nh+1,nw])
        M[nh+1][nw] = True
      if 0<=nh-1 and not M[nh-1][nw]:
        qq.appenad([nh-1,nw])
        M[nh-1][nw] = True
    que = qq
  print(ans-1)

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

Fixed submission:
ab = list(map(int, input().split()))
a = max(ab)
b = min(ab)
r = a%b
while r!=0:
    a = b
    b = r
    r = a%b
print(int(max(ab) * min(ab)/b))

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
ans = 1
while True:
    if (ans%a + ans%b) == 0:
        print(ans)
        break
    ans += 1
Problem p02832 (python)

Fixed submission:
n = int(input())
a_l = list(map(int, input().split()))
if min(a_l) !=1:
    print(-1)
    exit()
else:
    ans = 1
    for i in a_l:
        if i == ans:
            ans += 1
print(n-ans+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_l = list(map(int, input().split()))
if min(a_l) !=1:
    print(-1)
else:
    ans = 1
    for i in a_l:
        if i == ans:
            ans += 1
print(n-ans+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a_l = list(map(int, input().split()))
if min(a_l) !=1:
    print(-1)
else:
    i = 1
    a_l = a_l[a_l.index(i)+1:]
    i += 1
    while True:
        if a_l.count(i) > 0:
            a_l = a_l[a_l.index(i)+1:]
            i += 1
        else:
            break
print(n - (i-1))
Problem p02773 (python)

Fixed submission:
N = int(input())
l = {}
for _ in range(N):
  s = input()
  l.setdefault(s, 0)
  l[s] += 1
l = sorted([(v, k) for k, v in l.items()])
c = l[-1][0]
r = []
for i in range(-1, -len(l)-1, -1):
  if l[i][0] < c:
    break
  r.append(l[i][1])
for x in reversed(r):
  print(x)

Buggy submission (verdict: Runtime Error):
N, K = [int(x) for x in input().split(' ')]
A = [int(x) for x in input().split(' ')]
r = sorted([A[i] * A[j] for i in range(N) for j in range(i+1, N)])
print(r[K-1])
Problem p02759 (python)

Fixed submission:
N=int(input())                                          # 1行1列


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

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())                            # 1行2列
List=[list(map(int,input().split())) for i in range(M)] # N行C列・・・Cは任意


if N == 1:
	answer = ' '
elif N == 2:
	answer = '  '
elif N == 3:
	answer = '   '

ok = 0
for search in List:
	# search[0]:桁数
	# search[1]:値
	if answer[search[0]-1] == str(search[1]) or answer[search[0]-1] == ' ':
		if N != 1 and search[0] == 1 and search[1] == 0:
			ok = -1
			break
		else:
			anslist = list(answer)
			anslist[search[0]-1] = str(search[1])
			answer = ''.join(anslist)
	else:
		ok = -1
		break

if ok == -1:
	print(-1)
else:
	for i in range(N):
		if answer[i] == ' ':
			anslist = list(answer)
			
			if i == 0 and N != 1:
				anslist[i] = '1'
			else:
				anslist[i] = '0'
			
			answer = ''.join(anslist)
	print(answer)
Problem p02777 (python)

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

if a==e:
	c = c - 1
else:
	d = d - 1

print(c,d)

Buggy submission (verdict: Runtime Error):
def main():
	all,rolls=map(int,input().split())
	List=list(map(int,input().split()))

	sum = 0
	sumList =[]

	for i in range(all - rolls + 1):
		sum = 0
		for j in range(rolls):
			sum = sum + (List[i + j] + 1) / 2
		sumList.append(sum)

	sumList.sort(reverse=True)
	print(sumList[0])

if __name__ == '__main__':
	main()

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

all,rolls=map(int,input().split())
List=list(map(int,input().split()))

sum = 0
sumList =[]

for i in range(all - rolls + 1):
	sum = 0
	for j in range(rolls):
		sum = sum + (List[i + j] + 1) / 2
	sumList.append(sum)

sumList.sort(reverse=True)
print(sumList[0])

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

all,rolls=map(int,input().split())
List=list(map(int,input().split()))

sum = 0
sumList =[]

for i in range(all - rolls + 1):
	sum = 0
	for j in range(rolls):
		sum = sum + (List[i + j] + 1) / 2
	sumList.append(sum)

sumList.sort(reverse=True)
print(sumList[0])

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

sum = 0
sumList =[]

for i in range(all - rolls + 1):
	sum = 0
	for j in range(rolls):
		sum = sum + (List[i + j] + 1) / 2
	sumList.append(sum)

sumList.sort(reverse=True)
print(sumList[0])
Problem p02753 (python)

Fixed submission:
S = input()
if S == "AAA" or S == "BBB" :
    print("No")
else :
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
S = input()
if S = "AAA" or "BBB" :
    print("Yes")
else :
    print("No")
Problem p02862 (python)

Fixed submission:
X, Y = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    X = 1
    Y = 1
    for i in range(1,r+1):
        X = (X*(n-i+1))%mod
        Y = (Y*i)%mod
    return (X*pow(Y, mod-2, mod))%mod

if (X+Y)%3 != 0 :
    print(0)
elif X < (X+Y)//3 or Y < (X+Y)//3 :
    print(0)
else :
    i = X - (X+Y)//3
    print(comb((X+Y)//3, i, mod))

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

dp = [[0]*(Y+1) for i in range(X+1)]
dp[0][0] = 1

for i in range(X+1) :
    for j in range(Y+1) :
        if i >= 1 and j >= 2 :
            dp[i][j] = (dp[i][j] + dp[i-1][j-2])%mod
        if i >= 2 and j >= 1 :
            dp[i][j] = (dp[i][j] + dp[i-2][j-1])%mod

print(dp[X][Y])
Problem p02754 (python)

Fixed submission:
import math
N, A, B = [int(i) for i in input().split()]
if A == 0 and B == 0:
    print(0)
else:
    count = A + B
    setCount = math.floor(N / count)
    amari = N - setCount * count
    if amari > 0:
        if A > amari:
            result = setCount * A + amari
        else:
            result = setCount * A + A
    else:
        result = setCount * A
    print(result)

Buggy submission (verdict: Runtime Error):
N, A, B = [int(i) for i in input().split()]
S = 'b' * A + 'r' * B
if A == 0 and B == 0:
    print(0)
else:
    while len(S) < N:
        S += S
    print(S[0:N].count('b'))

Buggy submission (verdict: Runtime Error):
N, A, B = [int(i) for i in input().split()]
S = 'b' * A + 'r' * B
while len(S) < N:
    S += S

print(S[0:N].count('b'))
Problem p02785 (python)

Fixed submission:
N, K = [int(i) for i in input().split()]
H = list(map(int, input().split()))

# 昇順にソート
H.sort()

if K >= len(H):
    print("0")
else:
    for i in  range(K):
        H.pop()
    print(sum(H))

Buggy submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
H = list(map(int, input().split()))

# 昇順にソート
H.sort()

for i in  range(K):
    H.pop()

if len(H) > 0:
    print(sum(H))
else:
    print("0")

Buggy submission (verdict: Runtime Error):
N, K = [int(i) for i in input().split()]
H = list(map(int, input().split()))

# 昇順にソート
H.sort()

for i in  range(K):
    H.pop()

print(sum(H))
Problem p02831 (python)

Fixed submission:
import fractions 

A, B = [int(i) for i in input().split()]

result = A * B // fractions.gcd(A, B)
print(result)

Buggy submission (verdict: Runtime Error):
import math

A, B = [int(i) for i in input().split()]

result = (A * B) // math.gcd(A, B)
print(result)
Problem p02793 (python)

Fixed submission:
#500
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

N = int(input())
A = list(map(int,input().split()))
LCM = 0
S = 0

for i in range(N):
    if i == 0:
        LCM = A[0]
    else:
        LCM = lcm(LCM,A[i])

for j in range(N):
    S = S + (LCM // A[j])

S = S % (10**9 + 7)
print(S)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

N = int(input())
A = list(map(int,input().split()))
LCM = 0
S = 0

for i in range(N):
    if i == 0:
        LCM = A[0]
    else:
        LCM = lcm(LCM,A[i])

for j in range(N):
    S = S + (LCM // A[j])

S = S % (10**9 + 7)
print(S)
Problem p02726 (python)

Fixed submission:
from collections import Counter

N, X, Y = map(int, input().split())
g = [[float("inf")] * N for _ in range(N)]

for i in range(1, N+1):
    for j in range(1, N+1):
        g[i-1][j-1] = min([abs(j-i), abs(X-i)+1+abs(Y-j), abs(Y-i)+1+abs(X-j)])

c = Counter()
for i in range(N):
    c.update(g[i][:i])

for i in range(1, N):
    print(c[i])

Buggy submission (verdict: Runtime Error):
from pprint import pprint
from collections import Counter
from functools import lru_cache

N, X, Y = map(int, input().split())

d = [[float("inf")]*N for i in range(N)] 
for i in range(N-1):
    d[i][i+1] = 1
    d[i+1][i] = 1

d[X-1][Y-1] = 1
d[Y-1][X-1] = 1

@lru_cache(maxsize=100000)
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

wf = warshall_floyd(d)
for i in range(N):
    wf[i][i] = 0

c = Counter()
for i in range(N):
    c.update(wf[i][:i])

for i in range(1, N):
    print(c[i])

Buggy submission (verdict: Runtime Error):
from pprint import pprint
from collections import Counter
from functools import lru_cache

N, X, Y = map(int, input().split())

d = [[float("inf")]*N for i in range(N)] 
for i in range(N-1):
    d[i][i+1] = 1
    d[i+1][i] = 1

d[X-1][Y-1] = 1
d[Y-1][X-1] = 1

@lru_cache(maxsize=100000)
def warshall_floyd(d):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

wf = warshall_floyd(d)
for i in range(N):
    wf[i][i] = 0

c = Counter()
for i in range(N):
    c.update(wf[i][:i])

for i in range(1, N):
    print(c[i])
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(A, B)

Buggy submission (verdict: Runtime Error):
S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(f"{A} {B}")
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
hole_ids = {int(input()) - 1: 0 for _ in range(m)}
X = 1000000007


def solve(n, hole_ids):
    # nums = []
    nums = [0] * n
    for i in range(n):
        if i in hole_ids:
            # nums.append(0)
            nums[i] = 0
            continue

        if i == 0:
            # nums.append(1)
            nums[i] = 1
        elif i == 1:
            # 1つ前から1段上がるから2つ前から2個飛ばし
            # nums.append(nums[-1] + 1)
            nums[i] = nums[i-1] + 1
        else:
            # nums.append((nums[-1] % X + nums[-2] % X) % X)
            nums[i] = (nums[i-1] + nums[i-2]) % X
    return nums[-1]


print(solve(n, hole_ids))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
hole_ids = {int(input()) - 1: 0 for _ in range(m)}
X = 1000000007


def solve(n, hole_ids):
    nums = []
    # nums = [0] * n
    for i in range(n):
        if i in hole_ids:
            nums.append(0)
            # nums[i] = 0
            continue

        if i == 0:
            nums.append(1)
            # nums[i] = 1
        elif i == 1:
            # 1つ前から1段上がるから2つ前から2個飛ばし
            nums.append(nums[-1] + 1)
            # nums[i] = nums[i-1] + 1
        else:
            nums.append((nums[-1] % X + nums[-2] % X) % X)
            # nums[i] = (nums[i-1] + nums[i-2]) % X
    return nums[-1]


print(solve(n, hole_ids))
n, m = map(int, input().split())
hole_ids = {int(input()) - 1: 0 for _ in range(m)}
X = 1000000007


def solve(n, hole_ids):
    nums = []
    # nums = [0] * n
    for i in range(n):
        if i in hole_ids:
            nums.append(0)
            # nums[i] = 0
            continue

        if i == 0:
            nums.append(1)
            # nums[i] = 1
        elif i == 1:
            # 1つ前から1段上がるから2つ前から2個飛ばし
            nums.append(nums[-1] + 1)
            # nums[i] = nums[i-1] + 1
        else:
            nums.append((nums[-1] % X + nums[-2] % X) % X)
            # nums[i] = (nums[i-1] + nums[i-2]) % X
    return nums[-1]


print(solve(n, hole_ids))
Problem p03135 (python)

Fixed submission:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(T,X):
    return T/X

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b] = line.split(' ')
    return (int(str_a), int(str_b))

def main():
    a, b = readQuestion()
    answer = solve(a, b)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(T,X):
    return T/X

def readQuestion():
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    X = int(ws[1])
    return (T, X,)

def main():
    solve(*readQuestion())

# Uncomment before submission
 main()

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
print(a/b)

Buggy submission (verdict: Runtime Error):
import sys

def solve(T,X):
    return T/X
    pass


def readQuestion():
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    X = int(ws[1])
    return (T, X,)

def main():
    solve(*readQuestion())

# Uncomment before submission
 main()

Buggy submission (verdict: Runtime Error):
import sys

def solve(T,X):
    return T/X



def readQuestion():
    ws = sys.stdin.readline().strip().split()
    T = int(ws[0])
    X = int(ws[1])
    return (T, X,)

def main():
    solve(*readQuestion())

# Uncomment before submission
 main()
Problem p03265 (python)

Fixed submission:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return str(x3) + ' '  + str(y3) + ' ' + str(x4) + ' ' + str(y4) + ' '

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c), int(str_d))

def main():
    a, b, c, d = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return str(x3) + ' '  + str(y3) + ' ' str(x4) + ' '  str(y4) + ' '

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c), int(str_d))

def main():
    a, b, c, d = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return x3,x4,y3,y4

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c)), int(str_d))

def main():
    a, b, c, d = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a,b,c,d):
    x = c-a
    y = d-b
    x3 = 0
    x4 = 0
    y3 = 0
    y4 = 0
    #print(x,y)
    x3 = c-y
    y3 = d+x
    x4 = x3-x
    y4 = y3-y
    return x3,x4,y3,y4

# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_a, str_b, str_c, str_d] = line.split(' ')
    return (int(str_a), int(str_b), int(str_c)), int(str_d))

def main():
    a, b, c = readQuestion()
    answer = solve(a, b, c, d)
    print(answer)
    
if __name__ == '__main__':
    main()
Problem p02847 (python)

Fixed submission:
S = input()
day = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-day.index(S))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A-2*B > 0:
    print(A-2*B)
else:
    print('0')
Problem p02725 (python)

Fixed submission:
k,n=map(int,input().split())
a=list(map(int,input().split()))
max_d=0
for i in range(n):
    x=0
    if i==n-1:
        if a[0]==0:
            x=k-a[i]
        else:
            x=k-a[i]+a[0]
    else:
        x=a[i+1]-a[i]
    if x>max_d:
        max_d=x
print(k-max_d)

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
    a=list(map(int,input().split()))
    max_d=0
    for i in range(n):
        x=0
        if i==n-1:
           if a[0]==0:
               x=k-a[i]
           else:
               x=k-a[i]+a[0]
        else:
            x=a[i+1]-a[i]
        if x>max_d:
            max_d=x
    print(k-max_d)

Buggy submission (verdict: Runtime Error):
t=int(input())
while(t):
    t-=1
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    max_d=0
    for i in range(n):
        x=0
        if i==n-1:
           if a[0]==0:
               x=k-a[i]
           else:
               x=k-a[i]+a[0]
        else:
            x=a[i+1]-a[i]
        if x>max_d:
            max_d=x
    print(k-max_d)
Problem p02725 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
A += [A[0] + K]
gap = max(y-x for x,y in zip(A, A[1:]))
print(K - gap)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
 
K, N, *A = map(int, read().split())
A.append([A[0] + K])
gap = max(y - x for x, y in zip(A, A[1:]))
print(K - gap)
Problem p02792 (python)

Fixed submission:
N = int(input())

g = [[0] * (10) for _ in range(10)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

print(ans)

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

g = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

print(ans)
Problem p02989 (python)

Fixed submission:
N = int(input())

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])

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

D = sorted([int(v) for v in input().split()])
arc = N // 2
abc = arc - 1
print(D[arc] - D[abc])
Problem p02990 (python)

Fixed submission:
from math import factorial

N, K = [int(_) for _ in input().split()]
# N = 10
MOD = 10 ** 9 + 7

kaijo = [0] * (N + 1)
kaijo[0] = kaijo[1] = 1
for i in range(2, N + 1):
    kaijo[i] = (kaijo[i - 1] * i) % MOD

gyaku = [0] * (N + 1)
gyaku[0] = gyaku[1] = 1

for i in range(2, N + 1):
    # gyaku[i] = (gyaku[i - 1] * pow(i, MOD - 2, MOD)) % MOD
    gyaku[i] = pow(kaijo[i], MOD - 2, MOD)


def calc(n, k):
    # return (kaijo[n] * gyaku[n - k] * gyaku[k]) % MOD
    return factorial(n) // (factorial(n - k) * factorial(k))


def solve():
    for i in range(1, K + 1):
        n = N - K + 1
        k = i
        if k <= n:
            print((calc(n, k) * calc(K - 1, i - 1)) % MOD)
        else:
            print(0)


solve()

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

N, K = [int(_) for _ in input().split()]
# N = 10
MOD = 10 ** 9 + 7

kaijo = [0] * (N + 1)
kaijo[0] = kaijo[1] = 1
for i in range(2, N + 1):
    kaijo[i] = (kaijo[i - 1] * i) % MOD

gyaku = [0] * (N + 1)
gyaku[0] = gyaku[1] = 1

for i in range(2, N + 1):
    # gyaku[i] = (gyaku[i - 1] * pow(i, MOD - 2, MOD)) % MOD
    gyaku[i] = pow(kaijo[i], MOD - 2, MOD)


def calc(n, k):
    # return (kaijo[n] * gyaku[n - k] * gyaku[k]) % MOD
    return factorial(n) // (factorial(n - k) * factorial(k))


def solve():
    for i in range(1, K + 1):
        n = N - K + 1
        k = i
        print((calc(n, k) * calc(K - 1, i - 1)) % MOD)


solve()
Problem p03242 (python)

Fixed submission:
print(input().replace('1','x').replace('9','1').replace('x','9'))

Buggy submission (verdict: Runtime Error):
print(input().translate(str.maketrans({'1':'9','9':'1'}))
Problem p03329 (python)

Fixed submission:
import numpy  as np

N = int(input())

# log_6 10^5 < 7
# log_9 10^5 < 6
# 15 = 1 + 6 + 5
memo = np.zeros((15, N + 1),int)
memo[:, :] = N * 2
memo = memo.tolist()
memo[0][0] = 0

values = []

i = 1
while i <= N:
    values.append(i)
    i *= 6
i = 9
while i <= N:
    values.append(i)
    i *= 9

for i in range(len(values)):
    v = values[i]
    for w in range(N+1):
        if v > w:
            memo[i + 1][w] = memo[i][w]
        else:
            memo[i + 1][w] = min(memo[i][w], memo[i+1][w - v] + 1)
print(int(memo[len(values)][N]))

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

N = int(input())

# log_6 10^5 < 7
# log_9 10^5 < 6
# 15 = 1 + 6 + 5
memo = np.zeros((15, N + 1))
memo[:, :] = N * 2
memo[0][0] = 0

values = []

i = 1
while i <= N:
    values.append(i)
    i *= 6
i = 9
while i <= N:
    values.append(i)
    i *= 9

for i in range(len(values)):
    v = values[i]
    for w in range(N+1):
        if v > w:
            memo[i + 1][w] = memo[i][w]
        else:
            memo[i + 1][w] = min(memo[i][w], memo[i+1][w - v] + 1)
print(int(memo[len(values)][N]))