Supply demand problem

https://hack.codingblocks.com/contests/c/489/265

My submissions : https://ide.codingblocks.com/#/s/22942

https://ide.codingblocks.com/#/s/29642
^I have marked some errors that I saw, hope it helps