Language: C++

#include <bits/stdc++.h>

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;

using namespace std;

int R, C, N;
int wr[100001], wc[100001];

struct E{
    int to, cost;
    E(int t, int c): to(t), cost(c) {};
};
vector<E> edge_r[100001], edge_c[100001];
int rmin, cmin;

bool dfs(int v) {
    if(v < R) {
        rmin = min(rmin, wr[v]);
        REP(i, edge_r[v].size()) {
            E e = edge_r[v][i];
            if(wc[e.to] != -1) {
                if(wr[v]+wc[e.to]!=e.cost) return false;
            } else {
                wc[e.to] = e.cost - wr[v];
                if(!dfs(e.to+R)) return false;
            }
        }
    }
    else {
        v -= R;
        cmin = min(cmin, wc[v]);
        REP(i, edge_c[v].size()) {
            E e = edge_c[v][i];
            if(wr[e.to] != -1) {
                if(wc[v]+wr[e.to]!=e.cost) return false;
            } else {
                wr[e.to] = e.cost - wc[v];
                if(!dfs(e.to)) return false;
            }
        }
    }
    return true;
}

int main(void) {
    int tr, tc, ta;
    cin >> R >> C >> N;

    REP(i, R) wr[i] = -1;
    REP(i, C) wc[i] = -1;

    REP(i, N) {
        cin >> tr >> tc >> ta;
        tr--; tc--;
        edge_r[tr].push_back(E(tc, ta));
        edge_c[tc].push_back(E(tr, ta));
    }

    REP(i, R) {
        if(wr[i] != -1 || edge_r[i].size() == 0) continue;
        wr[i] = 0;
        rmin = numeric_limits<int>::max();
        cmin = numeric_limits<int>::max();
        if(!dfs(i) || rmin+cmin < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}#include <bits/stdc++.h>

#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
typedef long long int ll;

using namespace std;

int R, C, N;
int wr[100001], wc[100001];

struct E{
    int to, cost;
    E(int t, int c): to(t), cost(c) {};
};
vector<E> edge_r[100001], edge_c[100001];
int rmin, cmin;

bool dfs(int v) {
    if(v < R) {
        rmin = min(rmin, wr[v]);
        REP(i, edge_r[v].size()) {
            E e = edge_r[v][i];
            if(wc[e.to] != -1) {
                if(wr[v]+wc[e.to]!=e.cost) return false;
            } else {
                wc[e.to] = e.cost - wr[v];
                if(!dfs(e.to+R)) return false;
            }
        }
    }
    else {
        v -= R;
        cmin = min(cmin, wc[v]);
        REP(i, edge_c[v].size()) {
            E e = edge_c[v][i];
            if(wr[e.to] != -1) {
                if(wc[v]+wr[e.to]!=e.cost) return false;
            } else {
                wr[e.to] = e.cost - wc[v];
                if(!dfs(e.to)) return false;
            }
        }
    }
    return true;
}

int main(void) {
    int tr, tc, ta;
    cin >> R >> C >> N;

    REP(i, R) wr[i] = -1;
    REP(i, C) wc[i] = -1;

    REP(i, N) {
        cin >> tr >> tc >> ta;
        tr--; tc--;
        edge_r[tr].push_back(E(tc, ta));
        edge_c[tc].push_back(E(tr, ta));
    }

    REP(i, R) {
        if(wr[i] != -1 || edge_r[i].size() == 0) continue;
        wr[i] = 0;
        rmin = numeric_limits<int>::max();
        cmin = numeric_limits<int>::max();
        if(!dfs(i) || rmin+cmin < 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Compiler output:
a.cc:73:2: error: stray '#' in program
   73 | }#include <bits/stdc++.h>
      |  ^
a.cc:73:3: error: 'include' does not name a type
   73 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:81:5: error: redefinition of 'int R'
   81 | int R, C, N;
      |     ^
a.cc:9:5: note: 'int R' previously declared here
    9 | int R, C, N;
      |     ^
a.cc:81:8: error: redefinition of 'int C'
   81 | int R, C, N;
      |        ^
a.cc:9:8: note: 'int C' previously declared here
    9 | int R, C, N;
      |        ^
a.cc:81:11: error: redefinition of 'int N'
   81 | int R, C, N;
      |           ^
a.cc:9:11: note: 'int N' previously declared here
    9 | int R, C, N;
      |           ^
a.cc:82:5: error: redefinition of 'int wr [100001]'
   82 | int wr[100001], wc[100001];
      |     ^~
a.cc:10:5: note: 'int wr [100001]' previously declared here
   10 | int wr[100001], wc[100001];
      |     ^~
a.cc:82:17: error: redefinition of 'int wc [100001]'
   82 | int wr[100001], wc[100001];
      |                 ^~
a.cc:10:17: note: 'int wc [100001]' previously declared here
   10 | int wr[100001], wc[100001];
      |                 ^~
a.cc:84:8: error: redefinition of 'struct E'
   84 | struct E{
      |        ^
a.cc:12:8: note: previous definition of 'struct E'
   12 | struct E{
      |        ^
a.cc:88:11: error: redefinition of 'std::vector<E> edge_r [100001]'
   88 | vector<E> edge_r[100001], edge_c[100001];
      |           ^~~~~~
a.cc:16:11: note: 'std::vector<E> edge_r [100001]' previously declared here
   16 | vector<E> edge_r[100001], edge_c[100001];
      |           ^~~~~~
a.cc:88:27: error: redefinition of 'std::vector<E> edge_c [100001]'
   88 | vector<E> edge_r[100001], edge_c[100001];
      |                           ^~~~~~
a.cc:16:27: note: 'std::vector<E> edge_c [100001]' previously declared here
   16 | vector<E> edge_r[100001], edge_c[100001];
      |                           ^~~~~~
a.cc:89:5: error: redefinition of 'int rmin'
   89 | int rmin, cmin;
      |     ^~~~
a.cc:17:5: note: 'int rmin' previously declared here
   17 | int rmin, cmin;
      |     ^~~~
a.cc:89:11: error: redefinition of 'int cmin'
   89 | int rmin, cmin;
      |           ^~~~
a.cc:17:11: note: 'int cmin' previously declared here
   17 | int rmin, cmin;
      |           ^~~~
a.cc:91:6: error: redefinition of 'bool dfs(int)'
   91 | bool dfs(int v) {
      |      ^~~
a.cc:19:6: note: 'bool dfs(int)' previously defined here
   19 | bool dfs(int v) {
      |      ^~~
a.cc:120:5: error: redefinition of 'int main()'
  120 | int main(void) {
      |     ^~~~
a.cc:48:5: note: 'int main()' previously defined here
   48 | int main(void) {
      |     ^~~~