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 Go (1.6) (judge verdict: Wrong Answer)

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	s := nextWord()
	t := nextWord()

	var dp [3005][3005]string
	var mstr string
	var mlen = 0
	tlen := len(t)
	slen := len(s)
	// init
	if t[0] == s[0] {
		dp[0][0] = s[0:1]
	}
	for i := 1; i < tlen; i++ {
		if t[i] == s[0] {
			dp[i][0] = s[0:1]
		} else {
			dp[i][0] = dp[i-1][0]
		}
	}
	for j := 1; j < slen; j++ {
		if t[0] == s[j] {
			dp[0][j] = t[0:1]
		} else {
			dp[0][j] = dp[0][j-1]
		}
	}

	for i := 1; i < tlen; i++ {
		for j := 1; j < slen; j++ {
			if t[i] == s[j] {
				dp[i][j] = dp[i-1][j-1] + t[i:i+1]
				if len(dp[i][j]) > mlen {
					mlen = len(dp[i][j])
					mstr = dp[i][j]
				}
			} else {
				if len(dp[i-1][j]) > len(dp[i][j-1]) {
					dp[i][j] = dp[i-1][j]
				} else {
					dp[i][j] = dp[i][j-1]
				}
			}
		}
	}

	fmt.Println(mstr)
}