apple pie's submission of Balanced Reversals | CodeChef