How do i optimise this code?

https://ide.codingblocks.com/s/312908 How do i solve this with the limit on the size of the dp array?

@tusharnitharwal
Statically allocating dp is too much for 1e4*1e4, you can use dynamic allocation by using vectors.
Check https://ide.codingblocks.com/s/312971

Another thing. If I instead use a bitset, and declare it like bitset<16> b, what would be the size of this bitset?

I tried creating a dynamic array but it says this:

/bin/run.sh: line 4: 18 Killed ./exe

It runs fine on my device offline