HISTOGRA - Largest Rectangle in a Histogram [spoj]

I am trying to solve the spoj problem “HISTOGRA” with the help of stack , when i submit it on spoj getting wrong , can anyone help me to find what is the problem ?

problem link: https://www.spoj.com/problems/HISTOGRA/

code link: https://ideone.com/dKrEOa