#![allow(confusable_idents, uncommon_codepoints, mixed_script_confusables)]
#![feature(
array_windows,
test,
slice_as_chunks,
array_chunks,
slice_split_once,
byte_slice_trim_ascii
)]
extern crate test;
mod util;
pub use util::prelude::*;
/// generated by passing 1, 0{20} and 0, 1, 0{19}, etc to the original
const INTERPOLATION_P1: [i32; 21] = [
1, -21, 210, -1330, 5985, -20349, 54264, -116280, 203490, -293930, 352716, -352716, 293930,
-203490, 116280, -54264, 20349, -5985, 1330, -210, 21,
];
/// just the reversed version of [`INTERPOLATION_P1`]
const INTERPOLATION_P2: [i32; 21] = [
21, -210, 1330, -5985, 20349, -54264, 116280, -203490, 293930, -352716, 352716, -293930,
203490, -116280, 54264, -20349, 5985, -1330, 210, -21, 1,
];
pub fn solve(a: impl Iterator<Item = i32>, interp: [i32; 21]) -> i32 {
a.zip(interp.into_iter())
.map(|(a, b)| a as i64 * b as i64)
.sum::<i64>() as i32
}
pub fn run(i: &str) -> impl Display {
i.行()
.map(|x| solve(&mut x.κ(), INTERPOLATION_P2))
.sum::<i32>()
}
fn main() {
let i = include_str!("inp.txt").trim();
println!("{}", run(i));
}
#[bench]
fn bench(b: &mut test::Bencher) {
let i = boxd(include_str!("inp.txt").trim());
b.iter(|| run(i));
}