On giving k=4 in custom input it is working correctly.But gives a run time error on submitting for same case(k=4).