I am getting different output for this problem. While using C++14, I am getting 50 instead of 42 in second subtask of test case 1 (My submission- 94759038). But I am getting correct answer on my pc, other online IDE link and if I use C++17. Can somewhat point out what is causing this unusual behaviour so that I can avoid it in the future.
Note: Though my logic is not correct for whole problem, it should pass the 1st test case.