;; -*- 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)

(declaim (inline hypot))
(defun hypot (x y)
  (sqrt (+ (* x x) (* y y))))

(defun scan-anticlockwise (n xs ys)
  (declare ((simple-array double-float (*)) xs ys)
           (uint32 n))
  (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)))))
    (let ((res 0d0))
      (declare (double-float res))
      (labels ((calc-max! (phase-width)
                 (dotimes (i n)
                   (let* ((base-vec (aref ords i))
                          (base-phase (aref phases base-vec))
                          (xsum 0d0)
                          (ysum 0d0))
                     (declare (double-float xsum ysum))
                     (loop for j from i below (+ i n)
                           for new-vec = (aref ords j)
                           for new-phase = (aref phases new-vec)
                           while (<= (- new-phase base-phase) phase-width)
                           do (incf xsum (aref xs new-vec))
                              (incf ysum (aref ys new-vec)))
                     (setq res (max res
                                    (hypot xsum ysum)
                                    ;; exclude the base vector
                                    (hypot (- xsum (aref xs base-vec))
                                           (- ysum (aref ys base-vec)))))))))
        (calc-max! (+ 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 (scan-anticlockwise n xs ys)))
      ;; reflect all the points to scan them clockwise
      (dotimes (i (* 2 n)) (setf (aref xs i) (- (aref xs i))))
      ;; (setq res (max res (scan-anticlockwise n xs ys)))
      (println res))))

#-swank (main)


Measured memory_bytes: 27104