Language: C++

ll score(vector<ll> const& ans, vector<array<ll, 4>> const& ab) {
    ll s = 0;
    rep(i, ab.size()) {
        if (ans[ab[i][1]] - ans[ab[i][0]] == ab[i][2])
            s += ab[i][3];
    }

    return s;
}

void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
    if (i == ans.size()) {
        m = max(m, score(ans, ab));
        return;
    }

    rep2(j, 1, M + 1) {
        ans[i] = j;
        dfs(ans, i + 1, M, m, ab);
    }
}

int main(void) {
    ll N, M, Q;
    cin >> N >> M >> Q;

    vector<array<ll, 4>> ab(Q);
    rep(i, Q) {
        rep(j, 4) cin >> ab[i][j];
        ab[i][0]--;
        ab[i][1]--;
    }

    ll m = 0;
    vector<ll> ans(N);
    ans[0] = 1;
    dfs(ans, 1, M, m, ab);

    cout << m << endl;

    return 0;
}


Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll score(vector<ll> const& ans, vector<array<ll, 4>> const& ab) {
      | ^~
a.cc:11:6: error: variable or field 'dfs' declared void
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |      ^~~
a.cc:11:10: error: 'vector' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |          ^~~~~~
a.cc:11:17: error: 'll' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                 ^~
a.cc:11:22: error: 'ans' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                      ^~~
a.cc:11:27: error: 'll' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                           ^~
a.cc:11:33: error: 'll' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                 ^~
a.cc:11:39: error: 'll' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                       ^~
a.cc:11:43: error: 'm' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                           ^
a.cc:11:46: error: 'vector' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                              ^~~~~~
a.cc:11:53: error: 'array' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                                     ^~~~~
a.cc:11:59: error: 'll' was not declared in this scope
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                                           ^~
a.cc:11:67: error: expected primary-expression before 'const'
   11 | void dfs(vector<ll>& ans, ll i, ll M, ll& m, vector<array<ll, 4>> const& ab) {
      |                                                                   ^~~~~
a.cc: In function 'int main()':
a.cc:24:5: error: 'll' was not declared in this scope
   24 |     ll N, M, Q;
      |     ^~
a.cc:25:5: error: 'cin' was not declared in this scope
   25 |     cin >> N >> M >> Q;
      |     ^~~
a.cc:25:12: error: 'N' was not declared in this scope
   25 |     cin >> N >> M >> Q;
      |            ^
a.cc:25:17: error: 'M' was not declared in this scope
   25 |     cin >> N >> M >> Q;
      |                 ^
a.cc:25:22: error: 'Q' was not declared in this scope
   25 |     cin >> N >> M >> Q;
      |                      ^
a.cc:27:5: error: 'vector' was not declared in this scope
   27 |     vector<array<ll, 4>> ab(Q);
      |     ^~~~~~
a.cc:27:12: error: 'array' was not declared in this scope
   27 |     vector<array<ll, 4>> ab(Q);
      |            ^~~~~
a.cc:27:26: error: 'ab' was not declared in this scope
   27 |     vector<array<ll, 4>> ab(Q);
      |                          ^~
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     rep(i, Q) {
      |         ^
a.cc:28:5: error: 'rep' was not declared in this scope
   28 |     rep(i, Q) {
      |     ^~~
a.cc:34:7: error: expected ';' before 'm'
   34 |     ll m = 0;
      |       ^~
      |       ;
a.cc:35:16: error: 'ans' was not declared in this scope
   35 |     vector<ll> ans(N);
      |                ^~~
a.cc:37:20: error: 'm' was not declared in this scope
   37 |     dfs(ans, 1, M, m, ab);
      |                    ^
a.cc:37:5: error: 'dfs' was not declared in this scope
   37 |     dfs(ans, 1, M, m, ab);
      |     ^~~
a.cc:39:5: error: 'cout' was not declared in this scope
   39 |     cout << m << endl;
      |     ^~~~
a.cc:39:18: error: 'endl' was not declared in this scope
   39 |     cout << m << endl;
      |                  ^~~~