#C14405. Substring Combinations

    ID: 44051 Type: Default 1000ms 256MiB

Substring Combinations

Substring Combinations

Given a string s and an integer k, your task is to output all distinct contiguous substrings of s that have exactly k characters. The substrings should appear in the same order as their first occurrence in s.

If k is less than or equal to 0, greater than the length of s, or if s is an empty string, then no output should be produced.

Note: Each substring must be printed on a separate line.

inputFormat

The input consists of two lines:

  1. The first line contains the string s.
  2. The second line contains an integer k.

You can assume that the string does not contain any extraneous whitespace.

outputFormat

Print each distinct substring of length k on a separate line in the order of their first occurrence in s. If there are no valid substrings, do not print anything.

## sample
abcabc
3
abc

bca cab

</p>