Language: C++

#include <bits/stdc++.h>

using namespace std;


struct abcd {
  int a, b, c, d;
  abcd() {}
  abcd(int a_, int b_, int c_, int d_): a(a_), b(b_), c(c_), d(d_) {}
};

int ans = 0;

int n, m, q;

vector<abcd> data;

void dfs(vector<int> A) {
  if ((int)A.size() == n) {
    int sum = 0;
    for (int i = 0; i < q; ++i) {
      abcd cur = data[i];
      if (A[cur.b] - A[cur.a] == cur.c) sum += cur.d;
    }
    ans = max(ans, sum);
    return;
  }


  int start = A.size() > 0? A.back(): 1;
  for (int i = start; i <= m; ++i) {
    vector<int> A_ = A;
    A_.push_back(i);
    dfs(A_);
  }
}

int main() {
  cin >> n >> m >> q;

  for (int i = 0; i < q; ++i) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    data.push_back(abcd(a, b, c, d));
  }
  vector<int> tmp;
  dfs(tmp);
  cout << ans << '\n';
  return 0;
}



Compiler output:
a.cc: In function 'void dfs(std::vector<int>)':
a.cc:22:18: error: reference to 'data' is ambiguous
   22 |       abcd cur = data[i];
      |                  ^~~~
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:16:14: note:                 'std::vector<abcd> data'
   16 | vector<abcd> data;
      |              ^~~~
a.cc: In function 'int main()':
a.cc:45:5: error: reference to 'data' is ambiguous
   45 |     data.push_back(abcd(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:16:14: note:                 'std::vector<abcd> data'
   16 | vector<abcd> data;
      |              ^~~~