MineLayer is a Minesweeper style puzzle played on an R by C grid. Each square of the grid holds one mine or no mine at all. A MineLayer puzzle is a grid of numbers, and each number is the total number of mines in every square adjacent to that square plus the square itself. A number is therefore between 0 and 9.
The goal is to find a mine layout that matches the given numbers.
Below is a 3 by 4 grid. The original layout is on the left and the puzzle is on the right.

One grid of numbers can match several layouts, so find the largest number of mines the middle row can hold. The number of rows is always odd, so the middle row is row (R+1)/2 from the top. Every puzzle has at least one solution.