Problem:
Score : 400 points

Problem Statement

Given are three integers N, K, and S.

Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below.
We can prove that, under the conditions in Constraints, such a sequence always exists.

There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.

Constraints

1 \leq N \leq 10^5

0 \leq K \leq N

1 \leq S \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K S

Output

Print a sequence satisfying the condition, in the following format:

A_1 A_2 ... A_N

Sample Input 1

4 2 3

Sample Output 1

1 2 3 4

Two pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.

Sample Input 2

5 3 100

Sample Output 2

50 50 50 30 70

Solution in Haskell (GHC 7.10.3) (judge verdict: Wrong Answer)

import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.Vector as VC
import qualified Data.Vector.Mutable as VM

readNums :: IO [Integer]
readNums = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readNumLists :: Int -> IO [[Integer]]
readNumLists n = replicateM n (map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine)

readStrings :: IO [String]
readStrings = map BS.unpack . BS.words <$> BS.getLine

readStringLists :: Int -> IO [[String]]
readStringLists n = replicateM n (map BS.unpack . BS.words <$> BS.getLine)

toTuple :: [a] -> (a, a)
toTuple (x:y:_) = (x, y)

main :: IO ()
main = do
  (n:k:s:_) <- readNums
  putStrLn $ unwords $ map show (solve (fromIntegral n) (fromIntegral k) (fromIntegral s))

solve n k s = take n (core ++ [s + 1] ++ mods ++ repeat (s + 1))
  where
    coreLen = floor $ sqrt $ fromIntegral k
    modLen = k - coreLen ^ 2
    core = replicate (coreLen - 1) 0 ++ [k] ++ replicate (coreLen - 1) 0
    mods
      | even modLen = s : replicate ((modLen - 2) `div` 2) 0 ++ [s]
      | otherwise = s : replicate ((modLen - 2) `div` 2) 0 ++ [s, s]
--  (n:_) <- readNums
--  xl <- map toTuple <$> readNumLists (fromIntegral n)
--  print $ solve n xl
--
--solve :: Num a => a -> [(a, a)] -> a
--solve n xl = 1
--  where
--    f :: Num a => [(a, a)] -> [(a, a)] -> [(a, a)]
--    f acc xss@(x1:x2:x3:xs)
--      | length xss == 2 = acc ++ [x2]
--      | isCommon x1 x2 && isCommon x2 x3 = f acc (tail xss)
--      | otherwise = f (acc ++ [x2]) (tail xss)
--    isCommon a b
--      | distance >= armDistance = False
--      | otherwise = True
--      where
--        distance = fst b - fst a
--        armDistance = snd a + snd b