matlab code for CUMCM 2013 problem B