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

Fixed submission:
def sub():
    N, Hs = [input() for _ in range(2)]
    Hs = [int(e) for e in Hs.split(" ")]
    count = 1
    maxH = Hs[0]
    for i in range(1, int(N)):
        h = Hs[i]
        if h >= maxH:
            count = count + 1
            maxH = h


    print("{}".format(count))

sub()

Buggy submission (verdict: Runtime Error):
def sub():
    N, Hs = [input() for _ in range(2)]
    Hs = [int(e) for e in Hs.split(" ")]
    count = 1
    maxH = Hs[0]
    for i in range(1, N):
        h = Hs[i]
        if h >= maxH:
            count = count + 1
            maxH = h


    print("{}".format(count))

sub()
Problem p03137 (python)

Fixed submission:
n, m = map(int, raw_input().strip().split())
lis = map(int, raw_input().strip().split())
lis = sorted(lis)
lol = []
for i in range(1, m):
    lol.append(lis[i] - lis[i-1])
lol = sorted(lol)
ans = lis[-1] - lis[0]
idx = len(lol) - 1
if idx >= 0:
    for i in xrange(n-1):
        ans -= lol[idx]
        idx-=1
        if idx == -1:
            break
print ans

Buggy submission (verdict: Runtime Error):
n, m = map(int, raw_input().split())
lis = map(int, raw_input().split())
lis = sorted(lis)
lol = []
for i in range(1, m):
    lol.append(lis[i] - lis[i-1])
lol = sorted(lol)
ans = lis[-1] - lis[0]
idx = len(lol) - 1
if idx >= 0:
    for i in xrange(n-1):
        ans -= lol[idx]
        idx-=1
print ans
Problem p03208 (python)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print('0')
else:
    sorted_hs = np.sort(hs)
    try:
        print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k) if not len(sorted_hs[i::k-1]) == 1]))
    except:
        print('0')

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print('0')
else:
    sorted_hs = np.sort(hs)
    print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print(0)
elif k == 1:
    print(0)
else:
    sorted_hs = np.sort(hs)
    print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if list(np.diff(hs)) == list(np.zeros(n-1, dtype=int)):
    print(0)
else:
    sorted_hs = np.sort(hs)
    print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))

if n == k:
    print(max(hs) - min(hs))
else:
    sorted_hs = np.sort(hs)
    print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k)]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n, k = map(int, input().split())
hs = []
for i in range(n):
    hs.append(int(input()))
sorted_hs = np.sort(hs)
print(min([min(np.diff(sorted_hs[i::k-1])) for i in range(k)]))
Problem p03426 (python)

Fixed submission:
def list_1d(d,v):
    return [ v for i in range(d)]

def abs(c): 
    if c > 0: 
        return c 
    else: 
        return -c

def distance_2d(a,b):
    return(abs(a[0]-b[0])+abs(a[1]-b[1]))

h,w,d = [int(i) for i in input().split()]
sa = list_1d(h*w+1,[])
da = list_1d(h*w+1,0)
for i in range(h):
    a = [int(k) for k in input().split()]
    for j in range(w):
        sa[a[j]] = [i,j]
q = int(input())
lr = [[int(i) for i in input().split()] for i in range(q)]

for i in range(d+1,h*w+1):
    da[i] = da[i-d] + distance_2d(sa[i],sa[i-d])

for i in range(0,q):
    print(da[lr[i][1]]-da[lr[i][0]])

Buggy submission (verdict: Runtime Error):
b = str(input()).split()
h = int(b[0])
w = int(b[1])
d = int(b[2])
c =[]

def abs(a,b):
    if a > b:
        return(a-b)
    else:
        return(b-a)

for i in range(0,h):
    c.append(str(input()).split())

q = int(input())
lr = []
energy = 0



for i in range(0,q):
    lr.append(str(input()).split())

for i in range(0,q):
    l = int(lr[i][0])
    r = int(lr[i][1])
    for j in range(0,h):
        for k in range(0,w):
            if int(c[j][k]) == l:
                li = j
                lj = k
            if int(c[j][k]) == l + d:
                di = j
                dj = k
        if l != r:
            energy += abs(li,di) + abs(lj,dj)
            l += d
        else:
            print(energy)
            break
Problem p03107 (python)

Fixed submission:
S = input()
import re
if len(S) > 1:
    print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
S = input()
print(min(len(re.findall('0', S)), len(re.findall('1', S))) * 2 if len(S) > 1 else 0)
Problem p03053 (python)

Fixed submission:
from collections import deque
import copy

def main():
  H, W = map(int, input().split())
  maps = [[j=="#" for j in input()] for i in range(H)]
  q = deque([(i, j) for i in range(H) for j in range(W) if maps[i][j]])
  count = 0
  while True:
    nq = deque()
    while q:
      x, y = q.popleft()
      if x > 0 and not maps[x-1][y]:
        maps[x-1][y] = True
        nq.append((x-1,y))
      if y > 0 and not maps[x][y-1]:
        maps[x][y-1] = True
        nq.append((x,y-1))
      if x < H-1 and not maps[x+1][y]:
        maps[x+1][y] = True
        nq.append((x+1,y))
      if y < W-1 and not maps[x][y+1]:
        maps[x][y+1] = True
        nq.append((x,y+1))
    if nq:
      q = copy.copy(nq)
    else:
        break
    count += 1
  print(count)

if __name__ == "__main__":
  main()

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

H, W = list(map(int, input().split()))
field = [input() for _ in range(H)]
dist = [[5000] * W for _ in range(H)]

def bfs():
  q = deque()
  for y in range(H):
    for x in range(W):
      if field[y][x] == '#':
        q.append((y, x))
        dist[y][x] = 0
  while len(q) > 0:
    y, x = q.popleft()
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
      ny, nx = y + dy, x + dx
      if ny < 0 or ny >= H or nx < 0 or nx >= W:
        continue
      if field[ny][nx] == '#':
        continue
      if dist[ny][nx] < dist[y][x] + 1:
        continue
      dist[ny][nx] = dist[y][x] + 1
      q.append((ny, nx))
      
bfs()
print(max([max[i] for i in dist]))

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

H, W = list(map(int, input().split()))
field = [input() for _ in range(H)]
dist = [[5000] * W for _ in range(H)]

def bfs():
  q = deque()
  for y in range(H):
    for x in range(W):
      if field[y][x] == '#':
        q.append((y, x))
        dist[y][x] = 0
  while len(q) > 0:
    y, x = q.popleft()
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
      ny, nx = y + dy, x + dx
      if ny < 0 or ny >= H or nx < 0 or nx >= W:
        continue
      if field[ny][nx] == '#':
        continue
      if dist[ny][nx] < dist[y][x] + 1:
        continue
      dist[ny][nx] = dist[y][x] + 1
      q.append((ny, nx))
      
bfs()
print(np.max(np.asarray(dist).flatten()))
Problem p03805 (python)

Fixed submission:
from collections import deque

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
  a, b = list(map(int, input().split()))
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
ans = 0
v = 0
s = 1
l = 1
q = deque()
q.append((v, s, l))

while q:
  v, s, l = q.popleft()
  if l == N:
    ans += 1
    continue
  for nv in G[v]:
    if s&(1<<nv) == 0:
      q.append((nv, s|(1<<nv), l+1))
print(ans)

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

N, M = list(map(int, input().split()))
G = [[] for _ in range(N)]
for _ in range(M):
  a, b = list(map(int, input().split()))
  G[a-1].append(b-1)
  G[b-1].append(a-1)
  
ans = 0
v = 0
s = 1
l = 1
q = deque()
q.append((v, s, l))

while q:
  v, s, l = q.popleft()
  if l == N:
    ans += 1
    continue
  for nv in G[v]:
    if s&(1<<n) == 0:
      q.append((nv, s|(1<<n), l+1))
print(ans)
Problem p03107 (python)

Fixed submission:
S = input()

if len(S) == 0:
    print(0)

else:
    # 1の数
    s = 0
    for i in range(len(S)):
        s += int(S[i])

    print(min(s, len(S)-s)*2)

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

if len(S) == 0:
    print(0)

else:
    # 見つけ次第消していく
    c = 0 # 消したキューブの数
    i = 1
    while i < len(S):
        if int(S[i-1]) + int(S[i]) == 1:
            S = S[:i-1] + S[i+1:]
            i -= 1
            c += 2
        else:
            i += 1

    print(c)
Problem p03127 (python)

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

# 最大公約数が答え

import fractions
import functools

print(functools.reduce(fractions.gcd, A))

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

# 最大公約数が答え

import math
import functools

print(functools.reduce(math.gcd, A))
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

a = input().split()
N = int(a[0])
M = int(a[1])

l = []
f = []
for i in range(N):
	temp = []
	l.append(temp)
	f.append(0)

for i in range(M):
	b = input().split()
	X = int(b[0]) - 1
	Y = int(b[1]) - 1
	l[X].append(Y)
	l[Y].append(X)

def search(cnt, li, flag, num):
	if(flag[num] == 0):
		flag[num] = cnt
		if(len(li[num]) != 0):
			for i in range(len(li[num])):
				search(cnt, li, flag, li[num][i])
		
cnt = 0
for i in range(N):
	if(f[i] == 0):
		cnt += 1
		search(cnt, l, f, i)			
print(cnt)

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

a = input().split()
N = int(a[0])
M = int(a[1])

l = []
f = []
for i in range(N):
	temp = []
	l.append(temp)
	f.append(0)

for i in range(M):
	b = input().split()
	X = int(b[0]) - 1
	Y = int(b[1]) - 1
	l[X].append(Y)
	l[Y].append(X)

def search(cnt, li, flag, num):
	if(flag[num] == 0):
		flag[num] = cnt
		if(len(li[num]) != 0):
			for i in range(len(li[num])):
				search(cnt, li, flag, li[num][i])
		
cnt = 0
for i in range(N):
	if(f[i] == 0):
		cnt += 1
		search(cnt, l, f, i)			
print(cnt)

Buggy submission (verdict: Runtime Error):
a = input().split()
N = int(a[0])
M = int(a[1])

l = []
f = []
for i in range(N):
	temp = []
	l.append(temp)
	f.append(0)

for i in range(M):
	b = input().split()
	X = int(b[0]) - 1
	Y = int(b[1]) - 1
	l[X].append(Y)
	l[Y].append(X)

def search(cnt, li, flag, num):
	if(flag[num] == 0):
		flag[num] = cnt
		if(len(li[num]) != 0):
			for i in range(len(li[num])):
				search(cnt, li, flag, li[num][i])
		
cnt = 0
for i in range(N):
	if(f[i] == 0):
		cnt += 1
		search(cnt, l, f, i)			
print(cnt)

Buggy submission (verdict: Runtime Error):
a = input().split()
N = int(a[0])
M = int(a[1])

l = []
f = []
for i in range(N):
	temp = []
	l.append(temp)
	f.append(0)

for i in range(M):
	b = input().split()
	X = int(b[0]) - 1
	Y = int(b[1]) - 1
	l[X].append(Y)
	l[Y].append(X)

def search(cnt, li, flag, num):
	if(flag[num] == 0):
		flag[num] = cnt
		if(len(li[num]) != 0):
			for i in range(len(li[num])):
				search(cnt, li, flag, li[num][i])
		
cnt = 0
for i in range(N):
	print(f)
	if(f[i] == 0):
		cnt += 1
		search(cnt, l, f, i)			
print(cnt)
Problem p03775 (python)

Fixed submission:
import math

N = int(input())

sosuu = 1
B = 1
for i in range(1,int(math.sqrt(N)+1)):
    if N % i == 0:
        sosuu = i
        B = N // i

print(len(str(max(sosuu, B))))

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

sosuu = 1
for i in range(1,int(math.sqrt(N+1))):
    if N % i == 0:
        sosuu = i
        B = N // i

print(len(str(max(sosuu, B))))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

sosuu = 1
for i in range(1,int(math.sqrt(N))):
    if N % i == 0:
        sosuu = i
        B = N // i

print(len(str(max(sosuu, B))))
Problem p03107 (python)

Fixed submission:
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeros += 1
print(2*min(ones, zeros))

Buggy submission (verdict: Runtime Error):
string = input()
ones = 0
zeros = 0
for s in string:
  if s == '1':
    ones += 1
  else:
    zeroes += 1
print(2*min(ones, zeros))
Problem p03272 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

from sys import stdin
import numpy as np

N, i = map(int, raw_input().split() )
print N-i + 1

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

N, i = map(int, raw_input().split() )
print n-1 + 1
Problem p03072 (python)

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


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))

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


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))

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


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))

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


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))

Buggy submission (verdict: Runtime Error):
N = int(input())
heights = [input().split() for _ in range(N)]


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))

Buggy submission (verdict: Runtime Error):
N = int(input())
heights = [input().split() for _ in range(N)]


def can_get_ocean_view(subheights):
    return 1 if max(subheights) == subheights[-1] else 0


def count_hotels_with_ocean_view(heights):
    hotels_with_ocean_view = [can_get_ocean_view(heights[:i]) for i in range(1, len(heights)+1)]
    return sum(hotels_with_ocean_view)


print(count_hotels_with_ocean_view(heights))
Problem p03073 (python)

Fixed submission:
tiles = list(map(int, input()))
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        if tile == color:
            counts = counts + 1
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Buggy submission (verdict: Runtime Error):
# tiles = list(map(int, input()))
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        if tile == color:
            counts = counts + 1
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Buggy submission (verdict: Runtime Error):
tiles = map(int, input())
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else 0
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))

Buggy submission (verdict: Runtime Error):
tiles = map(int, input().split())
# inputs = "10010010"
# tiles = list(map(int, inputs))


def count_repaint_tiles(tiles):
    if len(tiles) == 0:
        return 0
    counts = 0
    color = tiles[0]
    for tile in tiles[1:]:
        counts = counts + 1 if tile != color else 0
        color = 1 - color
    return counts


print(count_repaint_tiles(tiles))
Problem p03127 (python)

Fixed submission:
from fractions import gcd

n = int(input())
hp_list = list(map(int,input().split()))
test = hp_list[0]

for i in range(n-1):
    test = gcd(test , hp_list[i+1])
    
print(test)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
hp_list = list(map(int,input().split()))
gcd = hp_list[0]

for i in range(n-1):
    gcd = math.gcd(gcd , hp_list[i+1])
    
print(gcd)
Problem p03137 (python)

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

if n >= m:
    print(0)
else:
    for i in range(len(locations) - 1):
        distance.append(locations[i+1] - locations[i])
    
    distance = sorted(distance)

    if n != 1:
        for i in range(n-1):
            distance.pop()
    
    print(sum(distance))

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

if m == 1:
    print(0)
else:
    for i in range(len(locations) - 1):
        distance.append(locations[i+1] - locations[i])
    
    distance = sorted(distance)

    if n != 1:
        for i in range(n-1):
            distance.pop()
    
    print(sum(distance))

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

if m == 1:
    print(0)
else:
    for i in range(len(locations) - 1):
        distance.append(locations[i+1] - locations[i])
    
    distance = sorted(distance)

    for i in range(n-1):
        distance.pop()
    
    print(sum(distance))

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

for i in range(len(locations) - 1):
    distance.append(locations[i+1] - locations[i])
    
distance = sorted(distance)

for i in range(n-1):
    distance.pop()
    
print(sum(distance))
Problem p03272 (python)

Fixed submission:
n,i = list(map(int,input().split()))
print(n-i+1)

Buggy submission (verdict: Runtime Error):
n,i = list(map,int(input().split()))
print(n-i+1)
Problem p03107 (python)

Fixed submission:
s = input()
 
ans = 0
stack = []
 
for c in s:
  if stack == []:
    stack.append(c)
    continue
  if c != stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)

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

ans = 0
stack = [s[0]]

for c in s[1:-1]:
  if c == stack[-1]:
    ans += 2
    stack.pop(-1)
  else:
    stack.append(c)
    
print(ans)
Problem p03055 (python)

Fixed submission:
from sys import stdin, stdout

def main():
    N = (int)(stdin.readline())
    graph = dict()
	
    if N == 1:
      print("First")
      return
    if N == 2:
      print("Second")
      return
    
    for i in range(N-1):
        edge = stdin.readline().split()
        ai = (int)(edge[0])
        bi = (int)(edge[1])

        if ai in graph.keys():
            graph[ai].append(bi)
        else:
            graph[ai] = [bi]
        
        if bi in graph.keys():
            graph[bi].append(ai)
        else:
            graph[bi] = [ai]

    mid_node = bfs(graph, 1)[0]
    
    longest_path = bfs(graph, mid_node)[1]
    
    if longest_path % 3 == 1:
        print("Second")
    else:
        print("First")

def bfs(graph, node):

    result = -1
    last_level = set()
    visited = set()

    last_level.add(node)
    visited.add(node)

    length = 0

    while len(last_level) > 0:
        
        new_level = set()

        length += 1

        for last_node in last_level:
            result = last_node
            for neighbor in graph[last_node]:
                if neighbor not in visited:
                    new_level.add(neighbor)
                    visited.add(neighbor)
        last_level = new_level
    
    return result, length - 1

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin, stdout

def main():
    N = (int)(stdin.readline())
    graph = dict()

    for i in range(N-1):
        edge = stdin.readline().split()
        ai = (int)(edge[0])
        bi = (int)(edge[1])

        if ai in graph.keys():
            graph[ai].append(bi)
        else:
            graph[ai] = [bi]
        
        if bi in graph.keys():
            graph[bi].append(ai)
        else:
            graph[bi] = [ai]

    mid_node = bfs(graph, 1)[0]
    
    longest_path = bfs(graph, mid_node)[1]
    
    if longest_path % 3 == 1:
        print("second")
    else:
        print("first")

def bfs(graph, node):

    result = -1
    last_level = set()
    visited = set()

    last_level.add(node)
    visited.add(node)

    length = 0

    while len(last_level) > 0:
        
        new_level = set()

        length += 1

        for last_node in last_level:
            result = last_node
            for neighbor in graph[last_node]:
                if neighbor not in visited:
                    new_level.add(neighbor)
                    visited.add(neighbor)
        last_level = new_level
    
    return result, length - 1

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

Fixed submission:
import numpy as np


def solve():
    h, w = map(int, input().split(' '))
    max_value = h + w
    values = []
    for i in range(h):
        values.append([0 if i == '#' else max_value for i in list(input())])
    values = np.array(values)

    for x in range(w - 1):
        values[:, x+1] = np.minimum(values[:, x] + 1, values[:, x+1])
    for x in range(w - 1, 0 , -1):
        values[:, x-1] = np.minimum(values[:, x-1], values[:, x] + 1)
    for x in range(h - 1):
        values[x+1, :] = np.minimum(values[x, :] + 1,values[x+1, :])
    for x in range(h - 1, 0, -1):
        values[x-1, :] = np.minimum(values[x, :] + 1, values[x-1, :])
    print(np.max(values))


solve()

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

h, w = map(int, input().split(' '))
a = [input() for _ in range(h)]
d = [[float('inf') for _ in range(w)] for _ in range(h)]
move = [(1, 0), (-1, 0), (0, 1), (0, -1)]

que = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            d[i][j] = 0
            if (i + 1 < h and a[i+1][j] == '.') or (i - 1 >= 0 and a[i-1][j] == '.') or (j + 1 < w and a[i][j+1] == '.') or (j - 1 >= 0 and a[i][j-1] == '.'):
                que.append((i, j))


while len(que) > 0:
    y, x = que.pop(0)

    for dy, dx in move:
        ny = y + dy
        nx = x + dx

        if (ny >= 0 and ny < h) and (nx >= 0 and nx < w) and a[ny][nx] == '.' and d[ny][nx] == float('inf'):
            d[ny][nx] = d[y][x] + 1
            if (ny + 1 < h and a[ny + 1][nx] == '.') or (ny - 1 >= 0 and a[ny - 1][nx] == '.') or (nx + 1 < w and a[ny][nx + 1] == '.') or (nx - 1 >= 0 and a[ny][nx - 1] == '.'):
                que.append((ny, nx))

print(np.max(d))
Problem p03307 (python)

Fixed submission:
a = input()
a = int(a)
if a%2 ==0:print(a)
else:print(2*a)

Buggy submission (verdict: Runtime Error):
a = int(print())
if a%2 ==0:print(a)
else:print(2*a)

Buggy submission (verdict: Runtime Error):
a = print()
if a%2 ==0:print(a)
else:print(2*a)