spoj-WA in problem STREETR

The link to my code is http://ideone.com/MKIvsk
please tell me why it is giving Wrong Answer.