/* written by Pankaj Kumar. country:-INDIA */ #include #include #include using namespace std; using namespace __gnu_pbds; typedef long long ll ; typedef vector vl; #define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0); // define values. // #define mod 1000000007 #define phi 1.618 /* Abbrevations */ #define ff first #define ss second #define mp make_pair #define line cout<>arr[i]; // Some print #define no cout<<"NO"<>test;while(test--) // sort #define all(V) (V).begin(),(V).end() #define srt(V) sort(all(V)) #define srtGreat(V) sort(all(V),greater()) #define printv(v) for(ll i=0;i0) { if(y%2==1) { res*=x; // res=res%mod; } y/=2; x*=x; // x=x%mod; } return res; } // datatype definination #define ordered_set tree,rb_tree_tag,tree_order_statistics_node_update> /* ascii value A=65,Z=90,a=97,z=122 */ /* -----------------------------------------------------------------------------------*/ ll solve() { ll n; cin>>n; vl v(n); forin(v,n); stack> st; vl ans; for(ll i=0;iv[i]) ans.pb(abs(st.top().ss-i)); else { while(st.size()>0&&st.top().ff<=v[i]) st.pop(); if(st.size()==0) ans.pb(0); else ans.pb(abs(st.top().ss-i)); } st.push({v[i],i}); } printv(ans); return 0; } int main() { speed; cout<<"Stack span problem"<