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

Fixed submission:
from collections import deque
H,W = map(int, input().split())
A = 0
dp = [None] * H
mat = [None] * (H*W)
matS = matE = 0
for h in range(H):
    s = list(input())
    for w, x in zip(range(W), s):
        if x == "#":
            mat[matE] = (h, w, 0)
            matE+=1
    dp[h] = s

def search(dp, mat, nH, nW, cnt):
    global matE
    if dp[nH][nW] == ".":
        mat[matE] = (nH, nW, cnt+1)
        matE+=1
        dp[nH][nW] = "#"

while matS < matE:
    h, w, cnt = mat[matS]
    matS += 1

    if h > 0:
        search(dp, mat, h - 1, w, cnt)
    if h < H-1:
        search(dp, mat, h + 1, w, cnt)
    if w > 0:
        search(dp, mat, h , w - 1, cnt)
    if w < W-1:
        search(dp, mat, h , w + 1, cnt)

print(cnt)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
A = []
for _ in range(H):
    A += [ [ 1 if x == "#" else 0 for x in input()] ]

import numpy as np


A = np.array(A)
WK = np.zeros(A.shape)
i = 0
S = H * W
while True:
    if np.min(A) == 1:
        break
    WK -= WK
    WK += A
    A[:-1] |= WK[1:]
    A[1:] |= WK[:-1]
    A[:,:-1] |= WK[:,1:]
    A[:,1:] |= WK[:,:-1]
    i += 1

print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
h, w = map(int, input().split())

M = h + w
data = np.ones((h+2, w+2), np.int16) * M
for ln in range(1, h+1):
    line = list(input().rstrip())
    for r, letter in zip(range(1, w+1), line):
        if letter == '#':
            data[ln,r] = 0

data = data.reshape((w,h))

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
A = []
for _ in range(H):
    A += [ [ x == "#" for x in input()] ]

import numpy as np
from scipy import ndimage
A = np.array(A, dtype= np.bool)
B = np.zeros(A.shape, dtype=np.bool)
i = 0
S = H * W
struct = ndimage.generate_binary_structure(2, 1)
while True:
    if np.alltrue(A):
        break
    ndimage.binary_dilation(A, structure=struct, output=B)
    A, B = B, A

    i += 1

print(i)
Problem p03135 (python)

Fixed submission:
T,X = map(int, input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
T,X = map(input().split())
print(T/X)
Problem p03208 (python)

Fixed submission:
import heapq

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

h = []
for _ in range(n):
    heapq.heappush(h, int(input()))

q = [heapq.heappop(h) for _ in range(k-1)]

ans = 1e9
for i in range(len(h)):
    p = i % (k-1)
    s = q[p]
    e = heapq.heappop(h)
    q[p] = e
    ans = min(ans, e - s)

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq

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

h = []
for _ in range(n):
    heapq.heappush(h, int(input()))

q = [heapq.heappop(h) for _ in range(k-1)]

ans = 1e9
while len(h):
    p = i % (k-1)
    s = q[p]
    e = heapq.heappop(h)
    q[p] = e
    ans = min(ans, e - s)

print(ans)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
PY = [list(map(int, input().split() +[x])) for x in range(M)]

PY = sorted(PY)

keyP = -1
for i, (P, Y, _) in enumerate(PY):
  if keyP != P:
    keyP = P
    keyNo = 1

  PY[i].append("{:0>6}{:0>6}".format(keyP, keyNo))
  keyNo += 1

for P, Y, _, s in sorted(PY, key=lambda x:x[2]):
  print(s)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(N)]

PY = sorted(PY)

keyP = -1
for P, Y in PY:
  if keyP != P:
    keyP = P
    keyNo = 1

  print("{:0>6}{:0>6}", keyP, keyNo)
  keyNo += 1
Problem p03250 (python)

Fixed submission:
S = "".join(sorted(input().split(), reverse=True))
print(int(S[0:2])+int(S[2]))

Buggy submission (verdict: Runtime Error):
S = sorted(input(), reverse=False)
print(int(S[0:2])+int(S[2]))
Problem p03252 (python)

Fixed submission:
S = input()
T = input()
TS = list(zip(T, S))

TS_set = set()
for t,s in TS:
  TS_set.add((t,s))

S_set = set()
for x in TS_set:
  S_set.add(x[1])

T_set = set()
for x in TS_set:
  T_set.add(x[0])

print("Yes" if S == T or len(TS_set) == len(S_set) == len(T_set) else "No")

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

U = set()
for s, t in sorted(zip(S, T)):
  U.add((s, t))

for x, y in zip(U[0:-1], U[1:]):
  if x == y:
    print("No")
    break
else:
  print("Yes")
Problem p03265 (python)

Fixed submission:
p = list(map(int, input().split()))
ps = list(zip(p[::2], p[1::2]))

ans = ""
for _ in range(2):
  v = list(map(lambda x, y: x - y, ps[1], ps[0]))
  v = [-v[1], v[0]]
  ps = [ps[1], list(map(lambda x, y: x + y, ps[1], v))]
  ans += " " + " ".join(map(str, ps[1]))

print(ans[0:])

Buggy submission (verdict: Runtime Error):
import numpy as np
p = map(int, input().split())
ps = list(map(lambda x, y: np.array([x, y]), p[::2], p[1::2]))+ [None, None]

ans = ""
for s, d, i in zip(ps[0:-1], ps[1:], range(2,4)):
  v = d - s
  s = d
  d = s + v.dot([[0,1], [-1,0]])
  ans += " ".join(map(str, d))
  ps[i] = d
print(ans[1:])
Problem p03617 (python)

Fixed submission:
VS = [(Y, Y*(2//q), q) for Y, q in zip(map(int, input().split()), (0.25, 0.5, 1, 2))]
N = int(input())
#print(VS)
tanka = 0
for Y, _, q in sorted(VS, key=lambda x:x[1], reverse=False):
  u = N // q
  N -= q * u
  #print((q, u))
  tanka += Y * int(u)
  if N <= 0:
    break
 
print(tanka)

Buggy submission (verdict: Runtime Error):
VS = [(Y, Y*(2/q), q) for Y, q in ((int(input()), q) for q in (0.25, 0.5, 1, 2))]
N = int(input())
tanka = 0
for Y, _, q in sorted(VS, key=lambda x:x[1], reverse=True):
  u = N // q
  N -= q * u
  tanka += Y * u
  if N <= 0:
    break

print(tanka)
Problem p03723 (python)

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

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
while True:
	if any([A % 2, B % 2, C % 2]):
		break
	A, B, C = B // 2 + C // 2, A // 2 + C // 2, A // 2 + B // 2
	count += 1
print(count)

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

if any([A % 2, B % 2, C % 2]):
	print(0)
	exit()

if A == B == C:
	print(-1)
	exit()

count = 0
    while all([A % 2 == 0, B % 2 == 0, C % 2 == 0]):
        A, B, C = ((B+C)//2, (A+C)//2, (A+B)//2)
	count += 1
print(count)
Problem p03804 (python)

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

f = lambda x: 1 if x == "#" else 0
A = [list(map(f, input())) for _ in range(N)]
B = [list(map(f, input())) for _ in range(M)]

def func():
  for i in range(N-M+1):
    for j in range(N-M+1):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

print("Yes" if func() else "No")

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  char A[50][50], B[50][50];
  for(int i=0; i<N; ++i) scanf("%s", &A[i][0]);
  for(int i=0; i<M; ++i) scanf("%s", &B[i][0]);
  for(int Ay=0; Ay<=N-M; ++Ay)for(int Ax=0; Ax<=N-M; ++Ax)
      if([&](int x, int y){
        for(int i = 0, j = 0; i < M; i+= j >= M ? j=0,1 :j++,0)
          if(A[x+i][y+j] != B[i][j]) return 0;
        return 1;
      }(Ax, Ay))
      {
        cout << "Yes" << endl;
        return 0;
      }
  cout << "No" << endl;
  return 0;
}

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

A = [list(map(int, input())) for _ in range(N)]
B = [list(map(int, input())) for _ in range(M)]

def func():
  for i in range(N-M):
    for j in range(N-M):
      if all(A[i+k][j+l] == B[k][l] for k in range(M) for l in range(M)):
        return True
  return False

print("Yes" if func() else "No")
Problem p03835 (python)

Fixed submission:
K, S = map(int, input().split())

cnt = 0

if S <= 0:
  cnt += 1
else:

  if K >= S:
      cnt+=3

  def cnt2(k, s):
      if 2 * k >= s:
          if s - 1 <= k:
              return s-1
          else:
              return k-(s-k)+1
      else:
          return 0

  cnt+=3*cnt2(K, S)

  for x in range(1, K+1):
      if S-x <=0:
          break
      cnt += cnt2(K, S-x)

print(cnt)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
P = list(tuple(map(int, input().split())) for _ in range(N))

M = 0
for i in range(N):
    for j in range(1,N):

        M = max(M, math.sqrt((P[i][0]-P[j][0]) ** 2 + (P[i][1]-P[j][1]) ** 2))

print("{:.6f}".format(M))
Problem p02578 (python)

Fixed submission:
import sys

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

h =[]

if n == 1:
    print(0)
    sys.exit()

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] += (a[0]- a[1]) 
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] += (a[i-1]- a[i]) 
    else:
        h.append(0)
        
print(sum(h))

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] += (a[i-1]- a[i]) 
    else:
        h.append(0)
        
print(sum(h))
Problem p02623 (python)

Fixed submission:
n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0],[0]

for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])


ans, j = 0, m

for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

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

time = 0
cont_a = 0
cont_b = 0

while time <= k:
    if a[cont_a] > b[cont_b]:
        if a[cont_a] < k:
            time += a[cont_a]
            cont_a += 1
        else:
            break
    else:
        if b[cont_b] < k:
            time += b[cont_b]
            cont_b += 1
        else:
            break
print(cont_a + cont_b)
Problem p02689 (python)

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))

cnt_w = [0 for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(m):
    cnt[mj[i][0]-1] += 1
    cnt[mj[i][1]-1] += 1
    if h[mj[i][0]-1] > h[mj[i][1]-1]:
        cnt_w[mj[i][0]-1] += 1
    elif h[mj[i][0]-1] < h[mj[i][1]-1]:
        cnt_w[mj[i][1]-1] += 1

tower = 0
for i in range(n):
    if cnt[i] == cnt_w[i]:
        tower += 1
print(tower)

Buggy submission (verdict: Runtime Error):
point = [0]*n
app = [0]*n
cnt = []

for i in ab:
    app[i[0]-1] += 1
    app[i[1]-1] += 1
    if h[i[0]-1] > h[i[1]-1]:
        point[i[0]-1] += 1
    elif h[i[0]-1] < h[i[1]-1]:
        point[i[1]-1] += 1
for i in range(n):
    if app[i] == point[i]:
        cnt.append(i+1)
print(cnt)

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

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

mj = []

for i in range(m):
    mj.append(list(map(int,input().split())))
    
tower = 0

for i in range(n):
    #自分からのびている道から先にある展望台を探索し、自分iと比較
    cnt = 0
    h_high = 0
    for j in range(m):
        if i+1 in mj[j]:
            cnt += 1
            if i == mj[j][0]-1:
                if h[i] > h[mj[j][1]-1]:
                    h_high += 1
            else:
                if h[i] > h[mj[j][0]-1]:
                    h_high += 1
    if cnt == h_high:
        tower += 1
        
print(len(tower))
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement

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

temp = list(combinations_with_replacement([i for i in range(1,m+1)],n))

ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
        
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product

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

temp = list(combinations([i for i in range(1,m+1)],n))


ans = 0

for a_temp in temp:
    ans_temp = 0
    for i in range(q):
        if a_temp[a[i][1]-1] - a_temp[a[i][0]-1] == a[i][2]:
            ans_temp += a[i][3]
    if ans < ans_temp:
        ans = ans_temp
print(ans)
Problem p02711 (python)

Fixed submission:
n = input()

if n.count("7") > 0:
    print("Yes")
else:
    print("No")

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

k = int(input())
ans = 0

for a in range(1,k+1):
    if i == 1:
        ans += k*k
        continue
    for b in range(1,k+1):
        n = gcd(a,b)
        if n == 1:
            ans += k
            continue
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)
Problem p02879 (python)

Fixed submission:
a,b = map(int,input().split())
print(a*b if a<=9 and b<=9 else -1)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input())
print(a*b if a<=9 and b<=9 else -1)
Problem p03053 (python)

Fixed submission:
from collections import deque

def main():
    h, w = map(int,input().split())
    A = [list(input()) for _ in range(h)]
    B = []

    for i,a in enumerate(A):
        for j,b in enumerate(a):
            if b == "#":
                B.append((i,j))

    dxy = [[1,0],[-1,0],[0,1],[0,-1]]

    stack = deque(B)
    darked = len(stack)
    targetd = h*w
    count = 0

    while darked < targetd:
        nextd = deque([])

        while stack:
            x, y = stack.popleft()
            for dx,dy in dxy:
                X = x + dx
                Y = y + dy
                if not(0 <= X < h) or not(0 <= Y < w):
                    continue
                if A[X][Y]==".":
                    A[X][Y]="#"
                    nextd.append((X,Y))
        count += 1
        stack = nextd
        darked += len(stack)
    print(count)
    
main()

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

def main():
h, w = map(int,input().split())
A = [list(input()) for _ in range(h)]
    B = []

    for i,a in enumerate(A):
        for j,b in enumerate(a):
            if b == "#":
                B.append((i,j))

    dxy = [[1,0],[-1,0],[0,1],[0,-1]]

    stack = deque(B)
    darked = len(stack)
    targetd = h*w
    count = 0

    while darked < targetd:
        nextd = deque([])

        while stack:
            x, y = stack.popleft()
            for dx,dy in dxy:
                X = x + dx
                Y = y + dy
                if not(0 <= X < h) or not(0 <= Y < w):
                    continue
                if A[X][Y]==".":
                    A[X][Y]="#"
                    nextd.append((X,Y))
        count += 1
        stack = nextd
        darked += len(stack)
    print(count)
    
main()
Problem p03137 (python)

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

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:m-n]))

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

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dist[:-(n-1)]))

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

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(m-1)]
    dist = sorted(dist)
    print(sum(dif[:-(n-1)]))

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

if n >= m:print(0)
else:
    dist = [abs(x[i+1] - x[i]) for i in range(M-1)]
    dist = sorted(dist)
    print(sum(dif[:-(n-1)]))

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

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

Buggy submission (verdict: Runtime Error):
n =int(input())
a=list(map(int,input().split())
counter=0
for i in range(n-1):
	if a[i] >a[i+1]:
    	   counter += a[i] -a[i+1]
print(counter)
Problem p02701 (python)

Fixed submission:
N = int(input())

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr)))

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

arr = []

for i in range(N):
    arr.append(input())

print(len(set(arr))

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

arr = []

for i in range(N):
    arr.append(input())

print(len(arr.set()))
Problem p02785 (python)

Fixed submission:
arr = input().split(" ")
H = int(arr[0])
K = int(arr[1])

HPs = input().split(" ")
HPs = [int(i) for i in HPs ]
HPs.sort(reverse=True)

if(K == 0):
    print(sum(HPs))
else:
    print(sum(HPs[K:]))

Buggy submission (verdict: Runtime Error):
arr = input().split(" ")
N = int(arr[0])
K = int(arr[1])

HP_arr = input().split(" ")
HP_arr.sort(reverse=True)
HP_arr = [int(i) for i in HP_arr ]

while(True):
    if(K > 0):
        HP_arr.pop(0)
        K -= 1
    else:
        break

print(sum(HP_arr))
Problem p03055 (python)

Fixed submission:
import sys
sys.setrecursionlimit(250000)
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[[]for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].append(b)
  g[b].append(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])

Buggy submission (verdict: Runtime Error):
def s(x,v,d):
  r=[d,v]
  for u in g[v]:
    if u!=x:
      t=s(v,u,d+1)
      if r[0]<t[0]:r=t
  return r
n,*t=map(int,open(0).read().split())
g=[set()for _ in range(n+1)]
for a,b in zip(t[::2],t[1::2]):
  g[a].add(b)
  g[b].add(a)
print('SFeicrosntd'[s(0,s(0,1,0)[1],0)[0]%3!=1::2])
Problem p02735 (python)

Fixed submission:
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
HW_list = []

for i in range(H):
    HW_list.append(str(input()))

dp = [[H * W] * W] * H

dp[0][0] = 0
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if i == 0:
            min_num_h = H * W
        else:
            min_num_h = dp[i - 1][j] + (0 if HW_list[i][j] == HW_list[i - 1][j] else 1)
        if j == 0:
            min_num_w = H * W
        else:
            min_num_w = dp[i][j - 1] + (0 if HW_list[i][j] == HW_list[i][j - 1] else 1)
        dp[i][j] = min(min_num_h, min_num_w)

print(dp[H - 1][W - 1] // 2 + (1 if HW_list[0][0] == "#" or HW_list[H - 1][W - 1] == "#" else 0))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
HW_list = []

for i in range(H):
    HW_list.append(str(input()))

dp = [[H * W] * H] * W

dp[0][0] = 0
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if i == 0:
            min_num_h = H * W
        else:
            min_num_h = dp[i - 1][j] + (0 if HW_list[i][j] == HW_list[i - 1][j] else 1)
        if j == 0:
            min_num_w = H * W
        else:
            min_num_w = dp[i][j - 1] + (0 if HW_list[i][j] == HW_list[i][j - 1] else 1)
        dp[i][j] = min(min_num_h, min_num_w)

print(dp[H - 1][W - 1] // 2 + (1 if HW_list[0][0] == "#" or HW_list[H - 1][W - 1] == "#" else 0))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
H, W = map(int, input().split())
HW_list = []

for i in range(H):
    HW_list.append(str(input()))

dp = [[H * W] * H] * W

dp[0][0] = 0
for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            continue
        if i == 0:
            min_num_h = H * W
        else:
            min_num_h = dp[i - 1][j] + (0 if HW_list[i][j] == HW_list[i - 1][j] else 1)
        if j == 0:
            min_num_w = H * W
        else:
            min_num_w = dp[i][j - 1] + (0 if HW_list[i][j] == HW_list[i][j - 1] else 1)
        dp[i][j] = min(min_num_h, min_num_w)

print(dp[H - 1][W - 1] // 2 + (1 if HW_list[0][0] == "#" or HW_list[H - 1][W - 1] else 0))
Problem p02831 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# lcm & gcd not math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

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

print(lcm(A, B))

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(A, B))
Problem p02912 (python)

Fixed submission:
# D 終了後再チャレンジ
# -*- coding: utf-8 -*-
import heapq

N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list = [-a for a in A_list]
heapq.heapify(A_list)

for i in range(M):
    max_price = heapq.heappop(A_list) * (-1)
    heapq.heappush(A_list, max_price // 2 * (-1))
    
ans = sum(A_list) * (-1)
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# from collections import deque
import bisect

N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list.sort()
# A_list = deque(A_list)

ans = 0
ans += sum(A_list[0:N - M])
del(A_list[0:N - M])
for i in range(M):
    max_price = A_list.pop()
    bisect.insort(A_list, max_price // 2)
    ans += A_list[0]
    del(A_list[0])
    

ans += sum(A_list)
print(ans)
Problem p03012 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
W_list = list(map(int, input().split()))

lr_sum = 0
for _ in range(N):
    if lr_sum <= 0:
        lr_sum += W_list.pop(0)
    else:
        lr_sum -= W_list.pop(-1)
print(abs(lr_sum))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
W_list = list(map(int, input().split()))

lr_sum = 0
pop_position = 1
for _ in range(N)
    if lr_sum <= 0:
        lr_sum += W_list[pop_position]
    else:
        lr_sum -= W_list[-pop_position]
print(lr_sum)
Problem p02847 (python)

Fixed submission:
a=input()
if a=="MON":
  print("6")
elif a=="SUN":
  print("7")
elif a=="TUE":
  print("5")
elif a=="WED":
  print("4")
elif a=="THU":
  print("3")
elif a=="FRI":
  print("2")
elif a=="SAT":
  print("1")

Buggy submission (verdict: Runtime Error):
a=input()
if a=="MON":
  print("6")
elif a=="SUN":
  ptint("7")
elif a=="TUE":
  print("5")
elif a=="WED":
  print("4")
elif a=="THU":
  print("3")
elif a=="FRI":
  print("2")
else:
  print("1")
Problem p02881 (python)

Fixed submission:
n = int(input())
s=[]
a=0
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      a=n//i
      s.append(n//i+n//a)
print(min(s)-2)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=[]
d=[(0,0)]

for i in range(1,n+1):
  if n%i==0:
    s.append((i-1,n//i-1))

for i in s:
  d.append(i[0]+i[1])

print(min(d))
Problem p02552 (python)

Fixed submission:
N = int(input())
if N ==0:
  print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
N = int(input)
if N ==0:
  print(1)
else:
  print(0)