from random import randint D = 1431655766 def f(X: int): T = [X, 1] + [0] * 98 def p(i, j, k): print(f'plus {i} {j} {k}') T[i - 1] = T[j - 1] + T[k - 1] def d(i, j): print(f'div {i} {j}') T[i - 1] = T[j - 1] >> 1 offa = 4 p(offa, offa, 1) for i in range(1, 31): p(offa + i, offa + i - 1, offa + i - 1) posa = 3 for bit in range(31): if (D >> bit) & 1: p(posa, posa, offa + bit) for _ in range(32): d(posa, posa) assert T[2] == X // 3 f(randint(0, 10 ** 9))