Lunchtime Cube

http://ideone.com/UPBg42 . Why am i getting segmentation fault . Should have passed the first two sub cases . Some one help me . Fine on my comipler segmentation on codechef