/* Problem URL: https://codeforces.com/contest/961/problem/D */ #include #include #include using namespace std; using namespace __gnu_pbds; template > using ordered_set = tree; #define V vector #define rmin(a, b) a = min(a, b) #define rmax(a, b) a = max(a, b) #define rep(i, lim) for (int i = 0; i < (lim); i++) #define nrep(i, s, lim) for (int i = s; i < (lim); i++) #define repv(i, v) for (auto &i : (v)) #define fillv(v) for (auto &itr_ : (v)) { cin >> itr_; } #define sortv(v) sort(v.begin(), v.end()) #define all(v) (v).begin(), (v).end() using vi = vector; using vvi = vector; using vvvi = vector; using vvvvi = vector; using ll = long long; using vl = vector; using vvl = vector; using vvvl = vector; using vvvvl = vector; template auto operator<<(ostream &os, const vector &vec)->ostream& { os << vec[0]; for (size_t i = 1; i < vec.size(); i++) { os << ' ' << vec[i]; } os << '\n'; return os; } template auto operator>>(istream &is, vector &vec)->istream& { for (auto &i : vec) { is >> i; } return is; } template auto operator<<(ostream &os, const vector> &vec)->ostream& { for (auto &i : vec) { os << i[0]; for (size_t j = 1; j < i.size(); j++) { os << ' ' << i[j]; } os << '\n'; } return os; } template auto operator>>(istream &is, vector> &vec)->istream& { for (auto &i : vec) { for (auto &j : i) { is >> j; } } return is; } // Geometria typedef long long ld; const ld DINF = 1e18; const ld pi = acos(-1.0); const ld eps = 1e-9; #define sq(x) ((x)*(x)) bool eq(ld a, ld b) { return abs(a - b) <= eps; } struct pt { // ponto ld x, y; pt(ld x_ = 0, ld y_ = 0) : x(x_), y(y_) {} bool operator < (const pt p) const { if (!eq(x, p.x)) return x < p.x; if (!eq(y, p.y)) return y < p.y; return 0; } bool operator == (const pt p) const { return eq(x, p.x) and eq(y, p.y); } pt operator + (const pt p) const { return pt(x+p.x, y+p.y); } pt operator - (const pt p) const { return pt(x-p.x, y-p.y); } pt operator * (const ld c) const { return pt(x*c , y*c ); } pt operator / (const ld c) const { return pt(x/c , y/c ); } ld operator * (const pt p) const { return x*p.x + y*p.y; } ld operator ^ (const pt p) const { return x*p.y - y*p.x; } friend istream& operator >> (istream& in, pt& p) { return in >> p.x >> p.y; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; if (n <= 3) { cout << "YES\n"; return 0; } V a(n); cin >> a; V group(n); V invalid(n); auto iscol = [&](pt a, pt b, pt c) { return (b.y - a.y) * (c.x - b.x) == (c.y - b.y) * (b.x - a.x); }; auto check = [&]() { int first = 0; while (group[first]) { first++; } int second = first + 1; while (group[second]) { second++; } rep(i, n) { if (group[i]) { continue; } if (!iscol(a[first], a[second], a[i])) { return false; } } return true; }; int c = 0; rep(i, n) { if (iscol(a[0], a[1], a[i])) { group[i] = true; } else { c++; } } if (c <= 2 || check()) { cout << "YES\n"; return 0; } fill(all(group), false); c = 0; rep(i, n) { if (iscol(a[0], a[2], a[i])) { group[i] = true; } else { c++; } } if (c <= 2 || check()) { cout << "YES\n"; return 0; } fill(all(group), false); c = 0; rep(i, n) { if (iscol(a[1], a[2], a[i])) { group[i] = true; } else { c++; } } if (c <= 2 || check()) { cout << "YES\n"; return 0; } cout << "NO\n"; }