Let me make an example (with numbers I just invented):
Coffee A and Coffee B have two additional ingredients, let us say milk and sugar, and for simplicity we assume that both ingredients have a food energy content of 4 kcal/g. Large A and large B have exactly the same amount of 41.6 g of these ingredients (when filled exactly to training by an average-strength Starbucks employee at 20 deg C and 1013 mbar air pressure).
Large A has 20.8 g of sugar and 20.8 g of milk. This gets rounded up to 21 g + 21 g = 42 g, which equals 168 kcal.
Large B has 20.3 g and 21.3 g of each. After rounding this becomes 20 g + 21 g = 41 g -> 164 kcal
We now say the small versions are exactly half of that:
Small A: 10.4 g + 10.4 g -> 10 g + 10 g = 20 g -> 80 kcal
Small B: 10.3 g + 10.65 g -> 10 g + 11g = 21 g -> 84 kcal
So you have large A > large B, but small A < small B, although they have exactly the same energy content and exactly the same rounding rule is applied.