I have an Excel table with three columns. Column A has a list of countries, Column B has a list of cities in each country and Column C has populations of those cities.
The way the table is structured makes it so that Column A will have repeated names of countries - as many times as the number of cities in each country, in column B.

I would like to sum the populations of the first five cities in each country.

I have tried using `SUMIF` and `COUNTIF` but haven't managed to do it. How can I sum the populations (in row C) of the first five cities appearing for each country?