Language: C++

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

int main() {
  int n,m,q;
  cin>>n>>m>>q;
  vector<vector<int>(4)>x(q,vector<int>(4));
  for(int i=0;i<q;i++){
    for(int j=0j<4;j++) cin>>x[i][j];
  }
  int ans=0;
  vector<int>a(10);
  a[0]=1;
  for(int i=1;i<=m;i++){
    a[1]=i;
    for(int j=a[1];j<=m;j++){
      a[2]=j;
      for(int k=a[2];k<=m;k++){
         a[3]=k;
        for(int l=a[3];l<=m;l++){
          a[4]=l;
          for(int o=a[4];o<=m;o++){
            a[5]=o;
            for(int p=a[5];p<=m;p++){
              a[6]=p;
              for(int r=a[6];r<=m;r++){
                a[7]=r;
                for(int s=a[7];s<=m;s++){
                  a[8]=s;
                  for(int t=a[8];t<=m;t++){
                    a[9]=t;
                    int answer=0;
                    for(int u=0;u<q;u++){
                      if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
                    }
                    ans=max(ans,answer);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:10: error: temporary of non-literal type 'std::vector<int>' in a constant expression
    7 |   vector<vector<int>(4)>x(q,vector<int>(4));
      |          ^~~~~~~~~~~~~~
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:428:11: note: 'std::vector<int>' is not literal because:
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector<int>' has a non-trivial destructor
a.cc:7:24: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
    7 |   vector<vector<int>(4)>x(q,vector<int>(4));
      |                        ^
a.cc:7:24: note:   expected a type, got 'std::vector<int>(4, std::allocator<int>())'
a.cc:7:24: error: template argument 2 is invalid
a.cc:7:43: error: expression list treated as compound expression in initializer [-fpermissive]
    7 |   vector<vector<int>(4)>x(q,vector<int>(4));
      |                                           ^
a.cc:7:29: error: cannot convert 'std::vector<int>' to 'int' in initialization
    7 |   vector<vector<int>(4)>x(q,vector<int>(4));
      |                             ^~~~~~~~~~~~~~
      |                             |
      |                             std::vector<int>
a.cc:9:17: error: invalid operands of types '__complex__ int' and 'int' to binary 'operator<'
    9 |     for(int j=0j<4;j++) cin>>x[i][j];
      |               ~~^~
      |               |  |
      |               |  int
      |               __complex__ int
a.cc:9:23: error: expected ';' before ')' token
    9 |     for(int j=0j<4;j++) cin>>x[i][j];
      |                       ^
      |                       ;
a.cc:9:31: error: invalid types 'int[int]' for array subscript
    9 |     for(int j=0j<4;j++) cin>>x[i][j];
      |                               ^
a.cc:34:29: error: invalid types 'int[int]' for array subscript
   34 |                       if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
      |                             ^
a.cc:34:42: error: invalid types 'int[int]' for array subscript
   34 |                       if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
      |                                          ^
a.cc:34:54: error: invalid types 'int[int]' for array subscript
   34 |                       if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
      |                                                      ^
a.cc:34:71: error: invalid types 'int[int]' for array subscript
   34 |                       if(a[x[u][1]-1]-a[x[u][0]-1]==x[u][2]) answer+=x[u][3];
      |                                                                       ^