#[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>()); ($t:ty) => (rl().parse::<$t>().unwrap()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().to_owned() } fn main() { let (_n, x) = read!(usize, usize); let mut a = read!([usize]); a.sort(); let mut cnt = 0; let mut r_min = 0; for l in 0..a.len() { for r in r_min..a.len() { match (a[l] + a[r]).cmp(&x) { std::cmp::Ordering::Equal if l == r => { cnt += 1; } std::cmp::Ordering::Equal => { cnt += 2; } std::cmp::Ordering::Greater => { r_min = r; break; } _ => {} } } } println!("{}", cnt); }