MAXAND18 - passing only the less constrained test cases...?

My initial submission https://www.codechef.com/viewsolution/34806943 got AC only on the second subtask.

I use a custom C# template with I/O code that benchmarked slightly faster than the obvious I/O on a data-heavy practice task, but which likes to throw exceptions if the input data doesn’t meet expectations…

As it’s NZEC (rather than WA), I supposed it might be weird test input that works ok with other answers using C++ cin/cout mechanisms, so spent a little while trying to refactor the code to deal with non-conforming input on a test case before moving on to a different problem.

Is it a problem with my code, or with the test data?

Self-answer: it was a problem with my code.

I tried to multiply the values by 2 in order get the loop limit, and find a bit which resulted in a higher value, which for a value at or close to 10^9 can overflow an int, meaning the loop never terminated, and tried to populate the result array beyond its limit.

Wasted too much time trying to debug the wrong thing.