Nested loops shouldn't cause an MLE, unless memory is being allocated within the loops and not freed, or something like that. And that's not happening here.
It might be the size of your arrays - the maximum number of cows and canes is given as 2.10^5, or 200,000. The array items are 64 bit values so each array could be 1.6MB. That might be bigger than your compiler allows for local variables, in which case you can try making them static. For example, instead of:
This moves the array out of relatively limited stack memory - it has other effects too, but you don't need to worry about that for now.
Regarding optimisation (won't affect MLE), you don't need 3 levels of nested loop - the inner loop, and statcane, can be removed. Instead, for each cane keep a record of the height of its top and bottom off the ground. The top's height is read in from the file and is fixed, but the bottom moves up as the cane is eaten.
For each cow eating a cane, work out how much of the cane will be eaten this time. If the bottom of the cane is above the cow, then none will be eaten - the cow can't reach it. But if the cow is above the bottom of the cane, it will either eat all of the cane if the cow is also above the top of the cane, or as much of the cane as it can reach if the top of the cane is above the cow.
After working out how much will be eaten, just move the bottom of the cane up by that amount, and increase the cow's height by the same amount (increase heightcow, you don't need finalcow).
Let us know if that helps (and correct the bugs mentioned earlier).