Code chef problem implementation