When the limits are small, the simplest correct program is the whole solution: try every option. Before you write the loops, count the steps for the largest input — if it is well under 10⁸, go ahead.
Two problems are here; the other eight are on Codeforces and AtCoder, the two biggest judges for competitive programming, and are submitted there. Their statements are in English (and Japanese, on AtCoder).
- First write down what you try — every pair, every floor, every 3 × 3 grid — and how many options that is.
- The product of three numbers up to 30 000 reaches 2.7 · 10¹³:
long long. - Наибольшее произведение has its statement in Russian only.