#include <bits/stdc++.h>
#include "registers.h"
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000'000'000'000'000'000LL;
const int II = 2'000'000'000;
const ll M = 1000'000'007LL;
const int N = 1000'007;
int n, k, m = 100, siz = 2000;
vector<bool> xv;
void HandleNP()
{
    ++n;
    vector<bool> xd(siz, 0);
    for(int l = n * k; l < n * k + k; ++l)
        xd[l] = 1;
    append_store(1, xd);
    append_or(0, 0, 1);
}
void DoBegin()
{
    vector<bool> v1(siz, 1), vp(siz, 0), vp2(siz, 0);
    append_store(m - 2, v1);
    for(int i = 0; i < n; ++i)
            vp[i * k + i + k] = 1;
    append_store(m - 4, vp);
    for(int i = 0; i < n; ++i)
        for(int j = i * k + i; j < i * k + i + k; ++j)
            vp2[j] = 1;
    append_store(m - 3, vp2);
}
void Get(int a, int pos)
{
    append_left(pos, 0, siz - (a + 1) * k);
    append_right(pos, pos, siz - k);
}
void Compare(int a, int b)
{
    Get(a, 1); Get(b, 2); 
    append_not(2, 2); 
    append_xor(1, 1, m - 4);
    append_add(3, 1, 2);
    append_xor(1, 1, m - 4);
    append_not(2, 2);
    append_and(3, 3, m - 4); 
    int d = 1;
    while(d < k + 1)
    {
        append_right(4, 3, min(d, k + 1 - d));
        append_or(3, 3, 4);
        d = min(d * 2, k + 1);
    }
    append_and(3, 3, m - 3);
    append_not(4, 3);
    append_and(4, 4, m - 3);
    append_and(5, 1, 3);
    append_and(6, 2, 4);
    append_or(7, 5, 6); //max;
    append_and(5, 1, 4);
    append_and(6, 2, 3);
    append_or(8, 5, 6); //min;
    append_xor(1, 1, 8);
    append_xor(2, 2, 7);
    append_left(1, 1, a * k);
    append_left(2, 2, b * k);
    append_xor(0, 0, 1);
    append_xor(0, 0, 2);
}
void construct_instructions(int _s, int _n, int _k, int _q)
{
    n = _n; k = _k;
    DoBegin();
    for(int i = n - 2; i >= 0; --i)
        Compare(i, i + 1);
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |