Language: C++

#include <bits/stdc++.h>
#define SIZE 10
#define PI 3.141592653589793

using namespace std;
typedef long long ll;

struct data{
	int Ai;
	int Bi;
	int ans;
	int point;
};

int N,M,Q;
int answer=0;
vector<int> A;
vector<data> given;

int dfs(vector<int> A){ 
/*
	for(auto itr:A)
		cout << itr << " ";
	cout << endl;
*/

	if(A.size() == N+1){
		int counter=0;
		for(auto g:given)
			if(A[g.Bi] - A[g.Ai] == g.ans) counter+=g.point;

		return counter;
	}

	A.push_back(A.back());
	while(A.back()<=M){
		answer=max(answer,dfs(A));
		A.back()++;
		//cout << "ANS>>>>>>>>>>>>>>>>>>>>>>>>>" << answer << endl;
	}

	return answer;
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int i;
	data tmp;

	cin >> N >> M >> Q;

	for(i=0;i<Q;i++){
		cin >> tmp.Ai >> tmp.Bi >> tmp.ans >> tmp.point;
		given.push_back(tmp);
	}

	A.resize(1,1);
	dfs(A);

	cout << answer << endl;

	return 0;
}



Compiler output:
a.cc:18:12: error: template argument 1 is invalid
   18 | vector<data> given;
      |            ^
a.cc:18:12: error: template argument 2 is invalid
a.cc: In function 'int dfs(std::vector<int>)':
a.cc:29:28: error: 'begin' was not declared in this scope
   29 |                 for(auto g:given)
      |                            ^~~~~
a.cc:29:28: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
                 from a.cc:1:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:29:28: error: 'end' was not declared in this scope
   29 |                 for(auto g:given)
      |                            ^~~~~
a.cc:29:28: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~
a.cc: In function 'int main()':
a.cc:50:9: error: reference to 'data' is ambiguous
   50 |         data tmp;
      |         ^~~~
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:
/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:8:8: note:                 'struct data'
    8 | struct data{
      |        ^~~~
a.cc:55:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   55 |                 cin >> tmp.Ai >> tmp.Bi >> tmp.ans >> tmp.point;
      |                        ^~~
      |                        tm
a.cc:56:23: error: request for member 'push_back' in 'given', which is of non-class type 'int'
   56 |                 given.push_back(tmp);
      |                       ^~~~~~~~~