Segmentation fault in Matrix search

Here is my code for matrix search in sorted matrix.
Although i am able to pass all the test cases but its still showing

/bin/run.sh: line 4: 18 Segmentation fault (core dumped) ./exe

This error

Your code is fine.
int arr[n][m]; instead of this, you can allocate array dynamically or use large enough size as this kind of declaration is not supported in earlier C++ versions.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.