Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, P = list(map(int, input().split()))
S = input()

tot = 0

if P in [2,5]:
  for i in range(1,N+1):
    if int(S[-i]) % P == 0:
      tot += N-i+1
else:
  S_mod = [0] * P
  S_mod[0] = 1 # 0 = 0 mod P
  for i in range(N-1, -1, -1):
    mod = int(S[i:]) % P
    #print(S[i:], mod)
    tot += S_mod[mod]
    S_mod[mod] += 1
print(tot)
    

Fixed submission:
N, P = list(map(int, input().split()))
S = input()
#S = map(int, list())

tot = 0

if P in [2,5]:
  for i in range(1,N+1):
    if int(S[-i]) % P == 0:
      tot += N-i+1
else:
  S_mod = [0] * P
  S_mod[0] = 1 # 0 = 0 mod P
  mod = 0
  mod10 = 10 % P
  mod_power10 = 1
  for i in range(N-1, -1, -1):
    mod = (int(S[i]) % P * mod_power10 + mod % P) % P
    #print(S[i:], mod)
    tot += S_mod[mod]
    S_mod[mod] += 1
    mod_power10 = (mod_power10 * mod10) % P
print(tot)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in nrange(N-1):
  if A[i] == A[i+1]:
    print("NO")
    break
else:
  print('YES')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
  if A[i] == A[i+1]:
    print("NO")
    break
else:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
L = []
for i in range(N):
  if A[i] in L:
    print('NO')
    break
  L.append(A[i])
else:
  print('YES')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
  if A[i] == A[i+1]:
    print("NO")
    break
else:
  print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
 
for i in range(N):
  if A[i] in A[i+1:]:
    print('NO')
    break
else:
  print('YES')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
  if A[i] == A[i+1]:
    print("NO")
    break
else:
  print('YES')

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

for i in range(N):
  if A[i] in A[i+1:]:
    print('NN)
else:
  print('YES')

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
A.sort()
for i in range(N-1):
  if A[i] == A[i+1]:
    print("NO")
    break
else:
  print('YES')
Buggy python submission (verdict: Runtime Error):
from math import ceil
import bisect

N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
X = [x for x, h in Monsters]
H = [ceil(h / A) for x, h in Monsters]

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  #i_2Di = bisect.bisect_left(X, X[i]+2*D)
  for j in range(i+1,N):
    if X[j] - X[i] > 2*D:
      i_2Di = j
      break
  H[i:i_2Di] -= A * ni
  min_n += ni
  
print(min_n)

Fixed submission:
from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    # 期限切れの蓄積ダメージを削除
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)

Buggy python submission (verdict: Runtime Error):
from math import ceil
import bisect

N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
X = [x for x, h in Monsters]
H = [ceil(h / A) for x, h in Monsters]

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  i_2Di = bisect.bisect_left(X, X[i]+2*D)
  H[i:i_2Di] -= A * ni
  min_n += ni
  
print(min_n)

Fixed submission:
from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    # 期限切れの蓄積ダメージを削除
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, D, A = list(map(int, input().split()))
X = np.ones(N)
H = np.ones(N)
for i in range(N):
  X[i], H[i] = list(map(int, input().split()))

H = H[X.argsort()]
X = np.sort(X)

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  in2Di = np.abs(X - X[i]) <= 2 * D
  ni = int(H[i]/A) if H[i] % A == 0 else int(H[i]/A) + 1
  H[in2Di] -= A * ni
  min_n += ni
  
print(min_n)

Fixed submission:
from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    # 期限切れの蓄積ダメージを削除
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = lit(map(int, input().split()))
print('Yes' if N == M else 'No')

Fixed submission:
N, M = list(map(int, input().split()))
print('Yes' if N == M else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
Cij = [[0 for _ in range(N)] for _ in range(N)]
for i in range(1,N+1):
  a, b = int(str(i)[0]), int(str(i)[-1])
  Cij[a][b] += 1
print(sum(Cij[i][j]*Cij[j][i] for i in range(N) for j in range(N)))

Fixed submission:
N = int(input())
Cij = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1,N+1):
  a, b = int(str(i)[0]), int(str(i)[-1])
  Cij[a][b] += 1
print(sum(Cij[i][j]*Cij[j][i] for i in range(10) for j in range(10)))
Buggy python submission (verdict: Time Limit Exceeded):
# from collections import deque
H, W = list(map(int, input().split()))
# dp = [[1000 for _ in range(W)] for _ in range(H)]

S = [['#']*(W+2)] + [['#']+list(input())+['#'] for h in range(H)] + [['#']*(W+2)]
# S = (H+2, W+2)
# S =  [input().split() for h in range(H)]
max_n = 0

for h1 in range(1,H+1):
  for w1 in range(1,W+1):
    if S[h1][w1] == '#':
      continue
    distance = [[1000 for _ in range(W+2)] for _ in range(H+2)]
    distance[h1][w1] = 0
    que = []
    que.append([h1,w1])
    que_i = 0
    while que_i < len(que):
      h, w = que[que_i]
      if S[h-1][w] == '.' and [h-1, w] not in que:
        que.append([h-1,w])
        distance[h-1][w] = min(distance[h][w] + 1, distance[h-1][w])
      if S[h+1][w] == '.' and [h+1, w] not in que:
        que.append([h+1,w])
        distance[h+1][w] = min(distance[h][w] + 1, distance[h+1][w])
      if S[h][w-1] == '.' and [h, w-1] not in que:
        que.append([h,w-1])
        distance[h][w-1] = min(distance[h][w] + 1, distance[h][w-1])
      if S[h][w+1] == '.' and [h-1, w+1] not in que:
        que.append([h,w+1])
        distance[h][w+1] = min(distance[h][w] + 1, distance[h][w+1])
      que_i += 1
    hw_max_n = 0
    for h2 in range(1,H+1):
      for w2 in range(1,W+1):
        if distance[h2][w2] != 1000:
          hw_max_n = max(hw_max_n, distance[h2][w2])
    max_n = max(max_n, hw_max_n)
print(max_n)

Fixed submission:
# from collections import deque
H, W = list(map(int, input().split()))
# dp = [[1000 for _ in range(W)] for _ in range(H)]

S = [['#']*(W+2)] + [['#']+list(input())+['#'] for h in range(H)] + [['#']*(W+2)]
# S = (H+2, W+2)
# S =  [input().split() for h in range(H)]
max_n = 0

for h1 in range(1,H+1):
  for w1 in range(1,W+1):
    if S[h1][w1] == '#':
      continue
    distance = [[1000 for _ in range(W+2)] for _ in range(H+2)]
    done_que = [[0 for _ in range(W+2)] for _ in range(H+2)]
    distance[h1][w1] = 0
    que = []
    que.append([h1,w1])
    que_i = 0
    while que_i < len(que):
      h, w = que[que_i]
      if S[h-1][w] == '.' and done_que[h-1][w] == 0:
        done_que[h-1][w] = 1
        que.append([h-1,w])
        distance[h-1][w] = min(distance[h][w] + 1, distance[h-1][w])
      if S[h+1][w] == '.' and done_que[h+1][w] == 0:
        done_que[h+1][w] = 1
        que.append([h+1,w])
        distance[h+1][w] = min(distance[h][w] + 1, distance[h+1][w])
      if S[h][w-1] == '.' and done_que[h][w-1] == 0:
        done_que[h][w-1] = 1
        que.append([h,w-1])
        distance[h][w-1] = min(distance[h][w] + 1, distance[h][w-1])
      if S[h][w+1] == '.' and done_que[h][w+1] == 0:
        done_que[h][w+1] = 1
        que.append([h,w+1])
        distance[h][w+1] = min(distance[h][w] + 1, distance[h][w+1])
      que_i += 1
    hw_max_n = 0
    for h2 in range(1,H+1):
      for w2 in range(1,W+1):
        if distance[h2][w2] != 1000:
          hw_max_n = max(hw_max_n, distance[h2][w2])
    max_n = max(max_n, hw_max_n)
print(max_n)
Buggy python submission (verdict: Runtime Error):
import itertools
N = int(input())
P = list(map(int, input()))
Q = list(map(int, input()))
Ns = list(itertools.permutations(range(1,N+1), N))
NP = 0
NQ = 0
for ni in Ns:
  if ni < P:
    NP += 1
  if ni < Q:
    NQ += 1
print(abs(NP - NQ)

Fixed submission:
import itertools
N = int(input())
P = int(''.join(input().split()))
Q = int(''.join(input().split()))
Ns = list(itertools.permutations([str(i) for i in range(1,N+1)], N))
NP = 0
NQ = 0
for ni in Ns:
  nii = int(''.join(ni))
  if nii < P:
    NP += 1
  if nii < Q:
    NQ += 1
print(abs(NP - NQ))
Buggy python submission (verdict: Runtime Error):
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))

Fixed submission:
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

k = min(k, n-1)
dp = [0] * (n+1)
diff = [[0] * (n) for _ in range(n)]
for i in range(0, n-1):
    for j in range(i+1, n):
        diff[i][j] = diff[j][i] = abs(h[i] - h[j])

for i in range(2, k+1):
    dp[i] = min([dp[ki] + diff[i-1][ki-1] for ki in range(1,i)])

for i in range(k+1, n+1):
    dp[i] = min([dp[i-ki] + diff[i-1][i-1-ki] for ki in range(1,k+1)])

print(dp[n])

Fixed submission:
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))

k = min(k, n-1)
dp = [0] * (n+1)

for i in range(2, k+1):
    dp[i] = min([dp[ki] + abs(h[i-1] - h[ki-1]) for ki in range(1,i)])

for i in range(k+1, n+1):
    dp[i] = min([dp[i-ki] + abs(h[i-1] - h[i-1-ki]) for ki in range(1,k+1)])

print(dp[n])

Fixed submission:
import numpy as np

n, k = list(map(int, input().split()))
h = np.array(list(map(int, input().split())))

k = min(k, n-1)
dp = np.zeros(n+1)

for i in range(2, k+1):
    dp[i] = np.min(dp[1:i] + np.abs(h[i-1] - h[0:i-1]))

for i in range(k+1, n+1):
    dp[i] = (dp[i-k:i] + np.abs(h[i-1] - h[i-k-1:i-1])).min()
    
print(int(dp[n]))
Buggy python submission (verdict: Time Limit Exceeded):
N, W = list(map(int, input().split()))
WV = []
for _ in range(N):
  WV.append(list(map(int, input().split())))

#dp = [[0] * (W+1+max([w for w,v in WV])) for _ in range(N+1)]
dp = [[0] * (W+1) for _ in range(N+1)]

for n in range(1, N+1):
  for w in range(1, W+1):
    if w >= WV[n-1][0]:
      dp[n][w] = max(dp[n-1][w-WV[n-1][0]] + WV[n-1][1], dp[n-1][w])
    else:
      dp[n][w] = dp[n-1][w]

print(max(dp[N]))

Fixed submission:
import sys
input = sys.stdin.readline
 
import numpy as np
 
def main():
  n, W = map(int, input().split())
  dp = np.zeros(W+1, dtype=np.int64)
  for _ in range(n):
    w, v = map(int, input().split())
    # w, vを使うかどうかで更新する
    dp[w:W+1] = np.maximum(dp[:W-w+1]+v, dp[w:W+1])
  print(dp[W])

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
 
import numpy as np
 
def main():
  n, W = map(int, input().split())
  dp = np.zeros(W+1, dtype=np.int64)
  for _ in range(n):
    w, v = map(int, input().split())
    # 状態n,wにおいてwi,viを使うかどうかで更新する
    dp[w:W+1] = np.maximum(dp[:W-w+1]+v, dp[w:W+1])
  print(dp[W])

if __name__ == "__main__":
  main()


Fixed submission:
# dp[n][w]とすると，O(nw)でwが大きすぎて大変
# dp[n][v]として，価値vを達成するための最小のwを記録するO(N^2 V_{max})
# さらにdp[v]としてw, vを使うかどうかで更新する
import sys
input = sys.stdin.readline
import numpy as np

n, W = map(int, input().split())
dp = np.full(10**5 + 1, 10**12, dtype='int64')
dp[0] = 0 
for _ in range(n):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

#print(np.max(np.where(dp <= W)))
print(np.where(dp <= W)[0][-1])
Buggy python submission (verdict: Runtime Error):
def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = [-1]*n # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = [-1]*N # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)

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

def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = np.full(N, -1, dtype=int) # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

def rec(n):
  if dp[n] != -1:
    return dp[n]
  else:
    max_n = 0
    for i in graph[n]:
      max_n = max(max_n, rec(i)+1)
    dp[n] = max_n
    return dp[n]
  
N, M = list(map(int, input().split()))

dp = [-1]*N # nを始点としたときの最大値

graph = [[] for _ in range(N)]
for _ in range(M):
  xi, yi = list(map(int, input().split()))
  graph[xi-1].append(yi-1)

ans = 0
for n in range(N):
  ans = max(rec(n), ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(2000)

D, goal = map(int, input().split())
q_num, bonus = [], []
for i in range(1,D+1):
  q, b = map(int, input().split())
  q_num.append(q)
  bonus.append(b)
ans = 100000

def rec(comb, next_n, current_score):
  if next_n == D + 1:
    global ans
    if current_score >= goal:
      ans = min(ans, sum(comb))
  else:
    for i in range(q_num[next_n-1]):
      rec(comb + [i], next_n+1, current_score + i * next_n * 100)
    rec(comb + [q_num[next_n-1]], next_n+1, current_score + q_num[next_n-1] * next_n * 100 + bonus[next_n-1])
rec([], 1, 0)

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(2000)

D, goal = map(int, input().split())
q_num, bonus = [], []
for i in range(1,D+1):
  q, b = map(int, input().split())
  q_num.append(q)
  bonus.append(b)
ans = 100000

def rec2(current_qn, next_n, current_score, tyuuto_done):
  if next_n == D + 1:
    global ans
    if current_score >= goal:
      ans = min(ans, current_qn)
  else:
    rec2(current_qn+q_num[next_n-1], next_n+1, current_score+q_num[next_n-1]*next_n*100+bonus[next_n-1], tyuuto_done)
    rec2(current_qn, next_n+1, current_score, tyuuto_done)
    if not tyuuto_done:
      for i in range(1,q_num[next_n-1]):
        rec2(current_qn+i, next_n+1, current_score+i*next_n*100, 1)

def rec(comb, next_n, current_score):
  if next_n == D + 1:
    global ans
    if current_score >= goal:
      ans = min(ans, sum(comb))
  else:
    for i in range(q_num[next_n-1]):
      rec(comb + [i], next_n+1, current_score + i * next_n * 100)
    rec(comb + [q_num[next_n-1]], next_n+1, current_score + q_num[next_n-1] * next_n * 100 + bonus[next_n-1])

# rec([], 1, 0)
rec2(0, 1, 0, 0)

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = list(map(int, input()))
print(max(0, min(b, d) - max(a, c)))

Fixed submission:
a, b, c, d = list(map(int, input().split()))
print(max(0, min(b, d) - max(a, c)))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

rec('-')
rec('+')
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(2000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

if n == 0:
  print(1)
else:
  rec('-')
  rec('+')
  print(ans)

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

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

rec('-')
rec('+')
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(2000)

s = list(input())
n = len(s)-1
ans = 0

def rec(plus):
  if len(plus) == n:
    global ans
    si = s[0]
    for i in range(n):
      if plus[i] == '-':
        si += s[i+1]
      else:
        ans = ans + int(si)
        si = s[i+1]
    ans = ans + int(si)
  else:
    rec(plus+'-')
    rec(plus+'+')

if n == 0:
  print(1)
else:
  rec('-')
  rec('+')
  print(ans)
Buggy python submission (verdict: Runtime Error):
 n=int(input())
    boss=[int(x) for x in input().split()]
    mem=list(range(1, n+1))
    h_map = dict.fromkeys(mem, 0)
    for i in boss:
      h_map[i]+=1
    for i in mem:
      print(h_map[i])

Fixed submission:
n=int(input())
boss=[int(x) for x in input().split()]
mem=list(range(1, n+1))
h_map = dict.fromkeys(mem, 0)
for i in boss:
    h_map[i]+=1

for i in mem:
    print(h_map[i])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

d = np.ones((n, n)) * 1001

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

print(c)


Fixed submission:
import numpy as np

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

d = np.ones((n, n)) * 1001

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

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

if a == b:
    if a == c:
        print("No")
    else:
        print("Yes")
elif a != b:
    if a == c:
        print("Yes")
    elif b == c:
        print("Yes")
    else:
        print("No")

Fixed submission:
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])

if a == b:
    if a == c:
        print("No")
    else:
        print("Yes")
elif a != b:
    if a == c:
        print("Yes")
    elif b == c:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
# それぞれのボールの文字列を取得
a = input()
b = input()

# それぞれのボールの個数を取得
aCount = int(input())
bCount = int(input())
ball = []
ball.append(aCount)
ball.append(bCount)

# 取り出したボールの文字列を取得
selectBall = input()

if selectBall == a:
    aCount = aCount-1
    ball[0] = aCount
    print(' '.join(map(str,ball)))
elif selectBall == b:
    bCount = bCount-1
    ball[1] = bCount
    print(' '.join(map(str,ball)))
else:
    print(' '.join(map(str,ball)))


Fixed submission:
# それぞれのボールの文字列を取得
a, b = input().split()

# それぞれのボールの個数を取得
aCount, bCount = input().split()
aNumber = int(aCount)
bNumber = int(bCount)

ball = []
ball.append(aNumber)
ball.append(bNumber)

# 取り出したボールの文字列を取得
selectBall = input()

if selectBall == a:
    aNumber = aNumber-1
    ball[0] = aNumber
    print(' '.join(map(str,ball)))
elif selectBall == b:
    bNumber = bNumber-1
    ball[1] = bNumber
    print(' '.join(map(str,ball)))
else:
    print(' '.join(map(str,ball)))

Buggy python submission (verdict: Runtime Error):
# それぞれのボールの文字列を取得
a = input()
b = input()

# それぞれのボールの個数を取得
aCount = int(input())
bCount = int(input())
ball = []
ball.append(aCount)
ball.append(bCount)

# 取り出したボールの文字列を取得
selectBall = input()

# それぞれの文字列の文字数を取得
# aLength = len(a)
# bLength = len(b)

# print(aLength)
# print(bLength)

if selectBall == a:
    aCount = aCount-1
    # print(aCount)
    ball[0] = aCount
    print(' '.join(map(str,ball)))
elif selectBall == b:
    bCount = bCount-1
    ball[1] = bCount
    print(' '.join(map(str,ball)))
else:
    print(' '.join(map(str,ball)))


Fixed submission:
# それぞれのボールの文字列を取得
a, b = input().split()

# それぞれのボールの個数を取得
aCount, bCount = input().split()
aNumber = int(aCount)
bNumber = int(bCount)

ball = []
ball.append(aNumber)
ball.append(bNumber)

# 取り出したボールの文字列を取得
selectBall = input()

if selectBall == a:
    aNumber = aNumber-1
    ball[0] = aNumber
    print(' '.join(map(str,ball)))
elif selectBall == b:
    bNumber = bNumber-1
    ball[1] = bNumber
    print(' '.join(map(str,ball)))
else:
    print(' '.join(map(str,ball)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
l.append(0)
for i in range(1, len(l)+1):
    print(l.count(i))

Fixed submission:
from collections import Counter
N = int(input())
l = list(map(int, input().split()))
counter = Counter(l)
for i in range(1, N+1):
    if i in counter.keys():
        print(counter[i])
    else:
        print(0)