added code and sample input