#K73137. Zigzag Word Length Pattern

    ID: 33909 Type: Default 1000ms 256MiB

Zigzag Word Length Pattern

Zigzag Word Length Pattern

You are given a sequence of words. A sequence is said to form a zigzag pattern if the lengths of the words strictly alternate between increasing and decreasing. In other words, for every three consecutive words with lengths \( a, b, c \), it must hold that either \( a c \) or \( a > b < c \). If the sequence contains fewer than two words, it is automatically considered to be zigzag.

Examples:

  • The sequence "a code of great fun" forms a zigzag because \(1 2 3\), so the output is yes.
  • The sequence "this is not zigzag" does not form a zigzag pattern, so the output is no.

Your task is to read a line from standard input, determine if the word sequence is zigzag, and print yes or no accordingly.

inputFormat

Input is read from standard input. A single line contains zero or more words separated by spaces. An empty input represents an empty sequence.

outputFormat

Print a single line to standard output which is either yes if the sequence forms a valid zigzag pattern or no otherwise.

## sample
a code of great fun
yes