Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<int> com;vector<int> cost;bool bo[100001];int iti[100001];
void dfs(int now){
  bo[now]=true;
  for(int i=0;i<com[now].size();i++){
    if(bo[com[now][i]]){
      if(iti[com[now][i]]!=iti[now]+cost[now][i]){
        cout<<"No"<<endl;
        exit(0);
      }
    }
    else{
      iti[com[now][i]]=iti[now]+cost[now][i];
      dfs(com[now][i]);
    }
  }
}
  
  
int main(){
  int n,m;cin>>n>>m;
  int l[m],r[m],d[m];
  for(int i=0;i<m;i++){
    cin>>l[i]>>r[i]>>d[i];
    com[l[i]].push_back(r[i]);
    com[r[i]].push_back(l[i]);
    cost[l[i]].push_back(d[i]);
    cost[r[i]].push_back(-d[i]);
  }
  for(int i=0;i<n;i++){
    if(bo[i])continue;
    iti[i]=0;
    dfs(i);
  }
  cout<<"Yes"<<endl;
}

  

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:6:26: error: request for member 'size' in 'com.std::vector<int>::operator[](((std::vector<int>::size_type)now))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
    6 |   for(int i=0;i<com[now].size();i++){
      |                          ^~~~
a.cc:7:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    7 |     if(bo[com[now][i]]){
      |                   ^
a.cc:8:22: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    8 |       if(iti[com[now][i]]!=iti[now]+cost[now][i]){
      |                      ^
a.cc:8:46: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
    8 |       if(iti[com[now][i]]!=iti[now]+cost[now][i]){
      |                                              ^
a.cc:14:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   14 |       iti[com[now][i]]=iti[now]+cost[now][i];
      |                   ^
a.cc:14:42: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   14 |       iti[com[now][i]]=iti[now]+cost[now][i];
      |                                          ^
a.cc:15:19: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   15 |       dfs(com[now][i]);
      |                   ^
a.cc: In function 'int main()':
a.cc:26:15: error: request for member 'push_back' in 'com.std::vector<int>::operator[](((std::vector<int>::size_type)l[i]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   26 |     com[l[i]].push_back(r[i]);
      |               ^~~~~~~~~
a.cc:27:15: error: request for member 'push_back' in 'com.std::vector<int>::operator[](((std::vector<int>::size_type)r[i]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   27 |     com[r[i]].push_back(l[i]);
      |               ^~~~~~~~~
a.cc:28:16: error: request for member 'push_back' in 'cost.std::vector<int>::operator[](((std::vector<int>::size_type)l[i]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   28 |     cost[l[i]].push_back(d[i]);
      |                ^~~~~~~~~
a.cc:29:16: error: request for member 'push_back' in 'cost.std::vector<int>::operator[](((std::vector<int>::size_type)r[i]))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   29 |     cost[r[i]].push_back(-d[i]);
      |                ^~~~~~~~~