Go: package main

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

var (
	nstr   func() string
	stdout *bufio.Writer
)

func init() {
	nstr = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func main() {
	defer stdout.Flush()

	n := nint()
	xList := make([]string, n)
	yList := make([]string, n)

	for i:=0;i<n ;i++  {
		xList[i] = nstr()
		yList[i] = nstr()
	}

	for i := 0; i<n	; i++  {
		fmt.Println(lcs(xList[i], yList[i]))
	}

}

func lcs(x string, y string) int{
	var m = len(x)
	var n = len(y)

	c := make([][]int, m+1)
	for i:= range c{
		c[i] = make([]int, n+1)
	}
	for i:=	1;i<=m ;i++  {
		for j:=1;j<=n ;j++  {
			if x[i-1] == y[j-1]{
				c[i][j] = c[i-1][j-1] + 1
			}else{
				c[i][j] = int(math.Max(float64(c[i-1][j]), float64(c[i][j-1])))
			}


		}
	}
	return c[m][n]

}


func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func nint64() int64 {
	i, err := strconv.ParseInt(nstr(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func nint() int {
	return int(nint64())
}

func getIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nint()
	}
	return b
}

func getStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = nstr()
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func bin(i int, prefix bool) string {
	i64 := int64(i)

	if prefix {
		return "0b" + strconv.FormatInt(i64, 2)
	} else {
		return strconv.FormatInt(i64, 2)
	}
}

func strReverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}

C++: #include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int LCS(const char* a,const char* b)
{
    int m=strlen(a); int n=strlen(b); //i???????¬????a????????????j???????¬????b?????????
    int c[m+1][n+1]; //c??°???????????¨?????°???????¬????a??????i??????????¬????b??????j????????´???LCS
    for(int i=0;i<=m;i++) c[i][0]=0;
    for(int i=0;i<=n;i++) c[0][i]=0;
    for(int i=0;i<m;i++)
        for(int j=0;j<n;j++)
        {
            if(a[i]==b[j]) c[i+1][j+1]=c[i][j]+1;
            else
            {
                c[i+1][j+1]=max(c[i][j+1],c[i+1][j]);
            }
        }
    return c[m][n];

}
int main()
{
    char *a=new char[1001];
    char *b=new char[1001];
    int q;
    while(cin>>q)
    {
        for(int i=0;i<q;i++)
        {
            cin>>a>>b;
            cout<<LCS(a,b)<<endl;
        }
    }
}

C++: #include<iostream>
#include<algorithm>
#include<string>
using namespace std;

int Ics(string X, string Y) {
	int c[101][101];
	int m = X.length();
	int n = Y.length();
	int maxl = 0;

	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 1; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j])
				c[i][j] = c[i - 1][j - 1] + 1;
			else if (c[i - 1][j] >= c[i][j - 1])
				c[i][j] = c[i - 1][j];
			else 
				c[i][j] = c[i][j - 1];

			maxl = max(maxl,c[i][j]);
		}
		
	}
	return maxl;
}

int main() {
	int n;
	string x, y;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;

		cout << Ics(x, y) << endl;
	}

	
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 301000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
//union_find
int par[100];
int depth[100];
ll N;
ll x[20],c[20],v[20];
string s,t;

int lcs(string x, string y){
    int dp[1010][1010];
    int m = x.size();
    int n = y.size();
    int mx = 0;
    x = ' ' + x;
    y = ' ' + y;
    for(int i = 0; i <= m; i++) dp[i][0] = 0;
    for(int i = 1; i <= n; i++) dp[0][i] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(x[i] == y[i]){
                dp[i][j] = dp[i-1][j-1] + 1;
            } else {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
            mx = max(mx, dp[i][j]);
        }
    }
    return mx;
}
int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> s >> t;
        cout << lcs(s,t) << endl;
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

int main() {

    int n;
    string str1, str2;

    cin >> n;

    for(int cnt = 0; cnt < n; ++cnt) {

        cin >> str1 >> str2;

        int dp[str1.size() + 1][str2.size() + 1];

        for(int i = 0; i <= str1.size(); ++i) {
            dp[i][0] = 0;
        }

        for(int i = 0; i <= str2.size(); ++i) {
            dp[0][i] = 0;
        }

        for(int i = 1; i <= str1.size(); ++i) {
            for(int j = 1; j <= str2.size(); ++j) {
                if(str1[i - 1] == str2[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                } else {
                    dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
                }
            }
        }

        cout << dp[str1.size()][str2.size()] << endl;

    }

}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C&lang=jp




#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

const int MAX_q=160;
const int MAX_L=1010;
bool done[MAX_L][MAX_L];
int memo[MAX_L][MAX_L];
int q;
string x,y;

int LCS(int i,int j)
{
    int res;

    if(i<0) return 0;
    if(j<0) return 0;

    if (done[i][j]) return memo[i][j];

    else if(x[i]==y[j])
    {
        res=LCS(i-1,j-1)+1;
    }
    else{
        int res1=LCS(i-1,j);
        int res2=LCS(i,j-1);
        res=max(res1,res2);
    }
    done[i][j]=true;
    memo[i][j]=res;
    return res;
}

int main()
{
    int res;
    cin>>q;
    rep(i,q)
    {
        cin>>x>>y;
        res=LCS(x.length()-1,y.length()-1);
        cout<<res<<"\n";
        rep(j,MAX_L)
        {
            rep(k,MAX_L)
            {
                done[j][k]=false;
            }
        }
    }


    return 0;
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int L[1001][1001];
int getc(int i,int j){
    if(i>=0&&j>=0)
        return L[i][j];
    else
        return 0;
}
int main(){
    int N;
    string X,Y;
    cin >> N;
    for(int k=0;k<N;++k){
        cin>>X>>Y;
        for(int i=0;i<X.length();++i){
            for(int j=0;j<Y.length();++j){
                if(X[i]==Y[j]){
                    L[i][j]=getc(i-1,j-1)+1;
                }
                else{
                    L[i][j]=max(getc(i-1,j),getc(i,j-1));
                }
            }
        }
        cout <<L[X.length()-1][Y.length()-1]<< endl;
    }
    return 0;
}