I enjoyed this puzzle. I do have a couple of suggestions:
-
Line 1 of input contains n–the number of species that you have, and line 2 has a blank-delimited list of that many species. However, it is very odd (and completely arbitrary) that the following n lines contain part names with respective part counts. There is no reason why the number of listed parts should be the same as the number of listed species. Either n should be the number of listed parts and the number of species should be inferred by parsing the species line, or the number of parts should be provided separately.
-
I went to some lengths to provide a solution that would find the unique integer solution (since you cannot have a fraction of a cow or a chicken). There are many examples of possible inputs for which there is only one unique correct solution but for which the problem is underconstrained without the integer constraint. I was disappointed to find after submitting my solution that there were other submitted solutions that passed all verifiers that simply solved a system of linear equations–a much simpler problem. There should definitely be verifier cases that have only one unique integer solution but for which there is no unique solution without the integer constraint. Without this the problem definitely does not belong in the very hard category.