Language: C++

//#pragma warning(disable:4996)
#include <Windows.h>
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
template<class T>
using V = vector<T>;
template<class T>
using VV = vector<vector<T>>;
typedef unsigned long long ULL;

void input();
void solve();

void daminput();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	//daminput();
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////


int N;
VLL X;
VLL Y;

void input() {
	cin >> N;
	X.resize(N);
	Y.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> X[i] >> Y[i];
	}
}

void daminput() {
}

void argsort(V<PLL>& points) {
	V<pair<PLL, int>> P(points.size());
	for (int n = 0; n < points.size(); n++)
	{
		P[n] = pair<PLL, int>(points[n], n);
	}
	auto dot = [](PLL a, PLL b) {
		return a.first * b.first + a.second * b.second;
	};
	auto cross = [](PLL a, PLL b) {
		return a.first * b.second - a.second * b.first;
	};
	auto deg = [&](PLL a) {
		int e1acr = cross(PI(1, 0), a);
		int e1adot = dot(PI(1, 0), a);
		if (e1adot > 0 && e1acr >= 0)return 1;
		else if (e1adot <= 0 && e1acr > 0)return 2;
		else if (e1adot < 0 && e1acr <= 0)return 3;
		else return 4;
	};
	auto comp = [&](pair<PLL,int> ap, pair<PLL,int> bp) {
		PLL a = ap.first;
		PLL b = bp.first;
		if (a.first == 0 && a.second == 0) {
			if (b.first == 0 && b.second == 0)return ap.second < bp.second;
			else return true;
		}
		if (b.first == 0 && b.second == 0) {
			return false;
		}
		if (cross(a, b) == 0 && dot(a, b) > 0)return ap.second < bp.second;
		int anum = deg(a);
		int bnum = deg(b);
		if (anum != bnum)return (anum < bnum);
		while (anum != 1) {
			swap(a.first, a.second);
			a.first *= -1;
			swap(b.first, b.second);
			b.first *= -1;
			anum = deg(a);
			bnum = deg(b);
		}
		LL a2 = a.first * a.first + a.second * a.second;
		LL b2 = b.first * b.first + b.second * b.second;
		LL ax2 = a.first * a.first;
		LL bx2 = b.first * b.first;
		bool res = (ax2 * b2 > bx2 * a2);
		return res;
	};
	sort(P.begin(), P.end(), [&](pair<PLL,int> a, pair<PLL, int> b) {
		return comp(a, b);
	});
	for (int n = 0; n < P.size(); n++)
	{
		points[n] = P[n].first;
	}
}

void solve() {
	vector<PLL> points0;
	for (int n = 0; n < N; n++)
	{
		if (X[n] != 0 || Y[n] != 0) {
			points0.push_back(PLL(X[n], Y[n]));
		}
	}
	N = points0.size();
	argsort(points0);
	V<PLL> sum(N);
	sum[0] = points0[0];
	for (int n = 1; n < N; n++)
	{
		sum[n].first = sum[n - 1].first + points0[n].first;
		sum[n].second = sum[n - 1].second + points0[n].second;
	}
	LL ans = 0;
	for (int s = 0; s < N; s++)
	{
		//[s,e] \subset [0,N-1]
		for (int e = s; e < N; e++)
		{
			LL x = sum[e].first;
			LL y = sum[e].second;
			if (s > 0) {
				x -= sum[s - 1].first;
				y -= sum[s - 1].second;
			}
			ans = max(ans, x * x + y * y);
		}
		//[s,N-1]+[0,e]
		for (int e = 0; e < s; e++)
		{
			LL x = sum.back().first;
			LL y = sum.back().second;
			if (s > 0) {
				x -= sum[s - 1].first;
				y -= sum[s - 1].second;
			}
			x += sum[e].first;
			y += sum[e].second;
			ans = max(ans, x * x + y * y);
		}
	}
	cout << setprecision(12) << sqrtl(ans) << "\n";
	return;
}

Compiler output:
a.cc:2:10: fatal error: Windows.h: No such file or directory
    2 | #include <Windows.h>
      |          ^~~~~~~~~~~
compilation terminated.