String sort problem in challenges STL

the code is failing in first test case

#include
#include
#include
using namespace std;
bool comp(string a, string b){
if(b.size() >= a.size() && b.substr(0, a.size()) == a)return false;

else if(a.size() >= b.size() && a.substr(0, b.size()) == b)return true;

else return a<b;

}
int main() {

int n;
cin>>n;
cin.get();
string a[100];

for(int i =0;i<n;i++){
        getline(cin, a[i]);
}
sort(a, a+n, comp);
for(int i =0;i<n;i++){
        cout<<a[i]<<endl;;
}

return 0;

}

hello @Username_cb it was a very small mistake i have made the change and commented it out .
please check the constraints and you will be able to find your error . https://ide.codingblocks.com/s/322203

I hope i have cleared your doubt .
Happy Learning !!

thanks, it worked well.

hey @Username_cb as you have said that your doubt is resolved so you can mark this doubt as resolved now and do hit the like button .
Happy Learning !!

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.