Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

#define DEBUG(x) cerr << #x << " = " << x << endl

typedef double D;
const D EPS = 1e-8;

struct P {
    D x, y;
    P(D x_, D y_) : x(x_), y(y_) { }
    P() {}
};

inline P operator -(const P& a, const P& b) { return P(a.x - b.x, a.y - b.y); }
inline D inp(const P& a, const P' b) { return a.x*b.x + a.y*b.y; }
inline D norm(const P& p) { return inp(p, p); }
inline D abs(const P& p) { return sqrt(norm(p)); }

struct C {
    P p; D r;
    C(P p_, D r_) : p(p_), r(r_) { }
    C() { }
};

inline bool iCC(const C& a, const C& b) {
    D d = abs(a.p - b.p);
    return (a.r + b.r)  - EPS > d;
}

int bit_count(unsigned int b) {
    return __builtin_popcount(b);
}

int bit_right(unsigned int b) {
    return __builtin_ctz(b);
}

int bit_left(unsigned int b) {
    return 31 - __builtin_clz(b);
}

int N;
vector<int> color;
vector<C> circle;
vector<char> ok;
int num;
int ans;


void solve() {
    vector<vector<int> > v(4, vector<int>());
    for(int i = 0; i < N; i++) {
        if(ok[i]) {
            bool fr = true;
            for(int j = i + 1; j < N; j++) {
                if(ok[j]) {
                    if(iCC(circle[i], circle[j])) {
                        fr = false;
                        break;
                    }
                }
            }
            if(fr) {
                v[color[i]].push_back(i);
            }
        }
    }
#if 0
    for(int i = 0; i < 4; i++) {
        cerr << "color " << i << ": ";
        for(int j = 0; j < (int)v[i].size(); j++) {
            cerr << v[i][j] << " ";
        }
        cerr << endl;
    }
#endif
    for(int i = 0; i < 4; i++) {
        if(v[i].size() >= 2) {
            for(int b = 0; b < (1 << v[i].size()); b++) {
                if(bit_count(b) == 2) {
                    int n = v[i][bit_right(b)];
                    int m = v[i][bit_left(b)];
                    ok[n] = 0;
                    ok[m] = 0;
                    num -= 2;
                    ans = max(ans, N - num);
                    solve();
                    ok[n] = 1;
                    ok[m] = 1;
                    num += 2;
                }
            }
        }
    }
}

int main() {
    for(; cin >> N, N; ) {
        color = vector<int>(N);
        circle = vector<C>(N);
        ok = vector<char>(N, 1);
        num = N;
        ans = 0;
        for(int i = 0; i < N; i++) {
            cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
            color[i]--;
        }
        reverse(circle.begin(), circle.end());
        reverse(color.begin(), color.end());
        solve();
        cout << ans << endl;
    }
}

Compiler output:
a.cc:19:33: warning: missing terminating ' character
   19 | inline D inp(const P& a, const P' b) { return a.x*b.x + a.y*b.y; }
      |                                 ^
a.cc:19:33: error: missing terminating ' character
   19 | inline D inp(const P& a, const P' b) { return a.x*b.x + a.y*b.y; }
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:20:1: error: 'D' declared as an 'inline' parameter
   20 | inline D norm(const P& p) { return inp(p, p); }
      | ^~~~~~
a.cc:20:10: error: expected ',' or '...' before 'norm'
   20 | inline D norm(const P& p) { return inp(p, p); }
      |          ^~~~
a.cc:27:2: error: expected ')' before ';' token
   27 | };
      |  ^
      |  )
a.cc:19:13: note: to match this '('
   19 | inline D inp(const P& a, const P' b) { return a.x*b.x + a.y*b.y; }
      |             ^
a.cc:29:23: error: 'C' does not name a type
   29 | inline bool iCC(const C& a, const C& b) {
      |                       ^
a.cc:29:35: error: 'C' does not name a type
   29 | inline bool iCC(const C& a, const C& b) {
      |                                   ^
a.cc: In function 'bool iCC(const int&, const int&)':
a.cc:30:17: error: request for member 'p' in 'a', which is of non-class type 'const int'
   30 |     D d = abs(a.p - b.p);
      |                 ^
a.cc:30:23: error: request for member 'p' in 'b', which is of non-class type 'const int'
   30 |     D d = abs(a.p - b.p);
      |                       ^
a.cc:31:15: error: request for member 'r' in 'a', which is of non-class type 'const int'
   31 |     return (a.r + b.r)  - EPS > d;
      |               ^
a.cc:31:21: error: request for member 'r' in 'b', which is of non-class type 'const int'
   31 |     return (a.r + b.r)  - EPS > d;
      |                     ^
a.cc: At global scope:
a.cc:48:8: error: 'C' was not declared in this scope
   48 | vector<C> circle;
      |        ^
a.cc:48:9: error: template argument 1 is invalid
   48 | vector<C> circle;
      |         ^
a.cc:48:9: error: template argument 2 is invalid
a.cc: In function 'void solve()':
a.cc:61:34: error: invalid types 'int[int]' for array subscript
   61 |                     if(iCC(circle[i], circle[j])) {
      |                                  ^
a.cc:61:45: error: invalid types 'int[int]' for array subscript
   61 |                     if(iCC(circle[i], circle[j])) {
      |                                             ^
a.cc: In function 'int main()':
a.cc:104:25: error: 'C' was not declared in this scope
  104 |         circle = vector<C>(N);
      |                         ^
a.cc:104:26: error: template argument 1 is invalid
  104 |         circle = vector<C>(N);
      |                          ^
a.cc:104:26: error: template argument 2 is invalid
a.cc:109:26: error: invalid types 'int[int]' for array subscript
  109 |             cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
      |                          ^
a.cc:109:43: error: invalid types 'int[int]' for array subscript
  109 |             cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
      |                                           ^
a.cc:109:60: error: invalid types 'int[int]' for array subscript
  109 |             cin >> circle[i].p.x >> circle[i].p.y >> circle[i].r >> color[i];
      |                                                            ^
a.cc:112:24: error: request for member 'begin' in 'circle', which is of non-class type 'int'
  112 |         reverse(circle.begin(), circle.end());
      |                        ^~~~~
a.cc:112:40: error: request for member 'end' in 'circle', which is of non-class type 'int'
  112 |         reverse(circle.begin(), circle.end());
      |                                        ^~~