{"raw_statement":[{"iden":"statement","content":"You are given a set of _n_ points on the plane. A line containing the origin is called good, if projection of the given set to this line forms a symmetric multiset of points. Find the total number of good lines.\n\nMultiset is a set where equal elements are allowed.\n\nMultiset is called symmetric, if there is a point _P_ on the plane such that the multiset is [centrally symmetric](https://en.wikipedia.org/wiki/Point_reflection) in respect of point _P_."},{"iden":"input","content":"The first line contains a single integer _n_ (1 ≤ _n_ ≤ 2000) — the number of points in the set.\n\nEach of the next _n_ lines contains two integers _x__i_ and _y__i_ ( - 106  ≤  _x__i_,  _y__i_  ≤  106) — the coordinates of the points. It is guaranteed that no two points coincide."},{"iden":"output","content":"If there are infinitely many good lines, print _\\-1_.\n\nOtherwise, print single integer — the number of good lines."},{"iden":"examples","content":"Input\n\n3\n1 2\n2 1\n3 3\n\nOutput\n\n3\n\nInput\n\n2\n4 3\n1 2\n\nOutput\n\n\\-1"},{"iden":"note","content":"Picture to the first sample test:\n\n![image](https://espresso.codeforces.com/eedc60313be8684bd6169b8b23f0f0afd92479a8.png)\n\nIn the second sample, any line containing the origin is good."}],"translated_statement":[{"iden":"statement","content":"给定平面上的一组 #cf_span[n] 个点。一条经过原点的直线被称为“好线”，当且仅当该点集在该直线上的投影形成一个对称的多重集。\n\n多重集是指允许重复元素的集合。\n\n一个多重集被称为对称的，如果存在平面上的一个点 #cf_span[P]，使得该多重集关于点 #cf_span[P] 中心对称。\n\n第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2000]) —— 点集中的点数。\n\n接下来的 #cf_span[n] 行，每行包含两个整数 #cf_span[xi] 和 #cf_span[yi] (#cf_span[ - 106  ≤  xi,  yi  ≤  106]) —— 点的坐标。保证没有两个点重合。\n\n如果存在无穷多条好线，请输出 _-1_。\n\n否则，输出一个整数 —— 好线的总数。\n\n第一个样例的图示：\n\n \n\n在第二个样例中，任何经过原点的直线都是好线。"},{"iden":"input","content":"第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 2000]) —— 点集中的点数。接下来的 #cf_span[n] 行，每行包含两个整数 #cf_span[xi] 和 #cf_span[yi] (#cf_span[ - 106  ≤  xi,  yi  ≤  106]) —— 点的坐标。保证没有两个点重合。"},{"iden":"output","content":"如果存在无穷多条好线，请输出 _-1_。否则，输出一个整数 —— 好线的总数。"},{"iden":"examples","content":"输入31 22 13 3输出3输入24 31 2输出-1"},{"iden":"note","content":"第一个样例的图示：在第二个样例中，任何经过原点的直线都是好线。"}],"sample_group":[],"show_order":[],"formal_statement":"Let $ S = \\{ \\mathbf{p}_1, \\mathbf{p}_2, \\dots, \\mathbf{p}_n \\} \\subset \\mathbb{R}^2 $ be a set of $ n $ distinct points in the plane, with $ \\mathbf{p}_i = (x_i, y_i) $.\n\nFor a line $ \\ell $ passing through the origin, let $ \\pi_\\ell : \\mathbb{R}^2 \\to \\ell $ denote the orthogonal projection onto $ \\ell $. Define the projected multiset:\n$$\nP_\\ell = \\{ \\pi_\\ell(\\mathbf{p}_i) \\mid \\mathbf{p}_i \\in S \\}.\n$$\n\nA line $ \\ell $ is **good** if $ P_\\ell $ is **centrally symmetric** about some point $ \\mathbf{P} \\in \\ell $, i.e., for every point $ \\mathbf{q} \\in P_\\ell $, the point $ 2\\mathbf{P} - \\mathbf{q} $ is also in $ P_\\ell $ with the same multiplicity.\n\nLet $ \\theta \\in [0, \\pi) $ parametrize the direction of $ \\ell $, so that $ \\ell = \\{ t (\\cos\\theta, \\sin\\theta) \\mid t \\in \\mathbb{R} \\} $.\n\nWe are to compute the number of distinct directions $ \\theta \\in [0, \\pi) $ for which $ P_\\ell $ is centrally symmetric.\n\n**Key observations:**\n\n1. The projection $ \\pi_\\ell(\\mathbf{p}_i) $ is the scalar projection along the unit vector $ \\mathbf{u}_\\theta = (\\cos\\theta, \\sin\\theta) $:\n   $$\n   \\pi_\\ell(\\mathbf{p}_i) = (\\mathbf{p}_i \\cdot \\mathbf{u}_\\theta) \\cdot \\mathbf{u}_\\theta.\n   $$\n   The **scalar coordinate** of the projection along $ \\ell $ is $ s_i = \\mathbf{p}_i \\cdot \\mathbf{u}_\\theta = x_i \\cos\\theta + y_i \\sin\\theta $.\n\n2. The multiset $ P_\\ell $ is centrally symmetric about some point $ \\mathbf{P} \\in \\ell $ **if and only if** the multiset of scalar projections $ \\{ s_1, s_2, \\dots, s_n \\} $ is centrally symmetric about some $ c \\in \\mathbb{R} $, i.e., for every $ s_i $, $ 2c - s_i $ is also in the multiset with the same multiplicity.\n\n3. A multiset of real numbers is centrally symmetric about $ c $ if and only if:\n   $$\n   \\{ s_1, \\dots, s_n \\} = \\{ 2c - s_1, \\dots, 2c - s_n \\}.\n   $$\n   This implies that the multiset is symmetric about its **mean** (if $ n $ is odd, the center must be the median, which must equal the mean). Thus, the only possible center is $ c = \\frac{1}{n} \\sum_{i=1}^n s_i $, and the condition becomes:\n   $$\n   \\forall i, \\exists j \\text{ such that } s_j = 2c - s_i.\n   $$\n\n4. Since $ c = \\frac{1}{n} \\sum_{i=1}^n \\mathbf{p}_i \\cdot \\mathbf{u}_\\theta = \\left( \\frac{1}{n} \\sum_{i=1}^n \\mathbf{p}_i \\right) \\cdot \\mathbf{u}_\\theta = \\bar{\\mathbf{p}} \\cdot \\mathbf{u}_\\theta $, where $ \\bar{\\mathbf{p}} = \\frac{1}{n} \\sum \\mathbf{p}_i $, the condition becomes:\n   $$\n   \\forall i, \\exists j \\text{ such that } \\mathbf{p}_i \\cdot \\mathbf{u}_\\theta + \\mathbf{p}_j \\cdot \\mathbf{u}_\\theta = 2 \\bar{\\mathbf{p}} \\cdot \\mathbf{u}_\\theta,\n   $$\n   or equivalently,\n   $$\n   (\\mathbf{p}_i + \\mathbf{p}_j - 2\\bar{\\mathbf{p}}) \\cdot \\mathbf{u}_\\theta = 0.\n   $$\n\n5. Define the **centered points**: $ \\mathbf{q}_i = \\mathbf{p}_i - \\bar{\\mathbf{p}} $. Then the condition becomes:\n   $$\n   \\forall i, \\exists j \\text{ such that } (\\mathbf{q}_i + \\mathbf{q}_j) \\cdot \\mathbf{u}_\\theta = 0.\n   $$\n   That is, $ \\mathbf{q}_i + \\mathbf{q}_j \\perp \\mathbf{u}_\\theta $.\n\n6. For the multiset of projections to be symmetric, the set $ \\{ \\mathbf{q}_1, \\dots, \\mathbf{q}_n \\} $ must be **centrally symmetric about the origin** in the plane — **but only along the direction $ \\mathbf{u}_\\theta $**. That is, for the projection to be symmetric, the set $ \\{ \\mathbf{q}_i \\} $ must be symmetric under reflection through the origin **in the direction of $ \\ell $**.\n\n   However, a necessary and sufficient condition is:\n\n   > The multiset $ \\{ \\mathbf{p}_i \\} $ is such that the set of vectors $ \\{ \\mathbf{p}_i - \\bar{\\mathbf{p}} \\} $ is centrally symmetric **as a whole** — then **every** line through the origin is good. Otherwise, only lines $ \\ell $ for which the projection of the centered set is symmetric (i.e., the direction $ \\mathbf{u}_\\theta $ is orthogonal to some $ \\mathbf{q}_i + \\mathbf{q}_j $) are candidates.\n\n7. **Critical insight**: The set of projections $ \\{ s_i \\} $ is centrally symmetric **if and only if** the multiset $ \\{ \\mathbf{q}_i \\} $ is centrally symmetric **in the direction of $ \\ell $**. That is, for every $ \\mathbf{q}_i $, there exists $ \\mathbf{q}_j $ such that $ \\mathbf{q}_i + \\mathbf{q}_j \\perp \\mathbf{u}_\\theta $.\n\n   But this must hold for **all** $ i $. So, the set $ \\{ \\mathbf{q}_i \\} $ must be centrally symmetric **as a whole** (i.e., $ \\{ \\mathbf{q}_i \\} = \\{ -\\mathbf{q}_i \\} $), or else only specific directions $ \\mathbf{u}_\\theta $ satisfy the condition.\n\n8. **Final characterization**:\n\n   - If the entire set $ S $ is centrally symmetric about $ \\bar{\\mathbf{p}} $, i.e., $ \\{ \\mathbf{p}_i \\} = \\{ 2\\bar{\\mathbf{p}} - \\mathbf{p}_i \\} $, then **every** line through the origin is good → output $ -1 $.\n\n   - Otherwise, the good lines correspond to directions $ \\mathbf{u}_\\theta $ such that $ \\mathbf{u}_\\theta \\perp (\\mathbf{q}_i + \\mathbf{q}_j) $ for some pair $ (i,j) $, and the multiset of projections is symmetric. But since the set is not centrally symmetric globally, the only possible good lines are those perpendicular to $ \\mathbf{q}_i + \\mathbf{q}_j $ for some pair $ i < j $, **and** for which the projection symmetry condition holds.\n\n   However, a simpler and known approach from competitive programming problems (e.g., CodeForces) is:\n\n   > The number of good lines equals the number of distinct directions $ \\theta \\in [0, \\pi) $ such that the multiset $ \\{ \\mathbf{p}_i \\cdot \\mathbf{u}_\\theta \\} $ is symmetric about its mean.\n\n   This happens if and only if the multiset $ \\{ \\mathbf{q}_i \\} $ is symmetric under reflection through the origin **along $ \\ell $**, i.e., the set of vectors $ \\{ \\mathbf{q}_i \\} $ is symmetric under the operation of negating components **along $ \\ell $**.\n\n   The only directions $ \\ell $ that can work are those for which the set $ \\{ \\mathbf{q}_i \\} $ is symmetric with respect to the line perpendicular to $ \\ell $ — i.e., $ \\ell $ is an axis of symmetry of the multiset $ \\{ \\mathbf{q}_i \\} $ **through the origin**.\n\n   But since we are projecting onto $ \\ell $, and requiring the **projection** to be centrally symmetric, the correct known solution is:\n\n   > Good lines correspond to directions $ \\mathbf{u} $ such that the multiset $ \\{ \\mathbf{q}_i \\} $ is symmetric under the transformation $ \\mathbf{v} \\mapsto -\\mathbf{v} $ **when projected onto $ \\mathbf{u}^\\perp $** — i.e., $ \\mathbf{u} $ is perpendicular to a vector $ \\mathbf{q}_i + \\mathbf{q}_j $ for some pair $ i, j $, and the pairing covers all points.\n\n   Actually, the known solution (from CodeForces problems like \"Good Line\") is:\n\n   - Compute $ \\bar{\\mathbf{p}} = \\frac{1}{n} \\sum \\mathbf{p}_i $.\n   - Compute $ \\mathbf{q}_i = \\mathbf{p}_i - \\bar{\\mathbf{p}} $.\n   - If all $ \\mathbf{q}_i = \\mathbf{0} $, then all points coincide — contradiction (guaranteed distinct), so skip.\n   - If $ \\{ \\mathbf{q}_i \\} = \\{ -\\mathbf{q}_i \\} $ as multisets → then every line is good → output $ -1 $.\n   - Otherwise, for each unordered pair $ (i, j) $ with $ i < j $, compute $ \\mathbf{v}_{ij} = \\mathbf{q}_i + \\mathbf{q}_j $. If $ \\mathbf{v}_{ij} \\ne \\mathbf{0} $, then the direction $ \\ell $ perpendicular to $ \\mathbf{v}_{ij} $ is a candidate.\n   - For each such candidate direction (i.e., normalized vector $ \\mathbf{u} \\perp \\mathbf{v}_{ij} $), check whether the projection of $ \\{ \\mathbf{q}_i \\} $ onto $ \\ell $ is centrally symmetric (i.e., the multiset of dot products $ \\{ \\mathbf{q}_i \\cdot \\mathbf{u} \\} $ is symmetric about 0).\n   - Count distinct such directions $ \\mathbf{u} \\in [0, \\pi) $.\n\n   But note: since $ \\mathbf{u} \\perp \\mathbf{v}_{ij} $, then $ \\mathbf{u} \\cdot (\\mathbf{q}_i + \\mathbf{q}_j) = 0 \\Rightarrow \\mathbf{q}_i \\cdot \\mathbf{u} = - \\mathbf{q}_j \\cdot \\mathbf{u} $, so at least this pair is symmetric. But we need **all** points to pair up.\n\n   So the algorithm:\n\n   - If the multiset $ \\{ \\mathbf{q}_i \\} $ is centrally symmetric about origin → output $ -1 $.\n   - Else:\n     - Initialize a set $ D $ of directions.\n     - For each pair $ (i, j) $, $ i < j $:\n       - Let $ \\mathbf{v} = \\mathbf{q}_i + \\mathbf{q}_j $.\n       - If $ \\mathbf{v} \\ne \\mathbf{0} $, compute a unit vector $ \\mathbf{u} $ perpendicular to $ \\mathbf{v} $, normalized to direction in $ [0, \\pi) $.\n       - Check if the multiset $ \\{ \\mathbf{q}_k \\cdot \\mathbf{u} \\} $ is symmetric about 0.\n       - If yes, add $ \\mathbf{u} $ to $ D $ (as a normalized direction, avoiding duplicates).\n     - Output $ |D| $.\n\n   However, note that if $ \\mathbf{v} = \\mathbf{0} $, then $ \\mathbf{q}_j = -\\mathbf{q}_i $, so this pair is already symmetric — but we still need to check global symmetry.\n\n   So the **formal statement** is:\n\n---\n\n**Definitions:**\n\n- Let $ \\mathbf{p}_1, \\dots, \\mathbf{p}_n \\in \\mathbb{R}^2 $ be distinct points.\n- Let $ \\bar{\\mathbf{p}} = \\frac{1}{n} \\sum_{i=1}^n \\mathbf{p}_i $.\n- Let $ \\mathbf{q}_i = \\mathbf{p}_i - \\bar{\\mathbf{p}} $ for $ i = 1, \\dots, n $.\n\n**Given:**\n\n- $ \\mathbf{q}_i \\ne \\mathbf{0} $ for at least one $ i $ (since points are distinct).\n- The multiset $ \\{ \\mathbf{q}_1, \\dots, \\mathbf{q}_n \\} $ is **not necessarily** centrally symmetric about $ \\mathbf{0} $.\n\n**Objective:**\n\nFind the number of distinct unit vectors $ \\mathbf{u} \\in \\mathbb{R}^2 $ with $ \\|\\mathbf{u}\\| = 1 $, and $ \\mathbf{u} $ representing a direction in $ [0, \\pi) $, such that the multiset $ \\{ \\mathbf{q}_i \\cdot \\mathbf{u} \\mid i = 1, \\dots, n \\} $ is symmetric about 0.\n\nThat is:\n\n$$\n\\{ \\mathbf{q}_1 \\cdot \\mathbf{u}, \\dots, \\mathbf{q}_n \\cdot \\mathbf{u} \\} = \\{ -(\\mathbf{q}_1 \\cdot \\mathbf{u}), \\dots, -(\\mathbf{q}_n \\cdot \\mathbf{u}) \\}\n$$\n\nas multisets.\n\n**Equivalently:**\n\nThe multiset $ \\{ \\mathbf{q}_i \\cdot \\mathbf{u} \\} $ is symmetric about 0 if and only if for every $ i $, there exists $ j $ such that $ \\mathbf{q}_i \\cdot \\mathbf{u} = - \\mathbf{q}_j \\cdot \\mathbf{u} $, and multiplicities match.\n\n**Constraint:**\n\nIf $ \\{ \\mathbf{q}_i \\} = \\{ -\\mathbf{q}_i \\} $ as multisets, then **every** $ \\mathbf{u} $ satisfies the condition → output $ -1 $.\n\nOtherwise, count the number of distinct directions $ \\mathbf{u} \\in S^1 / \\sim $ (where $ \\mathbf{u} \\sim -\\mathbf{u} $) for which $ \\{ \\mathbf{q}_i \\cdot \\mathbf{u} \\} $ is symmetric about 0.\n\n---\n\n**Final Formal Statement:**\n\nLet $ \\mathbf{q}_i = \\mathbf{p}_i - \\frac{1}{n} \\sum_{j=1}^n \\mathbf{p}_j $ for $ i = 1, \\dots, n $.\n\n- If $ \\{ \\mathbf{q}_1, \\dots, \\mathbf{q}_n \\} = \\{ -\\mathbf{q}_1, \\dots, -\\mathbf{q}_n \\} $ as multisets, output $ -1 $.\n- Else, let $ \\mathcal{U} = \\left\\{ \\mathbf{u} \\in \\mathbb{R}^2 \\mid \\|\\mathbf{u}\\| = 1, \\{ \\mathbf{q}_i \\cdot \\mathbf{u} \\}_{i=1}^n \\text{ is symmetric about } 0 \\right\\} $.\n- Output $ \\left| \\left\\{ \\mathbf{u} \\in \\mathcal{U} \\mid \\mathbf{u} \\in [0, \\pi) \\text{ direction} \\right\\} \\right| $.\n\nWhere \"direction in $ [0, \\pi) $\" means we identify $ \\mathbf{u} $ and $ -\\mathbf{u} $, and represent each line by its unique unit vector with angle $ \\theta \\in [0, \\pi) $.\n\n---","simple_statement":null,"has_page_source":false}