Language: C++

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include<memory>

using namespace std;

int main() {
	int N, M;
	cin >> N;
	cin >> M;

	//人の位置に関する情報が存在しない場合
	if (N <= 0 || M <= 0) {
		cout << "Yes";
		return 0;
	}

	struct Record {
		int L;
		int R;
		int D;
	};

	vector<Record> recordList(M);

	for (int i = 0; i < M; i++) {
		Record record;
		cin >> record.L;
		cin >> record.R;
		cin >> record.D;
		recordList[i] = record;
	}

	//レコードの大小関係を一意に修正　L>Rとする
	for (auto& record : recordList) {
		if (record.L > record.R) {
			auto temp = record.L;
			record.L = record.R;
			record.R = temp;
			record.D = -record.D;
		}
	}

	//record.Lで昇順となるようにソート
	sort(recordList.begin(), recordList.end(), [](const auto& a, const auto& b) {
		return a.L < b.L;
	});

	//for (auto record : recordList) {
	//	cout << record.L << " " << record.R << " " << record.D << endl;
	//}

	//unordered_map<int, unordered_map<int, int>> numberLine;
	//int humanList[1000000000] = { -1 };
	//unique_ptr<int[]> humanList(new int[10000000000]);
	unordered_map<int, int> humanList;

	vector<Record> afterRecordList;
	
	//数直線上に配置
	auto MakeHumanList = [/*&numberLine,*/ &humanList, &afterRecordList](const auto& recordList) 
	{
		auto front = recordList.front();
		humanList[front.L] = 0;

		if (humanList.count(front.R) != 0 && humanList[front.R] != front.D) {
			return false;
		}

		humanList[front.R] = front.D;

		for (const auto& record : recordList) {
			int pos = -1;

			if (humanList.count(record.L) == 0 && humanList.count(record.R) == 0) {
				afterRecordList.emplace_back(record);
				continue;
			}
			else if (humanList.count(record.L) != 0) {
				pos = humanList[record.L];
			}
			else if (humanList.count(record.L) == 0 && humanList.count(record.R) != 0) {
				pos = humanList[record.R] - record.D;
			}

			humanList[record.L] = pos;

			if (humanList.count(record.R) != 0 && humanList[record.R] != pos + record.D) {
				return false;
			}

			humanList[record.R] = pos + record.D;
		}

		//後回しにしたやつ
		//for (const auto& record : afterRecordList) {
		//	cout << record.L << " " << record.R << " " << record.D << endl;
		//}

		return true;
	};

	if (!MakeHumanList(recordList)) {
		cout << "No";
		return 0;
	}

	while (afterRecordList.size() != 0) {
		recordList = afterRecordList;
		afterRecordList.clear();

		if (!MakeHumanList(recordList)) {
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'cin' was not declared in this scope
   18 |         cin >> N;
      |         ^~~
a.cc:13:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
   12 | #include<memory>
  +++ |+#include <iostream>
   13 | 
a.cc:23:17: error: 'cout' was not declared in this scope
   23 |                 cout << "Yes";
      |                 ^~~~
a.cc:23:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:33:9: error: 'vector' was not declared in this scope
   33 |         vector<Record> recordList(M);
      |         ^~~~~~
a.cc:13:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
   12 | #include<memory>
  +++ |+#include <vector>
   13 | 
a.cc:33:22: error: expected primary-expression before '>' token
   33 |         vector<Record> recordList(M);
      |                      ^
a.cc:33:24: error: 'recordList' was not declared in this scope
   33 |         vector<Record> recordList(M);
      |                        ^~~~~~~~~~
a.cc:54:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   54 |         sort(recordList.begin(), recordList.end(), [](const auto& a, const auto& b) {
      |         ^~~~
      |         sqrt
a.cc:67:22: error: expected primary-expression before '>' token
   67 |         vector<Record> afterRecordList;
      |                      ^
a.cc:67:24: error: 'afterRecordList' was not declared in this scope
   67 |         vector<Record> afterRecordList;
      |                        ^~~~~~~~~~~~~~~
a.cc: In lambda function:
a.cc:85:33: error: 'afterRecordList' is not captured
   85 |                                 afterRecordList.emplace_back(record);
      |                                 ^~~~~~~~~~~~~~~
a.cc:70:76: note: the lambda has no capture-default
   70 |         auto MakeHumanList = [/*&numberLine,*/ &humanList, &afterRecordList](const auto& recordList)
      |                                                                            ^
a.cc:67:24: note: '<typeprefixerror>afterRecordList' declared here
   67 |         vector<Record> afterRecordList;
      |                        ^~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:113:17: error: 'cout' was not declared in this scope
  113 |                 cout << "No";
      |                 ^~~~
a.cc:113:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:122:25: error: 'cout' was not declared in this scope
  122 |                         cout << "No";
      |                         ^~~~
a.cc:122:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:127:9: error: 'cout' was not declared in this scope
  127 |         cout << "Yes";
      |         ^~~~
a.cc:127:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'