why WA IN TWTCLOSE

I have submitted the solution with two solutions

http://www.codechef.com/viewsolution/5478918
http://www.codechef.com/viewsolution/5478914

first one give WA and second one give AC . But only difference is that i am converting int to long long int in first case , does it make any difference . Can any body explain it to me .

thanks in advance,

alt text

As you are declaring ans as int and using a wrong format specifier in printf(), it leads to an undefined behavior, and thus a garbage value is been printed.