criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N,M,L; cin>>N>>M>>L;
  vector<vector<pii>> A(N);
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    A[X-1].pb(mp(Y-1,Z));
    A[Y-1].pb(mp(X-1,Z));
  }
  vector<vector<pii>> F(N,vector<pii>(N,mp(MOD,MOD)));
  rep(i,0,N){
    priority_queue<pair<int,pii>,vector<pair<int,pii>>,greater<pair<int,pii>>> Q;
    Q.push(mp(0,mp(0,i)));
    F[i][i]=mp(0,0);
    while(Q.size()>0){
      int X=Q.top().first,Y=Q.top().second.second,Z=L-Q.top().second.first;
      Q.pop();
      rep(j,0,A[Y].size()){
        int B=A[Y][j].first,C=A[Y][j].second,D=X,E=Z;
        if(E<C){
          D++;
          E=L;
        }
        if(E>=C&&F[i][B]>mp(D,L-E)){
          F[i][B]=mp(D,L-E);
          Q.push(mp(D,mp(L-E,B)));
        }
      }
    }
  }
  int Q; cin>>Q;
  rep(_,0,Q){
    int S,T; cin>>S>>T;
    int ans=F[S-1][T-1];
    if(ans==MOD)
      ans=-1;
    cout<<ans<<endl;
  }
  }


Compiler output:
a.cc: In function 'int main()':
a.cc:50:23: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'long long int' in initialization
   50 |     int ans=F[S-1][T-1];
      |                       ^
Language: C++

#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
typedef long long ll;
const ll INF=0x3f;
ll dist1[310][310],dist2[310][310];
int main()
{
    int n,m,l,q;
    scanf("%d%d%d",&n,&m,&l);
    memset(dist1, 0x3f, sizeof(dist1));
    memset(dist2, 0x3f, sizeof(dist2));
    for(int i=0; i<n; i++)
    {
        dist1[i][i]=0;
        dist2[i][i]=0;
    }
    for(int i=0; i<m; i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        a--;
        b--;
        dist1[a][b]=dist1[b][a]=c;
    }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist1[i][j]=min(dist1[i][j], dist1[i][k]+dist[k][j]);
            }
    for(i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(dist1[i][j]<1) dist2[i][j]=1;
        }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist[j][k]);
            }
    scanf("%d",&q);
    for(int i=0; i<q; i++)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        if(dist2[s][t]==INF) printf("%d",-1);
        else printf("%lld", dist2[s][t]-1);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:58: error: 'dist' was not declared in this scope; did you mean 'dist2'?
   41 |                 dist1[i][j]=min(dist1[i][j], dist1[i][k]+dist[k][j]);
      |                                                          ^~~~
      |                                                          dist2
a.cc:43:9: error: 'i' was not declared in this scope
   43 |     for(i=0; i<n; i++)
      |         ^
a.cc:52:58: error: 'dist' was not declared in this scope; did you mean 'dist2'?
   52 |                 dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist[j][k]);
      |                                                          ^~~~
      |                                                          dist2
Language: C++

#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
typedef long long ll;
const ll INF=0x3f;
ll dist[310][310],dist2[310][310];
int main()
{
    int n,m,l,q;
    scanf("%d%d%d",&n,&m,&l);
    memset(dist1, 0x3f, sizeof(dist1));
    memset(dist2, 0x3f, sizeof(dist2));
    for(int i=0; i<n; i++)
    {
        dist1[i][i]=0;
        dist2[i][i]=0;
    }
    for(int i=0; i<m; i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        a--;
        b--;
        dist1[a][b]=dist1[b][a]=c;
    }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist1[i][j]=min(dist1[i][j], dist1[i][k]+dist[k][j]);
            }
    for(i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(dist1[i][j]<1) dist2[i][j]=1;
        }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist[j][k]);
            }
    scanf("%d",&q);
    for(int i=0; i<q; i++)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        if(dist2[s][t]==INF) printf("%d",-1);
        else printf("%lld", dist2[s][t]-1);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: 'dist1' was not declared in this scope; did you mean 'dist2'?
   22 |     memset(dist1, 0x3f, sizeof(dist1));
      |            ^~~~~
      |            dist2
a.cc:43:9: error: 'i' was not declared in this scope
   43 |     for(i=0; i<n; i++)
      |         ^
Language: C++

#include <iostream> 
#include <cstdio> 
#include <fstream> 
#include <algorithm> 
#include <cmath> 
#include <deque> 
#include <vector> 
#include <queue> 
#include <string> 
#include <cstring> 
#include <map> 
#include <stack> 
#include <set> 
using namespace std;
typedef long long ll;
const ll INF=0x3f;
ll dist[310][310],dist2[310][310];
int main()
{
    int n,m,l,q;
    scanf("%d%d%d",&n,&m,&l);
    memset(dist1, 0x3f, sizeof(dist1));
    memset(dist2, 0x3f, sizeof(dist2));
    for(int i=0; i<n; i++)
    {
        dist1[i][i]=0;
        dist2[i][i]=0;
    }
    for(int i=0; i<m; i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        a--;
        b--;
        dist1[a][b]=dist1[b][a]=c;
    }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist1[i][j]=min(dist1[i][j], dist1[i][k]+dist[k][j]);
            }
    for(i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(dist1[i][j]<1) dist2[i][j]=1;
        }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist[j][k]);
            }
    scanf("%d",&q);
    for(int i=0; i<q; i++)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        if(dist2[s][t]==INF) printf("%d",-1);
        else printf("%lld", dist2[s][t]-1);
    }
    return 0;
}


Compiler output:
a.cc:1:10: error: extended character   is not valid in an identifier
    1 | #include <iostream> 
      |          ^
a.cc:1:10: fatal error: iostream>�: No such file or directory
    1 | #include <iostream> 
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=0x3f;
ll dist[310][310],dist2[310][310];
int main()
{
    int n,m,l,q;
    scanf("%d%d%d",&n,&m,&l);
    memset(dist1, 0x3f, sizeof(dist1));
    memset(dist2, 0x3f, sizeof(dist2));
    for(int i=0; i<n; i++)
    {
        dist1[i][i]=0;
        dist2[i][i]=0;
    }
    for(int i=0; i<m; i++)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        a--;
        b--;
        dist1[a][b]=dist1[b][a]=c;
    }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist1[i][j]=min(dist1[i][j], dist1[i][k]+dist[k][j]);
            }
    for(i=0; i<n; i++)
        for(int j=0; j<n; j++)
        {
            if(dist1[i][j]<1) dist2[i][j]=1;
        }
    for(int k=0; k<n; k++)
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
            {
                dist2[i][j]=min(dist2[i][j], dist2[i][k]+dist[j][k]);
            }
    scanf("%d",&q);
    for(int i=0; i<q; i++)
    {
        int s,t;
        scanf("%d%d",&s,&t);
        if(dist2[s][t]==INF) printf("%d",-1);
        else printf("%lld", dist2[s][t]-1);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:12: error: 'dist1' was not declared in this scope; did you mean 'dist2'?
   10 |     memset(dist1, 0x3f, sizeof(dist1));
      |            ^~~~~
      |            dist2
a.cc:31:9: error: 'i' was not declared in this scope
   31 |     for(i=0; i<n; i++)
      |         ^
Language: C++

#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;


int main(void)
{
  ll n,m,l;
  cin >> n >> m >> l;
  ll dist[301][301];
  REP(i,301) REP(j,301) dist[i][j]=l+1;
  REP(i,m) {
    ll a,b,c;
    cin >> a >> b >> c;
    dist[a][b]=c;
    dist[b][a]=c;
  }
  REP(k,n+1)REP(i,n+1)REP(j,n+1)
    dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
  REP(i,n+1)REP(j,n+1)
    if(dist[i][j]<=l) dist[i][j]=1;
    else dist[i][j]=n;
  REP(k,n+1)REP(i,n+1)REP(j,n+1)
    dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]);
  ll q;
  cin >> q;
  REP(i,q) {
    ll s,t;
    cin >> s >> t;
    ll answer = dist[i][j];
    if(answer>=n) answer = -1;
    cout << answer << endl;
  }
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:33:25: error: 'j' was not declared in this scope
   33 |     ll answer = dist[i][j];
      |                         ^
Language: Java

import java.util.Scanner;

public class Solution {
    static Scanner sc;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        long[][] graph = new long[N][N];
        int[] A = new int[M];int[] B = new int[M];int[] C = new int[M];
        for(int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
            graph[A[i] - 1][B[i] - 1] = C[i];
            graph[B[i] - 1][A[i] - 1] = C[i];
        }

        for(int i = 0; i < N; i++) {
            graph[i][i] = 0;
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(graph[i][j] == 0) {
                        graph[i][j] = (long)10e10;
                    }
                    if(graph[i][j] > graph[i][k] + graph[k][j]) {
                        graph[i][j] = graph[i][k] + graph[k][j];
                    }
                }
            }
        }

        long[][] floyd = new long[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                floyd[i][j] = graph[i][j] <= L ? 1 : (long)10e10;
            }
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(floyd[i][j] > floyd[i][k] + floyd[k][j]) {
                        floyd[i][j] = floyd[i][k] + floyd[k][j];
                    }
                }
            }
        }

        int Q = sc.nextInt();
        for(int i = 0; i < Q; i++) {
            int s = sc.nextInt(); int t = sc.nextInt();
            long ans = -1;
            if(s > t) {
                ans = floyd[t-1][s-1] - 1;
            } else {
                ans = floyd[s-1][t-1] - 1;
            }
            if(ans >= (long)10e10 - 1) {
                System.out.println("-1");
            } else {
                System.out.println(ans);
            }
        }
    }
}

Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: Java

import java.util.Scanner;

public class Solution {
    static Scanner sc;
    static boolean[][] dp;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        int[][] graph = new int[N][N];
        int[] A = new int[M];int[] B = new int[M];int[] C = new int[M];
        for(int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
            graph[A[i] - 1][B[i] - 1] = C[i];
            graph[B[i] - 1][A[i] - 1] = C[i];
        }

        for(int i = 0; i < N; i++) {
            graph[i][i] = 0;
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(graph[i][j] == 0) {
                        graph[i][j] = Integer.MAX_VALUE/2 - 1;
                    }
                    if(graph[i][j] > graph[i][k] + graph[k][j]) {
                        graph[i][j] = graph[i][k] + graph[k][j];
                    }
                }
            }
        }

        int[][] floyd = new int[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                floyd[i][j] = graph[i][j] <= L ? 1 : Integer.MAX_VALUE/2 - 1;
            }
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(floyd[i][j] > floyd[i][k] + floyd[k][j]) {
                        floyd[i][j] = floyd[i][k] + floyd[k][j];
                    }
                }
            }
        }

        int Q = sc.nextInt();
        for(int i = 0; i < Q; i++) {
            int s = sc.nextInt(); int t = sc.nextInt();
            int ans = -1;
            if(s > t) {
                ans = floyd[t-1][s-1] - 1;
            } else {
                ans = floyd[s-1][t-1] - 1;
            }
            if(ans >= Integer.MAX_VALUE/2 - 3) {
                System.out.println("-1");
            } else {
                System.out.println(ans);
            }
        }
    }
}

Compiler output:
Main.java:3: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Solution {
    static Scanner sc;
    static boolean[][] dp;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int L = sc.nextInt();
        int[][] graph = new int[N][N];
        int[] A = new int[M];int[] B = new int[M];int[] C = new int[M];
        for(int i = 0; i < M; i++) {
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
            C[i] = sc.nextInt();
            graph[A[i] - 1][B[i] - 1] = C[i];
            graph[B[i] - 1][A[i] - 1] = C[i];
        }

        for(int i = 0; i < N; i++) {
            graph[i][i] = 0;
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(graph[i][j] == 0) {
                        graph[i][j] = Integer.MAX_VALUE/2 - 1;
                    }
                    if(graph[i][j] > graph[i][k] + graph[k][j]) {
                        graph[i][j] = graph[i][k] + graph[k][j];
                    }
                }
            }
        }

        int[][] floyd = new int[N][N];
        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                floyd[i][j] = graph[i][j] <= L ? 1 : Integer.MAX_VALUE/2 - 1;
                //System.out.print(floyd[i][j] + " ");
            }
           // System.out.println();
        }

        for(int k = 0; k < N; k++) {
            for(int i = 0; i < N; i++) {
                for(int j = i + 1; j < N; j++) {
                    if(floyd[i][j] > floyd[i][k] + floyd[k][j]) {
                        floyd[i][j] = floyd[i][k] + floyd[k][j];
                    }
                }
            }
        }

        for(int i = 0; i < N; i++) {
            for(int j = i + 1; j < N; j++) {
                //System.out.println(floyd[i][j]);
            }
        }

        int Q = sc.nextInt();
        for(int i = 0; i < Q; i++) {
            int s = sc.nextInt(); int t = sc.nextInt();
            int ans = -1;
            if(s > t) {
                ans = floyd[t-1][s-1] - 1;
            } else {
                ans = floyd[s-1][t-1] - 1;
            }
            if(ans >= Integer.MAX_VALUE/2 - 3) {
                System.out.println("-1");
            } else {
                System.out.println(ans);
            }
        }
    }
}

Compiler output:
Main.java:6: error: class Solution is public, should be declared in a file named Solution.java
public class Solution {
       ^
1 error
Language: C++

#include<bits\stdc++.h>

using namespace std;

int d[310][310];
int f[310][310];

const int INF = 0x3f3f3f3f;
int main(){
    int n, m, L;
    cin >>n >>m >>L;

    memset(d, INF, sizeof(d));
    memset(f, INF, sizeof(f));

    for(int i=0;i<m;i++){
        int a, b, c;
        cin >>a>>b>>c;
        d[a][b] = c;
        d[b][a] = c;
    }
    for(int i=1;i<=n;i++){
        d[i][i] = 0;
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }


    for(int i=1;i<=n;i++){
        for(int j =1;j<=n;j++){
            if(d[i][j] <= L){
                f[i][j] = 0;
            }
        }
    }

    for(int k=1;k<=n;k++){
        for(int i=1;i<=n;i++){
            if(i==k)
                continue;
            for(int j=1;j<=n;j++){
                if(i==j || k==j)
                    continue;
                f[i][j] = min(f[i][j], f[i][k] + f[k][j] + 1);
            }
        }
    }

    int q;
    cin >>q;
    while(q--){
        int s, t;
        cin >>s>>t;
        if(f[s][t] == INF)
            cout <<-1 <<endl;
        else
            cout <<f[s][t] <<endl;
    }
}



Compiler output:
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
    1 | #include<bits\stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <boost/optional.hpp>
auto const none = boost::none;


template<class T> struct Graph {
  using size_t = std::size_t;
  size_t n; std::vector<std::vector<boost::optional<T>>> dat;
  Graph() {}
  Graph(size_t n) : n(n), dat(n, std::vector<boost::optional<T>>(n)) {}
  void init(size_t n) { this->n = n; dat.resize(n); for(size_t i=0;i<n;++i) dat[i].assign(n, none); }
  auto& operator[](size_t i) { return dat[i]; }
  void de(size_t i, size_t j, T v) { dat[i][j] = v; }
  void e(size_t i, size_t j, T v) { de(i, j, v); de(j, i, v); }
  auto begin() { return dat.begin(); }
  auto end() { return dat.end(); }
  size_t size() const { return n; }
  void wf() {
    for(size_t k=0; k<size(); ++k) for(size_t i=0; i<size(); ++i) for(size_t j=0; j<size(); ++j) {
      if(!dat[i][k] || !dat[k][j]) continue;
      T v = *dat[i][k] + *dat[k][j];
      if(!dat[i][j] || v < *dat[i][j]) dat[i][j] = v;
    }
  }
};


void abc143_e() {
  int N, M; long long L;
  std::cin >> N >> M >> L;
  Graph<long long> g(N);
  for(int i=0;i<M;++i) {
    int A, B, C;
    std::cin >> A >> B >> C;
    g.e(--A, --B, C);
  }

  g.wf();
  for(auto& v : g) for(auto& e : v) if(e && *e <= L) e = 1; else e = none;
  g.wf();

  int Q; cin >> Q;
  for(int i=0;i<Q;++i) {
    int s, t;
    std::cin >> s >> t;
    --s; --t;
    std::cout << (g[s][t] ? *g[s][t]-1 : -1) << '\n';
  }
}

signed main() {

  abc143_e();

  return 0;
}


Compiler output:
a.cc:3:10: fatal error: boost/optional.hpp: No such file or directory
    3 | #include <boost/optional.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;
const ll INF=1e18+10;

int N, M;
ll L;
ll cost[305][305];
void input(){
  	cin>>N>>M>>L;
	rep1(i, N)rep1(j, N){
		if(i == j) cost[i][j]=0;
		else cost[i][j] = INF;
	}
	rep(_, M){
		int A, B;
		ll C;
		cin>>A>>B>>C;
		cost[A][B]=C;
		cost[B][A]=C;
	}

}
int ch[305][305];
void solve(){
	rep1(k, N)rep1(i, N)rep1(j, N)cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
	rep1(i, N)rep1(j, N){
		if(i == j)ch[i][j]=0;
		else if(cost[i][j]<=L) ch[i][j]=1;
		else ch[i][j] = MAX;
	}
	rep1(k ,N)rep1(i, N)rep1(j, N) ch[i][j]= min(ch[i][j], ch[i][k]+ch[k][j]);

}

void output(){
	int Q;
	cin>>Q;
	rep(_,Q){
		int s, t;
		cin>>s>>t;
		if(ch[s][t] == MAX) cout<<-1<<endl;
		else cout<<ch[s][t]-1<<endl;
	}
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1e17

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

void solve(){
   
    int n,m,l;
    cin >> n >> m >> l;

    int fuel[n+2][n+2] = {inf};
    int dist[n+2][n+2] = {inf};
    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            //cout << fuel[i][j] << endl;
            fuel[i][j] = inf;
            dist[i][j] = inf;
        }
        dist[i][i] = 0;
        fuel[i][i] = 0;
    }

    for(int i = 0;i<m;i++){
        int a , b ,c;
        cin >> a >> b >> c;

        fuel[a][b] = min(fuel[a][b], c);
        fuel[b][a] = min(fuel[b][a], c);

    }
    //floyd-warshall to find the min fuel needed to go between two towns
    for(int k = 1;k<=n;k++)
    for(int i = 1;i<=n;i++){
        for(int j= 1;j<=n;j++){
            if(i==j)continue;
            fuel[i][j] = min(fuel[i][k] + fuel[k][j], fuel[i][j]); 
        }
        //fuel[i][i] = 0;
    }

    for(int i = 1;i<=n;i++){
        for(int j = 1;j<=n;j++){
            if(i==j)continue;
            if(fuel[i][j]<=l)dist[i][j] = min(dist[i][j], 1LL);
        }
        //dist[i][i] = 0;
    }

    for(int k = 1;k<=n;k++)
    for(int i = 1;i<=n;i++){
        for(int j= 1;j<=n;j++){
            //if(i==j)continue;
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]); 
        }
        //dist[i][i] = 0;
    }

    int q;
    cin >> q;
    while(q--){
        int a , b;
        cin >> a>> b;
        if(dist[a][b]<inf){
        cout << dist[a][b]-1 << endl;
         }
        else
        cout << -1 << endl;
    }


} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Compiler output:
a.cc: In function 'void solve()':
a.cc:10:13: error: narrowing conversion of '1.0e+17' from 'double' to 'long long int' [-Wnarrowing]
   10 | #define inf 1e17
      |             ^~~~
a.cc:30:27: note: in expansion of macro 'inf'
   30 |     int fuel[n+2][n+2] = {inf};
      |                           ^~~
a.cc:10:13: error: narrowing conversion of '1.0e+17' from 'double' to 'long long int' [-Wnarrowing]
   10 | #define inf 1e17
      |             ^~~~
a.cc:31:27: note: in expansion of macro 'inf'
   31 |     int dist[n+2][n+2] = {inf};
      |                           ^~~
Language: C++

#include <bits/stdc++.h>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

void waf(vector<vector<int>> &dist, int n) {
    rep(k, n) rep (i, n) rep (j , n) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
}

int main(int argc, const char * argv[]) {
    // source code
    long n, m, l;
    cin >> n >> m >> l;
    vector<vector<long>> dist(n);
    rep (i, n) dist[i].assign(n, INT_MAX);
    rep (i, m) {
        long a, b, c;
        cin >> a >> b >> c;
        dist[--a][--b] = c;
        dist[b][a] = c;
    }
    waf(dist, n);
    rep (i, n) rep (j , n) {
        if (dist[i][j] <= l) dist[i][j] = 1;
        else dist[i][j] = INT_MAX;
    }
    waf(dist, n);
    long Q;
    cin >> Q;
    rep (i, Q) {
        long s, q;
        cin >> s >> q;
        if (dist[--s][--q] < INT_MAX) cout << dist[s][q] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:27:9: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'std::vector<std::vector<long int> >'
   27 |     waf(dist, n);
      |         ^~~~
a.cc:9:31: note: in passing argument 1 of 'void waf(std::vector<std::vector<int> >&, int)'
    9 | void waf(vector<vector<int>> &dist, int n) {
      |          ~~~~~~~~~~~~~~~~~~~~~^~~~
a.cc:32:9: error: invalid initialization of reference of type 'std::vector<std::vector<int> >&' from expression of type 'std::vector<std::vector<long int> >'
   32 |     waf(dist, n);
      |         ^~~~
a.cc:9:31: note: in passing argument 1 of 'void waf(std::vector<std::vector<int> >&, int)'
    9 | void waf(vector<vector<int>> &dist, int n) {
      |          ~~~~~~~~~~~~~~~~~~~~~^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const int MOD2 = 998244353;
const double EPS = 1e-9;

int main() {
  int N, M, L; cin >> N >> M >> L;
  vector<vector<P>> edge(N);
  rep(i,M) {
    int a, b, c; cin >> a >> b >> c; --a; --b;
    edge[a].push_back(P(c, b));
    edge[b].push_back(P(c, a));
  }

  Graph move(N);
  rep(i,N) {
    priority_queue<P> pq;
    vi fuel(N, -1);
    pq.push(P(L, i));
    fuel[i] = L;

    while (!pq.empty()) {
      auto p = pq.top(); pq.pop();
      int f, v; tie(f, v) = p;
      if (fuel[v] > f) continue;

      for (auto np : edge[v]) {
        int d, nv; tie(d, nv) = np;
        if (f < d) continue;
        if (fuel[nv] >= f-d) continue;
        fuel[nv] = f-d;
        pq.push(P(f-d, nv));
      }
    }

    fuel[i] = -1;
    rep(j,N) {
      if (fuel[j] != -1) move[i].push_back(j);
    }
  }

  Graph query(N, vi(N, -1));
  rep(i,N) {
    queue<int> q;
    q.push(i);
    query[i][i] = 0;

    while (!q.empty()) {
      auto v = q.top(); q.pop();

      for (auto nv : move[v]) {
        if (query[i][nv] != -1) continue;
        query[i][nv] = query[i][v] + 1;
        q.push(nv);
      }
    }
  }

  int Q; cin >> Q;
  rep(i,Q) {
    int s, t; cin >> s >> t; --s; --t;
    if (query[s][t] == -1) cout << -1 << endl;
    else cout << query[s][t] - 1 << endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:18: error: 'class std::queue<int>' has no member named 'top'; did you mean 'pop'?
   60 |       auto v = q.top(); q.pop();
      |                  ^~~
      |                  pop
Language: Java

import java.util.*;
import java.io.*;
import java.lang.*;

public class prog {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        StringTokenizer s = new StringTokenizer(scan.nextLine());
        int N = Integer.parseInt(s.nextToken());
        int M = Integer.parseInt(s.nextToken());
        int L = Integer.parseInt(s.nextToken());

        long[][] edges = new long[N][N];
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                edges[i][j] = Integer.MAX_VALUE;

        for (int i = 0; i < M; ++i) {
            s = new StringTokenizer(scan.nextLine());
            int A = Integer.parseInt(s.nextToken()) - 1;
            int B = Integer.parseInt(s.nextToken()) - 1;
            int C = Integer.parseInt(s.nextToken());
            edges[A][B] = C;
            edges[B][A] = C;
        }

        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    edges[i][j] = Math.min(edges[i][j], edges[i][k] + edges[k][j]);
                }
            }
        }

        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < N; ++j) {
                edges[i][j] = (edges[i][j] <= L) ? 0 : Integer.MAX_VALUE;
            }
        }


        for (int k = 0; k < N; ++k) {
            for (int i = 0; i < N; ++i) {
                for (int j = 0; j < N; ++j) {
                    edges[i][j] = Math.min(edges[i][j], edges[i][k] + edges[k][j] + 1);
                }
            }
        }

        int Q = Integer.parseInt(scan.nextLine());
        for (int i = 0; i < Q; ++i) {
            s = new StringTokenizer(scan.nextLine());
            int S = Integer.parseInt(s.nextToken()) - 1;
            int T = Integer.parseInt(s.nextToken()) - 1;

            if (edges[S][T] < Integer.MAX_VALUE)
                System.out.println(edges[S][T]);
            else
                System.out.println(-1);
        }
    }
}


Compiler output:
Main.java:5: error: class prog is public, should be declared in a file named prog.java
public class prog {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const int INF = 1000000;

int N,M,L,Q; int ans = 0;


vector<vector<int> > dis(500, vector<int>(500, INF));
vector<vector<int> > Graph(500, vector<int>(500, INF));



void warshal_floyd(){
    for (int k = 0;k < N; k++){
        for (int i=0;i<N;i++){
            for (int j=0;j<N;j++){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }

    }
}
    

void input(){
    cin >> N >> M >> L;
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b;
        dis[a][b] = c;
        dis[b][a] = c;
    }
    rep(i, N){
        dis[i][i] = 0;
    }
    warshal_floyd();
}

void solve (){//xからyへ行く時の最小で何回補給する必要があるか求める。
    input();
    rep(i, N){
        rep(j, N){
            if(dis[i][j] <= L)Graph[i][j] = 1;
        }
    } 

    rep(k, N)rep(i, N)rep(j, N)Graph[i][j] = min(Graph[i][j], Graph[i][k] + Graph[k][j]);
            
    }

    int Q;cin >> Q;
    for(int i=0;i<Q;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        int ans = Graph[a][b]-1;
        if (Graph[a][b] == INF)ans = -1;
        cout << ans << endl;
    }
    return ;
}

int main () {
     solve();
     return 0;
}




Compiler output:
a.cc:61:9: error: redefinition of 'int Q'
   61 |     int Q;cin >> Q;
      |         ^
a.cc:14:11: note: 'int Q' previously declared here
   14 | int N,M,L,Q; int ans = 0;
      |           ^
a.cc:61:11: error: 'cin' does not name a type
   61 |     int Q;cin >> Q;
      |           ^~~
a.cc:62:5: error: expected unqualified-id before 'for'
   62 |     for(int i=0;i<Q;i++){
      |     ^~~
a.cc:62:17: error: 'i' does not name a type
   62 |     for(int i=0;i<Q;i++){
      |                 ^
a.cc:62:21: error: 'i' does not name a type
   62 |     for(int i=0;i<Q;i++){
      |                     ^
a.cc:70:5: error: expected unqualified-id before 'return'
   70 |     return ;
      |     ^~~~~~
a.cc:71:1: error: expected declaration before '}' token
   71 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const int INF = 1000000;

int N,M,L,Q; int ans = 0;


vector<vector<int> > dis(500, vector<int>(500, INF));
vector<vector<int> > Graph(500, vector<int>(500, INF));



void warshal_floyd(){
    for (int k = 0;k < N; k++){
        for (int i=0;i<N;i++){
            for (int j=0;j<N;j++){
                dis[i][j] = min(dis[i][j], dis[i][k] + d[k][j]);
            }
        }

    }
}
    

void input(){
    cin >> N >> M >> L;
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b; --c;
        dis[a][b] = c;
        dis[b][a] = c;
    }
    rep(i, N){
        dis[i][i] = 0;
    }
    warshal_floyd();
}

void solve (){//xからyへ行く時の最小で何回補給する必要があるか求める。
    input();
    rep(i, N){
        rep(j, N){
            if(dis[i][j] <= L)Graph[i][j] = 1;
        }
    } 

    rep(k, N){
        rep(i, N){
            rep(j, N){
                Graph[i][j] = min(Graph[i][j], Graph[i][k] + Graph[k][j]);
            }
        }
    }

    int Q;cin >> Q;
    for(int i=0;i<Q;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        int ans = Graph[a][b]-1;
        if (Graph[a][b] == INF)ans = -1;
        cout << ans << endl;
    }
    return ;
}

int main () {
     solve();
     return 0;
}




Compiler output:
a.cc: In function 'void warshal_floyd()':
a.cc:26:56: error: 'd' was not declared in this scope
   26 |                 dis[i][j] = min(dis[i][j], dis[i][k] + d[k][j]);
      |                                                        ^
Language: C++

#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <utility>
#define chmin(x, y) x = min(x , y);
#define rep(i, j) for (int (i)=0;(i)<(j);(i)++)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long int ll;

const int INF = 1000000;

int N,M,L,Q; int ans = 0;


vector<vector<int> > dis(500, vector<int>(500, IMF));
vector<vector<int> > Graph(500, vector<int>(500, IMF));

void input(){
    cin >> N >> M >> L;
    rep(i,M){
        int a, b, c;
        cin >> a >> b >> c;
        --a; --b; --c;
        dis[a][b] = c;
        dis[b][a] = c;
    }
    rep(i, N){
        dis[i][i] = 0;
    }
    warshal_floyd();
}


void warshal_floyd(){
    int Short = 0
    for (int k = 0;k < N; k++){
        for (int i=0;i<N;i++){
            for (int j=0;j<N;j++){
                dis[i][j] = min(dis[i][j], dis[i][k] + d[k][j]);
                if(k == N-1){

                }
                    }
                }

            }
        }
    }
    
}

void solve (){//xからyへ行く時の最小で何回補給する必要があるか求める。
    input();
    rep(i, N){
        rep(j, N){
            if(dis[i][j] <= L)Graph[i][j] = 1;
        }
    } 

    rep(k, N){
        rep(i, N){
            rep(j, N){
                Graph[i][j] = min(Graph[i][j], Graph[i][k] + Graph[k][j]);
            }
        }
    }

    int Q;cin >> Q;
    for(int i=0;i<Q;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        int ans = Graph[a][b]-1;
        if (Graph[a][b] == INF)ans = -1;
        cout << ans << endl;
    }
    return ;
}

int main () {
     solve();
     return 0;
}




Compiler output:
a.cc:17:48: error: 'IMF' was not declared in this scope; did you mean 'INF'?
   17 | vector<vector<int> > dis(500, vector<int>(500, IMF));
      |                                                ^~~
      |                                                INF
a.cc:18:50: error: 'IMF' was not declared in this scope; did you mean 'INF'?
   18 | vector<vector<int> > Graph(500, vector<int>(500, IMF));
      |                                                  ^~~
      |                                                  INF
a.cc: In function 'void input()':
a.cc:32:5: error: 'warshal_floyd' was not declared in this scope
   32 |     warshal_floyd();
      |     ^~~~~~~~~~~~~
a.cc: In function 'void warshal_floyd()':
a.cc:38:5: error: expected ',' or ';' before 'for'
   38 |     for (int k = 0;k < N; k++){
      |     ^~~
a.cc:38:20: error: 'k' was not declared in this scope
   38 |     for (int k = 0;k < N; k++){
      |                    ^
a.cc: At global scope:
a.cc:50:5: error: expected declaration before '}' token
   50 |     }
      |     ^
a.cc:52:1: error: expected declaration before '}' token
   52 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;
ll d[305][305];  /* 最短距離 */
vector<ll> d2[305]; /* 補給しなくてもいける点同士のつながり */ /* 幅優先探索をつかう */
vector<ll> ans(305, -1);    /* 単一始点最小補給回数 */
bool isUsed[305];

int main(){
    ll n, m, l;
    cin >> n >> m >> l;

    REP(i, n) REP(j, n) {
        if(i == j) d[i][j] = 0;
        else d[i][j] = INF;
    }

    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = c;
        d[b][a] = c;
    }

    /* ワーシャルフロイド */
    /* i: 経由する頂点、j: 開始頂点、k: 終端 */
    REP(i, n) REP(j, n) REP(k, n) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
    }

    //REP(i, n) REP(j, n) cout << "kyori(" << i << ", " << j << ") = " << d[i][j] << endl;

    REP(i, n) REP(j, n) {
        if(d[i][j] <= l && 0 < d[i][j]) {
            d2[i].push_back(j);
        }
    }

    /*
    REP(i, n) {
        cout << i << " ";
        REP(j, d2[i].size()) {
            cout << d2[i][j] << " ";
        }
        cout << endl;

    }
    */

    int q;
    cin >> q;

    REP(query, q) {
        REP(i, n) ans[i] = -1, isUsed[i] = false;
        int s, t;
        cin >> s >> t;
        s--, t--;
        queue<int> que;
        que.push(s);
        ans[s] = 0;
        while(que.size()) {
            REP(i, que.size()) {
                int k = que.front();
                que.pop();
                REP(j, d2[k].size()) if(!isUsed[d2[k][j]]) {
                    isUsed[d2[k][j]] = true;
                    ans[d2[k][j]] = ans[k] + 1;
                    que.push(d2[k][j]);
                }
            }
            if(ans[s][t] != -1) break;
        }
        if(ans[t] == -1) {
            cout << "-1" << endl;
        } else {
            cout << ans[t] - 1 << endl;
        }
    } 

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:82:22: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[int]' for array subscript
   82 |             if(ans[s][t] != -1) break;
      |                      ^
Language: C++

#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

template<class T>using p_queue=std::priority_queue<T, std::vector<T>, std::greater<>>;

void warshall_floyd(boost::multi_array<int, 2> & ar, int N)
{
	for (int k : boost::irange(0, N))
	{
		for (int i : boost::irange(0, N))
		{
			for (int j : boost::irange(0, N))
			{
				ar[i][j] = std::min(ar[i][j], ar[i][k] + ar[k][j]);
			}
		}
	}
}


void Main()
{
	int N, M;
	std::int64_t L;
	std::cin >> N >> M >> L;
	std::vector<std::map<index_t, std::int64_t>> edge(N);
	for (auto c : boost::irange(0, M))
	{
		index_t a, b;
		std::int64_t c;
		std::cin >> a >> b >> c;
		--a; --b;
		edge[a][b] = c;
		edge[b][a] = c;
	}
	boost::multi_array<int, 2> charge(boost::extents[N][N]);
	for (auto i : boost::irange(0, N))
	{
		for (auto j : boost::irange(0, N))
		{
			charge[i][j] = N;
		}
	}

	for (auto i : boost::irange(0, N))
	{
		p_queue<std::pair<std::int64_t, index_t>> queue;
		for (auto p : edge[i])
		{
			if (p.second <= L)
			{
				queue.emplace(p.second, p.first);
			}
		}
		while (queue.size())
		{
			auto p = queue.top();
			queue.pop();
			auto len = p.first;
			auto index = p.second;
			if (charge[i][index] == 1)
			{
				continue;
			}
			charge[i][index] = 1;
			for (auto n : edge[index])
			{
				if (n.second + len <= L)
				{
					queue.emplace(n.second + len, n.first);
				}
			}
		}
	}
	warshall_floyd(charge, N);

	int Q;
	std::cin >> Q;
	for (auto i : boost::irange(0, Q))
	{
		int s, t;
		std::cin >> s >> t;
		--s; --t;
		std::cout << (charge[s][t] == N ? -1 : charge[s][t] - 1) << std::endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Compiler output:
a.cc:2:9: fatal error: boost/multi_array.hpp: No such file or directory
    2 | #include<boost/multi_array.hpp>
      |         ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>

#define inf 100000000000

using namespace std;

int N, M, L, Q;
long long dist[305][305];
int a, b, c;

int main() {
    scanf("%d %d %d", &N, &M, &L)
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = inf;
        }
    }

    for (int i=0; i<M; i++) {
        scanf("%d %d %d", &a, &b, &c);
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = (dist[i][j] <= L) ? 1:inf;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    cin >> Q;
    for (int i=0; i<Q; i++) {
        scanf("%d %d", &a, &b);
        if (dist[a-1][b-1] == inf) {
            printf("-1\n");
        } else {
            printf("%lld\n", dist[a-1][b-1]-1);
        }
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:34: error: expected ';' before 'for'
   12 |     scanf("%d %d %d", &N, &M, &L)
      |                                  ^
      |                                  ;
   13 |     for (int i=0; i<N; i++) {
      |     ~~~                           
a.cc:13:19: error: 'i' was not declared in this scope
   13 |     for (int i=0; i<N; i++) {
      |                   ^
Language: C++

#include <iostream>

using namespace std;

int N, M, L, Q;
int dist[305][305];
int a, b, c;

int main() {

    cin >> N >> M >> L;
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = INT_MAX;
        }
    }

    for (int i=0; i<M; i++) {
        cin >> a >> b >> c;
        dist[a-1][b-1] = c;
        dist[b-1][a-1] = c;
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                if (dist[i][k]!= INT_MAX && dist[k][j]!= INT_MAX) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            dist[i][j] = (dist[i][j] <= L) ? 1:INT_MAX;
        }
    }

    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            for (int k=0; k<N; k++) {
                if (dist[i][k]!= INT_MAX && dist[k][j]!= INT_MAX) {
                    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }
    }

    cin >> Q;
    for (int i=0; i<Q; i++) {
        cin >> a >> b;
        if (dist[a-1][b-1] == INT_MAX) {
            cout << "-1\n";
        } else {
            cout << dist[a-1][b-1]-1 << "\n";
        }
    }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:26: error: 'INT_MAX' was not declared in this scope
   14 |             dist[i][j] = INT_MAX;
      |                          ^~~~~~~
a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    1 | #include <iostream>
  +++ |+#include <climits>
    2 | 
a.cc:27:34: error: 'INT_MAX' was not declared in this scope
   27 |                 if (dist[i][k]!= INT_MAX && dist[k][j]!= INT_MAX) {
      |                                  ^~~~~~~
a.cc:27:34: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:36:48: error: 'INT_MAX' was not declared in this scope
   36 |             dist[i][j] = (dist[i][j] <= L) ? 1:INT_MAX;
      |                                                ^~~~~~~
a.cc:36:48: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:43:34: error: 'INT_MAX' was not declared in this scope
   43 |                 if (dist[i][k]!= INT_MAX && dist[k][j]!= INT_MAX) {
      |                                  ^~~~~~~
a.cc:43:34: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:53:31: error: 'INT_MAX' was not declared in this scope
   53 |         if (dist[a-1][b-1] == INT_MAX) {
      |                               ^~~~~~~
a.cc:53:31: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'