Run time Error in Google Kick Start Round G 2020

Yesterday, I had participated in Google Kick Start and submitted my solution, but it show RE while sample cases are passed successfully.

I have also try my code on "ideone " for sample cases.

Anyone who find some error or bug in my code please make me it noted.

Problem Statement:

My solution:

#include <bits/stdc++.h>
using namespace std;

int main(){
    int tc,m,n,fs;
    string s;
    string s1="KICK",s2="START";
    for(int i=0;i<tc;i++){
        for(int j=0;j<s.size()-3;j++)
            if(,4)) == 0){
            if(,5)) == 0 && j<s.size()-4){
        cout<<"Case #"<<i+1<<": "<<n<<endl;

s.substr is getting out of bound
j<s.size()-4 should come before s2.compareā€¦ because for ex cond1&&cond2&&cond3 the order is from cond1 to cond2

can someone check my code for problem no. 3, Combination Locks, no idea where it is failing. I have used Binary Search+Prefix Sum, help would be appreciated.Thanks!
Code :