Language: C++

#include<iostream>
using namespace std;

int* t;
int n,m,q;
int *a,*b,*c,*d;
int max;
void f(int p){
  if(p==n){
    int s=0;
    for(int i=0;i<q;i++){
      if(t[b[i]]-t[a[i]]==c[i])s+=d[i];
    }
    if(t>max){
      max=t;
    }
  }else{
    for(int i=t[p-1];i<=m;i++){
      t[p]=i;
      f(p+1);
    }
  }
}
int main(){
  cin>>n>>m>>q;
  a=new int[q];
  b=new int[q];
  c=new int[q];
  d=new int[q];
  for(int i=0;i<q;i++){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  t=new int[n]{};
  max=-1;
  for(int i=1;i<=m;i++){
    t[0]=i;
    f(1);
  }
  cout << max << endl;
  return 0;
}  


Compiler output:
a.cc: In function 'void f(int)':
a.cc:14:10: error: reference to 'max' is ambiguous
   14 |     if(t>max){
      |          ^~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc:15:7: error: reference to 'max' is ambiguous
   15 |       max=t;
      |       ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc: In function 'int main()':
a.cc:34:3: error: reference to 'max' is ambiguous
   34 |   max=-1;
      |   ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~
a.cc:39:11: error: reference to 'max' is ambiguous
   39 |   cout << max << endl;
      |           ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:7:5: note:                 'int max'
    7 | int max;
      |     ^~~