Packing circles of a fixed diameter into a bounded square cross-section can be done in a simple square (rectangular) grid or, more efficiently, in a hexagonal (offset-row) packing, which allows more circles to fit in the same area because alternating rows can be spaced closer together (by a factor of sqrt(3)/2) than in a plain square grid.
In a simple square grid, pencils of diameter 0.5 cm placed in a 5 cm x 5 cm cross-section would allow floor(5/0.5) = 10 pencils...
Full option-by-option analysis available to enrolled students.