comb :: Int -> Int -> [Int] -> [([Int],[Int])]
comb s _ xs | s < 0 = []
comb s 0 xs | s == 0    = [([],xs)]
            | otherwise = []
comb _ _ [] = []
comb s k (x:xs) = [ (x:ys,zs) | (ys,zs) <- comb (s-x) (k-1) xs ]
                ++[ (ys,x:zs) | (ys,zs) <- comb s     k     xs ]

comb' :: Int -> Int -> [Int] -> [([Int],[Int])]
comb' s 0 xs | s == 0    = [([],xs)]
             | otherwise = []
comb' _ _ []             = []
comb' s k (x:xs) = [ (x:ys,zs) | (ys,zs) <- comb (s-x) (k-1) xs ]
