Language: C++

#include <bits/stdc++.h>

using namespace std;


int graph[101][101];
int dist[101][101];
int prev[101][101];
int V;
int cnt[101][101], mark[101][101];

void floydWarshall ()
{
    int i, j, k;
 
    for (i = 0; i < V; i++)
        for (j = 0; j < V; j++) {
        	if(!graph[i][j])	continue;
            dist[i][j] = graph[i][j];
            mark[i][j] = 1;
            cnt[i][j]++;
            prev[i][j] = i;
        }
 
    for (k = 0; k < V; k++)
    {
        // Pick all vertices as source one by one
        for (i = 0; i < V; i++)
        {
            for (j = 0; j < V; j++)
            {
            	if(!graph[i][k] && !graph[k][j])	continue;
                if (dist[i][k] + dist[k][j] < dist[i][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                    if(prev[i][j] != -1) {
		                if(cnt[prev[i][j]][j] == 1)	mark[prev[i][j]][j] = 0;
	                    cnt[prev[i][j]][j]--;
	                }
                    mark[k][j] = 1;
                    cnt[k][j]++;
                    prev[i][j] = k;

                }
            }
        }
    }
}

set<pair<int, int> > s;

// void f() {
// 	for(int i = 0; i < V; ++i) {
// 		for(int j = 0; j < V; ++j) {
// 			if(i == j)	continue;

// 			int curr = pre[i][j];
// 			int curr2 = j;

// 			while(curr2 != curr) {
// 				if(curr > curr2)	swap(curr, curr2);
// 				s.insert(make_pair(curr, curr2));
// 				curr2 = curr;
// 				curr = pre[i][curr2];
// 			}
// 		}
// 	}
// }

int main(void) {

	
	int n, m;
	cin>>n>>m;
	memset(graph, 0, sizeof(graph));
	memset(cnt, 0, sizeof(cnt));
	memset(mark, 0, sizeof(mark));
	memset(prev, -1, sizeof(prev));

	for(int i = 0; i < m; ++i) {
		int a, b, c;
		cin>>a>>b>>c;
		
		--a, --b;
		graph[a][b] = c;
		graph[b][a] = c;
	}
	V = n;
	floydWarshall();
	

	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		for(int j = i+1; j < n; ++j) {
			if(mark[i][j])	cnt++;
			//cout<<mark[i][j];
		}
		//cout<<endl;
	}

	cout<<(m-cnt);

	return 0;
}



Compiler output:
a.cc: In function 'void floydWarshall()':
a.cc:22:13: error: reference to 'prev' is ambiguous
   22 |             prev[i][j] = i;
      |             ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:35:24: error: reference to 'prev' is ambiguous
   35 |                     if(prev[i][j] != -1) {
      |                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:36:40: error: reference to 'prev' is ambiguous
   36 |                                 if(cnt[prev[i][j]][j] == 1)     mark[prev[i][j]][j] = 0;
      |                                        ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:36:70: error: reference to 'prev' is ambiguous
   36 |                                 if(cnt[prev[i][j]][j] == 1)     mark[prev[i][j]][j] = 0;
      |                                                                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:37:33: error: reference to 'prev' is ambiguous
   37 |                             cnt[prev[i][j]][j]--;
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:41:21: error: reference to 'prev' is ambiguous
   41 |                     prev[i][j] = k;
      |                     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:77:16: error: reference to 'prev' is ambiguous
   77 |         memset(prev, -1, sizeof(prev));
      |                ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~
a.cc:77:33: error: reference to 'prev' is ambiguous
   77 |         memset(prev, -1, sizeof(prev));
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:8:5: note:                 'int prev [101][101]'
    8 | int prev[101][101];
      |     ^~~~