Language: C++

//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, T) = read!(usize, usize);
    let mut A = vec![];
    let mut B = vec![];

    for (a, b) in read![usize, i64; N] {
        A.push(a);
        B.push(b);
    }

    let mut dp = vec![vec![0; T]; N + 1];
    dp[0][0] = 0;

    let mut prev = vec![vec![None; T]; N + 1];

    for i in 0..N {
        for t in 0..T {
            if dp[i + 1][t] < dp[i][t] {
                dp[i + 1][t] = dp[i][t];
                prev[i + 1][t] = prev[i][t];
            }

            if t + A[i] < T && dp[i + 1][t + A[i]] < dp[i][t] + B[i] {
                dp[i + 1][t + A[i]] = dp[i][t] + B[i];
                prev[i + 1][t + A[i]] = Some((i, t));
            }
        }
    }

    for t in 0..T - 1 {
        if dp[N][t + 1] < dp[N][t] {
            dp[N][t + 1] = dp[N][t];
            prev[N][t + 1] = prev[N][t];
        }
    }

    let mut dishes = BTreeSet::new();
    {
        let mut i = N;
        let mut t = T - 1;
        while let Some((j, u)) = prev[i][t] {
            dishes.insert(j);
            i = j;
            t = u;
        }
    }

    let mut max_b = 0;
    for i in 0..N {
        if !dishes.contains(&i) && max_b < B[i] {
            max_b = B[i];
        }
    }

    println!("{}", dp[N][T - 1] + max_b)
}


Compiler output:
a.cc:7:2: error: invalid preprocessing directive #!
    7 | #![allow(unused_imports)]
      |  ^
a.cc:8:2: error: invalid preprocessing directive #!
    8 | #![allow(non_snake_case)]
      |  ^
a.cc:20:2: error: invalid preprocessing directive #[
   20 | #[allow(unused_macros)]
      |  ^
a.cc:23:10: error: invalid preprocessing directive #[
   23 |         #[cfg(debug_assertions)]
      |          ^
a.cc:35:2: error: invalid preprocessing directive #[
   35 | #[allow(unused_macros)]
      |  ^
a.cc:38:11: error: too many decimal points in number
   38 |         ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
      |           ^~~~~
a.cc:40:11: error: too many decimal points in number
   40 |         ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
      |           ^~~~~
a.cc:51:2: error: invalid preprocessing directive #[
   51 | #[allow(dead_code)]
      |  ^
a.cc:56:6: error: invalid preprocessing directive #[
   56 |     #[allow(deprecated)]
      |      ^
a.cc:79:14: error: too many decimal points in number
   79 |     for i in 0..N {
      |              ^~~~
a.cc:80:18: error: too many decimal points in number
   80 |         for t in 0..T {
      |                  ^~~~
a.cc:93:14: error: too many decimal points in number
   93 |     for t in 0..T - 1 {
      |              ^~~~
a.cc:112:14: error: too many decimal points in number
  112 |     for i in 0..N {
      |              ^~~~
a.cc:10:1: error: 'use' does not name a type
   10 | use std::cell::RefCell;
      | ^~~
a.cc:11:1: error: 'use' does not name a type
   11 | use std::cmp::{max, min, Ordering};
      | ^~~
a.cc:12:1: error: 'use' does not name a type
   12 | use std::collections::*;
      | ^~~
a.cc:13:1: error: 'use' does not name a type
   13 | use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
      | ^~~
a.cc:14:1: error: 'use' does not name a type
   14 | use std::io::{stderr, stdin, BufRead, Write};
      | ^~~
a.cc:15:1: error: 'use' does not name a type
   15 | use std::mem::{replace, swap};
      | ^~~
a.cc:16:1: error: 'use' does not name a type
   16 | use std::ops::*;
      | ^~~
a.cc:17:1: error: 'use' does not name a type
   17 | use std::rc::Rc;
      | ^~~
a.cc:21:1: error: 'macro_rules' does not name a type
   21 | macro_rules! debug {
      | ^~~~~~~~~~~
a.cc:36:1: error: 'macro_rules' does not name a type
   36 | macro_rules! read {
      | ^~~~~~~~~~~
a.cc:52:1: error: 'fn' does not name a type
   52 | fn rl() -> String {
      | ^~
a.cc:64:1: error: 'fn' does not name a type
   64 | fn main() {
      | ^~