I’m posting the sources for my submissions for GCJ 2012, they proved correct for the large inputs too which ranked me on 2730 out of 18365(HUGE participation this year!). The source for 4th question is not here, because I didn’t do it. The questions in this contest were the best quality questions in a competition that I’ve participated, very well organized and automated. What am I talking about? its Google, so it should be like this. So here‘s the code, and yes I use Netbeans. I find it awesome for C++, if you don’t agree, well try it. Unlike some people I don’t have the brains to keep the whole STL on my head. And Netbeans auto completion is just the best I’ve seen. MSVS is already out of the list because it needs me to do non-standard stuff. I still don’t find Emacs and VIM making my coding super fast but I’d like to learn how these some what old beasts are preferred by a lot of top coders, and most in production environments.