Language: C++

#include <iostream>
#include <cstdio>
#include <complex>
#include <algorithm>
#include <vector>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

typedef complex<double> P;

double s[20];
double t[20];
P p[20];
int r[20];
const double EPS = 1e-10;
const double PI = acos(0) * 2;

inline bool contain(int i, P pos){
  P ps[3] = { p[i] + (double)r[i] * P(cos(s[i]), sin(s[i])),
 	      p[i] + (double)r[i] * P(cos(t[i]), sin(t[i])),
	      p[i] };

  REP(j,3) if(std::abs(ps[j] - pos) < EPS) return true;

  double d = abs(pos - p[i]);

  if(d < r[i] + EPS){
    double dir = arg(pos - p[i]);
    dir -= 2 * PI;
    
    while(t[i] + EPS > dir){
      if(s[i] - EPS < dir && dir < t[i] + EPS)
	return true;
      dir += 2 * PI;
    }
  }

  return false;
}

static inline bool eq(const P &a, const P &b){
  return abs(a-b) < EPS;
}
/* àÏ */
static inline double inp(const P &a, const P &b){
  return (conj(a)*b).real();
}
/* OÏ */
static inline double outp(const P &a, const P &b){
  return (conj(a)*b).imag();
}

class Line{
public:
  P p; /* position */
  P d; /* direction */
  Line(){}
  Line(P pos, P dir){p=pos; d=dir/abs(dir);}
};

/* _Æûü©ç */
inline Line LineDirect(P pos, P dir){
  return Line(pos, dir);
}
/* 2_©ç */
inline Line LinePos(P p1, P p2){
  return Line(p1, p2-p1);
}

/* _Æ¼üÌ£ */
double dist(const Line &l, const P &p){
  return std::abs(outp(l.d, p-l.p) / abs(l.d));
}

/* 2ÂÌ¼üÌð_ */
P crossPoint(const Line &l1, const Line &l2){
  double num = outp(l2.d, l2.p-l1.p);
  double denom = outp(l2.d, l1.d);
  return P(l1.p + l1.d * num/denom);
}

class Circle{
public:
  P p;
  double r;

  Circle(P c, double rr) : p(c), r(rr) {}
};

inline bool complexEq(const P &p1, const P &p2){
  return std::abs(p1 - p2) < EPS;
}

inline bool circleEq(const Circle &c1, const Circle &c2){
  return complexEq(c1.p, c2.p) && std::abs(c1.r - c2.r) < EPS;
}

bool isCross(const Circle &c1, const Circle &c2){
  if(abs(c1.p - c2.p) < c1.r + c2.r + EPS)
    if(abs(c1.p - c2.p) + EPS > max(c1.r, c2.r) - min(c1.r, c2.r))
      return true;
  return false;
}

bool isCross(const Circle &c1, const Line &l1){
  return dist(l1, c1.p) < c1.r + EPS;
}

// xNgpðxNgbÉËeµ½xNgðvZ·é
inline P proj(const P &p, const P &b) {
  return b*inp(p,b)/norm(b);
}
 
// _p©ç¼ülÉø¢½üÌ«ÆÈé_ðvZ·é
inline P perf(const Line &l, const P &p) {
  Line m = LineDirect(l.p - p, l.d);
  return (p + (m.p - proj(m.p, m.d)));
}
 
// üªsð¼übÉËeµ½üªðvZ·é
inline Line proj(const Line &s, const Line &b) {
  return LineDirect(perf(b, s.p), proj(s.d, b.d));
}

vector<P> crossPoints(const Circle &c, const Line &l) {
  P h = perf(l, c.p);
  double d = abs(h - c.p);
  vector<P> res;
  if(d < c.r - EPS){
    P x = l.d / abs(l.d) * sqrt(c.r*c.r - d*d);
    res.push_back(h + x);
    res.push_back(h - x);
  }else if(d < c.r + EPS){
    res.push_back(h);
  }
  return res;
}

pair<P, P> crossPoints(const Circle &c1, const Circle &c2) {
  double d = abs(c1.p - c2.p);
  double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
  double rs = sqrt(c1.r*c1.r - rc*rc);
  P diff = (c2.p - c1.p) / d;
  return make_pair(c1.p + diff * P(rc, rs), c1.p + diff * P(rc, -rs));
}

int main(){
  int tt; scanf("%d", &tt);
  while(tt --> 0){
    int m;
    scanf("%d", &m);

    REP(i,m){
      scanf("%lf%lf%d%lf%lf", &p[i].real(), &p[i].imag(), r+i, s+i, t+i);
      if(s[i] > t[i]) s[i] -= 360.0;
      s[i] = s[i] / 180.0 * PI;
      t[i] = t[i] / 180.0 * PI;
      // printf("s: %f t: %f\n", s[i], t[i]);
    }
    
    vector<P> pos;
    
    // S_
    REP(i,m) pos.push_back(p[i]);
    
    // ~ÊÌ[
      pos.push_back(p[i] + (double)r[i] * P(cos(t[i]), sin(t[i])));
    }

    // ¼üÆ¼ü
    REP(i,m) for(int j = i + 1; j < m; j++){
      P p_i[2] = { P(cos(s[i]), sin(s[i])), P(cos(t[i]), sin(t[i])) };
      P p_j[2] = { P(cos(s[j]), sin(s[j])), P(cos(t[j]), sin(t[j])) };

      REP(ii, 2) REP(jj, 2){
	Line l1 = LineDirect(p[i], p_i[ii]);
	Line l2 = LineDirect(p[j], p_j[jj]);

	if(std::abs((l1.d / l2.d).imag()) > EPS)
	  pos.push_back(crossPoint(l1, l2));
      }
    }
    
    // ~ÊÌð_
    REP(i,m) for(int j = i + 1; j < m; j++){
      Circle c1 = Circle(p[i], r[i]);
      Circle c2 = Circle(p[j], r[j]);

      if(isCross(c1, c2) && !circleEq(c1, c2)){
	pair<P, P> pp = crossPoints(c1, c2);

	pos.push_back(pp.first);
	pos.push_back(pp.second);
      }
    }

    // ~Æ¼üÌð_
    REP(i,m) REP(j,m) if(i != j){
      Circle c = Circle(p[i], r[i]);
      P p_j[2] = { P(cos(s[j]), sin(s[j])), P(cos(t[j]), sin(t[j])) };

      REP(k,2){
	Line l = LineDirect(p[j], p_j[k]);
	if(isCross(c, l)){
	  vector<P> ret = crossPoints(c, l);
	  REP(kk, ret.size())
	    pos.push_back(ret[kk]);
	}
      }
    }

    int ans = 0;
    REP(i, pos.size()){
      int tmp = 0;
      REP(j,m){
	if(contain(j, pos[i])){
	  tmp++;
	}
      }
      // printf("%f,%f : %d\n", pos[i].real(), pos[i].imag(), tmp);
      ans = max(ans, tmp);
    }

    printf("%d\n", ans);
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:156:41: error: lvalue required as unary '&' operand
  156 |       scanf("%lf%lf%d%lf%lf", &p[i].real(), &p[i].imag(), r+i, s+i, t+i);
      |                                ~~~~~~~~~^~
a.cc:156:55: error: lvalue required as unary '&' operand
  156 |       scanf("%lf%lf%d%lf%lf", &p[i].real(), &p[i].imag(), r+i, s+i, t+i);
      |                                              ~~~~~~~~~^~
a.cc:169:23: error: 'i' was not declared in this scope
  169 |       pos.push_back(p[i] + (double)r[i] * P(cos(t[i]), sin(t[i])));
      |                       ^
a.cc:173:11: error: 'm' was not declared in this scope
  173 |     REP(i,m) for(int j = i + 1; j < m; j++){
      |           ^
a.cc:7:39: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc:182:11: error: 'pos' was not declared in this scope; did you mean 'pow'?
  182 |           pos.push_back(crossPoint(l1, l2));
      |           ^~~
      |           pow
a.cc:187:11: error: 'm' was not declared in this scope
  187 |     REP(i,m) for(int j = i + 1; j < m; j++){
      |           ^
a.cc:7:39: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc:194:9: error: 'pos' was not declared in this scope; did you mean 'pow'?
  194 |         pos.push_back(pp.first);
      |         ^~~
      |         pow
a.cc:200:11: error: 'm' was not declared in this scope
  200 |     REP(i,m) REP(j,m) if(i != j){
      |           ^
a.cc:7:39: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc:209:13: error: 'pos' was not declared in this scope; did you mean 'pow'?
  209 |             pos.push_back(ret[kk]);
      |             ^~~
      |             pow
a.cc:215:12: error: 'pos' was not declared in this scope; did you mean 'pow'?
  215 |     REP(i, pos.size()){
      |            ^~~
a.cc:7:39: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc:217:13: error: 'm' was not declared in this scope
  217 |       REP(j,m){
      |             ^
a.cc:7:39: note: in definition of macro 'REP'
    7 | #define REP(i,n) for(int i=0; i<(int)(n); i++)
      |                                       ^
a.cc: At global scope:
a.cc:228:3: error: expected unqualified-id before 'return'
  228 |   return 0;
      |   ^~~~~~
a.cc:229:1: error: expected declaration before '}' token
  229 | }
      | ^