Undefined behaviour

Okay… great !!

Great. Thanks everyone for looking into this. Also, Can I now use the header bits/stdc++.h blindly ignoring these links (c++ - Why should I not #include <bits/stdc++.h>? - Stack Overflow) as long as the compiler supports it?

Yes, you can.

1 Like

There is no issue with bits/stdc++ for purpose of CP since you don’t need to worry about the compile time :stuck_out_tongue:

1 Like

@algmyr So basically, this varies from compiler to compiler as the compilers are not set to produce results for a false(invoking undefined behaviour) code…right?

Behavior may or may not be different in different compilers, or even for the same code snippet in different circumstances using the same compiler. Point is you can’t really assume anything as soon as you introduce UB into the program.

In the case you had, compiling with “-fstack-protector-all -fsanitize=address” and testing against a few cases would probably have showed you that something was wrong. Try running your old code with the flags I mentioned on the case:

1
2
1 1