lbin :: V.Vector (P.Vector Word8)
(bin, lbin) = runST $ do
  mbin  <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  mlbin <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  F.forM_ [0.._N] $ \i -> do
    mbini <- V.unsafeIndexM mbin i
    PM.unsafeWrite mbini 0 1
    PM.unsafeWrite mbini 1 1
    PM.unsafeWrite mbini i 1
    mlbini <- V.unsafeIndexM mlbin i
    PM.unsafeWrite mlbini 0 0
    PM.unsafeWrite mlbini 1 0
    PM.unsafeWrite mlbini i 0
  F.forM_ [1.._N+1] $ \j ->
    F.forM_ [j+1.._N+1] $ \i -> do
      mbinim1 <- V.unsafeIndexM mbin (i - 1)
      mbini   <- V.unsafeIndexM mbin i
      bx <- PM.unsafeRead mbinim1 (j-1)
      by <- PM.unsafeRead mbinim1 j
      let bz = bx + by
      PM.unsafeWrite mbini j bz
      mlbini <- V.unsafeIndexM mlbin i
      PM.unsafeWrite mlbini j (bits bz)
  xs <- V.forM mbin P.unsafeFreeze
  ys <- V.forM mlbin P.unsafeFreeze
  return (xs,ys)

-- | The sortBy below could be replaced with judicious use of <http://alexbowe.com/popcount-permutations/>
-- to reduce startup times.
lbin :: V.Vector (P.Vector Word8)
(bin, lbin) = runST $ do
  mbin  <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  mlbin <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  F.forM_ [0.._N] $ \i -> do
    mbini <- V.unsafeIndexM mbin i
    PM.unsafeWrite mbini 0 1
    PM.unsafeWrite mbini 1 1
    PM.unsafeWrite mbini i 1
    mlbini <- V.unsafeIndexM mlbin i
    PM.unsafeWrite mlbini 0 0
    PM.unsafeWrite mlbini 1 0
    PM.unsafeWrite mlbini i 0
  F.forM_ [1.._N+1] $ \j ->
    F.forM_ [j+1.._N+1] $ \i -> do
      mbinim1 <- V.unsafeIndexM mbin (i - 1)
      mbini   <- V.unsafeIndexM mbin i
      bx <- PM.unsafeRead mbinim1 (j-1)
      by <- PM.unsafeRead mbinim1 j
      let bz = bx + by
      PM.unsafeWrite mbini j bz
      mlbini <- V.unsafeIndexM mlbin i
      PM.unsafeWrite mlbini j (bits bz)
  xs <- V.forM mbin P.unsafeFreeze
  ys <- V.forM mlbin P.unsafeFreeze
  return (xs,ys)

-- | The sortBy below could be replaced with judicious use of <http://alexbowe.com/popcount-permutations/>
-- to reduce startup times.
(bin, lbin) = runST $ do
  mbin  <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  mlbin <- V.replicateM (_N+2) $ PM.replicate (_N+2) 0
  F.forM_ [0.._N] $ \i -> do
    mbini <- V.unsafeIndexM mbin i
    PM.unsafeWrite mbini 0 1
    PM.unsafeWrite mbini 1 1
    PM.unsafeWrite mbini i 1
    mlbini <- V.unsafeIndexM mlbin i
    PM.unsafeWrite mlbini 0 0
    PM.unsafeWrite mlbini 1 0
    PM.unsafeWrite mlbini i 0
  F.forM_ [1.._N+1] $ \j ->
    F.forM_ [j+1.._N+1] $ \i -> do
      mbinim1 <- V.unsafeIndexM mbin (i - 1)
      mbini   <- V.unsafeIndexM mbin i
      bx <- PM.unsafeRead mbinim1 (j-1)
      by <- PM.unsafeRead mbinim1 j
      let bz = bx + by
      PM.unsafeWrite mbini j bz
      mlbini <- V.unsafeIndexM mlbin i
      PM.unsafeWrite mlbini j (bits bz)
  xs <- V.forM mbin P.unsafeFreeze
  ys <- V.forM mlbin P.unsafeFreeze
  return (xs,ys)

-- | The sortBy below could be replaced with judicious use of <http://alexbowe.com/popcount-permutations/>
-- to reduce startup times.