union on tree memory error:(

my algorithm run in maximum of O(n^2)…
but show SIGSEGV error in C then how could I remove that error ?
do int work for value <=50000 in gcc compiler used by codechef?

how and where should I declare array of a[n][n] where n<=50000