void merge_two_vec(vector<int> &vec1,vector<int> &vec2,vector<int> &result)
{
int i , j =0;
while(i<vec1.size()&&j<vec2.size()){
if(vec1[i]<vec2[j]){
result.push_back(vec1[i]);
i++;
}
else{
result.push_back(vec2[j]);
j++;
}
}
for(;i<vec1.size();i++)
result.push_back(vec1[i]);
for(;j<vec2.size();j++)
result.push_back(vec2[j]);
}
void merge_sort(vector<int> &vec){
if(vec.size()<2)
return;
int mid = vec.size()/2;
vector<int> vec1;
vector<int> vec2;
for(int i=0;i<mid;i++)
vec1.push_back(vec[i]);
for(int i=mid;i<vec.size();i++)
vec2.push_back(vec[i]);
merge_sort(vec1);
merge_sort(vec2);
vec.clear();
merge_two_vec(vec1,vec2,vec);
}