My code is giving error

This

#include <bits/stdc++.h>

using namespace std;

bool compare(string a, string b){

if(a.size() > b.size()){
return (a.substr(0,b.size()) == b);
}
else if(a.size() < b.size()){
return (b.substr(0,a.size()) == a);
}

return (a>=b);

}

int main(){

int n;
cin >> n;
cin.get();


vector <string> v(n);



for(int i=0;i<n;i++){
	getline(cin,v[i]);
}

sort(v.begin(),v.end(),compare);

for(auto s : v){
	cout << s << endl;
}


return 0;

}

@rohitgarg025 please share your code by saving it on cb ide

also since space separated input is given, why are you taking input with getline? it will store ALL the values inside a single string. If you want to separate them just use cin

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.