5. Twelve pencils are sharpened so that they all have different lengths. Masha wants to put the pencils in a box in two rows of 6 each, so that in each row the lengths of the pencils decrease from left to right, and each pencil in the second row lies on a longer pencil. In how many ways can she do this?

Answer: 132.
A layout of pencils that satisfies the conditions in the problem will be called correct. We will stack the pencils in a box in descending order of length. The order of placement will be recorded in the form of a broken path from the point (0,0) in a rectangular Cartesian coordinate system on a plane to the point $(6,6)$. The path will be constructed according to the following rules. If a pencil is placed in the lower row, we draw the next segment of the broken line of length 1 parallel to the Ox axis; if a pencil is placed in the second row, we draw a segment of length 1 parallel to the Oy axis. As a result, a broken path is formed consisting of 12 segments, each of which has a unit length and is parallel to one of the coordinate axes, and there are exactly 6 segments parallel to each axis. In addition, for each node with coordinates (x, y), the inequality $\mathrm{x} \geq \mathrm{y}$ holds. Such a path is also called correct, and the nodes through which a correct path can pass are called admissible. Each correct layout is uniquely associated with a correct path. The reverse is also true: each correct path is uniquely associated with a correct layout of pencils. Therefore, it is necessary to find the number of correct broken paths from the origin to the point $(6,6)$. All such paths are located within a square with a side of 6, the sides of which lie on the coordinate axes or are parallel to them. We will draw a square, marking the nodes of the coordinate grid. Admissible nodes are marked with a circle, in which we will place the number of possible continuations of the path from the marked node to the end. The node with coordinates $(6,6)$, corresponding to the end of all correct paths, is marked with the number 1.

The rule for filling in subsequent values: in the marked node ( $x, y)$, we place a number equal to the sum of the numbers in the nodes ( $x+1, \mathrm{y})$ and ( $x, y+1)$, if these nodes are admissible. The filling of the diagram occurs sequentially from the top right corner to the bottom left. The filled diagram is shown in the figure.

![](https://cdn.mathpix.com/cropped/2024_05_06_d8efe70e6e1aeb491532g-4.jpg?height=871&width=874&top_left_y=1358&top_left_x=320)

The number 132 in the lower left corner of the figure is the answer to the problem.