Runtime (Or Memory) Error

So I’m doing the problem described here, but for some reason it says “Execution killed with signal 9” on some test cases. I have done stress testing for around 500 test cases, with all of them having the maximum bounds, and none of them have produced the same result that the judge gives me.

Can I have a pointer as to where I went wrong with my code?

You’re exceeding the memory limit.

Oh yeah, thanks for the help! Didn’t notice that.