Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

struct data{int a, b, c, d;};
int n, m, q;

int dfs(int v, int id, vint &x, vector<data> &Q) {
    if (id == n) {
        int sum = 0;
        rep(i,q) {
            if (x[Q[i].b]-x[Q[i].a] == Q[i].c) sum += Q[i].d;
        }
        return sum;
    }
    int res = 0;
    x[id] = v;
    for (int i = v; i <= m; i++) {
        res = max(dfs(i,id+1,x,Q),res);
    }
    return res;
}

int main() {
    cin >> n >> m >> q;
    vector<data> Q(q);
    vint x(n);
    rep(i,q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        Q[i] = data{a,b,c,d};
    }
    int ans = 0;
    for (int i = 1; i <= m; i++) {
        ans = max(dfs(i,0,x,Q),ans);
    }
    cout << ans << endl;
}

Compiler output:
a.cc:23:44: error: template argument 1 is invalid
   23 | int dfs(int v, int id, vint &x, vector<data> &Q) {
      |                                            ^
a.cc:23:44: error: template argument 2 is invalid
a.cc:23:44: error: template argument 1 is invalid
a.cc:23:44: error: template argument 2 is invalid
a.cc:23:44: error: template argument 1 is invalid
a.cc:23:44: error: template argument 2 is invalid
a.cc:23:33: error: invalid template-id
   23 | int dfs(int v, int id, vint &x, vector<data> &Q) {
      |                                 ^~~~~~
a.cc:23:40: error: reference to 'data' is ambiguous
   23 | int dfs(int v, int id, vint &x, vector<data> &Q) {
      |                                        ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:20:8: note:                 'struct data'
   20 | struct data{int a, b, c, d;};
      |        ^~~~
a.cc:23:33: error: missing template argument list after 'std::vector'; template placeholder not permitted in parameter
   23 | int dfs(int v, int id, vint &x, vector<data> &Q) {
      |                                 ^~~~~~
      |                                       <>
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'template<class _Tp, class _Alloc> class std::vector' declared here
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc: In function 'int dfs(...)':
a.cc:27:19: error: 'Q' was not declared in this scope
   27 |             if (x[Q[i].b]-x[Q[i].a] == Q[i].c) sum += Q[i].d;
      |                   ^
a.cc:34:32: error: 'Q' was not declared in this scope
   34 |         res = max(dfs(i,id+1,x,Q),res);
      |                                ^
a.cc: In function 'int main()':
a.cc:41:16: error: template argument 1 is invalid
   41 |     vector<data> Q(q);
      |                ^
a.cc:41:16: error: template argument 2 is invalid
a.cc:47:10: error: invalid types 'int[int]' for array subscript
   47 |         Q[i] = data{a,b,c,d};
      |          ^
a.cc:47:16: error: reference to 'data' is ambiguous
   47 |         Q[i] = data{a,b,c,d};
      |                ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:20:8: note:                 'struct data'
   20 | struct data{int a, b, c, d;};
      |        ^~~~