use proconio::input; fn main() { input! { n: usize, _f: usize, abc: [[u32; n]; 3], } let abc = (0..n) .map(|i| { let mut x = vec![abc[0][i], abc[1][i], abc[2][i]]; x.sort(); x.dedup(); x }) .collect::<Vec<_>>(); let mut dp = vec![0u64; n + 1]; dp[0] = 1; let ans = abc .iter() .map(|x| { let mut swp = if x[0] == 0 { dp.clone() } else { vec![0; n + 1] }; for &x in x { if x == 0 { continue; } for i in 0..=n { if i == 0 { swp[i] |= dp[i].wrapping_shl(x); } else { swp[i] |= dp[i].wrapping_shl(x) | (dp[i - 1] >> (64 - x)); } } } dp = swp; dp.iter().map(|dp| dp.count_ones()).sum::<u32>() }) .collect::<Vec<_>>(); println!( "{}", ans.iter() .map(std::string::ToString::to_string) .collect::<Vec<_>>() .join("\n") ); }