# What's wrong with my solution?

``````vector<long long> CL,CR;
map<int,int> m;
const int mod=1000000007;
vector<int> Solution::solve(vector<int> &arr, vector<int> &B) {
m.clear();
CL.clear();
CR.clear();
CL.resize(arr.size(),0);
CR.resize(arr.size(),0);
stack<int> s;
for (int i = 0; i < arr.size(); i++) {
while (s.size() != 0 && arr[s.top()] <= arr[i]) {
CL[i] += CL[s.top()] + 1;
s.pop();
}
s.push(i);
}
while (s.size() != 0)
s.pop();

for (int i = arr.size() - 1; i >= 0; i--) {
while (s.size() != 0 && arr[s.top()] < arr[i]) {
CR[i] += CR[s.top()] + 1;
s.pop();
}
s.push(i);
}
while (s.size() != 0)
s.pop();
for(int i=0;i<arr.size();i++)
{
CL[i]=(CL[i]+1)*(CR[i]+1);
}
for(int i=0;i<arr.size();i++)
{
long long p=1;
for(int j=1;j*j<=arr[i];j++)
{
if(arr[i]%j==0)
{
p=(p*(j%mod))%mod;
if((arr[i]/j)!=j)
{
p=(p*((arr[i]/j)%mod))%mod;
}
}
}
if(m.find(p)==m.end())
{
m[p]=CL[i];
}
else
{
m[p]+=CL[i];
}
}
vector<int> v,f;
for(auto p:m)
{
v.push_back(p.first);
}
reverse(v.begin(),v.end());
for(int i=0;i<v.size();i++)
{
f.push_back(m[v[i]]);;
}
for(int i=1;i<f.size();i++){
f[i]+=f[i-1];
}
vector<int> ans;
for(int i=0;i<B.size();i++)
{
int ind=lower_bound(f.begin(),f.end(),B[i])-f.begin();
ans.push_back(v[ind]);
}
return ans;

}``````