Skip to main content

library_checker/sample/
many_aplusb.rs

1use competitive::prelude::*;
2#[doc(no_inline)]
3pub use competitive::tools::{FastInput, FastOutput};
4
5#[verify::library_checker("many_aplusb")]
6pub fn many_aplusb(reader: impl Read, mut writer: impl Write) {
7    let s = read_all_unchecked(reader);
8    let mut scanner = Scanner::new(&s);
9    scan!(scanner, t);
10    for (a, b) in scanner.iter::<(usize, usize)>().take(t) {
11        writeln!(writer, "{}", a + b).ok();
12    }
13}
14
15#[verify::library_checker("many_aplusb")]
16pub fn many_aplusb_fast(reader: impl Read, writer: impl Write) {
17    let s = read_all_unchecked(reader);
18    let mut writer = FastOutput::with_capacity(1 << 12, writer);
19    let mut scanner = unsafe { FastInput::from_slice(s.as_bytes()) };
20    let t = unsafe { scanner.u64() };
21    for _ in 0..t {
22        let a = unsafe { scanner.u64() };
23        let b = unsafe { scanner.u64() };
24        writer.u64(a + b);
25        writer.byte(b'\n');
26    }
27}