Source Code
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define printv(x) for(int i : x) cout << i << " "; cout << endl;

#define fl(x) for(int i = 0 ; i < x.size(); i++ )
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl

void dash(int p ) {
    for (int i = 0; i < p; ++i) {
        cout << '-';
    }
}

vector<int> count(int p ) {
    if(p == 1) {
        return {1};
    }

    vector<int> t = count(p- 1);
    vector<int> x(t.size() * 2 +1 );

    for (int i = 0; i <t.size(); ++i) {
        x[i] = t[i];
    }
    x[t.size()] = p ;

    for (int i = t.size() +1; i < t.size() * 2 + 1; ++i) {
        x[i] = t[i - t.size()- 1];
    }

    return x ;
}


void solve() {
    int l , p ;
    cin >> l  >> p ;



    for(int i = 0 ; i < l ; i++) {
        dash(p);
        cout << i << endl;

        for (int i = 1; i <= pow(2, p- 1) -1; ++i) {
            int x = i ;
            int s = 1 ;

            while(x % 2 != 1) {
                x = x >>  1;
                s++;
            }

            dash(s) ;
            cout << endl;
        }
    }

    dash(p);
    cout << l << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//    int t ; cin >> t; while(t--) solve();
    solve();

    return 0;

}
Copy
Ruler iMrOmarX
GNU G++17
11 ms
960 KB
Accepted