Why Ceuta and Melilla are splitted in two districts? Their population is too small and it makes no sense. They are autonomous cities, not provinces.
Well, I treated them as though they were provinces. In which case, they have a population very similar to Soria, so all 3 end up entitled to 2 districts.
When dividing the 298 seats proportionally, you end up with Ceuta and Melilla both entitled to something like 0.52 seats, which rounded up to 1, plus the extra minimum seat means they get 2.
At least Soria has a sizeable territory, while Ceuta and Melilla are tiny enclaves in the Moroccan coast. Personally I would have not splitted the autonomous cities, nor provinces like Soria. The effects of malapportionment can be as damaging as gerrymandering.
Another question, given that you are making a FPTP simulation, why are you calculating block results? It would make sense in a two-round system (see France), but under FPTP the candidates usually run for parties and coalitions, not for "the left" or "the right". A different question is that certain parties agree to run together. like PP+Cs in the Basque Country elections