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

Fixed submission:
n = int(input())
s = [input() for _ in range(2)]

ans = 1
law = 10 ** 9 + 7

i = 0
while i < n:
    if s[0][i] == s[1][i]:
        if i == 0:
            ans *= 3
        else:
            ans *= 3 - len({s[0][i-1], s[1][i-1]})
        i += 1
    else:
        if i == 0:
            ans *= 6
        else:
            if s[0][i-1] == s[1][i-1]:
                ans *= 2
            else:
                ans *= 3
        i += 2
    ans %= law
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [input() for _ in range(2)]
if n == 1:
    print(3)
    exit()
law = 10 ** 9 + 7
dp = [[0 for _ in range(2)] for _ in range(n)] # 直前の色と同じかどうか
dp[0][0] = 3
dp[0][1] = 0
dp[1][0] = 0
dp[1][1] = 6
sideway = s[0][1] == s[0][2]
for i in range(2, n):
    if sideway:
        sideway = False
        if s[0][i-2] == s[1][i-2]: # |=
            dp[i][0] = 0
            dp[i][1] = sum(dp[i-1])
        else: # ==
            dp[i][0] = 0
            dp[i][1] = dp[i-1][0] * 2 + dp[i-1][1]
    else:
        if s[0][i] == s[1][i]:
            sideway = False
            if s[0][i-1] == s[1][i-1]: # ||
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =|
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1])
        else:
            sideway = True
            if s[0][i-1] == s[1][i-1]: # |-
                dp[i][0] = 0
                dp[i][1] = sum(dp[i-1]) * 2
            else: # =-
                dp[i][0] = sum(dp[i-1])
                dp[i][1] = 2 * sum(dp[i-2]) - dp[i][0]
    dp[i][0] %= law
    dp[i][1] %= law
print(sum(dp[i-1]))
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2 * 10 ** 5)

n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]
connect = [set() for _ in range(n)]
for a, b in edge:
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

d1 = [0] * n
dn = [0] * n

def dfs(v, ng, dis, d):
    d[v] = dis
    ng.add(v)
    for n in connect[v]:
        if n not in ng:
            dfs(n, ng, dis+1, d)

dfs(0, set(), 0, d1)
dfs(n-1, set(), 0, dn)

black = 0
white = 0
for i in range(n):
    if d1[i] <= dn[i]:
        black += 1
    else:
        white += 1
if black > white:
    print('Fennec')
else:
    print('Snuke')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5)

n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]
connect = [set() for _ in range(n)]
for a, b in edge:
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

d1 = [0] * n
dn = [0] * n

def dfs(v, ng, dis, d):
    d[v] = dis
    ng.add(v)
    for n in connect[v]:
        if n not in ng:
            dfs(n, ng, dis+1, d)

dfs(0, set(), 0, d1)
dfs(n-1, set(), 0, dn)

black = 0
white = 0
for i in range(n):
    if d1[i] <= dn[i]:
        black += 1
    else:
        white += 1
if black > white:
    print('Fennec')
else:
    print('Snuke')

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5)

n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]
connect = [set() for _ in range(n)]
for a, b in edge:
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

d1 = [0] * n
dn = [0] * n

def dfs(v, ng, dis, d):
    d[v] = dis
    ng.add(v)
    for n in connect[v]:
        if n not in ng:
            dfs(n, ng, dis+1, d)

dfs(0, set(), 0, d1)
dfs(n-1, set(), 0, dn)

black = 0
white = 0
for i in range(n):
    if d1[i] < dn[i]:
        black += 1
    else:
        white += 1
if black > white:
    print('Fennec')
else:
    print('Snuke')

Buggy submission (verdict: Runtime Error):
n = int(input())
edge = [tuple(map(int, input().split())) for _ in range(n-1)]
connect = [set() for _ in range(n)]
for a, b in edge:
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

d1 = [0] * n
dn = [0] * n

def dfs(v, ng, dis, d):
    d[v] = dis
    ng.add(v)
    for n in connect[v]:
        if n not in ng:
            dfs(n, ng, dis+1, d)

dfs(0, set(), 0, d1)
dfs(n-1, set(), 0, dn)

black = 0
white = 0
for i in range(n):
    if d1[i] < dn[i]:
        black += 1
    else:
        white += 1
if black > white:
    print('Fennec')
else:
    print('Snuke')
Problem p03722 (python)

Fixed submission:
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(2*n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if b == n - 1 and z >= n - 1:
                print('inf')
                exit()
print(-dis[n-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(n+1)
    update = False
    for a, b, c in edge:
        a -= 1
        b -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
            if z == n:
                print('inf')
                exit()
print(-dis[n-1])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(m)]

inf = 10 ** 18
dis = [inf] * n
dis[0] = 0

for z in range(n+1):
    update = False
    for a, b, c in edge:
        a -= 1
        a -= 1
        if dis[a] != inf and dis[b] > dis[a] - c:
            dis[b] = dis[a] - c
            update = True
    if not update:
        break

if z == n:
    print('inf')
else:
    print(-dis[n-1])
Problem p03759 (python)

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else: print('NO')

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else: prin('NO')
Problem p03826 (python)

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

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())

print(max(a*b, c*d))
Problem p04000 (python)

Fixed submission:
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 10

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

c[0] = (h-2) * (w-2) - sum(c)

for x in c:
    print(x)

Buggy submission (verdict: Runtime Error):
h, w, n = map(int, input().split())
a = {tuple(map(int, input().split())) for _ in range(n)}

d = {}
c = [0] * 9

def next(x, y):
    ret = []
    for i in range(max(0, x-2), min(h-2, x+1)):
        for j in range(max(0, y-2), min(w-2, y+1)):
            ret.append((i, j))
    return ret

for x, y in a:
    x -= 1
    y -= 1
    for s, t in next(x, y):
        if (s, t) not in d:
            count = 0
            for i in range(3):
                for j in range(3):
                    if (s + i + 1, t + j + 1) in a:
                        count += 1
            d[(s, t)] = count
            c[count] += 1

c[0] = (h-2) * (w-2) - sum(c)

for x in c:
    print(x)
Problem p02646 (python)

Fixed submission:
a,b=map(int,input().split())
c,d=map(int,input().split())
e=int(input())
if abs(a-c)<=e*(b-d):
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
c,d==map(int,input().split())
e=int(input())
if abs(a-c)>e*abs(b-d):
  print('YES')
else:
  print('NO')
Problem p02687 (python)

Fixed submission:
s=input()
if s[1]=='R':
  print('ABC')
else:
  print('ARC')

Buggy submission (verdict: Runtime Error):
s=input()
if s[1]='R':
  print('ABC')
else:
  print('ARC')
Problem p02719 (python)

Fixed submission:
a,b=map(int,input().split())
print(min(a%b,b-a%b))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(min(a%b,(b%(a%b))))
Problem p02727 (python)

Fixed submission:
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[-x:]
q=sorted(list(map(int,input().split())))[-y:]
r=sorted(list(map(int,input().split())))
for i in range(len(p)):
  r.append(p[i])
for i in range(len(q)):
  r.append(q[i])
r=sorted(r)[-x-y:]
print(sum(r))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[-x:]
q=sorted(list(map(int,input().split())))[-y:]
r=sorted(list(map(int,input().split())))
for i in range(len(p)):
  r.append(p[i])
  r.append(q[i])
r=sorted(r)[-x-y:]
print(sum(r))

Buggy submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[-x-y:]
q=sorted(list(map(int,input().split())))[-x-y:]
r=sorted(list(map(int,input().split())))
for i in range(len(p)):
  r.append(p[i])
  r.append(q[i])
r=sorted(r)[-x-y:]
print(sum(r))

Buggy submission (verdict: Runtime Error):
s,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())))[-x-y:]
q=sorted(list(map(int,input().split())))[-x-y:]
r=sorted(list(map(int,input().split())))
for i in range(len(p)):
  r.append(p[i])
  r.append(q[i])
r=sorted(r)[-x-y:]
print(sum(r))
Problem p02747 (python)

Fixed submission:
s=input()
for i in range(1,6):
  if s=='hi'*i:
    print('Yes')
    quit()
print('No')

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(1,6):
  if s=='hi'*i:
  print('Yes')
  quit()
print('No')
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(10**n):
  x=str(i)
  if len(x)<n:pass
  else:
    c=0
    for i in range(m):
      if x[l[i][0]-1]==str(l[i][1]):
        c+=1
    if c==m:
      print(x)
      quit()
print(-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(m):
  a,b=map(int,input().split())
  l.append([a,b])
for i in range(10**(n-1)-1,10**n):
  x=str(i)
  c=0
  for i in range(m):
    if x[l[i][0]-1]==str(l[i][1]):
      c+=1
  if c==m:
    print(x)
    quit()
print(-1)
Problem p02845 (python)

Fixed submission:
n=int(input())
mod=1000000007
l=list(map(int,input().split()))
me=[3]+[0]*2*n
ans=1
for x in l:
  ans=ans*me[x]%mod
  me[x]-=1
  me[x+1]+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=1
mod=1000000007
me=[0,0,0]
now=3
for x in l:
  if x==0:
    ans*now
    now-=1
    if now<0:
      print(0)
      quit()
    me[-now]=1
  else:
    a=len([i for i, y in enumerate(me) if y == x])
    if a>3:
      print(0)
      quit()
    ans=ans*a%mod    
    me[me.index(x)]+=1
if now==0:
  print(6*ans%mod)
else:
  print(3*ans%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=1
mod=1000000007
me=[0,0,0]
now=3
for x in l:
  if x==0:
    ans*now
    now-=1
    if now<0:
      print(0)
      quit()
    me[-now]=1
  else:
    a=len([i for i, y in enumerate(me) if y == x])
    if a>2:
      print(0)
      quit()
    ans=ans*a%mod    
    me[me.index(x)]+=1
if now==0:
  print(6*ans%mod)
else:
  print(3*ans%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=1
mod=10**9+7
me=[0,0,0]
now=3
for x in l:
  if x==0:
    ans*now
    now-=1
    if now<0:
      print(0)
      quit()
    me[-now]=1
  else:
    ans=ans*len([i for i, y in enumerate(me) if y == x])%mod
    me[me.index(x)]+=1
if now==0:
  print(6*ans%mod)
else:
  print(3*ans%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=1
mod=10**9+7
me=[0,0,0]
now=3
for x in l:
  if x==0:
    ans*now
    now-=1
    me[-now]=1
  else:
    ans=ans*len([i for i, y in enumerate(me) if y == x])%mod
    me[me.index(x)]+=1
if now==0:
  print(6*ans%mod)
else:
  print(3*ans%mod)
Problem p03197 (python)

Fixed submission:
n=int(input())
for i in range(n):
  if int(input())%2==1:
    print('first')
    quit()
print('second')

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline()
n=int(input())
for i in range(n):
  if int(input())%2==1:
    print('first')
    quit()
print('second')
Problem p03627 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
import collections
c = collections.Counter(l)
ans1=[]
ans2=[0]
for x in c.keys():
  if c[x]>1:
    ans1.append(x)
  if c[x]>3:
    ans2.append(x)
ans1.sort()
if len(ans1)<2:
  print(0)
else:
  print(max(ans1[-1]*ans1[-2],max(ans2)**2))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
import collections
c = collections.Counter(l)
ans1=[]
ans2=[]
for x in c.keys():
  if c[x]>1:
    ans1.append(x)
  if c[x]>3:
    ans2.append(x)
ans1.sort()
if len(ans1)<2:
  print(0)
else:
  print(max(ans1[-1]*ans1[-2],max(ans2)**2))
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

check = [(-1, 0), (0, -1), (1, 0), (0, 1)]
for j in range(h):
  for i in range(w):
    if grid[j][i] == "#":
      temp = [(i+cx, j+cy) for cx, cy in check if (0<= i+cx <w and 0<= j+cy <h)]
      count = 0
      for t_cx, t_cy in temp:
        if grid[t_cy][t_cx] == "#":
          count += 1
      if count == 0:
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]

check = [(-1, 0), (0, -1), (1, 0), (0, 1)]
for j in range(h):
  for i in range(w):
    if grid[i][j] == "#":
      temp = [(i+cx, j+cy) for cx, cy in check if (0<= i+cx <w and 0<= j+cy <h)]
      count = 0
      for t_cx, t_cy in temp:
        if grid[t_cx][t_cy] == "#":
          count += 1
      if count == 0:
        print("No")
        exit()
print("Yes")
Problem p03608 (python)

Fixed submission:
from itertools import permutations
import sys

def main():
    
    N, M, R = map(int, sys.stdin.readline().split())
    r = [i - 1 for i in map(int, sys.stdin.readline().split())]
    
    d = [[float('inf')] * N for _ in range(N)]
    
    for i in range(N):
        d[i][i] = 0
        
    for i in range(M):
        a, b, c = map(int,sys.stdin.readline().split())
        d[a-1][b-1] = c
        d[b-1][a-1] = c
        
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    
    ans = 10**12
    
    for each in permutations(r):
        t_dis = 0
        for i in range(R-1):
            t_dis += d[each[i]][each[i+1]]  
        
        ans = min(ans, t_dis)
    
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools

def warshall_floyd(d):
  len_d = len(d)
  for k in range(len_d):
    for i in range(len_d):
      for j in range(len_d):
        if d[i][j] < d[i][k] + d[k][j]:
          d[i][j] = d[i][k] + d[k][j]
  return d

def main():
  n, m, r = map(int, input().split())
  list_r = list(map(int, input().split()))
  list_cand = list(itertools.permutations(list_r))

  dist = [[float("inf") if i != j else 0 for j in range(n)] for i in range(n)]
  for i in range(m):
    a, b, c = map(int, input().split())
    dist[a-1][b-1] = c
    dist[b-1][a-1] = c
  min_dist = warshall_floyd(dist)

  result = 10**100
  for one_cand in list_cand:
    temp = 0
    for i in range(r-1)
      temp += min_dist[one_cand[i]-1][one_cand[i+1]-1]
    if temp < result:
      result = temp
  print(result)

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

Fixed submission:
n = int(input())
list_p = list(map(int, input().split()))
count = 0
i = 0
while i < n:
  if list_p[i] == i + 1:
    count += 1
    i += 2
  else:
    i += 1
    continue
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
list_p = list(map(int, input().split()))
same_p = [1 if i+1 == p else 0 for i, p in enumerate(list_p)]

count = 0
i = 0
while i < n:
  if sum(same_p) == 0:
    break
  if same_p[i] == 1:
    temp_p = list_p[i]
    list_p[i] = list_p[i+1]
    list_p[i+1] = temp_p
    same_p[i] = 0
    same_p[i+1] = 0
    if list_p[i+1] == i+2:
      same_p[i+1] = 1
    count += 1
  i += 1
print(count)
Problem p03695 (python)

Fixed submission:
n = int(input())
list_a = list(map(int, input().split()))
num_rank = [0 for _ in range(9)]
for one_a in list_a:
  temp_rank = one_a // 400
  if temp_rank > 8:
    temp_rank = 8
  num_rank[temp_rank] += 1
if len([i for i in num_rank[:-1] if i > 0]) > 0:
  min_color = len([i for i in num_rank[:-1] if i > 0])
else:
  min_color = 1
max_color = len([i for i in num_rank[:-1] if i > 0]) + num_rank[-1]
print("{} {}".format(min_color, max_color))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_a = list(map(int, input().split()))
num_rank = [0 for _ in range(9)]
for one_a in list_a:
  temp_rank = one_a // 400
  num_rank[temp_rank] += 1
if len([i for i in num_rank[:-1] if i > 0]) > 0:
  min_color = len([i for i in num_rank[:-1] if i > 0])
else:
  min_color = 1
max_color = len([i for i in num_rank[:-1] if i > 0]) + num_rank[-1]
print("{} {}".format(min_color, max_color))

Buggy submission (verdict: Runtime Error):
n = int(input())
list_a = list(map(int, input().split()))
num_rank = [0 for _ in range(9)]
for one_a in list_a:
  temp_rank = one_a // 400
  num_rank[temp_rank] += 1

min_color = len([i for i in num_rank[:-1] if i > 0])
max_color = len([i for i in num_rank[:-1] if i > 0]) + num_rank[-1]
print("{} {}".format(min_color, max_color))
Problem p03837 (python)

Fixed submission:
import heapq

def dijkstra(graph, node, target):
  INF = float("inf")
  dist = [INF] * node
  dist[target] = 0
  que = [(0, target)]
  while que:
    co, one_node = heapq.heappop(que)
    for next_c, next_n in graph[one_node]:
      dist_candi = dist[one_node] + next_c
      if dist_candi < dist[next_n]:
        dist[next_n] = dist_candi
        heapq.heappush(que, (dist[next_n], next_n))
  return dist


class SetGraph:
  def __init__(self, node_num):
    self.n = node_num
    self.graph = [[] for _ in range(self.n)]

  def add_one_edge(self, start, end, cost):
    self.graph[start].append((cost, end))
    self.graph[end].append((cost, start))

  def get_graph(self):
    return self.graph 
  

n, m = map(int, input().split(" "))
graph_set = SetGraph(n)
for i in range(m):
  a, b, c = map(int, input().split(" "))
  graph_set.add_one_edge(a - 1, b - 1, c)
graph = graph_set.get_graph()

cost = []
for i in range(n):
  temp_cost = dijkstra(graph, n, i)
  cost.append(temp_cost)

result = 0
for i in range(n):
  for c, node in graph[i]:
    if cost[i][node] != c:
      result += 1

print(result // 2)

Buggy submission (verdict: Runtime Error):
import heapq

def dijkstra(graph, node, start):
  INF = float("inf")
  dist = [INF] * node
  dist[start] = 0
  que = [(0, start)]
  while que:
    cost, one_node = heapq.heappop(heap)
    for next_c, next_n in graph[one_node]:
      dist_candi = dist[one_node] + next_c
      if dist_candi < dist[next_n]:
        dist[next_node] = dist_candi
        heapq.heappush(heap, (dist[next_n], next_n))
  return dist

class SetGraph:
  def __init__(self, node_num):
    self.graph = [[] for _ in range(node_num)]

  def add_one_edge(self, start, end, cost):
    self.graph[start].append((cost, end))
    self.graph[end].append((cost, start))

  def get_graph(self):
    return self.graph 
  

n, m = map(int, input().split(" "))
graph = SetGraph(n)
add_process = SetGraph.add_one_edge
for i in range(m):
  a, b, c = map(int, input().split(" "))
  add_process(a - 1, b - 1, c)
graph = Graph.get_graph()

cost = []
for i in range(n):
  temp_cost = dijkstra(graph, n, i)
  cost.append(temp_cost)

result = 0
for i in range(n):
  for c, node in graph[i]:
    if cost[i][node] != c:
      result += 1

print(result // 2)
Problem p03943 (python)

Fixed submission:
a, b, c = map(int, input().split(" "))
if a + b == c or b + c == a or c + a == b:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split(" "))
if a % 2 = 0 and b % 2 = 0 and c % 2 = 0:
  print("Yes")
else:
  print("No")
Problem p04000 (python)

Fixed submission:
import collections
h, w, n = map(int, input().split(" "))
list_include = []
for i in range(n):
  a, b = map(int, input().split(" "))
  for y in range(3):
    for x in range(3):
      if a - y > 0 and a - y + 2 <= h:
        if b - x > 0 and b - x + 2 <= w:
          list_include.append((a - y, b - x))
count = collections.Counter(list_include)
result = [0 for _ in range(10)]
for item in count.items():
  result[item[1]] += 1
result[0] = (h - 2) * (w - 2) - sum(result)
for one_result in result:
  print(one_result)

Buggy submission (verdict: Runtime Error):
import numpy as np
h, w, n = map(int, input().split(" "))
board = np.zeros((h, w))
for i in range(n):
  a, b = map(int, input().split(" "))
  board[a - 1][b - 1] = 1
result = [0 for _ in range(10)]
for start_h in range(h - 2):
  for start_w in range(w - 2):
    sum_black = np.count_nonzero(board[start_h:(start_h+3), start_w:(start_w + 3)] > 0)
    result[sum_black] += 1

for one_result in result:
  print(one_result)
Problem p02675 (python)

Fixed submission:
# 1
# 2 
# 3
n=input()
a=n[-1]
if a in list('24579'):
  ans='hon'
elif a in list('0168'):
  ans='pon'
else:
  ans='bon'

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=n[0]
if a in list('24579'):
  ans='hon'
elif a in list('0168'):
  ans='pon'
else:
  ans='bon'

print(ans)
Problem p02730 (python)

Fixed submission:
sel='B'
#A
if sel=='A':
    N,M=map(int,input().split())
    ans=0
    ans+=M*(M-1)//2
    ans+=N*(N-1)//2
    print(ans)

#B
if sel=='B':
    def ispal(s):
        for i in range(len(s)//2+1):
            if s[i]!=s[-(i+1)]:
                return False
        return True

    S=input()
    N=len(S)
    if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')

#C
if sel=='C':
    L=int(input())
    print((L**3)/27)

#D
if sel=='D':    
    N=int(input())
    A=[int(i) for i in input().split()]
    kin=list(set(A))
    cnt={}
    for k in kin:
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    SUM=0
    for k in kin:
        SUM+=cnt[k]*(cnt[k]-1)//2
    for a in A:
        if cnt[a]>=2:
            print(SUM-cnt[a]+1)
        else:
            print(SUM)
        
#E
if sel=='E':
    a=0

#F
if sel=='F':
    N,S=map(int,input().split())
    A=[int(i) for i in input().split()]

    for l in range(N):
        for r in range(l,N):
            print(tab[l][r])

Buggy submission (verdict: Runtime Error):
sel='B'
#A
if sel=='A':
    N,M=map(int,input().split())
    ans=0
    ans+=M*(M-1)//2
    ans+=N*(N-1)//2
    print(ans)

#B
if sel=='B':
    def ispal(s):
        for i in range(len(s)//2+1):
            if s[i]!=s[-(i+1)]:
                return False
        return True

    S=input()
    if ispal(S) and ispal(S[:(N-1)//2]) and ispal(S[(N+3)//2-1:]):
        print('Yes')
    else:
        print('No')

#C
if sel=='C':
    L=int(input())
    print((L**3)/27)

#D
if sel=='D':    
    N=int(input())
    A=[int(i) for i in input().split()]
    kin=list(set(A))
    cnt={}
    for k in kin:
        cnt[k]=0
    for a in A:
        cnt[a]+=1
    SUM=0
    for k in kin:
        SUM+=cnt[k]*(cnt[k]-1)//2
    for a in A:
        if cnt[a]>=2:
            print(SUM-cnt[a]+1)
        else:
            print(SUM)
        
#E
if sel=='E':
    a=0

#F
if sel=='F':
    N,S=map(int,input().split())
    A=[int(i) for i in input().split()]

    for l in range(N):
        for r in range(l,N):
            print(tab[l][r])