criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.io.*;
import java.util.Arrays;
   
class Main{
   
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
   
   
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
if(BellmanFord(v,e,r,es,d)){
out.println("NEGATIVE CYCLE");
}
else{
for(int i=0;i<v;i++){
if(d[i]==INF){
out.println("INF");
}
else{
out.println(d[i]);
}
}
}
out.flush();
}
}
   
private static boolean BellmanFord(int v,int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
for(int i=0;i<v;i++){
boolean update=false;
for(int j=0;j<ee;j++){
Edge e=es[j];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
update=true;
if(i==v-1){
return true;
}
}
}
if(!update){
return false;
}
}
}
}

Compiler output:
Main.java:71: error: missing return statement
}
^
1 error
Language: Java

import java.io.*;
import java.util.Arrays;
   
class Main{
   
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
   
   
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
if(BellmanFord(v,e,r,es,d)){
out.println("NEGATIVE CYCLE");
}
else{
for(int i=0;i<v;i++){
if(d[i]==INF){
out.println("INF");
}
else{
out.println(d[i]);
}
}
}
out.flush();
}
}
   
private static boolean BellmanFord(int v,int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
for(int i=0;i<v;i++){
boolean update=false;
for(int j=0;j<ee;j++){
Edge e=es[j];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
update=true;
}
}
if(!update){
return false;
}
if(i==v-1){
return true;
}
}
}
}

Compiler output:
Main.java:71: error: missing return statement
}
^
1 error
Language: Java

import java.io.*;
import java.util.Arrays;
   
class Main{
   
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
   
   
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
if(BellmanFord(v,e,r,es,d)){
out.println("NEGATIVE CYCLE");
}
else{
for(int i=0;i<v;i++){
if(d[i]==INF){
out.println("INF");
}
else{
out.println(d[i]);
}
}
}
out.flush();
}
}
   
private static boolean BellmanFord(int v,int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
for(int i=0;i<=v;i++){
if(i==v) return true;
boolean update=false;
for(int j=0;j<ee;j++){
Edge e=es[j];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
update=true;
}
if(!update){
return false;
}
}
}
}

Compiler output:
Main.java:69: error: reached end of file while parsing
}
 ^
1 error
Language: Java

import java.io.*;
import java.util.Arrays;
   
class Main{
   
static final int INF=Integer.MAX_VALUE/2;
static final PrintWriter out=new PrintWriter(System.out);
   
   
static class Edge{
int from;
int to;
int cost;
Edge(int from,int to,int cost){
this.from=from; this.to=to; this.cost=cost;
}
}
   
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int v=Integer.parseInt(line.split(" ")[0]);
int e=Integer.parseInt(line.split(" ")[1]);
int r=Integer.parseInt(line.split(" ")[2]);
Edge[] es=new Edge[e];
int[] d=new int[v];
for(int i=0;i<e;i++){
line=br.readLine();
int s=Integer.parseInt(line.split(" ")[0]);
int t=Integer.parseInt(line.split(" ")[1]);
int c=Integer.parseInt(line.split(" ")[2]);
es[i]=new Edge(s,t,c);
}
if(BellmanFord(v,e,r,es,d)){
out.println("NEGATIVE CYCLE");
}
else{
for(int i=0;i<v;i++){
if(d[i]==INF){
out.println("INF");
}
else{
out.println(d[i]);
}
}
}
out.flush();
}
}
   
private static boolean BellmanFord(int v,int ee,int r,Edge[] es,int[] d){
Arrays.fill(d,INF);
d[r]=0;
for(int i=0;i<=v;i++){
if(i==v) return true;
boolean update=false;
for(int j=0;j<ee;j++){
Edge e=es[j];
if(d[e.to]>d[e.from]+e.cost){
d[e.to]=d[e.from]+e.cost;
update=true;
}
}
if(!update){
return false;
}
}
}
}

Compiler output:
Main.java:69: error: missing return statement
}
^
1 error
Language: Java

import java.util.Arrays;
import java.util.Scanner;

// bellman-ford ????????????????????????
public class BellmanFord {

    static int dist[][];
    static final int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int E = sc.nextInt();
        int s = sc.nextInt();

        Edge[] list = new Edge[E];

        for (int i = 0; i < E; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int f = sc.nextInt();
            list[i] = new Edge(a, b, f);
            // ????????°??????
            // list[i] = new Edge(b, a, f);
        }

        int[] d = new int[N];
        Arrays.fill(d, INF);
        d[s] = 0;

        for (int i = 0; i < E; i++) {
            for (int j = 0; j < E; j++) {
                Edge e = list[j];
                if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                    d[e.to] = d[e.from] + e.cost;
                    if (i == E - 1) {
                        System.out.println("NEGATIVE CYCLE");
                        return;
                    }
                }
            }
        }

        for (int i = 0; i < N; i++) {
            System.out.println(d[i] == INF ? "INF" : d[i]);
        }
    }

    static class Edge implements Comparable<Edge> {
        public int from;
        public int to;
        public int cost;

        public Edge(int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }


        @Override
        public int compareTo(Edge o) {
            return this.cost - o.cost;
        }
    }

    public static boolean hasNegativeLoopWF(int[][] a) {
        for (int i = 0; i < a.length; i++) {
            if (a[i][i] < 0) {
                return true;
            }
        }
        return false;
    }
}

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

import java.util.*;

class Main {
    //Bellman-Ford's Algorithm
    private static final int MAX = 99999;
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int V = scanner.nextInt();
        int E = scanner.nextInt();
        int src = scanner.nextInt();

        int[] dist = new int[V];
        int[][] edges = new int[E][3];

        for(int i = 0; i < V; ++i){
            dist[i] = MAX;
        }
        dist[src] = 0;

        for(int i = 0; i < E; ++i){
            int[] edge = new int[] {scanner.nextInt(), scanner.nextInt(), scanner.nextInt()};
            edges[i] = edge;
        }

        for(int i = 1; i < V; ++i){
            boolean update = false;
            for(int j = 0; j < E; ++j){
                int[] edge = edges[j];
                if(dist[edge[1]] > dist[edge[0]] + edge[2]){
                    dist[edge[1]] = dist[edge[0]] + edge[2];
                    update = true;
                }
            }

            if(!update){
                break;
            }
        }

        boolean containNegativeCycle = false;
        for(int j = 0; j < E; ++j){
            int[] edge = edges[j];
            if(dist[edge[1]] > dist[edge[0]] + edge[2]){
                containNegativeCycle = true;
                break;
            }
        }

        if(containNegativeCycle){
            System.out.println("NEGATIVE CYCLE");
            return;
        }

        for(int i = 0; i < V; ++i){
            System.out.println(dist[i] == MAX ? "INF" : dist[i]);
        }
    }

Compiler output:
Main.java:57: error: reached end of file while parsing
    }
     ^
1 error
Language: Java

package jp.ac.saburou.GRL;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class GRL1B {

	private static int INF = 100000000;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int numEdge = sc.nextInt();
		int start = sc.nextInt();
		ArrayList<ArrayList<Edge>> graph = new ArrayList<ArrayList<Edge>>(num);
		for(int i = 0; i < num; i++){
			graph.add(new ArrayList<Edge>());
		}
		for(int i = 0; i < numEdge; i++){
			int u = sc.nextInt();
			int v = sc.nextInt();
			int w = sc.nextInt();
			graph.get(u).add(new Edge(u, v, w));
		}

		try {
			long[] dist = bellmanford(graph, start);
			for (int i = 0; i < num; i++)
				System.out.println(dist[i] >= INF ? "INF" : dist[i]);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			sc.close();
		}
	}

	private static long[] bellmanford(ArrayList<ArrayList<Edge>> graph, int start) throws Exception{
		int numVerticles = graph.size();
		long[] dist = new long[numVerticles];
		Arrays.fill(dist, Integer.MAX_VALUE);
		dist[start] = 0;
		for(int i = 0; i <= numVerticles; i++){
			boolean fail = i == numVerticles;
			boolean noUpdate = true;
			for(int u = 0; u < numVerticles; u++){
				for(Edge e : graph.get(u)){
					int v = e.v;
					long newLength = dist[u] + e.weight;
					if(newLength < dist[v]){
						if(fail) throw new Exception("NEGATIVE CYCLE");
						dist[v] = newLength;
						noUpdate = false;
					}
				}
			}
			if(noUpdate) break;
		}
		return dist;
	}
}

class Edge {
	int u;
	int v;
	int weight;

	public Edge(int u, int v, int weight) {
		this.u = u;
		this.v = v;
		this.weight = weight;
	}
}

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

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

#define INF 2000000000

struct edge{int from, to, cost;};

edge es[2010];

int d[1010];
int V, E;

void bellman_ford(int s){
  
  for(int i = 0;i < V;i++) d[i] = INF;
  d[s] = 0;
  
  while(true){
    bool update = false;
    
    for(int i = 0;i < E;i++){
      edge e = es[i];
      if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if(!update) break;
  }
}

bool find_negative_loop(){
  
  memset(d, 0, sizeof(d));
  
  for(int i = 0;i < V;i++){
    for(int j = 0;j < E;j++){
      edge e = es[j];
      if(d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from] + e.cost;
        if(i == V - 1) return true;
      }
    }
  }
  return false;
}

int main(){
  
  int r;
  
  cin >> V >> E >> r;
  for(int i = 0;i < E;i++) cin >> es[i].from >> es[i].to >> es[i].cost;
  
  if(find_negative_loop()){
    cout << "NEGATIVE CYCLE" << endl;
    return 0;
  }
  
  bellman_ford(r);
  
  for(int i = 0;i < V;i++){
    if(d[i] == INF) cout << "INF" << endl;
    else cout << d[i] << endl;
  }
  
  return 0;
}


Compiler output:
a.cc: In function 'bool find_negative_loop()':
a.cc:37:3: error: 'memset' was not declared in this scope
   37 |   memset(d, 0, sizeof(d));
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<algorithm>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const ll MAX_N = 100001;
static const ll MAX_M = 100001;

//////////////////////////////////////////////////////
//BellmanFord/////////////////////////////////////////
//////////////////////////////////////////////////////
struct edge { int from, to, cost; };
edge es[MAX_M];
ll d[MAX_N];
int V, E;

void bellmanFord(int s) {
	fill(d, d + V, INF);
	d[s] = 0;
	while (1) {
		bool update = false;
		rep(i, 0, E) {
			edge e = es[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) break;
	}
}
bool find_negative_loop() {
	memset(d, 0, sizeof(d));
	rep(i, 0, V) {
		rep(j, 0, E) {
			edge e = es[j];
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (i == V - 1) return true;
			}
		}
	}
}
///////////////////////////////////////////////////////
int main() {
	ll r; cin >> V >> E >> r;
	rep(i, 0, E) {
		ll s, t, d; cin >> s >> t >> d;
		es[i].from = s;
		es[i].to = t;
		es[i].cost = d;
	}

	bellmanFord(r);

	rep(i, 0, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'bool find_negative_loop()':
a.cc:40:9: error: 'memset' was not declared in this scope
   40 |         memset(d, 0, sizeof(d));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <queue>
  +++ |+#include <cstring>
    5 | using namespace std;
a.cc:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

// graph //
int V,E,r,from,to,weight;

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

vector<Edge> edges;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> V >> E >> r;
    REP(i,E){
        cin >> from >> to >> weight;
        edges.emplace_back(from,to,weight);
    }

    vector<ll> dist(V,INF);
    dist[r] = 0;
    REP(i,V){
        bool update = false;
        for(auto e : edges){
            if(dist[e.to] > dist[e.from] + e.cost){
                update = true;
                dist[e.to] = dist[e.from] + e.cost;
                if(i == V-1){
                    cout << "NEGATIVE CYCLE" << '\n';
                    return 0;
                }
            }
        }
        if(!update) break;
    }

    REP(i,V){
        if(dist[i]==INF) cout << "INF" << '\n';
        else cout << dist[i] << '\n';
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:12: error: 'll' was not declared in this scope
   28 |     vector<ll> dist(V,INF);
      |            ^~
a.cc:28:14: error: template argument 1 is invalid
   28 |     vector<ll> dist(V,INF);
      |              ^
a.cc:28:14: error: template argument 2 is invalid
a.cc:28:23: error: 'INF' was not declared in this scope
   28 |     vector<ll> dist(V,INF);
      |                       ^~~
a.cc:28:26: error: expression list treated as compound expression in initializer [-fpermissive]
   28 |     vector<ll> dist(V,INF);
      |                          ^
a.cc:29:9: error: invalid types 'int[int]' for array subscript
   29 |     dist[r] = 0;
      |         ^
a.cc:33:20: error: invalid types 'int[int]' for array subscript
   33 |             if(dist[e.to] > dist[e.from] + e.cost){
      |                    ^
a.cc:33:33: error: invalid types 'int[int]' for array subscript
   33 |             if(dist[e.to] > dist[e.from] + e.cost){
      |                                 ^
a.cc:35:21: error: invalid types 'int[int]' for array subscript
   35 |                 dist[e.to] = dist[e.from] + e.cost;
      |                     ^
a.cc:35:34: error: invalid types 'int[int]' for array subscript
   35 |                 dist[e.to] = dist[e.from] + e.cost;
      |                                  ^
a.cc:46:16: error: invalid types 'int[int]' for array subscript
   46 |         if(dist[i]==INF) cout << "INF" << '\n';
      |                ^
a.cc:47:26: error: invalid types 'int[int]' for array subscript
   47 |         else cout << dist[i] << '\n';
      |                          ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>

using namespace std;

int main() {
  int const INF = INT_MAX;
  int V, E, r; cin >> V >> E >> r;
  static int G[V][V]; fill(G[0], G[0]+V*V, INF);
  for(int i=0; i<E; i++) {
    int s, t; cin >> s >> t;
    cin >> G[s][t];
  }
  for(int i=0; i<V; i++) G[i][i] = 0;
  
  for(int k=0; k<V; k++)
    for(int i=0; i<V; i++)
      for(int j=0; j<V; j++)
        if(G[i][k]!=INF && G[k][j]!=INF)
          G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
  
  for(int i=0; i<V; i++) if(G[i][i]<0) { cout << "NEGATIVE CYCLE\n"; return 0; }
  for(int i=0; i<V; i++) {
    if(G[r][i]>=INF) cout << "INF" << endl;
    else cout << G[r][i] << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: storage size of 'G' isn't constant
   11 |   static int G[V][V]; fill(G[0], G[0]+V*V, INF);
      |              ^
Language: C++

#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
const int INF = INT_MAX/4;
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  {
    for(int j=0;j<vertex;j++) {
      if(graph[start][j]<INF/2 && graph[j][j]<0) {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
      }
    }
  }
  
  for(int i=0;i<vertex;i++) {
    if(graph[start][i]>=INF/2) {
      cout << "INF" << endl;
    } else {
      cout << graph[start][i] << endl;
    }
  }
  return 0;
}
 
inline int fastmin(int a, int b) {
  return (((a-b)>>31)&(a-b))+b;
}

int mymin(int a, int b) __attribute__((noinline)) {
  int t;
  if (a < b) {
    t = a;
  } else {
    t = b;
  }
  return t;
}
 
void check()
{
  for(int k=0;k<vertex;k++) {
    for(int i=0;i<vertex;i++) {
      int gik= graph[i][k];
      for(int j=0;j<vertex;j++) {
        graph[i][j]= mymin(graph[i][j], gik+graph[k][j]);
      }
    }
  }
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
        {
          if(i==j)
            {
              graph[i][j]=0;
            }
          /*else
            {
            graph[i][j]=INF;
            }*/
        }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
    dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
      {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
      }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
      for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }  
      cout << endl;    
      }*/
   
 
}

Compiler output:
a.cc:54:25: error: attributes are not allowed on a function-definition
   54 | int mymin(int a, int b) __attribute__((noinline)) {
      |                         ^~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <climits>
#include <vector>
#include <queue>
 
#define MAX_V 1024
using namespace std;
 
void get_map();
void check();
struct edge
{
  int to;
  int weight;
};
 
 
#define INF INT_MAX/4
vector<edge> g[2000];
int graph[MAX_V][MAX_V];
int dist[MAX_V];
int numofedge;
int vertex;
int start;
int flag=0;
 
int main()
{
  get_map();
  check();
  {
    for(int j=0;j<vertex;j++) {
      if(graph[start][j]<INF/2 && graph[j][j]<0) {
          cout << "NEGATIVE CYCLE" <<endl;
          return 0;
      }
    }
  }
  
  for(int i=0;i<vertex;i++) {
    if(graph[start][i]>=INF/2) {
      cout << "INF" << endl;
    } else {
      cout << graph[start][i] << endl;
    }
  }
  while (c == 0) {}
  return 0;
}
 
inline int fastmin(int a, int b) {
  return (((a-b)>>31)&(a-b))+b;
}

int c = 0;
int mymin_slow(int a, int b) {
  int t;
  if (a < b) {
    t = a;
    c+=2;
  } else {
    t = b;
    c+=1;
  }
  return t;
}
 
void check()
{
  for(int k=0;k<vertex;k++) {
    for(int i=0;i<vertex;i++) {
      int gik= graph[i][k];
      for(int j=0;j<vertex;j++) {
        graph[i][j]= mymin_slow(graph[i][j], gik+graph[k][j]);
      }
    }
  }
}
 
void get_map()
{
  int edge, from ,to;
  cin >> vertex >> numofedge >> start;
   
  fill(graph[0], graph[vertex], INF);
   
  for(int i=0;i<vertex;i++)
    {
      for(int j=0;j<vertex;j++)
        {
          if(i==j)
            {
              graph[i][j]=0;
            }
          /*else
            {
            graph[i][j]=INF;
            }*/
        }
    }
 
  /*for(int i=0;i<vertex;i++)
    {
    dist[i]=INF;
    }
  */
  for(int i=0;i<numofedge;i++)
    {
      cin>>from>>to;
      cin >> graph[from][to];
    }
 
  /*  for(int i=0;i<numofedge;i++)
      {
      int from, to, weight; 
      cin >> from >> to >> weight;
      g[from].push_back({to , weight});
      }
  */ 
 
  /*  for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }
      cout << endl;
      }*/
  // dist[start]=0;
   
  /*  cout << vertex << endl;
      for(int i=0;i<vertex;i++)
      {
      for(int j=0;j<vertex;j++)
      {
      cout << graph[i][j] << " ";
      }  
      cout << endl;    
      }*/
   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:10: error: 'c' was not declared in this scope
   47 |   while (c == 0) {}
      |          ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define All(X)      (X).begin(),(X).end()
const ll int INF =1000000001;
int v,e,r;


struct edge {ll int from,to,cost; };

vector<edge> es(e);
vector<ll int> d(v);

bool find_negative_loop(){
	//memset(d,0,sizeof(d));
	fill(All(d),0);
	REP(i,v){
		REP(j,e){
			edge e = es[j];
			if(d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				if(i==v-1) return true;
			}
		}
	}
	return false;
}

void SearchMinCost(int s){
	REP(i,v) d[i] = INF;
	d[s] = 0;
	while(true){
		bool update = false;
		REP(i,e){
			edge e = es[i];
			if(d[e.from]!=INF && d[e.to] > d[e.from] + e.cost ){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update) break;
	}
}
int main(){
	cin >> v >> e >> r;
	es.resize(e);
	REP(i,e) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	d.resize(v);
	SearchMinCost(r);

	if(find_negative_loop()){
		cout <<"NEGATIVE CYCLE"<<endl;
	}else{
		SearchMinCost(r);
		REP(i,v) {
			if(d[i]>=INF) cout << "INF" <<endl;
			else cout << d[i] <<endl;
		}
	//}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:77:2: error: expected '}' at end of input
   77 | }
      |  ^
a.cc:58:11: note: to match this '{'
   58 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
typedef int Weight;
const Weight INF = 1e8;
 
struct Edge {
    int src, dst;
    Weight weight;
Edge(int f, int t, Weight c) :
    src(f), dst(t), weight(c) {}
    bool operator< (const Edge &e);
};
 
bool Edge::operator< (const Edge &e)
{
    return weight != e.weight ? weight > e.weight :
        src != e.src ? src < e.src : dst < e.dst;
}
 
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
 
// グラフgの始点sから各頂点までの距離がdistに入る．
// 経路に負閉路が存在しないときtrue，そうでないときfalse．
// また，経路に負閉路を含む場合は，distが負の無限大となる．
// prefは最短路木の親頂点が入る
bool ShortestPath(const Graph &g, int s,
                  vector<Weight> &dist, vector<int> &prev)
{
    int n = g.size();
 
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -2);
 
    bool negative_cycle = false;
    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (auto e = g[i].begin(); e != g[i].end(); ++e) {
                if (dist[e->src] != INF && dist[e->dst] > dist[e->src] + e->weight) {
                    dist[e->dst] = dist[e->src] + e->weight;
                    prev[e->dst] = e->src;
                    if (k == n - 1) {
                        dist[e->dst] = -INF;
                        negative_cycle = true;
                    }
                }
            }
        }
    }
    return !negative_cycle;
}
 
 
vector<int> BuildPath(const vector<int> &prev, int t)
{
    vector<int> path;
    for (int u = t; u >= 0; u = prev[u])
        path.push_back(u);
    reverse(path.begin(), path.end());
 
    return path;
}
 
int main()
{
    int V, E, r, s, t, d;
 
    cin >> V >> E >> r;
    Graph g;
    g.reserve(N);
    for (int i = 0; i < E; ++i) {
        cin >> s >> t >> d;
        g[s].push_back(Edge(s, t, d));
    }
 
    vector<Weight> dist;
    vector<int> prev;
    if (ShortestPath(g, r, dist, prev)) {
        for (int i = 0; i < V; ++i) {
            if (INF <= dist[i])
                cout << "INF\n";
            else
                cout << dist[i] << '\n';
        }
    }
    else {
        cout << "NEGATIVE CYCLE\n";
    }
 
 
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:15: error: 'N' was not declared in this scope
   76 |     g.reserve(N);
      |               ^
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i ) 
 
const int INF = 1 << 30;
 
struct edge
{
    int from, to, cost;
 
    edge( int from, int to, int cost )
    :   from( from ), to( to ), cost( cost )
    {}
};
 
int v, e, r;
std::vector<edge> es;
int d[1000];
 
void bellman_ford()
{
    std::fill( d, d+v, INF );
    d[r] = 0;
 
    int cnt = 0;
    while( true )
    {
        bool update = false;
 
        rep( i, e )
        {
            edge &e = es[i];
 
            if( d[e.from] != INF && d[e.to] > d[e.from]+e.cost )
                d[e.to] = d[e.from]+e.cost, update = true;
        }
 
        if( !update )
            break;
 
        ++cnt;
 
        if( cnt > v )
        {
            puts("NEGATIVE CYCLE");
            return;
        }
    }
 
    rep( i, v )
    {
        if( d[i] == INF )
            puts("INF");
        else
            printf( "%d\n", d[i] );
    }
}

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++

#include <cstdio>
#define SUPER_LARGE 987654321
int V, E, R, A[1000][1000], MEMO[1000], VISIT[1000];
bool Negative_Cycle = false;
void input(void);
void init(void);
void initA(void);
void initV(void);
int DP(int s, int d);
int NC(int s, int d);
int main(void){
    //freopen("in.txt", "r", stdin);
    input();
    int i, ans[1000];
    for(i = 0; i < V; i++){
        ans[i] = DP(R, i);
        initV();
        NC(R, i);
        if (Negative_Cycle == true){
            printf("NEGATIVE CYCLE\n");
            return 0;
        }
        init();
    }
    for(i = 0; i < V; i++){
        if (ans[i] >= SUPER_LARGE) printf("INF\n");
        else printf("%d\n", ans[i]);
    }
    return 0;
}
int DP(int s, int d){
    if (VISIT[d] == 1) return MEMO[d];
    VISIT[d] = 1;
    if (d == s) return 0;
    int i, min = SUPER_LARGE;
    for(i = 0; i < V; i++){
        if (A[i][d] != -10001){
            int cnd = A[i][d] + DP(s, i);
            if (cnd < min) min = cnd;
        }
    }
    MEMO[d] = min;
    return min;
}
int NC(int s, int d){
    if (VISIT[d] == 1) return MEMO[d];
    VISIT[d] = 1;
    if (d == s) return 0;
    int i, min = MEMO[d];
    for(i = 0; i < V; i++){
        if (A[i][d] != -10001){
            int cnd = A[i][d] + NC(s, i);
            if (cnd < min){
                Negative_Cycle = true;
                break;
            }
        }
    }
    MEMO[d] = min;
    return min;
}
void input(void){
    scanf("%d%d%d", &V, &E, &R);
    initA();
    int i, a, b, w;
    for (i = 0; i < E; i++){
        scanf("%d%d%d", &a, &b, &w);
        A[a][b] = w;
    }
}
void initA(void){
    int i, j;
    for(i = 0; i < V; i++)
        for(j = 0; j < V; j++) A[i][j] = -10001;
}
void init(void){
    int i;
    for(i = 0; i < V; i++){
        MEMO[i] = 0;
        VISIT[i] = 0;
    }
}

Compiler output:
/usr/bin/ld: /tmp/cccXoaGv.o: in function `main':
a.cc:(.text+0x39): undefined reference to `initV()'
collect2: error: ld returned 1 exit status
Language: C++

#include <cstdio>
#define MIN(a, b) a < b ? a : b
#define SUPER_LARGE 987654321
int V, E, R, D[1000];
struct edges {
	int s;
	int d;
	int w;
};
struct edges A[2000];
void input(void);
bool DP(void);
int main(void){
	input();
	if (DP())
		printf("NEGATIVE CYCLE\n");
	else{
		int i;
		for (i = 0; i < V; i++){
			if (D[i] >= SUPER_LARGE)
				printf("INF\n");
			else
				printf("%d\n", D[i]);
		}
	}
		
	return 0;
}
bool DP(void){
	int i, j, k;
	for (i = 0; i < V; i++) D[i] = SUPER_LARGE;
	D[R] = 0;
	for (j = 0; j < V; j++)  // for relaxation order
	for (k = 0; k < E; k++) D[A[k].d] = MIN(A[k].w + D[A[k].s], D[A[k].d]); // relaxation 

	bool nc = false;
	for (k = 0; k < E; k++){
		if (D[A[k].d] > A[k].w + D[A[k].s]) {
			nc = true;
			break;
		}
	}
	return nc;
}

Compiler output:
/usr/bin/ld: /tmp/ccckmPKM.o: in function `main':
a.cc:(.text+0x9): undefined reference to `input()'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
#define INF 1000000000
#define MAX_V 1000
#define MAX_E 2000
using namespace std;

typedef pair<int, int> P;
struct edge { int from, to, cost; };
int V, E, r;
int d[MAX_V];

edge es[MAX_E];

bool Bellman_Ford(int start) {
	fill(d, d + V, INF);
	d[s] = 0;
	bool update;
	for (int i = 0; i < V; i++) {
		update = false;
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) break;
	}
	return update;
}

int main()
{
	int r;
	cin >> V >> E >> r;
	for (int i = 0, s, t, d; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
	}
	if (!Bellman_Ford(r)) {
		for (int i = 0; i < V; i++) {
			if (d[i] == INF)
				cout << "INF" << endl;
			else
				cout << d[i] << endl;
		}
	}
	else {
		cout << "NEGATIVE CYCLE" << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'bool Bellman_Ford(int)':
a.cc:16:11: error: 's' was not declared in this scope
   16 |         d[s] = 0;
      |           ^
Language: C++

//Bellman-Ford???(???????§???????????????????)

#include <iostream>
#include <cstdio>

using namespace std;

const long int INF = 5000000000;
const int MAX_E = 500000;
const int MAX_V = 100000;

struct edge   //??????????????????cost?????????from????????????to??????(?????????)???
{
	int from;
	int to;
	int cost;

	edge()
	{
		from = 0;
		to = 0;
		cost = 0;
	}
};

int V,E,r;    //??°?????????????????°,?????°,?§????
long int d[MAX_V];
edge es[MAX_E];


void shortest_path(int r)
{
	for(int i = 0; i < V; i++)
	{
		d[i] = INF;
	}

	d[r] = 0;

	while(true)
	{
		bool update = false;

		for(int i = 0; i < E; i++)
		{
			edge e = es[i];

			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost)  //????????´??°
			{
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;   //????????´??°??????????????£?????????????????????
	}
}


bool find_negative_cycle()
{
	memset(d, 0, sizeof(d));

	for(int i = 0; i < V; i++)
	{
		for(int j = 0; j < E; j++)
		{
			edge e = es[j];

			if (d[e.to] > d[e.from] + e.cost)
			{
				d[e.to] = d[e.from] + e.cost;

				if (i == V-1)
				{
					return true;
				}
			}
		}
	}

	return false;
}


int main()
{
	int a[10];

	scanf(" %d %d %d", &V,&E,&r);

	for(int i = 0; i < E; i++)
	{
		scanf(" %d %d %d", &es[i].from, &es[i].to, &es[i].cost);
	}

	if (find_negative_cycle())
	{
		printf("NEGATIVE CYCLE\n");
		return 0;
	}

	shortest_path(r);

	for(int i = 0; i < V; i++)
	{
		if (d[i] == INF)
		{
			printf("INF\n");
		}else
		{
			printf("%ld\n", d[i]);
		}
	}

	return 0;
}

Compiler output:
a.cc: In function 'bool find_negative_cycle()':
a.cc:62:9: error: 'memset' was not declared in this scope
   62 |         memset(d, 0, sizeof(d));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <cstdio>
  +++ |+#include <cstring>
    5 |
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <array>
//#include <tuple>

//using namespace std;

//constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int V, E, r;
    std::cin >> V >> E >> r;

    std::vector<std::vector<std::pair<int, int>>> edges(V, std::vector<std::pair<int, int>>());
    while(--E >= 0) {
        int s, t, d;
        std::cin >> s >> t >> d;
        edges[s].push_back(std::make_pair(t, d));
    }

    std::vector<long long> dist(V, INT_MAX);
    dist[r] = 0;
    while(--V >= 0){
        for(int i = 0; i < edges.size(); ++i) {
            for(const auto& edge: edges[i]) {
                int v = edge.first;
                int w = edge.second;
                dist[v] = std::min(dist[v], dist[i] + w);
            }
        }
    }

    bool isNegative = false;
    for(int i = 0; i < edges.size(); ++i) {
        for(const auto& edge: edges[i]) {
            int v = edge.first;
            int w = edge.second;
            if(dist[v] > dist[i] + w) {
                isNegative = true;
                break;
            }
        }
    }

    if(isNegative) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        for (auto val: dist) {
            if(val < INT_MAX / 2)std::cout << val << std::endl;
            else std::cout << "INF" << std::endl;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:36: error: 'INT_MAX' was not declared in this scope
   28 |     std::vector<long long> dist(V, INT_MAX);
      |                                    ^~~~~~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <array>
  +++ |+#include <climits>
   10 | //#include <tuple>
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <array>
//#include <tuple>

using namespace std;

//constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int V, E, r;
    std::cin >> V >> E >> r;

    std::vector<std::vector<std::pair<int, int>>> edges(V, std::vector<std::pair<int, int>>());
    while(--E >= 0) {
        int s, t, d;
        std::cin >> s >> t >> d;
        edges[s].push_back(std::make_pair(t, d));
    }

    std::vector<long long> dist(V, INT_MAX);
    dist[r] = 0;
    while(--V >= 0){
        for(int i = 0; i < edges.size(); ++i) {
            for(const auto& edge: edges[i]) {
                int v = edge.first;
                int w = edge.second;
                dist[v] = std::min(dist[v], dist[i] + w);
            }
        }
    }

    bool isNegative = false;
    for(int i = 0; i < edges.size(); ++i) {
        for(const auto& edge: edges[i]) {
            int v = edge.first;
            int w = edge.second;
            if(dist[v] > dist[i] + w) {
                isNegative = true;
                break;
            }
        }
    }

    if(isNegative) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        for (auto val: dist) {
            if(val < INT_MAX / 2)std::cout << val << std::endl;
            else std::cout << "INF" << std::endl;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:36: error: 'INT_MAX' was not declared in this scope
   28 |     std::vector<long long> dist(V, INT_MAX);
      |                                    ^~~~~~~
a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    9 | #include <array>
  +++ |+#include <climits>
   10 | //#include <tuple>
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <array>
#include <limits>
//#include <tuple>

using namespace std;

//constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int V, E, r;
    std::cin >> V >> E >> r;

    std::vector<std::vector<std::pair<int, int>>> edges(V, std::vector<std::pair<int, int>>());
    while(--E >= 0) {
        int s, t, d;
        std::cin >> s >> t >> d;
        edges[s].push_back(std::make_pair(t, d));
    }

    std::vector<int> dist(V, std::numeric_limits<int>::max());
    dist[r] = 0;
    while(--V >= 0){
        for(int i = 0; i < edges.size(); ++i) {
            for(const auto& edge: edges[i]) {
                int v = edge.first;
                int w = edge.second;
                if(dist[i] != std::numeric_limits<int>::max()) {
                    dist[v] = std::min(dist[v], dist[i] + w);
                }
            }a
        }
    }

    bool isNegative = false;
    for(int i = 0; i < edges.size(); ++i) {
        for(const auto& edge: edges[i]) {
            int v = edge.first;
            int w = edge.second;
            if(dist[i] != std::numeric_limits<int>::max()
               && dist[v] > dist[i] + w) isNegative = true;
        }
    }

    if(isNegative) {
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        for (auto val: dist) {
            if(val != std::numeric_limits<int>::max())std::cout << val << std::endl;
            else std::cout << "INF" << std::endl;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:14: error: 'a' was not declared in this scope
   39 |             }a
      |              ^
Language: C++

#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//ここから下
int v,e,r;
edge es[2145];
int d[1145];
bool find_negative_loop(){
    memset(d,0,sizeof(d));
    rep(i,0,v){
        rep(j,0,e){
            edge e=es[j];
            if(d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;
                if(i==v-1)return true;
            }
        }
    }
    return false;
}

void shortest_path(int s){
    rep(i,0,v)d[i]=inf;
    d[s]=0;
    while(true){
        bool update=false;
        rep(i,0,e){
            edge e=es[i];
            if(d[e.from]!=inf&&d[e.to]>d[e.from]+e.cost){
                d[e.to]=d[e.from]+e.cost;update=true;
            }
        }
        if(!update)break;
    }
}
signed main(){
    cin>>v>>e>>r;
    if(v==1){
        cout<<0<<endl;
        return 0;
    }
    rep(i,0,e){
        int a,b,c;cin>>a>>b>>c;
        es[i]=edge{a,b,c};
    }
    if(find_negative_loop()){
        cout<<"NEGATIVE CYCLE"<<endl;
        return 0;
    }
    shortest_path(r);
    rep(i,0,v){
        if(d[i]==inf)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
    return 0;
}


Compiler output:
a.cc: In function 'bool find_negative_loop()':
a.cc:27:5: error: 'memset' was not declared in this scope
   27 |     memset(d,0,sizeof(d));
      |     ^~~~~~
a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   14 | #include<list>
  +++ |+#include <cstring>
   15 | using namespace std;
Language: C++


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define MAX_V 1001
#define MAX_E 2001
#define INF (1e9 + 1)

using namespace std;

struct edge{
  int from,to,cost;
};
vector<edge> edges;

int V,E,r,a,b,c;
int d[MAX_V];

void bellford(){
  REP(i,MAX_V) d[i] = INF;
  d[r] = 0;
  REP(i,V){
    bool update = false;
    REP(j,E){
      edge e = edges[j];
      if(d[e.from] != INF && d[e.from]+e.cost < d[e.to]){
        update = true;
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1){
          cout << "NEGATIVE CYCLE" << endl;
          return;
        }
      }
    }
    if(!update)break;
    }

    REP(i,V){
      if(d[i]==INF)cout << "INF"<<endl;
      else cout << d[i] << endl;
    }
}


int main(){
  scanf("%d %d %d",&V,&E,&r);
  REP(i,E){
    scanf("%d %d %d",&a,&b,&c);
    edges.push_back((edge){a,b,c});
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:53:4: error: expected '}' at end of input
   53 |   }
      |    ^
a.cc:48:11: note: to match this '{'
   48 | int main(){
      |           ^
Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAXE = 2020;
const int MAXV = 1010;
struct edge {
  int from;
  int to;
  int cost;
};
edge es[MAXE];
int d[MAXV];
int V, E;
void shortest_path(int s){
  for(int i=0;i<MAXV;i++) d[i]=1e9;
  d[s]=0;
  int cnt=0;
  while(true){
    cnt++;
    if(cnt > E) {
        cout<<"NEGATIVE CYCLE"<<endl;
        exit(0);
    }
    bool update=false;
    for(int i=0;i<E;i++){
      if(d[es[i].from]!=1e9&&d[es[i].to]>d[es[i].from]+es[i].cost){
        d[es[i].to]=d[es[i].from]+es[i].cost;
        update=true;
      }
    }
    if(!update)break;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin>>V>>E>>r;
  FOR(i,0,E){
      cin>>es[i].from>>es[i].to>>es[i].cost;
  }
  sortest_path(r);
  FOR(i,0,V){
      if(d[i] == 1e9) cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
  }
  
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:3: error: 'sortest_path' was not declared in this scope; did you mean 'shortest_path'?
   63 |   sortest_path(r);
      |   ^~~~~~~~~~~~
      |   shortest_path
Language: C++

#include <iostream>
#include <vector>
using namespace std;
//
bool negtive=true;
struct edge{int from;int to;int cost;};
struct bellman{
	//
	int v,e;
	vector<edge> G;
	vector<int> D;
	//
	bellman(int n,int m){
		v=n;e=m;
		D.resize(v);
		fill(D.begin(),D.end(),1e9+7);
	}
	//
	void add_edge(int from,int to,int cost){
		G.push_back((edge){from,to,cost});
	}
	//
	vector<int> dist(int s){
		D[s]=0;
		for(int i=0;i<v;i++){
			bool f=false;
			for(int j=0;j<e;j++){
				edge &e=G[j];
				if(D[e.from]!=1e9+7&&D[e.to]>D[e.from]+e.cost){
					D[e.to]=D[e.from]+e.cost;
					f=true;
					if(i==v-1){
						negative=false;
						break;
					}
				}
			}
			if(!negative){
				break;
			}
			if(!f){
				break;
			}
		}
		return D;
	}
};
//
int main(){
	int V,E,r;
	cin>>V>>E>>r;
	bellman be(V,E);
	for(int i=0;i<E;i++){
		int s,t,d;
		cin>>s>>t>>d;
		be.add_edge(s,t,d);
	}
	vector<int> ans=be.dist(r);
	if(!negative){
		cout<<"NEGATIVE CYCLE"<<endl;
	}
	for(int i=0;i<V;i++){
		if(ans[i]==1e9+7){
			cout<<"INF"<<endl;
		}else{
			cout<<ans[i]<<endl;
		}
	}
	return 0;
}


Compiler output:
a.cc: In member function 'std::vector<int> bellman::dist(int)':
a.cc:33:49: error: 'negative' was not declared in this scope; did you mean 'negtive'?
   33 |                                                 negative=false;
      |                                                 ^~~~~~~~
      |                                                 negtive
a.cc:38:29: error: 'negative' was not declared in this scope; did you mean 'negtive'?
   38 |                         if(!negative){
      |                             ^~~~~~~~
      |                             negtive
a.cc: In function 'int main()':
a.cc:59:13: error: 'negative' was not declared in this scope; did you mean 'negtive'?
   59 |         if(!negative){
      |             ^~~~~~~~
      |             negtive
Language: C++

#include <cstdio>
#include <vector>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool shortestPath(const Graph g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  REP(k, n) REP(i, n) FOR(e,g[i]) {
    if (dist[e->dst] > dist[e->src] + e->weight) {
      dist[e->dst] = dist[e->src] + e->weight;
      prev[e->dst] = e->src;
      if (k == n-1) {
        dist[e->dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main(){
	int r,T,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&r);
		Graph g(V);
		vector<Weight> dist;
		vector<int> prev;
		for(;E--;)scanf("%d%d",&s,&t),g[s].push_back(Edge(s,t,-1));
		if(!shortestPath(g,r,dist,prev))puts("NEGATIVE CYCLE");
		else for(i=0;i<V;i++){
			if(dist[i]>=INF)puts("INF");
			else printf("%d\n",dist[i]);
		}
	//}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:26: error: 'i' was not declared in this scope
   55 |                 else for(i=0;i<V;i++){
      |                          ^