Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>P;
struct edge{int to,cost;};
const long long minf= -1145141919
int l[200005],r[200005],d[200005];
int par[100005],rnk[100005];
vector<edge>G[100005];
bool visit[100005];
int dis[100005];

void init(int n) {
	for (int i = 0; i<n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x]<rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}

bool bfs(int s){
	dis[s]=0;
	queue<int>Q;
	Q.push(s);
	while(Q.size()){
		int v=Q.front();
		Q.pop();
		for(int i=0;i<G[v].size()){
			edge e=G[v][i];
			if(dis[e.to]!=minf&&dis[e.to]!=dis[v]+e.cost){
				return false;
				}
			else if(dis[e.to]==minf){
				dis[e.to]=dis[v]+e.cost;
				Q.push(e.to);
				}	
			}
		}return true;
	}

signed main(){
	int n,m;
	cin>>n>>m;
	init(n);
	for(int i=0;i<m;i++){
		cin>>l[i]>>r[i]>>d[i];
		unite(l[i]-1,r[i]-1);
		G[l[i]-1].push_back({G[r[i]-1],d[i]});
		G[r[i]-1].push_back({G[l[i]-1],d[i]});
		l[i]--,r[i]--;
		}
		
	fill(visit,visit+n,false);	
	for(int i=0;i<n;i++){
		if(visit[par(i)])continue;
		visit[i]=true;
		if(!bfs(i)){
			puts("No");
			return 0;
			}
		}	
		puts("Yes");
	}

Compiler output:
a.cc:3:13: error: expected ',' or ';' before 'long'
    3 | #define int long long
      |             ^~~~
a.cc:7:1: note: in expansion of macro 'int'
    7 | int l[200005],r[200005],d[200005];
      | ^~~
a.cc: In function 'bool bfs(long long int)':
a.cc:46:42: error: expected ';' before ')' token
   46 |                 for(int i=0;i<G[v].size()){
      |                                          ^
      |                                          ;
a.cc: In function 'int main()':
a.cc:64:22: error: 'l' was not declared in this scope
   64 |                 cin>>l[i]>>r[i]>>d[i];
      |                      ^
a.cc:64:28: error: 'r' was not declared in this scope
   64 |                 cin>>l[i]>>r[i]>>d[i];
      |                            ^
a.cc:64:34: error: 'd' was not declared in this scope
   64 |                 cin>>l[i]>>r[i]>>d[i];
      |                                  ^
a.cc:71:14: error: reference to 'visit' is ambiguous
   71 |         fill(visit,visit+n,false);
      |              ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [100005]'
   10 | bool visit[100005];
      |      ^~~~~
a.cc:71:20: error: reference to 'visit' is ambiguous
   71 |         fill(visit,visit+n,false);
      |                    ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [100005]'
   10 | bool visit[100005];
      |      ^~~~~
a.cc:73:20: error: reference to 'visit' is ambiguous
   73 |                 if(visit[par(i)])continue;
      |                    ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [100005]'
   10 | bool visit[100005];
      |      ^~~~~
a.cc:73:29: error: 'par' cannot be used as a function
   73 |                 if(visit[par(i)])continue;
      |                          ~~~^~~
a.cc:74:17: error: reference to 'visit' is ambiguous
   74 |                 visit[i]=true;
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:10:6: note:                 'bool visit [100005]'
   10 | bool visit[100005];
      |      ^~~~~