True that a big part of the cost is absorbing the costs of failed drugs, but most of it is in clinical trials, which is normally past the academia setting.
If I had to guess, a tiny tiny percent of all potential drugs make it to clinical trails. So again, now you're looking at 1 in 10,000. You're only looking at the 1, ignoring the 9,999, and saying "look pharma pays for all of it!"
How much research at unis ends up being completely worthless from a pharmaceutical product perspective? Almost all of it. But how many products began based on research conducted at universities? ... all of them.