Language: C++

#include <bits/stdc++.h>

#define X first
#define Y second
#define pb push_back

using namespace std;

const long long INF = 1e18;
const long long mod = 1e9 + 7;
signed main() {
    ios_base::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;

    vector <long long> d(n, INF), c(n, 0);
    d[--s] = 0;
    c[s] = 1;

    set < pair <long long, int> > Q;
    for (int i = 0; i < n; i++)
        Q.insert({d[i], i});

    for (int i = 0; i < m; i++)
    {
        int u, v, cost;
        cin >> u >> v >> cost;
        u--, v--;
        g[u].pb({v, cost});
        g[v].pb({u, cost});
    }

    while (!Q.empty())
    {
        pair <long long, int> t = *Q.begin();
        Q.erase(Q.begin());
        int v = t.Y;
        for (auto e : g[v])
        {
            if (d[e.X] < d[v] + e.Y) continue;
            if (d[e.X] == d[v] + e.Y) {c[e.X] += c[v]; c[e.X] %= mod continue;}
            Q.erase({d[e.X], e.X});
            d[e.X] = d[v] + e.Y;
            c[e.X] = c[v];
            Q.insert({d[e.X], e.X});
        }
    }
    t--;
    cout << (c[t] * (c[t] - 1) / 2) % mod;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'g' was not declared in this scope
   29 |         g[u].pb({v, cost});
      |         ^
a.cc:38:23: error: 'g' was not declared in this scope
   38 |         for (auto e : g[v])
      |                       ^
a.cc:42:20: error: no matching function for call to 'std::set<std::pair<long long int, int> >::erase(<brace-enclosed initializer list>)'
   42 |             Q.erase({d[e.X], e.X});
      |             ~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:656:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator]'
  656 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:656:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<long long int, int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator'}
  656 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:686:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; size_type = long unsigned int; key_type = std::pair<long long int, int>]'
  686 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:686:29: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<long long int, int> >::key_type&' {aka 'const std::pair<long long int, int>&'}
  686 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:708:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator]'
  708 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:708:7: note:   candidate expects 2 arguments, 1 provided
a.cc:45:21: error: no matching function for call to 'std::set<std::pair<long long int, int> >::insert(<brace-enclosed initializer list>)'
   45 |             Q.insert({d[e.X], e.X});
      |             ~~~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note: candidate: 'template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >]'
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_set.h:568:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:511:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::pair<long long int, int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, int> >, std::pair<long long int, int> >::rebind<std::pair<long long int, int> >; typename _Alloc::value_type = std::pair<long long int, int>; value_type = std::pair<long long int, int>]'
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<long long int, int> >::value_type&' {aka 'const std::pair<long long int, int>&'}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:520:7: note: candidate: 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::pair<long long int, int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, int> >, std::pair<long long int, int> >::rebind<std::pair<long long int, int> >; typename _Alloc::value_type = std::pair<long long int, int>; value_type = std::pair<long long int, int>]'
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::set<std::pair<long long int, int> >::value_type&&' {aka 'std::pair<long long int, int>&&'}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:548:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; value_type = std::pair<long long int, int>]'
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:553:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, value_type&&) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >; iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, int>, std::pair<long long int, int>, std::_Identity<std::pair<long long int, int> >, std::less<std::pair<long long int, int> >, std::allocator<std::pair<long long int, int> > >::const_iterator; value_type = std::pair<long long int, int>]'
  553 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_set.h:553:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_set.h:580:7: note: candidate: 'void std::set<_Key, _Compare, _Alloc>::insert(std::initializer_list<_Tp>) [with _Key = std::pair<long long int, int>; _Compare = std::less<std::pair<long long int, int> >; _Alloc = std::allocator<std::pair<long long int, int> >]'
  580 |       insert(initializer_list<value_type> __l)