Source Code
#include <bits/stdc++.h>

using namespace std;

#define cin(vec) for(auto& i : vec) cin >> i
#define cin_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> vec[i][j]; j++);
#define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
#define cout_2d(vec, n, m) for(int i = 0; i < n; i++, cout << "\n") for(int j = 0; j < m && cout << vec[i][j] << " "; j++);
#define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
#define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" << "\n";
#define fixed(n) fixed << setprecision(n)
#define ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
#define fill(vec, value) memset(vec, value, sizeof(vec));
#define Num_of_Digits(n) ((int)log10(n) + 1)
#define mod_combine(a, b, m) (((a % m) * (b % m)) % m)
#define all(vec) vec.begin(), vec.end()
#define rall(vec) vec.rbegin(), vec.rend()
#define sz(x) int(x.size())
#define debug(x) cout << #x << ": " << (x) << "\n";
#define fi first
#define se second
#define Pair pair < int, int >
#define ll long long
#define ull unsigned long long
#define Mod  1'000'000'007
#define OO 2'000'000'000
#define EPS 1e-9
#define PI acos(-1)

void CP_IO(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    #endif
}

string dashes[11] = {"","-","--","---","----","-----","------","-------","--------","---------","----------"};
string Print[11]={"","-\n","","","","","","","","",""};

string print(int p){
    if(Print[p].size() == 0) Print[p] = print(p - 1) + dashes[p] + '\n' + print(p - 1);
    return Print[p]; 
}

void Solve(){
    int l, p;
    cin >> l >> p;
    for(int i = 0; i < l; i++){
        cout << dashes[p] << i << '\n';
        cout << print(p - 1);
    }
    cout << dashes[p] << l;
}

int main(){
    CP_IO();
    int t = 1;
    //cin >> t;
    while(t--)
        Solve();
    return 0;
}
Copy
Ruler R0X
GNU G++17
4 ms
1.2 MB
Runtime Error