Language: C++

/*https://atcoder.jp/contests/abc143/submissions/14402758*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
    int n,m,l;
    cin>>n>>m>>l;
    int a[m],b[m],c[m];
    vector<vector<int>>length(n,vector<int>(n,2000000000));
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        length[a[i]-1][b[i]-1]=c[i];
        length[b[i]-1][a[i]-1]=c[i];
    }
    for(int i=0;i<n;i++)length[i][i]=0;
    vector<vector<int>>way(n,vector<int>(n,-1));
    for(int i=0;i<n;i++){
        int used[n]={};
        P d[n];
        for(int j=0;j<n;j++)d[j]={10000,l};
        d[i]={0,0};
        while(true){
            int v=-1;//未確定
            for(int j=0;j<n;j++){
                if(used[j]==0 && (v==-1 || d[j]<d[v]))v=j;//更新
            }
            if(v==-1)break;
            used[v]=1;
            if(d[v].first<10000)way[i][v]=d[v].first;
            for(int j=0;j<n;j++){
                //cout<<d[v].first<<" "<<d[v].second<<" "<<length[v][j]<<endl;
                if(d[v]<d[j]){
                    if(l-d[v].second>=length[v][j]){
                        d[j]={d[v].first,d[v].second+length[v][j]};
                    }
                    else if(l>=length[v][j]){
                        d[j]={d[v].first+1,length[v][j]};
                    }
                }
            }
        }
    }
    int q;
    cin>>q;
    int s[q],t[q];
    for(int i=0;i<q;i++)cin>>s[i]>>t[i];
    for(int i=0;i<q;i++)cout<<way[s[i]-1][t[i]-1]<<endl;
    return 0;
}

typedef pair<ll,ll> P;
int main(){
    ll n,m,l;
    cin>>n>>m>>l;
    ll a[m],b[m],c[m];
    vector<vector<ll>>length(n,vector<ll>(n,2000000000));
    for(ll i=0;i<m;i++){
        cin>>a[i]>>b[i]>>c[i];
        length[a[i]-1][b[i]-1]=c[i];
        length[b[i]-1][a[i]-1]=c[i];
    }
    for(ll i=0;i<n;i++)length[i][i]=0;
    vector<vector<ll>>way(n,vector<ll>(n,-1));
    for(ll i=0;i<n;i++){
        ll used[n]={};
        P d[n];
        for(ll j=0;j<n;j++)d[j]={10000,l};
        d[i]={0,0};
        while(true){
            ll v=-1;//未確定
            for(ll j=0;j<n;j++){
                if(used[j]==0 && (v==-1 || d[j]<d[v]))v=j;//更新
            }
            if(v==-1)break;
            used[v]=1;
            if(d[v].first<10000)way[i][v]=d[v].first;
            for(ll j=0;j<n;j++){
                //cout<<d[v].first<<" "<<d[v].second<<" "<<length[v][j]<<endl;
                if(d[v]<d[j]){
                    if(l-d[v].second>=length[v][j]){
                        d[j]={d[v].first,d[v].second+length[v][j]};
                    }
                    else if(l>=length[v][j]){
                        d[j]={d[v].first+1,length[v][j]};
                    }
                }
            }
        }
    }
    ll q;
    cin>>q;
    ll s[q],t[q];
    for(ll i=0;i<q;i++)cin>>s[i]>>t[i];
    for(ll i=0;i<q;i++)cout<<way[s[i]-1][t[i]-1]<<endl;
    return 0;
}


Compiler output:
a.cc:4:22: error: stray '#' in program
    4 | using ll = long long;#include<bits/stdc++.h>
      |                      ^
a.cc:4:23: error: 'include' does not name a type
    4 | using ll = long long;#include<bits/stdc++.h>
      |                       ^~~~~~~
a.cc:53:21: error: conflicting declaration 'typedef struct std::pair<long long int, long long int> P'
   53 | typedef pair<ll,ll> P;
      |                     ^
a.cc:6:23: note: previous declaration as 'typedef struct std::pair<int, int> P'
    6 | typedef pair<int,int> P;
      |                       ^
a.cc:54:5: error: redefinition of 'int main()'
   54 | int main(){
      |     ^~~~
a.cc:7:5: note: 'int main()' previously defined here
    7 | int main(){
      |     ^~~~