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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
    vector<int> size;//各グループの要素数uf.size[uf.find(1)]みたいな感じでfind経由忘れずに
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
            size[y]+=size[x];
        }else{
            par[y]=x;
            size[x]+=size[y];
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};

struct edge{
  int to,cost;
};

vector<edge> g[100010];
int n,m;

void dfs(int st,int en,int& sum,vector<bool > vis){
  if(st==en || vis[st] || g[st].empty()){
    return ;
  }
  vis[st]=true;
  for(auto itr:g[st]){
    sum+=itr.cost;
    dfs(itr.to,en,sum);
  }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    UnionFind uf(n+1);
    rep(i,m){
      int x,y,z;
      cin>>x>>y>>z;
      if(uf.same(x,y)){
        int sum=0;
        vector<bool> vis(n+10,false)
        dfs(x,y,sum,vis);
        //cout<<sum<<'\n';
        if(sum!=z){
          cout<<"No"<<endl;
          return 0;
        }
      }else{
        uf.unite(x,y);
        g[x].push_back({y,z});
      }
    }
    cout<<"Yes"<<endl;
}


Compiler output:
a.cc: In function 'void dfs(int, int, int&, std::vector<bool>)':
a.cc:78:8: error: too few arguments to function 'void dfs(int, int, int&, std::vector<bool>)'
   78 |     dfs(itr.to,en,sum);
      |     ~~~^~~~~~~~~~~~~~~
a.cc:71:6: note: declared here
   71 | void dfs(int st,int en,int& sum,vector<bool > vis){
      |      ^~~
a.cc: In function 'int main()':
a.cc:93:9: error: expected ',' or ';' before 'dfs'
   93 |         dfs(x,y,sum,vis);
      |         ^~~
Language: C

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

int N,dis[100010],par[100010],ok=1;

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

int find(int x){
	if(par[x]==x)return x;
	int r=find(f[x]);
	dis[x] = dis[par[x]]+dis[x];
	return par[x] = r;
}

void unit(int x,int y,int z){
	int px=find(x), py=find(y);
	if(px==py){
		if(abs(dis[x]-dis[y])!=z)ok=0;
	}else{
		par[py]=px;
		dis[py]=dis[x]+z-dis[y];
	}
}

int main(void){
	int M,i;
	scanf("%d%d",&N,&M);
	init();
	for(i=0;i<M;i++){
		int L,R,D;
		scanf("%d%d%d",&L,&R,&D);
		unit(L,R,D);
	}
	if(ok)printf("Yes");
	else printf("No");
	
	return 0;
}

Compiler output:
main.c: In function 'find':
main.c:12:20: error: 'f' undeclared (first use in this function)
   12 |         int r=find(f[x]);
      |                    ^
main.c:12:20: note: each undeclared identifier is reported only once for each function it appears in
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long d[100005];
int n,m;
bool vis[100005],use[100005];
vector<int>v[100005];
vector<int>e[100005];
void read(int& x)
{
    char c=getchar();
    x=0;
    while(c<'0'||c>'9')c=getchar();
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
}//快读
bool dfs(int fa)
{
    vis[fa]=1;
    use[fa]=1;
    for(int i=0;i<v[fa].size();i++)
    {
        int y=v[fa][i];
        int z=e[fa][i];
        if(d[y]>d[fa]+z)//如果可以更新
        {
            if(vis[y])return 1;//如果新点已经被访问，返回1
            d[y]=d[fa]+z;//更新点权
            if(dfs(y))return 1;//如果在继续下一层dfs时返回了0,这一层也返回0
        }
    }
    vis[fa]=0;撤除vis标记
    return 0;
}
int main()
{
    read(n);
    read(m);
    for(int i=1;i<=n;i++)
    {
        d[i]=200000000000ll;
    }
    for(int i=1;i<=m;i++)
    {
        int x,y,z;
        read(x);
        read(y);
        read(z);
        v[x].push_back(y);
        e[x].push_back(z);
        v[y].push_back(x);
        e[y].push_back(-z);
    }
    bool ok=0;
    for(int i=1;i<=n;i++)
    {
        if(!use[i])//没走过就走
        {
            d[i]=0;
            if(dfs(i))
            {
                ok=1;
            }
        }
    }
    if(ok)printf("No\n");
    else printf("Yes\n");
    return 0;
}

Compiler output:
a.cc: In function 'bool dfs(int)':
a.cc:34:15: error: '\U000064a4\U00009664vis\U00006807\U00008bb0' was not declared in this scope
   34 |     vis[fa]=0;撤除vis标记
      |               ^~~~~~~~~~~
a.cc:34:12: warning: control reaches end of non-void function [-Wreturn-type]
   34 |     vis[fa]=0;撤除vis标记
      |     ~~~~~~~^~
Language: C++

#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)

ll const INF = 1000000000000000000;
int const M_MAX = 200000;
int const N_MAX = 100000;

int N, M;

int L[M_MAX + 1], R[M_MAX + 1], D[M_MAX + 1];
int xs[N_MAX + 1][N_MAX + 1];
int used[N_MAX + 1];

int find(int l, int r) {
  if (xs[l][r] != 0) return xs[l][r];
  if (used[l]) return 0;
  used[l]++;

  rep(i, N) {
    if (xs[l][i] == 0) continue;

    int result = find(i, r);
    if (result != 0) {
      xs[l][r] = xs[l][i] + result;
      return xs[l][r];
    }
  }
  return 0;
}

int main() {
  scanf("%d %d", &N, &M);

  rep(i, M) {
    scanf("%d %d %d", &L[i], &R[i], &D[i]);
  }

  rep(i, M) {
    int l = L[i];
    int r = R[i];
    int d = D[i];

    rep(i, N) used[i] = 0;
    int dist = find(l, r);
    if (dist == 0) {
      xs[l][r] = d;
      xs[r][l] = -d;
    } else if (dist != d) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}


Compiler output:
/tmp/ccy1iMRf.o: in function `find(int, int)':
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccy1iMRf.o
a.cc:(.text+0x9a): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccy1iMRf.o
a.cc:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccy1iMRf.o
/tmp/ccy1iMRf.o: in function `main':
a.cc:(.text+0x2be): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccy1iMRf.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
int n,m,fa[100005],dist[100005];
bool f;
int find(int n){
	if(fa[n]==n) return n;
	int mon=fa[n];
	fa[n]=find(fa[n]);
	dist[m]+=dist[mon];
	return fa[n];
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){fa[i]=i;}
	for(int i=1;i<=m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		if(f){continue;}
		int r1=find(u),r2=find(v);
		if(r1!=r2){
			fa[r2]=r1;
			dist[r2]=dist[r1]+w-dist[v]+dist[u];
		}
		else if(dist[v]-dist[u]!=w) f=true;
	}
    if(f) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   13 |         cin>>n>>m;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:11: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   26 |     if(f) cout<<"No"<<endl;
      |           ^~~~
      |           std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:26:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   26 |     if(f) cout<<"No"<<endl;
      |                       ^~~~
      |                       std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:27:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   27 |     else cout<<"Yes"<<endl;
      |          ^~~~
      |          std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:27:23: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   27 |     else cout<<"Yes"<<endl;
      |                       ^~~~
      |                       std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

#include<cstdio>
#define maxn 100005
int n,m,fa[maxn],dist[maxn];
bool f;
int find(int n){
	if(fa[n]==n) return n;
	int mon=fa[n];
	fa[n]=find(fa[n]);
	dist[m]+=dist[mon];
	return fa[n];
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){fa[i]=i;}
	for(int i=1;i<=m;i++){
		int u,v,w;
		cin>>u>>v>>w;
		if(f){continue;}
		int r1=find(u),r2=find(v);
		if(r1!=r2){
			fa[r2]=r1;
			dist[r2]=dist[r1]+w-dist[v]+dist[u];
		}
		else if(dist[v]-dist[u]!=w) f=true;
	}
    if(f) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:9: error: 'cin' was not declared in this scope
   14 |         cin>>n>>m;
      |         ^~~
a.cc:27:11: error: 'cout' was not declared in this scope
   27 |     if(f) cout<<"No"<<endl;
      |           ^~~~
a.cc:27:23: error: 'endl' was not declared in this scope
   27 |     if(f) cout<<"No"<<endl;
      |                       ^~~~
a.cc:28:10: error: 'cout' was not declared in this scope
   28 |     else cout<<"Yes"<<endl;
      |          ^~~~
a.cc:28:23: error: 'endl' was not declared in this scope
   28 |     else cout<<"Yes"<<endl;
      |                       ^~~~
Language: C

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>

typedef long long ll;
using namespace std;

bool check_graph(map<int, map<int, int>> &p, int src, int dst, int dnew) {
    
    deque<pair<int, int>> q;
    map<int, bool> visited;
    
    visited[src] = true;
    q.push_back(make_pair(src, 0));
    
    while (q.size()) {
        int v = q.back().first;
        int z = q.back().second;
        q.pop_back();
        if (v == dst) {
            return z == dnew;
        } else if (p.find(v) != p.end()) {
            for (const auto& itr: p[v]) {
                if (visited[itr.first]) continue;
                visited[itr.first] = true;
                q.emplace_back(itr.first, z + itr.second);
            }
        }
    }
    
    return true;
    
}

int main() {
    
    int n, m;
    cin >> n >> m;
    vector<int> l, r, d;
    map<int, map<int, int>> p;
    for (int i = 0; i < m; i++) {
        int li, ri, di;
        cin >> li >> ri >> di;
        if (!check_graph(p, li, ri, di)) {
            cout << "No" << endl;
            return 0;
        }
        if (!check_graph(p, ri, li, -di)) {
            cout << "No" << endl;
            return 0;
        }
        p[li][ri] = di;
        p[ri][li] = -di;
    }
    
    cout << "Yes" << endl;
    
}

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

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge {
	int v,w,nxt;
} e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w) {
	e[++ecnt].v = v;
	e[ecnt].w = w;
	e[ecnt].nxt = head[u];
	head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
int dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st) {
	que.push(st);
	inq[st] = 1;
	dist[st] = 0;
	while(!que.empty()) {
		int u = que.front();
		que.pop();
		for(int i = head[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if(dist[v] == 1061109567) {
				dist[v] = dist[u] + e[i].w;
				vis[v] = 1;
				if(!inq[v]) que.push(v);
			}
			else if(dist[v] != dist[u] + e[i].w) return 0;
				
		}
		inq[u] = 0;
	}
	return 1;
}

int main() {
	memset(dis,0x3f,sizeof(dis));
	scanf("%d%d",&N,&M);
	for(int i = 1; i <= M; ++ i) {
		scanf("%d%d%d",&l[i],&r[i],&d[i]);
		adde(l[i],r[i],d[i]);
		adde(r[i],l[i],-d[i]);
	}
	for(int i = 1; i <= N; ++ i) {
		if(!vis[i]) {
			vis[i] = 1;
			if(!spfa(i)) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:16: error: 'dis' was not declared in this scope; did you mean 'vis'?
   52 |         memset(dis,0x3f,sizeof(dis));
      |                ^~~
      |                vis
Language: C++

#include <iostream>
#include <cstdio>
#define N 1000001
#define M 2000001
#define inf 2147483647
#define int long long
using namespace std;
int n,m,hd[N],t,x,y,z,vis[N],d[N];
int q[N],fst,lst;
struct edge
{
    int to,nt,w;
}e[M];
void add(int u,int v,int w)
{
    e[++t].to=v,e[t].w=w;
    e[t].nt=hd[u],hd[u]=t;
}
bool spfa(int s)
{
    vis[s]=true,q[lst++]=s;
    if(lst==N)lst=0;
    while(lst!=fst)
    {
        int k=q[fst++];
        if(fst==N)fst=0;
        for(int i=hd[k],kk,w;i;i=e[i].nt)
        {
            kk=e[i].to,w=e[i].w;
            if(vis[kk]){if(d[kk]!=d[k]+w)return 1;}
            else
            {
                vis[kk]=true,d[kk]=d[k]+w;
                q[lst++]=kk;
                if(lst==N)lst=0;
            }
        }
    }
    return 0;
}
unsigned main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&z);
        add(x,y,z),add(y,x,-z);
    }
    for(int i=1;i<=n;i++)
        if(vis[i]==0&&spfa(i)){printf("No");return 0;}
    printf("Yes");
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <cstdio>
#define N 1000001
#define M 2000001
#define inf 2147483647
#define int long long
using namespace std;
int n,m,hd[N],t,x,y,z,vis[N],d[N];
int q[N],fst,lst;
struct edge
{
    int to,nt,w;
}e[M];
void add(int u,int v,int w)
{
    e[++t].to=v,e[t].w=w;
    e[t].nt=hd[u],hd[u]=t;
}
bool spfa(int s)
{
    vis[s]=true,q[lst++]=s;
    if(lst==N)lst=0;
    while(lst!=fst)
    {
        int k=q[fst++];
        if(fst==N)fst=0;
        for(int i=hd[k],kk,w;i;i=e[i].nt)
        {
            kk=e[i].to,w=e[i].w;
            if(vis[kk]){if(d[kk]!=d[k]+w)return 1;}
            else
            {
                vis[kk]=true,d[kk]=d[k]+w;
                q[lst++]=kk;
                if(lst==N)lst=0;
            }
        }
    }
    return 0;
}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&z);
        add(x,y,z),add(y,x,-z);
    }
    for(int i=1;i<=n;i++)
        if(vis[i]==0&&spfa(i)){printf("No");return 0;}
    printf("Yes");
    return 0;
}


Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
#define INF 0x3f3f3f3f
struct Edge
{
    int to,next,cost;
}e[400005];
    int n,ml,md;
int head[400005],cnt=0;
void addedge(int from,int to,int cost)
{
    e[++cnt].to = to;
    e[cnt].cost = cost;
    e[cnt].next = head[from];
    head[from] = cnt;
}
    int flag=0;
queue<int> q;
const int N=1005;
int vis[N],dis[N],circle[N];
void spfa(int s)
{
    memset(dis,0x3f,sizeof(dis));
    memset(vis,0,sizeof(vis));
    memset(circle,0,sizeof circle);
    q.push(s);
    vis[s]=1;dis[s]=0;
    while(!q.empty())
    {
        int u = q.front(); q.pop();
        vis[u] = 0;
        for(int i = head[u] ; i; i = e[i].next)
        {
            int v=e[i].to;
            int w=e[i].cost;
            if(dis[v] > dis[u] + w)
            {
                dis[v] = dis[u] + w;
                circle[v] = circle[u] + 1;
                if(circle[v] >= 2*n)
                {
                	flag=1;
                    cout<<-1<<endl;
                    return;
                }
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }	
        } 
    }
}
int main()
{

    cin>>n>>ml>>md;
    int x,y,z;
    for(int i=1;i<=n;i++) addedge(0,i,0);
    for(int i=1;i<=ml;i++)
    {
        cin>>x>>y>>z;
        addedge(x,y,z); 
    } 
    for(int i=1;i<=md;i++)
    {
        cin>>x>>y>>z;
        addedge(y,x,-z);	
	}
    spfa(0);	
    spfa(1);
    if(flag) return 0;
    if(dis[n] == INF) cout<<"-2";
    else cout<<dis[n]
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:22: error: expected ';' before 'return'
   78 |     else cout<<dis[n]
      |                      ^
      |                      ;
   79 |     return 0;
      |     ~~~~~~
Language: C++

#include <cstdio>
#include <queue>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

struct ed{
	int next;
	int to;
	int dis;
} edge[200010];
int head[100010];
int edge_tot;

inline void addedge(int from,int to,int dis){
	edge_tot += 1;
	edge[edge_tot].next = head[from];
	edge[edge_tot].to = to;
	edge[edge_tot].dis = dis;
	head[from] = edge_tot;
}
int vis[100010];
long long dis[100010];
queue<int> q;
bool inq[100010];

bool spfa(int s){
	q.push(s);
	inq[s] = true;
	dis[s] = 0;
	long long curmax = 0;long long curmin = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = head[u];i;i = edge[i].next){
			int v = edge[i].to;
			if(dis[v] == 12345678987654321){
				dis[v] = dis[u] + edge[i].dis;
				curmax = max(curmax,dis[v]);
				curmin = min(curmin,dis[v]);
				if(curmax - curmin > 1000000000) return false;
				vis[v] = 1;
				if(!inq[v])
					q.push(v);
			}
			else if(dis[v] != dis[u] + edge[i].dis)
				return false;
		}
		inq[u] = 0;
	}
	return true;
}

int main(){
	for(int i = 1;i <= 100000;i++){
		dis[i] = 12345678987654321;
	}
	scanf("%d%d",&n,&m);
	int tmp1,tmp2,tmp3;
	for(int i = 1;i <= m;i++){
		scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
		addedge(tmp1,tmp2,tmp3);
		addedge(tmp2,tmp1,-tmp3);
	}
	for(int i = 1;i <= n;i++){
		if(!vis[i]){
			vis[i] = 1;
			bool l = spfa(i);
			if(!l){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:23: error: 'n' was not declared in this scope
   59 |         scanf("%d%d",&n,&m);
      |                       ^
a.cc:59:26: error: 'm' was not declared in this scope; did you mean 'tm'?
   59 |         scanf("%d%d",&n,&m);
      |                          ^
      |                          tm
Language: C++

#include <cstdio>
#include <queue>
#include <cstring>
#define INF 0x7fffffff
using namespace std;

bool ans;
int n,m,edge_tot;
struct ed{
	int next;
	int to;
	int dis;
} edge[200010];
int head[100010];
int vis[100010];
long long dis[100010];
queue<int> q;
int inq[100010];

inline long long min(long long a,long long b){
	return a < b ? a : b;
}

inline long long max(long long a,long long b){
	return a > b ? a : b;
}
/*
inline int read(){
	int res = 0;
	int sym = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-') sym = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		res = res * 10 + ch - '0';
		ch = getchar();
	}
	return res * sym;
}
*/
inline void addedge(int from,int to,int dis){
	edge_tot += 1;
	edge[edge_tot].next = head[from];
	edge[edge_tot].to = to;
	edge[edge_tot].dis = dis;
	head[from] = edge_tot;
}

bool spfa(int s){
	inq[s] = 1;
	dis[s] = 0;
	q.push(s);
	long long curmax = 0;long long curmin = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = head[u];i;i = edge[i].next){
			int v = edge[i].to;
			if(dis[v] == 12345678987654321){
				dis[v] = dis[u] + edge[i].dis;
				curmax = max(curmax,dis[v]);
				curmin = min(curmin,dis[v]);
				if(curmax - curmin > 1000000000) return false;
				vis[v] = 1;
				if(!inq[v])
					q.push(v);
			}
			else if(dis[v] != dis[u] + edge[i].dis)
				return false;
		}
		inq[u] = 0;
	}
	return true;
}

inline void Input(){
	
	for(int i = 1;i <= 100000;i++){
		dis[i] = 12345678987654321
	}
	scanf("%d%d",&n,&m);
	int tmp1,tmp2,tmp3;
	for(int i = 1;i <= m;i++){
		scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
		addedge(tmp1,tmp2,tmp3);
		addedge(tmp2,tmp1,-1 * tmp3);
	}
	
	
}

inline void Work(){
	
	for(int i = 1;i <= n;i++){
		if(!vis[i]){
			vis[i] = 1;bool l = spfa(i);
			if(!l){
				printf("No");
				return;
			}
		}
	}
	printf("Yes");
}
/*
inline void Output(){
	
	if(ans) printf("Yes");
	else printf("No");
	
}
*/
int main(){
	
	Input();
	
	Work();
	
	return 0;
}

Compiler output:
a.cc: In function 'void Input()':
a.cc:81:43: error: expected ';' before '}' token
   81 |                 dis[i] = 12345678987654321
      |                                           ^
      |                                           ;
   82 |         }
      |         ~
Language: C++

#include <cstdio>
#include <queue>
#include <cstring>
#define INF 0x7fffffff
using namespace std;

bool ans;
int n,m,edge_tot;
struct ed{
	int next;
	int to;
	int dis;
} edge[200010];
int head[100010];
int vis[100010];
long long dis[100010];
queue<int> q;
int inq[100010];

inline long long min(long long a,long long b){
	return a < b ? a : b;
}

inline long long max(long long a,long long b){
	return a > b ? a : b;
}
/*
inline int read(){
	int res = 0;
	int sym = 1;
	char ch = getchar();
	while(ch < '0' || ch > '9'){
		if(ch == '-') sym = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9'){
		res = res * 10 + ch - '0';
		ch = getchar();
	}
	return res * sym;
}
*/
inline void addedge(int from,int to,int dis){
	edge_tot += 1;
	edge[edge_tot].next = head[from];
	edge[edge_tot].to = to;
	edge[edge_tot].dis = dis;
	head[from] = edge_tot;
}

bool spfa(int s){
	inq[s] = 1;
	dis[s] = 0;
	q.push(s);
	long long curmax = 0;long long curmin = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int i = head[u];i;i = edge[i].next){
			int v = edge[i].to;
			int val = edge[i].dis;
			if(dis[v] == INF){
				dis[v] = dis[u] + val;
				curmax = max(curmax,dis[v]);
				curmin = min(curmin,dis[v]);
				if(curmax - curmin > 1000000000) return false;
				vis[v] = 1;
				if(!inq[v]){
					q.push(v);
				}
			}else if(dis[v] != dis[u] + val){
				return false;
			}
			
		}
		inq[u] = 0;
	}
	return true;
}

inline void Input(){
	
	for(int i = 1;i <= 100000;i++){
		dis[i] = 12345678987654321
	}
	scanf("%d%d",&n,&m);
	int tmp1,tmp2,tmp3;
	for(int i = 1;i <= m;i++){
		scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
		addedge(tmp1,tmp2,tmp3);
		addedge(tmp2,tmp1,-1 * tmp3);
	}
	
	
}

inline void Work(){
	
	for(int i = 1;i <= n;i++){
		if(!vis[i]){
			vis[i] = 1;bool l = spfa(i);
			if(!l){
				printf("No");
				return;
			}
		}
	}
	printf("Yes");
}
/*
inline void Output(){
	
	if(ans) printf("Yes");
	else printf("No");
	
}
*/
int main(){
	
	Input();
	
	Work();
	
	return 0;
}

Compiler output:
a.cc: In function 'void Input()':
a.cc:84:43: error: expected ';' before '}' token
   84 |                 dis[i] = 12345678987654321
      |                                           ^
      |                                           ;
   85 |         }
      |         ~
Language: C++

#include <queue>
#include <cstdio> 
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 1100000
#define M 2200000
using namespace std;
int n,m,dis[N],maxdis = 0;
queue<int>q,Empty;
char inq[N];
int fst[N],nxt[M],to[M],val[M],cnt = 0;
inline void addedge(int x,int y,int z){
	cnt++;
	nxt[cnt] = fst[x];
	fst[x] = cnt;
	to[cnt] = y;
	val[cnt] = z;
}
int spfa(int x){
	q = Empty;
	q.push(x);
	inq[x] = 1;
	dis[x] = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		inq[u] = 0;
		for(int i = fst[u];i != -1;i = nxt[i]){
			int v = to[i];
			if(dis[v] == 0x7f7f7f7f){
				dis[v] = dis[u] + val[i];
				if(!inq[v]){
					q.push(v);
					inq[v] = 1;
				}
			}
			else if(dis[v] != dis[u] + val[i])
				return 0;
			maxdis = max(maxdis,dis[v]);
		}
	}
	return 1;
}
int main()
{
//	freopen("line.in","r",stdin);
//	freopen("line.out","w",stdout);
	memset(dis,0x7f,sizeof dis);
	memset(inq,0,sizeof inq);
	memset(fst,-1,sizeof fst);
	cin>>n>>m;
	for(int i = 1;i <= m;i++){
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		addedge(x,y,z);
		addedge(y,x,-z);
	}
	for(int i = 1;i <= n;i++)
		if(dis[i] == 0x7f7f7f7f)
			if(!spfa(i))return puts]("No"),0;
	cout<<"Yes";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:61:44: error: invalid conversion from 'int (*)(const char*)' to 'int' [-fpermissive]
   61 |                         if(!spfa(i))return puts]("No"),0;
      |                                            ^~~~
      |                                            |
      |                                            int (*)(const char*)
a.cc:61:48: error: expected ';' before ']' token
   61 |                         if(!spfa(i))return puts]("No"),0;
      |                                                ^
      |                                                ;
a.cc:61:48: error: expected primary-expression before ']' token
Language: C++

#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

unordered_map<int,int> ans;
int n,m;

main(){
	cin>>n>>m;
	cin>>l>>r>>d;
	ans.insert(mp(l,0));
	ans.insert(mp(r,ans[l]+d));
	rep(i,n-1){
		cin>>l>>r>>d;
		if(ans.count(r)==0)ans.insert(mp(r,ans[l]+d));
		else{
			if(ans[r]!=ans[l]+d){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

Compiler output:
a.cc:8:9: warning: "INT_MAX" redefined
    8 | #define INT_MAX LLONG_MAX
      |         ^~~~~~~
In file included from /usr/include/c++/14/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:38,
                 from a.cc:5:
/usr/lib/gcc/x86_64-linux-gnu/14/include/limits.h:120:9: note: this is the location of the previous definition
  120 | #define INT_MAX __INT_MAX__
      |         ^~~~~~~
a.cc:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:48:14: error: 'l' was not declared in this scope
   48 |         cin>>l>>r>>d;
      |              ^
a.cc:48:17: error: 'r' was not declared in this scope
   48 |         cin>>l>>r>>d;
      |                 ^
a.cc:48:20: error: 'd' was not declared in this scope
   48 |         cin>>l>>r>>d;
      |                    ^
Language: C++

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;
#define LL long long
const LL N = 1e5+10;

inline LL read(){
    LL x=0,sign=1;char c=getchar();
    for (;c<'0'||c>'9';){if(c=='-')sign=-1;c=getchar();}
    for (;c>='0'&&c<='9';)x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*sign;
}

LL n,m,en;
struct edge{
    LL e,d;
    edge *next;
}*v[N],ed[(N<<2)+N];
inline void add_edge(LL s,LL e,LL d){
    ed[++en].next = v[s];
    v[s] = ed + en;
    v[s] -> e = e;
    v[s] -> d = d;
}

#include <queue>
queue <LL> q;
LL vis[N],tot[N],dis[N];
struct que{
    LL l,r,d;
    inline que() {}
    inline que(LL _,LL __,LL ___):
        l(_), r(__), d(___) {}
}Q[N<<1]; 

int main()
{
    n = read();
    m = read();
    for (LL i=1;i<=m;i++){
        LL l,r,d;
        l = read(); r = read(); d = read();
        Q[i].l = l,Q[i].r = r,Q[i].d = d;
        if (d<0) d*=-1,swap(l,r);
        add_edge(l,r,d);
        add_edge(r,l,-d);
    }
    for (LL i=1;i<=n;i++) add_edge(0,i,0);
    memset(dis,0x80,sizeof(dis));
    dis[0] = 0;
    vis[0] = 1;
    q.push(0);
    LL Max = 0, Min = 0;
    for (;!q.empty();){
        LL u = q.front();
        q.pop();
        tot[u] ++;
        vis[u] = 0;
        if (tot[u]==n+1){
            printf("No");
            return 0;
        }
        for (edge *e=v[u];e;e=e->next)
            if (dis[e->e]<dis[u]+e->d){
                Max = max(Max,dis[u]+e->d);
                Min = min(Min,dis[u]+e->d);
                if（Max-Min>1e9) printf("No");
                dis[e->e]=dis[u]+e->d;
                if (!vis[e->e]) q.push(e->e);
            }
    }
 	for (LL i=1;i<=m;i++) 
        if (dis[Q[i].r]-dis[Q[i].l]!=Q[i].d){
        printf("No");
        return 0;
    }
    printf("Yes");
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:70:17: error: 'if\U0000ff08Max' was not declared in this scope
   70 |                 if（Max-Min>1e9) printf("No");
      |                 ^~~~~~~
Language: C++

// ConsoleApplication69.cpp : アプリケーションのエントリ ポイントを定義します。
//

#include "stdafx.h"
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<utility>
using namespace std;
#define REP(i, a,b) for(i=a;i<b;i++) 
#define output(x) cout<<x<<endl;
typedef long long int ll;



int main()
{
	ll  i, j, k, l, m, sum, flag, ans, N, x, y,M;
	sum = 0;
	flag = 0;
	cin >> N >> M;
	vector<pair<int, int>>P(M);
	vector<ll>D(M);

	REP(i, 0, M) {
		cin >> P[i].first >> P[i].second >> D[i];
	}
	
	vector<ll>col(N+1);
	vector<ll>vis(N+1);
	REP(i, 0, N+1) {
		col[i] = vis[i] = 0;
	}
	REP(i, 0, M) {
		//cout << col[P[i].first] << " " << col[P[i].second] << endl;
		if (vis[P[i].first] == 0 && vis[P[i].second] == 0) {
			col[P[i].second] = D[i] + col[P[i].first];
			vis[P[i].first] = vis[P[i].second] = 1;
		}
		else if (vis[P[i].first] == 1 && vis[P[i].second] == 0) {
			col[P[i].second] = D[i] + col[P[i].first];
			vis[P[i].second] = 1;
		}
		else if (vis[P[i].first] == 0 && vis[P[i].second] == 1) {
			col[P[i].first] = -D[i] + col[P[i].second];
			vis[P[i].first] = 1;
		}
		else if (vis[P[i].first] == 1 && vis[P[i].second] == 1) {
			if (col[P[i].second] != D[i] + col[P[i].first]) {
				
				flag = 1;
				break;
			}
		}


	}
	if (flag) {
		output("No");
	}
	else {
		output("Yes");
	}

	return 0;
}







Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#define lint long long
#define MAXN 500050
using namespace std;
struct Edge{
	int to, next, w;
} e[MAXN];
int h[MAXN], en, n, m;
lint dis[MAXN];
bool vis[MAXN], vis2[MAXN];
void addedge(int u, int v, int w){
	e[en].to = v;
	e[en].next = h[u];
	e[en].w = w;
	h[u] = en++;
}
bool spfa(int st){
	//memset(vis2, 0, sizeof(vis2));
	queue <int> q;
	q.push(st);
	vis2[st] = 1;
	dis[st] = 0;
	while(!q.empty())
	{
		int u = q.front();
		q.pop();
		vis2[u] = 0;
		for(int i = h[u]; ~i; i = e[i].next){
			int v = e[i].to;
			if(dis[v] == -1){
				dis[v] = dis[u] + e[i].w;
				vis[v] = 1;
				if(!vis2[v]){
					vis2[v] = 1;
					q.push(v);
				}
			} else if(dis[v] != dis[u] + e[i].w)
				return 0;
		}
	}
	return 1;
}
int main(){
	memset(h, -1, sizeof(h)); memset(dis, -1, sizeof(dis));
	scanf("%d%d", &n, &m);
	int u, v, w;
	for(int i = 1;i <= m;i++){
		scanf("%d%d%d", &u, &v, &w);
		addedge(u, v, w);
		addedge(v, u, -w);
	}
	for(int i = 1;i <= n;i++){
		if(!vis[i]){
			vis[i] = 1;
			if(!spfa(i)){
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}
]

Compiler output:
a.cc:71:1: error: expected unqualified-id before ']' token
   71 | ]
      | ^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;

class UnionFind
{
public:
    int link[100010], rnk[100010], weight[100010];
    void init ()
    {
        for (int i=0; i<100010; i++)
        {
            link[i]=i;
            rnk[i]=1;
            weight[i]=0;
        }
    }
    int Find (int x)//find parent of x
    {
        if (link[x]==x) return x;
        int r=Find(link[x]);
        weight[x]+=weight[link[x]];
        link[x]=r;
        return r;
    }
    int wght (int x)
    {
        int r=Find(x);
        return weight[x];
    }
    int diff (int x, int y) { return wght(y)-wght(x); }
    bool same (int x, int y)//tell x and y are in the same set
    {
        return Find(x)==Find(y);
    }
    void unite (int x, int y, int w)
    {
        if (same(x, y)) return;
        w=w+wght(x)-wght(y);
        x=Find(x);
        y=Find(y);
        if (rnk[x]<rnk[y]) { swap(x, y) w=-w; }
        if (rnk[x]==rnk[y]) rnk[x]++;
        link[y]=x;
        weight[y]=w;
    }
};

int main()
{
    UnionFind U;
    U.init();
    int n, m, l, r, d;
    bool ans=true;
    cin>>n>>m;
    for (int i=0; i<m; i++)
    {
        cin>>l>>r>>d;
        if (U.same(l, r))
        {
            if (U.diff(l, r)!=d) ans=false;
        }
        else U.unite(l, r, d);
    }
    if (ans) cout<<"Yes\n";
    else cout<<"No\n";
}


Compiler output:
a.cc: In member function 'void UnionFind::unite(int, int, int)':
a.cc:43:41: error: expected ';' before 'w'
   43 |         if (rnk[x]<rnk[y]) { swap(x, y) w=-w; }
      |                                         ^
Language: C++

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
struct node_ {
	int v,c,next;
} node[300001];
int head[100001],e;
void addnode(int u,int v,int c) {
	e++;
	node[e].c=c;
	node[e].v=v;
	node[e].next=head[u];
	head[u]=e;
}
int n,m;
bool b[100001],flag;
int d[100001];
int L,R,D;
void dfs(int x) {
	b[x]=1;
	for(int i=head[x]; i!=0; i=node[i].next) {
		int y=node[i].v,c=node[i].c;
		if(d[y]>d[x]+c) {
			if(b[y]) {
				flag=1;
				return;
			}
			d[y]=d[x]+c;
			dfs(y);
			if(flag)return;
		}
	}
	b[x]=0;
	return;
}
int main() {
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++) {
		scanf("%d%d%d",&L,&R,&D);
		addnode(R,L,D);
		addnode(L,R,-D);
	}
	for(int i=1; i<=n; i++) {
		memset(b,0,sizeof(b));
		memset(d,INT_MAX,sizeof(d));
		dfs(i);
		if(flag)break;
	}
	if(flag) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

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

#include<bits/stdc++.h>
using namespace std;
int n,m,x,head[100001],ans=0,s=1,dist[100001];
bool in[200001];
queue<int>q;
struct node{
	int next ,to,v;
}a[200001];
bool spfa(){
	for(int i=1;i<=n;i++)dist[i]=9999999;
	dist[s]=0;
	q.push(s);
	inqueue[s]=1;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		inqueue[u]=0;
		for(int k=head[u];k!=0;k=a[k].next){
			int v=a[k].next;
			int c=a[k].v;
			if(dist[v]!=dist[u]+a[k].v){
				cout<<"No";
				return 0;
			}
			
		}
	}
	return 1;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>a[i].to>>a[i].v;
		a[i].next=head[x];
		head[x]=i;
	}
	
}

Compiler output:
a.cc: In function 'bool spfa()':
a.cc:13:9: error: 'inqueue' was not declared in this scope; did you mean 'sigqueue'?
   13 |         inqueue[s]=1;
      |         ^~~~~~~
      |         sigqueue
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,m,x,head[100001],ans=0,s=1;
bool in[200001];
queue<int>q;
struct node{
	int next ,to,v;
}a[200001];
bool spfa(){
	for(int i=1;i<=n;i++)dist[i]=9999999;
	dist[s]=0;
	q.push(s);
	inqueue[s]=1;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		inqueue[u]=0;
		for(int k=head[u];k!=0;k=a[k].next){
			int v=a[k].next;
			int c=a[k].v;
			if(dist[v]!=dist[u]+a[k].v){
				cout<<"No";
				return 0;
			}
			
		}
	}
	return 1;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>x>>a[i].to>>a[i].v;
		a[i].next=head[x];
		head[x]=i;
	}
	
}

Compiler output:
a.cc: In function 'bool spfa()':
a.cc:10:30: error: 'dist' was not declared in this scope
   10 |         for(int i=1;i<=n;i++)dist[i]=9999999;
      |                              ^~~~
a.cc:11:9: error: 'dist' was not declared in this scope
   11 |         dist[s]=0;
      |         ^~~~
a.cc:13:9: error: 'inqueue' was not declared in this scope; did you mean 'sigqueue'?
   13 |         inqueue[s]=1;
      |         ^~~~~~~
      |         sigqueue
Language: C++

#include<bits/stdc++.h>
#define inf 999999999
using namespace std;
int main() {
	cin>>n>>m;
	if(m==0) {
		cout<<"Yes";
		return 0;
	}
	cout<<"Yes";



}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:14: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 |         cin>>n>>m;
      |              ^
      |              yn
a.cc:5:17: error: 'm' was not declared in this scope; did you mean 'tm'?
    5 |         cin>>n>>m;
      |                 ^
      |                 tm
Language: C++

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

const int maxn=100005;
int pre[maxn],f[maxn+5];

int Find(int x) {
  if(pre[x]==x)
    return x;
  int ret=Find(pre[x]);
  f[x]=f[x]+f[pre[x]];
  return pre[x]=ret;
}

int main() {
  int n, m;
  bool flag=true;

  scanf("%d%d",&n,&m);
  for(int i=1;i<=n;i++)
    pre[i]=i;

  for(int i=1;i<=m;i++) {
    int l,r,d;
    scanf("%d%d%d",&l,&r,&d);
    if(flag) {
      if(Find(l)==Find(r)) {
        if(f[r]<=f[l]) {
          int p=f[l]-f[r];
          if(p!=d)
            flag=false;
        }
        else
          flag=false;
      }
      else {
        int k=Find(l);
        pre[k]=l;
        f[k]=-f[l];
        pre[l]=r;
        f[l]=d;
      }
    }
  }
  if(flag)
    cout<<"Yes"<<endl;
    return 0;
  else
    cout<<"No"<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:3: error: 'else' without a previous 'if'
   48 |   else
      |   ^~~~
Language: C++

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

template<class Abel> struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n,Abel SUM_UNITY=0){
		init(n);
	}

	void init(int n,Abel SUM_UNITY=0){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		Abel weight(int x){
			root(x);
			return diff_weight[x];
		}

		int diff(int x,int y){
			return weight(y)-weight(x);
		}
		bool merge(int x, int y, int w){
			w += weight(x);w -= weight(y);
			x = root(x);y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = x;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			if(tree.diff(l,r) != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:25: error: class template argument deduction failed:
   63 |         UnionFind tree(N);
      |                         ^
a.cc:63:25: error: no matching function for call to 'UnionFind(int&)'
a.cc:10:9: note: candidate: 'template<class Abel> UnionFind(int, Abel)-> UnionFind<Abel>'
   10 |         UnionFind(int n,Abel SUM_UNITY=0){
      |         ^~~~~~~~~
a.cc:10:9: note:   template argument deduction/substitution failed:
a.cc:63:25: note:   couldn't deduce template parameter 'Abel'
   63 |         UnionFind tree(N);
      |                         ^
a.cc:5:29: note: candidate: 'template<class Abel> UnionFind(UnionFind<Abel>)-> UnionFind<Abel>'
    5 | template<class Abel> struct UnionFind{
      |                             ^~~~~~~~~
a.cc:5:29: note:   template argument deduction/substitution failed:
a.cc:63:25: note:   mismatched types 'UnionFind<Abel>' and 'int'
   63 |         UnionFind tree(N);
      |                         ^
Language: C++

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

templete<class Abel> struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n,Abel SUM_UNITY=0){
		init(n);
	}

	void init(int n,Abel SUM_UNITY=0){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		Abel weight(int x){
			root(x);
			return diff_weight[x];
		}

		int diff(int x,int y){
			return weight(y)-weight(x);
		}
		bool merge(int x, int y, int w){
			w += weight(x);w -= weight(y);
			x = root(x);y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = x;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			if(tree.diff(l,r) != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}


Compiler output:
a.cc:5:1: error: 'templete' does not name a type
    5 | templete<class Abel> struct UnionFind{
      | ^~~~~~~~
a.cc: In function 'int main()':
a.cc:63:9: error: 'UnionFind' was not declared in this scope
   63 |         UnionFind tree(N);
      |         ^~~~~~~~~
a.cc:68:20: error: 'tree' was not declared in this scope; did you mean 'free'?
   68 |                 if(tree.issame(l,r)){
      |                    ^~~~
      |                    free
Language: C++

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

templete<class Abel>struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n,Abel SUM_UNITY=0){
		init(n);
	}

	void init(int n,Abel SUM_UNITY=0){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		Abel weight(int x){
			root(x);
			return diff_weight[x];
		}

		int diff(int x,int y){
			return weight(y)-weight(x);
		}
		bool merge(int x, int y, int w){
			w += weight(x);w -= weight(y);
			x = root(x);y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = x;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			if(tree.diff(l,r) != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}


Compiler output:
a.cc:5:1: error: 'templete' does not name a type
    5 | templete<class Abel>struct UnionFind{
      | ^~~~~~~~
a.cc: In function 'int main()':
a.cc:63:9: error: 'UnionFind' was not declared in this scope
   63 |         UnionFind tree(N);
      |         ^~~~~~~~~
a.cc:68:20: error: 'tree' was not declared in this scope; did you mean 'free'?
   68 |                 if(tree.issame(l,r)){
      |                    ^~~~
      |                    free
Language: C++

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

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<int> diff_weight;

	UnionFind(int n){
		init(n);
	}

	void init(int n){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		int weight(int x){
			root(x);
			return diff_weight(x);
		}

		int diff(int x,int y){
			return weight(y)-weight(x);
		}
		bool merge(int x, int y, int w){
			w += weight(x);
			w -= weight(y);
			x = root(x);
			y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = x;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			if(tree.diff(l,r) != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}



Compiler output:
a.cc: In member function 'int UnionFind::weight(int)':
a.cc:37:43: error: no match for call to '(std::vector<int>) (int&)'
   37 |                         return diff_weight(x);
      |                                ~~~~~~~~~~~^~~
Language: C++

# include <cstring>
# include <cstdio>
# include <iostream>
# include <queue>
# define N 100050
# define M 200050 
# define WQD 0x7f7f7f7f
int n;
int m;
struct Edge{int next,to, w;}  e[M<<1];
int head[N+1]; 
int dis[N+1];/
bool vis[N+1];
bool spfa(int s);
using namespace std;
int main()
{
	ios::sync_with_stdio ( false ) ;
	int u,v,w;
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	for(int i=1; i<=m; i++)
	{
		cin>>u>>v>>w;
		e[i]=(Edge){head[u],v,w};head[u]=i;
		e[m+i]=(Edge){head[v],u,-w};head[v]=m+i;
	}
	for(int i=1; i<=n; i++)
		if(!vis[i]) 
		{
			vis[i]=1;
			if(spfa(i)==false)  {cout<<"No";return 0;}
		}
	cout<<"Yes";
	return 0;
}
bool spfa(int s)
{
 	queue<int>q;
 	int book[N+1];
	memset(book,0,sizeof(book));
	memset(dis,0x7f,sizeof(dis));dis[s]=0;
	q.push(s);book[s]=1;
	while(q.size()>0)
	{
		int k=q.front();q.pop();
		book[k]=0;
		for(int i=head[k]; i!=-1; i=e[i].next)
		{
			int v=e[i].to;
			if(dis[v]==WQD && dis[k]<WQD ) 
			{				
				dis[v]=dis[k]+e[i].w;
				if(book[v]==0)	{q.push(v);	book[e[i].to]=1;}
				vis[v]=1;
			}
			else if(  (dis[v]!=dis[k]+e[i].w) )	return false;
		}		
    }
	return true;
}

Compiler output:
a.cc:12:14: error: expected unqualified-id before '/' token
   12 | int dis[N+1];/
      |              ^
a.cc: In function 'int main()':
a.cc:29:21: error: 'vis' was not declared in this scope; did you mean 'dis'?
   29 |                 if(!vis[i])
      |                     ^~~
      |                     dis
a.cc: In function 'bool spfa(int)':
a.cc:55:33: error: 'vis' was not declared in this scope; did you mean 'dis'?
   55 |                                 vis[v]=1;
      |                                 ^~~
      |                                 dis