Go: package main

import "fmt"

func main() {
	var nPairs int
	fmt.Scanln(&nPairs)

	var a, b string
	for i := 0; i < nPairs; i++ {
		fmt.Scanln(&a)
		fmt.Scanln(&b)
		fmt.Println(lcsSize(a, b))
	}
}

func lcsSize(sa, sb string) int {
	dp := make([][]int, len(sa)+1)
	for i := 0; i <= len(sa); i++ {
		dp[i] = make([]int, len(sb)+1)
	}

	for a := 1; a <= len(sa); a++ {
		for b := 1; b <= len(sb); b++ {
			if sa[a-1] == sb[b-1] {
				dp[a][b] = dp[a-1][b-1] + 1
			} else {
				dp[a][b] = max(dp[a][b-1], dp[a-1][b])
			}
		}
	}

	return dp[len(sa)][len(sb)]
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

C++: /*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

chrono::high_resolution_clock::time_point step_time[10];
int step_time_i = 0;
void measure_time() {
    step_time[step_time_i++] = chrono::high_resolution_clock::now();
}
double calc_microsecond(const chrono::high_resolution_clock::time_point &a, const chrono::high_resolution_clock::time_point &b) {
    return chrono::duration_cast<chrono::microseconds>(b - a).count() / 1000.0;
}
void print_time() {
    if (step_time_i < 2) return;
    fprintf(stderr, "Time: ");
    if (step_time_i > 2)
        fprintf(stderr, "%.3f ", calc_microsecond(step_time[0], step_time[step_time_i-1]));
    rep(i, step_time_i - 1)
        fprintf(stderr, "%.3f ", calc_microsecond(step_time[i], step_time[i+1]));
    fprintf(stderr, "\n");
}

char buf[1000*1000];
int bufi = 0;
template<typename T>
void readi(T &n) {
    bool negative = false;
    int c;
    n = 0;
    c = buf[bufi++];
    if (c == '-') negative = true, c = buf[bufi++];
    for (; '0' <= c && c <= '9'; c = buf[bufi++])
        n = 10 * n + c - '0';
    if (negative) n = -n;
}

// End of template.

int main(){
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int q;
    cin >> q;
    rep(qi, q) {
        string x, y;
        cin >> x >> y;
        int dp[1010] = {};
        rep(yi, y.size()) {
            for (int xi = x.size() - 1; xi >= 0; --xi) {
                dp[xi + 1] = max(dp[xi] + (x[xi] == y[yi]), dp[xi + 1]);
            }
            rep(xi, x.size()) dp[xi + 1] = max(dp[xi + 1], dp[xi]);
        }
        print(dp[x.size()]);
    }

    return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
string x, y;
int dp[1010][1010];
int f(int i,int j) {
	if (i < 0 || j < 0)return 0;
	if (dp[i][j] >= 0)return dp[i][j];
	if (x[i] == y[j])return dp[i][j] = f(i - 1, j - 1) + 1;
	else return dp[i][j] = max(f(i - 1, j), f(i, j - 1));
}
signed main() {
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> x >> y;
		for (int i = 0; i <= x.size(); i++)for (int j = 0; j <= y.size(); j++)dp[i][j] = -1;
		cout << f(x.size() - 1, y.size() - 1) << endl;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int q;
    cin>>q;
    rep(i, q) {
        string s, t;
        cin>>s>>t;
        vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));

        rep(i, s.size()) {
            rep(j, t.size()) {
                chmax(dp[i + 1][j + 1], dp[i][j + 1]);
                chmax(dp[i + 1][j + 1], dp[i + 1][j]);
                if (s[i] == t[j]) {
                    chmax(dp[i + 1][j + 1], dp[i][j] + 1);
                }
            }
        }
        cout<<dp[s.size()][t.size()]<<endl;
    }
}

C++: #include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
int q;
cin >> q;
vi result(0);
while(q > 0){
  string s, t;
  cin >> s >> t;
  int ssize = s.size(), tsize = t.size();
  vvi dp(1100, vi(1100, 0));

  for(int i = 0; i < ssize; i++){
    for(int j = 0; j < tsize; j++){
      if(s.at(i) == t.at(j)) dp.at(i+1).at(j+1) = dp.at(i).at(j) + 1;
      else{
        chmax(dp.at(i+1).at(j+1), dp.at(i).at(j+1));
        chmax(dp.at(i+1).at(j+1), dp.at(i+1).at(j));
      }
    }
  }

  result.push_back(dp.at(ssize).at(tsize));

  q--;
}

for(auto x: result) cout << x << endl;
  
}

C++: 
#include<iostream>

int main(){
  int n;
  std::string x,y;
  std::cin>>n;
  int a[1000][1000];
  int b[n];

  for(int i=0;i<n;i++){
    std::cin>>x;
    std::cin>>y;
    for(int j=0;j<1000;j++){
      for(int k=0;k<1000;k++){
	a[j][k]=0;
      }
    }
    for(int j=0;j<=x.size();j++){
      for(int k=0;k<=y.size();k++){
	if(x[j]==y[k]){
	  a[j+1][k+0]=a[j][k]+1;
	}else{
	  if(a[j][k+1]>a[j+1][k]){
	    a[j+1][k+1]=a[j][k+1];
	  }else{
	    a[j+1][k+1]=a[j+1][k];
	  }
	}
      }
    }
    b[i]=a[x.size()][y.size()];
  }

  for(int i=0;i<n;i++){
  std::cout<<b[i]<<"\n";
  }

  return 0;
}