My code is not working for several test cases

#include
#include
#include
#include
#include
using namespace std;

int isSubstring(string s1, string s2)
{
// using find method to check if s1 is
// a substring of s2
if (s2.find(s1) != string::npos)
return s2.find(s1);
return -1;
}
void check_func(long long num,vector&res){
if(num==0||num==1){
return ;
}
if(num==2 ||num==3 ||num==5 ||num==7 ||num==11||num==13||num==17||num==19||num==23||num==29){
//cout<<“Number is”<<num<<" “;
res.push_back(to_string(num));
//count=count+1;
}
else if( num%2!=0 && num%3!=0 && num%5!=0 && num%7!=0 && num%11!=0 && num%13!=0 && num%17!=0 && num%19!=0 && num%23!=0 && num%29!=0){
//cout<<“Number is”<<num<<” ";
res.push_back(to_string(num));
//count=count+1;
}

}
int main() {
int l;
cin>>l;
string s;
cin>>s;
int count=0;
setnumbers;
vectorres;
for (int i = 0; i < s.size(); i++)
{
string subStr="";
for (int j = i; j < s.size(); j++)
{
subStr += s[j];
long long num=stoi(subStr);
numbers.insert(num);
}
}
for(auto num:numbers)
{
check_func(num,res);
}
if(res.size()>1){
for(int i=0;i<res.size();i++){
for(int j=i+1;j<res.size();j++){
int p=isSubstring(res[i], res[j]);
if(p==-1){
count++;
}

	}
	
}
}
else{
	count=res.size();
}

cout<<count<<endl;


return 0;

}

hi @riagoel3999,
According to the Problem the work is to find the Max CB numbers from the given number.

•As to work on substrings of the given number, we will capture the element into the String instead of integer .
•The number ‘n’ given is nothing to do with our approach(as we are working on String) but can be useful acoording to your approach.

Intuition :
•Put loop on string that will give substring of every length.
•create a function that will return true if the passed number is a CB number otherwise return false.
•To put a check if the digit is already a part of the any other CB number, create an boolean array say, valid which store which digits till now has been a part of any other CB number.
•Take a counter and increment if a CB number is found.
•At the end print the count.
refer this code ->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I understood your solution but i dont understand why is my solution giving wrong answer. Here is my solution: https://ide.codingblocks.com/s/671263

Can u please reply I sent you the code

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.