Language: C++

/** 幾何ライブラリ **/
#include <complex>

#define X real()
#define Y imag()

const double EPS = 1e-7;
const double PI = acos(-1.0);

typedef double D;
typedef complex<D> P; // Point

struct L { // Line
	P a, b;
	L(){}
	L(P aa, P bb) : a(aa), b(bb){}
};

struct C { // Circle
	P p; D r, m;
	C() {}
	C(P pp, D rr, D mm) : p(pp), r(rr), m(mm){}
};

// 共役複素数 conj(a);

// 符号
int sig(D a, D b=0) {
	if (a < b-EPS) return -1;
	if (a > b+EPS) return 1;
	return 0;
}

// 内積
D dot(P a, P b) { return (conj(a)*b).real(); }

// 外積
D cross(P a, P b) { return (conj(a)*b).imag(); }

// 線分abに対する点cの位置
enum STATE{LEFT=1, RIGHT=-1, BACK=2, FRONT=-2, ON=0, IN=3, OUT=-3};
int ccw(P a, P b, P c)
{
	b -= a, c -= a;
	D s = sig(cross(b, c));
	if (s) return s>0 ? LEFT : RIGHT;
	if (sig(dot(b, c))<0) return BACK;
	if (sig(abs(c), abs(b))>0) return FRONT;
	return ON;
}

// 直線lに対する点pの写像
P projection(L l, P p)
{
	return l.a + (l.b-l.a)/abs(l.b-l.a) * dot(l.b-l.a, p-l.a)/abs(l.b-l.a);
}

// 直線lに対する点pの反射
P reflection(L l, P p)
{
	return p + (projection(l, p)-p)*P(2, 0);
}

// 直線abと点cの距離
D dLP(L l, P c)
{
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分abと点cの距離
D dSP(L l, P c)
{
	if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
	if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
	return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
}

// 線分と線分の交差判定
bool iSS(L s, L t)
{
	return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
	&& (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
}

// 線分と線分の距離
D dSS(L s, L t)
{
	if (iSS(s, t)) return 0;
	return min(min(dSP(t, s.a), dSP(t, s.b)), min(dSP(s, t.a), dSP(s, t.b)));
}

// 線分と線分の交点 (公差していることが前提)
P cSS(L s, L t)
{
	D d1 = dLP(t, s.a);
	D d2 = dLP(t, s.b);
	D tmp = d1 / (d1 + d2);
	return s.a + (s.b-s.a)*tmp;
}

// 直線と直線の交差判定
bool iLL(L s, L t)
{
	return sig(cross(s.b-s.a, t.b-t.a))!=0;
}

// 直線と直線の交点 iLLを確認してから使用
P cLL(L s, L t)
{
	P ss = s.b - s.a, tt = t.b - t.a;
	return s.a + ss*cross(tt, t.a-s.a)/cross(tt, ss);
}

// 円と直線の交差判定 (交点の数を返す)
int iCL(C c, L l)
{
	int t = sig(dLP(l, c.p), c.r);
	if (t < 0) return 2;
	else if (t == 0) return 1;
	return 0;
}

// 円と直線の交点を求める
vector<P> cCL(C c, L l)
{
	vector<P> res;
	int n = iCL(c, l);
	
	P h = projection(l, c.p);
	D d = abs(h-c.p);
	
	if (n == 2) {
		P x = (l.b-l.a)/abs(l.b-l.a)*sqrt(c.r*c.r - d*d);
		res.push_back(h+x);
		res.push_back(h-x);
	} else if (n == 1) {
		res.push_back(h);
	}
	
	return res;
}

// 円と円の交点を求める (交点があることが前提)
vector<P> cCC(C a, C b)
{
	D d = abs(b.p - a.p);
	D rc = (d*d + a.r*a.r - b.r*b.r)/(2*d);
	D rs = sqrt(a.r*a.r - rc*rc);
	P diff = (b.p-a.p)/d;
	
	vector<P> res;
	res.push_back(a.p + diff*P(rc, rs));
	res.push_back(a.p + diff*P(rc, -rs));
	return res;
}


// 点pから円cに引いた接点を求める
void printL(L l);

vector<P> tCP(C c, P p)
{
	vector<P> res;
	
	D d = abs(c.p-p);
	if (sig(d, c.r)<0) return res;
	
	D rc = c.r*c.r/d;
	D rs = sqrt(c.r*c.r-rc*rc);
	P v = (p-c.p)/abs(p-c.p);
	
	res.push_back(c.p + v*rc + rs*v*P(0, 1));
	res.push_back(c.p + v*rc - rs*v*P(0, 1));
	return res;
}

// ２つの円の共通接線を求める
vector<L> tCCout(C a, C b) // 外接線のみ
{
	vector<L> res;
	
	if (sig(a.r, b.r)==0) {
		res.push_back(L(a.p+a.r*P(0, 1), b.p+b.r*P(0, 1)));
		res.push_back(L(a.p-a.r*P(0, 1), b.p-b.r*P(0, 1)));
	} else {
		D d = abs(b.p - a.p);
		P v = (a.p - b.p)/d;
		D t = d*a.r/(b.r-a.r);
		P q = a.p + v*t;

		vector<P> ta = tCP(a, q), tb = tCP(b, q);
		for (int i=0; i<min(ta.size(), tb.size()); i++)
			res.push_back(L(ta[i], tb[i]));
	}
	return res;
}

vector<L> tCCin(C a, C b) // 内接線のみ
{
	vector<L> res;
	D d = abs(b.p - a.p);
	P v = (b.p - a.p)/d;
	D t = d*a.r/(a.r+b.r);
	//P q = a.p + v*t;
	P q = (a.p*b.r + b.p*a.r)/(a.r+b.r);
	
	vector<P> ta = tCP(a, q), tb = tCP(b, q);
	for (int i=0; i<min(ta.size(), tb.size()); i++)
		res.push_back(L(ta[i], tb[i]));
	return res;
}

vector<L> tCC(C a, C b) // 全て
{
	vector<L> res;
	for (L l : tCCout(a, b)) res.push_back(l);
	for (L l : tCCin(a, b)) res.push_back(l);
	return res;
}

/** Problem2201 : Immortal Jewels **/
int SCALE = 1;

void printL(L l)
{
	cout << "line(" << l.a.X*SCALE << ", " << l.a.Y*SCALE << ", " << l.b.X*SCALE << ", " << l.b.Y*SCALE << ");" << endl;
}

void printP(P p)
{
	cerr << "point(" << p.X*SCALE << ", " << p.Y*SCALE << ");" << endl;
}

void printC(C c)
{
	cerr << "circle(" << c.p.X*SCALE << ", " << c.p.Y*SCALE << ", " << c.r*SCALE << ");" << endl;
}

int main()
{
	int N;
	while (cin>>N, N) {
		vector<C> cs(N);
		
		rep(i, N) {
			D x, y, r, m;
			cin>>x>>y>>r>>m;
			cs[i].p = P(x, y), cs[i].r = r, cs[i].m = m;
		}
		
		int ans = 1;
		for (int i=0; i<N; i++) {
			for (int j=0; j<N; j++) {
				if (i==j) continue;
				C a = cs[i], b = cs[j];
				rep(aa, 2) {
					rep(bb, 2) {
						a.r += aa*a.m, b.r += bb*b.m;
						for (L l : tCC(a, b)) {
							int tmp=0;
							for (C c : cs) {
								D d = abs(dLP(l, c.p));
								if (sig(c.r, d) <= 0 && sig(d, c.r+c.m) <= 0) tmp++;
							}
							ans = max(ans, tmp);
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

Compiler output:
a.cc:11:9: error: 'complex' does not name a type
   11 | typedef complex<D> P; // Point
      |         ^~~~~~~
a.cc:14:9: error: 'P' does not name a type
   14 |         P a, b;
      |         ^
a.cc:16:12: error: expected ')' before 'aa'
   16 |         L(P aa, P bb) : a(aa), b(bb){}
      |          ~ ^~~
      |            )
a.cc:20:9: error: 'P' does not name a type
   20 |         P p; D r, m;
      |         ^
a.cc:22:12: error: expected ')' before 'pp'
   22 |         C(P pp, D rr, D mm) : p(pp), r(rr), m(mm){}
      |          ~ ^~~
      |            )
a.cc:35:7: error: 'P' was not declared in this scope; did you mean 'PI'?
   35 | D dot(P a, P b) { return (conj(a)*b).real(); }
      |       ^
      |       PI
a.cc:35:12: error: 'P' was not declared in this scope; did you mean 'PI'?
   35 | D dot(P a, P b) { return (conj(a)*b).real(); }
      |            ^
      |            PI
a.cc:35:15: error: expression list treated as compound expression in initializer [-fpermissive]
   35 | D dot(P a, P b) { return (conj(a)*b).real(); }
      |               ^
a.cc:38:9: error: 'P' was not declared in this scope; did you mean 'PI'?
   38 | D cross(P a, P b) { return (conj(a)*b).imag(); }
      |         ^
      |         PI
a.cc:38:14: error: 'P' was not declared in this scope; did you mean 'PI'?
   38 | D cross(P a, P b) { return (conj(a)*b).imag(); }
      |              ^
      |              PI
a.cc:38:17: error: expression list treated as compound expression in initializer [-fpermissive]
   38 | D cross(P a, P b) { return (conj(a)*b).imag(); }
      |                 ^
a.cc:42:9: error: 'P' was not declared in this scope; did you mean 'PI'?
   42 | int ccw(P a, P b, P c)
      |         ^
      |         PI
a.cc:42:14: error: 'P' was not declared in this scope; did you mean 'PI'?
   42 | int ccw(P a, P b, P c)
      |              ^
      |              PI
a.cc:42:19: error: 'P' was not declared in this scope; did you mean 'PI'?
   42 | int ccw(P a, P b, P c)
      |                   ^
      |                   PI
a.cc:42:22: error: expression list treated as compound expression in initializer [-fpermissive]
   42 | int ccw(P a, P b, P c)
      |                      ^
a.cc:53:1: error: 'P' does not name a type
   53 | P projection(L l, P p)
      | ^
a.cc:59:1: error: 'P' does not name a type
   59 | P reflection(L l, P p)
      | ^
a.cc:65:12: error: 'P' has not been declared
   65 | D dLP(L l, P c)
      |            ^
a.cc: In function 'D dLP(L, int)':
a.cc:67:28: error: 'struct L' has no member named 'b'
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                            ^
a.cc:67:32: error: 'struct L' has no member named 'a'
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                ^
a.cc:67:39: error: 'struct L' has no member named 'a'
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                       ^
a.cc:67:40: error: 'cross' cannot be used as a function
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                        ^
a.cc:67:49: error: 'struct L' has no member named 'b'
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                                 ^
a.cc:67:53: error: 'struct L' has no member named 'a'
   67 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                                     ^
a.cc: At global scope:
a.cc:71:12: error: 'P' has not been declared
   71 | D dSP(L l, P c)
      |            ^
a.cc: In function 'D dSP(L, int)':
a.cc:73:23: error: 'struct L' has no member named 'b'
   73 |         if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
      |                       ^
a.cc:73:27: error: 'struct L' has no member named 'a'
   73 |         if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
      |                           ^
a.cc:73:34: error: 'struct L' has no member named 'a'
   73 |         if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
      |                                  ^
a.cc:73:35: error: 'dot' cannot be used as a function
   73 |         if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
      |                                   ^
a.cc:73:56: error: 'struct L' has no member named 'a'
   73 |         if (sig(dot(l.b-l.a, c-l.a))<0) return abs(c-l.a);
      |                                                        ^
a.cc:74:23: error: 'struct L' has no member named 'a'
   74 |         if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
      |                       ^
a.cc:74:27: error: 'struct L' has no member named 'b'
   74 |         if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
      |                           ^
a.cc:74:34: error: 'struct L' has no member named 'b'
   74 |         if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
      |                                  ^
a.cc:74:35: error: 'dot' cannot be used as a function
   74 |         if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
      |                                   ^
a.cc:74:56: error: 'struct L' has no member named 'b'
   74 |         if (sig(dot(l.a-l.b, c-l.b))<0) return abs(c-l.b);
      |                                                        ^
a.cc:75:28: error: 'struct L' has no member named 'b'
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                            ^
a.cc:75:32: error: 'struct L' has no member named 'a'
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                ^
a.cc:75:39: error: 'struct L' has no member named 'a'
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                       ^
a.cc:75:40: error: 'cross' cannot be used as a function
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                        ^
a.cc:75:49: error: 'struct L' has no member named 'b'
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                                 ^
a.cc:75:53: error: 'struct L' has no member named 'a'
   75 |         return abs(cross(l.b-l.a, c-l.a))/abs(l.b-l.a);
      |                                                     ^
a.cc: In function 'bool iSS(L, L)':
a.cc:81:23: error: 'struct L' has no member named 'a'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                       ^
a.cc:81:28: error: 'struct L' has no member named 'b'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                            ^
a.cc:81:33: error: 'struct L' has no member named 'a'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                 ^
a.cc:81:34: error: 'ccw' cannot be used as a function
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                  ^
a.cc:81:44: error: 'struct L' has no member named 'a'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                            ^
a.cc:81:49: error: 'struct L' has no member named 'b'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                                 ^
a.cc:81:54: error: 'struct L' has no member named 'b'
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                                      ^
a.cc:81:55: error: 'ccw' cannot be used as a function
   81 |         return (ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0)
      |                                                       ^
a.cc:82:19: error: 'struct L' has no member named 'a'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                   ^
a.cc:82:24: error: 'struct L' has no member named 'b'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                        ^
a.cc:82:29: error: 'struct L' has no member named 'a'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                             ^
a.cc:82:30: error: 'ccw' cannot be used as a function
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                              ^
a.cc:82:40: error: 'struct L' has no member named 'a'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                                        ^
a.cc:82:45: error: 'struct L' has no member named 'b'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                                             ^
a.cc:82:50: error: 'struct L' has no member named 'b'
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                                                  ^
a.cc:82:51: error: 'ccw' cannot be used as a function
   82 |         && (ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0);
      |                                                   ^
a.cc: In function 'D dSS(L, L)':
a.cc:89:33: error: 'struct L' has no member named 'a'
   89 |         return min(min(dSP(t, s.a), dSP(t, s.b)), min(dSP(s, t.a), dSP(s, t.b)));
      |                                 ^
a.cc:89:46: error: 'struct L' has no member named 'b'
   89 |         return min(min(dSP(t, s.a), dSP(t, s.b)), min(dSP(s, t.a), dSP(s, t.b)));
      |                                              ^
a.cc:89:20: error: 'min' was not declared in this scope; did you mean 'std::min'?
   89 |         return min(min(dSP(t, s.a), dSP(t, s.b)), min(dSP(s, t.a), dSP(s, t.b)));
      |                    ^~~
      |                    std::min
In file included from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from /usr/include/c++/14/complex:44,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:89:64: error: 'struct L' has no member named 'a'
   89 |         return min(min(dSP(t, s.a), dSP(t, s.b)), min(dSP(s, t.a), dSP(s, t.b)));
      |