Language: C++

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int sqr(int x){
  return x*x;
}

short mem[1<<24];
int ud[24];

int dfs(int b){
  if(mem[b]>=0)return mem[b];
  mem[b]=0;
  for(int i=0;i<4;i++){
    for(int j=0;j<6;j++){
      for(int k=0;k<j;k++){
	int jx=i*6+j;
	int kx=i*6+k;
	if((b>>jx&1)&&(b>>kx&1)&&!(ud[jx]&b)&&!(ud[kx]&b)){
	  mem[b]=max(mem[b],dfs(b&~(1<<jx)&~(1<<kx))+2);
	}
      }
    }
  }
  return mem[b];
}

int main(){
  for(int n;cin>>n,n;){
    int x[24],y[24],r[24],c[24];
    vector<int> u[24];
    vector<int> cs[4];
    for(int i=0;i<n;i++){
      cin>>x[i]>>y[i]>>r[i]>>c[i];
      cs[c[i]-1].push_back(i);
      for(int j=0;j<i;j++){
	if(sqr(x[i]-x[j])+sqr(y[i]-y[j])<sqr(r[i]+r[j])){
	  u[i].push_back(j);
	}
      }
    }
    int m[24];
    int b=0;
    for(int i=0;i<4;i++){
      for(int j=0;j<6;j++){
	if(j<cs[i].size()){
	  b|=1<<i*6+j;
	  m[cs[i][j]]=i*6+j;
	}
      }
    }
    fill(begin(ud),end(ud),0);
    for(int i=0;i<4;i++){
      for(int j=0;j<6;j++){
	if(j<cs[i].size()){
	  for(auto e:u[cs[i][j]]){
	    ud[i*6+j]|=1<<m[e];
	  }
	}
      }
    }
    fill(begin(mem),end(mem),-1);
    cout<<dfs(b)<<endl;
  }
}

Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:23:21: error: no matching function for call to 'max(short int&, int)'
   23 |           mem[b]=max(mem[b],dfs(b&~(1<<jx)&~(1<<kx))+2);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:23:21: note:   deduced conflicting types for parameter 'const _Tp' ('short int' and 'int')
   23 |           mem[b]=max(mem[b],dfs(b&~(1<<jx)&~(1<<kx))+2);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: '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:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:23:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'short int'
   23 |           mem[b]=max(mem[b],dfs(b&~(1<<jx)&~(1<<kx))+2);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~