Sigmod Programming Contest 2013 submission