Problem:
D: Many Points
問題
二次元平面上に $N$ 個の点があります。それぞれには $1$ から $N$ までの番号がついており、$i$ 番目の点 $p_i$ の座標は $(x_i, y_i)$ です。異なる番号がつけられた二つの点が重なることはありません。
あなたはこれらの $N$ 個の点全てからのユークリッド距離が等しい直線 $L$ を引きたいです。より形式的には、点 $p_i$ と直線 $L$ との距離を $d(p_i, L)$ と表記するとき、$d(p_1, L) = d(p_2, L) = \ldots = d(p_N, L)$ となる直線 $L$ を求めたいです。
しかし、そのような直線が常に存在するわけではありません。
$T$ 個のテストケースに対して、条件を満たす直線が存在するか判定してください。
入力形式
入力は複数のテストケースからなります。$1$ 行目にはテストケースの数 $T$ が与えられます。
各テストケースの形式は以下の通りです。
$N$
$x_1$ $y_1$
$x_2$ $y_2$
...
$x_N$ $y_N$
制約
入力は全て整数で与えられる
$1 \leq T \leq 30$
$1 \leq N \leq 2 \times 10^4$
$-10^9 \leq x_i, y_i \leq 10^9$
$i \neq j$ ならば $x_i \neq x_j$ または $y_i \neq y_j$ が成り立つ
出力形式
$T$ 行出力してください。$i$ 行目には $i$ 番目のテストケースに対する出力をしてください。
条件を満たす直線が存在する場合は
Yes
、存在しない場合は
No
と出力してください。
入力例1
2
3
-1 -1
1 -1
1 1
5
-1 -1
1 -1
1 1
-1 1
0 0
出力例1
Yes
No
この入力の 1 つ目のテストケースでは直線 $x = 0$ や $y = 0$ が条件を満たします。
2 つ目のテストケースでは条件を満たす直線は存在しません。

Submitted solutions:

code_snippet: // AOJ #3167 Many Points
// 2025.4.7

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int Cin() {
	int n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void Couts(const string &s) { for (char c : s) pc(c); pc('\n'); }

struct P { ll x, y; };
P diff(const P &p, const P &q) { return {q.x - p.x, q.y - p.y}; }
ll cross(ll ax, ll ay, ll bx, ll by) { return ax * by - ay * bx; }

int main(){
    int T = Cin();
    while(T--){
        int n = Cin();
        vector<P> pts(n);
        for (int i=0; i<n; i++) pts[i].x = Cin(), pts[i].y = Cin();
        if(n <= 2) { Couts("Yes"); continue; }

        bool col = true;
        P d0 = diff(pts[0], pts[1]);
        for (int i=2; i<n; i++){
            P d1 = diff(pts[0], pts[i]);
            if(cross(d0.x, d0.y, d1.x, d1.y) != 0){
                col = false;
                break;
            }
        }
        if(col) { Couts("Yes"); continue; }

        bool ok = false;
        int lim = min(n, 10);
        for (int i = 0; i < lim && !ok; i++){
            for (int j = i+1; j < lim && !ok; j++){
                ll dx = pts[j].x - pts[i].x;
                ll dy = pts[j].y - pts[i].y;
                for (int k = 0; k < 2 && !ok; k++){
                    ll cx, cy;
                    if(k == 0){ cx = dx; cy = dy; }
                    else { cx = dy; cy = -dx; }
                    if(cx == 0 && cy == 0) continue;
                    unordered_set<ll> S;
                    S.reserve(n*2);
                    for(auto &p : pts){
                        ll f = cx * p.x + cy * p.y;
                        S.insert(f);
                        if(S.size() > 2) break;
                    }
                    if(S.size() <= 2){
                        ok = true;
                        break;
                    }
                }
            }
        }
        Couts(ok? "Yes": "No");
    }
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3968
final_rank: 2

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 998244353;
const int inf = (1<<30);

const int dy[4] = {-1,0,0,1};
const int dx[4] = {0,-1,1,0};

#define double long double
#define equals(a,b) (fabs((a)-(b)) < EPS)

namespace geometry {
    const double EPS = 1e-10;
    const double PI = asinl(1) * 2;

    struct Point {
        double x,y;
        Point(){}
        Point(double x, double y):x(x),y(y){}
        Point operator+(Point p) {return Point(x+p.x,y+p.y);}
        Point operator-(Point p) {return Point(x-p.x,y-p.y);}
        Point operator*(double k) {return Point(x*k,y*k);}
        Point operator/(double k) {return Point(x/k,y/k);}
        double norm() {return x*x+y*y;}
        double abs() {return sqrt(norm());}

        bool operator<(const Point &p) const {
            return x!=p.x ? x<p.x : x<p.y;
        }

        bool operator==(const Point &p) const {
            return fabs(x-p.x) < EPS and fabs(y-p.y) < EPS;
        }
    };

    struct Segment {
        Point p1, p2;
        Segment() {}
        Segment(Point p1, Point p2):p1(p1),p2(p2){}
    };

    // using Line = Segment;
    typedef Segment Line;

    double norm(Point a) {
        return a.x*a.x+a.y*a.y;
    }

    double abs(Point a) {
        return sqrt(norm(a));
    }

    double dot(Point a, Point b) {
        return a.x*b.x+a.y*b.y;
    }

    double cross(Point a, Point b) {
        return a.x*b.y-a.y*b.x;
    }

    bool isParallel(Point a, Point b) {
        return equals(cross(a,b), 0.0);
    }

    bool isParallel(Point a1, Point a2, Point b1, Point b2) {
        return isParallel(a1-a2,b1-b2);
    }

    bool isParallel(Line l1, Line l2) {
        return equals(cross(l1.p2-l1.p1,l2.p2-l2.p1), 0.0);
    }

    // COUNTER CLOCKWISE
    static const int CCW_COUNTER_CLOCKWISE = 1;
    static const int CCW_CLOCKWISE = -1;
    static const int CCW_ONLINE_BACK = 2;
    static const int CCW_ONLINE_FRONT = -2;
    static const int CCW_ON_SEGMENT = 0;

    int ccw(Point p0, Point p1, Point p2) {
        Point a = p1-p0;
        Point b = p2-p0;
        if(cross(a,b) > EPS) return CCW_COUNTER_CLOCKWISE;
        if(cross(a,b) < -EPS) return CCW_CLOCKWISE;
        if(dot(a,b) < -EPS) return CCW_ONLINE_BACK;
        if(a.norm() < b.norm()) return CCW_ONLINE_FRONT;
        return CCW_ON_SEGMENT;
    }
}
using namespace geometry;

namespace geometry {
    ostream &operator<<(ostream &os, Point p) {
        os<<fixed<<setprecision(12)<<p.x<<" "<<p.y;
        return os;
    }
}

bool on_line(int ccw_result) {
    return ccw_result == CCW_ONLINE_BACK or ccw_result == CCW_ONLINE_FRONT or ccw_result == CCW_ON_SEGMENT;
}

bool is_all_points_on_line(const vector<Point> &ps, Line l) {
    for(const auto &p:ps) {
        if(not on_line(ccw(l.p1, l.p2, p))) {
            return false;
        }
    }
    return true;
}

bool on_lines( Line l1, Line l2, Point p) {
    return on_line(ccw(l1.p1, l1.p2, p)) or on_line(ccw(l2.p1, l2.p2, p));
}

pair<Line, bool> find_line(Line l1, const vector<Point> &ps, int used1, int used2) {
        bool found_p = false, found_l2 = false;
        Point p;
        Line l2;
        for(int i=0;i<(int)(ps.size());i++) {
            if(i==used1 or i==used2) {
                continue;
            }

            if (not on_line(ccw(l1.p1, l1.p2, ps[i]))) {
                if (found_p) {
                    l2 = Line(p, ps[i]);
                    found_l2 = true;
                    break;
                }
                p = ps[i];
                found_p = true;
            }
        }

        return {l2, found_l2};
}

pair<Point, int> find_point(Line l, const vector<Point> &ps) {
    for(int i=0;i<(int)(ps.size()); i++) {
        const auto &p = ps[i];

        if (not on_line(ccw(l.p1, l.p2, p))) {
            return {p, i};
        }
    }
    return {Point(), -1};
}

bool is_only_point_not_on_line(Line l, const vector<Point> &ps) {
    auto [p, p_idx] = find_point(l, ps);
    for(int i=p_idx+1;i<(int)(ps.size());i++) {
        const auto &p = ps[i];

        if (not on_line(ccw(l.p1, l.p2, p))) {
            return false;
        }
    }
    return true;
}

bool solve() {
    int n;
    cin >> n;

    vector<Point> ps(n);
    rep(i, n) {
        cin >> ps[i].x >> ps[i].y;
    }

    if (n <= 3) {
        cout << "Yes\n";
        return true;
    }

    if (is_all_points_on_line(ps, Line(ps[0], ps[1]))) {
        cout << "Yes\n";
        return true;
    }

    if (is_only_point_not_on_line(Line(ps[0], ps[1]), ps)) {
        cout << "Yes\n";
        return true;
    }

    Line l1 = Line(ps[0], ps[1]);

    auto [p, p_idx] = find_point(l1, ps);

    {
        Line l1 = Line(ps[0], ps[1]);

        auto [l2, found_l2] = find_line(l1, ps, 0, 1);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    {
        Line l1 = Line(ps[0], ps[p_idx]);

        auto [l2, found_l2] = find_line(l1, ps, 0, p_idx);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    {
        Line l1 = Line(ps[1], ps[p_idx]);

        auto [l2, found_l2] = find_line(l1, ps, 1, p_idx);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    cout << "No\n";

    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int t;
    cin >> t;

    rep(_, t) {
        solve();
    }
}
accuracy: 1
time_ms: 220
memory_kb: 4200
final_rank: 7

code_snippet: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;
using ll = long long;
using P = pair<int,int>;
const int mod = 998244353;
const int inf = (1<<30);

const int dy[4] = {-1,0,0,1};
const int dx[4] = {0,-1,1,0};

#define equals(a,b) (fabs((a)-(b)) < EPS)

namespace geometry {
    const double EPS = 1e-10;
    const double PI = asinl(1) * 2;

    struct Point {
        double x,y;
        Point(){}
        Point(double x, double y):x(x),y(y){}
        Point operator+(Point p) {return Point(x+p.x,y+p.y);}
        Point operator-(Point p) {return Point(x-p.x,y-p.y);}
        Point operator*(double k) {return Point(x*k,y*k);}
        Point operator/(double k) {return Point(x/k,y/k);}
        double norm() {return x*x+y*y;}
        double abs() {return sqrt(norm());}

        bool operator<(const Point &p) const {
            return x!=p.x ? x<p.x : x<p.y;
        }

        bool operator==(const Point &p) const {
            return fabs(x-p.x) < EPS and fabs(y-p.y) < EPS;
        }
    };

    struct Segment {
        Point p1, p2;
        Segment() {}
        Segment(Point p1, Point p2):p1(p1),p2(p2){}
    };

    // using Line = Segment;
    typedef Segment Line;

    double norm(Point a) {
        return a.x*a.x+a.y*a.y;
    }

    double abs(Point a) {
        return sqrt(norm(a));
    }

    double dot(Point a, Point b) {
        return a.x*b.x+a.y*b.y;
    }

    double cross(Point a, Point b) {
        return a.x*b.y-a.y*b.x;
    }

    bool isParallel(Point a, Point b) {
        return equals(cross(a,b), 0.0);
    }

    bool isParallel(Point a1, Point a2, Point b1, Point b2) {
        return isParallel(a1-a2,b1-b2);
    }

    bool isParallel(Line l1, Line l2) {
        return equals(cross(l1.p2-l1.p1,l2.p2-l2.p1), 0.0);
    }

    // COUNTER CLOCKWISE
    static const int CCW_COUNTER_CLOCKWISE = 1;
    static const int CCW_CLOCKWISE = -1;
    static const int CCW_ONLINE_BACK = 2;
    static const int CCW_ONLINE_FRONT = -2;
    static const int CCW_ON_SEGMENT = 0;

    int ccw(Point p0, Point p1, Point p2) {
        Point a = p1-p0;
        Point b = p2-p0;
        if(cross(a,b) > EPS) return CCW_COUNTER_CLOCKWISE;
        if(cross(a,b) < -EPS) return CCW_CLOCKWISE;
        if(dot(a,b) < -EPS) return CCW_ONLINE_BACK;
        if(a.norm() < b.norm()) return CCW_ONLINE_FRONT;
        return CCW_ON_SEGMENT;
    }
}
using namespace geometry;

namespace geometry {
    ostream &operator<<(ostream &os, Point p) {
        os<<fixed<<setprecision(12)<<p.x<<" "<<p.y;
        return os;
    }
}

bool on_line(int ccw_result) {
    return ccw_result == CCW_ONLINE_BACK or ccw_result == CCW_ONLINE_FRONT or ccw_result == CCW_ON_SEGMENT;
}

bool is_all_points_on_line(const vector<Point> &ps, Line l) {
    for(const auto &p:ps) {
        if(not on_line(ccw(l.p1, l.p2, p))) {
            return false;
        }
    }
    return true;
}

bool on_lines( Line l1, Line l2, Point p) {
    return on_line(ccw(l1.p1, l1.p2, p)) or on_line(ccw(l2.p1, l2.p2, p));
}

pair<Line, bool> find_line(Line l1, const vector<Point> &ps, int used1, int used2) {
        bool found_p = false, found_l2 = false;
        Point p;
        Line l2;
        for(int i=0;i<(int)(ps.size());i++) {
            if(i==used1 or i==used2) {
                continue;
            }

            if (not on_line(ccw(l1.p1, l1.p2, ps[i]))) {
                if (found_p) {
                    l2 = Line(p, ps[i]);
                    found_l2 = true;
                    break;
                }
                p = ps[i];
                found_p = true;
            }
        }

        return {l2, found_l2};
}

pair<Point, int> find_point(Line l, const vector<Point> &ps) {
    for(int i=0;i<(int)(ps.size()); i++) {
        const auto &p = ps[i];

        if (not on_line(ccw(l.p1, l.p2, p))) {
            return {p, i};
        }
    }
    return {Point(), -1};
}

bool is_only_point_not_on_line(Line l, const vector<Point> &ps) {
    auto [p, p_idx] = find_point(l, ps);
    for(int i=p_idx+1;i<(int)(ps.size());i++) {
        const auto &p = ps[i];

        if (not on_line(ccw(l.p1, l.p2, p))) {
            return false;
        }
    }
    return true;
}

bool solve() {
    int n;
    cin >> n;

    vector<Point> ps(n);
    rep(i, n) {
        cin >> ps[i].x >> ps[i].y;
    }

    if (n <= 3) {
        cout << "Yes\n";
        return true;
    }

    if (is_all_points_on_line(ps, Line(ps[0], ps[1]))) {
        cout << "Yes\n";
        return true;
    }

    if (is_only_point_not_on_line(Line(ps[0], ps[1]), ps)) {
        cout << "Yes\n";
        return true;
    }

    Line l1 = Line(ps[0], ps[1]);

    auto [p, p_idx] = find_point(l1, ps);

    {
        Line l1 = Line(ps[0], ps[1]);

        auto [l2, found_l2] = find_line(l1, ps, 0, 1);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    {
        Line l1 = Line(ps[0], ps[p_idx]);

        auto [l2, found_l2] = find_line(l1, ps, 0, p_idx);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    {
        Line l1 = Line(ps[1], ps[p_idx]);

        auto [l2, found_l2] = find_line(l1, ps, 1, p_idx);

        assert(found_l2);

        if (isParallel(l1, l2)) {
            bool all_points_on_line = true;

            for (auto p: ps) {
                if(not on_lines(l1, l2, p)) {
                    all_points_on_line = false;
                    break;
                }
            }

            if (all_points_on_line) {
                cout << "Yes\n";
                return true;
            }
        }
    }

    cout << "No\n";

    return true;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    int t;
    cin >> t;

    rep(_, t) {
        solve();
    }
}
accuracy: 0.8846153846153846
time_ms: 210
memory_kb: 3844
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
//using ll = long long;

using Real = long double;

const Real EPS = 1e-13;
const string Yes = "Yes";
const string No = "No";

struct Point{
    Real x, y;
    Point(){}
    Point(Real a, Real b){
        x = a;
        y = b;
    }
};

// ax + by + c = 0
struct Line{
    Real a, b, c;
    Line(){}
    Line(Real x0, Real y0, Real x1, Real y1){
        a = -(y1 - y0);
        b = x1 - x0;
        c = -y0 * (x1 - x0) + x0 * (y1 - y0);
    }
};

Real dist2(Point p, Line l){
    Real res = fabsl(l.a * p.x + l.b * p.y + l.c);
    res *= res;
    res /= (l.a * l.a + l.b * l.b);
    return res;
}

bool equal(Real a, Real b){
    return fabsl(a - b) <= EPS;    
}

int main() {
    int T; cin >> T;
    while(T--){
        int N; cin >> N;
        vector<Point> P(N);
        for(int i= 0; i < N; i++) cin >> P[i].x >> P[i].y;

        if(N <= 2){
            cout << Yes << endl;
            continue;
        }

        Line line(P[0].x, P[0].y, P[1].x, P[1].y);
        int idx = -1;
        for(int i = 2; i < N; i++){
            if(!equal(0.0, dist2(P[i], line))){
                idx = i;
                break;
            }
        }

        if(idx == -1){
            cout << Yes << endl;
            continue;
        }

        vector<Point> Ps(3);
        Ps[0] = P[0];
        Ps[1] = P[1];
        Ps[2] = P[idx];
        //for(int i = 0; i < 3; i++) cerr << Ps[i].x << Ps[i].y << endl;

        Point mid01((Ps[0].x + Ps[1].x) / 2, (Ps[0].y + Ps[1].y) / 2);
        Point mid12((Ps[1].x + Ps[2].x) / 2, (Ps[1].y + Ps[2].y) / 2);
        Point mid20((Ps[2].x + Ps[0].x) / 2, (Ps[2].y + Ps[0].y) / 2);
        //cerr << mid01.x  << " " << mid01.y << endl;
        //cerr << mid12.x  << " " << mid12.y << endl;
        //cerr << mid20.x  << " " << mid20.y << endl;
        
        vector<Line> ls(3);
        ls[0] = Line(mid01.x, mid01.y, mid12.x, mid12.y);
        assert(equal(dist2(Ps[0], ls[0]), dist2(Ps[1], ls[0])));
        assert(equal(dist2(Ps[0], ls[0]), dist2(Ps[2], ls[0])));

        ls[1] = Line(mid12.x, mid12.y, mid20.x, mid20.y);
        assert(equal(dist2(Ps[0], ls[1]), dist2(Ps[1], ls[1])));
        assert(equal(dist2(Ps[0], ls[1]), dist2(Ps[2], ls[1])));

        ls[2] = Line(mid20.x, mid20.y, mid01.x, mid01.y);
        assert(equal(dist2(Ps[0], ls[2]), dist2(Ps[1], ls[2])));
        assert(equal(dist2(Ps[0], ls[2]), dist2(Ps[2], ls[2])));

        //ll tmp = fabsl(dist2(P[0], );
        bool isok = 0;
        for(int i = 0; i < 3; i++){
            Real tmp = fabsl(dist2(P[0], ls[i]));
            bool flag = 1;
            for(int j = 0; j < N; j++){
                if(!equal(fabsl(dist2(P[j], ls[i])), tmp)){
                    flag = 0;
                    break;
                }
            }
            if(flag) isok = 1;
        }

        if(isok) cout << Yes << endl;
        else cout << No << endl;

    }
}
accuracy: 1
time_ms: 390
memory_kb: 4264
final_rank: 9

code_snippet: /* -*- coding: utf-8 -*-
 *
 * 3167.cc: Many Points
 */

#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 20000;

/* typedef */

typedef long long ll;

template <typename T>
struct Pt {
  T x, y;
  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt<T> &p) : x(p.x), y(p.y) {}

  Pt<T> operator+(const Pt<T> p) const { return Pt<T>(x + p.x, y + p.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt<T> p) const { return Pt<T>(x - p.x, y - p.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt<T> v) const { return x * v.x + y * v.y; }
  T cross(Pt<T> v) const { return x * v.y - y * v.x; }
  T d2() { return x * x + y * y; }

  Pt<T> rot90() { return Pt<T>(-y, x); }

  bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
  bool operator<(const Pt<T> &pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }
};

typedef Pt<ll> pt;
typedef vector<pt> vpt;

/* global variables */

pt ps[MAX_N];

/* subroutines */

// convex_hull()
//   make a convex_hull 'chs' from a set of points 'ps'
//   Note: ps must be sorted, and must contain at least 2 points
void convex_hull(const int n, const pt ps[], vpt& chs) {
  vpt lhs, uhs;

  lhs.push_back(ps[0]);
  lhs.push_back(ps[1]);
  for (int i = 2; i < n; i++) {
    while (lhs.size() >= 2) {
      int ln = lhs.size();
      pt &lh0 = lhs[ln - 2], &lh1 = lhs[ln - 1];
      if ((lh1 - lh0).cross(ps[i] - lh1) > 0) break;
      lhs.pop_back();
    }
    lhs.push_back(ps[i]);
  }

  uhs.push_back(ps[n - 1]);
  uhs.push_back(ps[n - 2]);
  for (int i = n - 3; i >= 0; i--) {
    while (uhs.size() >= 2) {
      int un = uhs.size();
      pt &uh0 = uhs[un - 2], &uh1 = uhs[un - 1];
      if ((uh1 - uh0).cross(ps[i] - uh1) > 0) break;
      uhs.pop_back();
    }
    uhs.push_back(ps[i]);
  }

  lhs.pop_back();
  uhs.pop_back();

  chs.clear();
  chs.reserve(lhs.size() + uhs.size());
  chs.assign(lhs.begin(), lhs.end());
  chs.insert(chs.end(), uhs.begin(), uhs.end());
}

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int tn;
  scanf("%d", &tn);

  for (int ti = 0; ti < tn; ti++) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
      scanf("%lld%lld", &ps[i].x, &ps[i].y);

    if (ti == -1) {
      printf("%d\n", n);
      for (int i = 0; i < n; i++) printf("%lld,%lld\n", ps[i].x, ps[i].y);
    }

    if (n <= 2) { puts("Yes"); continue; }

    sort(ps, ps + n);
    vpt chs;
    convex_hull(n, ps, chs);
    int chn = chs.size();
    //printf("chs=%d\n", chn);

    if (chn <= 2)
      puts("Yes");
    else if (chn == 3) {
      bool ok = false;
      for (int i = 0; ! ok && i < 3; i++) {
	pt p0 = chs[i], p1 = chs[(i + 1) % 3], p2 = chs[(i + 2) % 3];
	pt v(p2 - p1);

	ok = true;
	for (int j = 0; ok && j < n; j++)
	  ok = (ps[j] == p0 || v.cross(ps[j] - p1) == 0);
      }

      if (ok) puts("Yes");
      else puts("No");
    }
    else if (chn == 4) {
      bool ok = false;
      for (int i = 0; ! ok && i < 2; i++) {
	pt p0 = chs[i], p1 = chs[(i + 1) % 4];
	pt p2 = chs[(i + 2) % 4], p3 = chs[(i + 3) % 4];
	pt v0(p1 - p0), v1(p3 - p2);

	if (v0.cross(v1) != 0) continue;

	ok = true;
	for (int j = 0; ok && j < n; j++)
	  ok = (v0.cross(ps[j] - p0) == 0 || v1.cross(ps[j] - p2) == 0);
      }

      if (ok) puts("Yes");
      else puts("No");
    }
    else
      puts("No");
  }

  return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 3220
final_rank: 1

code_snippet: /* -*- coding: utf-8 -*-
 *
 * 3167.cc: Many Points
 */

#include<cstdio>
#include<vector>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 20000;

/* typedef */

typedef long long ll;

template <typename T>
struct Pt {
  T x, y;
  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt<T> &p) : x(p.x), y(p.y) {}

  Pt<T> operator+(const Pt<T> p) const { return Pt<T>(x + p.x, y + p.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt<T> p) const { return Pt<T>(x - p.x, y - p.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt<T> v) const { return x * v.x + y * v.y; }
  T cross(Pt<T> v) const { return x * v.y - y * v.x; }
  T d2() { return x * x + y * y; }

  Pt<T> rot90() { return Pt<T>(-y, x); }

  bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
  bool operator<(const Pt<T> &pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }
};

typedef Pt<ll> pt;
typedef vector<pt> vpt;

/* global variables */

pt ps[MAX_N];

/* subroutines */

// convex_hull()
//   make a convex_hull 'chs' from a set of points 'ps'
//   Note: ps must be sorted, and must contain at least 2 points
void convex_hull(const int n, const pt ps[], vpt& chs) {
  vpt lhs, uhs;

  lhs.push_back(ps[0]);
  lhs.push_back(ps[1]);
  for (int i = 2; i < n; i++) {
    while (lhs.size() >= 2) {
      int ln = lhs.size();
      pt &lh0 = lhs[ln - 2], &lh1 = lhs[ln - 1];
      if ((lh1 - lh0).cross(ps[i] - lh1) > 0) break;
      lhs.pop_back();
    }
    lhs.push_back(ps[i]);
  }

  uhs.push_back(ps[n - 1]);
  uhs.push_back(ps[n - 2]);
  for (int i = n - 3; i >= 0; i--) {
    while (uhs.size() >= 2) {
      int un = uhs.size();
      pt &uh0 = uhs[un - 2], &uh1 = uhs[un - 1];
      if ((uh1 - uh0).cross(ps[i] - uh1) > 0) break;
      uhs.pop_back();
    }
    uhs.push_back(ps[i]);
  }

  lhs.pop_back();
  uhs.pop_back();

  chs.clear();
  chs.reserve(lhs.size() + uhs.size());
  chs.assign(lhs.begin(), lhs.end());
  chs.insert(chs.end(), uhs.begin(), uhs.end());
}

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int tn;
  scanf("%d", &tn);

  while (tn--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
      scanf("%lld%lld", &ps[i].x, &ps[i].y);

    if (n <= 2) { puts("Yes"); continue; }

    sort(ps, ps + n);
    vpt chs;
    convex_hull(n, ps, chs);
    int chn = chs.size();
    //printf("chs=%d\n", chn);

    if (chn <= 2)
      puts("Yes");
    else if (chn == 3) {
      bool ok = false;
      for (int i = 0; ! ok && i < 3; i++) {
	pt p0 = chs[i], p1 = chs[(i + 1) % 3], p2 = chs[(i + 2) % 3];
	pt v(p2 - p1);

	ok = true;
	for (int j = 0; ok && j < n; j++)
	  ok = (ps[j] == p0 || v.cross(ps[j] - p1) == 0);
      }

      if (ok) puts("Yes");
      else puts("No");
    }
    else if (chn == 4) {
      bool ok = false;
      for (int i = 0; ! ok && i < 2; i++) {
	pt p0 = chs[i], p1 = chs[(i + 1) % 4];
	pt p2 = chs[(i + 2) % 4], p3 = chs[(i + 3) % 4];
	pt v0(p1 - p0), v1(p3 - p2);

	ok = true;
	for (int j = 0; ok && j < n; j++)
	  ok = (v0.cross(ps[j] - p0) == 0 || v1.cross(ps[j] - p2) == 0);
      }

      if (ok) puts("Yes");
      else puts("No");
    }
    else
      puts("No");
  }

  return 0;
}
accuracy: 0.8846153846153846
time_ms: 110
memory_kb: 3164
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=9167167167167167167;
const int INF=100000000;
const ll mod=998244353;
#define rep(i,a) for (ll i=0;i<a;i++)
#define all(p) p.begin(),p.end()
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}
template<class T> void vec_out(vector<T> &p){for(int i=0;i<(int)(p.size());i++){if(i) cout<<" ";cout<<p[i];}cout<<"\n";}



void solve();
// oddloop
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t=1;
	cin>>t;
	rep(i,t) solve();
}

void solve(){
	int N;
	cin>>N;
	vector<pair<ll,ll>> p(N);
	rep(i,N) cin>>p[i].first>>p[i].second;
	if(N<4){
		cout<<"Yes\n";
		return;
	}
	auto f=[](vector<pair<ll,ll>> pos,pair<ll,ll> A,pair<ll,ll> B)->bool{
		int n=pos.size();
		ll X=A.second-B.second;
		ll Y=B.first-A.first;
		set<ll> s;
		rep(i,n) s.insert(X*pos[i].first+Y*pos[i].second);
		return (int)s.size()<=2;
	};
	yneos(f(p,p[0],p[1])||f(p,p[0],p[2])||f(p,p[1],p[2]));
}
accuracy: 1
time_ms: 210
memory_kb: 5624
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using lli = long long int;
using Point = pair<lli, lli>;

lli gcd(lli a, lli b){
    if(a%b==0) return b;
    return gcd(b,a%b);
}
Point operator +(const Point& a, const Point& b){
    return Point(a.first +b.first, a.second +b.second);
}
Point operator -(const Point& a, const Point& b){
    return Point(a.first -b.first, a.second -b.second);
}
Point reduce(Point p){
    if(p.first == 0){
        if(p.second == 0) return Point(0, 0);
        return Point(0, 1);
    }
    if(p.second == 0){
        return Point(1, 0);
    }
    if(p.first < 0){
        p.first = -p.first;
        p.second = -p.second;
    }
    lli d = gcd(p.first, abs(p.second));
    return Point(p.first/d, p.second/d);
}

int main(){
    int t;
    cin >> t;
    for(int rep=0; rep<t; rep++){
        int n;
        cin >> n;
        vector<Point> p(n);
        for(int i=0; i<n; i++){
            cin >> p[i].first >> p[i].second;
        }

        if(n <= 2){
            cout << "Yes" << endl;
            continue;
        }

        bool ok = false;
        for(int d=0; d<3; d++){
            Point dir = reduce(p[d] -p[(d+1)%3]);
            vector<Point> rem;
            for(int i=0; i<n; i++){
                if(i == d) continue;
                if(reduce(p[i] -p[d]) != dir){
                    rem.push_back(p[i]);
                }
            }
            if(rem.size() < 2u){
                ok = true;
                break;
            }
            int count = 0;
            for(int i=1; i<(int)rem.size(); i++){
                if(reduce(rem[i] -rem[0]) != dir){
                    count++;
                }
            }
            if(count == 0){
                ok = true;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 630
memory_kb: 4244
final_rank: 12

code_snippet: #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <limits>
using namespace std;

const double EPS = 1e-6;
const double INF = 1e12;
const double PI = acos(-1);
const double NaN = std::numeric_limits<double>::quiet_NaN();
#define EQ(n,m) (abs((n)-(m)) < EPS)

struct P{
    double X;
    double Y;
    P(double x=0.0, double y=0.0): X(x),Y(y){}

    inline const P inv() const { return P(X/(X*X+Y*Y), -Y/(X*X+Y*Y)); }
    inline const P operator -() const { return P(-X, -Y); }
    inline const P operator +(const P& a) const { return P(X+a.X, Y+a.Y); }
    inline const P operator -(const P& a) const { return P(X-a.X, Y-a.Y); }
    inline const P operator *(const P& a) const { return P(X*a.X -Y*a.Y, X*a.Y +Y*a.X); }
    inline const P operator /(const P& a) const { return *this *a.inv(); }
    inline const P operator *(const double& c) const { return P(c*X, c*Y); }
    inline const P operator /(const double& c) const { return P(X/c, Y/c); }

    inline P& operator +=(const P& a){ X+=a.X; Y+=a.Y; return *this; }
    inline P& operator -=(const P& a){ X-=a.X; Y-=a.Y; return *this; }
    inline P& operator *=(const P& a){ double nX=X*a.X-Y*a.Y; Y=X*a.Y+Y*a.X; X=nX; return *this; }
    inline P& operator /=(const P& a){ double d=a.X*a.X+a.Y*a.Y; double nX=(X*a.X+Y*a.Y)/d; Y=(-X*a.Y+Y*a.X)/d; X=nX; return *this; }
    inline P& operator *=(const double& c){ X*=c; Y*=c; return *this; }
    inline P& operator /=(const double& c){ X/=c; Y/=c; return *this; }

    inline bool operator ==(const P& a) const { return EQ(X,a.X) and EQ(Y,a.Y); }
    inline bool operator !=(const P& a) const { return !(*this==a); }
    inline bool operator <(const P& a) const { return !EQ(X,a.X)? X<a.X: Y+EPS<a.Y; }
    inline bool operator <=(const P& a) const { return *this<a or *this==a; }
    inline bool operator >(const P& a) const { return !(*this<=a); }
    inline bool operator >=(const P& a) const { return !(*this<a); }
};
P operator *(const double& c, const P& p){ return P(c*p.X, c*p.Y); }
double norm(const P& a){ return a.X*a.X +a.Y*a.Y; }
double abs(const P& a){ return sqrt(a.X*a.X +a.Y*a.Y); }
double arg(const P& a){ return atan2(a.X, a.Y); }
double dot(const P& a, const P& b){ return a.X*b.X +a.Y*b.Y; }
double cross(const P& a, const P& b){ return a.X*b.Y -a.Y*b.X; }
std::ostream& operator <<(std::ostream& lhs, const P& rhs){
    lhs << "(" << rhs.X << ", " << rhs.Y << ")";
    return lhs;
}

typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};

double distanceLP(const L &l, const P &p) {
    return abs(cross(l[1]-l[0], p-l[0])) /abs(l[1]-l[0]);
}
bool isParallel(const P &a, const P &b){
    return abs(cross(a,b)) < EPS;
}
bool isParallel(const L &a, const L &b){
    return isParallel(a[1]-a[0], b[1]-b[0]);
}

int main(){
    int t;
    cin >> t;
    for(int rep=0; rep<t; rep++){
        int n;
        cin >> n;
        vector<P> p(n);
        for(int i=0; i<n; i++){
            cin >> p[i].X >> p[i].Y;
        }

        if(n <= 2){
            cout << "Yes" << endl;
            continue;
        }

        bool ok = false;
        for(int d=0; d<3; d++){
            L line(p[d], p[(d+1)%3]);
            vector<P> rem;
            for(int i=0; i<n; i++){
                if(abs(distanceLP(line, p[i]) > EPS)){
                    rem.push_back(p[i]);
                }
            }
            if(rem.size() < 2u){
                ok = true;
                break;
            }
            L nline(rem[0], rem[1]);
            if(!isParallel(line, nline)){
                continue;
            }
            int count = 0;
            for(P v: rem){
                if(abs(distanceLP(nline, v) > EPS)){
                    count++;
                }
            }
            if(count == 0){
                ok = true;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}
accuracy: 0.8846153846153846
time_ms: 400
memory_kb: 4280
final_rank: 18

code_snippet: #line 2 "/home/yuruhiya/programming/library/template/template_no_Ruby.cpp"
#include <bits/stdc++.h>
#line 4 "/home/yuruhiya/programming/library/template/constants.cpp"
#include <string_view>
#line 7 "/home/yuruhiya/programming/library/template/constants.cpp"

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rfor(i, m, n) for (int i = (m); i >= (n); --i)
#define unless(c) if (!(c))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define range_it(a, l, r) (a).begin() + (l), (a).begin() + (r)

using namespace std;
using ll = long long;
using LD = long double;
using VB = vector<bool>;
using VVB = vector<VB>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VS = vector<string>;
using VD = vector<LD>;
using PII = pair<int, int>;
using VP = vector<PII>;
using PLL = pair<ll, ll>;
using VPL = vector<PLL>;
template <class T> using PQ = priority_queue<T>;
template <class T> using PQS = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000000;
constexpr long long inf_ll = 1000000000000000000ll, MOD = 1000000007;
constexpr long double PI = 3.14159265358979323846, EPS = 1e-12;
namespace CharacterClass {
	constexpr string_view
	    digit = "0123456789",
	    xdigit = "0123456789ABCDEFabcdef", lower = "abcdefghijklmnopqrstuvwxyz",
	    upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
	    alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
	    alnum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
	    word = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",
	    punct = R"(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)",
	    graph =
	        R"(!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~)",
	    print =
	        R"( !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~)",
	    blank = " \t", space = " \t\n\r\f\v";
}  // namespace CharacterClass
#line 7 "/home/yuruhiya/programming/library/template/Input.cpp"
using namespace std;

#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock
#define fwrite_unlocked fwrite
#define fflush_unlocked fflush
#endif
class Scanner {
	static int gc() {
		return getchar_unlocked();
	}
	static char next_char() {
		char c;
		read(c);
		return c;
	}
	template <class T> static void read(T& v) {
		cin >> v;
	}
	static void read(char& v) {
		while (isspace(v = gc()))
			;
	}
	static void read(bool& v) {
		v = next_char() != '0';
	}
	static void read(string& v) {
		v.clear();
		for (char c = next_char(); !isspace(c); c = gc()) v += c;
	}
	static void read(int& v) {
		v = 0;
		bool neg = false;
		char c = next_char();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void read(long long& v) {
		v = 0;
		bool neg = false;
		char c = next_char();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c); c = gc()) v = v * 10 + (c - '0');
		if (neg) v = -v;
	}
	static void read(double& v) {
		v = 0;
		double dp = 1;
		bool neg = false, after_dp = false;
		char c = next_char();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.') {
				after_dp = true;
			} else if (after_dp) {
				v += (c - '0') * (dp *= 0.1);
			} else {
				v = v * 10 + (c - '0');
			}
		}
		if (neg) v = -v;
	}
	static void read(long double& v) {
		v = 0;
		long double dp = 1;
		bool neg = false, after_dp = false;
		char c = next_char();
		if (c == '-') {
			neg = true;
			c = gc();
		}
		for (; isdigit(c) || c == '.'; c = gc()) {
			if (c == '.') {
				after_dp = true;
			} else if (after_dp) {
				v += (c - '0') * (dp *= 0.1);
			} else {
				v = v * 10 + (c - '0');
			}
		}
		if (neg) v = -v;
	}
	template <class T, class U> static void read(pair<T, U>& v) {
		read(v.first);
		read(v.second);
	}
	template <class T> static void read(vector<T>& v) {
		for (auto& e : v) read(e);
	}
	template <size_t N = 0, class T> static void read_tuple_impl(T& v) {
		if constexpr (N < tuple_size_v<T>) {
			read(get<N>(v));
			read_tuple_impl<N + 1>(v);
		}
	}
	template <class... T> static void read(tuple<T...>& v) {
		read_tuple_impl(v);
	}
	struct ReadVectorHelper {
		size_t n;
		ReadVectorHelper(size_t _n) : n(_n) {}
		template <class T> operator vector<T>() {
			vector<T> v(n);
			read(v);
			return v;
		}
	};
	struct Read2DVectorHelper {
		size_t n, m;
		Read2DVectorHelper(const pair<size_t, size_t>& nm) : n(nm.first), m(nm.second) {}
		template <class T> operator vector<vector<T>>() {
			vector<vector<T>> v(n, vector<T>(m));
			read(v);
			return v;
		}
	};

public:
	string read_line() const {
		string v;
		for (char c = gc(); c != '\n' && c != '\0'; c = gc()) v += c;
		return v;
	}
	template <class T> T read() const {
		T v;
		read(v);
		return v;
	}
	template <class T> vector<T> read_vector(size_t n) const {
		vector<T> a(n);
		read(a);
		return a;
	}
	template <class T> operator T() const {
		return read<T>();
	}
	int operator--(int) const {
		return read<int>() - 1;
	}
	ReadVectorHelper operator[](size_t n) const {
		return ReadVectorHelper(n);
	}
	Read2DVectorHelper operator[](const pair<size_t, size_t>& nm) const {
		return Read2DVectorHelper(nm);
	}
	void operator()() const {}
	template <class H, class... T> void operator()(H&& h, T&&... t) const {
		read(h);
		operator()(forward<T>(t)...);
	}

private:
	template <template <class...> class, class...> struct Multiple;
	template <template <class...> class V, class Head, class... Tail>
	struct Multiple<V, Head, Tail...> {
		template <class... Args> using vec = V<vector<Head>, Args...>;
		using type = typename Multiple<vec, Tail...>::type;
	};
	template <template <class...> class V> struct Multiple<V> { using type = V<>; };
	template <class... T> using multiple_t = typename Multiple<tuple, T...>::type;
	template <size_t N = 0, class T> void multiple_impl(T& t) const {
		if constexpr (N < tuple_size_v<T>) {
			auto& vec = get<N>(t);
			using V = typename remove_reference_t<decltype(vec)>::value_type;
			vec.push_back(read<V>());
			multiple_impl<N + 1>(t);
		}
	}

public:
	template <class... T> auto multiple(size_t h) const {
		multiple_t<T...> result;
		while (h--) multiple_impl(result);
		return result;
	}
} in;
#define inputs(T, ...) \
	T __VA_ARGS__;     \
	in(__VA_ARGS__)
#define ini(...) inputs(int, __VA_ARGS__)
#define inl(...) inputs(long long, __VA_ARGS__)
#define ins(...) inputs(string, __VA_ARGS__)
#line 7 "/home/yuruhiya/programming/library/template/Output.cpp"
#include <charconv>
#line 10 "/home/yuruhiya/programming/library/template/Output.cpp"
using namespace std;

struct BoolStr {
	const char *t, *f;
	BoolStr(const char* _t, const char* _f) : t(_t), f(_f) {}
} Yes("Yes", "No"), yes("yes", "no"), YES("YES", "NO"), Int("1", "0");
struct DivStr {
	const char *d, *l;
	DivStr(const char* _d, const char* _l) : d(_d), l(_l) {}
} spc(" ", "\n"), no_spc("", "\n"), end_line("\n", "\n"), comma(",", "\n"),
    no_endl(" ", "");
class Output {
	BoolStr B{Yes};
	DivStr D{spc};

public:
	void put(int v) const {
		char buf[12]{};
		if (auto [ptr, e] = to_chars(begin(buf), end(buf), v); e == errc{}) {
			fwrite(buf, sizeof(char), ptr - buf, stdout);
		} else {
			assert(false);
		}
	}
	void put(long long v) const {
		char buf[21]{};
		if (auto [ptr, e] = to_chars(begin(buf), end(buf), v); e == errc{}) {
			fwrite(buf, sizeof(char), ptr - buf, stdout);
		} else {
			assert(false);
		}
	}
	void put(bool v) const {
		put(v ? B.t : B.f);
	}
	void put(vector<bool>::reference v) const {
		put(v ? B.t : B.f);
	}
	void put(char v) const {
		putchar_unlocked(v);
	}
	void put(const char* v) const {
		fwrite_unlocked(v, 1, strlen(v), stdout);
	}
	void put(double v) const {
		printf("%.20f", v);
	}
	void put(long double v) const {
		printf("%.20Lf", v);
	}
	template <class T> void put(const T& v) const {
		cout << v;
	}
	template <class T, class U> void put(const pair<T, U>& v) const {
		put(v.first);
		put(D.d);
		put(v.second);
	}
	template <class InputIterater>
	void put_range(const InputIterater& begin, const InputIterater& end) const {
		for (InputIterater i = begin; i != end; ++i) {
			if (i != begin) put(D.d);
			put(*i);
		}
	}
	template <class T> void put(const vector<T>& v) const {
		put_range(v.begin(), v.end());
	}
	template <class T, size_t N> void put(const array<T, N>& v) const {
		put_range(v.begin(), v.end());
	}
	template <class T> void put(const vector<vector<T>>& v) const {
		for (size_t i = 0; i < v.size(); ++i) {
			if (i) put(D.l);
			put(v[i]);
		}
	}

	Output() = default;
	Output(const BoolStr& _boolstr, const DivStr& _divstr) : B(_boolstr), D(_divstr) {}
	Output& operator()() {
		put(D.l);
		return *this;
	}
	template <class H> Output& operator()(H&& h) {
		put(h);
		put(D.l);
		return *this;
	}
	template <class H, class... T> Output& operator()(H&& h, T&&... t) {
		put(h);
		put(D.d);
		return operator()(forward<T>(t)...);
	}
	template <class InputIterator>
	Output& range(const InputIterator& begin, const InputIterator& end) {
		put_range(begin, end);
		put(D.l);
		return *this;
	}
	template <class T> Output& range(const T& a) {
		range(a.begin(), a.end());
		return *this;
	}
	template <class... T> void exit(T&&... t) {
		operator()(forward<T>(t)...);
		std::exit(EXIT_SUCCESS);
	}
	Output& flush() {
		fflush_unlocked(stdout);
		return *this;
	}
	Output& set(const BoolStr& b) {
		B = b;
		return *this;
	}
	Output& set(const DivStr& d) {
		D = d;
		return *this;
	}
	Output& set(const char* t, const char* f) {
		B = BoolStr(t, f);
		return *this;
	}
} out;
#line 7 "/home/yuruhiya/programming/library/template/functions.cpp"
using namespace std;

template <class T = long long> constexpr T TEN(size_t n) {
	T result = 1;
	for (size_t i = 0; i < n; ++i) result *= 10;
	return result;
}
template <class T, class U,
          enable_if_t<is_integral_v<T> && is_integral_v<U>, nullptr_t> = nullptr>
constexpr auto div_ceil(T n, U m) {
	return (n + m - 1) / m;
}
template <class T, class U> constexpr auto div_ceil2(T n, U m) {
	return div_ceil(n, m) * m;
}
template <class T> constexpr T triangle(T n) {
	return (n & 1) ? (n + 1) / 2 * n : n / 2 * (n + 1);
}
template <class T> constexpr T nC2(T n) {
	return (n & 1) ? (n - 1) / 2 * n : n / 2 * (n - 1);
}
template <class T, class U> constexpr auto middle(const T& l, const U& r) {
	return l + (r - l) / 2;
}
template <class T, class U, class V>
constexpr bool in_range(const T& v, const U& lower, const V& upper) {
	return lower <= v && v < upper;
}
template <class T, enable_if_t<is_integral_v<T>, nullptr_t> = nullptr>
constexpr bool is_square(T n) {
	T s = sqrt(n);
	return s * s == n || (s + 1) * (s + 1) == n;
}
template <class T = long long> constexpr T BIT(int b) {
	return T(1) << b;
}
template <class T> constexpr int BIT(T x, int i) {
	return (x & (1 << i)) ? 1 : 0;
}
template <class T, class U, enable_if_t<is_integral_v<U>, nullptr_t> = nullptr>
constexpr T Pow(T a, U n) {
	assert(n >= 0);
	T result = 1;
	while (n > 0) {
		if (n & 1) {
			result *= a;
			n--;
		} else {
			a *= a;
			n >>= 1;
		}
	}
	return result;
}
template <class T, class U, enable_if_t<is_integral_v<U>, nullptr_t> = nullptr>
constexpr T Powmod(T a, U n, T mod) {
	assert(n >= 0);
	if (a > mod) a %= mod;
	T result = 1;
	while (n > 0) {
		if (n & 1) {
			result = result * a % mod;
			n--;
		} else {
			a = a * a % mod;
			n >>= 1;
		}
	}
	return result;
}
template <class T> bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> int sz(const T& v) {
	return v.size();
}
template <class T, class U> int lower_index(const T& a, const U& v) {
	return lower_bound(all(a), v) - a.begin();
}
template <class T, class U> int upper_index(const T& a, const U& v) {
	return upper_bound(all(a), v) - a.begin();
}
template <class T> auto Slice(const T& v, size_t i, size_t len) {
	return i < v.size() ? T(v.begin() + i, v.begin() + min(i + len, v.size())) : T();
}
template <class T, class U = typename T::value_type> U Gcdv(const T& v) {
	return accumulate(next(v.begin()), v.end(), U(*v.begin()), gcd<U, U>);
}
template <class T, class U = typename T::value_type> U Lcmv(const T& v) {
	return accumulate(next(v.begin()), v.end(), U(*v.begin()), lcm<U, U>);
}
namespace internal {
	template <class T, size_t N> auto make_vector(vector<int>& sizes, const T& init) {
		if constexpr (N == 1) {
			return vector(sizes[0], init);
		} else {
			int size = sizes[N - 1];
			sizes.pop_back();
			return vector(size, make_vector<T, N - 1>(sizes, init));
		}
	}
}  // namespace internal
template <class T, size_t N>
auto make_vector(const int (&sizes)[N], const T& init = T()) {
	vector s(rbegin(sizes), rend(sizes));
	return internal::make_vector<T, N>(s, init);
}
#line 7 "/home/yuruhiya/programming/library/template/template_no_Ruby.cpp"
#if __has_include(<library/dump.hpp>)
#include <library/dump.hpp>
#define LOCAL
#else
#define dump(...) ((void)0)
#endif

template <class T> constexpr T oj_local(const T& oj, const T& local) {
#ifndef LOCAL
	return oj;
#else
	return local;
#endif
}
#line 5 "/home/yuruhiya/programming/library/Utility/Pair.cpp"
using namespace std;

template <class T> struct Pair {
	using value_type = T;
	static constexpr bool cmp_x(const Pair<value_type>& p1, const Pair<value_type>& p2) {
		return p1.xy() < p2.xy();
	}
	static constexpr bool cmp_y(const Pair<value_type>& p1, const Pair<value_type>& p2) {
		return p1.yx() < p2.yx();
	}
	static constexpr value_type get_x(const Pair<value_type>& p) {
		return p.x;
	}
	static constexpr value_type get_y(const Pair<value_type>& p) {
		return p.y;
	}

	value_type x, y;
	constexpr Pair() : x(), y() {}
	constexpr Pair(value_type _x, value_type _y) : x(_x), y(_y) {}
	constexpr Pair(const pair<value_type, value_type>& xy) : x(xy.first), y(xy.second) {}
	constexpr Pair(const tuple<value_type, value_type>& xy)
	    : x(get<0>(xy)), y(get<0>(xy)) {}
	constexpr Pair operator+() const {
		return *this;
	}
	constexpr Pair operator-() const {
		return {-x, -y};
	}
	constexpr Pair operator+(const Pair& p) const {
		return Pair(*this) += p;
	}
	constexpr Pair operator-(const Pair& p) const {
		return Pair(*this) -= p;
	}
	constexpr Pair operator*(const Pair& p) const {
		return Pair(*this) *= p;
	}
	constexpr Pair operator/(const Pair& p) const {
		return Pair(*this) /= p;
	}
	constexpr Pair operator%(const Pair& p) const {
		return Pair(*this) %= p;
	}
	constexpr Pair operator+(value_type n) const {
		return Pair(*this) += n;
	}
	constexpr Pair operator-(value_type n) const {
		return Pair(*this) -= n;
	}
	constexpr Pair operator*(value_type n) const {
		return Pair(*this) *= n;
	}
	constexpr Pair operator/(value_type n) const {
		return Pair(*this) /= n;
	}
	constexpr Pair operator%(value_type n) const {
		return Pair(*this) %= n;
	}
	constexpr Pair& operator+=(const Pair& p) {
		x += p.x;
		y += p.y;
		return *this;
	}
	constexpr Pair& operator-=(const Pair& p) {
		x -= p.x;
		y -= p.y;
		return *this;
	}
	constexpr Pair& operator*=(const Pair& p) {
		x *= p.x;
		y *= p.y;
		return *this;
	}
	constexpr Pair& operator/=(const Pair& p) {
		x /= p.x;
		y /= p.y;
		return *this;
	}
	constexpr Pair& operator%=(const Pair& p) {
		x %= p.x;
		y %= p.y;
		return *this;
	}
	constexpr Pair& operator+=(value_type n) {
		x += n;
		y += n;
		return *this;
	}
	constexpr Pair& operator-=(value_type n) {
		x -= n;
		y -= n;
		return *this;
	}
	constexpr Pair& operator*=(value_type n) {
		x *= n;
		y *= n;
		return *this;
	}
	constexpr Pair& operator/=(value_type n) {
		x /= n;
		y /= n;
		return *this;
	}
	constexpr Pair& operator%=(value_type n) {
		x %= n;
		y %= n;
		return *this;
	}
	constexpr bool operator==(const Pair& p) const {
		return x == p.x && y == p.y;
	}
	constexpr bool operator!=(const Pair& p) const {
		return x != p.x || y != p.y;
	}
	constexpr bool operator<(const Pair& p) const {
		return x < p.x || (!(p.x < x) && y < p.y);
	}
	constexpr bool operator>(const Pair& p) const {
		return p < *this;
	}
	constexpr bool operator<=(const Pair& p) const {
		return !(p < *this);
	}
	constexpr bool operator>=(const Pair& p) const {
		return !(*this < p);
	}
	constexpr value_type operator[](size_t i) const {
		assert(0 <= i && i < 2);
		return i == 0 ? x : y;
	}
	constexpr pair<value_type, value_type> to_pair() const {
		return {x, y};
	}
	constexpr tuple<value_type, value_type> to_tuple() const {
		return {x, y};
	}
	constexpr Pair xy() const {
		return {x, y};
	}
	constexpr Pair yx() const {
		return {y, x};
	}
	constexpr operator tuple<value_type&, value_type&>() {
		return tuple<value_type&, value_type&>(x, y);
	}
	friend ostream& operator<<(ostream& os, const Pair& p) {
		return os << p.x << ' ' << p.y;
	}
	friend istream& operator>>(istream& is, Pair& p) {
		return is >> p.x >> p.y;
	}
};
namespace std {
	template <class T> struct tuple_size<Pair<T>> : integral_constant<size_t, 2> {};
	template <size_t N, class T> struct tuple_element<N, Pair<T>> { using type = T; };
}  // namespace std
template <size_t N, class T> T get(const Pair<T>& p) {
	return N == 0 ? p.x : p.y;
}
#line 3 "b.cpp"

void solve() {
	using P = Pair<ll>;

	ini(n);
	vector<P> p = in[n];
	if (n <= 3) {
		out(true);
		return;
	}

	auto check = [&](P a) {
		vector<P> remain;
		FOR(i, 1, n) {
			P b = p[0] - p[i];
			if (a.x * b.y - a.y * b.x != 0) {
				remain.push_back(p[i]);
			}
		}
		FOR(i, 1, sz(remain)) {
			P b = remain[0] - remain[i];
			if (a.x * b.y - a.y * b.x != 0) {
				return false;
			}
		}
		return true;
	};

	out(check(p[0] - p[1]) || check(p[0] - p[2]) || check(p[1] - p[2]));
}

int main() {
	for (int t = in; t--;) {
		solve();
	}
}
accuracy: 1
time_ms: 280
memory_kb: 4300
final_rank: 8

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 9223372036854775807
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 20005

struct Point{

	ll x,y;
};

struct Info{
	bool operator==(const struct Info &arg) const{

		if(bunbo == 0 && arg.bunbo == 0){ //★★★注意★★★

			return true;
		}

		return bunshi == arg.bunshi && bunbo == arg.bunbo;
	}

	ll bunshi,bunbo;
};

int N;
Point point[SIZE];

ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

Info calc_slope(int a,int b){

	Info ret;
	ret.bunbo = point[a].x-point[b].x;
	ret.bunshi = point[a].y-point[b].y;
	ll common = gcd(ret.bunbo,ret.bunshi);

	ret.bunbo /= common;
	ret.bunshi /= common;

	if(ret.bunbo < 0){
		ret.bunshi *= -1;
		ret.bunbo *= -1;
	}
	return ret;
}

void func(){

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&point[i].x,&point[i].y);
	}
	if(N <= 3){

		printf("Yes\n");
		return;
	}

	int tmp_index = -1;
	Info base_info = calc_slope(0,1);

	for(int i = 2; i < N; i++){

		Info tmp_info = calc_slope(0,i);
		if(tmp_info.bunbo != base_info.bunbo || (tmp_info.bunbo != 0 && tmp_info.bunshi != base_info.bunshi)){

			tmp_index = i;
			break;
		}
	}

	if(tmp_index == -1){ //全て同一直線上

		printf("Yes\n");
		return;
	}

	Info work_info1,work_info2;

	for(int loop = 0; loop < 3; loop++){

		switch(loop){
		case 0: //0,1基準
			base_info = calc_slope(0,1);
			break;
		case 1: //1,tmp_index基準
			base_info = calc_slope(1,tmp_index);
			break;
		case 2: //tmp_index,0基準
			base_info = calc_slope(tmp_index,0);
			break;
		}

		bool FLG = true;

		for(int i = 2; i < N; i++){
			if(i == tmp_index)continue;

			bool tmp_FLG = false;

			switch(loop){
			case 0: //0,1基準

				work_info1 = calc_slope(i,tmp_index);
				work_info2 = calc_slope(i,0);

				break;
			case 1: //1,tmp_index基準

				work_info1 = calc_slope(i,0);
				work_info2 = calc_slope(i,1);

				break;
			case 2: //tmp_index,0基準

				work_info1 = calc_slope(i,1);
				work_info2 = calc_slope(i,tmp_index);

				break;
			}

			if(base_info == work_info1 || base_info == work_info2){

				tmp_FLG = true;
			}

			if(!tmp_FLG){
				FLG = false;
				break;
			}
		}
		if(FLG){
			printf("Yes\n");
			return;
		}
	}


	printf("No\n");
}


int main(){

	int num_case;
	scanf("%d",&num_case);

	for(int loop = 0; loop < num_case; loop++){
		scanf("%d",&N);

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 3476
final_rank: 3

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 9223372036854775807
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 20005

struct Point{

	ll x,y;
};

struct Info{
	bool operator==(const struct Info &arg) const{

		if(bunbo == 0 && arg.bunbo == 0){

			return true;
		}

		return bunshi == arg.bunshi && bunbo == arg.bunbo;
	}

	ll bunshi,bunbo;
};

int N;
Point point[SIZE];

ll gcd(ll x,ll y){

	x = abs(x);
	y = abs(y);

	if(x < y){
		swap(x,y);
	}
	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}

Info calc_slope(int a,int b){

	Info ret;
	ret.bunbo = point[a].x-point[b].x;
	ret.bunshi = point[a].y-point[b].y;
	ll common = gcd(ret.bunbo,ret.bunshi);

	ret.bunbo /= common;
	ret.bunshi /= common;

	if(ret.bunbo < 0){
		ret.bunshi *= -1;
		ret.bunbo *= -1;
	}
	return ret;
}

void func(){

	for(int i = 0; i < N; i++){

		scanf("%lld %lld",&point[i].x,&point[i].y);
	}
	if(N <= 3){

		printf("Yes\n");
		return;
	}

	int tmp_index = -1;
	Info base_info = calc_slope(0,1);

	for(int i = 2; i < N; i++){

		Info tmp_info = calc_slope(0,i);
		if(tmp_info.bunbo != base_info.bunbo || (tmp_info.bunbo != 0 && tmp_info.bunshi != base_info.bunshi)){

			tmp_index = i;
			break;
		}
	}

	if(tmp_index == -1){ //全て同一直線上

		printf("Yes\n");
		return;
	}

	Info work_info1,work_info2;

	//printf("tmp_index:%d\n",tmp_index);

	for(int loop = 0; loop < 3; loop++){

		switch(loop){
		case 0: //0,1基準
			base_info = calc_slope(0,1);
			break;
		case 1: //1,tmp_index基準
			base_info = calc_slope(1,tmp_index);
			break;
		case 2: //tmp_index,0基準
			base_info = calc_slope(tmp_index,0);
			break;
		}

		bool FLG = true;

		for(int i = 2; i < N; i++){
			if(i == tmp_index)continue;

			bool tmp_FLG = false;

			switch(loop){
			case 0: //0,1基準

				work_info1 = calc_slope(i,tmp_index);
				work_info2 = calc_slope(i,0);

				break;
			case 1: //1,tmp_index基準

				work_info1 = calc_slope(i,0);
				work_info2 = calc_slope(i,1);

				break;
			case 2: //tmp_index,0基準

				work_info1 = calc_slope(i,1);
				work_info2 = calc_slope(i,tmp_index);

				break;
			}

			if(base_info == work_info1 || base_info == work_info2){

				tmp_FLG = true;
			}

			if(!tmp_FLG){
				/*printf("loop:%d\n",loop);

				printf("base bunbo:%lld bunshi:%lld\n",base_info.bunbo,base_info.bunshi);
				printf("work1: bunbo:%lld bunshi:%lld\n",work_info1.bunbo,work_info1.bunshi);
				printf("work2: bunbo:%lld bunshi:%lld\n",work_info2.bunbo,work_info2.bunshi);*/
				FLG = false;
				break;
			}
		}
		if(FLG){
			printf("Yes\n");
			return;
		}
	}


	printf("No\n");
}


int main(){

	int num_case;
	scanf("%d",&num_case);

	for(int loop = 0; loop < num_case; loop++){
		scanf("%d",&N);

		func();
	}

	return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 3480
final_rank: 4

code_snippet: #include <random>
#include "bits/stdc++.h"
//#include <atcoder/all>

using namespace std;
// using namespace atcoder;

using ld = long double;
using Point = std::complex<ld>;

const ld eps = 1e-9, pi = acos(-1.0);

namespace std {
bool operator<(const Point &lhs, const Point &rhs) {
  if (lhs.real() < rhs.real() - eps) return true;
  if (lhs.real() > rhs.real() + eps) return false;
  return lhs.imag() < rhs.imag();
}
}  // namespace std

Point input_point() {
  ld x, y;
  std::cin >> x >> y;
  return Point(x, y);
}

bool eq(ld a, ld b) { return (abs(a - b) < eps); }

ld dot(Point a, Point b) { return real(conj(a) * b); }

ld cross(Point a, Point b) { return imag(conj(a) * b); }

// CCW::counter clockwise
int ccw(Point a, Point b, Point c) {
  b -= a;
  c -= a;
  if (cross(b, c) > eps) return 1;    // a,b,c : counter-clockwise
  if (cross(b, c) < -eps) return -1;  // a,b,c : clockwise
  if (dot(b, c) < 0) return 2;        // c,a,b : on a line
  if (norm(b) < norm(c)) return -2;   // a,b,c : on a line
  return 0;                           // a,c,b : on a line
}

class Line {
 public:
  Point a, b;
  Line() : a(Point(0, 0)), b(Point(0, 0)) {}
  Line(Point a, Point b) : a(a), b(b) {}
};

ld dot(Line l, Line m) { return dot((l.a - l.b), (m.a - m.b)); }

// l:line, m:line が交点を持つか
bool isis_ll(Line l, Line m) { return !eq(cross(l.b - l.a, m.b - m.a), 0); }

// l:line, s:segment
bool isis_ls(Line l, Line s) {
  return isis_ll(l, s) &&
         (cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < eps);
}

// s:segment, t:segment
bool isis_ss(Line s, Line t) {
  return ccw(s.a, s.b, t.a) * ccw(s.a, s.b, t.b) <= 0 &&
         ccw(t.a, t.b, s.a) * ccw(t.a, t.b, s.b) <= 0;
}

// p が l:line 上に存在するか
bool isis_lp(Line l, Point p) { return (abs(cross(l.b - p, l.a - p)) < eps); }

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  auto output_answer = [](bool f) { cout << (f ? "Yes" : "No") << endl; };
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<Point> ps(n);
    for (int i = 0; i < n; i++) {
      ps[i] = input_point();
    }
    if (n <= 3) {
      output_answer(true);
      continue;
    }
    auto check = [&](Point p1, Point p2) {
      Line l1 = Line(p1, p2);
      vector<Point> not_ls;
      for (int i = 0; i < n; i++) {
        if (!isis_lp(l1, ps[i])) not_ls.emplace_back(ps[i]);
      }
      if (not_ls.size() <= 1) {
        return true;
      }
      Line l2 = Line(not_ls[0], not_ls[1]);
      bool ok = !isis_ll(l1, l2);
      for (auto p : not_ls) {
        if (!isis_lp(l2, p)) ok = false;
      }
      return ok;
    };
    {
      // 全て一直線上 / p[0], p[1] が同じ側
      auto ok = check(ps[0], ps[1]);
      if (ok) {
        output_answer(ok);
        continue;
      }
    }
    // p[0], p[1] が反対側
    {
      // p[0], p[2] が同じ側
      auto ok = check(ps[0], ps[2]);
      if (ok) {
        output_answer(ok);
        continue;
      }
    }
    {
      // p[1], p[2] が同じ側
      auto ok = check(ps[1], ps[2]);
      if (ok) {
        output_answer(ok);
        continue;
      }
    }
    output_answer(false);
  }
}
accuracy: 1
time_ms: 260
memory_kb: 5560
final_rank: 13

code_snippet: #ifdef ONLINE_JUDGE
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
istream& operator>>(istream& is, __int128_t &x) {
    x = 0;
    string s;
    is >> s;
    int n = int(s.size()), it = 0;
    if (s[0] == '-') it++;
    for (; it < n; it++) x = (x * 10 + s[it] - '0');
    if (s[0] == '-') x = -x;
    return is;
}
ostream& operator<<(ostream& os, __int128_t x) {
    if (x == 0) return os << 0;
    if (x < 0) os << '-', x = -x;
    deque<int> deq;
    while (x) deq.emplace_front(x % 10), x /= 10;
    for (int e : deq) os << e;
    return os;
}
template<class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<class T> 
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for(auto e : v) os << e << ", ";
    return os << "]";
}
template<class Container> inline int SZ(Container& v) {return int(v.size());}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31 - __builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63 - __builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline constexpr long long TEN(int x) {return x == 0 ? 1 : TEN(x-1) * 10;}
namespace detail {
    template<typename Tp, int Nb>
    auto make_vector(vector<int>& sizes, Tp const& x) {
        if constexpr (Nb == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[Nb-1];
            sizes.pop_back();
            return vector(size, make_vector<Tp, Nb-1>(sizes, x));
        }
    }
}
template<typename Tp, int Nb>
auto make_vector(int const(&sizes)[Nb], Tp const& x = Tp()) {
    vector<int> s(Nb);
    for (int i = 0; i < Nb; i++) s[i] = sizes[Nb-i-1];
    return detail::make_vector<Tp, Nb>(s, x);
}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T>& v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// 精度が足りないときはlong double
using DD = long double;
constexpr DD EPS = 1e-11;
const DD PI = acos(DD(-1));
inline int sgn(DD a) {return (a < -EPS) ? -1 : (a > EPS) ? 1 : 0;}

//点
struct Point {
    DD x, y;
    Point (DD x = 0, DD y = 0): x(x), y(y) {}

    Point operator+(const Point &p) const { return Point(*this) += p;}
    Point operator-(const Point &p) const { return Point(*this) -= p;}
    Point operator*(const Point &p) const { return Point(*this) *= p;}
    Point operator*(DD a) const { return Point(*this) *= a;}
    Point operator/(DD a) const { return Point(*this) /= a;}
    Point& operator+=(const Point &p) { x += p.x; y += p.y; return *this;}
    Point& operator-=(const Point &p) { x -= p.x; y -= p.y; return *this;}
    Point& operator*=(const Point &p) { DD u = x*p.x - y*p.y; DD v = x*p.y + y*p.x; x = u; y = v; return *this;}
    Point& operator*=(DD a) { x *= a; y *= a; return *this;}
    Point& operator/=(DD a) { x /= a; y /= a; return *this;}
    bool operator==(const Point &p) const { return !sgn(x - p.x) && !sgn(y - p.y);}
    bool operator!=(const Point &p) const { return sgn(x - p.x) || sgn(y - p.y);}
    bool operator<(const Point &p) const {
        if (sgn(x - p.x)) return sgn(x - p.x) < 0;
        return sgn(y - p.y) < 0;
    }
    friend istream& operator>>(istream& is, Point& p) { is >> p.x >> p.y; return is;}
    friend ostream& operator<<(ostream& os, const Point& p) { os << p.x << " " << p.y; return os;}

    DD norm() { return x*x + y*y;}
    DD abs() { return sqrt(norm());}
    DD arg() { return atan2(y,x);}
};

//ベクトル
using Vector = Point;

inline DD norm(const Vector &a) { return a.x * a.x + a.y * a.y;}
inline DD abs(const Vector &a) { return sqrt(norm(a));}
inline DD dot(const Vector &a, const Vector &b) { return a.x * b.x + a.y * b.y;}
inline DD cross(const Vector &a, const Vector &b) { return a.x * b.y - a.y * b.x;}
inline Point rot(const Point &p, DD ang) { return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) { return Point(-p.y, p.x);}
inline DD arg(const Vector &p) { return atan2(p.y, p.x);}
inline Vector polar(DD a, DD r) { return Point(cos(r) * a, sin(r) * a);}
//象限
int ort(const Point &a) {
    if (sgn(norm(a))) {
        if (sgn(a.y) > 0) return sgn(a.x) > 0 ? 1 : 2;
        return sgn(a.x) > 0 ? 4 : 3;
    }
    return 0;
}
bool xsort(const Point &a, const Point &b) {
    if (sgn(a.x - b.x)) return sgn(a.x - b.x) < 0;
    return sgn(a.y - b.y) < 0;
}
bool ysort(const Point &a, const Point &b) {
    if (sgn(a.y - b.y)) return sgn(a.y - b.y) < 0;
    return sgn(a.x - b.x) < 0;
}

bool argsortcross(const Point &a, const Point &b) {
    int ao = ort(a), bo = ort(b);
    if (ao != bo) return ao < bo;
    return sgn(cross(a,b)) > 0;
}

bool argsortatan2(const Point &a, const Point &b) {
    return sgn(atan2(b.y, b.x) - atan2(a.y, a.x)) > 0;
}

//線分
struct Segment {
    Point p1,p2;
    Segment() {};
    Segment(Point p1, Point p2) : p1(p1),p2(p2) {}
};

//直線
using Line = Segment;

// 円
struct Circle {
    Point c;
    DD r;
    Circle(){}
    Circle(Point c, DD r): c(c), r(r) {}
    friend istream& operator >>(istream& is, Circle& C) { is >> C.c >> C.r; return is;}
    friend ostream& operator <<(ostream& os, const Circle& C) { os << C.c << " " << C.r; return os;}
};

//多角形
using Polygon = vector<Point>;

//点の進行方向
int ccw(const Point &p0, const Point &p1, const Point &p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (sgn(cross(a,b)) > 0) return 1; //p0,p1から見てp2は左側(反時計回り)
    if (sgn(cross(a,b)) < 0) return -1; //p0,p1から見てp2は右側(時計回り)
    if (sgn(dot(a,b)) < 0) return 2; //p2-p0-p1の順に一直線上
    if (sgn(norm(b) - norm(a)) > 0) return -2; //p0-p1-p2の順に一直線上
    return 0; //p0-p2-p1の順に一直線上
}

//直線の交差判定 交差する場合1, 平行な場合0, 同一直線のとき-1
int intersectLP(const Vector &a, const Vector &b) {
    if (sgn(cross(a,b))) return 1;
    if (sgn(dot(a,b))) return 0;
    return -1;
} 
int intersectLP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p2-p1,p4-p3);}
int intersectLP(const Line &l1, const Line &l2) {return intersectLP(l1.p1,l1.p2,l2.p1,l2.p2);}

//直線の平行判定
bool isParallel(const Vector &a, Vector &b) {return intersectLP(a,b) <= 0;}
bool isParallel(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p1,p2,p3,p4) <= 0;}
bool isParallel(const Line &l1, const Line &l2) {return intersectLP(l1,l2) <= 0;}

//直線の直交判定
bool isOrthogonal(const Vector &a, const Vector &b) {return !sgn(dot(a,b));}
bool isOrthogonal(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return isOrthogonal(p2-p1,p4-p3);}
bool isOrthogonal(const Line &l1, const Line &l2) {return isOrthogonal(l1.p1,l1.p2,l2.p1,l2.p2);}

//線分の交差判定
bool intersectSP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);}
bool intersectSP(const Segment &s1, const Segment &s2) { return intersectSP(s1.p1, s1.p2, s2.p1, s2.p2);}

//直線と線分の交差判定
bool intersectLSP(const Line &l, const Segment &s) {return ccw(l.p1,l.p2,s.p1)*ccw(l.p1,l.p2,s.p2) <= 0;}

//直線と直線の交点
Point getCrossPointLP(const Line &l1, const Line &l2) {
    assert(intersectLP(l1,l2)==1);
    return l1.p1 + (l1.p2-l1.p1)*cross(l2.p1-l1.p1,l2.p2-l2.p1)/cross(l1.p2-l1.p1,l2.p2-l2.p1);
}

//線分と線分の交点
Point getCrossPointSP(const Segment &s1, const Segment &s2) {
    assert(intersectSP(s1,s2));
    return getCrossPointLP(s1,s2);
}

//射影
Point project(const Segment &s, const Point &p) {
    Vector base = s.p2 - s.p1;
    DD r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

//線対称
Point reflect(const Segment &s, const Point &p) {return p + (project(s,p) - p) * 2;}

//点と直線の距離
DD getDistanceLP(const Line &l, const Point &p) { return abs(cross(l.p2 - l.p1,p - l.p1) / abs(l.p2 - l.p1));}

//点と線分の距離
DD getDistanceSP(const Segment &s, const Point &p) {
    if (sgn(dot(s.p2 - s.p1,p - s.p1)) < 0) return abs(p - s.p1);
    if (sgn(dot(s.p1 - s.p2,p - s.p2)) < 0) return abs(p - s.p2);
    return getDistanceLP(s, p);
}

//直線と直線の距離
DD getDistanceLP(const Line &l1, const Line &l2) {
    if (intersectLP(l1,l2)) return 0;
    return getDistanceLP(l1,l2.p1);
}

//直線と線分の距離
DD getDistanceLSP(const Line &l, const Segment &s) {
    if (intersectLSP(l,s)) return 0;
    return min(getDistanceLP(l,s.p1),getDistanceLP(l,s.p2));
}

//線分と線分の距離
DD getDistanceSP(const Segment &s1, const Segment &s2) {
    if (intersectSP(s1, s2)) return 0;
    return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)});
}

//円と直線の交差判定
bool intersectLP(const Circle &c, const Line &l) { return sgn(getDistanceLP(l, c.c) - c.r) <= 0;}
//円と線分の交差判定
bool intersectSP(const Circle &c, const Segment &s) {
    return sgn(getDistanceSP(s,c.c) - c.r) <= 0 && sgn(max(abs(s.p1 - c.c),abs(s.p2 - c.c)) - c.r) >= 0;
}
//円と円の交差判定
int intersect(const Circle &c1, const Circle &c2) {
    if (sgn(abs(c1.c - c2.c) - (c1.r + c2.r)) > 0) return 4;     //2つの円が離れている場合
    if (!sgn(abs(c1.c - c2.c) - (c1.r + c2.r))) return 3;        //2つの円が外接する場合
    if (sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c)) > 0) return 0; //一方がもう一方を内包する場合
    if (!sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c))) return 1;    //2つの円が内接する場合
    return 2;                                                    //2つの円が交わる場合
}

//円と直線の交点
pair<Point, Point> getCrossPoints(const Circle &c, const Line &l) {
    assert(intersectLP(c,l));
    Vector pr = project(l, c.c);
    Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
    DD base = sqrt(c.r * c.r - norm(pr - c.c));
    return make_pair(pr + e * base, pr - e * base);
}

//円と円の交点
pair<Point, Point> getCrossPoints(const Circle &c1, const Circle &c2) {
    assert(intersect(c1, c2));
    DD d = abs(c1.c - c2.c);
    DD a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (c1.r * d * 2));
    DD t = arg(c2.c - c1.c);
    return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}

//点pを通る円の接線
pair<Line, Line> tangent(const Circle &c, const Point &p) {
    assert(sgn(abs(c.c - p) - c.r) >= 0);
    if (!sgn(abs(c.c - p) - c.r)) {
        Point q = rot90(c.c - p);
        return pair<Line, Line>(Line(p,p+q), Line(p,p+q));
    } 
    Circle c2=Circle(p,sqrt(norm(c.c-p)-c.r*c.r));
    auto q = getCrossPoints(c,c2);
    return pair<Line, Line>(Line(p,q.first), Line(p,q.second));
}

//多角形の面積
DD area(const Polygon &g) {
    const int N = g.size();
    DD ret = 0;
    for (int i = 0; i < N; ++i) {
        ret += cross(g[i],g[(i+1)%N]);
    }
    return fabs(ret)/2;
}

//凸性判定
bool isConvex(const Polygon &g) {
    const int N = g.size();
    for (int i = 0; i < N; ++i) {
        if (ccw(g[i],g[(i+1)%N],g[(i+2)%N]) == -1) return 0;
    }
    return 1;
}

// 多角形-点の包含判定
int containment(const Polygon &g, const Point &p) {
    const int N = g.size();
    DD ang = 0;
    for (int i = 0; i < N; i++) {
        if (!ccw(g[i],g[(i+1)%N],p)) return 1; // pがgの辺上に存在する
        ang += atan2(cross(g[(i+1)%N] - p, g[i] - p), dot(g[(i+1)%N] - p, g[i] - p));
    }
    if (sgn(ang)) return 2; // pがgに含まれる
    return 0; // pがgに含まれない
}

//凸包
Polygon andrewScan(Polygon s) {
    Polygon u,l;
    const int N = s.size();
    if (N < 3) return s;
    sort(s.begin(), s.end(), xsort);
    u.emplace_back(s[0]);
    u.emplace_back(s[1]);
    l.emplace_back(s[N-1]);
    l.emplace_back(s[N-2]);
    
    for (int i = 2; i < s.size(); ++i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = u.size(); n >= 2 && ccw(u[n-2],u[n-1],s[i]) != -1; --n) {
            u.pop_back();
        }
        u.emplace_back(s[i]);
    }

    for (int i = N - 3; i >= 0; --i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) != -1; --n) {
            l.pop_back();
        }
        l.emplace_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; --i) l.emplace_back(u[i]);

    return l;
}

//最遠点対
DD farthestpointpair(const Polygon &g) {
    const int N = g.size();
    if (N == 2) return abs(g[1] - g[0]);
    int i = 0, j = 0;
    for (int k = 0; k < N; ++k) {
        if (g[k].y > g[i].y) i = k;
        if (g[k].y < g[j].y) j = k;
    }

    DD ret = 0;
    int si = i, sj = j;
    while (i != sj || j != si) {
        ret = max(ret, abs(g[i]-g[j]));
        if (sgn(cross(g[(i+1)%N] - g[i], g[(j+1)%N] - g[j])) < 0) {
            ++i;
            if (i == N) i = 0;
        } else {
            ++j;
            if (j == N) j = 0;
        }
    }

    return ret;
}

void solve() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    if (N <= 2) {
        cout << "Yes" << ln;
        return;
    }

    vector<pii> arr = {pii(0,1),pii(1,2),pii(2,0)};
    for (auto &[a,b] : arr) {
        Line l = Line(P[a],P[b]);
        Polygon Q;
        rep(i,N) {
            if (sgn(getDistanceLP(l,P[i])) == 0) continue;
            Q.emplace_back(P[i]);
        }
        if (int(Q.size()) <= 1) {
            cout << "Yes" << ln;
            return;
        }
        Line s = Line(Q[0],Q[1]);
        if (intersectLP(l,s)) continue;
        bool ok = true;
        for (auto &p : Q) {
            if (sgn(getDistanceLP(s,p))) ok = false; 
        }
        if (ok) {
            cout << "Yes" << ln;
            return;
        }
    }

    cout << "No" << ln;
}

int main() {
    int Q; cin >> Q;
    while (Q--) {
        solve();
    }
}
accuracy: 1
time_ms: 240
memory_kb: 5532
final_rank: 11

code_snippet: #ifdef ONLINE_JUDGE
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
istream& operator>>(istream& is, __int128_t &x) {
    x = 0;
    string s;
    is >> s;
    int n = int(s.size()), it = 0;
    if (s[0] == '-') it++;
    for (; it < n; it++) x = (x * 10 + s[it] - '0');
    if (s[0] == '-') x = -x;
    return is;
}
ostream& operator<<(ostream& os, __int128_t x) {
    if (x == 0) return os << 0;
    if (x < 0) os << '-', x = -x;
    deque<int> deq;
    while (x) deq.emplace_front(x % 10), x /= 10;
    for (int e : deq) os << e;
    return os;
}
template<class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<class T> 
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    for(auto e : v) os << e << ", ";
    return os << "]";
}
template<class Container> inline int SZ(Container& v) {return int(v.size());}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31 - __builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63 - __builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline int kthbit(long long x, int k) {return (x>>k)&1;}
inline constexpr long long TEN(int x) {return x == 0 ? 1 : TEN(x-1) * 10;}
namespace detail {
    template<typename Tp, int Nb>
    auto make_vector(vector<int>& sizes, Tp const& x) {
        if constexpr (Nb == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[Nb-1];
            sizes.pop_back();
            return vector(size, make_vector<Tp, Nb-1>(sizes, x));
        }
    }
}
template<typename Tp, int Nb>
auto make_vector(int const(&sizes)[Nb], Tp const& x = Tp()) {
    vector<int> s(Nb);
    for (int i = 0; i < Nb; i++) s[i] = sizes[Nb-i-1];
    return detail::make_vector<Tp, Nb>(s, x);
}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T>& v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// 精度が足りないときはlong double
using DD = double;
constexpr DD EPS = 1e-11;
const DD PI = acos(DD(-1));
inline int sgn(DD a) {return (a < -EPS) ? -1 : (a > EPS) ? 1 : 0;}

//点
struct Point {
    DD x, y;
    Point (DD x = 0, DD y = 0): x(x), y(y) {}

    Point operator+(const Point &p) const { return Point(*this) += p;}
    Point operator-(const Point &p) const { return Point(*this) -= p;}
    Point operator*(const Point &p) const { return Point(*this) *= p;}
    Point operator*(DD a) const { return Point(*this) *= a;}
    Point operator/(DD a) const { return Point(*this) /= a;}
    Point& operator+=(const Point &p) { x += p.x; y += p.y; return *this;}
    Point& operator-=(const Point &p) { x -= p.x; y -= p.y; return *this;}
    Point& operator*=(const Point &p) { DD u = x*p.x - y*p.y; DD v = x*p.y + y*p.x; x = u; y = v; return *this;}
    Point& operator*=(DD a) { x *= a; y *= a; return *this;}
    Point& operator/=(DD a) { x /= a; y /= a; return *this;}
    bool operator==(const Point &p) const { return !sgn(x - p.x) && !sgn(y - p.y);}
    bool operator!=(const Point &p) const { return sgn(x - p.x) || sgn(y - p.y);}
    bool operator<(const Point &p) const {
        if (sgn(x - p.x)) return sgn(x - p.x) < 0;
        return sgn(y - p.y) < 0;
    }
    friend istream& operator>>(istream& is, Point& p) { is >> p.x >> p.y; return is;}
    friend ostream& operator<<(ostream& os, const Point& p) { os << p.x << " " << p.y; return os;}

    DD norm() { return x*x + y*y;}
    DD abs() { return sqrt(norm());}
    DD arg() { return atan2(y,x);}
};

//ベクトル
using Vector = Point;

inline DD norm(const Vector &a) { return a.x * a.x + a.y * a.y;}
inline DD abs(const Vector &a) { return sqrt(norm(a));}
inline DD dot(const Vector &a, const Vector &b) { return a.x * b.x + a.y * b.y;}
inline DD cross(const Vector &a, const Vector &b) { return a.x * b.y - a.y * b.x;}
inline Point rot(const Point &p, DD ang) { return Point(cos(ang) * p.x - sin(ang) * p.y, sin(ang) * p.x + cos(ang) * p.y);}
inline Point rot90(const Point &p) { return Point(-p.y, p.x);}
inline DD arg(const Vector &p) { return atan2(p.y, p.x);}
inline Vector polar(DD a, DD r) { return Point(cos(r) * a, sin(r) * a);}
//象限
int ort(const Point &a) {
    if (sgn(norm(a))) {
        if (sgn(a.y) > 0) return sgn(a.x) > 0 ? 1 : 2;
        return sgn(a.x) > 0 ? 4 : 3;
    }
    return 0;
}
bool xsort(const Point &a, const Point &b) {
    if (sgn(a.x - b.x)) return sgn(a.x - b.x) < 0;
    return sgn(a.y - b.y) < 0;
}
bool ysort(const Point &a, const Point &b) {
    if (sgn(a.y - b.y)) return sgn(a.y - b.y) < 0;
    return sgn(a.x - b.x) < 0;
}

bool argsortcross(const Point &a, const Point &b) {
    int ao = ort(a), bo = ort(b);
    if (ao != bo) return ao < bo;
    return sgn(cross(a,b)) > 0;
}

bool argsortatan2(const Point &a, const Point &b) {
    return sgn(atan2(b.y, b.x) - atan2(a.y, a.x)) > 0;
}

//線分
struct Segment {
    Point p1,p2;
    Segment() {};
    Segment(Point p1, Point p2) : p1(p1),p2(p2) {}
};

//直線
using Line = Segment;

// 円
struct Circle {
    Point c;
    DD r;
    Circle(){}
    Circle(Point c, DD r): c(c), r(r) {}
    friend istream& operator >>(istream& is, Circle& C) { is >> C.c >> C.r; return is;}
    friend ostream& operator <<(ostream& os, const Circle& C) { os << C.c << " " << C.r; return os;}
};

//多角形
using Polygon = vector<Point>;

//点の進行方向
int ccw(const Point &p0, const Point &p1, const Point &p2) {
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (sgn(cross(a,b)) > 0) return 1; //p0,p1から見てp2は左側(反時計回り)
    if (sgn(cross(a,b)) < 0) return -1; //p0,p1から見てp2は右側(時計回り)
    if (sgn(dot(a,b)) < 0) return 2; //p2-p0-p1の順に一直線上
    if (sgn(norm(b) - norm(a)) > 0) return -2; //p0-p1-p2の順に一直線上
    return 0; //p0-p2-p1の順に一直線上
}

//直線の交差判定 交差する場合1, 平行な場合0, 同一直線のとき-1
int intersectLP(const Vector &a, const Vector &b) {
    if (sgn(cross(a,b))) return 1;
    if (sgn(dot(a,b))) return 0;
    return -1;
} 
int intersectLP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p2-p1,p4-p3);}
int intersectLP(const Line &l1, const Line &l2) {return intersectLP(l1.p1,l1.p2,l2.p1,l2.p2);}

//直線の平行判定
bool isParallel(const Vector &a, Vector &b) {return intersectLP(a,b) <= 0;}
bool isParallel(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return intersectLP(p1,p2,p3,p4) <= 0;}
bool isParallel(const Line &l1, const Line &l2) {return intersectLP(l1,l2) <= 0;}

//直線の直交判定
bool isOrthogonal(const Vector &a, const Vector &b) {return !sgn(dot(a,b));}
bool isOrthogonal(const Point &p1, const Point &p2, const Point &p3, const Point &p4) {return isOrthogonal(p2-p1,p4-p3);}
bool isOrthogonal(const Line &l1, const Line &l2) {return isOrthogonal(l1.p1,l1.p2,l2.p1,l2.p2);}

//線分の交差判定
bool intersectSP(const Point &p1, const Point &p2, const Point &p3, const Point &p4) { return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);}
bool intersectSP(const Segment &s1, const Segment &s2) { return intersectSP(s1.p1, s1.p2, s2.p1, s2.p2);}

//直線と線分の交差判定
bool intersectLSP(const Line &l, const Segment &s) {return ccw(l.p1,l.p2,s.p1)*ccw(l.p1,l.p2,s.p2) <= 0;}

//直線と直線の交点
Point getCrossPointLP(const Line &l1, const Line &l2) {
    assert(intersectLP(l1,l2)==1);
    return l1.p1 + (l1.p2-l1.p1)*cross(l2.p1-l1.p1,l2.p2-l2.p1)/cross(l1.p2-l1.p1,l2.p2-l2.p1);
}

//線分と線分の交点
Point getCrossPointSP(const Segment &s1, const Segment &s2) {
    assert(intersectSP(s1,s2));
    return getCrossPointLP(s1,s2);
}

//射影
Point project(const Segment &s, const Point &p) {
    Vector base = s.p2 - s.p1;
    DD r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

//線対称
Point reflect(const Segment &s, const Point &p) {return p + (project(s,p) - p) * 2;}

//点と直線の距離
DD getDistanceLP(const Line &l, const Point &p) { return abs(cross(l.p2 - l.p1,p - l.p1) / abs(l.p2 - l.p1));}

//点と線分の距離
DD getDistanceSP(const Segment &s, const Point &p) {
    if (sgn(dot(s.p2 - s.p1,p - s.p1)) < 0) return abs(p - s.p1);
    if (sgn(dot(s.p1 - s.p2,p - s.p2)) < 0) return abs(p - s.p2);
    return getDistanceLP(s, p);
}

//直線と直線の距離
DD getDistanceLP(const Line &l1, const Line &l2) {
    if (intersectLP(l1,l2)) return 0;
    return getDistanceLP(l1,l2.p1);
}

//直線と線分の距離
DD getDistanceLSP(const Line &l, const Segment &s) {
    if (intersectLSP(l,s)) return 0;
    return min(getDistanceLP(l,s.p1),getDistanceLP(l,s.p2));
}

//線分と線分の距離
DD getDistanceSP(const Segment &s1, const Segment &s2) {
    if (intersectSP(s1, s2)) return 0;
    return min({getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2), getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2)});
}

//円と直線の交差判定
bool intersectLP(const Circle &c, const Line &l) { return sgn(getDistanceLP(l, c.c) - c.r) <= 0;}
//円と線分の交差判定
bool intersectSP(const Circle &c, const Segment &s) {
    return sgn(getDistanceSP(s,c.c) - c.r) <= 0 && sgn(max(abs(s.p1 - c.c),abs(s.p2 - c.c)) - c.r) >= 0;
}
//円と円の交差判定
int intersect(const Circle &c1, const Circle &c2) {
    if (sgn(abs(c1.c - c2.c) - (c1.r + c2.r)) > 0) return 4;     //2つの円が離れている場合
    if (!sgn(abs(c1.c - c2.c) - (c1.r + c2.r))) return 3;        //2つの円が外接する場合
    if (sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c)) > 0) return 0; //一方がもう一方を内包する場合
    if (!sgn(fabs(c1.r - c2.r) - abs(c1.c - c2.c))) return 1;    //2つの円が内接する場合
    return 2;                                                    //2つの円が交わる場合
}

//円と直線の交点
pair<Point, Point> getCrossPoints(const Circle &c, const Line &l) {
    assert(intersectLP(c,l));
    Vector pr = project(l, c.c);
    Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
    DD base = sqrt(c.r * c.r - norm(pr - c.c));
    return make_pair(pr + e * base, pr - e * base);
}

//円と円の交点
pair<Point, Point> getCrossPoints(const Circle &c1, const Circle &c2) {
    assert(intersect(c1, c2));
    DD d = abs(c1.c - c2.c);
    DD a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (c1.r * d * 2));
    DD t = arg(c2.c - c1.c);
    return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a));
}

//点pを通る円の接線
pair<Line, Line> tangent(const Circle &c, const Point &p) {
    assert(sgn(abs(c.c - p) - c.r) >= 0);
    if (!sgn(abs(c.c - p) - c.r)) {
        Point q = rot90(c.c - p);
        return pair<Line, Line>(Line(p,p+q), Line(p,p+q));
    } 
    Circle c2=Circle(p,sqrt(norm(c.c-p)-c.r*c.r));
    auto q = getCrossPoints(c,c2);
    return pair<Line, Line>(Line(p,q.first), Line(p,q.second));
}

//多角形の面積
DD area(const Polygon &g) {
    const int N = g.size();
    DD ret = 0;
    for (int i = 0; i < N; ++i) {
        ret += cross(g[i],g[(i+1)%N]);
    }
    return fabs(ret)/2;
}

//凸性判定
bool isConvex(const Polygon &g) {
    const int N = g.size();
    for (int i = 0; i < N; ++i) {
        if (ccw(g[i],g[(i+1)%N],g[(i+2)%N]) == -1) return 0;
    }
    return 1;
}

// 多角形-点の包含判定
int containment(const Polygon &g, const Point &p) {
    const int N = g.size();
    DD ang = 0;
    for (int i = 0; i < N; i++) {
        if (!ccw(g[i],g[(i+1)%N],p)) return 1; // pがgの辺上に存在する
        ang += atan2(cross(g[(i+1)%N] - p, g[i] - p), dot(g[(i+1)%N] - p, g[i] - p));
    }
    if (sgn(ang)) return 2; // pがgに含まれる
    return 0; // pがgに含まれない
}

//凸包
Polygon andrewScan(Polygon s) {
    Polygon u,l;
    const int N = s.size();
    if (N < 3) return s;
    sort(s.begin(), s.end(), xsort);
    u.emplace_back(s[0]);
    u.emplace_back(s[1]);
    l.emplace_back(s[N-1]);
    l.emplace_back(s[N-2]);
    
    for (int i = 2; i < s.size(); ++i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = u.size(); n >= 2 && ccw(u[n-2],u[n-1],s[i]) != -1; --n) {
            u.pop_back();
        }
        u.emplace_back(s[i]);
    }

    for (int i = N - 3; i >= 0; --i) {
        // 凸包上の点も含めるなら ccw() == 1 含めないなら ccw() != -1
        for (int n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) != -1; --n) {
            l.pop_back();
        }
        l.emplace_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (int i = u.size() - 2; i >= 1; --i) l.emplace_back(u[i]);

    return l;
}

//最遠点対
DD farthestpointpair(const Polygon &g) {
    const int N = g.size();
    if (N == 2) return abs(g[1] - g[0]);
    int i = 0, j = 0;
    for (int k = 0; k < N; ++k) {
        if (g[k].y > g[i].y) i = k;
        if (g[k].y < g[j].y) j = k;
    }

    DD ret = 0;
    int si = i, sj = j;
    while (i != sj || j != si) {
        ret = max(ret, abs(g[i]-g[j]));
        if (sgn(cross(g[(i+1)%N] - g[i], g[(j+1)%N] - g[j])) < 0) {
            ++i;
            if (i == N) i = 0;
        } else {
            ++j;
            if (j == N) j = 0;
        }
    }

    return ret;
}

void solve() {
    int N; cin >> N;
    Polygon P(N);
    rep(i,N) cin >> P[i];

    if (N <= 2) {
        cout << "Yes" << ln;
        return;
    }

    vector<pii> arr = {pii(0,1),pii(1,2),pii(2,0)};
    for (auto &[a,b] : arr) {
        Line l = Line(P[a],P[b]);
        Polygon Q;
        rep(i,N) {
            if (sgn(getDistanceLP(l,P[i])) == 0) continue;
            Q.emplace_back(P[i]);
        }
        if (int(Q.size()) <= 1) {
            cout << "Yes" << ln;
            return;
        }
        Line s = Line(Q[0],Q[1]);
        if (intersectLP(l,s)) continue;
        bool ok = true;
        for (auto &p : Q) {
            if (sgn(getDistanceLP(s,p))) ok = false; 
        }
        if (ok) {
            cout << "Yes" << ln;
            return;
        }
    }

    cout << "No" << ln;
}

int main() {
    int Q; cin >> Q;
    while (Q--) {
        solve();
    }
}
accuracy: 0.8846153846153846
time_ms: 230
memory_kb: 4312
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

bool isheiko(long long dx1, long long dy1, long long dx2, long long dy2) {
    return dx1 * dy2 == dy1 * dx2;
}

bool solve(const vector<long long> &x, const vector<long long> &y) {
    int N = (int)x.size();
    if (N <= 3) return true;
    int k = -1;
    for (int i = 2; i < N; ++i) {
        if (!isheiko(x[i]-x[0], y[i]-y[0], x[1]-x[0], y[1]-y[0])) k = i;
    }
    if (k == -1) return true;

    vector<long long> ax = {x[0], x[1], x[k]}, ay = {y[0], y[1], y[k]};
    for (int iter = 0; iter < 3; ++iter) {
        long long dx = ax[(iter+2)%3] - ax[(iter+1)%3];
        long long dy = ay[(iter+2)%3] - ay[(iter+1)%3];
        bool ok = true;
        for (int i = 0; i < N; ++i) {
            if (!isheiko(x[i]-ax[iter], y[i]-ay[iter], dx, dy) &&
                !isheiko(x[i]-ax[(iter+1)%3], y[i]-ay[(iter+1)%3], dx, dy))
                ok = false;
        }
        if (ok) return true;
    }
    return false;
}

int main() {
    int T; cin >> T;
    while (T--) {
        int N; cin >> N;
        vector<long long> x(N), y(N);
        for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
        if (solve(x, y)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}
accuracy: 1
time_ms: 390
memory_kb: 3396
final_rank: 6

code_snippet: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

template <typename T>
T cross(T a, T b, T c, T d) {
    return a * d - b * c;
}

int main() {
    int T;
    cin >> T;
    vector<int> gp(20010);
    while (T--) {
        int N;
        cin >> N;
        vector<long long> x(N), y(N);
        repeat(i, N) cin >> x[i] >> y[i];
        if (N <= 3) {
            cout << "Yes" << endl;
            continue;
        }
        bool flg = false;
        repeat(i, 3) {
            repeat(j, N) gp[j] = 0;
            // 方向ベクトル i -> (i + 1)%3
            int f1 = i;
            int t1 = (i + 1) % 3;
            int num1 = 2, num2 = 0;
            gp[f1] = gp[t1] = 1;
            repeat(j, N) {
                if (gp[j]) continue;
                // (x[t1] - x[f1], y[t1] - y[f1]) cross (x[j] - x[f1], y[j] - y[f1])
                if (cross(x[t1] - x[f1], y[t1] - y[f1], x[j] - x[f1], y[j] - y[f1]) == 0LL) {
                    gp[j] = 1;
                    ++num1;
                }
            }
            int f2 = -1;
            int t2 = -1;
            repeat(j, N) {
                if (gp[j]) continue;
                if (f2 == -1) {
                    f2 = j;
                    gp[j] = 2;
                    ++num2;
                } else if (t2 == -1) {
                    t2 = j;
                    gp[j] = 2;
                    ++num2;
                } else {
                    assert(f2 != -1 && t2 != -1);
                    if (cross(x[t2] - x[f2], y[t2] - y[f2], x[t1] - x[f1], y[t1] - y[f1]) != 0LL) {
                        break;
                    }
                    // (x[t2] - x[f2], y[t2] - y[f2]) cross (x[j] - x[f2], y[j] - y[f2])
                    if (cross(x[t2] - x[f2], y[t2] - y[f2], x[j] - x[f2], y[j] - y[f2]) == 0LL) {
                        gp[j] = 2;
                        ++num2;
                    }
                }
            }
            if (num1 + num2 == N) {
                if (t2 == -1 || f2 == -1) {
                    flg = true;
                    break;
                }
                if (cross(x[t2] - x[f2], y[t2] - y[f2], x[t1] - x[f1], y[t1] - y[f1]) == 0LL) {
                    flg = true;
                    break;
                }
            }
        }
        if (flg)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 340
memory_kb: 3440
final_rank: 5

code_snippet: #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
#define sz(x) int(x.size())
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

template <typename T>
T cross(T a, T b, T c, T d) {
    return a * d - b * c;
}

int main() {
    int T;
    cin >> T;
    vector<int> gp(20010);
    while (T--) {
        int N;
        cin >> N;
        vector<long long> x(N), y(N);
        repeat(i, N) cin >> x[i] >> y[i];
        if (N <= 3) {
            cout << "Yes" << endl;
            continue;
        }
        bool flg = false;
        repeat(i, 3) {
            repeat(j, N) gp[j] = 0;
            // 方向ベクトル i -> (i + 1)%3
            int f1 = i;
            int t1 = (i + 1) % 3;
            int num1 = 2, num2 = 0;
            gp[f1] = gp[t1] = 1;
            repeat(j, N) {
                if (gp[j]) continue;
                // (x[t1] - x[f1], y[t1] - y[f1]) cross (x[j] - x[f1], y[j] - y[f1])
                if (cross(x[t1] - x[f1], y[t1] - y[f1], x[j] - x[f1], y[j] - y[f1]) == 0LL) {
                    gp[j] = 1;
                    ++num1;
                }
            }
            int f2 = -1;
            int t2 = -1;
            repeat(j, N) {
                if (gp[j]) continue;
                if (f2 == -1) {
                    f2 = j;
                    gp[j] = 2;
                    ++num2;
                } else if (t2 == -1) {
                    t2 = j;
                    gp[j] = 2;
                    ++num2;
                } else {
                    assert(f2 != -1 && t2 != -1);
                    if (cross(x[t2] - x[f2], y[t2] - y[f2], x[t1] - x[f1], y[t1] - y[f1]) != 0LL) {
                        break;
                    }
                    // (x[t2] - x[f2], y[t2] - y[f2]) cross (x[j] - x[f2], y[j] - y[f2])
                    if (cross(x[t2] - x[f2], y[t2] - y[f2], x[j] - x[f2], y[j] - y[f2]) == 0LL) {
                        gp[j] = 2;
                        ++num2;
                    }
                }
            }
            if (num1 + num2 == N) {
                if (cross(x[t2] - x[f2], y[t2] - y[f2], x[t1] - x[f1], y[t1] - y[f1]) == 0LL) {
                    flg = true;
                }
            }
        }
        if (flg)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}
accuracy: 0.7692307692307693
time_ms: 340
memory_kb: 3464
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define int long long
vector<string> ans;
struct Q{int s,b;};
void update(Q &a){
  if(a.b==0&&a.s==0)return;
  int g=__gcd(abs(a.b),abs(a.s));
  a.b/=g;a.s/=g;
  if(a.b<0)a.s*=-1,a.b*=-1;
  if(a.b==0)a.s=abs(a.s);
}
bool same(Q &a,Q &b){
  update(a);update(b);
  return a.s==b.s&&a.b==b.b;
}

string solve(){
  int n;cin>>n;
  vector<int> x(n),y(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  set<int> S;for(int p:x)S.insert(p);if(S.size()<=2)return "Yes";
  for(int _=0;_<1000;_++){
    int s=rand()%n,t=rand()%n;
    while(x[s]==x[t])(++t)%=n;
    //cout<<x[s]<<" "<<y[s]<<" "<<x[t]<<" "<<y[t]<<endl;
    Q slope={y[s]-y[t],x[s]-x[t]};update(slope);
    Q se1,se2;
    se2={0,0};update(se2);//cout<<"SSS"<<se2.b<<" "<<se2.s<<endl;
    se1={x[s]*y[t]-x[t]*y[s],x[s]-x[t]};update(se1);
    int out=0;
    for(int i=0;i<n&&!out;i++){
      Q tmp={slope.b*y[i]-slope.s*x[i],slope.b};update(tmp);
      if(same(tmp,se1)||same(tmp,se2))continue;
      if(!se2.s&&!se2.b)se2=tmp;
      else out=1;
    }
    //if(!out)cout<<x[s]<<" "<<y[s]<<" "<<x[t]<<" "<<y[t]<<" "<<se1.b<<" "<<se1.s<<" "<<se2.b<<" "<<se2.s<<endl;
    if(!out)return "Yes";
  }
  return "No";
}

signed main(){
  int t;cin>>t;
  while(t--)ans.push_back(solve());
  for(auto p:ans)cout<<p<<endl;
}
accuracy: 1
time_ms: 740
memory_kb: 4500
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ld=long double;
struct line{ld a,b;};//y=ax+b

bool same(ld x,ld y){
  return abs(x-y)<1e-1;
}

line f(ld x1,ld y1,ld x2,ld y2){//2点を通る直線
  return {(y1-y2)/(x1-x2),(y2*x1-y1*x2)/(x1-x2)};
}
line g(ld x1,ld y1,ld x2,ld y2,ld x3,ld y3){
  ld a=f(x2,y2,x3,y3).a;
  return {a,(y1+y2)/2.0-a*(x1+x2)/2.0};
}

ld d(line A,ld x,ld y){//直線と点の距離
  return abs(A.a*x-y+A.b)/sqrt(A.a*A.a+1.0);
}

bool check1(vector<ld> &x,vector<ld> &y){
  line a=f((x[1]+x[2])/2.0,(y[1]+y[2])/2.0,(x[0]+x[2])/2.0,(y[0]+y[2])/2.0);
  ld D=d(a,x[0],y[0]);
  for(int i=0;i<x.size();i++)if(!same(d(a,x[i],y[i]),D))return false;
  return true;
}

bool check2(vector<ld> &x,vector<ld> &y){
  line a=g(x[0],y[0],x[2],y[2],x[1],y[1]);
  ld D=d(a,x[0],y[0]);
  for(int i=0;i<x.size();i++)if(!same(d(a,x[i],y[i]),D))return false;
  return true;
}

string solve(){
  int n;cin>>n;
  vector<ld> x(n),y(n);
  for(int i=0;i<n;i++)cin>>x[i]>>y[i];
  if(n<=3)return "Yes";

  set<int> XX;
  for(ld p:x)XX.insert(round(p));
  if(XX.size()<=2)return "Yes";

  int cnt=0;

  AHAHA:
  assert(++cnt<=1000);
  for(int i=2;i<n&&same(x[0],x[1]);i++)
    if(!same(x[i],x[0])){
      swap(x[i],x[1]);
      swap(y[i],y[1]);
    }
  for(int i=3;i<n&&(same(x[0],x[2])||same(x[1],x[2]));i++)
    if(!same(x[i],x[0])&&!same(x[i],x[1])){
      swap(x[i],x[2]);
      swap(y[i],y[2]);
    }

  line A=f(x[0],y[0],x[1],y[1]);
  bool F=true;
  for(int i=2;i<n;i++)
    if(!same(A.a*x[i]+A.b,y[i])){
      F=false;
      if(!same(x[0],x[i])&&!same(x[1],x[i])){
        swap(x[i],x[2]);
        swap(y[i],y[2]);
      }
    }
  if(F)return "Yes";
  if(same(A.a*x[2]+A.b,y[2])){
    int aa=rand()%(n-2)+2,bb=rand()%(n-2)+2;
    swap(x[0],x[aa]);swap(y[0],y[aa]);
    swap(x[1],x[bb]);swap(y[1],y[bb]);
    goto AHAHA;
  }

  if(check1(x,y)||check2(x,y))return "Yes";
  swap(x[2],x[1]);swap(y[2],y[1]);
  if(check1(x,y)||check2(x,y))return "Yes";
  swap(x[2],x[0]);swap(y[2],y[0]);
  if(check1(x,y)||check2(x,y))return "Yes";
  return "No";
}

int main(){
  int t;cin>>t;
  vector<string> ans;
  while(t--)ans.push_back(solve());
  for(string p:ans)cout<<p<<endl;
}
accuracy: 0.8846153846153846
time_ms: 710
memory_kb: 5148
final_rank: 19