There are many ways to extend the patent or the effect of the patent: https://www.upcounsel.com/how-long-does-a-drug-patent-last
A good example is Lipitor. For Pfizer it brought in over $11B per year in revenue. Cost was around $150 per month. You can now get a month’s supply for $5.94 according to GoodRx. That’s a 96% reduction in the cost.