@vijju123 i think it is still there is their any other logical mistake in my code you’r reply is very helpful thank’s for you’r reply you how did you debug can you explain
Valgrind is complaining about use of uninitialized memory in lines 42, 44, 56 and 63. I’d guess your ‘i’ and ‘j/sz’ variables get bigger than 100 and you access the co and dp arrays out of bounds.
I checked for some critical values of N. Out of those, none of values of N\le 500 gave RE. The next were couple of cases with N=1000, and I got a RE immediately. Also, @schleppel 's answer might help, though I think there is something more.
When you’re stuck try writing a test case generator and compare the output of your program to one of the solutions of the contest that got AC.
When you found a test case that gets you differing output the debugging “fun” can begin.
And when this doesn’t get you anywhere clean up your code and ask here again. The code you linked is a mess. Give your variables meaningful names, not k, co, fg etc. Use standard c++ and not dirty hacks like variable length arrays (scanf("%d%d",&n,&q);int a[n]; - this is not legal c++).