Language: C++

#include <bits/stdc++.h>
using namespace std;
using LL = long long int;

int vx[4] = {-1, -1, +1, +1};
int vy[4] = {-1, +1, -1, +1};

int main(){
	int R, C, N;
	cin >> R >> C >> N;
	vector<int> r(N), c(N), a(N);
	vector<vector<LL>> state(R+2, vector<LL>(C+2, -1)), cond(R+2, vector<LL>(C+2, -1));
	for(int i = 0; i < N; i++){
		cin >> r[i] >> c[i] >> a[i];
		state[r[i]][c[i]] = a[i];
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 4; j++){
			int x = r[i] + vx[j];
			int y = c[i] + vy[j];
			if(state[x][y] == -1){
				if(state[x][c[i]] != -1 && state[r[i]][y] != -1){
					state[x][y] = state[x][c[i]] + state[r[i]][y] - a[i];
					if(state[x][y] < 0){
						cout << "No" << endl;
						return 0
					}
				}else if(cond[x][y] == -1){
					cond[x][y] = a[i] % 2;
				}else if(cond[x][y] != a[i] % 2){
					cout << "No" << endl;
					return 0
				}
			}else{
				if(state[x][c[i]] != -1 && state[r[i]][y] != -1){
					if(a[i] + state[x][y] != state[x][c[i]] + state[r[i]][y]){
						cout << "No" << endl;
						return 0
					}
				}else if(state[x][c[i]] != -1){
					state[r[i]][y] = a[i] + state[x][y] - state[x][c[i]];
					if(state[r[i]][y] < 0){
						cout << "No" << endl;
						return 0
					}
				}else if(state[r[i]][y] != -1){
					state[x][c[i]] = a[i] + state[x][y] - state[r[i]][y];
					if(state[r[i]][y] < 0){
						cout << "No" << endl;
						return 0
					}
				}
			}
		}
	}
	
	cout << "Yes" << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:57: error: expected ';' before '}' token
   26 |                                                 return 0
      |                                                         ^
      |                                                         ;
   27 |                                         }
      |                                         ~                
a.cc:32:49: error: expected ';' before '}' token
   32 |                                         return 0
      |                                                 ^
      |                                                 ;
   33 |                                 }
      |                                 ~                
a.cc:38:57: error: expected ';' before '}' token
   38 |                                                 return 0
      |                                                         ^
      |                                                         ;
   39 |                                         }
      |                                         ~                
a.cc:44:57: error: expected ';' before '}' token
   44 |                                                 return 0
      |                                                         ^
      |                                                         ;
   45 |                                         }
      |                                         ~                
a.cc:50:57: error: expected ';' before '}' token
   50 |                                                 return 0
      |                                                         ^
      |                                                         ;
   51 |                                         }
      |                                         ~