What is the error in my code?

The error is in the loop
for(auto str: s ) { cout<<s<<endl; }
Instead, it should be cout<<str<<endl; because each element of the set is iterated as str.
Here is the updated code.