#include #include #include #include using namespace std; bool is_kadomatsu(int a, int b, int c) { if (a == b || b == c || c == a) { return false; } return max({a, b, c}) == b || min({a, b, c}) == b; } int main() { vector d(7); for (int i = 0; i < 7; i++) { cin >> d[i]; } sort(d.begin(), d.end()); int ok; do { ok = true; for (int i = 0; i < 5; i++) { if (d[i] < d[i+2] && is_kadomatsu(d[i], d[i+1], d[i+2])) { } else { ok = false; break; } } } while (!ok && next_permutation(d.begin(), d.end())); cout << (ok ? "YES" : "NO") << endl; return 0; }