import itertools
import sys
xs = list(map(int, input().split()))
for ps in itertools.permutations(xs, len(xs)):
    kc = []
    bs = []
    for i in range(0, len(ps) - 2):
        slice = ps[i:i + 3]
        if len(set(slice)) == 3 and (max(slice) == slice[1] or min(slice) ==
            slice[1]):
            kc.append(True)
        else:
            kc.append(False)
        bs.append(slice[0] < slice[2])
    if all(kc) and all(bs):
        print('YES')
        sys.exit()
print('NO')

3d8bbe7d4dd0fabe8d26eb1a5e27486c1e4d6843
<mask token>

<mask token>
for ps in itertools.permutations(xs, len(xs)):
    kc = []
    bs = []
    for i in range(0, len(ps) - 2):
        slice = ps[i:i + 3]
        if len(set(slice)) == 3 and (max(slice) == slice[1] or min(slice) ==
            slice[1]):
            kc.append(True)
        else:
            kc.append(False)
        bs.append(slice[0] < slice[2])
    if all(kc) and all(bs):
        print('YES')
        sys.exit()
print('NO')

<mask token>
xs = list(map(int, input().split()))
for ps in itertools.permutations(xs, len(xs)):
    kc = []
    bs = []
    for i in range(0, len(ps) - 2):
        slice = ps[i:i + 3]
        if len(set(slice)) == 3 and (max(slice) == slice[1] or min(slice) ==
            slice[1]):
            kc.append(True)
        else:
            kc.append(False)
        bs.append(slice[0] < slice[2])
    if all(kc) and all(bs):
        print('YES')
        sys.exit()
print('NO')

import itertools
import sys
xs = list(map(int, input().split()))
for ps in itertools.permutations(xs, len(xs)):
    kc = []
    bs = []
    for i in range(0, len(ps) - 2):
        slice = ps[i:i + 3]
        if len(set(slice)) == 3 and (max(slice) == slice[1] or min(slice) ==
            slice[1]):
            kc.append(True)
        else:
            kc.append(False)
        bs.append(slice[0] < slice[2])
    if all(kc) and all(bs):
        print('YES')
        sys.exit()
print('NO')
