Miniature Algebraic Natural Relay (also called MALNAR
) is the latest technological advancement in the
flourishing realm of small programmable devices. You can write your own programs for this device using
MalnarScript, an esoteric programming language with the following set of features:
- Input to the program is a single non-negative integer strictly less than .
- Output of the program is a single non-negative integer strictly less than .
- When programming in MalnarScript you can only use one -bit unsigned integer variable . At the beginning of the program, this variable holds the input and its value at the end of the program is considered to be the program's output.
- The source code of MalnarScript must consist of at most commands of the form
A=<expr>
which are executed in order and each of them must consist of at most a thousand characters. The symbol<expr>
is defined recursively as follows:<expr> = A | <num> | (<expr><operator><expr>)
In other words, symbol <expr>
can either be a variable , or it can conform to the definition of symbol
<num>
, or it can (inside parentheses) represent a two-membered expression in which each operand conforms
to the same <expr>
definition.
The symbol <num>
in the definition above represents a non-negative decimal integer strictly less than ,
while the symbol <operator>
can either be +
, -
, |
, &
, <<
or >>
which (in order) represent the operations
of addition, subtraction, bitwise or, bitwise and, left shift and right shift.
Also the character A
can appear at most times in the <expr>
symbol.
In the case of overflow or underflow when performing the operations of addition and subtraction, MalnarScript will perform those operations modulo . For example, when the expression will evaluate to and the expression will evaluate to 5 in MalnarScript.
The right side of the equation in each command evaluates into a single number which will then be stored into . In order to evaluate the right hand side expression, MalnarScript first replaces each occurrence of with its current value. The calculation of expression then proceeds as it would in any mathematical expression, i.e., the parentheses take precedence. Note that the priorities of operators (in term of operation order) are irrelevant because the final result is completely defined by placement of parentheses.
Your task is to write a program which outputs a program in MalnarScript which calculates the number of ones in a binary representation of the input value.
Input
The first line contains two integers and from the task description.
Output
In the first line you should output the number of commands of the produced MalnarScript program.
In the remaining lines you should output the commands of the sought program. Each command must be printed in a separate line and must satisfy the syntax of MalnarScript as described in the task description.
It is important that there are no unnecessary empty lines or extra whitespace characters in the output.
Each line (including the last) must be terminated by the end-of-line character (\n
).
Scoring
Subtask | Score | Constraints |
---|---|---|
1 | 15 | |
2 | 15 | |
3 | 35 | |
4 | 45 |
Sample Input 1
2 2
Sample Output 1
1
A=(A-((A&2)>>1))
Explanation For Sample 1
Sample Input 2
3 5
Sample Output 2
2
A=((A&4)|((A&3)-((A&2)>>1)))
A=((A&3)+((A&4)>>2))
Comments