File size: 523 Bytes
1fd0050
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    long long k;
    if (!(cin >> k)) return 0;

    if (k == 1) {
        cout << 1 << "\n";
        cout << "HALT PUSH 1 GOTO 1\n";
        return 0;
    }

    long long n = min<long long>(k, 512);
    cout << n << "\n";

    for (long long i = 1; i < n; ++i) {
        cout << "POP 1 GOTO " << (i + 1) << " PUSH 1 GOTO " << (i + 1) << "\n";
    }
    cout << "HALT PUSH 1 GOTO 1\n";

    return 0;
}