Digital Dictionary doubt

#include
#include
#include
using namespace std;
bool compare(string a,string b)
{
if(a.size()==b.size())
{
return a<b;
}
else
return a<b;
}
int main()
{
int n;
cin>>n;
string s[n];
for(int i=0;i<n;i++)
{
cin>>s[i];
}
int q;
cin>>q;
for(int i=0;i<q;i++)
{
vector v;
string p;
cin>>p;
for(int j=0;j<n;j++)
{
if(s[j].substr(0,p.size())==p)
{
v.push_back(s[j]);
}
}
if(v.empty())
{
cout<<“No suggestions”<<endl;
}
else
{
sort(v.begin(),v.end(),compare);
for(int i=0;i<v.size();i++)
{
cout<<v[i]<<endl;
}
}
}
}

giving wrong output during submission

I have attached sample input and output for this problem.
Run your program for those inputs and resolve the problem that is producing wrong outputs.

https://drive.google.com/open?id=1RWnyrLfDFce3Qi_9THQYCN_PvL-AhuUm

Hopefully, this would help.

I can’t able to detect error in my code

Have you checked the output, is it coming the same?
Try to find the pattern that is common in the wrong output. Then, solve for that

Have you resolved it yourself or should i help you with your code?

You have not responded to this thread for 6 days.
Please, mark it as resolved if you have solved it yourself.
Else, let me know.

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.