I’m unsure what is causing an error that I cannot replicate on my machine. Could you please guide me on what this is.
Code:
#include <bits/stdc++.h>
#include
//#include <ext/pb_ds/tree_policy.hpp>
//PBDS
//#include <ext/pb_ds/assoc_container.hpp>
//typedef tree<pii, null_type, less<pii>, rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//using namespace __gnu_pbds;
#define pb push_back
#define sz(x) ((int)(x).size())
#define fastIO() {ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);}
#define rep(i, n) for (int i = 0; i < (n); i++)
#define vrep(x, v) for (auto x : v)
#define all(n) n.begin(), n.end()
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
bool comp(string s1, string s2){
if(s1.length()<s2.length())swap(s1,s2);
// cout<<s1.substr(0, s2.length())<<'\n';
if(s1.substr(0, s2.length())==s2)return true;
return s1<s2;
}
int main() {
fastIO();
int n;
cin>>n;
vector<string> v1(n);
rep(i,n)cin>>v1[i];
sort(all(v1), comp);
for(auto i:v1)cout<<i<<"\n";
return 0;
}

