You're going to have to do better than just dumping your code.
Like for example
- a link to the actual problem.
- the input you provide to the program.
> int a[n][m];
1. C++ doesn't allow variable length arrays.
2. If m,n are large, you could be blowing up the stack.
If m * n * sizeof(int) is much larger than say 1MB, you could be stuck.
> for(int i = 0; i < n; i++){
> for(int j = 0; j < m; j++){
From past observation, most CF problems require you to sit down and think of a smart way to solve the problem.
And not go for the obvious brute-force "try everything" approach.