Source Code
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define t int t;cin>>t; while(t--)
#define out(a,n) for(int i=0;i<n;i++){cout<<a[i]<< " ";}
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
using namespace std;
using pll = pair<ll, ll>;
void fun(int x)
{

    if (x==1)
    {
        cout<<"-"<<endl;
        return;
    }
    fun(x-1);
    for (int i=0; i<x; i++)
        cout<<"-";
    cout<<endl;
    fun(x-1);
}
int main ()
{
    FAST;
    // t
    {
        ll l,p;
        cin>>l>>p;
        for (int i=0; i<=l; i++)
        {
            for (int j=0; j<p; j++)
            {
                cout<<"-";
            }
            cout<<i<<endl;
            if (i==l)
                return 0;
            fun(p-1);

        }



    }

}
Copy
Ruler Ann_Sam65
GNU G++17
207 ms
262.1 MB
Memory Limit Exceeded