(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 (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
;;;
;;; Maximum bipartite matching by Ford-Fulkerson
;;;
(defun find-matching (graph)
  "Takes adjacency list and returns the maximal bipartite matching. Note that
this function doesn't check if GRAPH is bipartite."
  (declare #.OPT
           ((simple-array list (*)) graph))
  (let* ((n (length graph))
         (checked (make-array n :element-type 'bit :initial-element 0))
         (matching (make-array n :element-type 'fixnum :initial-element -1))
         (res 0))
    (declare ((integer 0 #.most-positive-fixnum) res))
    (labels ((%match (vertex) ; Returns T if VERTEX is matched.
               (setf (aref checked vertex) 1)
               (dolist (candidate (aref graph vertex))
                 (let ((partner-of-candidate (aref matching candidate)))
                   (when (or (= -1 partner-of-candidate)
                             (and (zerop (aref checked partner-of-candidate))
                                  (%match partner-of-candidate)))
                     (setf (aref matching vertex) candidate
                           (aref matching candidate) vertex)
                     (return t))))))
      (dotimes (v n (values matching res))
        (when (= -1 (aref matching v))
          (fill checked 0)
          (when (%match v)
            (incf res)))))))

(defmacro split-ints-bind (vars string &body body)
  (let ((position (gensym))
        (s (gensym)))
    (labels ((expand (vars &optional init-pos)
               (if (null vars)
                   body
                   `((multiple-value-bind (,(car vars) ,position)
                         (parse-integer ,s :start ,(or init-pos position)
                                           :junk-allowed t)
                       ,@(when (null (cdr vars)) `((declare (ignore ,position))))
                       ,@(expand (cdr vars)))))))
      `(let ((,s ,string))
         (declare (string ,s))
         ,@(expand vars 0)))))

(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)

(defmacro 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 ()
  (declare #.OPT)
  (let* ((n (read))
         (red-xs (make-array n :element-type 'uint8))
         (red-ys (make-array n :element-type 'uint8))
         (blue-xs (make-array n :element-type 'uint8))
         (blue-ys (make-array n :element-type 'uint8))
         (graph (make-array (* 2 n) :element-type 'list :initial-element nil)))
    (declare (uint8 n))
    (dotimes (idx n)
      (split-ints-bind (x y) (read-line)
        (setf (aref red-xs idx) x
              (aref red-ys idx) y)))
    (dotimes (idx n)
      (split-ints-bind (x y) (read-line)
        (setf (aref blue-xs idx) x
              (aref blue-ys idx) y)))
    (dotimes (red-idx n)
      (dotimes (blue-idx n)
        (when (and (< (aref red-xs red-idx)
                      (aref blue-xs blue-idx))
                   (< (aref red-ys red-idx)
                      (aref blue-ys blue-idx)))
          (push (+ n blue-idx) (aref graph red-idx))
          (push red-idx (aref graph (+ n blue-idx))))))
    (println (nth-value 1 (find-matching graph)))))

#-swank(main)


Measured memory_bytes: 32608