Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

class WarshallFloyd:
    def __init__(self,n):
        self.dist = {}
        for i in range(n-1):
            for j in range(i,n):
                self.dist[(i,j)] = 1e100

    def unite(self,x,y,c):
        if x == y:
            return False
        elif x > y:
            x,y = y,x
        if self.dist[(x,y)] <= c:
            return False
        else:
            for i in range(n-1):
                for j in range(i+1,n):
                    self.dist[(i,j)] = min(self.d(i,j), self.d(i,x) + c + self.d(y,j), self.d(i,y) + c + self.d(x,j))

    def d(self,x,y):
        if x == y:
            return 0
        if x > y:
            x,y = y,x
        return self.dist[(x,y)]

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.unite(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
for a,b,c in ABC:
    ans += (c > wf.d(a,b))
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
wf.build()
for a,b,c in ABC:
    ans += (c > wf.d[a][b])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
class WarshallFloyd:
    def __init__(self,n):
        self.dist = {}
        for i in range(n-1):
            for j in range(i,n):
                self.dist[(i,j)] = 1e100

    def unite(self,x,y,c):
        if x == y:
            return False
        elif x > y:
            x,y = y,x
        if self.dist[(x,y)] <= c:
            return False
        else:
            for i in range(n-1):
                for j in range(i+1,n):
                    self.dist[(i,j)] = min(self.d(i,j), self.d(i,x) + c + self.d(y,j), self.d(i,y) + c + self.d(x,j))

    def d(self,x,y):
        if x == y:
            return 0
        if x > y:
            x,y = y,x
        return self.dist[(x,y)]

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.unite(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
for a,b,c in ABC:
    ans += (c > wf.d(a,b))
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
wf.build()
for a,b,c in ABC:
    ans += (c > wf.d[a][b])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
class WarshallFloyd:
    def __init__(self,n):
        self.dist = {}
        for i in range(n-1):
            for j in range(i,n):
                self.dist[(i,j)] = 1e100

    def unite(self,x,y,c):
        if x == y:
            return False
        elif x > y:
            x,y = y,x
        if self.dist[(x,y)] <= c:
            return False
        else:
            for i in range(n-1):
                for j in range(i+1,n):
                    self.dist[(i,j)] = min(self.d(i,j), self.d(i,x) + c + self.d(y,j), self.d(i,y) + c + self.d(x,j))

    def d(self,x,y):
        if x == y:
            return 0
        if x > y:
            x,y = y,x
        return self.dist[(x,y)]

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.unite(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
for a,b,c in ABC:
    ans += (c > wf.d(a,b))
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

class WarshallFloyd:
    def __init__(self,n):
        self.v = n
        self.d = [[1e100]*n for _ in range(n)]
        for i in range(n):
            self.d[i][i] = 0

    def path(self,x,y,c):
        if x == y:
            return False
        self.d[x][y] = c
        self.d[y][x] = c
        return True

    def build(self):
        for k in range(self.v):
            for i in range(self.v):
                for j in range(self.v):
                    self.d[i][j] = min(self.d[i][j], self.d[i][k] + self.d[k][j])

n,m = map(int,input().split())
ABC = [tuple() for _ in range(m)]
wf = WarshallFloyd(n)
for i in range(m):
    a,b,c = map(int,input().split())
    wf.path(a-1,b-1,c)
    ABC[i] = (a-1,b-1,c)
ans = 0
wf.build()
for a,b,c in ABC:
    ans += (c > wf.d[a][b])
print(ans)