My solutions for Facebook Hackercup 2013, Qualifying Round