I submitted this code for this challenge https://www.codechef.com/problems/CHEFCHR and got a SIGSEGV fault though the code works fine on my VS 2017 - though I don't have an input file with 200000 lines
Codechef use GCC 6.3 with O2 lm fomit-frame-pointer pthread
If input.size() == 4 then input[j+4] is out of bounds when j == 0.
If input.size() < 3 then input.size()-3 will wrap around and become a very large value (because input.size() returns an unsigned type) so the loop condition will be true and the loop will run and access string elements out of bounds, until it probably crashes.