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 (Python):
from math import *
n = int(input())
engine = [list(map(int, input().split())) for i in range(n)]

args = []
for i in range(n):
    x, y = engine[i]
    if x == 0:
        if y < 0:
            args.append((-pi/2, x, y))
        elif y > 0:
            args.append((pi/2, x, y))

    elif y == 0:
        if x > 0:
            args.append((0, x, y))
        elif x < 0:
            args.append((pi, x, y))

    else:
        args.append((atan2(y, x), x, y))

args.sort()
l = len(args)
args = args[:] + args[:]
ans = 0
for i in range(1, l+1):
    for j in range(l):
        x, y = 0, 0
        for k in range(j, j+i):
            x += args[k][1]
            y += args[k][2]
        ans = max(ans, hypot(x, y))

print(ans)

Solution (Python):
N=int(input())
S1=[]
S2=[]
S3=[]
S4=[]
YP=[]
YM=[]

for i in range(N):
    x,y=map(int,input().split())
    if x==0:
        if y>=0:
            YP.append([0,x,y])
        else:
            YM.append([0,x,y])
    else:
        if x>0 and y>=0:
            S1.append([y/x,x,y])
        elif x>0 and y<0:
            S2.append([y/x,x,y])
        elif x<0 and y<0:
            S3.append([y/x,x,y])
        else:
            S4.append([y/x,x,y])
S1.sort(reverse=True)

S2.sort(reverse=True)
S3.sort(reverse=True)
S4.sort(reverse=True)
L=YP+S1+S2+YM+S3+S4
List=L+L


ans=0
for i in range(len(L)):
    X=List[i][1]
    Y=List[i][2]
    cnt=(X*X+Y*Y)
    if ans<cnt:
        ans=cnt
    for j in range(1,len(L)):
            X+=List[i+j][1]
            Y+=List[i+j][2]
            cnt=(X*X+Y*Y)
            if ans<cnt:
                ans=cnt
print(ans**0.5)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
args = sorted([(math.atan2(y,x),x,y) for x,y in xy])
ans = 0
for key,(sarg,sx,sy) in enumerate(args):
  tmpx,tmpy = sx,sy
  dist = tmpx**2 + tmpy**2
  for arg,x,y in args[key+1:]:
    tmpx += x
    tmpy += y
    tmp = tmpx**2 + tmpy**2
    if tmp < dist:
      break
    else:
      dist = tmp
  for arg,x,y in args[:key]:
    tmpx += x
    tmpy += y
    tmp = tmpx**2 + tmpy**2
    if tmp < dist:
      break
    else:
      dist = tmp
  ans = max(ans,dist)
print(math.sqrt(ans))

Solution (Python):
from math import *

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
xy.sort(key=lambda t: atan2(t[1], t[0]))
ans = 0

for i in range(N):
    nx, ny = 0, 0
    
    for j in range(i, i+N):
        nx += xy[j%N][0]
        ny += xy[j%N][1]
        ans = max(ans, (nx**2+ny**2)**0.5)

print(ans)

Solution (Python):
from math import sqrt
n = int(input())
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
        return
    def __lt__(self, p2):
        return self.quadrant() < p2.quadrant() or self.quadrant() == p2.quadrant() and self.x * p2.y - self.y * p2.x > 0
    def __repr__(self):
        return repr((self.x, self.y))
    def __add__(self, p2):
        return Point(self.x+p2.x, self.y+p2.y)
    def __sub__(self, p2):
        return Point(self.x-p2.x, self.y-p2.y)
    def quadrant(self):
        if self.x > 0 and self.y >= 0:
            return 1
        elif self.y > 0:
            return 2
        elif self.x < 0:
            return 3
        else:
            return 4
    def square(self):
        return self.x ** 2 + self.y ** 2

xy = [Point(xi, yi) for xi, yi in (map(int, input().split()) for _ in range(n)) if not xi == yi == 0]


cur_point = sum((p for p in xy if p.y > 0 or p.y == 0 and p.x >= 0), Point(0, 0))

inv = list(Point(-p.x, -p.y) for p in xy)
xy.extend(inv)
xy.sort()

mx = cur_point.square()
for p in xy:
    cur_point -= p
    mx = max(mx, cur_point.square())

print(sqrt(mx))

Solution (Python):
from math import atan2, hypot

def solve():
    N = int(input())
    engines = [tuple(map(int, input().split())) for _ in range(N)]

    engines.sort(key=lambda x: atan2(x[1], x[0]))

    ans = 0
    for L in range(N):
        for R in range(L, L+N):
            x, y = 0, 0
            for i in range(L, R+1):
                i %= N
                dx, dy = engines[i]
                x, y = x+dx, y+dy
            dist = hypot(x, y)
            if dist > ans:
                ans = dist

    print(ans)


solve()

Solution (Python):
from math import atan2, hypot

def solve():
    N = int(input())
    engines = [tuple(map(int, input().split())) for _ in range(N)]

    engines.sort(key=lambda x: atan2(x[1], x[0]))

    ans = 0
    for L in range(N):
        for R in range(L, L+N):
            x, y = 0, 0
            for i in range(L, R+1):
                i %= N
                dx, dy = engines[i]
                x, y = x+dx, y+dy
            dist = hypot(x, y)
            if dist > ans:
                ans = dist

    print(ans)


solve()

Solution (Python):
import math

n = int(input())
xy = [list(map(int,input().split())) for _ in range(n)]


xy2 = []
for x,y in xy:
    if(x==y==0):
        continue
    xy2.append((x,y))


n = len(xy2)
if(n==0):
    print(0)
    exit()

degs = [0]
for x,y in xy2:
    deg = math.atan2(y,x)
    deg1 = (deg + math.pi*0.5)%(2*math.pi)
    deg2 = (deg + math.pi*1.5)%(2*math.pi)
    degs.append(deg1)
    degs.append(deg2)

degs.append(2*math.pi)
degs.sort()

ans = 0
for i in range( len(degs)-1 ):
    deg = (degs[i+1]+degs[i])/2
    sum_x = 0
    sum_y = 0
    for x,y in xy2:
        tmp = x*math.cos(deg) + y*math.sin(deg)
        if (tmp > 0):
            sum_x += x
            sum_y += y
        ans = max(ans, (sum_x**2 + sum_y**2)**0.5)

print(ans)

Solution (Python):
from functools import cmp_to_key

def argsort(arr):
    def cmp(p1, p2):
        x1, y1 = p1
        x2, y2 = p2
        if x1 >= y1 == 0:
            if y2 > 0: return -1
            if y2 < 0: return 1
            if x2 < 0: return -1
            return 0
        if x2 >= y2 == 0:
            if y1 > 0: return 1
            if y1 < 0: return -1
            if x1 < 0: return 1
            return 0
        if y1 == 0: return 1
        if y2 == 0: return -1
        if y1 > 0 and y2 < 0: return 1
        if y2 > 0 and y1 < 0: return -1
        if x1 * y2 > x2 * y1: return -1
        if x1 * y2 < x2 * y1: return 1
        return 0
    return sorted(arr, key=cmp_to_key(cmp))

def dist(x, y):
    return (x**2 + y**2)**0.5

N = int(input())

P = [tuple(map(int, input().split())) for _ in range(N)]
P = argsort(P)

C = [(0, 0)]
for i in range(N):
    C.append((C[-1][0] + P[i][0], C[-1][1] + P[i][1]))

res = 0

for i in range(N):
    for lt in range(N):
        for rt in range(N):
            if lt <= i <= rt:
                x = C[rt + 1][0] - C[lt][0]
                y = C[rt + 1][1] - C[lt][1]
            elif i <= rt < lt or rt < lt <= i:
                x = C[rt + 1][0] + C[N][0] - C[lt][0]
                y = C[rt + 1][1] + C[N][1] - C[lt][1]
            else:
                continue
            res = max(res, dist(x, y))

print(res)

Solution (Python):
from math import atan2
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key=lambda x:atan2(x[1],x[0]))
ans=0
for i in range(n):
    x,y=0,0
    for j in range(n):
        x1,y1=l[(i+j)%n]
        x+=x1
        y+=y1
        ans=max(x**2+y**2,ans)
print(ans**0.5)

Solution (Python):
import math
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
xy.sort(key = lambda x:math.atan2(x[1],x[0]))
xyrad = [math.atan2(xy[i][1],xy[i][0]) for i in range(n)]
ans = []
x,y = list(zip(*xy))
xsum,ysum = sum(x),sum(y)
eps = 10**-8
for i in range(n):
  xs,ys = 0,0
  for j in range(i,i+n):
    xs += xy[j%n][0]
    ys += xy[j%n][1]
    ans.append(math.hypot(xs,ys))
print(max(ans))

Solution (Python):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
import math
a = []
for i in range(n):
    x,y = mi()
    x += 1e-15
    theta = math.degrees(math.atan2(y,x))
    a.append([theta,x,y])
a.sort()
a2 = list(a)
a = a + a2
import numpy as np
x = []
y = []
for i in range(len(a)):
    x.append(a[i][1])
    y.append(a[i][2])
x = np.array(x)
y = np.array(y)
xsum = np.cumsum(x)
ysum = np.cumsum(y)
ans = 0
for i in range(1,n+1):
    for k in range(i,n+i):
        xtmp = xsum[k] - xsum[i-1]
        ytmp = ysum[k] - ysum[i-1]
        tmp = (xtmp**2 + ytmp**2) ** 0.5
        ans = max(ans,tmp)
print(ans)

Solution (Python):
from math import atan2, pi

N = int(input())
engines = []
total_X = total_Y = 0
for i in range(N):
  x, y = map(int, input().split())
  engines.append((atan2(y, x), x, y)) 
  total_X += x
  total_Y += y

engines.sort()
ans2 = 0
l = r = 0
X = engines[0][1]
Y = engines[0][2]

for l in range(N):
  theta = engines[l][0]
  xl, yl = engines[l][1:]
  
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] < theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi < theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2) 
  
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] <= theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi <= theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2) 
  X -= xl
  Y -= yl

print(ans2 ** 0.5)

Solution (Python):
from math import atan2, pi

N = int(input())
engines = []
total_X = total_Y = 0
for i in range(N):
  x, y = map(int, input().split())
  engines.append((atan2(y, x), x, y)) 
  total_X += x
  total_Y += y

engines.sort()
ans2 = 0
l = r = 0
X = engines[0][1]
Y = engines[0][2]

for l in range(N):
  theta = engines[l][0]
  xl, yl = engines[l][1:]
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] < theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi < theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2)
  while r + 1 - l < N \
      and (theta <= engines[(r+1)%N][0] <= theta+pi \
           or theta <= engines[(r+1)%N][0]+2*pi <= theta+pi):
    r += 1
    X += engines[r%N][1]
    Y += engines[r%N][2]
  ans2 = max(ans2, X**2+Y**2, (total_X-X)**2+(total_Y-Y)**2)
  X -= xl
  Y -= yl

print(ans2 ** 0.5)

Solution (Python):
import math

n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    x, y = info[i]
    info[i] = (math.atan2(y, x), x, y)
info = sorted(info)

info = info + info
ans = 0
for i in range(n):
    x, y = 0, 0
    for j in range(i, i + n):
        _, xp, yp = info[j]
        x += xp
        y += yp
        ans = max(ans, (x ** 2 + y ** 2) ** 0.5)

print(ans)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x, y = xy[i]
    test_case.append((y, -x))
    test_case.append((-y, x))

ret = 0
for nx, ny in test_case:
    sx, sy = 0, 0
    for j in range(n):
        x, y = xy[j]
        if nx * x + ny * y > 0 or (nx * x + ny * y == 0 and -ny * x + nx * y >= 0):
            sx += x
            sy += y
    ret = max(ret, math.hypot(sx, sy))
print(ret)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy = 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy))
print(ret)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 <= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((x1, y1))
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Solution (Python):
import math

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

test_case = []
for x in (-1, 0, 1):
    for y in (-1, 0, 1):
        test_case.append((x, y))
for i in range(n):
    x1, y1 = xy[i]
    test_case.append((x1, y1))
    test_case.append((-x1, -y1))
    test_case.append((y1, -x1))
    test_case.append((-y1, x1))

ret = 0
for x1, y1 in test_case:
    sx, sy, tx, ty = 0, 0, 0, 0
    for j in range(n):
        x2, y2 = xy[j]
        if x1 * x2 + y1 * y2 > 0 or (x1 * x2 + y1 * y2 == 0 and -y1 * x2 + x1 * y2 >= 0):
            sx += x2
            sy += y2
        else:
            tx += x2
            ty += y2
    ret = max(ret, math.hypot(sx, sy), math.hypot(tx, ty))
print(ret)

Solution (Python):
import math
def arg(x,y):
  if x==0:
    if y>0:
      return math.pi/2
    else:
      return 3*math.pi/2
  else:
    if x>0:
      return math.atan(y/x)
    else:
      return math.atan(y/x)+math.pi
n=int(input())
A=[]
for i in range(n):
  x,y=map(int,input().split())
  if x==0 and y==0:
    continue
  A.append([arg(x,y),x,y])
  A.append([arg(x,y)+2*math.pi,x,y])
A=sorted(A)
n=len(A)//2
ans=0
for i in range(n):
  for j in range(1,n+1):
    X=0
    Y=0
    for k in range(i,i+j):
      X=X+A[k][1]
      Y=Y+A[k][2]
    d=(X**2+Y**2)**(1/2)
    if d>ans:
      ans=d
print(ans)

Solution (Python):
from math import*
def main():

    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    k = 10000
    ans2 = 0
    for i in range(k):
        t = 2*i*pi/k
        s = sin(t)
        c = cos(t)
        ans = [0, 0]
        for a, b in ab:
            if a*s+b*c >= 0:
                ans[0] += a
                ans[1] += b
        ans2 = max(ans2, ans[0]**2+ans[1]**2)
    print(ans2**0.5)


main()

Solution (Python):
from math import*
def main():

    n = int(input())
    ab = [list(map(int, input().split())) for _ in [0]*n]
    k = 10000
    ans2 = 0
    for i in range(k):
        t = 2*i*pi/k
        s = sin(t)
        c = cos(t)
        ans = [0, 0]
        for a, b in ab:
            if a*s+b*c >= 0:
                ans[0] += a
                ans[1] += b
        ans2 = max(ans2, ans[0]**2+ans[1]**2)
    print(ans2**0.5)


main()

Solution (Python):
from math import radians, sin, cos, sqrt
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for theta in range(3600):
	ansx, ansy = 0, 0
	e = [cos(radians(theta/10)), sin(radians(theta/10))]
	for x, y in a:
		pr = x * e[0] + y * e[1]
		if pr > (1e-10):
			ansx += x
			ansy += y
	ans = max(ans, sqrt(ansx**2+ansy**2))
print(ans)

Solution (Python):

def examF():
    
    def calc_L(a,b):
        return (a**2 + b**2)**(1/2)
    N = I()
    X = [[]for _ in range(N)]
    for i in range(N):
        x,y = LI()
        d = math.degrees(math.atan2(y,x))
        if d<0:
            d += 360
        X[i] = [d,x,y]
    X.sort()
    
    ans = 0
    for i in range(N):
        cur_X = 0; cur_Y = 0
        for d2,x2,y2 in (X[i:] + X[:i]):
            if calc_L(cur_X+x2,cur_Y+y2)<calc_L(cur_X,cur_Y):
                continue
            cur_X += x2
            cur_Y += y2

        now = calc_L(cur_X,cur_Y)
        if now>ans:
            ans = now

    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examF()

"""

"""

Solution (Python):
def examA():
    N = I()
    ans = 0
    print(ans)
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    N = I()
    node = N*(N-1)//2
    V = [[]for _ in range(node)]
    D = [[0]*N for _ in range(N)]
    cur = 0
    for i in range(N):
        for j in range(i+1,N):
            D[i][j] = cur
            D[j][i] = cur
            cur += 1
    
    for i in range(N):
        a = LI()
        for j in range(N-2):
            fr = D[i][a[j]-1]
            to = D[i][a[j+1]-1]
            
            V[fr].append(to)

    visited = [False] * node
    calculated = [False] * node
    dp = [1] * node
    
    def dfs(v):
        if visited[v]:
            if not calculated[v]:
                return -1  
            return dp[v]
        visited[v] = True
        for u in V[v]:  
            res = dfs(u)
            if res == -1: return -1  
            elif res+1>dp[v]:
                dp[v] = res + 1
        calculated[v] = True
        return dp[v]

    ans = 0
    for i in range(node):
        res = dfs(i)
        ans = max(ans,res)
        if res == -1:
            print('-1')  
            return
    print(ans)
    return

def examF():
    def calc_L(a,b):
        return (a**2 + b**2)**(1/2)
    N = I()
    X = [[]for _ in range(N)]
    for i in range(N):
        x,y = LI()
        d = math.degrees(math.atan2(y,x))
        if d<0:
            d += 360
        X[i] = [d,x,y]
    X.sort()
    
    ans = 0
    for i in range(N):
        cur_X = 0; cur_Y = 0
        for d2,x2,y2 in (X[i:] + X[:i]):
            if calc_L(cur_X+x2,cur_Y+y2)<calc_L(cur_X,cur_Y):
                continue
            cur_X += x2
            cur_Y += y2

        now = calc_L(cur_X,cur_Y)
        if now>ans:
            ans = now

    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examF()

"""

"""

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    p = LIR(n)
    p.sort(key = lambda x:math.atan2(x[1],x[0]))
    p += p
    ans = 0
    for i in range(n):
        m = [0,0]
        for j in range(i,i+n):
            m[0] += p[j][0]
            m[1] += p[j][1]
            d = m[0]**2+m[1]**2
            if ans < d:
                ans = d
    print(ans**0.5)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    import sys
    from math import atan2, hypot, pi
    from bisect import bisect_left
    input = sys.stdin.readline

    eps = 10**-8
    N = int(input())
    P = []
    rad = []
    for _ in range(N):
        x, y = map(int, input().split())
        P.append((atan2(y, x), x, y))
        rad.append(atan2(y, x))
    P.sort(key=lambda p: p[0])
    rad.sort()
    for i in range(N):
        r, x, y = P[i]
        P.append((r+pi*2, x, y))
        rad.append(r+pi*2)

    ans = 0
    for i in range(N):
        rad_op = rad[i] + pi
        j = bisect_left(rad, rad_op)
        xsum = ysum = 0
        for k in range(i, j):
            x, y = P[k][1], P[k][2]
            xsum += x
            ysum += y
        ans = max(ans, hypot(xsum, ysum))
        xsum -= P[i][1]
        ysum -= P[i][2]
        ans = max(ans, hypot(xsum, ysum))
    for i in range(N, N*2):
        rad_op = rad[i] - pi
        j = bisect_left(rad, rad_op)
        xsum = ysum = 0
        for k in range(j, i+1):
            x, y = P[k][1], P[k][2]
            xsum += x
            ysum += y
        ans = max(ans, hypot(xsum, ysum))
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
e = []
for _ in range(N):
  x, y = map(int, input().split())
  e.append((x, y))
res = 0
for i in range(N):
  for j in range(N):
    u = e[i][0] + e[j][0]
    v = e[i][1] + e[j][1]
    px = 0
    py = 0
    for k in range(N):
      x, y = e[k]
      if u * x + v * y > 0:
        px += x
        py += y
    res = max(res, sqrt(px ** 2 + py ** 2))
print(res)

Solution (Python):
from cmath import phase

N, *XY = map(int, open(0).read().split())

XY = sorted((complex(x, y) for x, y in zip(*[iter(XY)] * 2)), key=phase)
XY += XY

print(max(abs(sum(XY[i:j])) for i in range(2 * N + 1) for j in range(2 * N + 1) if j - i <= N))

Solution (Python):
from cmath import phase

N, *XY = map(int, open(0).read().split())

XY = sorted((complex(x, y) for x, y in zip(*[iter(XY)] * 2)), key=phase)
XY += XY


ans = 0
for i in range(2 * N + 1):
    for j in range(2 * N + 1):
        if j - i <= N:
            ans = max(ans, abs(sum(XY[i:j])))

print(ans)

Solution (Python):
from itertools import combinations
from cmath import phase

N, *XY = map(int, open(0).read().split())

XY = sorted((complex(x, y) for x, y in zip(*[iter(XY)] * 2)), key=phase)
XY += XY


ans = 0
for i, j in combinations(range(2 * N + 1), 2):
    if j - i <= N:
        ans = max(ans, abs(sum(XY[i:j])))

print(ans)

Solution (Python):
from math import hypot,atan2
N = int(input())
XY = [tuple(map(int,input().split())) for i in range(N)]
xy = sorted(XY, key=lambda x:atan2(x[1],x[0]))
xy += xy

ans = 0
for i in range(N):
    sx = sy = 0
    for j in range(N):
        x,y = xy[i+j]
        sx += x
        sy += y
        d = hypot(sx,sy)
        if d > ans:
            ans = d
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
import math

from collections import deque
from operator import itemgetter


N = int(input())
XY1 = []
XY2 = []
for _ in range(N):
    x, y = map(int, input().split())
    theta = math.atan2(y, x)
    if y == 0 and x < 0:
        theta -= 2*math.pi
    if theta < 0:
        XY1.append((x, y, theta))
    else:
        XY2.append((x, y, theta))

XY1.sort(key=itemgetter(2))
XY2.sort(key=itemgetter(2))

q1 = deque()
q2 = deque()
for xy1 in XY1:
    q1.append(xy1)
for xy2 in XY2:
    q2.append(xy2)

ans = 0
for _ in range(N+4):
    px, py = 0, 0
    mx, my = 0, 0
    for xy1 in q1:
        px += xy1[0]
        py += xy1[1]
    for xy2 in q2:
        mx += xy2[0]
        my += xy2[1]
    dp = math.sqrt(px**2+py**2)
    if dp > ans:
        ans = dp
    dm = math.sqrt(mx**2+my**2)
    if dm > ans:
        ans = dm
    
    if len(q1) == 0:
        xy2 = q2.popleft()
        q1.append(xy2)
    elif len(q2) == 0:
        xy1 = q1.popleft()
        q2.append(xy1)
    else:
        xy1 = q1[0]
        xy2 = q2[0]
        theta1 = xy1[2]
        theta2 = xy2[2]
        if theta1 + math.pi < theta2:
            q1.popleft()
            q2.append((xy1[0], xy1[1], theta1+2*math.pi))
        else:
            q2.popleft()
            q1.append((xy2[0], xy2[1], theta2))

print(ans)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    s = S()
    t = S()
    ans = 0
    for i in range(len(s)):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return


def B():
    a,b = LI()
    for i in range(10000):
        if 1+i*a-i >= b:
            print(i)
            return
    return


def C():
    n = I()
    a = LI()
    ans = 0
    r = 1
    for l in range(n):
        if r == l:
            r += 1
        while r < n and a[r-1] >= a[r]:
            r += 1
        ans = max(ans, r-l-1)
    print(ans)
    return


def D():
    n = I()
    print(n*(n-1)>>1)
    return


def E():
    def dfs(x,p):
        if dp[x] != None:
            return dp[x]
        dp[x] = -1
        for y in v[x]:
            if p[y]:
                dp[x] = float("inf")
                break
            p[y] = 1
            dp[x] = max(dp[x], dfs(y,p)+1)
            p[y] = 0
        return dp[x]

    n = I()
    a = LIR(n)
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    m = n*(n-1)
    v = [[] for i in range(m)]
    for i in range(n):
        p = n*min(i, a[i][0]) + max(i, a[i][0])
        for j in range(n-2):
            p_ = n*min(i, a[i][j+1]) + max(i, a[i][j+1])
            v[p_].append(p)
            p = p_
    dp = defaultdict(lambda : None)
    for i in range(m):
        if not v[i]:
            dp[i] = 1
    ans = 1
    p = [0]*m
    for x in range(m):
        p[x] = 1
        if ans < dfs(x,p):
            ans = dp[x]
        p[x] = 0
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return


def E_():
    n = I()
    a = LIR(n)
    for i in range(n):
        for j in range(n-1):
            a[i][j] -= 1
    m = n*(n-1)
    v = [[] for i in range(m)]
    f = [0]*m
    for i in range(n):
        p = n*min(i, a[i][0]) + max(i, a[i][0])
        for j in range(n-2):
            p_ = n*min(i, a[i][j+1]) + max(i, a[i][j+1])
            v[p].append(p_)
            f[p] += 1
            p = p_
    q = []
    for i in range(m):
        heappush(q,(f[i],i))
    if q[0][0]:
        print(-1)
        return
    d = [1 if not f[i] else -1 for i in range(m)]
    bfs = [1]*m
    while q:
        fx, x = heappop(q)
        if not bfs[x]:
            continue
        bfs[x] = 0
        for y in v[x]:
            d[y] = d[x]+1
            f[y] -= 1
            if not f[y]:
                heappush(q,(0,y))
    print(d)
    return

def F():
    n = I()
    p = LIR(n)
    p.sort(key = lambda x : math.atan2(x[1],x[0]))
    for i in range(n):
        p.append(p[i])
    ans = 0
    for i in range(n):
        d = [0,0]
        for j in range(i,n+i):
            d[0] += p[j][0]
            d[1] += p[j][1]
            dist = d[0]**2+d[1]**2
            if ans < dist:
                ans = dist
    print(ans**0.5)
    return


if __name__ == "__main__":
    F()