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

import java.util.*;

public class Main {
    static int n;
    static int m;
    static int s;
    static int t;
    static long arigane = (long) 1e15;
    static int[][] grapht;
    static int[][] graphf;
    static long[] tmemo;
    static long[] fmemo;
    static PriorityQueue<Path> paths;
    static long min = Long.MAX_VALUE;
    static List<Long> ret = new ArrayList<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        s = sc.nextInt() - 1;
        t = sc.nextInt() - 1;
        grapht = new int[n][n];
        graphf = new int[n][n];
        tmemo = new long[n];
        fmemo = new long[n];
        for (int i = 0; i < n; i++) {
            tmemo[i] = -1;
            fmemo[i] = -1;
        }
        for (int i = 0; i < m; i++) {
            int u = sc.nextInt() - 1;
            int v = sc.nextInt() - 1;
            int a = sc.nextInt();
            int b = sc.nextInt();
            grapht[u][v] = a;
            grapht[v][u] = a;
            graphf[u][v] = b;
            graphf[v][u] = b;
        }

        paths = new PriorityQueue<>(Comparator.comparingLong(x -> x.score));
        paths.add(new Path(s, 0));
        while(!paths.isEmpty()) {
            Path c = paths.poll();
            if(tmemo[c.current] != -1) continue;
            tmemo[c.current] = c.score;
            for (int i = 0; i < n; i++) {
                if(grapht[c.current][i] > 0 && tmemo[i] == -1) {
                    Path tmp = new Path(i, c.score + grapht[c.current][i]);
                    paths.add(tmp);
                }
            }
        }

        paths.add(new Path(t, 0));
        while(!paths.isEmpty()) {
            Path c = paths.poll();
            if(fmemo[c.current] != -1) continue;
            fmemo[c.current] = c.score;
            for (int i = 0; i < n; i++) {
                if(graphf[c.current][i] > 0 && fmemo[i] == -1) {
                    Path tmp = new Path(i, c.score + graphf[c.current][i]);
                    paths.add(tmp);
                }
            }
        }
        for (int i = 0; i < n; i++) {
            min = Math.min(min, tmemo[n - 1 - i] + fmemo[n - 1 - i]);
            ret.add(arigane - min);
        }
        for (int i = 0; i < n; i++) {
            System.out.println(ret.get(n - 1 - i));
        }
    }

    static class Path {
        int current;
        long score;

        Path(int current, long score) {
            this.current = current;
            this.score = score;
        }
    }

    static class Edge {
        int to;
        int a;
        int b;
    }

}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
long long n, m, d;
cin >> n >> m >> d;
cout << fixed << setprecision(10) << (ld)(m - 1) * 2 * (n - d) / (n * n);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:39: error: 'ld' was not declared in this scope; did you mean 'd'?
    8 | cout << fixed << setprecision(10) << (ld)(m - 1) * 2 * (n - d) / (n * n);
      |                                       ^~
      |                                       d
Language: C++

n, m, s, t = map(int, input().split())
s-=1
t-=1
G = [[] for i in range(n)]
for i in range(m):
    u,v,a,b=map(int,input().split())
    G[u-1].append((v-1,a,b))
    G[v-1].append((u-1,a,b))

V=10**15
ans=[0]*n
from heapq import heappush,heappop
def dijkstra(u,k):
    D=[10**18]*n
    q=[(u,0)]
    D[u]=0
    while q:
        u,d=heappop(q)
        if D[u]<d: continue
        for v ,a ,b in G[u]:
            w=b if k else a
            if d + w < D[v]:
                D[v]=d+w
                heappush(q,(v,d+w))
    return D
D1=dijkstra(s,0)
D2=dijkstra(t,1)
tmp=1e18
for i in reversed(range(n)):
    tmp=min(tmp,D1[i]+D2[i])
    ans[i]=10**15-tmp
print(*ans,sep="\n")



Compiler output:
a.cc:1:1: error: 'n' does not name a type
    1 | n, m, s, t = map(int, input().split())
      | ^
Language: Java

import org.apache.commons.lang.math.*;
import util.*;

public class Sample extends CommonUtil {
    public void foo() throws Exception {
        int n = 100000;
        int m = 99999;
        String str[] = new String[m];

        int src, dst;
        for (int i = 2; i <= m + 1; i++) {
            str[i - 2] =
                "1 " + i + " " + RandomUtils.nextInt(1000000000) + " "
                    + RandomUtils.nextInt(1000000000);
        }

        println(n + " " + m + " 1 2");
        for (int i = 0; i < m; i++) {
            println(str[i]);
        }
    }

    private String make(int s, int d) {
        if (s < d) {
            return s + " " + d;
        } else {
            return d + " " + s;
        }
    }

    public static void main(String[] args) {
        try {
            new Sample().foo();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Compiler output:
Main.java:4: error: class Sample is public, should be declared in a file named Sample.java
public class Sample extends CommonUtil {
       ^
Main.java:4: error: cannot find symbol
public class Sample extends CommonUtil {
                            ^
  symbol: class CommonUtil
Main.java:1: error: package org.apache.commons.lang.math does not exist
import org.apache.commons.lang.math.*;
^
Main.java:2: error: package util does not exist
import util.*;
^
Main.java:13: error: cannot find symbol
                "1 " + i + " " + RandomUtils.nextInt(1000000000) + " "
                                 ^
  symbol:   variable RandomUtils
  location: class Sample
Main.java:14: error: cannot find symbol
                    + RandomUtils.nextInt(1000000000);
                      ^
  symbol:   variable RandomUtils
  location: class Sample
Main.java:17: error: cannot find symbol
        println(n + " " + m + " 1 2");
        ^
  symbol:   method println(String)
  location: class Sample
Main.java:19: error: cannot find symbol
            println(str[i]);
            ^
  symbol:   method println(String)
  location: class Sample
8 errors
Language: C++

#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>

using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
ll longinf=1ll<<60;



ll n,m,s,t;
ll dista[100002],distb[100002];
vector<P> machia[100002],machib[100002];
priority_queue<P,vector<P>,greater<P>> quea,queb;
ll mini[100002];

int main(){
  cin>>n>>m>>s>>t;
  rep1(i,m){
    ll u,v,a,b;
    cin>>u>>v>>a>>b;
    machia[u].push_back(make_pair(a,v));
    machia[v].push_back(make_pair(a,u));
    machib[u].push_back(make_pair(b,v));
    machib[v].push_back(make_pair(b,u));
  }
  rep1(i,n){
    dista[i]=longinf;
    distb[i]=longinf;
  }
  dista[s]=0;
  rep0(i,machia[s].size()){
    quea.push(machia[s][i]);
    dista[machia[s][i].second]=machia[s][i].first;
  }
  while(quea.size()){
    P p=quea.top();
    quea.pop();
    if(p.first>dista[p.second]) continue;
    for(int i=0;i<machia[p.second].size();i++){
      if(machia[p.second][i].first+dista[p.second]<dista[machia[p.second][i].second]){
        dista[machia[p.second][i].second]=machia[p.second][i].first+dista[p.second];
        quea.push(machia[p.second][i]);
      }
    }
  }
   distb[t]=0;
  rep0(i,machib[t].size()){
    queb.push(machib[t][i]);
    distb[machib[t][i].second]=machib[t][i].first;
  }
  while(queb.size()){
    P p=queb.top();
    queb.pop();
    if(p.first>distb[p.second]) continue;
    for(int i=0;i<machib[p.second].size();i++){
      if(machib[p.second][i].first+distb[p.second]<distb[machib[p.second][i].second]){
        distb[machib[p.second][i].second]=machib[p.second][i].first+distb[p.second];
        queb.push(machib[p.second][i]);
      }
    }
  }
  ll shozikin=1e15;
  mini[n]=dista[n]+distb[n];
  for(int i=n-1;i>=1;i--){
    mini[i]=min(mini[i+1],dista[i]+distb[i]);
  }
  rep1(i,n){
    printf("%ld\n",ans[i]);
  }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:80:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   80 |     printf("%ld\n",ans[i]);
      |                    ^~~
      |                    abs
Language: C++

#include <stdio.h>
#include <vector>

#define INF 100000000000000000
#define ll long long

int main() {

  int n, m, s, t;
  scanf("%d %d %d %d", &n, &m, &s, &t);

  int* u = new int[m];
  int* v = new int[m];
  ll* costa = new ll[n];
  ll* costb = new ll[n];
  int* a = new int[m];
  int* b = new int[m];

  for(int i=0;i<m;i++) {
    scanf("%d %d %d %d", &u[i], &v[i], &a[i], &b[i]);
  }

  s = s - 1;
  t = t - 1;
  for(int i=0;i<m;i++) {
    u[i] = u[i] - 1;
    v[i] = v[i] - 1;
  }
  for(int i=0;i<n;i++) {
    costa[i] = INF;
    costb[i] = INF;
  }

  costa[s] = 0;
  std::vector<int> chka;
  for(int i=0;i<n;i++) {
    ll min = INF;
    int minidx = -1;
    for(int t=0;t<n;t++) {
      if(!(std::find(chka.begin(), chka.end(), t) != chka.end())) {
        if(min > costa[t]) {
          min = costa[t];
          minidx = t;
        }
      }
    }
    for(int t=0;t<m;t++) {
      if(v[t] == minidx) {
        if(costa[u[t]] > costa[v[t]] + a[t]) {
          costa[u[t]] = costa[v[t]] + a[t];
        }
      }
      if(u[t] == minidx) {
        if(costa[v[t]] > costa[u[t]] + a[t]) {
          costa[v[t]] = costa[u[t]] + a[t];
        }
      }
    }
    chka.push_back(minidx);
  }

  costb[t] = 0;
  std::vector<int> chkb;
  for(int i=0;i<n;i++) {
    ll min = INF;
    int minidx = -1;
    for(int t=0;t<n;t++) {
      if(!(std::find(chkb.begin(), chkb.end(), t) != chkb.end())) {
        if(min > costb[t]) {
          min = costb[t];
          minidx = t;
        }
      }
    }
    for(int t=0;t<m;t++) {
      if(v[t] == minidx) {
        if(costb[u[t]] > costb[v[t]] + b[t]) {
          costb[u[t]] = costb[v[t]] + b[t];
        }
      }
      if(u[t] == minidx) {
        if(costb[v[t]] > costb[u[t]] + b[t]) {
          costb[v[t]] = costb[u[t]] + b[t];
        }
      }
    }
    chkb.push_back(minidx);
  }

  for(int i=0;i<n;i++) {
    ll min = INF;
    for(int t=i;t<n;t++) {
      if(min > costa[t] + costb[t]) {
        min = costa[t] + costb[t];
      }
    }
    printf("%lld\n", (1000000000000000 - min));
  }


  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:17: error: 'find' is not a member of 'std'
   40 |       if(!(std::find(chka.begin(), chka.end(), t) != chka.end())) {
      |                 ^~~~
a.cc:68:17: error: 'find' is not a member of 'std'
   68 |       if(!(std::find(chkb.begin(), chkb.end(), t) != chkb.end())) {
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define INF LONG_MAX
#define SUGOI_DEKAI 1000000000000000
#define yen first
#define snk second

struct Node {
  vector<int> dst;
  map<int, pair<int, int>> cost;
};

int main() {
  int n, m, src, dst;
  vector<Node> Graph; //vertex is expressed as integer
  vector<pair<long, long>> cost;
  vector<long> result;
  queue<int> Queue;
  cin >> n >> m >> src >> dst;
  src--; dst--;
  Graph.resize(n); cost.resize(n); visited.resize(n); result.resize(n);
  for (int i=0;i<m;i++) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    Graph[u].dst.push_back(v);
    Graph[v].dst.push_back(u);
    Graph[u].cost[v].yen = Graph[v].cost[u].yen = a;
    Graph[u].cost[v].snk = Graph[v].cost[u].snk = b;
  }
  for (int i=0;i<n;i++)cost[i].yen = cost[i].snk = result[i] = INF, Graph[i].cost[i].yen = Graph[i].cost[i].snk = 0;
  cost[src].yen = cost[dst].snk = 0;
  Queue.push(src);
  while (!Queue.empty()) {
    bool flag = false;
    int pos = Queue.front(); Queue.pop();
    for (int i=0;i<Graph[pos].dst.size();i++) {
      int to = Graph[pos].dst[i];
      long change = cost[to].yen;
      cost[to].yen = min(Graph[pos].cost[to].yen + cost[pos].yen, cost[to].yen);
      if(change != cost[to].yen)Queue.push(to);
    }
  }

  //snuke
  for (int i = 0; i < visited.size(); i++)visited[i] = false;
  Queue.push(dst);
  while (!Queue.empty()) {
    bool flag = false;
    int pos = Queue.front(); Queue.pop();
    for (int i = 0; i < Graph[pos].dst.size(); i++) {
      int to = Graph[pos].dst[i];
      long change = cost[to].snk;
      cost[to].snk = min(Graph[pos].cost[to].snk + cost[pos].snk, cost[to].snk);
      if(change != cost[to].snk)Queue.push(to);
    }
  }

  for (int i=0;i<n;i++)result[i] = cost[i].yen + cost[i].snk; //minimum cost from src to dst via i:0~n-1
  for (int i=n-2;i>=0;i--)result[i] = min(result[i],result[i+1]); //consider year: if later is smaller, then that is better in earlier
  for(int i=0;i<n;i++)cout << SUGOI_DEKAI - result[i] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:36: error: 'visited' was not declared in this scope
   21 |   Graph.resize(n); cost.resize(n); visited.resize(n); result.resize(n);
      |                                    ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
define MAX_DIST 99999999999999LL

class Dijkstra{
public:
    struct edge{
        ll to;
        ll cost;
    };
    int vertex;
    vector<vector<edge>> graph;
    vector<ll> dist;

    Dijkstra(ll n){
        vertex = n;
        graph = vector<vector<edge>>(n);
        dist = vector<ll>(n);
    };

    void dijkstra(int s){
        priority_queue<pll, vector<pll>, greater<pll>> que;
        fill(dist.begin(), dist.end(), MAX_DIST);
        dist[s] = 0;
        que.push(pll(0, s));

        while (!que.empty()){
            pll p = que.top();  //cost/to
            que.pop();
            int v = p.second;
            if (dist[v] < p.first) continue;
            for (int i = 0; i < graph[v].size(); i++) {
                edge e = graph[v][i];
                if (dist[e.to] > dist[v] + e.cost && !(dist[e.to] == MAX_DIST && dist[v] == MAX_DIST)){
                    dist[e.to] = dist[v] + e.cost;
                    que.push(pll(dist[e.to], e.to));
                }
            }
        }

    }

    void addEdge(ll from, ll to, ll cost) {
        edge e;
        e.to = to;
        e.cost = cost;
        graph[from].push_back(e);
    }
};

int main() {
    ll e, v, s, t;
    cin >> v >> e >> s >> t;
    s--; t--;
    Dijkstra si(v);
    Dijkstra ti(v);
    for(int i = 0; i < e; i++){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        si.addEdge(a,b,c);
        si.addEdge(b,a,c);
        ti.addEdge(a,b,d);
        ti.addEdge(b,a,d);
    }

    si.dijkstra(s);
    ti.dijkstra(t);
    vector<ll> st(v);
    vector<ll> ans(v);
    for(int i = 0; i < v; i++){
        st[i] = si.dist[i] + ti.dist[i];
    }
    ans[v-1] = st[v-1];
    for(int i = v-2; i >= 0; i--){
        ans[i] = min(st[i],ans[i+1]);
    }

    for(int i = 0; i < v; i++){
        printf("%.0f\n",1e15-ans[i]);
    }

    return 0;
}


Compiler output:
a.cc:6:1: error: 'define' does not name a type
    6 | define MAX_DIST 99999999999999LL
      | ^~~~~~
a.cc: In function 'int main()':
a.cc:58:5: error: 'Dijkstra' was not declared in this scope
   58 |     Dijkstra si(v);
      |     ^~~~~~~~
a.cc:59:13: error: expected ';' before 'ti'
   59 |     Dijkstra ti(v);
      |             ^~~
      |             ;
a.cc:64:9: error: 'si' was not declared in this scope; did you mean 'i'?
   64 |         si.addEdge(a,b,c);
      |         ^~
      |         i
a.cc:66:9: error: 'ti' was not declared in this scope; did you mean 'i'?
   66 |         ti.addEdge(a,b,d);
      |         ^~
      |         i
a.cc:70:5: error: 'si' was not declared in this scope; did you mean 's'?
   70 |     si.dijkstra(s);
      |     ^~
      |     s
a.cc:71:5: error: 'ti' was not declared in this scope; did you mean 't'?
   71 |     ti.dijkstra(t);
      |     ^~
      |     t
Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(a,b) (x+y-1)/y
#define min(x,y)(x<y?x:y)
 
using namespace std;

struct Edge {
  int to, w;
};
 
vector<ll> dijkstra(const vec<Edge, 2>& G, int s) {
  const int N = G.size();
  vector<ll> dist(N, 1ll << 60);
  priority_queue<pair<ll, int>> q;
  dist[s] = 0;
  q.emplace(0, s);
  while (!q.empty()) {
    auto p = q.top();
    q.pop();
    ll d = -p.first;
    int v = p.second;
    if (dist[v] < d) continue;
    for (auto& e : G[v]) {
      if (dist[e.to] <= d + e.w) continue;
      dist[e.to] = d + e.w;
      q.emplace(-dist[e.to], e.to);
    }
  }
  return dist;
}
 
int main() {
  int N, M, S, T;
  while (cin >> N >> M >> S >> T) {
    --S;
    --T;
    vec<Edge, 2> yG(N), sG(N);
    for (int i = 0; i < M; i++) {
      int u, v, a, b;
      cin >> u >> v >> a >> b;
      --u;
      --v;
      yG[u].push_back(Edge{v, a});
      yG[v].push_back(Edge{u, a});
      sG[u].push_back(Edge{v, b});
      sG[v].push_back(Edge{u, b});
    }
    vector<ll> yDist = dijkstra(yG, S), sDist = dijkstra(sG, T);
    vector<ll> ans(N, 1ll << 60);
    for (int i = 0; i < N; i++) {
      ans[i] = yDist[i] + sDist[i];
    }
    for (int i = N - 2; i >= 0; i--) ans[i] = min(ans[i], ans[i + 1]);
    ll base = 1000000000000000ll;
    for (ll x : ans) cout << base - x << endl;
  }
  return 0;
}

Compiler output:
a.cc:22:27: error: 'vec' does not name a type
   22 | vector<ll> dijkstra(const vec<Edge, 2>& G, int s) {
      |                           ^~~
a.cc:22:30: error: expected ',' or '...' before '<' token
   22 | vector<ll> dijkstra(const vec<Edge, 2>& G, int s) {
      |                              ^
a.cc: In function 'std::vector<long long int> dijkstra(int)':
a.cc:23:17: error: 'G' was not declared in this scope
   23 |   const int N = G.size();
      |                 ^
a.cc:26:8: error: 's' was not declared in this scope
   26 |   dist[s] = 0;
      |        ^
a.cc: In function 'int main()':
a.cc:48:5: error: 'vec' was not declared in this scope
   48 |     vec<Edge, 2> yG(N), sG(N);
      |     ^~~
a.cc:48:13: error: expected primary-expression before ',' token
   48 |     vec<Edge, 2> yG(N), sG(N);
      |             ^
a.cc:48:18: error: 'yG' was not declared in this scope; did you mean 'yn'?
   48 |     vec<Edge, 2> yG(N), sG(N);
      |                  ^~
      |                  yn
a.cc:48:25: error: 'sG' was not declared in this scope
   48 |     vec<Edge, 2> yG(N), sG(N);
      |                         ^~
a.cc:62:27: error: 'sDist' was not declared in this scope; did you mean 'yDist'?
   62 |       ans[i] = yDist[i] + sDist[i];
      |                           ^~~~~
      |                           yDist
Language: Java

import java.util.*;

public class SH_D{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), m= sc.nextInt(), s=sc.nextInt(), t =sc.nextInt();

    int[][] paths = new int[m][4];
    for(int i=0; i<m; i++){
      for(int j=0;j<4; j++){
        paths[i][j] = sc.nextInt();
      }
    }
    int[] snook = new int[n+1];
    int[] yen = new int[n+1];
    for(int i=0;i<n+1;i++){
      snook[i] = Integer.MAX_VALUE;
      yen[i] = Integer.MAX_VALUE;
    }
    yen[s]=0;snook[t]=0;

    Queue<Integer> city_to_visit = new ArrayDeque<Integer>();
    city_to_visit.add(s);
    while(!city_to_visit.isEmpty()){
      int city = city_to_visit.poll();
      for(int[] path: paths){
        if(path[0]==city && path[2]+yen[city] < yen[path[1]]){
          yen[path[1]] = path[2]+yen[city];
          city_to_visit.add(path[1]);
        }else
        if(path[1]==city && path[2]+yen[city] < yen[path[0]]){
          yen[path[0]] = path[2]+yen[city];
          city_to_visit.add(path[0]);
        }
      }
    }
    city_to_visit.add(t);
    while(!city_to_visit.isEmpty()){
      int city = city_to_visit.poll();
      for(int[] path: paths){
        if(path[0]==city && path[3]+snook[city] < snook[path[1]]){
          snook[path[1]] = path[3]+snook[city];
          city_to_visit.add(path[1]);
        }else
        if(path[1]==city && path[3]+snook[city] < snook[path[0]]){
          snook[path[0]] = path[3]+snook[city];
          city_to_visit.add(path[0]);
        }
      }
    }
    for(int i=0;i<n;i++){
      int min_ = Integer.MAX_VALUE;
      for(int j=i+1;j<n+1;j++){
        min_ = min_ < yen[j]+snook[j] ? min_ :yen[j]+snook[j];
      }
      System.out.println(Math.pow(10,15)-min_);
    }
  }
}

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

#include<cstdio>
#include<vector>
using namespace std;

long long int ss[100010],tt[100010];
vector<vector<long long int>> g1(100010);
  vector<vector<long long int>> g2(100010);
  vector<vector<int>> g3(100010);

int dfss1(int s,long long int num){
  int i,n;
  
  n=g1[s].size();
  for(i=0;i<n;i++){
    if(ss[g3[s][i]]>num+g1[s][i]){
      ss[g3[s][i]]=num+g1[s][i];
      dfss1(g3[s][i],ss[g3[s][i]]);
    }
  }
}

int dfst2(int s,long long int num){
  int i,n;
  n=g2[s].size();
  for(i=0;i<n;i++){
    if(tt[g3[s][i]]>num+g2[s][i]){
      tt[g3[s][i]]=num+g2[s][i];
      dfst2(g3[s][i],tt[g3[s][i]]);
    }
  }
}
int main(){
  long long int a,b,max;
  int n,m,s,t,u,v;
  scanf("%d %d %d %d",&n,&m,&s,&t);
  for(int i=0;i<m;i++){
    scanf("%d %d %lld %lld",&u,&v,&a,&b);
    g1[u].push_back(a);
    g1[v].push_back(a);
    g2[u].push_back(b);
    g2[v].push_back(b);
    g3[u].push_back(v);
    g3[v].push_back(u);
  }
  for(int i=1;i<=n;i++){
    ss[i]=tt[i]=1000000000000000;
  }
  ss[s]=tt[t]=0;
  dfss1(s,0);
  dfst2(t,0);
  for(int i=0;i<n;i++){
    max=0;
    for(int j=i+1;j<=n;j++){
      if(max<1000000000000000-ss[j]-tt[j])
        max=1000000000000000-ss[j]-tt[j];
    }
    printf("%lld\n",max);
  }
}

Compiler output:
main.c:1:9: fatal error: cstdio: No such file or directory
    1 | #include<cstdio>
      |         ^~~~~~~~
compilation terminated.
Language: C++

/*betaでやろう*/
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <iterator>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define PB push_back
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define mp make_pair
#define INT int_64
const ll INF = 1e17;
const ll NEGA=-INF; 

ll ans = 0;
int cnt=0;

ll a[200000];
int used[1001];
ll dp[1001][1001];
ll sumx,sumy,sumz;
ll sx,sy,sz;
ll v[200000],u[200000],a[200000],b[200000];
int main() 
{ 
 ll n,m,s,t;
 cin>>n>>m>>s>>t;
 rep(i,m) cin>>u[i]>>v[i]>>a[i]>>b[i];
 rep(i,n){
     cout<<1;
 }
}



Compiler output:
a.cc:40:24: error: redefinition of 'll a [200000]'
   40 | ll v[200000],u[200000],a[200000],b[200000];
      |                        ^
a.cc:35:4: note: 'll a [200000]' previously declared here
   35 | ll a[200000];
      |    ^
Language: Java

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(), m= sc.nextInt(), s=sc.nextInt(), t =sc.nextInt();

    int[][] paths = new int[m][4];
    for(int i=0; i<m; i++){
      for(int j=0;j<4; j++){
        paths[i][j] = sc.nextInt();
      }
    }
    int[] snook = new int[n+1];
    int[] yen = new int[n+1];
    for(int i=0;i<n+1;i++){
      snook[i] = Integer.MAX_VALUE;
      yen[i] = Integer.MAX_VALUE;
    }
    yen[t]=0;snook[t]=0;

    Queue<Integer> city_to_visit = new ArrayDeque<Integer>();
    city_to_visit.add(s);
    while(!city_to_visit.isEmpty()){
      int city = city_to_visit.poll();
      for(int[] path: paths){
        if(path[0]==city && path[2]+yen[city] < yen[path[1]]){
          yen[path[1]] = path[2]+yen[city];
          city_to_visit.add(path[1]);
        }else
        if(path[1]==city && path[2]+yen[city] < yen[path[0]]){
          yen[path[0]] = path[2]+yen[city];
          city_to_visit.add(path[0]);
        }
      }
    }
    city_to_visit.add(t);
    while(!city_to_visit.isEmpty()){
      int city = city_to_visit.poll();
      for(int[] path: paths){
        if(path[0]==city && path[3]+snook[city] < snook[path[1]]){
          snook[path[1]] = path[3]+snook[city];
          city_to_visit.add(path[1]);
        }else
        if(path[1]==city && path[3]+snook[city] < snook[path[0]]){
          snook[path[0]] = path[3]+snook[city];
          city_to_visit.add(path[0]);
        }
      }
    }
    for(int i=0;i<n;i++){
      int min_ = Integer.MAX_VALUE;
      for(int j=i;j<n;j++){
        min_ = min_ < yen[j]+snook[j] ? min_ :yen[j]+snook[j];
      }
      System.out.println(1000000000000000-min_);
    }
  }
}

Compiler output:
Main.java:56: error: integer number too large
      System.out.println(1000000000000000-min_);
                         ^
1 error
Language: C++

#include<cstdio>
#include<set>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>

struct Train
{
	int connectCities[2];
	int money;
	int sunuke;
};

struct CurrentStatus {
	int cityId;
	int money;
	int sunuke;
};

struct City {
	int max_money= 0;
	int max_sunuke = 0;
};

std::vector<Train> trains;
std::vector<City> cities;
std::vector<CurrentStatus> currentStatus;


int STARTMONEY = (int)pow(10, 15);
int finalMoney;


void initialize(int s, int round) {
	//initialize cities
	for (auto& c : cities) {
		c.max_money = 0;
		c.max_sunuke = 0;
	}

	//initialize currentStatus
	currentStatus.clear();

	CurrentStatus status;
	status.cityId = s;
	status.money = STARTMONEY;
	finalMoney = 0;
	currentStatus.emplace_back(status);

	if (status.cityId >= round) {
		status.money = 0;
		status.sunuke = STARTMONEY;
		currentStatus.emplace_back(status);
	}

}

bool journy(int round) {
	std::vector<CurrentStatus> nextStatus;
	for (const auto& status : currentStatus) {
		CurrentStatus newStatus;
		//find nect status
		for (const Train& train : trains) {
			if (std::find(std::begin(train.connectCities), std::end(train.connectCities), status.cityId)) {
				newStatus.cityId = train.connectCities[0] == status.cityId ? train.connectCities[1] : train.connectCities[0];
				newStatus.money = status.money - train.money;
				newStatus.sunuke = status.sunuke - train.sunuke;
			}
		}

		//rog data if valid data
		City& city = cities[newStatus.cityId];

		//w/o exchange
		if (std::max(newStatus.money, newStatus.sunuke) > 0) {
			if (std::min(city.max_money, city.max_sunuke) < newStatus.money) {
				nextStatus.emplace_back(newStatus);
				city.max_money = newStatus.money;
			}
		}

		//do exchnge
		if (newStatus.cityId >= round && newStatus.money > 0) {
			newStatus.sunuke = newStatus.money;
			newStatus.money = 0;
			if (city.max_sunuke < newStatus.sunuke) {
				nextStatus.emplace_back(newStatus);
				city.max_sunuke = newStatus.sunuke;
			}
		}
	}
	currentStatus = nextStatus;
	return currentStatus.size() > 0;
}

int main() {
	int n, m, s, t;
	scanf_s("%d %d %d %d", &n, &m, &s, &t);
	trains.reserve(m);
	cities.resize(n);

	int u, v, a, b;
	for (int mid = 0; mid < m; mid++) {
		scanf_s("%d %d %d %d", &u, &v, &a, &b);
		Train train;
		train.connectCities[0] = u;
		train.connectCities[1] = v;
		train.money = a;
		train.sunuke = b;
		trains.emplace_back(train);
	}

	for (int round = 0; round < n; round++) {
		initialize(s, round);
		while (journy(round));
		std::cout << cities[t].max_sunuke << std::endl;
	}


	return 1;
}

Compiler output:
a.cc:31:23: error: 'pow' was not declared in this scope
   31 | int STARTMONEY = (int)pow(10, 15);
      |                       ^~~
a.cc: In function 'int main()':
a.cc:99:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
   99 |         scanf_s("%d %d %d %d", &n, &m, &s, &t);
      |         ^~~~~~~
      |         scanf
Language: C++

#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

struct edge{ long long int to, cost; } ;
typedef pair<long long int, long long int> P;

int V;
vector<edge> G[100001];
long long int d[100001];
void di(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+V, 1000000000000);
	d[s]=0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top(); que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(long long int i=0;i<G[v].size();i++){
			edge e=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));
			}
		}
	}
}

int main(){
	int n,m,s,t;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	V=n;
	s--;
	t--;
	long long int u[m],v[m],a[m],b[m];
	for(int i=0;i<m;i++){
		scanf("%lld%lld%lld%lld",&u[i],&v[i],&a[i],&b[i]);
		u[i]--;
		v[i]--;
	}
	long long int p[n]={};//s~
	for(int i=0;i<m;i++){
		edge.G[u[i]].pushback(v[i], a[i]);
	}
	di(s);
	for(int i=0;i<n;i++){
		p[i]=d[i];
	}
	di(t);
	for(int i=0;i<n;i++){
		p[i]=p[i]+d[i];
		p[i]=1000000000000000-p[i];

	}
	sort(p,p+n);
	printf("%lld",p[n-1]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:21: error: expected unqualified-id before '.' token
   47 |                 edge.G[u[i]].pushback(v[i], a[i]);
      |                     ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <utility>
#include <queue>
#include <set>
#define INF 9999999999999999
using namespace std;

int main()
{
    static long long n, m, s, t, u, v, a, b, cost[100010], dis[100010];
    static bool vis[100010];
    cin>>n>>m>>s>>t;
    s--;
    t--;
    static vector<pair<long long, long long>> yen[100010]; //which city, cost(yen)
    static vector<pair<long long, long long>> snk[100010]; //which city, cost(snk)
    for (int i=0; i<m; i++)
    {
        cin>>u>>v>>a>>b;
        yen[u-1].push_back({v-1, a});
        yen[v-1].push_back({u-1, a});
        snk[u-1].push_back({v-1, b});
        snk[v-1].push_back({u-1, b});
    }
    for (int i=n-1; i>=0; i--) //exchange in which city
    {
        cost[i]=0;
        memset(vis, false, sizeof(vis));
        for (int j=0; j<100010; j++) dis[j]=INF;
        dis[s]=0;
        priority_queue<pair<long long, long long>> que;
        que.push({0, s});
        while (!que.empty())
        {
            int c=que.top().second;
            que.pop();
            if (c==i) break;
            if (vis[c]) continue;
            vis[c]=true;
            for (auto u : yen[c])
            {
                long long d=u.first, e=u.second;
                if (dis[c]+e<dis[d])
                {
                    dis[d]=dis[c]+e;
                    que.push({-dis[d], d});
                }
            }
        }
        cost[i]+=dis[i];
        if (cost[i]>cost[i+1]) { cost[i]=cost[i+1] continue; }
        memset(vis, false, sizeof(vis));
        for (int j=0; j<100010; i++) dis[j]=INF;
        dis[i]=0;
        priority_queue<pair<long long, long long>> q;
        q.push({0, i});
        while (!q.empty())
        {
            int c=q.top().second;
            q.pop();
            if (c==t) break;
            if (vis[c]) continue;
            vis[c]=true;
            for (auto u : snk[c])
            {
                long long d=u.first, e=u.second;
                if (dis[c]+e<dis[d])
                {
                    dis[d]=dis[c]+e;
                    q.push({-dis[d], d});
                }
            }
        }
        cost[i]+=dis[t];
    }
    set<long long> S;
    for (int i=0; i<n; i++) S.insert(cost[i]);
    for (int i=0; i<n; i++)
    {
        cout<<1000000000000000-*S.begin()<<endl;
        S.erase(cost[i]);
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:57:51: error: expected ';' before 'continue'
   57 |         if (cost[i]>cost[i+1]) { cost[i]=cost[i+1] continue; }
      |                                                   ^~~~~~~~~
      |                                                   ;
Language: C++

// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <queue>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<LL, LL> LLLL;
typedef pair<LLLL, int> LLLLI;

int n, m, s, t;

map<int, LL> ey[100000];
map<int, LL> es[100000];
LL ms[100000];
LL mt[100000];

int main(int argc, char *argv[]) {
	memset(ms, -1, sizeof(ms));
	memset(mt, -1, sizeof(ms));
	cin >> n >> m >> s >> t;
	--s, --t;
	for (int i = 0; i < m; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u, --v;
		ey[u][v] = a;
		es[u][v] = b;
		ey[v][u] = a;
		es[v][u] = b;
	}

	vector<LL> ans(n);
	vector<LLLLI> f(n);
	for (int i = 0; i < n; ++i) {
		f[i].first.first = -1;
		f[i].first.second = -1;
		f[i].first.second = -1;
	}

	LL initial = 1000000000000000LL;
	mt[s] = initial;
	priority_queue<LLLLI, vector<LLLLI> > queue;
	queue.push(LLLLI(LLLL(0, initial), s));

	f[s] = LLLLI(LLLL(initial, 0), s);

	for (int ex = n - 1; ex >= 0; --ex) {
		LL mx = 0;
		if (ex != n - 1) {
			mx = ans[ex + 1];
			queue.push(f[ex]);
		}

		while (queue.size()) {
			LLLLI top = queue.top();
			queue.pop();
			LL y = top.first.second;
			LL s = top.first.first;
			LL node = top.second;
			for (auto kv : ey[node]) {
				int dest = kv.first;
				LL ry = y - kv.second;
				LL tot = s + ry;
				if (ry >= 0 && (s > ms[dest] || tot > mt[dest])) {
					ms[dest] = max(ms[dest], s);
					mt[dest] = max(mt[dest], tot);
					queue.push(LLLLI(LLLL(s, ry), dest));

					if (ry > 0) {
						LL rs = ry;
						if (dest == ex) {
							ms[dest] = max(ms[dest], rs);
							queue.push(LLLLI(LLLL(rs, 0), dest));
						} else if (rs > f[dest].first.first) {
							f[dest] = LLLLI(LLLL(rs, 0), dest);
						}
					}
				}
			}
			for (auto kv : es[node]) {
				int dest = kv.first;
				LL rs = s - kv.second;
				LL tot = rs + y;
				if (rs >= 0 && (rs > ms[dest] || tot > mt[dest])) {
					ms[dest] = max(ms[dest], rs);
					mt[dest] = max(mt[dest], tot);
					queue.push(LLLLI(LLLL(rs, y), dest));
				}
			}
			if (node == t) {
				mx = max(mx, s);
				break;
			}
		}
		ans[ex] = mx;
	}

	for (int i = 0; i < n; ++i) {
		cout << ans[i] << endl;
	}

	return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:23:9: error: 'memset' was not declared in this scope
   23 |         memset(ms, -1, sizeof(ms));
      |         ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 |
Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<limits>
#include<queue>

using namespace std;

int main(void) {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	vector<vector<pair<int, long long>>> yw(n + 1), sw(n + 1);
	for (int i = 0; i < m; i++) {
		int u, v;
		long long a, b;
		cin >> u >> v >> a >> b;
		yw[u].push_back(make_pair(v, a));
		yw[v].push_back(make_pair(u, a));
		sw[u].push_back(make_pair(v, b));
		sw[v].push_back(make_pair(u, b));
	}
	vector<long long> yc(n + 1, LLONG_MAX), sc(n + 1, LLONG_MAX);
	priority_queue<pair<long long, int>> Q;
	Q.push(make_pair(0, s));
	yc[s] = 0;
	while (!Q.empty()) {
		pair<long long, int> qt = Q.top();
		Q.pop();
		int idx = qt.second;
		for (int i = 0; i < yw[idx].size(); i++) {
			int dst = yw[idx][i].first;
			long long ycc = yc[idx] + yw[idx][i].second;
			if (ycc < yc[dst]) {
				yc[dst] = ycc;
				Q.push(make_pair(yc[dst], dst));
			}
		}
	}
	Q.push(make_pair(0, t));
	sc[t] = 0;
	while (!Q.empty()) {
		pair<long long, int> qt = Q.top();
		Q.pop();
		int idx = qt.second;
		for (int i = 0; i < sw[idx].size(); i++) {
			int dst = sw[idx][i].first;
			long long scc = sc[idx] + sw[idx][i].second;
			if (scc < sc[dst]) {
				sc[dst] = scc;
				Q.push(make_pair(sc[dst], dst));
			}
		}
	}

	vector<long long> ans(n + 1);
	for (int i = 1; i <= n; i++) {
		ans[i] = 1000000000000000LL - yc[i] - sc[i];
	}
	for (int i = n - 1; i >= 1; i--) {
		if (ans[i] < ans[i + 1]) ans[i] = ans[i + 1];
	}
	for (int i = 1; i <= n; i++) cout << ans[i] << endl;


	system("pause");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:37: error: 'LLONG_MAX' was not declared in this scope
   24 |         vector<long long> yc(n + 1, LLONG_MAX), sc(n + 1, LLONG_MAX);
      |                                     ^~~~~~~~~
a.cc:8:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    7 | #include<queue>
  +++ |+#include <climits>
    8 |
Language: C++

#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using Cost = LL;
const Cost INF = 1e9;

class dijkstra {
	struct edge {
		int to;
		Cost cost;
		edge(int to_, Cost cost_) : to(to_), cost(cost_) {}
	};
	bool isdir;
	vector<vector<edge> > G;
	int V;
public:
	dijkstra(int V_, bool isdir_ = true) : isdir(isdir_), V(V_), G(V_) {}
	void add(int a, int b, Cost c) {
		G[a].emplace_back(b, c);
		if (!isdir) G[b].emplace_back(a, c);
	}
	vector<Cost> calc(int s) {
		vector<Cost> d(V, INF);
		using pci = pair<Cost, int>;
		priority_queue<pci, vector<pci>, greater<pci> > q;
		q.emplace(0, s);
		while (!q.empty(å)) {
			auto p = q.top(); q.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			d[v] = p.first;
			for (auto& e : G[v]) {
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					q.emplace(d[e.to], e.to);
				}
			}
		}
		return d;
	}
};


int main() {
  LL n,m,s,t;
  cin>>n>>m>>s>>t;
  dijkstra yen(n,false);
  dijkstra snuuk(n,false);
  s--;t--;
  REP(i,m){
    LL u,v,a,b;
    cin>>u>>v>>a>>b;
    u--;v--;
    yen.add(u,v,a);
    snuuk.add(u,v,b);
  }

  vector<Cost> yen_cost=yen.calc(s);
  vector<Cost> snuuk_cost=snuuk.calc(t);


  vector<Cost> ans(n,0);
  ans[n-1]=yen_cost[n-1]+snuuk_cost[n-1];
  for(int i=n-2;i>=0;--i){
    ans[i]=min(yen_cost[i]+snuuk_cost[i],ans[i+1]);
  }

  REP(i,n){
    cout<<1000000000000000LL-ans[i]<<endl;
  }
}


Compiler output:
a.cc: In member function 'std::vector<long long int> dijkstra::calc(int)':
a.cc:68:33: error: '\U000000e5' was not declared in this scope
   68 |                 while (!q.empty(å)) {
      |                                 ^
Language: C++

	int n = ri(), m = ri(), s = ri()-1, t = ri()-1;

	Graph G1(n), G2(n);

	rep(i, m) {
		int u = ri() - 1;
		int v = ri() - 1;
		int a = ri(), b = ri();
		out(u,v,a,b);
		G1[u].emplace_back(v, a);
		G1[v].emplace_back(u, a);
		G2[u].emplace_back(v, b);
		G2[v].emplace_back(u, b);
	}
	out(G1, G2);
	
	vl D1 = cal(n, m, s, G1);
	vl D2 = cal(n, m, t, G2);

	out(D1);
	out(D2);

	SegTreeMin<ll> seg(n);
	rep(i, n) {
		seg.set(i, D1[i]+D2[i]);
	}
	seg.build();

	rep(i, n) {
		ll mi = seg.query(i, n);

	}


	// TODO check OVERFLOW


Compiler output:
a.cc:1:17: error: 'ri' was not declared in this scope
    1 |         int n = ri(), m = ri(), s = ri()-1, t = ri()-1;
      |                 ^~
a.cc:3:9: error: 'Graph' does not name a type
    3 |         Graph G1(n), G2(n);
      |         ^~~~~
a.cc:5:12: error: expected constructor, destructor, or type conversion before '(' token
    5 |         rep(i, m) {
      |            ^
a.cc:15:12: error: expected constructor, destructor, or type conversion before '(' token
   15 |         out(G1, G2);
      |            ^
a.cc:17:9: error: 'vl' does not name a type
   17 |         vl D1 = cal(n, m, s, G1);
      |         ^~
a.cc:18:9: error: 'vl' does not name a type
   18 |         vl D2 = cal(n, m, t, G2);
      |         ^~
a.cc:20:12: error: expected constructor, destructor, or type conversion before '(' token
   20 |         out(D1);
      |            ^
a.cc:21:12: error: expected constructor, destructor, or type conversion before '(' token
   21 |         out(D2);
      |            ^
a.cc:23:9: error: 'SegTreeMin' does not name a type
   23 |         SegTreeMin<ll> seg(n);
      |         ^~~~~~~~~~
a.cc:24:12: error: expected constructor, destructor, or type conversion before '(' token
   24 |         rep(i, n) {
      |            ^
a.cc:27:9: error: 'seg' does not name a type
   27 |         seg.build();
      |         ^~~
a.cc:29:12: error: expected constructor, destructor, or type conversion before '(' token
   29 |         rep(i, n) {
      |            ^
Language: C++


#include <cstdio>
#include <vector>
#include <string>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll, int> pli;

struct st {
  int to;
  int yen;
  int snu;
};

int main() {
  int n, m, s, t; scanf("%d%d%d%d", &n, &m, &s, &t); s--; t--;
  vector<st> e[n];
  for (int i = 0; i < m; ++i) {
     int u, v, a, b; scanf("%d%d%d%d", &u, &v, &a, &b); u--; v--;
     e[u].push_back((st){v, a, b});
     e[v].push_back((st){u, a, b});
  }

  ll dists[2][n]; memset(dists, 0x3f, sizeof(dists));
  for (int i = 0; i < 2; ++i) {
    ll* dist = dists[i];
    priority_queue<pli> q;
    q.push(make_pair(-0LL, (i == 0 ? s : t)));
    dist[(i == 0 ? s : t)] = 0;
    while(q.size()) {
      ll cost = -q.top().first;
      int pos = q.top().second;
      q.pop();

      for (const st& edge : e[pos]) {
        ll next_cost = cost + (i == 0 ? edge.yen : edge.snu);
        int next_pos = edge.to;
        if (dist[next_pos] <= next_cost) continue;
        dist[next_pos] = next_cost;
        q.push(make_pair(-next_cost, next_pos));
      }
    }
  }

#if 0
  for (int i = 0 ; i < n; ++i) {
    printf("%lld %lld\n", dists[0][i], dists[1][i]);
  }
#endif

  ll ans[n];
  ans[n-1] = dists[0][n-1] + dists[1][n-1];
  for (int i = n - 2; i >= 0; --i) {
    ans[i] = min<ll>(ans[i + 1], dists[0][i] + dists[1][i]);
  }
  for (int i = 0; i < n; ++i) {
    printf("%lld\n", 1000LL * 1000 * 1000 * 1000 * 1000 - ans[i]);
  }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: 'memset' was not declared in this scope
   26 |   ll dists[2][n]; memset(dists, 0x3f, sizeof(dists));
      |                   ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <queue>
  +++ |+#include <cstring>
    6 | using namespace std;
Language: C++

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

#define int long long
#define REP(i, n) for ( int i = 0; i < (n); i++ )
const int INF = 1e15;

struct Edge {
  int to, cost;
  Edge(int to, int cost): to(to), cost(cost) {}
};

int N, M;
vector<vector<Edge> > G;
vector<int> add[2];
bool zero = false;

void dfs(int v, int s, bool f) {
  if ( add[f][v] != INF ) {
    if ( add[f][v] != s ) zero = true;
    return;
  }
  add[f][v] = s;
  for ( Edge &e: G[v] ) {
    dfs(e.to, e.cost-s, !f);
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> M;
  G.resize(N);
  add[0].resize(N, INF);
  add[1].resize(N, INF);
  REP(i, M) {
    int u, v, s;
    cin >> u >> v >> s;
    u--; v--;
    G[u].push_back(Edge(v, s));
    G[v].push_back(Edge(u, s));
  }

  dfs(0, 0, 0);

  if ( zero ) {
    cout << 0 << endl;
    return 0;
  }
  /* REP(i, N) {
    cout << add[0][i] << " " << add[1][i] << endl;
  } */
  int ma = INF;
  int mi = 0;
  set<int> all;
  REP(i, N) {
    if ( add[0][i] != INF && add[1][i] != INF ) {
      if ( (add[1][i]-add[0][i])/2 <= 0 ) {
        cout << 0 << endl;
        return 0;
      }
      all.insert((add[1][i]-add[0][i])/2);
    }
    if ( add[0][i] != INF ) mi = max(mi, -add[0][i]);
    if ( add[1][i] != INF ) ma = min(ma, add[1][i]);
  }

  if ( all.size() == 1 ) cout << 1 << endl;
  else cout << 0 << endl;
  else cout << max(0LL, ma-mi-1) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:72:3: error: 'else' without a previous 'if'
   72 |   else cout << max(0LL, ma-mi-1) << endl;
      |   ^~~~
Language: Java

/*input
4 3
1 2 6
3 4 5
2 3 7
*/
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;


public class Main {
	private static final int N = (int)1e5 + 100;
	private static final long oo = (long) 1e18;
	public static class Pair {
		public int v;
		public long s;
		Pair(int v, long s) {
			this.v = v;
			this.s = s;
		}
	}

	private static long n, m, flag = 0;
	private static long[] a = new long[N];
	private static long[] step = new long[N];
	private static long[] res = new long[N];
	private static boolean[] visit = new boolean[N];

	public static ArrayList<ArrayList<Pair> > vi = new ArrayList< ArrayList <Pair> >();

	static void run() { System.out.print("0"); System.exit(0); }
	static void done() { System.out.print("1"); System.exit(0); }
	static boolean check(long x) {
		res[1] = x;
		for(int i = 1; i <= n; ++i) {
			if(step[i] % 2 == 0) {
				res[i] = a[i] + x;
			} else res[i] = a[i] - x;
		}
		for(int i = 1; i <= n; ++i) {
			for(Pair cur: vi.get(i))	{
				if(cur.s != (res[i] + res[cur.v])) return false;
			}
		}
		return true;
	}

	static void dfs(int u) {
		visit[u] = true;
		for(Pair cur: vi.get(u)) {
			if(!visit[cur.v]) {
				step[cur.v] = 1 - step[u];
				a[cur.v] = cur.s - a[u];
				dfs(cur.v);
			}
		}
	}

	public static void main(String[] args) {
		Scanner inp = new Scanner(System.in);

		n = inp.nextLong();
		m = inp.nextLong();
		
		for(int i = 1; i <= n + 1; ++i) {
			visit[i] = false;
			vi.add(new ArrayList<Pair>());
		}
		for(int i = 1; i <= m; ++i) {
			int u, v, s;
			u = inp.nextInt();
			v = inp.nextInt();
			s = inp.nextInt();
			vi.get(u).add(new Pair(v, s));
			vi.get(v).add(new Pair(u, s));
		} 
		step[1] = a[1] = 0;

		dfs(1);

		long minn = 1, maxn = oo;

		//for(int i = 1; i <= n; ++i) System.out.println(a[i] + " " + step[i]);

		for(int i = 1; i <= n; ++i ) {
			for(Pair cur: vi.get(i)) {
				if(1 - step[i] == step[cur.v]) {
					if(a[cur.v] != cur.s - a[i]) done();
				} else {
					long tmp = cur.s - a[i];
					if(step[i] % 2 == 0) {
						if(check((tmp - a[cur.v]) / 2)) done();
						else {
							//System.out.print(i + " ");
							//System.out.println(cur.v);
							run();
						}
					} else {
						if(check((a[cur.v] - tmp) / 2)) done();
						else {
							//System.out.print(i + " ");
							//System.out.println(cur.v);
							run();
						}	
					}
				}
			}
			if(step[i] == 0) minn = Math.max(minn, 1 - a[i]);
			else maxn = Math.min(maxn, a[i] - 1);
		}
			
		minn = Math.max(minn, 1);
		System.out.print(Math.max(maxn - minn + 1, 0L));
	}
}

Compiler output:
Main.java:72: error: cannot find symbol
		Scanner inp = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:72: error: cannot find symbol
		Scanner inp = new Scanner(System.in);
		                  ^
  symbol:   class Scanner
  location: class Main
2 errors