Language: C++

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

set<pair<int,int>> used_edge;

template <typename T>
class Dijkstra {
    struct edge { int to; T cost; };
    typedef pair<T, int> P; // <譛遏ｭ霍晞屬, 鬆らせ逡ｪ蜿ｷ>

public:
    T INF;

    Dijkstra(int V) 
        : INF(std::numeric_limits<T>::max())
        , m_V(V)
        {
        m_G.resize(m_V);
    }

    // a -> b縺ｫ迚・婿蜷代・繧ｨ繝・ず繧貞ｼｵ繧・    void add_dir_edge(int a, int b, T cost) {
        m_G[a].push_back( edge{ b, cost } );
    }

    // a <-> b縺ｫ荳｡譁ｹ蜷代・繧ｨ繝・ず繧貞ｼｵ繧・    void add_undir_edge(int a, int b, T cost) {
        add_dir_edge(a, b, cost);
        add_dir_edge(b, a, cost);
    }

    // 鬆らせs縺九ｉ蜷・らせ縺ｾ縺ｧ縺ｮ霍晞屬繧定ｨ育ｮ励＠縺ｦ霑斐☆
    vector<T> shortest_path(int s) {
        vector<T> d(m_V, INF);
        vector<pair<int,int>> last_edge(m_V);

        priority_queue<P, vector<P>, greater<P> > que;
        d[s] = 0;
        que.push(P(0, s));
    
        while(!que.empty()) {
            P p = que.top();
            que.pop();

            auto dist = p.first;
            auto v = p.second;
            if (d[v] < dist) continue;
            REP(i, m_G[v].size()) {
                edge e = m_G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                    last_edge[e.to] = mp(v, e.to);
                }
            }
        }

        for (auto edge : last_edge) {
            int v1 = edge.first;
            int v2 = edge.second;
            if (v1 != v2) {
                used_edge.insert(mp(v1,v2));
                used_edge.insert(mp(v2,v1));
            }
        }

        return d;
    }

private:
    int m_V;
    vector<vector<edge> > m_G;
};

int main(void)
{
    cin.sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    Dijkstra<int> dij(N);
    REP(m,M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dij.add_undir_edge(a, b, c);
    }
    REP(n,N) {
        auto res = dij.shortest_path(n);
    }
    cout << (M - (SIZE(used_edge) / 2)) << endl;

    return 0;
}


Compiler output:
a.cc:50:9: error: 'm_G' does not name a type
   50 |         m_G[a].push_back( edge{ b, cost } );
      |         ^~~
a.cc:50:43: error: expected unqualified-id before ')' token
   50 |         m_G[a].push_back( edge{ b, cost } );
      |                                           ^
a.cc: In constructor 'Dijkstra<T>::Dijkstra(int)':
a.cc:44:11: error: class 'Dijkstra<T>' does not have any field named 'm_V'
   44 |         , m_V(V)
      |           ^~~
a.cc:46:9: error: 'm_G' was not declared in this scope
   46 |         m_G.resize(m_V);
      |         ^~~
a.cc:46:20: error: 'm_V' was not declared in this scope
   46 |         m_G.resize(m_V);
      |                    ^~~
a.cc: At global scope:
a.cc:51:6: error: expected ';' before 'add_dir_edge'
   51 |     }
      |      ^
      |      ;
......
   54 |         add_dir_edge(a, b, cost);
      |         ~~~~~~~~~~~~
a.cc:55:21: error: expected constructor, destructor, or type conversion before '(' token
   55 |         add_dir_edge(b, a, cost);
      |                     ^
a.cc:56:5: error: expected declaration before '}' token
   56 |     }
      |     ^
a.cc:59:12: error: 'T' was not declared in this scope
   59 |     vector<T> shortest_path(int s) {
      |            ^
a.cc:59:13: error: template argument 1 is invalid
   59 |     vector<T> shortest_path(int s) {
      |             ^
a.cc:59:13: error: template argument 2 is invalid
a.cc: In function 'int shortest_path(int)':
a.cc:60:16: error: 'T' was not declared in this scope
   60 |         vector<T> d(m_V, INF);
      |                ^
a.cc:60:17: error: template argument 1 is invalid
   60 |         vector<T> d(m_V, INF);
      |                 ^
a.cc:60:17: error: template argument 2 is invalid
a.cc:60:21: error: 'm_V' was not declared in this scope
   60 |         vector<T> d(m_V, INF);
      |                     ^~~
a.cc:60:26: error: 'INF' was not declared in this scope
   60 |         vector<T> d(m_V, INF);
      |                          ^~~
a.cc:60:29: error: expression list treated as compound expression in initializer [-fpermissive]
   60 |         vector<T> d(m_V, INF);
      |                             ^
a.cc:63:24: error: 'P' was not declared in this scope
   63 |         priority_queue<P, vector<P>, greater<P> > que;
      |                        ^
a.cc:63:35: error: template argument 2 is invalid
   63 |         priority_queue<P, vector<P>, greater<P> > que;
      |                                   ^
a.cc:63:49: error: template argument 1 is invalid
   63 |         priority_queue<P, vector<P>, greater<P> > que;
      |                                                 ^
a.cc:63:49: error: template argument 2 is invalid
a.cc:63:49: error: template argument 3 is invalid
a.cc:64:10: error: invalid types 'int[int]' for array subscript
   64 |         d[s] = 0;
      |          ^
a.cc:65:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   65 |         que.push(P(0, s));
      |             ^~~~
a.cc:67:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
   67 |         while(!que.empty()) {
      |                    ^~~~~
a.cc:68:14: error: expected ';' before 'p'
   68 |             P p = que.top();
      |              ^~
      |              ;
a.cc:69:17: error: request for member 'pop' in 'que', which is of non-class type 'int'
   69 |             que.pop();
      |                 ^~~
a.cc:71:25: error: 'p' was not declared in this scope
   71 |             auto dist = p.first;
      |                         ^
a.cc:74:20: error: 'm_G' was not declared in this scope
   74 |             REP(i, m_G[v].size()) {
      |                    ^~~
a.cc:23:43: note: in definition of macro 'REP'
   23 | #define REP(i,n) for(int i = 0; i < (int)(n); ++i)
      |                                           ^
a.cc:75:17: error: 'edge' was not declared in this scope
   75 |                 edge e = m_G[v][i];
      |                 ^~~~
a.cc:76:23: error: 'e' was not declared in this scope
   76 |                 if (d[e.to] > d[v] + e.cost) {
      |                       ^
a.cc:78:25: error: request for member 'push' in 'que', which is of non-class type 'int'
   78 |                     que.push(P(d[e.to], e.to));
      |                         ^~~~
a.cc: At global scope:
a.cc:96:1: error: expected unqualified-id before 'private'
   96 | private:
      | ^~~~~~~
a.cc:98:19: error: 'edge' was not declared in this scope
   98 |     vector<vector<edge> > m_G;
      |                   ^~~~
a.cc:98:23: error: template argument 1 is invalid
   98 |     vector<vector<edge> > m_G;
      |                       ^
a.cc:98:23: error: template argument 2 is invalid
a.cc:98:25: error: template argument 1 is invalid
   98 |     vector<vector<edge> > m_G;
      |                         ^
a.cc:98:25: error: template argument 2 is invalid
a.cc:99:1: error: expected declaration before '}' token
   99 | };
      | ^
a.cc: In function 'int main()':
a.cc:112:13: error: 'class Dijkstra<int>' has no member named 'add_undir_edge'
  112 |         dij.add_undir_edge(a, b, c);
      |             ^~~~~~~~~~~~~~
a.cc:115:24: error: 'class Dijkstra<int>' has no member named 'shortest_path'
  115 |         auto res = dij.shortest_path(n);
      |                        ^~~~~~~~~~~~~