Go: package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	for q := 0; q < n; q++ {
		var s1, s2 string
		fmt.Scan(&s1, &s2)
		s1, s2 = " " + s1, " " + s2

		dp := make([][]int, len(s1))
		for i := range dp {
			dp[i] = make([]int, len(s2))
		}

		max := 0

		for i := 1; i < len(s1); i++ {
			for j := 1; j < len(s2); j++ {
				if s1[i] == s2[j] {
					dp[i][j] = dp[i-1][j-1] + 1
				} else {
					dp[i][j] = Max(dp[i-1][j], dp[i][j-1])
				}
				max = Max(max, dp[i][j])
			}
		}

		fmt.Println(max)
	}
}

func Max(n ...int) int {
	max := n[0]
	for _, v := range n[1:] {
		if v > max {
			max = v
		}
	}
	return max
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};

void slove(string X, string Y){
	int dp[1000][1000];//dp[X?????????][Y?????????] = LCS
	int sizex = X.size();
	int sizey = Y.size();

	//???????????????????????????????????????????????????0????????????????????\?????????
	X = ' ' + X;
	Y = ' ' + Y;

	reps(i, 1, sizex + 1) dp[i][0] = 0;//?????????????????????0??????dp???0
	reps(i, 1, sizey + 1) dp[0][i] = 0;//?????????????????????0??????dp???0

	int ans = 0;//????°??????????
	reps(i, 1, sizex + 1){
		reps(j, 1, sizey + 1){
			if(X[i] == Y[j]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else if(X[i] != Y[j]) dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);

			ans = max(ans, dp[i][j]);
		}
	}
	printf("%d\n", ans);
	return;
}

int main(void){
	int n; cin >> n;
	string s1, s2;
	rep(i, n){
		cin >> s1 >> s2;
		slove(s1, s2);
	}
	return 0;
}

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;
}