Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<utility>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll n, m, q;
ll ans = 0;
vll a, b, c, d;
 
void dfs(vll A) {//再起全探索
  if (A.size() == n+1) {
    ll now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }

  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
  A.push_back(A.back());//一番後ろに最後尾と同じ値をつける
}


int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    a = b = c = d = vector<int>(q);
    REP(i,q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vector<int>(1,1));
    cout << ans <<"\n";
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(vll)':
a.cc:30:9: error: 'i' was not declared in this scope
   30 |     rep(i,q) {
      |         ^
a.cc:30:5: error: 'rep' was not declared in this scope; did you mean 'frexp'?
   30 |     rep(i,q) {
      |     ^~~
      |     frexp
a.cc: In function 'int main()':
a.cc:50:34: error: no match for 'operator=' (operand types are 'vll' {aka 'std::vector<long long int>'} and 'std::vector<int>')
   50 |     a = b = c = d = vector<int>(q);
      |                                  ^
In file included from /usr/include/c++/14/vector:72,
                 from a.cc:2:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:54:9: error: could not convert 'std::vector<int>(1, 1, std::allocator<int>())' from 'vector<int>' to 'vector<long long int>'
   54 |     dfs(vector<int>(1,1));
      |         ^~~~~~~~~~~~~~~~
      |         |
      |         vector<int>