Problem link - KFOLD - https://www.codechef.com/COOK121B/problems/KFOLD.

My solution - https://www.codechef.com/viewsolution/37109035

I believe the time complexity of my code is O ( T*(N + 3*K + N/2*K ) ) ,

where T<=100 and K<=N <=1000 . I believe it should run within 1 sec . Please help me find out my mistake !

Edit - I commented the same thing on the main editorial of this problem but no one replied, so had to create this thread