Buggy python submission (verdict: Runtime Error):
n,m =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(m):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]

for a in range(n):
    for b in range(n):
        for c in range(n):
            if dist[b][a]+dist[a][c] < dist[b][c]:
                if route[b][a] == None:
                    route[b][c] = copy.deepcopy(route[a][c])[1:]
                else:
                    route[b][c] = copy.deepcopy(route[b][a]).extend(copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]

ans = 0
for i in range(n):
    for k in range(n):
        if route[i][k]:
            ans += 1

print(m-ans//2)


Fixed submission:
n,M =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(M):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]


for a in range(n):
    for b in range(n):
        for c in range(n):
            #print(a,b,c)
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]) + (copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]


#for i in range(n):
    #print(route[i])

used = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for k in range(n):
        for m in range(len(route[i][k])-1):
            used[route[i][k][m]][route[i][k][m+1]] = 1
            used[route[i][k][m+1]][route[i][k][m]] = 1
#for i in range(n):
    #print(used[i])

ans = 0
for i in range(n):
    for k in range(n):
        if used[i][k]:
            ans += 1

print(M-(ans//2))

Buggy python submission (verdict: Runtime Error):
n,m =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(m):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]

for a in range(n):
    for b in range(n):
        for c in range(n):
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]).extend(copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]
ans = 0
for i in range(n):
    for k in range(n):
        if route[i][k]:
            ans += 1

print(m-ans//2)


Fixed submission:
n,M =map(int,input().split())
inf = 10**15

dist = [[inf for i in range(n)] for i in range(n)]
route = [[ [] for i in range(n)] for i in range(n)]
import copy

for i in range(M):
    ak,bk,ck = map(int,input().split())
    dist[ak-1][bk-1]  =ck
    dist[bk-1][ak-1]  =ck

for i in range(n):
    for k in range(n):
        route[i][k] = [i,k]
        route[k][i] = [k,i]


for a in range(n):
    for b in range(n):
        for c in range(n):
            #print(a,b,c)
            if dist[b][a]+dist[a][c] < dist[b][c]:
                route[b][c] = copy.deepcopy(route[b][a]) + (copy.deepcopy(route[a][c])[1:])
                dist[b][c] =  dist[b][a]+dist[a][c]


#for i in range(n):
    #print(route[i])

used = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
    for k in range(n):
        for m in range(len(route[i][k])-1):
            used[route[i][k][m]][route[i][k][m+1]] = 1
            used[route[i][k][m+1]][route[i][k][m]] = 1
#for i in range(n):
    #print(used[i])

ans = 0
for i in range(n):
    for k in range(n):
        if used[i][k]:
            ans += 1

print(M-(ans//2))