Computing sum on column + sum on row + sum on each diagonal
For every element, you currently sum \$n\$ elements for the row, column, diagonal and anti-diagonal, so \$4*n\$ elements.
That's a total of \$4*n^3\$ adds.

That can be improved on easily by pre-processing:


Build an array of the sums for all rows, columns, diagonals and anti-diagonals. You need \$4*n\$ space and \$4*n^2\$ adds.
Add the proper sums for each element, that's \$4\$ adds per element, for a total of \$4*n^2\$ adds.
Together, that's \$8*n^2\$ adds.


In conclusion, you can trade \$4*n\$ extra space for a speed-up by a factor of \$n/2\$.

Regarding your current code:


I cannot find anyplace you use something from &lt;set&gt;. So, why include it?
You should avoid using namespace std; It's a plague and just biding its time to bite you later.
Why is “using namespace std;” considered bad practice?

You can import selected identifiers with using std::cout;, and qualify others with std::cin.
You know you can introduce a variable in the initializer-part of the for-loop?
There's no need for a separate step to open a fstream. User the right ctor.
You noticed an error, you wrote to stderr about it, so why do you try to muddle on instead of aborting?
You never check whether input failed. Are you completely sure the input is well-formed?
Consider merging your allocations where possible. new and delete are quite costly after all.
return 0; is implicit in main().
You never free the memory you allocated. That's actually a good thing as cleaning up just for the OS to take everything down is wasted effort. Beware false positives in leak-detectors though.
I suggest a comment // m and m[0] to m[n - 1] intentionally left allocated though, in case anyone (else) later pokes around and might conceivably adopt it into a greater whole. Also shows you considered it.
You might consider investing into a class for square matrices. It's quite easy to build one.