Code runs well in ide but giving segmentation error while submiting

My code is giving error while runs well in local and online ide. https://ide.codingblocks.com/s/231149

@ayusdas2000
Your code is giving Wrong ans since you haven’t print final ans%MOD. Just after line 62, write res[i]%=MOD;
Your code will work
https://ide.codingblocks.com/s/269837
here is the updated code