Language: C++

use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::thread;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut a = vec![0; n];
    let mut b = vec![0; n];
    for i in 0..n {
        a[i] = sc.ne();
        b[i] = sc.ne();
    }
    let mut cur = 0;
    for i in (0..n).rev() {
        let x = a[i] + cur;
        cur += b[i] - if x % b[i] == 0 { b[i] } else { x % b[i] };
    }
    println!("{}", cur);
}
const DEFAULT_STACK: usize = 16 * 1024 * 1024;
fn main() {
    let builder = thread::Builder::new();
    let th = builder.stack_size(DEFAULT_STACK);
    let handle = th.spawn(|| { exec(); }).unwrap();
    let _ = handle.join();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => return None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => panic!("parse error"),
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Compiler output:
a.cc:10:14: error: too many decimal points in number
   10 |     for i in 0..n {
      |              ^~~~
a.cc:15:15: error: too many decimal points in number
   15 |     for i in (0..n).rev() {
      |               ^~~~
a.cc:29:2: error: invalid preprocessing directive #[
   29 | #[allow(dead_code)]
      |  ^
a.cc:36:2: error: invalid preprocessing directive #[
   36 | #[allow(dead_code)]
      |  ^
a.cc:1:1: error: 'use' does not name a type
    1 | use std::io::{self, Stdin};
      | ^~~
a.cc:2:1: error: 'use' does not name a type
    2 | use std::str::{self, FromStr};
      | ^~~
a.cc:3:1: error: 'use' does not name a type
    3 | use std::error::Error;
      | ^~~
a.cc:4:1: error: 'use' does not name a type
    4 | use std::thread;
      | ^~~
a.cc:5:1: error: 'fn' does not name a type
    5 | fn exec() {
      | ^~
a.cc:21:20: error: found ':' in nested-name-specifier, expected '::'
   21 | const DEFAULT_STACK: usize = 16 * 1024 * 1024;
      |                    ^
      |                    ::
a.cc:21:7: error: 'DEFAULT_STACK' does not name a type
   21 | const DEFAULT_STACK: usize = 16 * 1024 * 1024;
      |       ^~~~~~~~~~~~~
a.cc:22:1: error: 'fn' does not name a type
   22 | fn main() {
      | ^~
a.cc:31:5: error: 'stdin' does not name a type
   31 |     stdin: Stdin,
      |     ^~~~~
a.cc:1:1: note: 'stdin' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | use std::io::{self, Stdin};
a.cc:37:6: error: expected initializer before 'Scanner'
   37 | impl Scanner {
      |      ^~~~~~~