At last!
![](https://habrastorage.org/webt/yi/qz/sd/yiqzsdpph_djhubu-0n16oe8ady.png)
The problem is 65A - Harry Potter and Three Spells, if you're curious.
Apparently, thinking before coding helps.
What is the longest it took you to upsolve a problem?