This one is a bit weird, I don’t like posting a lot about my problems here but I’m really stuck on this one. Can’t really spot the error in the problem I was solving today (it’s THOUSES), here’s the link to my submission:

https://www.codechef.com/viewsolution/48906139

EDIT: It disappears when I remove the vector part in calc function. But I don’t get why.

But I can’t spot a case in which I’m accessing non-existent memory. I’d appreciate any form of help, thanks.