Different output on coding blocks ide and ubuntu

I am getting different output on coding blocks ide(as compared to my ubuntu os)-

#include
#include
#include<math.h>
#include
#include
using namespace std;

/*void bs(long long int a[],long long int n){
int freq;
freq=new int[3];
for(int i=0;i<3;i++)
freq[i]=0;
for(long long int i=0;i<n;i++)
freq[a[i]]++;
for(int i=0;i<3;i++){
for(int j=0;j<freq[i];j++)
cout<<i<<endl;
}
}
/
bool cmp(string str1,string str2){
if( (str1.length()>str2.length() && str1.substr(0,str2.length())==str2) || (str1.length()<str2.length() && str2.substr(0,str1.length())==str1) )
return str1.length()>str2.length();
return str1<str2;
}

int main(){
/*long long int n,*a;
cin>>n;
a = new long long int[n];
for(long long int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n,cmp);
for(long long int i=0;i<n;i++)
cout<<a[i]<<endl;
*/
int n;
cin>>n;
cin.ignore();
string *str;
str = new string[n];
for(int i=0;i<n;i++)
getline(cin,str[i]);
sort(str,str+n,cmp);
for(int i=0;i<n;i++)
cout<<str[i]<<endl;
return 0;
}

Hey Anish, can you mention the problem’s exact name also share the online ide link of your code here, so that we can help you in debugging and tell you the reason why its happening.