Language: C++

#include <bits/stdc++.h>
using namespace std;

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;


struct hoge
{
    int a;
    int b;
    int diff;
    int score;
};
vector<hoge> data;
int dfs(int n, int m,int before,int index, vector<int> vc)
{
    // for(auto i : vc)cout << i;
    // cout << endl;
    if(n==0)
    {
        int sum = 0;
        for(auto i:data)
        {
            if(vc[i.b]-vc[i.a]==i.diff)
            {
                sum += i.score;
            }
        }
        return sum;
    }
    int ans = 0;
    for (int i = before; i <= m; i++)
    {
        vc[index] = i;
        ans = max(ans, dfs(n-1,m,i,index+1,vc));
    }
    return ans;
}



int main()
{
    int n,m,q;
    cin >> n >> m >> q;
    
    rep(i,q)
    {
        int a,b,c,d;
        cin >> a >> b >> c >> d;
        --a;--b;
        hoge temp;
        temp.a = a;temp.b = b;temp.diff = c;temp.score = d;
        data.push_back(temp);
    }
    vector<int> vc(n);
    cout << dfs(n,m,1,0,vc) << endl;
   
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, int, std::vector<int>)':
a.cc:33:20: error: reference to 'data' is ambiguous
   33 |         for(auto i:data)
      |                    ^~~~
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:25:14: note:                 'std::vector<hoge> data'
   25 | vector<hoge> data;
      |              ^~~~
a.cc: In function 'int main()':
a.cc:65:9: error: reference to 'data' is ambiguous
   65 |         data.push_back(temp);
      |         ^~~~
/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:25:14: note:                 'std::vector<hoge> data'
   25 | vector<hoge> data;
      |              ^~~~