Language: C++

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

#define rep(i,n) for(int i=0; i<n; i++)
int check(vector<int>A, int B, int q){
  int score
  rep(i,q){
    if(A[B[i][1]]- A[B[i][0]] >= B[i][2]  )score += B[i][3];
  }
  return score;
  
}

int maxA(int p,int q, int m,vector<int>A, vector<int> maxq,int[][] B,int maxnum ){

    for(int i=A[p-1]; i<= maxq[p-1]; i++){
      A[p]=i;
      
      if(p = m-1){        
        return max(maxnum,check(A,B,q))
      }
      else {
        p++;
        maxnum = maxA(p,m,A,maxq);
      }
    }
    if(p<m-1){
    for(int i=A[p-1]; i<= maxq[p-1]; i++ ){
      A[p]=i;
      p++;
      maxA(p,m,A,maxq);
    }else{
      for(int i=A[p-1]; i<= maxq[p-1]; i++ ){
      A.push_back(i);
      p++;
      maxA(p,m,A,maxq);
    }
  }


}

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

  int A[q][4];
  int maxq[n]={0};
  int maxq[0] = 1;
  rep(i, q){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    A[i]={a-1,b-1,c,d};
    if(A[i][2] > maxq[A[i][1]]) maxq[A[i][1]] = A[i][2];
  }
  for(int i=1; i<n; i++)maxq[i] = min(m, maxq[i] + maxq[i-1]);
  
  
  vector<int> B(9) = {1};
  cout << maxA(1,q,m,B,maxq,A,0) << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int check(std::vector<int>, int, int)':
a.cc:4:18: error: expected initializer before 'for'
    4 | #define rep(i,n) for(int i=0; i<n; i++)
      |                  ^~~
a.cc:7:3: note: in expansion of macro 'rep'
    7 |   rep(i,q){
      |   ^~~
a.cc:7:7: error: 'i' was not declared in this scope
    7 |   rep(i,q){
      |       ^
a.cc:4:31: note: in definition of macro 'rep'
    4 | #define rep(i,n) for(int i=0; i<n; i++)
      |                               ^
a.cc:10:10: error: 'score' was not declared in this scope
   10 |   return score;
      |          ^~~~~
a.cc: At global scope:
a.cc:14:66: error: multidimensional array must have bounds for all dimensions except the first
   14 | int maxA(int p,int q, int m,vector<int>A, vector<int> maxq,int[][] B,int maxnum ){
      |                                                                  ^
a.cc:14:68: error: expected ',' or '...' before 'B'
   14 | int maxA(int p,int q, int m,vector<int>A, vector<int> maxq,int[][] B,int maxnum ){
      |                                                                    ^
a.cc: In function 'int maxA(...)':
a.cc:20:20: error: 'maxnum' was not declared in this scope
   20 |         return max(maxnum,check(A,B,q))
      |                    ^~~~~~
a.cc:20:35: error: 'B' was not declared in this scope
   20 |         return max(maxnum,check(A,B,q))
      |                                   ^
a.cc:20:40: error: expected ';' before '}' token
   20 |         return max(maxnum,check(A,B,q))
      |                                        ^
      |                                        ;
   21 |       }
      |       ~                                 
a.cc:24:9: error: 'maxnum' was not declared in this scope
   24 |         maxnum = maxA(p,m,A,maxq);
      |         ^~~~~~
a.cc:32:6: error: expected '}' before 'else'
   32 |     }else{
      |      ^~~~
a.cc:27:14: note: to match this '{'
   27 |     if(p<m-1){
      |              ^
a.cc: In function 'int main()':
a.cc:49:7: error: conflicting declaration 'int maxq [0]'
   49 |   int maxq[0] = 1;
      |       ^~~~
a.cc:48:7: note: previous declaration as 'int maxq [n]'
   48 |   int maxq[n]={0};
      |       ^~~~
a.cc:53:9: error: assigning to an array from an initializer list
   53 |     A[i]={a-1,b-1,c,d};
      |     ~~~~^~~~~~~~~~~~~~
a.cc:59:20: error: expected ',' or ';' before '=' token
   59 |   vector<int> B(9) = {1};
      |                    ^