The sample test case runs fine but on submitting all test cases are giving wrong answer
Wrong answer while submitting
@sanyam_13 the logic of your code is correct. character arrays and get, getline etc can behave quite unpredicatably sometimes so its better to use string datatype.