#[allow(unused_imports)] use std::io::{stdout, BufWriter, Write}; fn main() { let out = stdout(); let mut out = BufWriter::new(out.lock()); inputv! { n:usize, } let mut v = vec![]; for _ in 0..n { inputv! { x:isize,y:isize, } v.push(Point::new(x, y)); } let mut ans = 0; for i in 0..n { for j in i + 1..n { let mut count = 0; for k in 0..n { if is_parallel(v[i], v[k], v[j], v[k]) { count += 1; } } ans = std::cmp::max(ans, count); } } println!("{}", ans); } //https://github.com/manta1130/competitive-template-rs use geometry::*; use input::*; pub mod geometry { use std::collections::VecDeque; use std::default::Default; use std::ops::{Add, AddAssign, Div, Mul, Neg, Sub, SubAssign}; #[derive(Debug, Copy, Clone, PartialEq)] pub struct Point { pub x: T, pub y: T, } impl Point { pub fn new(x: T, y: T) -> Point { Point { x, y } } } impl Add for Point where T: Add, { type Output = Point; fn add(self, other: Point) -> Point { Point::new(self.x + other.x, self.y + other.y) } } impl AddAssign for Point where T: AddAssign, { fn add_assign(&mut self, other: Point) { self.x += other.x; self.y += other.y; } } impl Sub for Point where T: Sub, { type Output = Point; fn sub(self, other: Point) -> Point { Point::new(self.x - other.x, self.y - other.y) } } impl SubAssign for Point where T: SubAssign, { fn sub_assign(&mut self, other: Point) { self.x -= other.x; self.y -= other.y; } } #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum LineStatus { Horizontal, Vertical, Normal, } #[derive(Debug, Copy, Clone, PartialEq)] pub struct Line { a: T, b: T, status: LineStatus, } impl Line where T: Copy + Clone + Add + Sub + Div + Mul + PartialEq + Neg + Default, { pub fn new(a: T, b: T) -> Line { Line { a, b, status: LineStatus::Normal, } } #[allow(clippy::eq_op)] pub fn new_horizontal(y: T) -> Line { Line { a: T::default(), b: y, status: LineStatus::Horizontal, } } #[allow(clippy::eq_op)] pub fn new_vertical(x: T) -> Line { Line { a: T::default(), b: x, status: LineStatus::Vertical, } } pub fn from(l1: Point, l2: Point) -> Option> { if l1 == l2 { return None; } let (a, b, status); if l1.x == l2.x { a = T::default(); b = l1.x; status = LineStatus::Vertical; } else if l1.y == l2.y { a = T::default(); b = l1.y; status = LineStatus::Horizontal; } else { a = (l1.y - l2.y) / (l1.x - l2.x); b = l1.y - a * l1.x; status = LineStatus::Normal; } Some(Line { a, b, status }) } pub fn from_point_slope(p: Point, a: T, s: LineStatus) -> Line { if s == LineStatus::Horizontal { Line::new_horizontal(p.y) } else if s == LineStatus::Vertical { Line::new_vertical(p.x) } else { Line::new(a, p.y - a * p.x) } } pub fn get_intersection(&self, other: Line) -> Option> { if self.get_status() == LineStatus::Normal && other.get_status() == LineStatus::Normal { let x = (other.get_intercept() - self.get_intercept()) / (self.get_slope() - other.get_slope()); Some(Point { x, y: x * self.get_slope() + self.get_intercept(), }) } else if self.status == other.status { None } else if self.is_horizontal() && other.is_vertical() { Some(Point { x: other.get_intercept(), y: self.get_intercept(), }) } else if self.is_vertical() && other.is_horizontal() { Some(Point { y: other.get_intercept(), x: self.get_intercept(), }) } else if self.is_horizontal() || self.is_vertical() { if self.is_horizontal() { let y = self.get_intercept(); Some(Point { x: other.substitution_y(y).unwrap(), y, }) } else { let x = self.get_intercept(); Some(Point { x, y: other.substitution_x(x).unwrap(), }) } } else if other.is_horizontal() { let y = other.get_intercept(); Some(Point { x: self.substitution_y(y).unwrap(), y, }) } else { let x = other.get_intercept(); Some(Point { x, y: self.substitution_x(x).unwrap(), }) } } pub fn get_slope(&self) -> T { self.a } pub fn get_intercept(&self) -> T { self.b } pub fn get_data(&self) -> (T, T) { (self.a, self.b) } pub fn is_horizontal(&self) -> bool { self.status == LineStatus::Horizontal } pub fn is_vertical(&self) -> bool { self.status == LineStatus::Vertical } pub fn get_status(&self) -> LineStatus { self.status } pub fn substitution_x(&self, x: T) -> Option { if self.is_horizontal() { Some(self.get_intercept()) } else if self.is_vertical() { None } else { Some(self.get_slope() * x + self.get_intercept()) } } pub fn substitution_y(&self, y: T) -> Option { if self.is_horizontal() { None } else if self.is_vertical() { Some(self.get_intercept()) } else { Some((y - self.get_intercept()) / self.get_slope()) } } } impl Line where T: Copy + Clone + Add + Sub + Div + Mul + PartialEq + Neg + Default + Into, { pub fn get_perpendicular(&self, p: Point) -> Line { Line::from_point_slope( Point::new(p.x.into(), p.y.into()), -(1.0 / self.get_slope().into()), match self.get_status() { LineStatus::Horizontal => LineStatus::Vertical, LineStatus::Vertical => LineStatus::Horizontal, LineStatus::Normal => LineStatus::Normal, }, ) } } pub fn cross(p1: Point, p2: Point) -> T where T: Sub + Mul, { p1.x * p2.y - p1.y * p2.x } pub fn dot(p1: Point, p2: Point) -> T where T: Add + Mul, { p1.x * p2.x + p1.y * p2.y } pub fn norm(p: Point) -> T where T: Mul + Add + Copy, { p.x * p.x + p.y * p.y } pub fn ccw(a: Point, mut b: Point, mut c: Point) -> isize where T: SubAssign + Sub + Mul + Copy + PartialOrd + Add + Default, { let zero = T::default(); b -= a; c -= a; if cross(b, c) > zero { 1 } else if cross(b, c) < zero { -1 } else if dot(b, c) < zero { 2 } else if norm(b) < norm(c) { -2 } else { 0 } } pub fn is_parallel(p11: Point, p12: Point, p21: Point, p22: Point) -> bool where T: Sub + Mul + PartialEq, { (p12.y - p11.y) * (p22.x - p21.x) == (p22.y - p21.y) * (p12.x - p11.x) } pub fn is_orthogonal(p11: Point, p12: Point, p21: Point, p22: Point) -> bool where T: Sub + Mul + Neg + PartialEq, { (p12.y - p11.y) * (p22.y - p21.y) == -(p22.x - p21.x) * (p12.x - p11.x) } pub fn arg_sort(v: &mut [Point], origin: Point, start: Point) where T: Add + Sub + SubAssign + Mul + PartialOrd + Copy + Default, { arg_sort_internal(v, origin, start, 0, v.len(), true); } #[allow(clippy::many_single_char_names)] fn arg_sort_internal( v: &mut [Point], origin: Point, pivot: Point, f: usize, t: usize, flag: bool, ) where T: Add + Sub + SubAssign + Mul + PartialOrd + Copy + Default, { if f == t { return; } let zero = T::default(); let mut plus = vec![]; let mut minus = vec![]; let mut inv = vec![]; let mut r = vec![]; let mut origin_count = 0_usize; for &it in v.iter().take(t).skip(f) { let p = pivot - origin; let c = it - origin; let cx = cross(p, c); if it == origin { origin_count += 1; } else if zero < cx { plus.push(it); } else if zero > cx { minus.push(it); } else if dot(pivot - origin, it - origin) < zero { inv.push(it); } else { r.push(it); } } for _ in 0..origin_count { r.insert(0, origin); } let mut po = f; if flag { for &i in &r { v[po] = i; po += 1; } for &i in &plus { v[po] = i; po += 1; } for &i in &inv { v[po] = i; po += 1; } for &i in &minus { v[po] = i; po += 1; } let ps = f + r.len(); let pe = f + r.len() + plus.len(); let ms = f + r.len() + plus.len() + inv.len(); let me = f + r.len() + plus.len() + inv.len() + minus.len(); if ps != pe { arg_sort_internal(v, origin, v[ps], ps, pe, false); } if ms != me { arg_sort_internal(v, origin, v[ms], ms, me, false); } } else { for &i in &minus { v[po] = i; po += 1; } for &i in &r { v[po] = i; po += 1; } for &i in &plus { v[po] = i; po += 1; } for &i in &inv { v[po] = i; po += 1; } let ms = f; let me = f + minus.len(); let ps = f + minus.len() + r.len(); let pe = f + minus.len() + r.len() + plus.len(); if ps != pe { arg_sort_internal(v, origin, v[ps], ps, pe, false); } if ms != me { arg_sort_internal(v, origin, v[ms], ms, me, false); } } } pub fn graham_scan(list: &mut [Point]) -> Vec> where T: Add + Sub + SubAssign + Mul + Ord + Copy + Default + From + std::fmt::Debug, { if list.len() <= 2 { return Vec::new(); } list.sort_by_key(|p| (p.y, p.x)); let pivot = Point::new(list[0].x + 1_i8.into(), list[0].y); arg_sort(list, list[0], pivot); let mut list_dedup = vec![list[0], list[1]]; let origin = list_dedup[0]; for &p in list.iter().skip(2) { let top = *list_dedup.last().unwrap(); if cross(top - origin, p - origin) != T::default() { list_dedup.push(p); } else if norm(top - origin) < norm(p - origin) { list_dedup.pop(); list_dedup.push(p); } } let list = list_dedup; let mut stack = VecDeque::new(); stack.push_front(list[0]); stack.push_front(list[1]); stack.push_front(list[2]); for &p in list.iter().skip(3) { while ccw(stack[1], stack[0], p) != 1 { stack.pop_front(); } stack.push_front(p); } stack.iter().rev().cloned().collect::>() } } pub mod input { use std::cell::RefCell; use std::io; pub const SPLIT_DELIMITER: char = ' '; pub use std::io::prelude::*; #[macro_export] thread_local! { pub static INPUT_BUFFER:RefCell>=RefCell::new(std::collections::VecDeque::new()); } #[macro_export] macro_rules! input_internal { ($x:ident : $t:ty) => { INPUT_BUFFER.with(|p| { if p.borrow().len() == 0 { let temp_str = input_line_str(); let mut split_result_iter = temp_str .split(SPLIT_DELIMITER) .map(|q| q.to_string()) .collect::>(); p.borrow_mut().append(&mut split_result_iter) } }); let mut buf_split_result = String::new(); INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap()); let $x: $t = buf_split_result.parse().unwrap(); }; (mut $x:ident : $t:ty) => { INPUT_BUFFER.with(|p| { if p.borrow().len() == 0 { let temp_str = input_line_str(); let mut split_result_iter = temp_str .split(SPLIT_DELIMITER) .map(|q| q.to_string()) .collect::>(); p.borrow_mut().append(&mut split_result_iter) } }); let mut buf_split_result = String::new(); INPUT_BUFFER.with(|p| buf_split_result = p.borrow_mut().pop_front().unwrap()); let mut $x: $t = buf_split_result.parse().unwrap(); }; } #[macro_export] macro_rules! inputv { ($i:ident : $t:ty) => { input_internal!{$i : $t} }; (mut $i:ident : $t:ty) => { input_internal!{mut $i : $t} }; ($i:ident : $t:ty $(,)*) => { input_internal!{$i : $t} }; (mut $i:ident : $t:ty $(,)*) => { input_internal!{mut $i : $t} }; (mut $i:ident : $t:ty,$($q:tt)*) => { input_internal!{mut $i : $t} inputv!{$($q)*} }; ($i:ident : $t:ty,$($q:tt)*) => { input_internal!{$i : $t} inputv!{$($q)*} }; } pub fn input_all() { INPUT_BUFFER.with(|p| { if p.borrow().len() == 0 { let mut temp_str = String::new(); std::io::stdin().read_to_string(&mut temp_str).unwrap(); let mut split_result_iter = temp_str .split_whitespace() .map(|q| q.to_string()) .collect::>(); p.borrow_mut().append(&mut split_result_iter) } }); } pub fn input_line_str() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() } #[allow(clippy::match_wild_err_arm)] pub fn input_vector() -> Vec where T: std::str::FromStr, { let mut v: Vec = Vec::new(); let s = input_line_str(); let split_result = s.split(SPLIT_DELIMITER); for z in split_result { let buf = match z.parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } #[allow(clippy::match_wild_err_arm)] pub fn input_vector_row(n: usize) -> Vec where T: std::str::FromStr, { let mut v = Vec::with_capacity(n); for _ in 0..n { let buf = match input_line_str().parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } pub trait ToCharVec { fn to_charvec(&self) -> Vec; } impl ToCharVec for String { fn to_charvec(&self) -> Vec { self.to_string().chars().collect::>() } } }