Language: C++

#include <cstdio>
#include <algorithm>
#include <vector>#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

class TLcsSolver
{
    typedef std::vector<std::vector<int> > TTable;
    TTable FTable;
    std::string FArray1;
    std::string FArray2;

    int Count(int i, int j)
    {
        if(i == 0 || j == 0) return 0;
        if(FArray1[i-1] == FArray2[j-1]){
            return FTable[i-1][j-1] + 1;
        }
        return std::max(FTable[i-1][j], FTable[i][j-1]);
    }
    void Solve()
    {
        for(std::size_t i = 1; i < FTable.size(); ++i){
            for(std::size_t j = 1; j < FTable[i].size(); ++j){
                FTable[i][j] = Count(i, j);
            }
        }
    }
public:
    TLcsSolver(const std::string& a, const std::string& b)
     : FArray1(a), FArray2(b)
     , FTable(a.size()+1, std::vector<int>(b.size()+1, 0))
    {
        Solve();
    }
    int Answer()const
    {
        return FTable[FArray1.size()][FArray2.size()];
    }
};

int main()
{
    int n;
    std::scanf("%d", &n);
    char a[1000];
    char b[1000];
    for(int i = 0; i < n; ++i){
        std::fgets(a, 1000, std::stdin);
        std::fgets(b, 1000, std::stdin));
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}
#include <string>

class TLcsSolver
{
    typedef std::vector<std::vector<int> > TTable;
    TTable FTable;
    std::string FArray1;
    std::string FArray2;

    int Count(int i, int j)
    {
        if(i == 0 || j == 0) return 0;
        if(FArray1[i-1] == FArray2[j-1]){
            return FTable[i-1][j-1] + 1;
        }
        return std::max(FTable[i-1][j], FTable[i][j-1]);
    }
    void Solve()
    {
        for(std::size_t i = 1; i < FTable.size(); ++i){
            for(std::size_t j = 1; j < FTable[i].size(); ++j){
                FTable[i][j] = Count(i, j);
            }
        }
    }
public:
    TLcsSolver(const std::string& a, const std::string& b)
     : FArray1(a), FArray2(b)
     , FTable(a.size()+1, std::vector<int>(b.size()+1, 0))
    {
        Solve();
    }
    int Answer()const
    {
        return FTable[FArray1.size()][FArray2.size()];
    }
};

int main()
{
    int n;
    std::scanf("%d", &n);
    char a[1000];
    char b[1000];
    for(int i = 0; i < n; ++i){
        std::gets(a);
        std::gets(b);
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Compiler output:
a.cc:3:18: warning: extra tokens at end of #include directive
    3 | #include <vector>#include <cstdio>
      |                  ^
In file included from /usr/include/c++/14/cstdio:42,
                 from a.cc:1:
a.cc: In function 'int main()':
a.cc:51:34: error: 'stdin' is not a member of 'std'; did you mean 'string'?
   51 |         std::fgets(a, 1000, std::stdin);
      |                                  ^~~~~
a.cc:52:34: error: 'stdin' is not a member of 'std'; did you mean 'string'?
   52 |         std::fgets(b, 1000, std::stdin));
      |                                  ^~~~~
a.cc: At global scope:
a.cc:59:7: error: redefinition of 'class TLcsSolver'
   59 | class TLcsSolver
      |       ^~~~~~~~~~
a.cc:8:7: note: previous definition of 'class TLcsSolver'
    8 | class TLcsSolver
      |       ^~~~~~~~~~
a.cc:95:5: error: redefinition of 'int main()'
   95 | int main()
      |     ^~~~
a.cc:44:5: note: 'int main()' previously defined here
   44 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:102:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
  102 |         std::gets(a);
      |              ^~~~
      |              getc
a.cc:103:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
  103 |         std::gets(b);
      |              ^~~~
      |              getc