At the start, 500g of coffee is roughly 570 degrees above absolute zero, and EACH 500g of ice water is roughly 490 degrees above absolute zero. There are two of these batches of ice water, so it took twice as much heat energy to warm the whole quantity of ice water to this temperature. The ice water holds more heat energy than the smaller amount of hot coffee has.