OP has a point..
"bags of 5" really could be interpreted as "an arbitrary number of sets such that each set is defined S_sub(n) = {1,1,1,1,1}" i.e an order of 5. This is fairly ridiculous being an invalid set!
There is simply no way to deduce the total discrete subsets in a set of candy such that C = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
Each of the above sets are mathematically identical. that is, C = {1} and each discrete sets S_sub(n) = {1}
that this point all we can be sure of is the problem has something to do with a single piece of candy.
it may then be more useful to interpret the wording "bag" as a multiset as represent the outcome as such
• • • • •|• • • • •|• • • • •|• • • • •|• • • • •|• • • • •|• • • • •|• • • • •
i.e a multiset of cardinalityk= 40 made up of elements of a set of cardinalityn= 5
which is pretty clear we are dealing with 8 bags and it even looks like bags of candy if you squint.