Language: C++

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

using namespace std;
typedef long long ll;

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

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

int dfs(vector<int> A){ 
	int i;

/*
	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;
	}
}

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

	int a,b,c,d;
	int i,j;
	int counter=0;
	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:31:28: error: 'begin' was not declared in this scope
   31 |                 for(auto g:given)
      |                            ^~~~~
a.cc:31: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:31:28: error: 'end' was not declared in this scope
   31 |                 for(auto g:given)
      |                            ^~~~~
a.cc:31: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:52:9: error: reference to 'data' is ambiguous
   52 |         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:13:2: note:                 'typedef struct data data'
   13 | }data;
      |  ^~~~
a.cc:57:24: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   57 |                 cin >> tmp.Ai >> tmp.Bi >> tmp.ans >> tmp.point;
      |                        ^~~
      |                        tm
a.cc:58:23: error: request for member 'push_back' in 'given', which is of non-class type 'int'
   58 |                 given.push_back(tmp);
      |                       ^~~~~~~~~
a.cc: In function 'int dfs(std::vector<int>)':
a.cc:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^