Problem:
Score : 800 points

Problem Statement

In Finite Encyclopedia of Integer Sequences (FEIS), all integer sequences of lengths between 1 and N (inclusive) consisting of integers between 1 and K (inclusive) are listed.

Let the total number of sequences listed in FEIS be X. Among those sequences, find the (X/2)-th (rounded up to the nearest integer) lexicographically smallest one.

Constraints

1 \leq N,K \leq 3 × 10^5

N and K are integers.

Input

Input is given from Standard Input in the following format:

K N

Output

Print the (X/2)-th (rounded up to the nearest integer) lexicographically smallest sequence listed in FEIS, with spaces in between, where X is the total number of sequences listed in FEIS.

Sample Input 1

3 2

Sample Output 1

2 1

There are 12 sequences listed in FEIS: (1),(1,1),(1,2),(1,3),(2),(2,1),(2,2),(2,3),(3),(3,1),(3,2),(3,3).
The (12/2 = 6)-th lexicographically smallest one among them is (2,1).

Sample Input 2

2 4

Sample Output 2

1 2 2 2

Sample Input 3

5 14

Sample Output 3

3 3 3 3 3 3 3 3 3 3 3 3 2 2

Solution in Kotlin (1.0.0) (judge verdict: Time Limit Exceeded)

fun prev(xs: IntArray, k: Int) {
  val n = xs.size
  if (xs[n - 1] > 0) {
    xs[n - 1]--
  } else {
    val p = xs.indexOfLast { it > 0 }
    xs[p]--
    if (xs[p] > 0) {
      for (i in (p + 1) until n) {
        xs[i] = k
      }
    }
  }
}

fun main(args: Array<String>) {
//  val ys = intArrayOf(3, 3, 3, 3, 3)
//  repeat(100) {
//    prev(ys, 5)
//    println(ys.asList())
//  }

  val (k, n) = readLine()!!.split(" ").map(String::toInt)

  if (k == 1) {
    val l = (n + 1) / 2
    val xs = IntArray(l, { 1 })
    println(xs.joinToString(" "))
    return
  }

  if (k % 2 == 0) {
    val xs = IntArray(n, { if (it == 0) k / 2 else k })
    println(xs.joinToString(" "))
    return
  }

  val xs = IntArray(n, { (k + 1) / 2 })
  repeat(n / 2) {
    prev(xs, k)
  }
  println(xs.filter { it > 0 }.joinToString(" "))
}