Problems from Nordic Collegiate Programming Contest (NCPC) 2008, adapted from Andrew Stankevich Contest 17, Petrozavodsk, February 2, 2006