For this Question: You are given an array A of size N. For each of the indices i (1 &le; i &le; N), find the the smallest index j such that i < j and the frequency of A<sub>i</sub> is lesser than or equal to that of A<sub>j</sub> in the array.

<b>Note</b>
Consider 1-based indexingThe first line of the input contains a single integer N.
The second line of the input contains N space-separated integers.

<b>Constraints:</b>
1 &le; N &le;10<sup>5</sup>
1 &le; A<sub>i</sub> &le; 10<sup>5</sup>For each of the indices i (1 &le; i &le; N), print the smallest index j such that i < j and the frequency of A<sub>i</sub> is lesser than or equal to that of A<sub>j</sub> in the array. If there is no such index j, print -1 for that particular index i.Sample Input:
7
1 2 3 3 3 1 1

Sample Output:
3 3 4 5 6 7 -1

<<b>Explanation:</b>
For,
i = 1, j = 3
i = 2, j = 3
i = 3, j = 4
i = 4, j = 5
i = 5, j = 6
i = 6, j = 7
i = 7, no such j exists, I have written this Solution Code: #include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for(auto &i : a) cin >> i, mp[i]++;
    for(auto &i : a) i = mp[i];
    stack<pair<int, int>> s;
    vector<int> ans(n, -1);
    for(int i = 0; i < n; i++){
        while(s.size() > 0 && s.top().first <= a[i]){
            ans[s.top().second] = i + 1;
            s.pop();
        }
        s.push({a[i], i});
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << ' ';
    }
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?