codeforces round 360, task B with bug fix (long longs git add . :-( )