void divide(vector<int>& nums, vector<int>& ans, vector<int>& d, vector<vector<int> >& temp, int start, int end) {
if (start == end) return;
divide(nums, ans, d, temp, start, (start+end)/2);
divide(nums, ans, d, temp, (start+end)/2+1, end);
int i = start, j = (start+end)/2+1, k = start;
while (i <= (start+end)/2 || j <= end) {
if (i == (start+end)/2+1) j++;
else if (j == end+1) i++;
else if (nums[i] > nums[j]) {
i = start, j = (start+end)/2+1;
while (i <= (start+end)/2 || j <= end) {
if (i == (start+end)/2+1) {
temp[0][k] = nums[j]; temp[1][k] = ans[j]; temp[2][k] = d[j];
temp[0][k] = nums[i]; temp[1][k] = ans[i]; temp[2][k] = d[i];
} else if (nums[i] > nums[j]) {
temp[0][k] = nums[i]; temp[1][k] = ans[i]; temp[2][k] = d[i];
temp[0][k] = nums[j]; temp[1][k] = ans[j]; temp[2][k] = d[j];
for (int l = start; l <= end; l++) {
nums[l] = temp[0][l]; ans[l] = temp[1][l]; d[l] = temp[2][l];
vector<int> countSmaller(vector<int>& nums) {
vector<int> ans, d, final, no;
vector<vector<int> > temp;
if (nums.size() == 0) return ans;
temp.push_back(no); temp.push_back(no); temp.push_back(no);
for (int i = 0; i < nums.size(); i++) {
ans.push_back(0); d.push_back(i); final.push_back(0);
temp[0].push_back(0); temp[1].push_back(0); temp[2].push_back(0);
divide(nums, ans, d, temp, 0, nums.size()-1);
for (int i = 0; i < nums.size(); i++) final[d[i]] = ans[i];