Language: C++

const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n,m;
    cin >> n >> m;
    ll l[m],r[m],d[m];
    vector<pair<ll, ll> > neighbor[n+1];
    ll place[n+1];
    ll inf = 1LL<<60;
    rep(i,n+1)place[i]=inf;
    rep(i,m)cin >> l[i] >> r[i] >> d[i];
    rep(i,m){
        neighbor[min(l[i],r[i])].push_back(make_pair(max(l[i],r[i]),(l[i]<r[i]) ? d[i] : (d[i]*-1)));
    }
    rep(i,n+1){
        if(place[i]!=inf){
            continue;
        } 
        place[i]=0;
        queue<ll> que;
        que.push(i);
        while(!que.empty()){
            ll cur = que.front();
            DEBUG{cout << "cur " << cur << endl;}
            que.pop();
            for(auto x:neighbor[cur]){
                DEBUG{
                    cout << "p " << place[x.first] << " nxt " << place[cur]+x.second << endl;
                }
                if(place[x.first]!=inf&&place[x.first]!=place[cur]+x.second){
                    cout << "No" << endl;
                    return 0;
                } 
                if(place[x.first]==inf){
                    que.push(x.first);
                    place[x.first]=place[cur]+x.second;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin >> n >> m;
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | const bool debug=false;
a.cc:12:5: error: 'vector' was not declared in this scope
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | const bool debug=false;
a.cc:12:12: error: 'pair' was not declared in this scope
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |            ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | const bool debug=false;
a.cc:12:19: error: expected primary-expression before ',' token
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |                   ^
a.cc:12:23: error: expected primary-expression before '>' token
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |                       ^
a.cc:12:25: error: expected primary-expression before '>' token
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |                         ^
a.cc:12:27: error: 'neighbor' was not declared in this scope
   12 |     vector<pair<ll, ll> > neighbor[n+1];
      |                           ^~~~~~~~
a.cc:15:9: error: 'i' was not declared in this scope
   15 |     rep(i,n+1)place[i]=inf;
      |         ^
a.cc:15:5: error: 'rep' was not declared in this scope
   15 |     rep(i,n+1)place[i]=inf;
      |     ^~~
a.cc:46:5: error: 'cout' was not declared in this scope
   46 |     cout << "Yes" << endl;
      |     ^~~~
a.cc:46:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:46:22: error: 'endl' was not declared in this scope
   46 |     cout << "Yes" << endl;
      |                      ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | const bool debug=false;