Language: C++

#include<bits/stdc++.h>

using namespace std;

#define allof(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1e5 + 5;
const ll mod = 1e9 + 7;

int N, M;
int S, T;

ll best[2][MAXN];
vector<pll> adj[MAXN];
vector<pll> pth[2][MAXN];

void dijkstra(int tp){
    memset(best[tp], 0x3f, sizeof best[tp]);
    best[tp][tp == 0 ? S : T] = 0;

    priority_queue<pll, vector<pll>, greater<pll>> pq;
    pq.push({0, tp == 0 ? S : T});
    while(!pq.empty()){
        pll top = pq.top();
        pq.pop();

        for(pll p : adj[top.second]){
            if(top.first + p.second < best[tp][p.first]){
                best[tp][p.first] = top.first + p.second;
                pq.push({best[tp][p.first], p.first});
            }
        }
    }
}

int incoming[2][MAXN];
ll pcnt[2][MAXN];

void count_path(int tp){
    pcnt[tp][tp == 0 ? S : T] = 1;
    queue<int> q;
    q.push(tp == 0 ? S : T);
    while(!q.empty()){
        int fr = q.front();
        q.pop();
        for(int i : pth[tp][fr]){
            pcnt[tp][i] += pcnt[tp][fr];
            pcnt[tp][i] %= mod;

            incoming[tp][i]--;
            if(!incoming[tp][i]){
                q.push(i);
            }
        }
    }
}

int main(){
    cin.tie(0);
    cin.sync_with_stdio(0);

    cin >> N >> M;
    cin >> S >> T;
    for(int a = 0; a < M; a++){
        int u, v, c;
        cin >> u >> v >> c;
        adj[u].push_back(pll(v, c));
        adj[v].push_back(pll(u, c));
    }

    dijkstra(0);
    dijkstra(1);

    for(int a = 1; a <= N; a++){
        if(best[0][a] + best[1][a] != best[0][T]){
            continue;
        }
        for(pll p : adj[a]){
            if(best[0][a] + p.second == best[0][p.first] && best[0][p.first] + best[1][p.first] == best[0][T]){
                pth[0][a].push_back(p);

                incoming[0][p.first]++;
            }
            if(best[1][a] + p.second == best[1][p.first] && best[0][p.first] + best[1][p.first] == best[0][T]){
                pth[1][a].push_back(p);

                incoming[1][p.first]++;
            }
        }
    }
    count_path(0);
    count_path(1);

    ll ans = pcnt[0][T] * pcnt[1][S] % mod;
    //cout << "Initially " << ans << endl;
    for(int a = 1; a <= N; a++){
        //cout << "at " << a << endl;
        if(best[0][a] == best[1][a]){
            //cout << "A -= " << pcnt[0][a] << " * " << pcnt[1][a] << endl;
            ans -= pcnt[0][a] * pcnt[1][a];
            ans %= mod;
        }
        for(pll p : pth[0][a]){
            //cout << "going to " << i << endl;
            if(best[0][a] * 2 < best[0][T] && best[0][T] < (best[0][a] + p.second) * 2){
                //cout << "B -= " << pcnt[1][i] << " * " << pcnt[0][a] << endl;
                ans -= pcnt[1][i] * pcnt[0][a];
                ans %= mod;
            }
        }
        //cout << endl;
    }
    ans %= mod;
    if(ans < 0){
        ans += mod;
    }
    cout << ans % mod;
}


Compiler output:
a.cc: In function 'void count_path(int)':
a.cc:50:31: error: cannot convert 'std::pair<long long int, long long int>' to 'int' in initialization
   50 |         for(int i : pth[tp][fr]){
      |                               ^
a.cc: In function 'int main()':
a.cc:111:32: error: 'i' was not declared in this scope
  111 |                 ans -= pcnt[1][i] * pcnt[0][a];
      |                                ^