You are executing 1 iteration less than required.
The reason is that, suppose input as-
4
65
566
11
1623455078
It can be represented as-
4\n
65\n
566\n
11\n
1623455078\n
The newline character after 4 gets caught by your string and is used in first iteration of T, giving a blank new line. This also leads to last string not getting executed. Hence, WA.
Try taking that newline char by using scanf("%d%c",&T,&ch);
1 Like