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

Fixed submission:
from collections import deque

h,w = map(int, input().split())
PATH = "."
WALL = "#"
z=0
# 迷路の配列を作成する。
maze=list()
for a in range(h):
 mazew=list()
 mazeh = input()
 for b in range(w):
  mazew.append(mazeh[b])
 maze.append(mazew)
for c in range(h):
 for d in range(w):
   # 地図上の未訪問地点を-1とする。
   # また、移動するごとに+1することで、スタート地点からの移動距離を保持する
  if maze[c][d]==WALL:
   continue
  else:
   distance_visited = list()
   for l in range(h):
    distance_visited.append([-1] * w)
   # スタート地点を登録する。
   queue = deque([[c, d]])
   distance_visited[c][d] = 0
   while True:
    x,y = queue.popleft()
      # 現在地点の上下左右のマスを確認する。
    for i,j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
     new_x, new_y = x + i, y + j
       # それぞれのマスが移動できる場合、かつまだ移動したことが無い場合
     if new_x>=0 and new_x<=h-1 and new_y>=0 and new_y<=w-1:
      if maze[new_x][new_y] != WALL and distance_visited[new_x][new_y] == -1:
               # そのマスのスタートからの移動距離を設定し、またキューに登録する。
       distance_visited[new_x][new_y] = distance_visited[x][y] + 1
       queue.append([new_x, new_y])
       if distance_visited[new_x][new_y]>z:
        z=distance_visited[new_x][new_y]
    if queue==deque([]):
     break
print(z)

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

h,w = map(int, input().split())
PATH = "."
WALL = "#"
z=0
# 迷路の配列を作成する。
maze=list()
for a in range(h):
 mazew=list()
 mazeh = input()
 for b in range(w):
  mazew.append(mazeh[b])
 maze.append(mazew)
 print(maze)

for c in range(h):
 for d in range(w):
  for e in range(h):
   for f in range(w):
   # 地図上の未訪問地点を-1とする。
   # また、移動するごとに+1することで、スタート地点からの移動距離を保持する。
    if maze[e][f] == WALL:
     continue
    else:
     distance_visited = list()
     for l in range(h):
      distance_visited.append([-1] * w)
    # スタート地点を登録する。
     queue = deque([[c, d]])
     distance_visited[c][d] = 0
     goal_x, goal_y=e,f
     while True:
      x,y = queue.popleft()
      # ゴールの場合は終了する。
      if x == e and y==f:
       goal_x, goal_y = x, y
       break
        # 現在地点の上下左右のマスを確認する。
      for i,j in ([1, 0], [-1, 0], [0, 1], [0, -1]):
       new_x, new_y = x + i, y + j
        # それぞれのマスが移動できる場合、かつまだ移動したことが無い場合
       if new_x>=0 and new_x<=h-1 and new_y>=0 and new_y<=w-1:
        if maze[new_x][new_y] != WALL and distance_visited[new_x][new_y] == -1:
                # そのマスのスタートからの移動距離を設定し、またキューに登録する。
         distance_visited[new_x][new_y] = distance_visited[x][y] + 1
         queue.append([new_x, new_y])
      if z<distance_visited[goal_x][goal_y]:
       z=distance_visited[goal_x][goal_y]
print(z)
Problem p02814 (python)

Fixed submission:
import fractions
N,M = map(int,input().split())
A = list(map(int,input().split()))
t=1
while A:
 b=0
 for i in range(N):
  A[i]=int(A[i]/2)
  if A[i]%2==1:
   b+=1
 if b==N:
  break
 elif 0<b<N:
  t=0
  break
 else:
  t+=1
if t==0:
 print(0)
else:
 ans = A[0]
 for i in range(1, N):
  ans = ans * A[i] // fractions.gcd(ans, A[i])
 ans=min(ans,(M+1))
 c=int(M/(2**(t-1))/ans)
 d=int(M/(2**(t))/ans)
 print(c-d)

Buggy submission (verdict: Runtime Error):
import fractions
N,M = map(int,input().split())
A = list(map(int,input().split()))
t=1
while A:
 b=0
 for i in range(N):
  A[i]=int(A[i]/2)
  if A[i]%2==1:
   b+=1
 if b==N:
  break
 elif 0<b<N:
  t=0
  break
 else:
  t+=1
if t==0:
 print(0)
else:
 ans = A[0]
 for i in range(1, N):
  ans = ans * A[i] // fractions.gcd(ans, A[i])
 print(int(M/(2**(t-1))/ans)-int(M/(2**(t))/ans))

Buggy submission (verdict: Runtime Error):
import fractions
N,M = map(int,input().split())
A = list(map(int,input().split()))
while A:
 t=1
 b=0
 for i in range(N):
  A[i]=int(A[i]/2)
  if A[i]%2==1:
   b+=1
 if b==N:
  break
 elif 0<b<N:
  t=0
  break
 else:
  t+=1
if t==0:
 print(0)
else:
 ans = A[0]
 for i in range(1, N):
  ans = ans * A[i] // fractions.gcd(ans, A[i])
 print(int(M/(2**(t-1))/ans)-int(M/(2**(t))/ans))

Buggy submission (verdict: Runtime Error):
import fractions
N,M=list(map(int, input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
if ans%2==1 or ans/2>M:
 print(0)
else:
 c=int(M/ans*2)
 d=int((1+c)/2)
 print(d)
Problem p02823 (python)

Fixed submission:
N,A,B=map(int,input().split())
if (B-A)%2==0:
 print((B-A)//2)
else:
 print(min((A+B-1)//2,(2*N-A-B+1)//2))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
if (a-b)%2==0:
 print((b-a)/2))
else:
 print(min(int((2*(a-1)+b-a+1)/2),int((2*(n-b)+b-a+1)/2)))
Problem p02845 (python)

Fixed submission:
N=int(input())
A= list(map(int,input().split()))
B=[0,0,0]
C=1
for i in range(N):
 E=0
 F=0
 for j in range(3):
  if A[i]==B[j]:
   E+=1
   if E==1:
    B[j]+=1
    F=j
 C*=E
 C%=1000000007
print(C)

Buggy submission (verdict: Runtime Error):
lst=[]
N=int(input())
h = map(int, input().split())
c=1
A=list(h)
B=len(A)
for i in range(B):
 if len(lst)<A[i]:
  c=0
  break
 elif len(lst)==A[i]:
  lst.append(1)
 else:
  lst[A[i]]+=1
  if lst[A[i]]==4:
   c=0
   break
 if A[i]==0:
  c*=1
 elif lst[A[i]-1]-lst[A[i]]+1<=0:
  if A[i]==1:
   c*=(4-lst[A[i]])
  else:
   c=0
   break
 else:
  c*=(lst[A[i]-1]-lst[A[i]]+1)
if lst[0]==1:
 c*=3
else:
 c*=6
print(c%1000000007)

Buggy submission (verdict: Runtime Error):
lst=[]
N=int(input())
h = map(int, input().split())
c=1
A=list(h)
B=len(A)
for i in range(B):
 if len(lst)==A[i]:
  lst.append(1)
 else:
  lst[A[i]]+=1
 if A[i]==0:
  c*=1
 else:
  c*=(lst[A[i]-1]-lst[A[i]]+1)
if lst[0]==1:
 c*=3
else:
 c*=6
print(c%1000000007)
Problem p02909 (python)

Fixed submission:
S=input()
if S=="Sunny":
 a="Cloudy"
elif S=="Cloudy":
 a="Rainy"
else:
 a="Sunny"
print(a)

Buggy submission (verdict: Runtime Error):
S=input()
if S="Sunny":
 a="Cloudy"
elif S="Cloudy":
 a="Rainy"
else:
 a="Sunny"
print(a)
Problem p02947 (python)

Fixed submission:
import math
import sys
input = sys.stdin.readline
N=int(input())
d={}
for i in [0]*N:
 s = ''.join(sorted(input().strip()))
 if s in d:
  d[s]+=1
 else:
  d[s]=1
e=0
for v in d.values():
 if v>=2:
  e+=int(v*(v-1)/2)
print(e)

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline
N=int(input())
d={}
for i in [0]*N:
 s = ''.join(sorted(input().strip()))
 if s in d:
  d[s]+=1
 else:
  d[s]=1
e=0
for v in d.values():
 if v>=2:
  e+=int(math.factorial(v)/2)
print(e)
Problem p02996 (python)

Fixed submission:
def merge_sort(arr):
 if len(arr) <= 1:
  return arr
 mid = len(arr) // 2
# ここで分割を行う
 left = arr[:mid]
 right = arr[mid:]
# 再帰的に分割を行う
 left = merge_sort(left)
 right = merge_sort(right)
# returnが返ってきたら、結合を行い、結合したものを次に渡す
 return merge(left, right)
def merge(left, right):
 merged = []
 l_i, r_i = 0, 0
# ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
 while l_i < len(left) and r_i < len(right):
    # ここで=をつけることで安定性を保っている
  if left[l_i][0] <= right[r_i][0]:
   merged.append(left[l_i])
   l_i += 1
  else:
   merged.append(right[r_i])
   r_i += 1

# 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
 if l_i < len(left):
  merged.extend(left[l_i:])
 if r_i < len(right):
  merged.extend(right[r_i:])
 return merged
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
for i in range(N):
 A,B= map(int,input().split())
 lst[i]=[B,A]
lsta=merge_sort(lst)
ans=0
t=0
for i in range(N):
 t+=lsta[i][1]
 if t>lsta[i][0]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
def merge_sort(arr):
 if len(arr) <= 1:
  return arr
 mid = len(arr) // 2
# ここで分割を行う
 left = arr[:mid]
 right = arr[mid:]
# 再帰的に分割を行う
 left = merge_sort(left)
 right = merge_sort(right)
# returnが返ってきたら、結合を行い、結合したものを次に渡す
 return merge(left, right)
def merge(left, right):
 merged = []
 l_i, r_i = 0, 0
# ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
 while l_i < len(left) and r_i < len(right):
    # ここで=をつけることで安定性を保っている
  if left[l_i][1] <= right[r_i][1]:
   merged.append(left[l_i])
   l_i += 1
  else:
   merged.append(right[r_i])
   r_i += 1

# 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
 if l_i < len(left):
  merged.extend(left[l_i:])
 if r_i < len(right):
  merged.extend(right[r_i:])
 return merged
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
for i in range(N):
 lst=[list[map(int,input().split())] for i in range(n)]
lsta=merge_sort(lst)
ans=0
t=0
for i in range(N):
 t+=lsta[i][0]
 if t>lsta[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")
Problem p03044 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N=int(input())
ki=[[] for f in range(N)]
for i in range(N-1):
 u,v,w = map(int,input().split())
 ki[u-1].append([v-1,w%2])
 ki[v-1].append([u-1,w%2])
stack = [[0,0]]
check = [0]*N #チェック済みリスト
ans=[2]*N
ans[0]=0
while stack != [] :
 a=stack.pop()
 if check[a[0]]==0:
  check[a[0]]=1
  for i in range(len(ki[a[0]])):
   if check[ki[a[0]][i][0]]==0:
    stack.append([ki[a[0]][i][0],(ki[a[0]][i][1]+ans[a[0]])%2])
    ans[ki[a[0]][i][0]]=(ki[a[0]][i][1]+ans[a[0]])%2
for i in ans:
 print(i)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N=int(input())
ki=[[] for f in range(N)]
for i in range(N-1):
 u,v,w = map(int,input().split())
 ki[u-1].append([v-1,w%2])
 ki[v-1].append([u-1,w%2])
stack = [[0,0]]
check = [0]*N #チェック済みリスト
ans=[2]*N
ans[0]=0
while stack != [] :
 a=stack.pop()
 ne=a[0]
 if check[ne]==0:
  check[ne]=1
  for i in range(len(ki[ne])):
   if check[ki[ne][i][0]]==0:
    stack.append([ki[ne][i][0],(ki[ne]][i][1]+ans[ne])%2])
    ans[ki[ne][i][0]]=(ki[ne][i][1]+ans[ne])%2
for i in ans:
 print(i)
Problem p03155 (python)

Fixed submission:
N = int(input())
H = int(input())
W = int(input())
print((N-H+1)*(N-W+1))

Buggy submission (verdict: Runtime Error):
N, H, W = input(), input(), input()
print((N-H+1)*(N-W+1))
Problem p03231 (python)

Fixed submission:
#!/usr/bin/env python

from fractions import gcd

N, M = map(int, input().split())
S = list(input())
T = list(input())

g = int(gcd(N, M))
l = N * M // g

for i, j in zip(S[::N//g], T[::M//g]):
    if i != j:
        print(-1)
        break
else:
    print(l)

Buggy submission (verdict: Runtime Error):

from fractions import gcd

def solve():
    N, M = map(int, input().split())
    S = list(input())
    T = list(input())

    k = N * M // gcd(N, M)

    S_new = ''.join([c + ' '*(k//N-1) for c in S])
    T_new = ''.join([c + ' '*(k//M-1) for c in T])

    for i in range(N):
        idx = i*(k//N)
        if S_new[idx] != ' ' and T_new[idx] != ' ' and S_new[idx] != T_new[idx]:
            print(-1)
            return
    for i in range(M):
        idx = i*(k//M)
        if S_new[idx] != ' ' and T_new[idx] != ' ' and S_new[idx] != T_new[idx]:
            print(-1)
            return
    
    print(k)

solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

from fractions import gcd

def solve():
    N, M = map(int, input().split())
    S = list(input())
    T = list(input())

    k = N * M // gcd(N, M)

    S_new = ''.join([c + ' '*(k//N-1) for c in S])
    T_new = ''.join([c + ' '*(k//M-1) for c in T])

    for i, j in zip(S_new, T_new):
        if i !=' ' and j != ' ' and i != j:
            print(-1)
            break
    else:
        print(k)

solve()
Problem p03247 (python)

Fixed submission:
#!/usr/bin/env python

import math

def query(p, q, ds):
    p_dirs = []
    q_dirs = []
    for d in ds:
        p_dir = 1 if p>0 else -1
        q_dir = 1 if q>0 else -1

        p_dirs.append(p_dir)
        q_dirs.append(q_dir)

        p -= p_dir * d
        q -= q_dir * d

    res = ''
    for pd, qd in zip(p_dirs, q_dirs):
        if pd > 0 and qd > 0:
            res += 'R'
        elif pd > 0 and qd < 0:
            res += 'U'
        elif pd < 0 and qd > 0:
            res += 'D'
        else:
            res += 'L'

    print(res)


def solve():
    n = int(input())
    queries = [tuple(map(int, input().split())) for _ in range(n)]
    m = max(map(lambda x: abs(x[0]) + abs(x[1]), queries))
    a = list(map(lambda x: (abs(x[0]) + abs(x[1])) % 2, queries))
    if len(set(a)) != 1:
        print(-1)
        return
    ps = [t[0]+t[1] for t in queries]
    qs = [t[0]-t[1] for t in queries]

    n_arms = int(math.ceil(math.log2(m)))
    if ps[0] % 2 == 0:
        ds = [2**i for i in reversed(range(n_arms))] + [1]
    else:
        ds = [2**i for i in reversed(range(n_arms))]
    print(len(ds))
    print(' '.join(map(str, ds)))
    for p, q in zip(ps, qs):
        query(p, q, ds)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python


def solve():
    n = int(input())
    queries = [tuple(map(int, input().split())) for _ in range(n)]
    m = max(map(lambda x: abs(x[0]) + abs(x[1]), queries))
    a = list(map(lambda x: (abs(x[0]) + abs(x[1])) % 2, queries))
    if len(set(a)) != 1:
        print(-1)
        return
    else:
        print(m)
        print(' '.join(['1'] * m))
        for (x, y) in queries:
            s = ''
            if x > 0:
                s += 'R' * abs(x)
            else:
                s += 'L' * abs(x)
            if y > 0:
                s += 'U' * abs(y)
            else:
                s += 'D' * abs(y)
            s += 'UD' * ((m - len(s)) // 2)
            print(s)


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

import numpy as np


def solve():
    n = int(input())
    queries = [tuple(map(int, input().split())) for _ in range(n)]
    m = max(map(lambda x: abs(x[0]) + abs(x[1]), queries))
    a = list(map(lambda x: (abs(x[0]) + abs(x[1])) % 2, queries))
    nunique = len(np.unique(a))
    if nunique != 1:
        print(-1)
        return
    else:
        print(m)
        print(' '.join(['1'] * m))
        for (x, y) in queries:
            s = ''
            if x > 0:
                s += 'R' * abs(x)
            else:
                s += 'L' * abs(x)
            if y > 0:
                s += 'U' * abs(y)
            else:
                s += 'D' * abs(y)
            s += 'UD' * ((m - len(s)) // 2)
            print(s)


if __name__ == '__main__':
    solve()
Problem p03364 (python)

Fixed submission:
#!/usr/bin/env python
import numpy as np
N = int(input())
alphabets = list('abcdefghijklmnopqrstuvwxyz')
A = np.zeros((N, N), dtype=int)
for i in range(N):
    for j, c in enumerate(input()):
        A[i,j] = alphabets.index(c)

B = np.concatenate([A, A], axis=0)
cnt = 0
for i in range(N):
    C = B[i:i+N, :]
    if (C==C.T).all():
        cnt += 1
print(cnt*N)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import numpy as np
N = int(input())
alphabets = 'abcdefghijklmnopqrstuvwxyz'
A = np.zeros((N, N))
for i in range(N):
    for j, c in enumerate(input()):
        A[i,j] = alphabets.index(c)

cnt = 0
for i in range(N):
    for j in range(N):
        B = np.roll(A, (i, j), (0, 1))
        if (B==B.T).all():
            cnt += 1
print(cnt)
Problem p03416 (python)

Fixed submission:
a, b = map(int, input().split())
cnt = 0
for i in range(a, b+1):
  if str(i)==''.join(reversed(str(i))):
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0
for i in range(a, b+1):
  if i==''.join(reversed(i)):
    cnt+=1
print(cnt)
Problem p03434 (python)

Fixed submission:
n = int(input())
alist = map(int, input().split())
alice = []
bob = []
for i, a in enumerate(sorted(alist, reverse=True)):
    if i % 2 == 0:
        alice.append(a)
    else:
        bob.append(a)
print(sum(alice) - sum(bob))

Buggy submission (verdict: Runtime Error):
n = int(input())
as = map(int, input().split())
alice = []
bob = []
for i, a in enumerate(as):
    if i%2==0:
        alice.append(a)
    else:
        bob.append(a)
print(sum(alice)-sum(bob))
Problem p03435 (python)

Fixed submission:
def main():
    arr = []
    for i in range(3):
        arr.append(list(map(int, input().split())))
    b1 = arr[0][0] - arr[0][1]
    b2 = arr[0][1] - arr[0][2]
    a1 = arr[1][0] - arr[0][0]
    a2 = arr[2][0] - arr[1][0]
    for i in range(3):
        if arr[i][0] - arr[i][1] != b1 or arr[i][1] - arr[i][2] != b2 or arr[1][i] - arr[0][i] != a1 or arr[2][i] - \
                arr[1][i] != a2:
            print("No")
            return
    print("Yes")

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    arr = []
    for i in range(3):
        arr.append(map(int, input().split()))
    b1 = arr[0][0] - arr[0][1]
    b2 = arr[0][1] - arr[0][2]
    a1 = arr[1][0] - arr[0][0]
    a2 = arr[2][0] - arr[1][0]
    for i in range(3):
        if arr[i][0] - arr[i][1] != b1 or arr[i][1] - arr[i][2] != b2 or arr[1][i] - arr[0][i] != a1 or arr[2][i] - \
                arr[1][i] != a2:
            print("No")
            return
    print("Yes")

if __name__ == '__main__':
    main()
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)

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

def main():
    N, M = map(int, input().split())
    link = [[] for _ in range(N+1)]
    value = [0 for _ in range(N+1)]

    for _ in range(M):
        l, r, d = map(int, input().split())
        link[l].append((r, d))
        link[r].append((l, -d))

    searched = set()
    q = deque()
    for u in range(N+1):
        if u in searched:
            continue
        q.append(u)
        searched.add(u)
        value[u] = 0

        # search
        while q:
            x = q.popleft()
            for y, d in link[x]:
                if y not in searched:
                    value[y] = value[x] + d
                    q.append(y)
                    searched.add(y)

    # verify
    for x in range(N+1):
        for y, d in link[x]:
            if value[y] != value[x] + d:
                print('No')
                return
    else:
        print('Yes')

if __name__ == '__main__':
    main()

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

# weighted graph
for _ in range(M):
    l, r, d = map(int, input().split())
    G[l].append((r, d))
    G[r].append((l, -d))

cache = set(range(1, N+1))

# depth first search
def dfs(graph, start, visited=None):
    global cache  # for checking disconnected
    visited = visited or {}
    visited[start[0]] = start[1]
    cache.remove(start[0])
    for nxt, v in graph[start[0]]:
        nxt_value = start[1] + v
        if nxt in visited:
            if nxt_value != visited[nxt]:
                return False
            continue
        return dfs(graph, (nxt, nxt_value), visited)
    return True

# while len(cache)>0:
#     if not dfs(G, (list(cache)[0], 0)):
#         print('No')
#         break
# else:
#     print('Yes')

if dfs(G, (0, 0)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for ai in range(a+1):
    for bi in range(b+1):
        for ci in range(c+1):
            if 500*ai + 100*bi + 50*ci == x:
                cnt += 1
print(cnt)
Problem p03448 (python)

Fixed submission:
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for ai in range(0, a+1):
    for bi in range(0, b+1):
        for ci in range(0, c+1):
            if 500*ai + 100*bi + 50*ci == x:
                cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for ai in range(a):
	for bi in range(b):
		for ci in range(c):
        	if 500*ai + 100*bi + 50*ci == x:
				cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
a, b, c, x = [int(input()) for _ in range(4)]
cnt = 0
for ai in range(a):
	for bi in range(b):
		for ci in range(c):
        	if 500*ai + 100*bi + 50*ci == x:
            	cnt += 1
print(cnt)
Problem p03608 (python)

Fixed submission:
#!/usr/bin/env python
# ワーシャルフロイド+全探索

import numpy as np
import itertools

def main():
    N, M, R = map(int, input().split())
    rs = list(map(int, input().split()))
    inf = float('inf')
    cost = [[inf]*N for _ in range(N)]

    # グラフ作る
    for i in range(N):
        cost[i][i] = 0

    for _ in range(M):
        a, b, c = map(int, input().split())
        cost[a-1][b-1] = c
        cost[b-1][a-1] = c
    
    # ワーシャルフロイドで全頂点間距離算出
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if cost[i][k]+cost[k][j] < cost[i][j]:
                    cost[i][j] = cost[i][k] + cost[k][j]

    # 組み合わせ全探索
    ans = inf
    for route in itertools.permutations(rs):
        d = 0
        for i in range(R-1):
            d += cost[route[i]-1][route[i+1]-1]
            if d > ans:
                break
        ans = min(ans, d)
    
    print(int(ans))


if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# ワーシャルフロイド+全探索

import numpy as np
import itertools

def main():
    N, M, R = map(int, input().split())
    rs = [int(a)-1 for a in input().split())]
    inf = float('inf')
    cost = [[inf]*N for _ in range(N)]

    # グラフ作る
    for i in range(N):
        cost[i][i] = 0

    for _ in range(M):
        a, b, c = map(int, input().split())
        cost[a][b] = c
        cost[b][a] = c
    
    # ワーシャルフロイドで全頂点間距離算出
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if cost[i][k]+cost[k][j] < cost[i][j]:
                    cost[i][j] = cost[i][k] + cost[k][j]

    # 組み合わせ全探索
    ans = inf
    for route in itertools.permutations(rs):
        d = 0
        for i in range(R-1):
            d += cost[route[i]][route[i+1]]
            if d > ans:
                break
        ans = min(ans, d)
    
    print(int(ans))


if __name__=='__main__':
    main()
Problem p03694 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(max(a)-min(a))
Problem p03711 (python)

Fixed submission:
g = [-1,0,2,0,1,0,1,0,0,1,0,1,0]
x, y = map(int, input().split())
print('Yes' if g[x]==g[y] else 'No')

Buggy submission (verdict: Runtime Error):
g = [0,2,0,1,0,1,0,0,1,0,1,0]
x, y = map(int, input().split())
print('Yes' if g[x]==g[y] else 'No')

Buggy submission (verdict: Runtime Error):
group = [0,2,0,1,0,1,0,0,1,0,1,0]
x, y = map(int, input().split())
print('Yes' if group[x]==group[y] else 'No')
Problem p03720 (python)

Fixed submission:
#!/usr/bin/env python

n, m = map(int, input().split())
l = []
l = [0] * n
for _ in range(m):
    a, b = map(int, input().split())  # 1-index
    l[a-1] += 1
    l[b-1] += 1

for i in l:
    print(i)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = []
l = [0] * n
for _ in range(m):
    a, b = map(int, input().split())  # 1-index
    l[a] += 1
    l[a] -= 1
    l[a-1] += 1
    l[b-1] += 1

for _ in range(n):
    pass

for i in l:
    print(i)