Codeforces Round #151 Problem C Beauty Pageant