Problem:
Score: 600 points

Problem Statement

E869120 is initially standing at the origin (0, 0) in a two-dimensional plane.

He has N engines, which can be used as follows:

When E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respectively. In other words, if E869120 uses the i-th engine from coordinates (X, Y), he will move to the coordinates (X + x_i, Y + y_i).

E869120 can use these engines in any order, but each engine can be used at most once. He may also choose not to use some of the engines.

He wants to go as far as possible from the origin.
Let (X, Y) be his final coordinates. Find the maximum possible value of \sqrt{X^2 + Y^2}, the distance from the origin.

Constraints

1 \leq N \leq 100

-1 \ 000 \ 000 \leq x_i \leq 1 \ 000 \ 000

-1 \ 000 \ 000 \leq y_i \leq 1 \ 000 \ 000

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
x_2 y_2
: :
x_N y_N

Output

Print the maximum possible final distance from the origin, as a real value.
Your output is considered correct when the relative or absolute error from the true answer is at most 10^{-10}.

Sample Input 1

3
0 10
5 -5
-5 -5

Sample Output 1

10.000000000000000000000000000000000000000000000000

The final distance from the origin can be 10 if we use the engines in one of the following three ways:

Use Engine 1 to move to (0, 10).

Use Engine 2 to move to (5, -5), and then use Engine 3 to move to (0, -10).

Use Engine 3 to move to (-5, -5), and then use Engine 2 to move to (0, -10).

The distance cannot be greater than 10, so the maximum possible distance is 10.

Sample Input 2

5
1 1
1 0
0 1
-1 0
0 -1

Sample Output 2

2.828427124746190097603377448419396157139343750753

The maximum possible final distance is 2 \sqrt{2} = 2.82842....
One of the ways to achieve it is:

Use Engine 1 to move to (1, 1), and then use Engine 2 to move to (2, 1), and finally use Engine 3 to move to (2, 2).

Sample Input 3

5
1 1
2 2
3 3
4 4
5 5

Sample Output 3

21.213203435596425732025330863145471178545078130654

If we use all the engines in the order 1 \rightarrow 2 \rightarrow 3 \rightarrow 4 \rightarrow 5, we will end up at (15, 15), with the distance 15 \sqrt{2} = 21.2132... from the origin.

Sample Input 4

3
0 0
0 1
1 0

Sample Output 4

1.414213562373095048801688724209698078569671875376

There can be useless engines with (x_i, y_i) = (0, 0).

Sample Input 5

1
90447 91000

Sample Output 5

128303.000000000000000000000000000000000000000000000000

Note that there can be only one engine.

Sample Input 6

2
96000 -72000
-72000 54000

Sample Output 6

120000.000000000000000000000000000000000000000000000000

There can be only two engines, too.

Sample Input 7

10
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20

Sample Output 7

148.660687473185055226120082139313966514489855137208

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

/*
;<+111===1?=1=zzzzvI==llllltttttttrrrrrrrvvwXzzzzzzzzzzzzzzzzzzzzzzzzzzzuUXwzzXXzvvvvvvvvXXwrrrrrrrrttz-_...............
:;;;;;;;;;;;<<?<+??=====lllzOtOZOtttttrrrrw0vvzzzzzzzuuuuuuuuuuuuuuuuuuuuuuXWXXXUXzzzzwwvvvwUwvvrrrrrrttt+_.............
;:;:;;;;;<<<-(<<<<?<z1?===zOOOlllttttttrrrdXvzzzzzuuuuuXWXuuuuuuuuuuuuuuuuuuuWkuUyWXvOzXzzzvvzXwvrrrrrrrttO-~......`..`.
;;;;;;;+<~(<<~(<(?<+I??==zwOOOllllltttrwOrwkZwXuzuuuuuuuuXWkZuZZuuZZuZZuuuuuuuuuuuXSI1wkzvvvvvvwXwvrrrrrtttO_~..........
;>;>>+z<(+><<+<<?<(zI?==z0OZlllllltttrwIzrrXv+OWuuuuuuuZZZZZyWWkZyZZZZyZZZZZZZZuuuuXk?wkzzzvvvvrvZXrrrrZzttto~~~..~.....
>>>>jI+wI+=1z<+==1zdZllzZOZttltltttrwVOwvzzuWXzvWuZZZZZyyyWfWWyyWWWkVVyWWVyyyyZZZZZX0zXkuuzzvvvvrrrrrrtrzdO1z>~~~~.~.~..
>??zwZwOtOOtlttOOtOXWyrdkdrrrrrrvwwVOwuXWSuZWXWyvWXyyyyyyyVVVVWHWppWWkkWkWHWVyyyyyyXkXWWkXuuuzzvvvvrrrzzOzXy?O-~~~.~~.~~
??jZzzXzw0vrvwXvvwzXqHkWH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` ?7wl.````..` WUZHMMMMWM$._dM3dM@@@MMHMMMMNMMNNMN#M#<;?<:::::
tltllllllllllllttXkrVM#NNNN##HN,_~7-..(S,..+zOd'`.``.```.`````` ````````. ?+._+zXV^.(?<(Hg@MMMMMNMMMNMNNMM#6?d3;::::::::
ttltlllllllllllllltttdHNNNNN#HMBH&...-.. _~~~~.`````````````````````.``.`````___.._.-JVY=dHNNMNNMNNMNNMB6?>;;;:::::::::~
tttttllllllllllllltttdM##NNN#HMc....```````````.``.``.````.``````````````.`````.`.._....~dH#NNMNMMMM#E??>;;;;:::::::::~:
rtttttttltllllllltlttwgHMNNNN#HMx.....`.````.````````````.._```````````.``.`.``.``.`....(M#NNMMM@@M@Mz?>>;;;;:::::::::::
rrtttttttltllltttllttrmHMMNNNN#HMe_..`.`.`.``.`````.``.``````````````.`````.`.`..`....-+M#NNMM@@@@M@R?>>;;;;;;;:;:::::::
rrrrttttttttttlttttttrWHM@MNNNN#MNO--..``.`````.``.`````````.`.`.`.```.`.``````....._(WBW#M@@@@@@@M@R??>>;;;;;:;::::::::
rrrrrrttttttlttltttttrdM@@MNMNNN#MOlz1--.....`.``````.``.`.``````.`.`.``.`.......-(g9C==d#M@@@@@@@M@R?>>>>;;;;;;;;;:::::
rrrrrrrrttttttttttttrrdM@@MNNMNN#MZll==z1(-...`..`.``.`.` .... .```.`.`......-(JWH9====zMM@@@H@H@@H@0??>>>>;;;;;;;;;;::;
vvvrrrrrrrrttttttttttrwMg@MMMMMNNH0tlll===?z1+--.....`.`.`.``..`...`....-((gMHHM8=====ldHM@@@@@@@@MgR=??>>>>>>;;;;;;;;;;
vrvrrrrrrrrrrrttttrrrrrdgg@MNMMNN#Rrtllll=======WHa-.-....`..`.....-((+WHHHWyy#Il====lldM@@H@@H@@@HgR=??>>>>>>>>>;;;;;;;
vrvvrrrrrtttrtrrtrtttrrdgggMN@MNN#Krtllllllll=lldkuuXUUG&---.-((JzuuuZZZyyyyyXRlllllllld@@@@@H@@@@MgS==???>>>>>>>;>>>;>;
vrvrrrrrrrrrttrttrrrrrrdHggM#@MNN##rtttllllllllltWuuZuuuuuuuuZuZZZZZZyyyyyyyyXSllllllltWg@@@HW@@@MMg0==?????>>>>>>>>>>>>
rrrrrrrrtrrtrttrtttrtrrdHqggMHHNN#NrtttttlltlllltdkuZZZZZZZZZZZZZZyZyyyyyyyyyWRtllllltdgg@@HHW@@@MgHI==????>??>>>>>>>>>>
rrrrrrrrttttttttttttttrwHkqqHMXM##MwrttttttttttttwKuuZZZZZZZZZZZZZZZZZZZyyyyyyHAwtttttdgggmHXHqmMHqKl=?????>??>??>??>???
vvvrrrtrtttttrttttttttrwHkkkkkkWHHHkrrtttOwwwwXUuXWuuuZuZZZZZZZZZZZZZZZZZZZZyyyyyyWWyqHHHkHZdXWHMkHS===??????????>??????
rrrrrtttttrttttttttttttrWpppppRZMHHkwXUUXvvvzzzzuuuuuuuuuuuuZuuZZZZZZZZZZZZZZZZZZZZZXHHHkH0wXSXHppW7?<11zz???>>?>??>?>??
rrrrrttttttllllzz??<<?v!jyVVXWfZdHMr1wwrvvvvvzzzzzzuuuuuuuuuuuuuuuuZZZZZZZZZZZZZZZZZWHSHkSdSXdWffV%~~~~~~<-__<??<<??>???
rrrtrttttv<!````````.?...UZyXZVWwM@b` ?1OZXUUUUUUUZZXkXuuZuuuuuuZuZXXXkkXXyyWWWWWUWH9=(HHXkHXHbpff~~~.~~~~(-````.``._?<z
rrrtttz^_`````.``.``.!...jZykXdfWX@H-...._?zrrvvzzuuuuuUUuuuuuuZXUuuuuuuuuuuuuuzVOV:.(WHWqqWqkkpW>~~~~~~~~~(-.``.```.`..
*/

#include <bits/stdc++.h>
#include <functional>
#include <iomanip>
using namespace std;
	
#define int long long
#define pb push_back
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>

template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>; 
using ll = long long;
ll INF = LLONG_MAX / 4000 - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
	
class fact {
public:
	int fmod = 1e9+7;
	vector<int> fac, inv;
	fact (int n, int Mod = 1e9+7) {
		fmod = Mod;
		fac = vector<int>(n,0);
		inv = vector<int>(n,0);
		fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
		for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
	}
	ll nCr(ll n, ll r) {if(n < r) return 0; return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
	ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
    inline int operator [] (int i) {return fac[i];}
};
	
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return (a / GCD(a, b)) * (b / GCD(a, b)) * GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
double dis(int x1, int x2, int y1, int y2) {
	return sqrt((double)abs(x1-x2)*(double)abs(x1-x2)+(double)abs(y1-y2)*(double)abs(y1-y2));
}

struct edge {
	int x, y;
	long double decl;
};

bool cmp(edge& a, edge& b) {
	return a.decl < b.decl;
}

bool solve() {
	int n; cin >> n;
	vector<edge> edges;
	REP (i,n) {
		int x, y; cin >> x >> y;
		if (x || y) {
			edges.pb({x,y,atan2((long double)y, (long double)x)});
		}
	}
	sort(all(edges),cmp);
	n = edges.size();

	double ans = 0;
	REP (i,n) {
		REP (j,n+1) {
			pair<int,int> pos={};
			FOR (k,i,i+j) {
				int idx = k % n;
				pos.F += edges[idx].x;
				pos.S += edges[idx].y;
			}
			chmax(ans,dis(0,pos.F,0,pos.S));
		}
	}

	cout << fixed << setprecision(15);
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}