Problem:
Score : 100 points

Problem Statement

You are given strings s and t.
Find one longest string that is a subsequence of both s and t.

Notes

A subsequence of a string x is the string obtained by removing zero or more characters from x and concatenating the remaining characters without changing the order.

Constraints

s and t are strings consisting of lowercase English letters.

1 \leq |s|, |t| \leq 3000

Input

Input is given from Standard Input in the following format:

s
t

Output

Print one longest string that is a subsequence of both s and t.
If there are multiple such strings, any of them will be accepted.

Sample Input 1

axyb
abyxb

Sample Output 1

axb

The answer is axb or ayb; either will be accepted.

Sample Input 2

aa
xayaz

Sample Output 2

aa

Sample Input 3

a
z

Sample Output 3

The answer is (an empty string).

Sample Input 4

abracadabra
avadakedavra

Sample Output 4

aaadara

Solution in Rust (1.15.1) (judge verdict: Time Limit Exceeded)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use libprocon::*;

fn main() {
    let s: String = read!(String);
    let t: String = read!(String);

    let s: Vec<char> = s.chars().collect();
    let t: Vec<char> = t.chars().collect();

    // dp[i][j] := s1...siとt1...tjに対する共通部分列
    let mut dp = vec![vec![vec![]; t.len() + 1]; s.len() + 1];

    for i in 0..s.len() {
        for j in 0..t.len() {
            if s[i] == t[j] {
                let mut cloned = dp[i][j].clone();
                cloned.push(s[i]);
                dp[i + 1][j + 1] = cloned;
            } else {
                dp[i + 1][j + 1] = if dp[i][j + 1].len() > dp[i + 1][j].len() {
                    dp[i][j + 1].clone()
                } else {
                    dp[i + 1][j].clone()
                }
            }
        }
    }
    println!("{}", dp[s.len()][t.len()].iter().collect::<String>())
}
*/

fn main() {
    let exe = "/tmp/bin344905A5";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";