Rosetta Problems

Two Contests

https://atcoder.jp/contests/agc040/tasks/agc040_b