MAXSPPROD linear algorithm
I finally spotted the error in my submission : I was computing the maximum of left-most * right-most mod 1000000007 while I should have been computing the maximum  of left-most * right-most, then returning its value modulo 1000000007.

In other terms 

int mp = 0;
std::stack&lt;int&gt; stack;
for(int i = 0; i &lt; v.size(); ++i){
    int j = next_bigger(v, stack, i );

    int mp_i = mult_mod(j, r[i]);
    if (mp &lt; mp_i){
        mp = mp_i;
    }
}
return mp;


Should be replaced by 

long long int mp = 0;
std::stack&lt;int&gt; stack;
for (int i = 0; i &lt; v.size(); ++i)
{
    long long int j = next_bigger(v, stack, i);
    long long int mp_i = j * r[i];
    if (mp &lt; mp_i)
    {
        mp = mp_i;
    }
}
return mp % 1000000007;