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

	#include<bits/stdc++.h>
	using namespace std; 
	#define ll long long int
	#define pb push_back
	#define mp make_pair
	#define pll pair<ll,ll>
	#define INF LLONG_MAX
	#define PI acos(-1)
	const ll MOD = 1e9 + 7;
	#define fir first
	#define sec second
	#define all(x) x.begin(),x.end()
	#define mem(a,b) memset(a,b,sizeof(a))
	#define rep(c,a,b) for(ll c=a;c<b;c++)
	#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
	ll dx4[]={-1,1,0,0};
	ll dy4[]={0,0,-1,1};
	ll dx8[]={-1,-1,-1,0,1,1,1,0};
	ll dy8[]={-1,0,1,1,1,0,-1,-1};
	bool isvalid(ll x,ll y,ll n,ll m)
	{
		return (x>=0 and y>=0 and x<n and y<m);
	}
	ll isprime[1000];
	vector<ll> prime;
	void sievetoprime(ll n)
	{
		mem(isprime,true);
		for(ll p=2;p*p<=n;p++)
		{
			if(isprime[p]==true)
			{
				for(ll i=p*p;i<=n;i+=p)
					isprime[i]=false;
			}
		}
	}
	ll lcm(ll a,ll b)
	{
		return (a/__gcd(a,b))*b;
	}
	bool cmp(pair<ll,pll> a,pair<ll,pll> b)
	{
		if(a.fir<b.fir)
			return true;
		if(a.fir==b.fir)
		{
			if(a.sec.fir<b.sec.fir)
				return true;
			return false;
		}
		return false;
	}
	void solve()
	{
		ll n,m;
		cin>>n>>m;
		vector<pair<ll,pll> > v;
		ll l,r,d;
		for(ll i=0;i<m;i++)
		{
			cin>>l>>r>>d;
			v.pb(mp(l,mp(r,d)));
		}
		sort(all(v),cmp);
		ll a[n+1]={0};
		ll vis[n+1]={0};
		vis[1]=1;
		for(ll i=0;i<m;i++)
		{
			l=v[i].fir;
			r=v[i].sec.fir;
			d=v[i].sec.sec;
			if(vis[r]==0 and vis[l]==1)
			{
				vis[r]=1;
				a[r]=a[l]+d;
			}
			else if(vis[r]==0 and vis[l]==0)
			{
				a[l]=0;
				a[r]=a[l]+d;
				vis[r]=1;
				vis[l]=1;
			}
			else if(vis[r]==1 and vis[l]==0)
			{
				a[l]=a[r]-d;
				vis[l]=1;
			}
			else if(vis[r] and vis[l])
			{
				if(a[r]-a[l]!=d)
				{
					cout<<"No\n";
					return;
				}
			}
		}
		for(ll i=0;i<=n;i++)
		{
			mn=min(mn,a[i]);
			mx=max(mx,a[i]);
		}
		if(mn<0)
		{
			for(ll i=1;i<=n;i++)
			{
				a[i]+=mn;
			}
			mx=mx+mn;
		}	
		if(mx>1000000000)
		{
			cout<<"No\n";
			return;
		}
		cout<<"Yes\n";
	}	
	
	int main()
	{
		#ifndef ONLINE_JUDGE
			freopen("input.txt","r",stdin);
			freopen("output.txt","w",stdout);
		#endif
		IOS
		ll t;
		t=1;
		//cin>>t;
		while(t--)
		{
			solve();
		}
	}

Compiler output:
a.cc: In function 'void solve()':
a.cc:103:25: error: 'mn' was not declared in this scope; did you mean 'm'?
  103 |                         mn=min(mn,a[i]);
      |                         ^~
      |                         m
a.cc:104:25: error: 'mx' was not declared in this scope; did you mean 'm'?
  104 |                         mx=max(mx,a[i]);
      |                         ^~
      |                         m
a.cc:106:20: error: 'mn' was not declared in this scope; did you mean 'm'?
  106 |                 if(mn<0)
      |                    ^~
      |                    m
a.cc:112:25: error: 'mx' was not declared in this scope; did you mean 'm'?
  112 |                         mx=mx+mn;
      |                         ^~
      |                         m
a.cc:114:20: error: 'mx' was not declared in this scope; did you mean 'm'?
  114 |                 if(mx>1000000000)
      |                    ^~
      |                    m
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

vector<int> par(0);
vector<int> depth(0);
vector<int> heavy(0);
void init(int n){
   par.resize(n);
   depth.resize(n,0);
   heavy.resize(n,0);
   rep(i,n) par[i]=i;
}

int find(int x){
   if(par[x]==x) return x;
   int parent =find(par[x]);
   heavy[x]+=heavy[par[x]];
   return par[x]=parent;
}

int wei(int x){
   find(x);
   return heavy[x];
}

void unite(int x,int y,int z){//yはxよりz重い
   z +=wei(x)-wei(y);
   x=find(x);
   y=find(y);
   if(par[x]==par[y]) return;
   if(depth[x]<depth[y]){
      par[x]=y;
      heavy[x]=-z;
   }
   else{
      par[y]=x;
      heavy[y]=z
   if(depth[x]==depth[y]) depth[x] ++;
   }
}

bool same(int x,int y){
   return find(x)==find(y);
}

int diff(int x,int y){//w[y]-w[x],比較不可なら-1
   if(!same(x,y)) return -1;
   return wei(y)-wei(x);
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m,l,r,d;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>l>>r>>d;
        r --;
        l --;
        if(diff(l,r)==d) continue;
        else if(same(l,r)){
            cout<<"No"<<endl;
            return 0;
        }
        else unite(l,r,d);
    }
    cout<<"Yes"<<endl;
}

Compiler output:
a.cc: In function 'void unite(int, int, int)':
a.cc:48:17: error: expected ';' before 'if'
   48 |       heavy[y]=z
      |                 ^
      |                 ;
   49 |    if(depth[x]==depth[y]) depth[x] ++;
      |    ~~
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int diff(int x,int y){//w[y]-w[x],比較不可なら-1
    if(!same(x,y)) return -1;
    return wei(y)-wei(x);
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m,l,r,d;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>l>>r>>d;
        r --;
        l --;
        if(diff(l,r)==d) continue;
        else if(same(l,r)){
            cout<<"No"<<endl;
            return 0;
        }
        else unite(l,r,d);
    }
    cout<<"Yes"<<endl;
}

Compiler output:
a.cc: In function 'int diff(int, int)':
a.cc:16:9: error: 'same' was not declared in this scope
   16 |     if(!same(x,y)) return -1;
      |         ^~~~
a.cc:17:12: error: 'wei' was not declared in this scope
   17 |     return wei(y)-wei(x);
      |            ^~~
a.cc: In function 'int main()':
a.cc:26:5: error: 'init' was not declared in this scope; did you mean 'int'?
   26 |     init(n);
      |     ^~~~
      |     int
a.cc:32:17: error: 'same' was not declared in this scope
   32 |         else if(same(l,r)){
      |                 ^~~~
a.cc:36:14: error: 'unite' was not declared in this scope
   36 |         else unite(l,r,d);
      |              ^~~~~
Language: C++

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,m;
  cin>>n>>m;
  vector<vector<pll>> ed(n+1,vector<pll>(0));
  rep(i,m){
    ll l,r,d,;
    cin>>l>>r>>d;
    ed[r].pb(pll(l,-d));
    ed[l].pb(pll(r,d));
  }
  queue<ll> que;
  vll dist(n+1,INF);
  for(int i=1;i<=n;i++){
    if(dist[i]==INF){
      dist[i]=0;
      que.pu(i);
      while(!empty(que)){
        ll from=que.front();
        que.pop();
        for(pll p:ed[from]){
          if(dist[p.F]==INF){
            dist[p.F]=dist[from]+p.S;
            que.pu(p.F);
          }
          else if(dist[p.F]!=dist[from]+p.S;){
            COUT("No");
            return 0;
          }
        }
      }
    }
  }
  COUT("Yes");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:14: error: expected unqualified-id before ';' token
   47 |     ll l,r,d,;
      |              ^
a.cc:66:45: error: expected primary-expression before ')' token
   66 |           else if(dist[p.F]!=dist[from]+p.S;){
      |                                             ^
Language: C++

#include <bits/stdc++.h>


using namespace std;


struct edge{int to;int cost;};

vector<edge> tree[100010];

long long int d[100010]={1e16};

bool f;
void bfs(int s){
  queue<int> q;
  q.push(s);
  d[s]=0;
  while(!q.empty()){
    
    int p=q.front();
    
    q.pop();
    for(auto x:tree[p]){
      
      int u=x.to,v=x.cost;
      
      if(d[u]==-1e16){
        d[u]=d[p]+v;
        q.push(u);
      }
      else{
        if(d[u]!=d[p]+v){
          f=false;
        }
      }
    }
  }
}

int main(){
  int n,m;
  
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int l,r,d;
    
    cin >> l >> r >> d;
    l--,r--;
    
    tree[l].push_back({r,d});
    tree[r].push_back({l,-d});
  }
  
  f=true;
  for(int i=0;i<n;i++){
    if(d[i]!=-1e16){
      continue;
    }
    bfs(i);
    
    if(!f){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Compiler output:
a.cc:11:26: error: narrowing conversion of '1.0e+16' from 'double' to 'long long int' [-Wnarrowing]
   11 | long long int d[100010]={1e16};
      |                          ^~~~
Language: C++

#include <bits/stdc++.h>


using namespace std;


struct edge{int to;int cost;};

vector<edge> tree[100010];

long long int d[100010]={1e16};

bool f;
void bfs(int s){
  queue<int> q;
  q.push(s);
  d[s]=0;
  while(!q.empty()){
    
    int p=q.front();
    
    q.pop();
    for(auto x:tree[p]){
      
      int u=x.to,v=x.cost;
      
      if(d[u]==-INF){
        d[u]=d[p]+v;
        q.push(u);
      }
      else{
        if(d[u]!=d[p]+v){
          f=false;
        }
      }
    }
  }
}

int main(){
  int n,m;
  
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int l,r,d;
    
    cin >> l >> r >> d;
    l--,r--;
    
    tree[l].push_back({r,d});
    tree[r].push_back({l,-d});
  }
  
  f=true;
  for(int i=0;i<n;i++){
    if(d[i]!=-1e16){
      continue;
    }
    bfs(i);
    
    if(!f){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


Compiler output:
a.cc:11:26: error: narrowing conversion of '1.0e+16' from 'double' to 'long long int' [-Wnarrowing]
   11 | long long int d[100010]={1e16};
      |                          ^~~~
a.cc: In function 'void bfs(int)':
a.cc:27:17: error: 'INF' was not declared in this scope
   27 |       if(d[u]==-INF){
      |                 ^~~
Language: C++

#include <bits/stdc++.h>

#define int long long

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 123;








int n, m, f[MAXN];
bool mark[MAXN];
vector<pii> g[MAXN];

void dfs(int);

int32_t main() {
    memset(f, 15, sizeof f);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        g[--l].push_back({--r, d}), g[r].push_back({l, -d});
    }
    for (int i = 0; i < n; i++)
        if (!mark[i])
            dfs(i);
    for (int i = 0; i < n; i++)
        for (auto ss : g[i]) {
            int u, x;
            tie(u, x) = ss;
            if (f[u] != f[i] + x)
                return cout << "No", 0;
        }
    cout << "Yes";
    return 0;
}
void dfs(int v) {
    mark[v] = true;
    for (auto ss : g[v]) {
        int u, q;
        tie(u, q) = ss;
        if (!mark[u])
            f[u] = f[v] + q;
            dfs(u);
        }
    }
}

Compiler output:
a.cc:55:1: error: expected declaration before '}' token
   55 | }
      | ^
Language: C++

#!/usr/bin/env python3
import sys
from collections import defaultdict, deque

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, M: int, L: "List[int]", R: "List[int]", D: "List[int]"):
    visited = [False] * N
    pos = [None] * N
    adj = [set()] * N

    for l, r, d in zip(L, R, D):
        adj[l].add((r, d))
        adj[r].add((l, -d))
    
    for i, vis in enumerate(visited):
        if vis:
            continue
        pos[i] = 0
        Q = deque([i], N)
        while len(Q) > 0:
            u = Q.popleft()
            visited[u] = True
            for v, d in adj[u]:
                if pos[v] is None:
                    pos[v] = pos[u] + d
                elif pos[v] != pos[u] + d:
                    print(NO)
                    return

                if visited[v]:
                    continue
                Q.append(v)
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    L = [int()] * (M)  # type: "List[int]" 
    R = [int()] * (M)  # type: "List[int]" 
    D = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        L[i] = int(next(tokens)) - 1
        R[i] = int(next(tokens)) - 1
        D[i] = int(next(tokens))
    solve(N, M, L, R, D)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #!
    1 | #!/usr/bin/env python3
      |  ^
a.cc:5:14: error: stray '#' in program
    5 | YES = "Yes"  # type: str
      |              ^
a.cc:6:12: error: stray '#' in program
    6 | NO = "No"  # type: str
      |            ^
a.cc:39:3: error: invalid preprocessing directive #Generated
   39 | # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
      |   ^~~~~~~~~
a.cc:46:28: error: stray '#' in program
   46 |     N = int(next(tokens))  # type: int
      |                            ^
a.cc:47:28: error: stray '#' in program
   47 |     M = int(next(tokens))  # type: int
      |                            ^
a.cc:48:24: error: stray '#' in program
   48 |     L = [int()] * (M)  # type: "List[int]"
      |                        ^
a.cc:49:24: error: stray '#' in program
   49 |     R = [int()] * (M)  # type: "List[int]"
      |                        ^
a.cc:50:24: error: stray '#' in program
   50 |     D = [int()] * (M)  # type: "List[int]"
      |                        ^
a.cc:57:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   57 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:2:1: error: 'import' does not name a type
    2 | import sys
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

bool rec(vector<pair<pair<int, int>, ll>> &V)
{
    int N = V.size();
    if (N == 0)
        return true;
    map<int, ll> mp;
    mp[V[0].first.first] = 0, mp[V[0].first.second] = V[0].second;
    for (int i = 1; i < N; i++)
    {
        auto L = V[i].first.first, R = V[i].first.second, d = V[i].second;
        if (mp.find(L) != mp.end() && mp.find(R) != mp.end())
        {
            if (mp[R] - mp[L] != d)
                return false;
        }
        else if (mp.find(L) != mp.end())
        {
            mp[R] = mp[L] + d;
        }
        else if (mp.find(R) != mp.end())
        {
            mp[L] = mp[R] - d;
        }
        else
        {
            mp[L] = 0;
            mp[R] = d;
        }
    }
    return true;
}

int N, M;

int main()
{
    cin >> N >> M;
    vector<pair<pair<int, int>, ll>> V;
    for (int i = 0; i < M; i++)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        if (a > b)
        {
            swap(a, b);
            c *= -1;
        }
        pair<int, int> p = make_pair(a, b);
        V.emplace_back(p, c);
    }
    sort(V.begin(), V.end());
    cout << (rec(V) ? "Yes" : "No") << endl;
}

Compiler output:
a.cc: In function 'bool rec(std::vector<std::pair<std::pair<int, int>, long long int> >&)':
a.cc:17:9: error: inconsistent deduction for 'auto': 'int' and then 'long long int'
   17 |         auto L = V[i].first.first, R = V[i].first.second, d = V[i].second;
      |         ^~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<vector<pair<int, int>>> al(100000);
vector<bool> visited(100000, false);
vector<long long> dist(100000, inf * -1);
//深さ優先
bool dfs(int i, int d) {
    if(visited[i] && d != dist[i])
        return false;
    if(visited[i] && d == dist[i])
        return true;
    visited[i] = true;
    dist[i] = d;
    REP(j, al[i].size()) {
        id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
    }
    return true;
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M), D(M);
    REP(i, M) cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    al[L[i]].push_back(make_pair(R[i], D[i]));
    al[R[i]].push_back(make_pair(L[i], -D[i]));
    REP(i, N) {
        if(!visited[i]) {
            //まだ訪れてないので距離が定まっていない
            if(!bfs(i, 0)) {
                // 0にしていいのか？
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Compiler output:
a.cc:33:32: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   33 | vector<long long> dist(100000, inf * -1);
      |                                ^~~
      |                                ynf
a.cc: In function 'bool dfs(int, int)':
a.cc:43:13: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
   43 |         id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
      |             ^~~
      |             ffs
a.cc:43:9: error: 'id' was not declared in this scope; did you mean 'i'?
   43 |         id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
      |         ^~
      |         i
a.cc: In function 'int main()':
a.cc:52:7: error: 'i' was not declared in this scope
   52 |     L[i]--;
      |       ^
a.cc:59:17: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
   59 |             if(!bfs(i, 0)) {
      |                 ^~~
      |                 ffs
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}
vector<vector<pair<int, int>>> al(100000);
vector<bool> visited(100000, false);

//深さ優先
bool dfs(int i, int d) {
    if(visited[i] && d != dist[i])
        return false;
    if(visited[i] && d == dist[i])
        return true;
    visited[i] = true;
    dist[i] = d;
    REP(j, al[i].size()) {
        id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
    }
    return true;
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M), R(M), D(M);
    REP(i, M) cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    al[L[i]].push_back(make_pair(R[i], D[i]));
    al[R[i]].push_back(make_pair(L[i], -D[i]));
    REP(i, N) {
        if(!visited[i]) {
            //まだ訪れてないので距離が定まっていない
            if(!bfs(i, 0)) {
                // 0にしていいのか？
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:36:27: error: 'dist' was not declared in this scope
   36 |     if(visited[i] && d != dist[i])
      |                           ^~~~
a.cc:38:27: error: 'dist' was not declared in this scope
   38 |     if(visited[i] && d == dist[i])
      |                           ^~~~
a.cc:41:5: error: 'dist' was not declared in this scope
   41 |     dist[i] = d;
      |     ^~~~
a.cc:43:13: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
   43 |         id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
      |             ^~~
      |             ffs
a.cc:43:9: error: 'id' was not declared in this scope; did you mean 'i'?
   43 |         id(!bfs(al[i][j].first, d + al[i][j].second)) return false;
      |         ^~
      |         i
a.cc: In function 'int main()':
a.cc:52:7: error: 'i' was not declared in this scope
   52 |     L[i]--;
      |       ^
a.cc:59:17: error: 'bfs' was not declared in this scope; did you mean 'ffs'?
   59 |             if(!bfs(i, 0)) {
      |                 ^~~
      |                 ffs
Language: Java

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        WeightedUnionFind uf;
        int n, m;
        int l, r, d;

        n = sc.nextInt();
        m = sc.nextInt();

        uf = new WeightedUnionFind(n + 1);

        for (int i = 0; i < m; i++) {
            l = sc.nextInt();
            r = sc.nextInt();
            d = sc.nextInt();

            if (uf.isSameGroup(l, r) &&
                uf.diff(l, r) != d) {
                System.out.println("No");
                return;
            }
            else {
                uf.unite(l, r, d);
            }
        }

        System.out.println("Yes");
    }
}


/**
 * 重み付きUnionFind木.
 * アーベル群まで拡張したいけどパフォが気になるので保留
 * ArrayList\<Integer\>がint[]よりだいぶ遅い
 */
public class WeightedUnionFind {
    /** 親を示す 自身が根の場合は -(集合の大きさ) を持つ */
    private int[] parent;
    /** 木の高さを持つ */
    private int[] rank;
    /** ノードの重み (親との差分) */
    private int[] diff_weight;

    public WeightedUnionFind(int nmemb) {
        parent = new int[nmemb];
        rank = new int[nmemb];
        diff_weight = new int[nmemb];

        Arrays.fill(parent, -1);
        Arrays.fill(rank, 0);
        Arrays.fill(diff_weight, 0);
    }

    /** 根を求める */
    private int root(int x) {
        if (parent[x] < 0) {
            return x;
        }

        // 累積和的に重みを再計算
        int r = root(parent[x]);
        diff_weight[x] += diff_weight[parent[x]];
        parent[x] = r;

        return parent[x];
    }

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

    public int diff(int x, int y) {
        return weight(y) - weight(x);
    }
    
    public boolean isSameGroup(int x, int y) {
        return root(x) == root(y);
    }

    /**
     * x->yの重みをwとして併合.
     * 即ち, weight(y) = weight(x) + w が成り立つ
     * x, yが既に同じグループのときは何もしない
     */
    public void unite(int x, int y, int w) {
        if (isSameGroup(x, y)) {
            return;
        }

        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
    
        if (rank[x] < rank[y]) {
            w = -w;
            x ^= y ^= x ^= y; //swap
        }
        else if (rank[x] == rank[y]) {
            rank[x]++;
        }

        parent[y] = x;
        diff_weight[y] = w;
    }

    public int groubSize(int x) {
        return -parent[root(x)];
    }
}


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

import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
//class nextCost implements Comparable<nextCost>{
//	public nextCost(node next, int cost) {
//		this.next = next;
//		this.cost = cost;
//	}
//	
//	node next;
//	int cost;
//	
//	@Override
//	public int compareTo(nextCost o) {
//		return cost-o.cost;
//	}
//}
//class node{
//	
//	int val;
//	int visited=0;
//	int sum=-1;
//	node(int val)
//	{
//		this.val=val;
//	}
//	List<nextCost> next =new ArrayList<>();
//}
public class Main {
	
	public static void main(String[] args) {
//		Scanner s =new Scanner(System.in);
//		
//		int n=s.nextInt(),m=s.nextInt();
//		s.nextLine();
//			node[] nodes = new node[n];
//			int[] visited = new int[n];
//			for(int i=0;i<n;i++){
//				nodes[i]=new node(i);
//			}
//			for(int i=0;i<m;i++){
//				int l=s.nextInt();
//				int r=s.nextInt();
//				int d=s.nextInt();
//				s.nextLine();
//				
//				nodes[l-1].next.add(new nextCost(nodes[r-1],d));
//				nodes[r-1].next.add(new nextCost(nodes[l-1],d));
//			}
//			boolean res=true;
//			for(int i=0;i<n;i++){
//				for (node q:nodes)
//					q.sum=-1;
//				res=fun(nodes[i],0);
//				if(res==false){
//					System.out.println("No");
//					break;
//				}
//				if(i==n-1) System.out.println("Yes");
//			}
		
        Random rand = new Random(); 
        int i=rand.nextInt(10);
        if(i%2==0) System.out.println("Yes");
        else System.out.println("No");
	}

Compiler output:
Main.java:67: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

struct UnionFind {
    // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
    vector<int> par;
    // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
    vector<int> sizes;

    UnionFind(int n) : par(n), sizes(n, 1) {
        // 最初は全てのデータiがグループiに存在するものとして初期化
        rep(i, 0, n) par[i] = i;
    }

    // データxが属する木の根を得る
    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
    }

    // 2つのデータx, yが属する木をマージする
    void unite(int x, int y) {
        // データの根ノードを得る
        x = find(x);
        y = find(y);

        // 既に同じ木に属しているならマージしない
        if (x == y) return;

        // xの木がyの木より大きくなるようにする
//        if (sizes[x] < sizes[y]) swap(x, y);

        // xがyの親になるように連結する
        par[y] = x;
        sizes[x] += sizes[y];
        // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
    }

    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
        return find(x) == find(y);
    }

    // データxが含まれる木の大きさを返す
    int size(int x) {
        return sizes[find(x)];
    }
};

class DPeopleOnALine {
public:
    int N,M,l,r,d;
void solve(std::istream& cin, std::ostream& cout) {
    UnionFind uf(101010);
    int pos[101010];
    memset(pos,0,sizeof(pos));
    cin >> N >> M;
    _for(i,M){
        cin >> l >> r >> d;
        if(uf.find(l) == uf.find(r)){
            if(pos[r] - pos[l] != d){
                cout << "No\n";
                return;
            }
        }
        else{
            uf.unite(l,r);
            pos[r] = pos[l]+d;
        }
    }
    cout << "Yes\n";


}
};


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

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define f first
#define pb push_back
#define s second
#define mp make_pair

int d[100100];
vector<pi> aList[100100];
int N,M,a,b,c;

void dfs(int x){
  for (auto i : aList[x]){
    int nxt = 0;
    if (i.f < x)nxt = d[x] - i.s;
    else nxt = d[x] + i.s;
    if (d[i.f] == -1){
      d[i.f] = nxt;
      dfs(i.f);
    }else{
      if (nxt != d[i.f]){
        cout<<"No";
        exit(0);
      }
    }
  }
}

int main(){
  cin >> N >> M;
  for (int i=0;i<M;++i){
    cin>>a>>b>>c;
    aList[a].pb(mp(b,c));
    aList[b].pb(mp(a,c));
  }
  memset(d, -1, sizeof(d));
  for (int i=1;i<=N;++i){ 
    if (d[i] != -1)continue;
    d[i] = 0;
    dfs(i);
  }
  cout<<"Yes";
}v

Compiler output:
a.cc:46:2: error: 'v' does not name a type; did you mean 'vi'?
   46 | }v
      |  ^
      |  vi
Language: C

#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 2000005 ;

int pre[maxn];
int dis[maxn];

int Find(int x)
{
     if(pre[x]==x)
        return x;

    int r=Find(pre[x]);
    dis[x]=dis[pre[x]]+dis[x];

    return pre[x]=r;
}

int Union(int x, int y, int z)
{
    int fx = Find(x);
    int fy = Find(y);

    if (fx == fy)
        return (z == dis[y] - dis[x]);

    pre[fy] = fx;

    dis[fy] = dis[x] + z - dis[y];

    return 1;
}

int x[maxn];
int y[maxn];
int z[maxn];

int main()
{
    int n, m;
    int flag = 1;

    cin >> n >> m;

    for (int i = 1; i <= n; i++)
        pre[i]=i;

    for (int i = 1; i <= m; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
    }

    for(int i =1;i<=m;i++)
    {
        flag = Union(x[i], y[i], z[i]);
        if(flag == 0)
            goto end;
    }

end:
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


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

#include <bits/stdc++.h>
#pragma warning (disable : 4996)
using namespace std;
const int INF = -1234567890;
typedef pair<int, int> pii;
int main()
{
	int a[100006];
	int n, m; scanf("%d %d", &n, &m);
	fill(a, a + n + 3, INF);
	vector<pii> graph[100006];
	for (int i = 0; i < m; i++)
	{
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		graph[x].push_back({ y,z });
		graph[y].push_back({ x,-z });
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] != INF) continue;
		a[i] = 0;
		axis.clear();
		queue<pii> v;
		v.push({ i,0 });
		while (!v.empty())
		{
			int tpx = v.front().first;
			int tpy = v.front().second;
			v.pop();
			for (int i = 0; i < graph[tpx].size(); i++)
			{
				auto loc = graph[tpx][i];
				if (a[loc.first] != INF)
				{
					if (a[loc.first] - tpy != loc.second) return !printf("No");
				}
				else
				{
					a[loc.first] = loc.second + tpy;
					v.push({ loc.first,a[loc.first] });
				}
			}
		}
	}
	return !printf("Yes");
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:17: error: 'axis' was not declared in this scope
   23 |                 axis.clear();
      |                 ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

typedef pair<int, int> pii;

const int MAXN = 1e5 + 5;
int N, M;
vector<pii> neigh[MAXN];
bool tk[MAXN];
int val[MAXN];

bool Fill(int v, int col) {
	if (tk[v]) return val[v] == col;
	tk[v] = true;
	val[v] = col;
	for (int i = 0; i < neigh[v].size(); i++) {
		pii u = neigh[v][i];
		if (!Fill(u.first, val[v] + u.second)) return false;
	}
	return true;
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; i++) {
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		neigh[a].push_back(pii(b, c));
		neigh[b].push_back(pii(a, -c));
	}
	for (int i = 1; i <= n; i++) {
		if (!tk[i]) {
			if (!Fill(i, 0)) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: 'n' was not declared in this scope
   27 |         scanf("%d %d", &n, &m);
      |                         ^
a.cc:27:29: error: 'm' was not declared in this scope
   27 |         scanf("%d %d", &n, &m);
      |                             ^
Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#define int long long
#define double long double
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用

using namespace std;
std::mt19937 mt((int)time(0));

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int L[200001], R[200001], D[200001];

int ma[100002];

signed main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < 100002; i++) {
		ma[i] = LL_HALFMAX;
	}
	for (int i = 0; i < M; i++) {
		cin >> L[i] >> R[i] >> D[i];
	}

	int cnt = 0;

	for (int i = 0; i < M; i++) {
		//LもRもまだ位置が決まってなかったら
		if (ma[L[i]] == LL_HALFMAX && ma[R[i]] == LL_HALFMAX) {
			ma[L[i]] = 0;
			ma[R[i]] = D[i];
		}
		//Lが決まってたら
		else if (ma[L[i]] != LL_HALFMAX && ma[R[i]] == LL_HALFMAX) {
			ma[R[i]] = ma[L[i]] + D[i];
		}
		//Rが決まってたら
		else if (ma[R[i]] != LL_HALFMAX && ma[L[i]] == LL_HALFMAX) {
			ma[L[i]] = ma[R[i]] - D[i];
		}
		//両方決まってたら
		else {
			if (ma[R[i]] - ma[L[i]] != D[i])cnt++;
		}
	}
	//はみ出し検査
	int mini = LLONG_MAX, maxi = LLONG_MIN;
	for (int i = 0; i < 100002; i++) {
		if (ma[i] == LL_HALFMAX) continue;
		if (ma[i] < mini) mini = ma[i];
		if (ma[i] > maxi) maxi = ma[i];
	}
	if (maxi - mini > 1000000000) cnt++;

	if (cnt == 0) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:20: error: 'LLONG_MAX' was not declared in this scope
   66 |         int mini = LLONG_MAX, maxi = LLONG_MIN;
      |                    ^~~~~~~~~
a.cc:17:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   16 | #include <assert.h>
  +++ |+#include <climits>
   17 | #define int long long
a.cc:70:29: error: 'maxi' was not declared in this scope
   70 |                 if (ma[i] > maxi) maxi = ma[i];
      |                             ^~~~
a.cc:72:13: error: 'maxi' was not declared in this scope
   72 |         if (maxi - mini > 1000000000) cnt++;
      |             ^~~~
Language: C++

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

#define int long long

int N, M;
//          id , distance
vector<pair<int, int> >vec[100005];
int pos[100005];
set<int> ok;
 
bool dfs(int pos){
	if(ok.count(pos) != 0)
		return true;
	ok.insert(pos);
	for(int i = 0; i < vec[pos].size(); i++){
		int nextpos = vec[pos][i].first;
		int diff = vec[pos][i].second;
		if(pos[nextpos] != INT_MAX && pos[nextpos] != pos[pos] + diff){
			return false;
		}
		pos[nextpos] = pos[pos] + diff;
		if(dfs(nextpos) == false){
			return false;
		}
	}
	ok.insert(pos);
	return true;
}
 
int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int L, R, D;
		cin >> L >> R >> D;
		L--;R--;
		vec[L].push_back(make_pair(R, D));
		vec[R].push_back(make_pair(L, -sD));
	}
 
	for(int i = 0; i < N; i++)
		pos[i] = INT_MAX;
 
 
	for(int i = 0; i < N; i++){
		if(ok.count(i) != 0)
			continue;
		pos[i] = 0;
		if(dfs(i) == false){
			puts("No");
			return 0;
		}
 
	}
 
	puts("Yes");
	return 0;
}



Compiler output:
a.cc: In function 'bool dfs(long long int)':
a.cc:19:23: error: invalid types 'long long int[long long int]' for array subscript
   19 |                 if(pos[nextpos] != INT_MAX && pos[nextpos] != pos[pos] + diff){
      |                       ^
a.cc:19:50: error: invalid types 'long long int[long long int]' for array subscript
   19 |                 if(pos[nextpos] != INT_MAX && pos[nextpos] != pos[pos] + diff){
      |                                                  ^
a.cc:19:66: error: invalid types 'long long int[long long int]' for array subscript
   19 |                 if(pos[nextpos] != INT_MAX && pos[nextpos] != pos[pos] + diff){
      |                                                                  ^
a.cc:22:20: error: invalid types 'long long int[long long int]' for array subscript
   22 |                 pos[nextpos] = pos[pos] + diff;
      |                    ^
a.cc:22:35: error: invalid types 'long long int[long long int]' for array subscript
   22 |                 pos[nextpos] = pos[pos] + diff;
      |                                   ^
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:38:48: error: 'sD' was not declared in this scope; did you mean 'D'?
   38 |                 vec[R].push_back(make_pair(L, -sD));
      |                                                ^~
      |                                                D
Language: C++

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

#define MAX_N 100000

typedef pair<int, int> pii;
vector<pii> edge[MAX_N + 1];
bool visited[MAX_N + 1];
int dist[MAX_N + 1];

bool dfs(int v) {
    visited[v] = true;
    for (int i = 0; i < edge[v].size(); ++i) {
        int next = edge[v][i].first;
        int cost = edge[v][i].second;
        if (!visited[next]) {
            dist[next] = dist[v] + cost;
            if (!dfs(next)) {
                return false;
            }
        } else {
            if (dist[next] != dist[v] + cost) {
                return false;
            }
        }
    }
    return true;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    if (M == 0) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < M; ++i) {
        int l, r, val;
        cin >> l >> r >> val;
        edge[l].push_back(make_pair(r, val));
        edge[r].push_back(make_pair(l, -val));
    }

    memset(visited, false, sizeof(visited));

    for (int i = 1; i < N; ++i) {
        if (!visited[i]) {
            dist[i] = 0;
            if (!dfs(i)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:47:5: error: 'memset' was not declared in this scope
   47 |     memset(visited, false, sizeof(visited));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int pre[MAXN], rnk[MAXN];
int F(int x)
{
	if (x != pre[x])
	{
		int p = pre[x];
		pre[x] = F(pre[x]);
		rnk[x] += rnk[p];
	}
	return pre[x];
}

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n,m;
	int l, r, d;
	while (cin >> n >> m) {
		for (int i = 0; i < MAXN; i++)
		{
			pre[i] = i;
			rnk[i] = 0;
		}
		int f = 0;
		for (int i = 0; i < m; i++)
		{
			cin >> l >> r >> d;
			int lx = F(l);
			int rx = F(r);
			if (lx != rx)
			{
				pre[rx] = lx;
0-=				rnk[rx] = rnk[l] -0+ d;
			}
			else if (rnk[r]-rnk[l] != d)
			{
				f = 1;
			}
 		}
		string ss[] = { "Yes","No" };
		cout << ss[f] << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:54: error: lvalue required as left operand of assignment
   60 | 0-=                             rnk[rx] = rnk[l] -0+ d;
      |                                                      ^
Language: C++

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

using namespace std;

#define   M             10005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           0x3f3f3f3f
#define   rush()        int T;scanf("%d",&T);while(T--)

typedef   pair<int,int> P;

vector <P> E[M];
int vis[M];

bool dfs(int u) {
	vis[u]=1;
	for(auto p : E[u]) {
		int v =p.first;
		int d =p.second;
		
		if(!vis[v]) {
			dis[v]=dis[u]+d;
			if(!dfs(v))
				return false;
		}
		else if(dis[u]+d != dis[v]) return false;
	}
	return true;
}


int main() {

	int n,m,f=0;
	scanf("%d %d",&n,&m);
	
//	mst(a,-1);
	
	while(m--) {
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		E[x].push_back(make_pair(y,z));
		E[y].push_back(make_pair(x,-z));
	}
	
	f=0;
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			if(!dfs(i)) {
				f=1;
				break;
			}
		}
	}
	
	if(f) puts("No");
	else  puts("Yes");
	
}



Compiler output:
a.cc: In function 'bool dfs(int)':
a.cc:27:25: error: 'dis' was not declared in this scope; did you mean 'vis'?
   27 |                         dis[v]=dis[u]+d;
      |                         ^~~
      |                         vis
a.cc:31:25: error: 'dis' was not declared in this scope; did you mean 'vis'?
   31 |                 else if(dis[u]+d != dis[v]) return false;
      |                         ^~~
      |                         vis
Language: C++

require 'pp'
N,M=gets.chomp.split(' ').map{|n| n.to_i}

DEBUG = false
def dpp str
	if(DEBUG)
		pp str
	end
end

def dfs(node, dist, e, f, d)
	if(d[node])
		if(d[node] != dist)
			return -1
		end
		return 0
	end
	f[node]=true
	d[node]=dist
	nodes=e[node]
	r = 0
	0.upto(nodes.size-1){|i|
		node = nodes[i]
		r = dfs(node[0], dist+node[1], e,f,d)
		if(r==-1)
			puts "No"
			exit(0)
		end
	}
end
# edge from the node
# 0 index
E = Array.new(N){[]}
# is already arrived 
F = Array.new(N){false}
# distance from `a` root
D = Array.new(N){}

1.upto(M){
	p=gets.chomp.split(' ').map{|n| n.to_i}
	p[0]-=1
	p[1]-=1
	E[p[0]].push([p[1],p[2]])
	E[p[1]].push([p[0],-p[2]])
}
dpp E

0.upto(N-1){|i|
	dfs(i,0,E,F,D)
}
puts "Yes"


Compiler output:
a.cc:1:9: warning: multi-character character constant [-Wmultichar]
    1 | require 'pp'
      |         ^~~~
a.cc:31:3: error: invalid preprocessing directive #edge
   31 | # edge from the node
      |   ^~~~
a.cc:32:5: error: "index" is not a valid filename
   32 | # 0 index
      |     ^~~~~
a.cc:34:3: error: invalid preprocessing directive #is; did you mean #if?
   34 | # is already arrived
      |   ^~
      |   if
a.cc:36:3: error: invalid preprocessing directive #distance
   36 | # distance from `a` root
      |   ^~~~~~~~
a.cc:1:1: error: 'require' does not name a type
    1 | require 'pp'
      | ^~~~~~~
a.cc:4:1: error: 'DEBUG' does not name a type
    4 | DEBUG = false
      | ^~~~~
a.cc:30:1: error: 'end' does not name a type
   30 | end
      | ^~~
a.cc:35:1: error: 'F' does not name a type
   35 | F = Array.new(N){false}
      | ^
a.cc:37:1: error: 'D' does not name a type
   37 | D = Array.new(N){}
      | ^
a.cc:39:1: error: expected unqualified-id before numeric constant
   39 | 1.upto(M){
      | ^~~~~~
a.cc:46:1: error: 'dpp' does not name a type
   46 | dpp E
      | ^~~
a.cc:51:1: error: 'puts' does not name a type
   51 | puts "Yes"
      | ^~~~
Language: C++

#include <iostream>
#include <limits>
#include <queue>

int n, m;
constexpr int MAXN = 100000;
int G[MAXN + 1][MAXN + 1];
int C[MAXN + 1];
int D[MAXN + 1];
int MAXINT = std::numeric_limits<int>::max();

bool solve() {
    std::queue<int> Q;
    for (int i = 0; i < n; i++) {
        if (C[i] == 0) {
            int r = i;
            C[r] = 1;
            D[r] = 0;
            Q.push(r);
            while (!Q.empty()) {
                r = Q.front();
                for (int j = 0; j < n; j++) {
                    if ((G[r][j] < MAXINT) && (C[j] == 1)) {
                        if ((D[r] + G[r][j]) != D[j]) {
                            return false;
                        }
                    } else if ((G[r][j] < MAXINT) && (C[j] == 0)) {
                        Q.push(j);
                        C[j] = 1;
                        D[j] = D[r] + G[r][j];
                    }
                }
                Q.pop();
            }
        }
    }
    return true;
}

int main() {
    std::cin >> n >> m;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            G[i][j] = MAXINT;
        }
    }
    for (int i = 0; i < m; i++) {
        int l, r, d;
        std::cin >> l >> r >> d;
        l -= 1;
        r -= 1;
        G[l][r] = d;
        G[r][l] = -d;
    }

    if (solve()) {
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}

Compiler output:
/tmp/ccf4M2zx.o: in function `solve()':
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0xf6): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x112): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x1b1): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x1e3): relocation truncated to fit: R_X86_64_PC32 against symbol `C' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x1fe): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccf4M2zx.o
a.cc:(.text+0x23e): relocation truncated to fit: R_X86_64_PC32 against symbol `D' defined in .bss section in /tmp/ccf4M2zx.o
collect2: error: ld returned 1 exit status