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

#include <stdio.h>

const int N = 131072;

int n, m;

struct edge {
	int to, weight;
};

struct node {
	edge e;
	node *next;
};

node nodes[N];
int currentCount = 0;
node *edges[N];
int p[N];
int count[N];
int distancePeople[N];

void addEdge(int from, int to, int weight) {
	edge e; e.to = to; e.weight = weight;
	//edges[from].push_back(e);
	node *nod = nodes + currentCount++;
	nod->e = e;
	nod->next = edges[from];
	edges[from] = nod;
}

int getPart(int x) {
	return p[x];
}

void init() {
	for(int i = 0; i < N; i++) {
		p[i] = i;
		count[i] = 1;
	}
}

void DFS(int x, int d, int initialDistancePeople, int part) {
	distancePeople[x] = initialDistancePeople + d;
	p[x] = part;
	count[part]++;
	for(node *p = edges[x]; p; p = p->next) {
		edge ed = p->e;
		if(p[ed.to] != part) {
			DFS(ed.to, ed.weight, distancePeople[x], part);
		}
	}
}

void unite(int x, int y, int d) {
	if(count[x] > count[y]) {
		DFS(y, d, distancePeople[x], getPart(x));
	} else {
		DFS(x, -d, distancePeople[y], getPart(y));
	}
	addEdge(x, y, d);
	addEdge(y, x, -d);
}

bool checkdistancePeople(int x, int y, int d) {
	//printf("%d %d\n", distancePeople[y] - distancePeople[x], d);
	return (distancePeople[y] - distancePeople[x]) == d;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		if(getPart(x) != getPart(y)) {
			unite(x, y, d);
		} else {
			if(!checkdistancePeople(x, y, d)) {
				printf("No\n");
				return 0;
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		printf("%d ", distancePeople[i]);
	}
	printf("\n");*/
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'void DFS(int, int, int, int)':
a.cc:49:29: error: no match for 'operator!=' (operand types are 'node' and 'int')
   49 |                 if(p[ed.to] != part) {
      |                    ~~~~~~~~ ^~ ~~~~
      |                           |    |
      |                           node int
Language: C++

#include <stdio.h>

const int N = 131072;

int n, m;

struct edge {
	int to, weight;
};

struct node {
	edge e;
	node *next;
};

node nodes[N];
int currentCount = 0;
node *edges[N];
int p[N];
int count[N];
int distancePeople[N];

void addEdge(int from, int to, int weight) {
	edge e; e.to = to; e.weight = weight;
	//edges[from].push_back(e);
	node *nod = nodes + currentCount++;
	nod->e = e;
	nod->next = edges[from];
	edges[from] = nod;
}

int getPart(int x) {
	return p[x];
}

void init() {
	for(int i = 0; i < N; i++) {
		p[i] = i;
		count[i] = 1;
	}
}

void DFS(int x, int d, int initialDistancePeople, int part) {
	distancePeople[x] = initialDistancePeople + d;
	p[x] = part;
	count[part]++;
	for(node *p = edges[x]; p; p = p->next) {
		ed = p->e;
		if(p[ed.to] != part) {
			DFS(ed.to, ed.weight, distancePeople[x], part);
		}
	}
}

void unite(int x, int y, int d) {
	if(count[x] > count[y]) {
		DFS(y, d, distancePeople[x], getPart(x));
	} else {
		DFS(x, -d, distancePeople[y], getPart(y));
	}
	addEdge(x, y, d);
	addEdge(y, x, -d);
}

bool checkdistancePeople(int x, int y, int d) {
	//printf("%d %d\n", distancePeople[y] - distancePeople[x], d);
	return (distancePeople[y] - distancePeople[x]) == d;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		if(getPart(x) != getPart(y)) {
			unite(x, y, d);
		} else {
			if(!checkdistancePeople(x, y, d)) {
				printf("No\n");
				return 0;
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		printf("%d ", distancePeople[i]);
	}
	printf("\n");*/
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'void DFS(int, int, int, int)':
a.cc:48:17: error: 'ed' was not declared in this scope; did you mean 'd'?
   48 |                 ed = p->e;
      |                 ^~
      |                 d
Language: C++

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

using namespace std;

const int N = 131072;

int n, m;

struct edge {
	int to, weight;
};

int p[N];
vector<edge> edges[N];
int count[N];
int distancePeople[N];

void addEdge(int from, int to, int weight) {
	edge e; e.to = to; e.weight = weight;
	edges[from].push_back(e);
}

int getPart(int x) {
	if(p[x] == x) {
		return x;
	}
	return getPart(p[x]);
}

void init() {
	for(int i = 0; i < N; i++) {
		p[i] = i;
		count[i] = 1;
	}
}

void DFS(int x, int d, int initialdistancePeople, int part) {
	distancePeople[x] = initialdistancePeople + d;
	p[x] = part;
	count[part]++;
	for(int i = 0; i < edges[x].size(); i++) {
		if(p[edges[x][i].to] != part) {
			DFS(edges[x][i].to, edges[x][i].weight, distancePeople[x], part);
		}
	}
}

void unite(int x, int y, int d) {
	if(count[x] > count[y]) {
		DFS(y, d, distancePeople[x], p[x]);
	} else {
		DFS(x, -d, distancePeople[y], p[y]);
	}
	addEdge(x, y, d);
	addEdge(y, x, -d);
}

bool checkdistancePeople(int x, int y, int d) {
	//printf("%d %d\n", distancePeople[y] - distancePeople[x], d);
	return (distancePeople[y] - distancePeople[x]) == d;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		if(getPart(x) != getPart(y)) {
			unite(x, y, d);
		} else {
			if(!checkdistancePeople(x, y, d)) {
				printf("No\n");
				return;
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		printf("%d ", distancePeople[i]);
	}
	printf("\n");*/
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:33: error: return-statement with no value, in function returning 'int' [-fpermissive]
   76 |                                 return;
      |                                 ^~~~~~
Language: C

#include<stdio.h>
int ta[100010],to[400040],co[400040],nt[400040];
long long d[100010];
int main(){
  int n,m,i,j,t,r,a,b,c,q[100010],u[100010]={};
  for(i=0;i<100005;i++)d[i]=ta[i]=-1;
  scanf("%d %d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    nt[i  ]=ta[to[i+m]=a];
    nt[i+m]=ta[to[i  ]=b];
    co[ta[b]=i+m]=-c;
    co[ta[a]=i  ]= c;
  }
  for(j=1;j<=n;j++){
    if(u[j])continue;
    d[j]=1e10;
    q[t=0]=j;
    u[q[t]]=1;
    for(r=1;r-t;t++){
      //for(i=0;i<n;i++)printf("%d ",d[i+1]);printf("\n");
      for(i=ta[q[t]];i+1;i=nt[i]){//printf("%d %d\n",q[t],to[i]);
		if(d[to[i]]>0&&d[to[i]]!=d[q[t]]+co[i])goto END;
		if(u[to[i]])continue;
		d[to[i]]=d[q[t]]+co[i];
      	u[to[i]=1;
		q[r++]=to[i];
      }
    }
  }
  printf("Yes\n");
  return 0;
 END:;
  printf("No\n");
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:26:18: error: expected ']' before ';' token
   26 |         u[to[i]=1;
      |                  ^
      |                  ]
main.c:27:30: error: expected ';' before '}' token
   27 |                 q[r++]=to[i];
      |                              ^
      |                              ;
   28 |       }
      |       ~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct node{
    int to;
    int far;
};
int main(void){
    int n,m;
    bool a=true;
    cin>>n>>m;
    vector<node> v[n];
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        v[l-1].push_back({r-1,d});
    }
    int x[100000]={0},done[100000]={0};
    for(int i=0;i<n;i++){
            for(auto itr = v[i].begin(); itr != v[i].end(); ++itr){
                if(done[i]!=0&&done[itr->to]!=0&&x[itr->to]!=x[i]+itr->far){
                    a=false;
                }
                else if(done[i]==0){
                    x[i]=x[itr->to]-itr->far;
                    done[i]++;done[itr->to]++;
                }else if(done[itr->to]==0){
                    x[itr->to]=x[i]+itr->far;
                    done[i]++;done[itr->to]++;
                }
            }
        if(!a)break;
    }
    string ans=(a)?"Yes":"No";
    cout<<ans<<endl;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct node{
    int to;
    int far;
};
int main(void){
    int n,m;
    bool a=true;
    cin>>n>>m;
    vector<node> v[n];
    for(int i=0;i<m;i++){
        int l,r,d;
        cin>>l>>r>>d;
        v[l-1].push_back({r-1,d});
        v[r-1].push_back({l-1,-d});
    }
    int x[100000]={0},done[100000]={0};
    for(int i=0;i<n;i++){
            for(auto itr = v[i].begin(); itr != v[i].end(); ++itr){
                if(done[i]!=0&&done[itr->to]!=0&&x[itr->to]!=x[i]+itr->far){
                    a=false;
                }
                else if(done[i]==0){
                    x[i]=x[itr->to]-itr->far;
                    done[i]++;done[itr->to]++;
                }else if(done[itr->to]==0){
                    x[itr->to]=x[i]+itr->far;
                    done[i]++;done[itr->to]++;
                }
            }
        if(!a)break;
    }
    string ans=(a)?"Yes":"No";
    cout<<ans<<endl;
}

Compiler output:
a.cc:42:8: error: redefinition of 'struct node'
   42 | struct node{
      |        ^~~~
a.cc:5:8: note: previous definition of 'struct node'
    5 | struct node{
      |        ^~~~
a.cc:46:5: error: redefinition of 'int main()'
   46 | int main(void){
      |     ^~~~
a.cc:9:5: note: 'int main()' previously defined here
    9 | int main(void){
      |     ^~~~
Language: C++

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define rep(i, N) for(int i =0;i < N;i++)
 
int N, M;
int main(){
  srand((unsigned int) time(NULL));
  scanf("%d %d", &N, &M);
	rep(i, M) {
      int r,l,d;
      scanf("%d %d %d", &r, &l, &d);
	}
  printf("%s\n", (rand() % 2) ? "Yes" : "No");
  return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:15:12: error: expected '}' at end of input
   15 |   return 0;
      |            ^
a.cc:7:11: note: to match this '{'
    7 | int main(){
      |           ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, N) for (int i = 0;i < N;++i)

using namespace std;
using LL = long long;

struct point{
	int to, cost;
};

vector<point> a[100000];


int N, M;
int dis[100000];

bool solve() {
	memset(dis, -1, sizeof(int));
	queue<int> que;
	que.push(0);
	while (!que.empty()) {
		int now = que.front(); que.pop();
		for (point elm : a[now]) {
			if (dis[elm.to] == -1) {
				dis[elm.to] = elm.cost + dis[now];
			}
			else {
				if (dis[elm.to] != elm.cost + dis[now]) {
					return false;
				}
			}
		}
	}
}


int main(void)
{
	cin >> N >> M;
	rep(i, M) {
		int r, l, d;
		cin >> r >> l >> d;
		point s = { l, d };
		a[r].push_back(s);
		s = { r, -1 * d };
		a[l].push_back(s);
	}
	cout << solve();

	return 0;
}

Compiler output:
a.cc: In function 'bool solve()':
a.cc:21:9: error: 'memset' was not declared in this scope
   21 |         memset(dis, -1, sizeof(int));
      |         ^~~~~~
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 | #define rep(i, N) for (int i = 0;i < N;++i)
a.cc:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
Language: C++

#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n,m;
	cin>>n>>m;
	int l[m],r[m],d[m];
	vector<pii> edge[n];
	rep(i,m){
		cin>>l[i]>>r[i]>>d[i];
		l[i]--;r[i]--;
		edge[l[i]].pb(pii(r[i],d[i]));
		edge[r[i]].pb(pii(l[i],-d[i]));
	}
	int num[n];
	fill(num,num+n,-1);
	rep(i,n){
		if(num[i]!=-1)continue;
		queue<int> que;
		num[i]=0;
		que.push(i);
		pii now;
		while(!que.empty()){
			now=que.front();
			que.pop();
			rep(j,vec[now].size()){
				num[vec[now][j].first]=num[now]+vec[now][j].second;
				que.push(vec[now][j].first);
			}
		}
	}
	bool check=true;
	rep(i,m){
		if(num[r[i]]-num[l[i]]!=d[i]){
			check=false;
			break;
		}
	}
	cout<<(check?"Yes":"No")<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:28: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   16 |                 edge[l[i]].pb(pii(r[i],d[i]));
      |                            ^~
a.cc:17:28: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
   17 |                 edge[r[i]].pb(pii(l[i],-d[i]));
      |                            ^~
a.cc:23:17: error: 'queue' was not declared in this scope
   23 |                 queue<int> que;
      |                 ^~~~~
a.cc:3:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    2 | #include<vector>
  +++ |+#include <queue>
    3 | #define loop(i,a,b) for(int i=a;i<b;i++)
a.cc:23:23: error: expected primary-expression before 'int'
   23 |                 queue<int> que;
      |                       ^~~
a.cc:25:17: error: 'que' was not declared in this scope
   25 |                 que.push(i);
      |                 ^~~
a.cc:30:31: error: 'vec' was not declared in this scope
   30 |                         rep(j,vec[now].size()){
      |                               ^~~
a.cc:3:35: note: in definition of macro 'loop'
    3 | #define loop(i,a,b) for(int i=a;i<b;i++)
      |                                   ^
a.cc:30:25: note: in expansion of macro 'rep'
   30 |                         rep(j,vec[now].size()){
      |                         ^~~
a.cc:31:59: error: no match for 'operator[]' (operand types are 'int [n]' and 'pii' {aka 'std::pair<int, int>'})
   31 |                                 num[vec[now][j].first]=num[now]+vec[now][j].second;
      |                                                           ^
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
typedef struct E{
  int to,cost;
}edge;
vector<vector<edge> >E(100010);
int n,m;
bool used[100010]={};
ll human[100010]={};
bool flag=true;
fill(human,100010,-INF);
void dfs(int now,int dis){
  for(int i=0;i<E[now].size();i++){
    if(!used[E[now][i].to]){
      used[E[now][i].to]=true;
      human[E[now][i].to]=dis+E[now][i].cost;
      dfs(E[now][i].to,dis+E[now][i].cost);
    }else{
      if(abs(human[now]-human[E[now][i].to])!=E[now][i].cost)
	flag=false;
    }
  }
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int l,r,d;cin>>l>>r>>d;
    edge e;
    e.to=r;e.cost=d;
    E[l].pb(e);
    e.to=l;e.cost=-d;
    E[r].pb(e);
  }
  for(int i=1;i<=n;i++){
    if(used[i]==false)
      dfs(i,human[i]);
  }
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}


Compiler output:
a.cc:29:5: error: expected constructor, destructor, or type conversion before '(' token
   29 | fill(human,100010,-INF);
      |     ^
Language: C++

//Hack from takuchibin #2045109
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int n, m;
	int l1,r1,d1;
	int l3,r3,d3;
	int e[100005];
    //すでに座標上に存在するか否か
	long long int f[100005];
    //座標上に存在する人の座標
    //fixing array size
	int count = 0;
	queue<int> l, r, d;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> l1 >> r1 >> d1;
		l.push(l1);
		r.push(r1);
		d.push(d1);
        //add rev
        l.push(r1);
        r.push(l1);
        d.push(-d1)
	}
	for(int i = 0;i < n;i++){
		e[i] = 0;
	}
	if(m == 0){
		cout << "Yes" << endl;
		return 0;
	}
	count = l.size() - 1;
	while(l.size()){
		l3 = l.front();
		r3 = r.front();
		d3 = d.front();
        //cout << l3 << r3 << d3 << endl;
		l.pop();
		r.pop();
		d.pop();
		if(e[l3] == 0 && e[r3] == 0){
			if(count == l.size()){
				e[l3] = 1;
				e[r3] = 1;
				f[l3] = 0;
				f[r3] = d3;
				count = 0;
			}else{
				count++;
				l.push(l3);
				r.push(r3);
				d.push(d3);
			}
		}else if(e[l3] == 0 && e[r3] == 1){
			count = 0;
			f[l3] = f[r3] - d3;
			e[l3] = 1;
		}else if(e[l3] == 1 && e[r3] == 0){
			count = 0;
			f[r3] = f[l3] + d3;
			e[r3] = 1;
		}else{
			count = 0;
			if(f[r3] != (f[l3] + d3)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:20: error: expected ';' before '}' token
   25 |         d.push(-d1)
      |                    ^
      |                    ;
   26 |         }
      |         ~
Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;
const int maxn = 1e5 + 100;
typedef long long ll;
vector<pair<int, int> > e[maxn];
ll dis[maxn];
bool vis[maxn];
int n, m,flag=0;

void dfs(int x)
{
	vis[x] = 1;
	for (int i = 0; i < e[x].size(); i++)
	{
		pair<int, int> cur=e[x][i];
		if (vis[cur.first]) {
			if (dis[cur.first] - dis[x] != cur.second) {
				flag = 1; break;
			}
		}
		else {
			dis[cur.first] = dis[x] + cur.second;
			dfs(cur.first);
		}
	}
}

int main()
{
	cin >> n >> m;
	memset(vis, 0, sizeof(vis));
	for (int i = 0; i < m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		e[l].push_back({ r,d });
		e[r].push_back({ l,-d });
	}
	flag = 0;
	for (int i = 0; i <n; i++) {
		if (!vis[i]) 
			dfs(i);
		if (flag) {
			break;
		}
	}
	if (flag) {
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'memset' was not declared in this scope
   34 |         memset(vis, 0, sizeof(vis));
      |         ^~~~~~
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 | using namespace std;
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

class People {
  vector<vector<Edge>> graph;
  vector<int> visited;
  vector<int> total;
  int n;
public:
  People () {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n, 0);
    total.resize(n);
    int l, r, d;
    for (int i=0; i<m; ++i) {
      cin >> l >> r >> d;
      graph[l].emplace_back(l, r, d);
      graph[r].emplace_back(r, l, -d);
    }
  }

  bool visit (int v, int t) {
    if (1 == visited[v]) {
      return t == total[v];
    } else if (0 == visited[v]) {
      total[t] = t;
      visited[v] = 1;
      for (Edge &e : graph[v]) {
        if (!visit(e.to, t + e.d)) {
          return false;
        }
      }
      visited[v] = 2;
      return true;
    }
    return true;
  }
  bool solve () {
    for (int i=0; i<n; ++i) {
      if (!visited[i]) return false;
    }
    return true;
  }
};

int main () {
  People p;
  cout << (p.solve() ? "Yes" : "No") << endl;
  return 0;
}

Compiler output:
a.cc:13:2: error: expected ';' after struct definition
   13 | }
      |  ^
      |  ;
Language: C++

#include <iostream>
#include <vector>

using namespace std;

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

class People {
  vector<vector<Edge>> graph;
  vector<int> visited;
  vector<int> total;
  int n;
public:
  People () {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n, 0);
    total.resize(n);
    int l, r, d;
    for (int i=0; i<m; ++i) {
      cin >> l >> r >> d;
      graph[l].emplace_back(l, r, d);
      graph[r].emplace_back(r, l, -d);
    }
  }

  bool visit (int v, int t) {
    if (1 == visited[v]) {
      return t == total[v];
    } else if (0 == visited[v]) {
      total[t] = t;
      visited[v] = 1;
      for (Edge &e : graph[v]) {
        if (!visit(e.to, t + e.d)) {
          return false;
        }
      }
      visited[v] = 2;
      return true;
    }
    return true;
  }
  bool solve () {
    for (int i=0; i<n; ++i) {
      if (!visited[i]) return false;
    }
    return true;
  }
}

int main () {
  People p;
  cout << (p.solve() ? "Yes" : "No") << endl;
  return 0;
}

Compiler output:
a.cc:13:2: error: expected ';' after struct definition
   13 | }
      |  ^
      |  ;
a.cc:57:2: error: expected ';' after class definition
   57 | }
      |  ^
      |  ;
Language: C++

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

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;

vvii g;
int n;

bool hascycle;
vi color;

void cycle(int v)
{
    color[v] = 1;
    for(ii u : g[v])
        if(!color[u.second])
            cycle(u.second);
        else if(color[u.second] == 1)
            hascycle = true;
    color[v] = 2;
}

vi sorted;

void toposort(int v)
{
    color[v] = 1;
    for(ii u : g[v])
        if(!color[u.second])
            toposort(u.second);
    sorted.push_back(v);
}

bool posible;
vi dis;

void check(int v, int d)
{ 
    color[v] = 1;
    dis[v] = d;
    for(ii u : g[v])
        if(!color[u.second])
            check(u.second, d + u.first);
        else if(dis[u.second] != d + u.first)
            posible = false; 
    color[v] = 2;
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int m,x,y,w;
    while(cin >> n >> m)
    {
        g = vvii(n);
        for(int i = 0; i < m; i++)
        {
            cin >> x >> y >> w; x--; y--;
            g[x].push_back({w, y});
        }
        // Cycle check
        color = vi(n, 0); hascycle = false;
        for(int i = 0; i < n; i++)
            if(!color[i])
                cycle(i);
        if(hascycle)
            cout << "No" << '\n';
        else
        {
            // Toposort
            color = vi(n, 0); sorted.clear(); 
            for(int i = 0; i < n; i++)
                if(!color[i])
                    toposort(i);
            reverse(sorted.begin(), sorted.end());
            // Distance check
            color = vi(n, 0); dis = vi(n, 0); posible = true;
            for(int v : sorted[i])
                if(!color[v])
                    check(v, 0);
            cout << (posible? "Yes" : "No") << '\n';
        }
    }
    return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:81:32: error: 'i' was not declared in this scope
   81 |             for(int v : sorted[i])
      |                                ^
Language: C++

/*
 		Resilience is the greatest of all virtues.
 		Code by rajiv
 */
 #include <iostream>
 #include <cstring>
 #include <vector>
 #include <map>
 #include <set>
 #include <stack>
 #include <queue>
 #include <deque>
 #include <sstream>
 #include <iomanip>
 #include <cassert>
 #include <sys/time.h>
 #include <algorithm>
 #include <bitset>
 #include <cmath>
 #include <functional>
 #include <cmath>

 using namespace std ;

 #define xx first
 #define yy second
 #define ll long long
 #define ld long double
 #define el (char)0x0A
 #define sp " "
 #define pb push_back
 #define mp make_pair
 #define all(x) (x).begin(),(x).end()
 #define clr(x) memset((x),0,sizeof(x))
 #define uint unsigned int
 #define abs(x) ((x<=0)?(-x):(x))
 #define CASET  int t;cin>>t;while(t--)
 #define FORN(i,x,y) for(int i=x;i<y;i++)
 #define MAXN 100005
 #define INF 10000000010
 #define MOD 1000000007
 #define last_set_bit(x) log2((x)&(-x))
 #define add(x,y) (x)=((x)+(y))%MOD
 #define PI 3.141592653589793

 typedef pair<int,int> PII ; typedef vector<int> VI ; typedef vector<vector<int> > VVI ; typedef vector<bool> VB ; typedef vector<string> VS ;
 typedef map<int,int> MII ; typedef map<int,VI > MIV ; typedef set<int> SI ; typedef set<PII > SPII ; typedef vector<PII > VPII ; typedef vector<VPII > VVPII ;
 const int N = 100050 ;


 vector<pair<int,ll >> v[N] ;

 ll D[N] ;
 int n , m  ;
 int dfs(int s, ll dist){
     if (D[s] != (LLONG_MAX)){
         return (D[s] == dist)?1:0 ;
     }
     D[s] = dist ;
     int ret = 1 ;
     for(auto it : v[s]){
         int x = dfs(it.xx,dist+it.yy) ;
         ret = min(ret,x) ;
     }
     return ret ;



 }
 int main(){
 	ios_base::sync_with_stdio(false) ;
 	cin.tie(nullptr) ;
    cin >> n >> m ;
    ll l , r , d ;
    for(int i = 0 ; i < m ; i++){
        cin >> l >> r >> d ;

        v[l].pb(mp(r,d)) ;
        v[r].pb(mp(l,-d));
    }

    for(int i = 0 ; i < N ; i++){
        D[i] = LLONG_MAX ;
    }
    bool ans = true ;
    for(int i = 1 ; i <= n ; i++){
        if (D[i]==(LLONG_MAX) && dfs(i,0)==0){
            ans = false ;
            break ;
        }
    }
    cout << (ans?"Yes":"No") << el ;
 }


Compiler output:
a.cc: In function 'int dfs(int, long long int)':
a.cc:56:19: error: 'LLONG_MAX' was not declared in this scope
   56 |      if (D[s] != (LLONG_MAX)){
      |                   ^~~~~~~~~
a.cc:22:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   21 |  #include <cmath>
  +++ |+#include <climits>
   22 | 
a.cc: In function 'int main()':
a.cc:83:16: error: 'LLONG_MAX' was not declared in this scope
   83 |         D[i] = LLONG_MAX ;
      |                ^~~~~~~~~
a.cc:83:16: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:87:20: error: 'LLONG_MAX' was not declared in this scope
   87 |         if (D[i]==(LLONG_MAX) && dfs(i,0)==0){
      |                    ^~~~~~~~~
a.cc:87:20: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
Language: Java

pos = [[] for i in range(100000)]
por = [[] for s in range(200000)]
posvis = [1 for y in range(200000)]
qe = []
n, m = map(int, input().split())
for i in range(m):
    l, r, d = map(int, input().split())
    pos[l].append([r, d, i])
    pos[r].append([l, -d, i])
    qe.append([l, r, d])
 
 
def deep(self, vis=1):
    for j in pos[self]:
        if posvis[j[2]]:
            posvis[j[2]] = 0
            if vis:
                por[self] = [100000]
            if len(set(por[self])) > 1:
                print("No")
                exit()
                por[j[0]].append(por[self][0] + j[1])
            por[j[0]].append(por[self][0] + j[1])
            deep(j[0], 0)
for qww in qe:
    if posvis[qww[0]]:
        deep(qww[0])
for i in por:
    if i:
        if len(set(i)) > 1:
            print("No")
            exit()
else:
    print("Yes")


Compiler output:
Main.java:1: error: class, interface, enum, or record expected
pos = [[] for i in range(100000)]
^
1 error
Language: C++

#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
 
struct kank{
  ll num;
  ll dx;
};
 
int main(){
  
  ll n,m;
  cin>>n>>m;
  ll l[m],r[m],d[m];
  list<kank> kanks[n+1];
  REP(i,m){
    cin>>l[i]>>r[i]>>d[i];
    kank k;
    k.num = r[i];
    k.dx = d[i];
    kanks[l[i]].push_back(k);
    k.num = l[i];
    k.dx = -d[i];
    kanks[r[i]].push_back(k);
  }
  
  string ans = "Yes";
  ll x[n+1];
  REP(i,n+1){
    x[i] = 0;
  }
  bool tukatta[n+1];
  REP(i,n+1){
    tukatta[i] = false;
  }
  
  for(int i=1;i<=n;i++){
    if(tukatta[i]==false){
      tukatta[i] = true;
      queue<ll> q;
      q.push(i);
      while(!q.empty){
        ll l = q.front();
        q.pop();
        tukatta[l] = true;
        while(!kanks[l].empty()){
          kank k = kanks[l].front();
          kanks[l].pop_front();
          if(tukatta[k.num]){
            if((x[k.num]-x[l])!=k.dx){
//              cout<<k.dx<<" "<<x[k.num]-x[l]<<endl;
              ans="No";
              cout<<ans<<endl;
              return 0;
            }
          }else{
 
            x[k.num] = x[l] + k.dx;
        //                cout<<k.num<<" "<<x[k.num]<<endl;
            q.push(k.num);
            tukatta[k.num]=true;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:16: error: cannot convert 'std::queue<long long int>::empty' from type 'bool (std::queue<long long int>::)() const' to type 'bool'
   44 |       while(!q.empty){
      |                ^~~~~
a.cc:44:16: error: in argument to unary !
   44 |       while(!q.empty){
      |              ~~^~~~~
Language: C++

#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
 
struct kank{
  ll num;
  ll dx;
};
 
int main(){
  
  ll n,m;
  cin>>n>>m;
  ll l[m],r[m],d[m];
  list<kank> kanks[n+1];
  REP(i,m){
    cin>>l[i]>>r[i]>>d[i];
    kank k;
    k.num = r[i];
    k.dx = d[i];
    kanks[l[i]].push_back(k);
    k.num = l[i];
    k.dx = -d[i];
    kanks[r[i]].push_back(k);
  }
  
  string ans = "Yes";
  ll x[n+1];
  REP(i,n+1){
    x[i] = 0;
  }
  bool tukatta[n+1];
  REP(i,n+1){
    tukatta[i] = false;
  }
  
  for(int i=1;i<=n;i++){
    if(tukatta[i]==false){
      tukatta[i] = true;
      queue<ll> q;
      q.push(i);
      while(q.size()){
        ll l = q.front();
        q.pop();
        tukatta[l] = true;
        while(kanks[l].size()){
          kank k = kanks[l].front();
          kanks[l].pop_front();
          if(tukatta[k.num]){
            if((x[k.num]-x[l])!=k.dx){
//              cout<<k.dx<<" "<<x[k.num]-x[l]<<endl;
              ans="No";
              cout<<ans<<endl;
              return 0;
            }
          }else{
 
            x[k.num] = x[l] + k.dx;
        //                cout<<k.num<<" "<<x[k.num]<<endl;
            q.push_back(k.num);
            tukatta[k.num]=true;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:62:15: error: 'class std::queue<long long int>' has no member named 'push_back'
   62 |             q.push_back(k.num);
      |               ^~~~~~~~~
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>

#define INF 20000000000
using namespace std;

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

int N;
int M;
int L[100000];
int R[100000];
int D[100000];

vector<edge> G[100001];
long long d[100001];
bool changed[100001];


void bfs(int s){
	priority_queue<P, vector<P>, greater<P> > que;
	if(d[s]==INF) d[s] = 0;
	changed[s] = true;
	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(int i=0;i<G[v].size();i++){
			struct edge e = G[v][i];
			if(d[e.to] == INF){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
				changed[d.to] = true;
				//printf("e.to:%d d[e.to]%lld\n",e.to,d[e.to]);
			}
		}
	}
}


int main(){
	scanf("%d %d", &N, &M);
	for(int i=0;i<M;i++) scanf("%d %d %d", &L[i],&R[i],&D[i]);
	for(int i=0;i<M;i++){
		struct edge e;
		e.cost = D[i];
		e.to = R[i];
		G[L[i]].push_back(e);
		//
		e.cost = -D[i];
		e.to = L[i];
		G[R[i]].push_back(e);
		//
	}
	for(int i=0;i<N+1;i++) changed[i] = false;
	fill(d,d+100001,INF);

	for(int i=0;i<M;i++){
		if(changed[L[i]]==false) bfs(L[i]);
	}


	for(int i=1;i<N+1;i++){
		//printf("%lld ",d[i]);
	}

	for(int i=0;i<M;i++){
		if(d[R[i]] - d[L[i]] != D[i]){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	return 0;
}


Compiler output:
a.cc: In function 'void bfs(int)':
a.cc:40:43: error: request for member 'to' in 'd', which is of non-class type 'long long int [100001]'
   40 |                                 changed[d.to] = true;
      |                                           ^~
Language: C++

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

using namespace std;

int prev_pos[200001] = {0};
int dist[200001] = {0};

int find(int x) {
    if (prev_pos[x] == 0) return x;

    int prev = prev_pos[x];
    prev_pos[x] = find(prev);
    dist[x] += dist[prev];
    return prev_pos[x];
}

int main() {
    int N, M;
    cin >> N >> M;

    bool flag = true;
    for (int i = 0; i < M; i++) {
        int L, R, D;
        cin >> L >> R >> D;
        int L_first = find(L);
        int R_first = find(R);

        if (L_first == L_first) {
            if (dist[L] - dist[R] != D) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            prev_pos[R_first] = L_first;
            dist[R_first] = dist[L] - dist[R] + d;
        }
    }
    cout << "No" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:49: error: 'd' was not declared in this scope
   41 |             dist[R_first] = dist[L] - dist[R] + d;
      |                                                 ^
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
struct info {
  int l, r, d;
  info(int l, int r, int d) : l(l), r(r), d(d) {}
  bool operator<(info &o) {
    return (l != o.l ? l < o.l : (r != o.r ? r < o.r : (d < o.d)));
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M;
  cin >> N >> M;
  vector<info> v;
  rep(i, 0, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    v.push_back(info(a, b, c));
    v.push_back(info(b, a, -c));
  }
  sort(all(v));

  map<int, int> m, inv;
  rep(i, 0, M) {
    int l = v[i].l, r = v[i].r, d = v[i].d;

    if (!m.count(l) and !m.count(r)) {
      m[l] = 0;
      m[r] = d;
    } else if (!m.count(l)) {
      m[l] = m[r] - d;
    } else if (!m.count(r)) {
      m[r] = m[l] + d;
    } else {
      
      }
    }
  }
  rep(i, 0, M) {
    int l = v[i].l, r = v[i].r, d = v[i].d;
    if (m[l] + d != m[r]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Compiler output:
a.cc:12:22: error: expected unqualified-id before 'for'
   12 | #define rep(i, a, b) for (int i = (a); i < (b); i++)
      |                      ^~~
a.cc:75:3: note: in expansion of macro 'rep'
   75 |   rep(i, 0, M) {
      |   ^~~
a.cc:75:7: error: 'i' does not name a type
   75 |   rep(i, 0, M) {
      |       ^
a.cc:12:40: note: in definition of macro 'rep'
   12 | #define rep(i, a, b) for (int i = (a); i < (b); i++)
      |                                        ^
a.cc:75:7: error: 'i' does not name a type
   75 |   rep(i, 0, M) {
      |       ^
a.cc:12:49: note: in definition of macro 'rep'
   12 | #define rep(i, a, b) for (int i = (a); i < (b); i++)
      |                                                 ^
a.cc:82:3: error: 'cout' does not name a type
   82 |   cout << "Yes" << endl;
      |   ^~~~
a.cc:84:3: error: expected unqualified-id before 'return'
   84 |   return 0;
      |   ^~~~~~
a.cc:85:1: error: expected declaration before '}' token
   85 | }
      | ^
Language: C++

#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

const int N=1e5+5;
const int INF=0x3f3f3f;

int par[N];
int v[N];

int Find(int x){
    int temp=par[x];
    if(par[x]!=x)   par[x]=Find(par[x]),v[x]+=v[temp];
    return par[x];
}

int main(void){
    int n,m;
    cin >>n >>m;
    for(int i=1;i<=n;i++)   par[i]=i;
    bool flag=true;
    for(int i=1;i<=m;i++){
        int l,r,d;
        scanf("%d%d%d",&l,&r,&d);
        int rootl=Find(l);
        int rootr=Find(r);
        if(rootr==rootl){
            if(v[r]-v[l]!=-d)   {flag=false;
            //cout << "v[r]="<<v[r]<<"v[l]="<<v[l]<<"-d="<<-d<<endl;}
            //cout <<"r="<<r<<"l="<<l<<endl;
        }
        else{
            par[rootl]=rootr;
            v[rootl]=d+v[r]-v[l];
        }
    }
    if(flag)    cout <<"Yes"<<endl;
    else    cout<<"No"<<endl;
}


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

#include <bits/stdc++.h>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define FORR(i,j,k,l) for(int i=j;i<=k;i+=l)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c)    scanf("%d %d %d", &a, &b, &c)
#define clean(mat,n)   FOR(i,0,n) mat[i].clear()
#define minn          (long long)-1000000000000000000
#define maxx          (long long) 1000000000000000000
#define mod          1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define LL           long long
#define NL '\n'
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define F first
#define S second
#define MAX 1000010
#define MP make_pair
#define valid(nx,ny)  ((nx >= 0) && (nx < row) && (ny >= 0) && (ny < col))
typedef pair<int,int> pr;


int lev[MAX], dis[MAX], st[MAX], col, en[MAX], vis[MAX], in[MAX];
vector<int> mat[MAX], cost[MAX], ty[MAX];
stack<int> stk;

int dfs(int p)
{
    ///cout << p << endl;
    st[p] = col;

    int temp = 0;

    FOR(i,0,(int)mat[p].size()-1)
    {
        int x = mat[p][i];

        if(st[x] != col)
        {
            if(ty[p][i])
            {
                dis[x] = dis[p] + cost[p][i];
                temp = max(temp ,dfs(x));
            }
            else
            {
                dis[x] = dis[p] - cost[p][i];
                temp = max(temp ,dfs(x));
            }
        }
        else
        {
            if(ty[p][i])
            {
                int v = dis[x] - dis[p];
                if(v != cost[p][i]) return 1;
            }
            else
            {
                int v = dis[p] - dis[x];
                if(v != cost[p][i]) return 1;
            }
        }

    }

    en[p] = col;

    return temp;
}

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    ///outf;

    int n, m, a, b, c, x, y, z;

    cin >> n >> m;

    FOR(i,0,m-1)
    {
        cin >> a >> b >> c;
        mat[a].PB(b);
        cost[a].PB(c);
        ty[a].PB(1);

        mat[b].PB(a);
        cost[b].PB(c);
        ty[b].PB(0);

    }

    col = 1;
    FOR(i,1,n)
        if(st[i] != col) stk.insert(i);

    while(!stk.empty())
    {
        int x = stk.top();
        if(st[x] != col)
        {
            //cout << x << ' ';
            col++;
            if(dfs(x)){
                cout << "No" << endl;
                return 0;
            }
        }

        stk.pop();
    }

    cout << "Yes";

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:108:30: error: 'class std::stack<int>' has no member named 'insert'
  108 |         if(st[i] != col) stk.insert(i);
      |                              ^~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define FORR(i,j,k,l) for(int i=j;i<=k;i+=l)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c)    scanf("%d %d %d", &a, &b, &c)
#define clean(mat,n)   FOR(i,0,n) mat[i].clear()
#define minn          (long long)-1000000000000000000
#define maxx          (long long) 1000000000000000000
#define mod          1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define LL           long long
#define NL '\n'
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define F first
#define S second
#define MAX 1000010
#define MP make_pair
#define valid(nx,ny)  ((nx >= 0) && (nx < row) && (ny >= 0) && (ny < col))
typedef pair<int,int> pr;


int lev[MAX], dis[MAX], st[MAX], col, en[MAX], vis[MAX], in[MAX];
vector<int> mat[MAX], cost[MAX], ty[MAX];
stack<int> stk;

int dfs(int p)
{
    ///cout << p << endl;
    st[p] = col;

    int temp = 0;

    FOR(i,0,(int)mat[p].size()-1)
    {
        int x = mat[p][i];

        if(st[x] != col)
        {
            if(ty[p][i])
            {
                dis[x] = dis[p] + cost[p][i];
                temp = max(temp ,dfs(x));
            }
            else
            {
                dis[x] = dis[p] - cost[p][i];
                temp = max(temp ,dfs(x));
            }
        }
        else
        {
            int v = dis[x] - dis[p];
            if(v != cost[p][i]) return 1;
        }

    }

    en[p] = col;

    return temp;
}

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    ///outf;

    int n, m, a, b, c, x, y, z;

    cin >> n >> m;

    FOR(i,0,m-1)
    {
        cin >> a >> b >> c;
        mat[a].PB(b);
        cost[a].PB(c);
        ty[a].PB(1);

        mat[b].PB(a);
        cost[b].PB(c);
        ty[b].PB(0);

    }

    col = 1;
    FOR(i,1,n)
        if(st[i] != col) stk.insert(i);

    while(!stk.empty())
    {
        int x = stk.top();
        if(st[x] != col)
        {
            //cout << x << ' ';
            col++;
            if(dfs(x)){
                cout << "No" << endl;
                return 0;
            }
        }

        stk.pop();
    }

    cout << "Yes";

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:100:30: error: 'class std::stack<int>' has no member named 'insert'
  100 |         if(st[i] != col) stk.insert(i);
      |                              ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int powint(int a, int x){
	int res = 1;
	REP(i,x){
		res = res *a; 
	}
	return res;
}

using namespace std;

class Point {
public:
	int jiku;
	long long int zahyou;
public:
	Point(){
		jiku=-1;
		zahyou=0;
	}
};

class Bar{
public:
	set<int> points;
};

int main(){
	int N,M;
	cin>>N>>M;
	vector<int> L(M);
	vector<int> R(M);
	vector<int> D(M);
	REP(i,M){
		cin>>L[i]>>R[i]>>D[i];

	}
	vector<Point> x(N);
	vector<Bar> b(N);
	bool dame=false;
	REP(i,M){
		int L,R,D;
		L=L[i];
		R=R[i];
		D=D[i];
		L--;
		R--;
		if(x[L].jiku==-1 && x[R].jiku==-1){
			x[L].jiku=L;
			x[R].jiku=L;
			x[L].zahyou=0;
			x[R].zahyou=D;
			b[L].points.insert(L);
			b[L].points.insert(R);
		} else if (x[L].jiku!=-1 && x[R].jiku!=-1){
			if(x[L].jiku == x[R].jiku){
				if(x[R].zahyou-x[L].zahyou!=D){
					dame=true;
					break;
				}
			} else {
				//x[L].jikuのほうにマージする
				int prejiku = x[R].jiku;
				long long int prezahyou = x[R].zahyou;
				x[R].jiku = x[L].jiku;
				x[R].zahyou = x[L].zahyou + D;
				for( auto p: b[prejiku].points){
					if(p==R) continue;
					//debug(p);
					x[p].jiku = x[L].jiku;
					x[p].zahyou = x[R].zahyou+x[p].zahyou-prezahyou;//なりたい座標
					b[x[L].jiku].points.insert(p);
				}
				b[x[L].jiku].points.insert(R);
			}
		} else if(x[L].jiku!=-1){
			x[R].jiku=x[L].jiku;
			x[R].zahyou=x[L].zahyou+D;
			b[x[R].jiku].points.insert(R);
		} else {
			x[L].jiku=x[R].jiku;
			x[L].zahyou=x[R].zahyou-D;
			b[x[L].jiku].points.insert(L);
		}
		/*
		REP(i,N){
			cout<<"Bar"<<i+1<<": ";
			for(auto p: b[i].points){
				cout<<p+1<<"("<<x[p].zahyou<<") ";
			}
			cout<<endl;
		}
		cout<<endl;
		*/
	}
	if(dame){
		cout<<"No"<<endl;
	} else {
		cout<<"Yes"<<endl;
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:20: error: invalid types 'int[int]' for array subscript
   46 |                 L=L[i];
      |                    ^
a.cc:47:20: error: invalid types 'int[int]' for array subscript
   47 |                 R=R[i];
      |                    ^
a.cc:48:20: error: invalid types 'int[int]' for array subscript
   48 |                 D=D[i];
      |                    ^
Language: C++

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll flag;
set<ll> se;
map<ll,ll> ma;
vector<pair<ll,pair<ll,ll> > > v;
vector<vector<pair<ll,ll> > > vv;
map<ll,ll> ma_index;

void f(ll l){
	rep(i,0,vv[l].sz){
		ll r = vv[l][i].se;
		ll d = vv[l][i].fi;
		if(ma[r]==0){
			ma[r] = ma[l]+d;
			if(ma[l]+d>1000000000){
				flag = 0;
			}
		}
		else{
			if(ma[r]!=ma[l]+d){
				flag = 0;
			}
		}
	}

}

int main() {
	flag = 1;
	ll n,m;
	cin>>n>>m;
	rep(i,0,m){
		ll a,b,c;
		cin>>a>>b>>c;
		v.pb(mp(c,mp(a,b)));
		se.insert(a);
	}
	vector<ll> v1(all(se));
	rep(i,0,v1.sz){
		ma_index[v1[i]] = i;
	}
	vector<vector<pair<ll,ll> > > vv_(se.sz,vector<pair<ll,ll>()) vv_;
	vv = vv_;
	rep(i,0,v.sz){
		ll l = v[i].se.fi;
		ll r = v[i].se.se;
		ll d = v[i].fi;
		vv[ma_index[l]].pb(mp(d,r));
	}
	sort(all(v));
	reverse(all(v));
	ll l0 = v[0].se.fi;
	ll r0 = v[0].se.se;
	ll d0 = v[0].fi;
	ma[l0] = 0;
	ma[r0] = d0;
	rep(i,0,v1.sz){
		f(v1[i]);
	}
	if(flag==1){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:68: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
   79 |         vector<vector<pair<ll,ll> > > vv_(se.sz,vector<pair<ll,ll>()) vv_;
      |                                                                    ^
a.cc:79:68: note:   expected a type, got 'std::pair<long long int, long long int>()'
a.cc:79:68: error: template argument 2 is invalid
a.cc:79:71: error: expected ',' or ';' before 'vv_'
   79 |         vector<vector<pair<ll,ll> > > vv_(se.sz,vector<pair<ll,ll>()) vv_;
      |                                                                       ^~~
Language: C++

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<pii,int >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define MAXN 300010
#define int ll
using namespace std;

bool used[MAXN];
ll len[MAXN];
int n,m;

vector<iiii >v;
vector<int >S[MAXN];


void main()
{
	scanf("%lld%lld",&n,&m);
	if(!m||m==1)
	{
		printf("Yes\n");
		return;
	}
	
	memset(len,-1ll,sizeof(len));
	int x,y,z;
	scanf("%lld%lld%lld",&x,&y,&z);x--;y--;
	
	queue<int>qu;
	qu.push(x);qu.push(y);
	
	len[x]=0;len[y]=1ll*z;
	m--;
	
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		scanf("%lld%lld%lld",&x,&y,&z);x--;y--;
		v.push_back(mp(mp(x,y),z));
		S[x].push_back(i);
		S[y].push_back(i);
	}
	

	int p=0;
	
	while (p<m)
	{
		while (!qu.empty())
		{
			int u=qu.front();
			qu.pop();
			for(int i=0;i<S[u].size();i++)
			{
				int j=S[u][i];
				used[j]=true;
				
				int x=v[j].first.first,y=v[j].first.second,z=v[j].second;
				if(len[x]==-1ll)
				{
					qu.push(x);
					len[x]=1ll*len[y]-z;
				}
				else if(len[y]==-1ll)
				{
					qu.push(y);
					len[y]=1ll*len[x]+z;
				}
				else if(len[y]-len[x]!=(ll)(z))
				{
					printf("No\n");
					return;
				}	
			
			}	
		}

		while (p<m&&used[p])p++;
		
		if(p<m)
		{
			used[p]=true;
			qu.push(v[p].first.first);
			qu.push(v[p].first.second);
			
			len[v[p].first.first]=0ll;
			len[v[p].first.second]=1ll*v[p].second;
			p++;
		}

	}
	
	printf("Yes\n");
	
		
	

	return;	
} 

Compiler output:
a.cc:40:1: error: '::main' must return 'int'
   40 | void main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:46:17: error: return-statement with no value, in function returning 'int' [-fpermissive]
   46 |                 return;
      |                 ^~~~~~
a.cc:96:41: error: return-statement with no value, in function returning 'int' [-fpermissive]
   96 |                                         return;
      |                                         ^~~~~~
a.cc:122:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
  122 |         return;
      |         ^~~~~~