Language: C++

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

int N, M, Q;
int sum;
vector<int> a, b, c, d;

void pei(vector<int> A){
  if(A.size() == n){
    int sum2 = 0;
    for(int i = 0; i < Q; i++){
      if(A[b] - A[a] == c){
        sum2 += d;
      }
    }
    sum = max(sum, sum2);
    return;
  }
  A.push_back(A.back());
  while(A.back() <= M){
    pei(A);
    A.back++;
  }
}

int main(){
  int N, M Q, i;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  vector<int> A;
  cin >> N >> M >> Q;
  for(i = 0; i < Q; i++){
    cin >> a(i) >> b(i) >> c(i) >> d(i);
  }
  A[0] = 1;
  sum = 0;
  pei(A);
  cout << sum << endl;
}
    


/*
int pei(vector<int> a, vector<int> v, vector<int> c, vector<int> d, int x, int sum){
  

int main(){
  int N, M Q, i;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  cin >> N >> M >> Q;
  for(i = 0; i < Q; i++){
    cin >> a(i) >> b(i) >> c(i) >> d(i);
  }
  
}
*/

Compiler output:
a.cc: In function 'void pei(std::vector<int>)':
a.cc:9:18: error: 'n' was not declared in this scope
    9 |   if(A.size() == n){
      |                  ^
a.cc:12:11: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
   12 |       if(A[b] - A[a] == c){
      |           ^
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,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:12:18: error: no match for 'operator[]' (operand types are 'std::vector<int>' and 'std::vector<int>')
   12 |       if(A[b] - A[a] == c){
      |                  ^
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
 1147 |       operator[](size_type __n) const _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:13:14: error: no match for 'operator+=' (operand types are 'int' and 'std::vector<int>')
   13 |         sum2 += d;
      |         ~~~~~^~~~
a.cc:22:7: error: no post-increment operator for type
   22 |     A.back++;
      |     ~~^~~~
a.cc: In function 'int main()':
a.cc:27:12: error: expected initializer before 'Q'
   27 |   int N, M Q, i;
      |            ^
a.cc:31:7: error: 'i' was not declared in this scope
   31 |   for(i = 0; i < Q; i++){
      |       ^