#P8467. Good Sequence Determination

    ID: 21642 Type: Default 1000ms 256MiB

Good Sequence Determination

Good Sequence Determination

Define a sequence (S = [S_1, S_2, S_3, S_4, S_5]) to be good if and only if there exists a permutation (P) of ({1,2,3,4,5}) such that [ S_{P_1} - 1 = S_{P_2} = S_{P_3} + 1 ] and [ S_{P_4} = S_{P_5}. ]

You are given an integer sequence (a = [a_1, a_2, a_3, a_4, a_5]) satisfying (0 \le a_i \le 9) for (1 \le i \le 5), where the first four elements (a_1, a_2, a_3, a_4) are provided as input. Your task is to determine whether there exists an integer (a_5) (with (0 \le a_5 \le 9)) such that the sequence (a) is good.

Note: A permutation of length 5 is defined as an ordering of the numbers (1,2,3,4,5) where each appears exactly once.

inputFormat

The input consists of a single line containing four space-separated integers (a_1, a_2, a_3, a_4).

outputFormat

Output a single line: print Yes if there exists an integer (a_5) (between 0 and 9, inclusive) that makes the sequence good; otherwise, print No.

sample

2 3 4 5
Yes