O(N3) giving TLE


#1

expected complexity is N2 or N3?
my N3 solution is giving TLE.