The array has a large size up to 100000 and m is number of gets.
For example:
int array[] = {1, 2, 2, 3, 4, 5, 5, 5, 6, 7};
get(1, 4, array);
And the result:
1: 1
2: 2
3: 1
I wrote this but it uses a lot of memory:
for (int i=1; i<=n; i++) {
ma[a[i]]++;
pref[i] = ma;
}
map<int,int> ans = pref[r];
for (auto i: pref[l - 1]) {
ans[i.first] -= i.second;
}
for (auto i: ans) {
cout << i.first << ' ' << i.second << '\n';
}