;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t)
  #-swank (set-dispatch-macro-character
           #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;;;
;;; Body
;;;

(defconstant +eps+ 1d-9)

(defun solve (n xs ys)
  (declare ((simple-array double-float (*)) xs ys)
           (uint32 n))
  (dbg xs ys)
  (let ((phases (make-array (* 2 n) :element-type 'double-float))
        (ords (make-array (* 2 n) :element-type 'uint32)))
    (dotimes (i (* 2 n))
      (setf (aref ords i) i))
    (dotimes (i n)
      (setf (aref phases i) (atan (aref ys i) (aref xs i))
            (aref phases (+ i n)) (+ (* 2 pi) (aref phases i))))
    (setf ords (sort ords (lambda (i j)
                            (< (aref phases i) (aref phases j)))))
    #>ords
    (let ((res 0d0))
      (declare (double-float res))
      (labels ((hypot (x y)
                 (declare (double-float x y))
                 (sqrt (+ (* x x) (* y y))))
               (calc (rot)
                 (dotimes (base n)
                   (let* ((base-v (aref ords base))
                          (base-phase (aref phases base-v))
                          (xsum 0d0)
                          (ysum 0d0))
                     (declare (double-float xsum ysum))
                     (loop for i from base below (+ base n)
                           for new-v = (aref ords i)
                           for new-phase = (aref phases new-v)
                           while (<= (- new-phase base-phase) rot)
                           do (dbg base i base-phase new-phase)
                              (incf xsum (aref xs new-v))
                              (incf ysum (aref ys new-v)))
                     (setq res (max res (hypot xsum ysum)))
                     (decf xsum (aref xs base-v))
                     (decf ysum (aref ys base-v))
                     (setq res (max res (hypot xsum ysum)))))))
        (calc (+ pi +eps+))
        res))))

(defun main ()
  (let* ((n (read))
         (xs (make-array (* 2 n) :element-type 'double-float))
         (ys (make-array (* 2 n) :element-type 'double-float)))
    (dotimes (i n)
      (let* ((x (float (read) 1d0))
             (y (float (read) 1d0)))
        (setf (aref xs i) x
              (aref xs (+ i n)) x
              (aref ys i) y
              (aref ys (+ i n)) y)))
    (let ((res 0))
      (setq res (max res (solve n xs ys)))
      (dotimes (i (* 2 n)) (setf (aref xs i) (- (aref xs i))))
      (setq res (max res (solve n xs ys)))
      (println res))))

#-swank (main)


Measured memory_bytes: 26852