Language: C++

#include <bits/stdc++.h>
using namespace std;
ll n,m,l,r,d;
std::vector<pair<ll,ll>> adj[200007];
set<ll> seen;
ll parr[200007];
ll size[200007];
ll dis[200007];
ll vis[200007];
ll vist[200007];

ll find(ll u) {
  if (parr[u] == u) return u;
  return parr[u] = find(parr[u]);
}
void init(ll n) {
  for(ll i = 1; i<=n; i++){
    parr[i] = i;
    size[i] = 1;
  }
}
void unify(ll a, ll b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    if (size[b] > size[a])
      swap(a, b);
    parr[b] = a;
    size[a] += size[b];
  }
}

void reset(){
  for(ll e : seen) dis[e] = vis[e] = vist[e] = 0;
  seen.clear();
}

void dfs(ll cur, ll d){
  seen.insert(cur);
  vis[cur] = 1;
  dis[cur] = d;
  for(auto e : adj[cur]){
    if(!vis[e.first]) dfs(e.first, d+e.second);
  }
}

ll check(ll cur){
  vis[cur] = 1;
  ll res=  1;
  for(auto e : adj[cur]){
    ll v = e.first;
    ll duv = e.second;
    if((dis[v]-dis[cur])!=duv) {
      // printf("  ambigues (dis[%d]-dis[%d]=%d) and duv=%d\n", cur, v, dis[cur]-dis[v], duv);
      return 0;
    }
    if(!vis[e.first]) res&=check(v);
  }
  return 1;
}
int main(){
  std::cin >> n >> m;
  init(n);
  for(ll i = 0; i<m; i++){
    std::cin >> l >> r >> d;
    unify(l, r);
    adj[l].push_back({r, d});
    adj[r].push_back({l, -d});
  }
  set<ll> cc;
  for(ll i = 1; i<=n; i++) cc.insert(find(i));
  for(ll e : cc){
    // printf("processing cc %d\n", e);
    reset();
    dfs(e, 0);
    // for(ll i = 1; i<=n; i++){
    //   printf("  dis[%d] = %d\n", i, dis[i]);
    // }
    if(!check(e)) return 0*printf("No\n");
  }
  return 0*printf("Yes\n");
}


Compiler output:
a.cc:3:1: error: 'll' does not name a type
    3 | ll n,m,l,r,d;
      | ^~
a.cc:4:18: error: 'll' was not declared in this scope
    4 | std::vector<pair<ll,ll>> adj[200007];
      |                  ^~
a.cc:4:21: error: 'll' was not declared in this scope
    4 | std::vector<pair<ll,ll>> adj[200007];
      |                     ^~
a.cc:4:21: error: template argument 1 is invalid
a.cc:4:21: error: template argument 2 is invalid
a.cc:4:23: error: template argument 1 is invalid
    4 | std::vector<pair<ll,ll>> adj[200007];
      |                       ^~
a.cc:4:23: error: template argument 2 is invalid
a.cc:5:5: error: 'll' was not declared in this scope
    5 | set<ll> seen;
      |     ^~
a.cc:5:7: error: template argument 1 is invalid
    5 | set<ll> seen;
      |       ^
a.cc:5:7: error: template argument 2 is invalid
a.cc:5:7: error: template argument 3 is invalid
a.cc:6:1: error: 'll' does not name a type
    6 | ll parr[200007];
      | ^~
a.cc:7:1: error: 'll' does not name a type
    7 | ll size[200007];
      | ^~
a.cc:8:1: error: 'll' does not name a type
    8 | ll dis[200007];
      | ^~
a.cc:9:1: error: 'll' does not name a type
    9 | ll vis[200007];
      | ^~
a.cc:10:1: error: 'll' does not name a type
   10 | ll vist[200007];
      | ^~
a.cc:12:1: error: 'll' does not name a type
   12 | ll find(ll u) {
      | ^~
a.cc:16:6: error: variable or field 'init' declared void
   16 | void init(ll n) {
      |      ^~~~
a.cc:16:11: error: 'll' was not declared in this scope
   16 | void init(ll n) {
      |           ^~
a.cc:22:6: error: variable or field 'unify' declared void
   22 | void unify(ll a, ll b) {
      |      ^~~~~
a.cc:22:12: error: 'll' was not declared in this scope
   22 | void unify(ll a, ll b) {
      |            ^~
a.cc:22:18: error: 'll' was not declared in this scope
   22 | void unify(ll a, ll b) {
      |                  ^~
a.cc: In function 'void reset()':
a.cc:34:7: error: 'll' was not declared in this scope
   34 |   for(ll e : seen) dis[e] = vis[e] = vist[e] = 0;
      |       ^~
a.cc:35:8: error: request for member 'clear' in 'seen', which is of non-class type 'int'
   35 |   seen.clear();
      |        ^~~~~
a.cc:36:1: error: expected primary-expression before '}' token
   36 | }
      | ^
a.cc:35:16: error: expected ')' before '}' token
   35 |   seen.clear();
      |                ^
      |                )
   36 | }
      | ~               
a.cc:34:6: note: to match this '('
   34 |   for(ll e : seen) dis[e] = vis[e] = vist[e] = 0;
      |      ^
a.cc:36:1: error: expected primary-expression before '}' token
   36 | }
      | ^
a.cc: At global scope:
a.cc:38:6: error: variable or field 'dfs' declared void
   38 | void dfs(ll cur, ll d){
      |      ^~~
a.cc:38:10: error: 'll' was not declared in this scope
   38 | void dfs(ll cur, ll d){
      |          ^~
a.cc:38:18: error: 'll' was not declared in this scope
   38 | void dfs(ll cur, ll d){
      |                  ^~
a.cc:47:1: error: 'll' does not name a type
   47 | ll check(ll cur){
      | ^~
a.cc: In function 'int main()':
a.cc:62:15: error: 'n' was not declared in this scope; did you mean 'yn'?
   62 |   std::cin >> n >> m;
      |               ^
      |               yn
a.cc:62:20: error: 'm' was not declared in this scope; did you mean 'tm'?
   62 |   std::cin >> n >> m;
      |                    ^
      |                    tm
a.cc:63:3: error: 'init' was not declared in this scope; did you mean 'int'?
   63 |   init(n);
      |   ^~~~
      |   int
a.cc:64:7: error: 'll' was not declared in this scope
   64 |   for(ll i = 0; i<m; i++){
      |       ^~
a.cc:64:17: error: 'i' was not declared in this scope
   64 |   for(ll i = 0; i<m; i++){
      |                 ^
a.cc:65:17: error: 'l' was not declared in this scope
   65 |     std::cin >> l >> r >> d;
      |                 ^
a.cc:65:22: error: 'r' was not declared in this scope
   65 |     std::cin >> l >> r >> d;
      |                      ^
a.cc:65:27: error: 'd' was not declared in this scope
   65 |     std::cin >> l >> r >> d;
      |                           ^
a.cc:66:5: error: 'unify' was not declared in this scope
   66 |     unify(l, r);
      |     ^~~~~
a.cc:70:7: error: 'll' was not declared in this scope
   70 |   set<ll> cc;
      |       ^~
a.cc:70:9: error: template argument 1 is invalid
   70 |   set<ll> cc;
      |         ^
a.cc:70:9: error: template argument 2 is invalid
a.cc:70:9: error: template argument 3 is invalid
a.cc:71:9: error: expected ';' before 'i'
   71 |   for(ll i = 1; i<=n; i++) cc.insert(find(i));
      |         ^~
      |         ;
a.cc:71:17: error: 'i' was not declared in this scope
   71 |   for(ll i = 1; i<=n; i++) cc.insert(find(i));
      |                 ^
a.cc:71:31: error: request for member 'insert' in 'cc', which is of non-class type 'int'
   71 |   for(ll i = 1; i<=n; i++) cc.insert(find(i));
      |                               ^~~~~~
a.cc:72:9: error: expected ';' before 'e'
   72 |   for(ll e : cc){
      |         ^~
      |         ;
a.cc:81:3: error: expected primary-expression before 'return'
   81 |   return 0*printf("Yes\n");
      |   ^~~~~~
a.cc:80:4: error: expected ';' before 'return'
   80 |   }
      |    ^
      |    ;
   81 |   return 0*printf("Yes\n");
      |   ~~~~~~
a.cc:81:3: error: expected primary-expression before 'return'
   81 |   return 0*printf("Yes\n");
      |   ^~~~~~
a.cc:80:4: error: expected ')' before 'return'
   80 |   }
      |    ^
      |    )
   81 |   return 0*printf("Yes\n");
      |   ~~~~~~
a.cc:72:6: note: to match this '('
   72 |   for(ll e : cc){
      |      ^