Please help me to find the error in this below code
#include
#include<bits/stdc++.h>
using namespace std;
bool comp (string a, string b)
{
if (a.length()>=b.length() && a.substr(0,b.length())==b)
{
return true;
}
else if (b.length()>a.length() && b.substr(0,a.length())==a)
{
return false;
}
else
{
return a<b;
}
}
int main()
{
vector a;
int n;
cin>>n;
if(n==0)
{
return 0;
}
if(n<0)
n=n*-1;
for (int i=1; i<=n;i++ )
{
string s;
cin>>s;
a.push_back(s);
}
sort(a.begin(), a.end(), comp);
for (int i=0; i<=a.size()-1; i++)
{
string m = a[i];
cout<<m<<",";
}
return 0;
}