Rosetta Problems

IOIOI

https://atcoder.jp/contests/joi2009ho/tasks/joi2009ho_a