Language: C++

($N,$M) =split(" ",<STDIN>);
for($i=0;$i<$M;$i++) {
	($L,$R,$D)=split(" ",<STDIN>);
	$L--;$R--;
	push @L,$L;
	push @R,$R;
	push @D,$D;
	$C{$L}{$R}=$#D;
	$C{$R}{$L}=$#D;
}

$m=0;
while ($m<$M) {
	$M{$m}=1;
	push @M,$m;
	$L=$L[$m];$R=$R[$m];
	push @K,$L;$K{$L}=1;
	push @K,$R;$K{$R}=1;
	$x{$L} = 0;
	$x{$R} = $D[$m];
	
	while ($#K>=0){
		$i=pop(@K);
		foreach $j ( keys %{$C{$i}} ) {
			$n=$C{$i}{$j};
			next if ($M{$n});
			$M{$n}=1;
			push @M,$n;
			if (!exists($K{$j})) {
				push @K,$j;$K{$j}=1;
			}
		}
	}
	$m++;
	for(;$M{$m}!=0;$m++){}
}

for($i=0;$i<=$#M;$i++){
	$m=$M[$i];$L=$L[$m];$R=$R[$m];
	if ( exists($x{$L}) ) {
		if ( exists($x{$R}) ) {
			if ($x{$R} != $x{$L}+$D[$m]) {
				print "No";
				exit;
			}
		} else {
			$x{$R} = $x{$L}+$D[$m];
		}
	} else {
		$x{$L} = $x{$R}-$D[$m];
	}
}


print "Yes";


Compiler output:
a.cc:5:14: error: stray '@' in program
    5 |         push @L,$L;
      |              ^
a.cc:6:14: error: stray '@' in program
    6 |         push @R,$R;
      |              ^
a.cc:7:14: error: stray '@' in program
    7 |         push @D,$D;
      |              ^
a.cc:8:21: error: stray '#' in program
    8 |         $C{$L}{$R}=$#D;
      |                     ^
a.cc:9:21: error: stray '#' in program
    9 |         $C{$R}{$L}=$#D;
      |                     ^
a.cc:15:14: error: stray '@' in program
   15 |         push @M,$m;
      |              ^
a.cc:17:14: error: stray '@' in program
   17 |         push @K,$L;$K{$L}=1;
      |              ^
a.cc:18:14: error: stray '@' in program
   18 |         push @K,$R;$K{$R}=1;
      |              ^
a.cc:22:17: error: stray '#' in program
   22 |         while ($#K>=0){
      |                 ^
a.cc:23:24: error: stray '@' in program
   23 |                 $i=pop(@K);
      |                        ^
a.cc:28:30: error: stray '@' in program
   28 |                         push @M,$n;
      |                              ^
a.cc:30:38: error: stray '@' in program
   30 |                                 push @K,$j;$K{$j}=1;
      |                                      ^
a.cc:38:15: error: stray '#' in program
   38 | for($i=0;$i<=$#M;$i++){
      |               ^
a.cc:1:4: error: expected ')' before ',' token
    1 | ($N,$M) =split(" ",<STDIN>);
      | ~  ^
      |    )
a.cc:1:7: error: expected constructor, destructor, or type conversion before ')' token
    1 | ($N,$M) =split(" ",<STDIN>);
      |       ^
a.cc:2:1: error: expected unqualified-id before 'for'
    2 | for($i=0;$i<$M;$i++) {
      | ^~~
a.cc:2:10: error: '$i' does not name a type
    2 | for($i=0;$i<$M;$i++) {
      |          ^~
a.cc:2:16: error: '$i' does not name a type
    2 | for($i=0;$i<$M;$i++) {
      |                ^~
a.cc:12:1: error: '$m' does not name a type
   12 | $m=0;
      | ^~
a.cc:13:1: error: expected unqualified-id before 'while'
   13 | while ($m<$M) {
      | ^~~~~
a.cc:38:1: error: expected unqualified-id before 'for'
   38 | for($i=0;$i<=$#M;$i++){
      | ^~~
a.cc:38:10: error: '$i' does not name a type
   38 | for($i=0;$i<=$#M;$i++){
      |          ^~
a.cc:38:18: error: '$i' does not name a type
   38 | for($i=0;$i<=$#M;$i++){
      |                  ^~
a.cc:55:1: error: 'print' does not name a type; did you mean 'int'?
   55 | print "Yes";
      | ^~~~~
      | int