Profit = TR - TC

\(\displaystyle \Pi(Q_1,Q_2) = (25Q_1+17Q_2 -2Q_1^2 -Q_2^2) - (2 + 5Q_1 + 5Q_2)\)

b.

Find the marginal costs/revenues by differentiating the total costs/revenues with respect to the output level of the relevant good.

Find maximum profit by equating marginal cost = marginal revienue in each market

Market 1:

\(\displaystyle MR_1 = 25 - 4Q_1\)

\(\displaystyle MC_1 = 5\)

\(\displaystyle 25-4Q_1 = 5\)

\(\displaystyle Q_1 = 5\)

market 2

\(\displaystyle MR_2 = 17 - 2Q_2\)

\(\displaystyle MC_2 = 5\)

\(\displaystyle 17-2Q_2 = 5\)

\(\displaystyle Q_2 = 6\)

I assume you know what a second derivative is so you should be able to do the rest yourself.

To get the price, use the fact that (Total Revenue / Quantity) = Price.