;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-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)

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(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

(defun main ()
  (let* ((n (read))
         (xs- (make-array n :fill-pointer 0 :element-type 'int32))
         (xs0 (make-array n :fill-pointer 0 :element-type 'int32))
         (xs+ (make-array n :fill-pointer 0 :element-type 'int32))
         (ys- (make-array n :fill-pointer 0 :element-type 'int32))
         (ys0 (make-array n :fill-pointer 0 :element-type 'int32))
         (ys+ (make-array n :fill-pointer 0 :element-type 'int32)))
    (dotimes (i n)
      (let ((x (read-fixnum))
            (y (read-fixnum))
            (d (read-char)))
        (ecase d
          (#\R
           (vector-push-extend x xs+)
           (vector-push-extend y ys0))
          (#\L
           (vector-push-extend x xs-)
           (vector-push-extend y ys0))
          (#\U
           (vector-push-extend x xs0)
           (vector-push-extend y ys+))
          (#\D
           (vector-push-extend x xs0)
           (vector-push-extend y ys-)))))
    (let ((xmax+ (reduce #'max xs+ :initial-value most-negative-fixnum))
          (xmax- (reduce #'max xs- :initial-value most-negative-fixnum))
          (xmax0 (reduce #'max xs0 :initial-value most-negative-fixnum))
          (ymax+ (reduce #'max ys+ :initial-value most-negative-fixnum))
          (ymax- (reduce #'max ys- :initial-value most-negative-fixnum))
          (ymax0 (reduce #'max ys0 :initial-value most-negative-fixnum))
          (xmin+ (reduce #'min xs+ :initial-value most-positive-fixnum))
          (xmin- (reduce #'min xs- :initial-value most-positive-fixnum))
          (xmin0 (reduce #'min xs0 :initial-value most-positive-fixnum))
          (ymin+ (reduce #'min ys+ :initial-value most-positive-fixnum))
          (ymin- (reduce #'min ys- :initial-value most-positive-fixnum))
          (ymin0 (reduce #'min ys0 :initial-value most-positive-fixnum)))
      (let ((cands (list (* 0.5d0 (- xmax- xmax+))
                         (* 0.5d0 (- xmin- xmin+))
                         (* 0.5d0 (- ymax- ymax+))
                         (* 0.5d0 (- ymin- ymin+))
                         (- xmax- xmax0)
                         (- xmax0 xmax+)
                         (- xmin- xmin0)
                         (- xmin0 xmin+)
                         (- ymax- ymax0)
                         (- ymax0 ymax+)
                         (- ymin- ymin0)
                         (- ymin0 ymin+))))
        (println
         (loop for time in cands
               minimize
                  (let ((time (max 0d0 (float time 1d0))))
                    (* (- (max (- xmax- time) (+ xmax+ time) xmax0)
                          (min (- xmin- time) (+ xmin+ time) xmin0))
                       (- (max (- ymax- time) (+ ymax+ time) ymax0)
                          (min (- ymin- time) (+ ymin+ time) ymin0))))))))))

#-swank(main)


Measured memory_bytes: 26468