CSES - A31 Generalized VByte
  • Time limit: 1.00 s
  • Memory limit: 512 MB

Implement a generalized version VByte encoding and decoding, that supports setting the size of the payload per block at run time.

The binary needs to support the "-s" command line flag, that indicates that the input is sorted and differences between subsequent numbers should be stored instead of numbers themselves.

The binary needs to support the "-k <k>" command line argument, that sets the size of the block payload to k. I.e -k 7, would be standard VByte, with one byte per block (7 for payload and one stop bit).

Input

A binary input stream, consisting of 64-bit unsigned integers. The first integer, n, is how many additional integers are in the input.

Output

After encoding the n integers, output to cerr the number of blocks used to encode the input, after this, repeate back the input sequence.

Constraints

  • n << 10^8
  • k < 56

Example

Input:

With k = 4

2, 7, 500

(in 64-bit binary)

Output:

4, 7, 500

I.e. The number of blocks = 4, followed by the input integers 7 and 500.