Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;(i)<(n);++(i))
using namespace std;

// Description: ????????????
// Verifyed: various problem
using namespace placeholders;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

const R INF = 1E40L;
const R PI = acos(-1.0L);
using P = complex<R>;
using L = struct {P s, t;};
using VP = vector<P>;
using C = struct {P c; R r;};

#define at(a,i) (a[(i + a.size()) % a.size()])

auto& operator >> (istream& is, P& p) { R x, y; is >> x >> y, p = P(x, y); return is;}
auto& operator << (ostream& os, P& p) { os << real(p) << " " << imag(p); return os;}

namespace std {
bool operator <  (const P& a, const P& b) { return sgn(real(a - b)) ? real(a - b) < 0 : sgn(imag(a - b)) < 0;}
bool operator == (const P& a, const P& b) { return sgn(real(a - b)) == 0 && sgn(imag(a - b)) == 0;}
}

inline R dot(P o, P a, P b) {return real(conj(a - o) * (b - o));}
inline R det(P o, P a, P b) {return imag(conj(a - o) * (b - o));}
inline P vec(L l) {return l.t - l.s;}
auto sdot = bind(sgn, bind(dot, _1, _2, _3));
auto sdet = bind(sgn, bind(det, _1, _2, _3));

//projection verify AOJ CGL_1_A
P proj(L l, P p) { R u = real((p - l.s) / vec(l)); return (1 - u) * l.s + u * l.t;}


// distance
// verified: AOJ CGL_2_D
R dsp(L l, P p) {
	P h = proj(l, p);
	if (sdot(l.s, l.t, p) <= 0) h = l.s;
	if (sdot(l.t, l.s, p) <= 0) h = l.t;
	return abs(p - h);
}

bool icp(C c, P p, int end = 0) {return sgn(abs(p - c.c) - c.r) <= -end;}
bool ics(C c, L s, int end = 0) {
	if (sgn(dsp(s, c.c) - c.r) > end) return false;
	if (icp(c, s.s, end) and icp(c, s.t, end)) return false;
	return true;
}

// cross point between circle and line
// verified: AOJ CGL_7_D
P cir(C c, R t) {return c.c + polar(c.r, t);}
VP cross(C c, L l) {
	P h = proj(l, c.c);
	P e = polar(sq(norm(c.r) - norm(h - c.c)), arg(vec(l)));
	return VP{h - e, h + e};
}

// cross point between circles
// verified: AOJ CGL_7_E
VP cross(C a, C b) {
	P d = b.c - a.c;
	P w = (norm(d) + norm(a.r) - norm(b.r)) / (2.0L * norm(d)) * d;
	return cross(a, {a.c + w, a.c + w + 1il * d});
}

R angle(P o,P a,P b){
	return arg(P(dot(o,a,b),det(o,a,b));
}

// common area of circle and polygon


R area_helper(C c, P a, P b) {
	if (icp(c, a) and icp(c, b)) return abs(det(0, a, b)) / 2.0l;
	return norm(c.r) * abs(angle(0,a,b)) / 2.0l;
}

R area(C c, P a, P b) {
	L l = {a, b};

	if (sgn(min({c.r, abs(a), abs(b), abs(b - a)})) == 0) return 0.0;

	if (ics(c, l)==false){
		return area_helper(c, a, b);
	}
	
	R res = 0.0;

	VP ary;

	ary.push_back(a);
	for (auto &p : cross(c, l)){
		if (sdot(p, a, b) < 0){
			ary.push_back(p);
		}
	}
	ary.push_back(b);

	//for(auto &p:ary) cerr  << p << endl;

	rep(i, ary.size()-1){
		//cerr << area_helper(c, at(ary, i), at(ary, i + 1)) << endl;
		res += area_helper(c, at(ary, i), at(ary, i + 1));
	}
	return res;

}

R area(C c, VP pol) {
	R res = 0;
	rep(i, pol.size()) {
		P a = at(pol, i) - c.c , b = at(pol, i + 1) - c.c;
		res += sdet(0,a,b) * area(C{0.0L, c.r}, a, b);
	}
	return res;
}


/*
R area(R r, P a, P b) {
	if (sgn(abs(a)-r) <= 0 and sgn(abs(b)-r) <= 0) return abs(det(0, a, b)) / 2.0l;
	return norm(r) * angle(0,a,b) / 2.0l;
}
*/

/*
R area(C c, VP pol) {
	R res = 0;
	rep(i, pol.size()) {
		R r = c.r;
		P a = at(pol, i) - c.c , b = at(pol, i + 1) - c.c;
		if (sgn(min({r, abs(a), abs(b), abs(b - a)})) == 0) continue;
		VP isc = cross(C{0.0l, r}, L{a, b});
		
		if(sdot(a,isc[0],isc[1])<=0 and sdot(b,isc[0],isc[1])<=0){
			res += area(r, a, b);
		}else{
			res += area(r, a, isc[0]) + area(r, isc[0], isc[1]) + area(r, isc[1], b);
		}

		//cerr << res << endl;
	}
	return res;
}
*/



int main(void) {
	int n;
	R r;
	cin >> n >> r;
	C c = C{0.0L, r};
	VP pol(n);
	rep(i, n) cin >> pol[i];
	cout.precision(20);
	cout << fixed << area(c, pol) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'R angle(P, P, P)':
a.cc:74:44: error: expected ')' before ';' token
   74 |         return arg(P(dot(o,a,b),det(o,a,b));
      |                   ~                        ^
      |                                            )