@l_returns has an awesome and easy to understand solution.
But if you are looking for a recursive solution then you can have a look at this solution.
@shivamchef
unordered set means it completely unordered… adding one element can change order of all other elements…
So if you insert elements while you are using for each loop then there will be lot of mess…
https://www.codechef.com/viewsolution/24082696
here is your AC solution
check this code and you’ll understand the problem…
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main() {
FIO;
int t,n,k,i,j;
unordered_set<int> v;
v.insert(0);
v.insert(5);
v.insert(8);
for(auto it:v)
cout << it << " ";
cout << endl;
v.insert(4);
for(auto it:v)
cout << it << " ";
cout << endl;
v.insert(10);
for(auto it:v)
cout << it << " ";
cout << endl;
return 0;
}
Karma Farming 
I think there are 3 levels and vijju is on 3rd one… I am on 2nd one… XD
Now i think i wont get to 3rd level…
exactly… got it XD… never mind…
that’s very bad @taran_1407 … @vijju123 may ban both of them… be careful XD…
Off-topic level --> infinity

thanks for the solution 


… (Need 20 characters)
Lol,I never knew that top-contributors get laddus

They used to get laddus… Now people don’t get it…
How can I know my trust level? I cannot see it anywhere 
You are member… 2nd level…
Really a important lesson on unordered Set . it’s looking like you saved me from 10s of future WA.
Now, I have 3rd-level of trust 
I’ve gained super-saiyyan abilities on Codechef-discuss 
Haha really ? Is that the third level ? How to achieve that ?
You need magical super powers … if you don’t have them, then you need to convince the ‘Chef’ that you deserve those magical powers…and he’ll give it to you 




Maybe I should try convincing pseudo admin @vijju123 ( credits to @aryanc403 for calling him that) for giving me trust level three… 
How to gain it be a secret then.