criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<stdio.h>
#include<string.h>
????????
int LCS(char *X, char *Y){
????int i,j,m,n,c[1001][1001];
????m = strlen(X);
????n = strlen(Y);
????????????
????for(i=0; i<m; i++){
????????c[i][0] = 0;
????}
????for(j=0; j<n; j++){
????????c[0][j] = 0;
????}
????????
????for(i=1;i<m+1;i++){
????????for(j=1;j<n+1;j++){
????????????if (X[i-1]==Y[j-1]) 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];
????????}
????}
????return c[i-1][j-1];
}
????????
int main(){
??}
????return 0;
}

Compiler output:
a.cc:3:1: error: expected unqualified-id before '?' token
    3 | ????????
      | ^
a.cc:25:1: error: expected unqualified-id before '?' token
   25 | ????????
      | ^
a.cc:28:1: error: expected unqualified-id before '?' token
   28 | ????return 0;
      | ^
a.cc:29:1: error: expected declaration before '}' token
   29 | }
      | ^
Language: C++

#include <stdio.h>
#include <iostream>
#include <algorithm>
??
using namespace std;
??
short checkTable[1001][1001];
??
int tmp_max=0;
??
??
void calc(int index,char pattern[],char to_search[],int to_search_length){
??
????????for(int i=to_search_length-1;i>=0;i--){
????????????????if(to_search[i]==pattern[index]){
????????????????????????checkTable[index][i]=1;
????????????????????????if(pattern[index+1]!='\0' && i < to_search_length-1){
????????????????????????????????checkTable[index][i] = checkTable[index+1][i+1] + checkTable[index][i];
????????????????????????}
????????????????}else{
????????????????????????if(i != to_search_length-1){
????????????????????????????????if(pattern[index+1] != '\0'){
????????????????????????????????????????checkTable[index][i]=(checkTable[index+1][i]>checkTable[index][i+1])
?????????????????????????????????????????????????????????checkTable[index+1][i]:checkTable[index][i+1];
??
????????????????????????????????}else{
????????????????????????????????????????checkTable[index][i]=(checkTable[index][i+1]>0)?checkTable[index][i+1]:0;
????????????????????????????????}
????????????????????????}else{
????????????????????????????????if(pattern[index+1] != '\0'){
????????????????????????????????????????checkTable[index][i]=(checkTable[index+1][i]>0)?checkTable[index+1][i]:0;
????????????????????????????????}else{
????????????????????????????????????????checkTable[index][i] = 0;
????????????????????????????????}
????????????????????????}
????????????????}
????????????????tmp_max = (tmp_max >= checkTable[index][i])?tmp_max:checkTable[index][i];
????????}
}
??
int main(){
??
????????int q,left_length,right_length;
????????char left[1001],right[1001];
??
????????scanf("%d",&q);
??
????????for(int i=0;i<q;i++){
????????????????left_length=0;
????????????????right_length=0;
????????????????scanf("%s %s",left,right);
????????????????for(int k=0;left[k]!='\0';k++)left_length++;
????????????????for(int k=0;right[k]!='\0';k++)right_length++;
??
????????????????if(right_length>=left_length){
??
????????????????????????for(int k=left_length-1;k>=0;k--)calc(k,left,right,right_length);
????????????????}else{
??
????????????????????????for(int k=right_length-1;k>=0;k--)calc(k,right,left,left_length);
????????????????}
????????????????printf("%d\n",tmp_max);
????????????????tmp_max=0;
????????}
??
????????return 0;
}

Compiler output:
a.cc:4:1: error: expected unqualified-id before '?' token
    4 | ??
      | ^
a.cc:6:1: error: expected unqualified-id before '?' token
    6 | ??
      | ^
a.cc:8:1: error: expected unqualified-id before '?' token
    8 | ??
      | ^
a.cc:10:1: error: expected unqualified-id before '?' token
   10 | ??
      | ^
a.cc:40:1: error: expected unqualified-id before '?' token
   40 | ??
      | ^
Language: C++

#include <cassert>
#include <algorithm>
#include <iostream>
#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();
        // Print();
    }
    int Answer()const
    {
        return FTable[FArray1.size()][FArray2.size()];
    }
    void Print()const
    {
        for(std::size_t i = 0; i < FTable.size(); ++i){
            for(std::size_t j = 0; j < FTable[i].size(); ++j){
                std::cout << FTable[i][j] << '\t';
            }
            std::cout << '\n';
        }
    } 
};

int main()
{
    int n;
    std::cin >> 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: In function 'int main()':
a.cc:60:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   60 |         std::gets(a);
      |              ^~~~
      |              getc
a.cc:61:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   61 |         std::gets(b);
      |              ^~~~
      |              getc
Language: C++

#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();
        // Print();
    }
    int Answer()const
    {
        return FTable[FArray1.size()][FArray2.size()];
    }
    void Print()const
    {
        for(std::size_t i = 0; i < FTable.size(); ++i){
            for(std::size_t j = 0; j < FTable[i].size(); ++j){
                std::cout << FTable[i][j] << '\t';
            }
            std::cout << '\n';
        }
    } 
};

int main()
{
    int n;
    std::cin >> 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: In member function 'void TLcsSolver::Print() const':
a.cc:45:22: error: 'cout' is not a member of 'std'
   45 |                 std::cout << FTable[i][j] << '\t';
      |                      ^~~~
a.cc:5:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <string>
  +++ |+#include <iostream>
    5 | 
a.cc:47:18: error: 'cout' is not a member of 'std'
   47 |             std::cout << '\n';
      |                  ^~~~
a.cc:47:18: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'int main()':
a.cc:55:10: error: 'cin' is not a member of 'std'
   55 |     std::cin >> n;
      |          ^~~
a.cc:55:10: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:59:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   59 |         std::gets(a);
      |              ^~~~
      |              getc
a.cc:60:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   60 |         std::gets(b);
      |              ^~~~
      |              getc
Language: C++

#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::cin >> 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: In function 'int main()':
a.cc:45:10: error: 'cin' is not a member of 'std'
   45 |     std::cin >> n;
      |          ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    4 | #include <string>
  +++ |+#include <iostream>
    5 | 
a.cc:49:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   49 |         std::gets(a);
      |              ^~~~
      |              getc
a.cc:50:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   50 |         std::gets(b);
      |              ^~~~
      |              getc
Language: C++

#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::gets(a);
        std::gets(b);
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   49 |         std::gets(a);
      |              ^~~~
      |              getc
a.cc:50:14: error: 'gets' is not a member of 'std'; did you mean 'getc'?
   50 |         std::gets(b);
      |              ^~~~
      |              getc
Language: C++

#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, stdin);
        std::fgets(b, 1000, stdin));
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:35: error: expected ';' before ')' token
   50 |         std::fgets(b, 1000, stdin));
      |                                   ^
      |                                   ;
Language: C++

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

class TLcsSolver
{
    int FTable[1000][1000];
    const char* FArray1;
    const char* FArray2;
    const int Fn1;
    const int Fn2;

    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 < Fn1; ++i){
            for(std::size_t j = 1; j < Fn2; ++j){
                FTable[i][j] = Count(i, j);
            }
        }
    }
public:
    TLcsSolver(const char* a, const char* b)
     : FArray1(a), FArray2(b)
     , Fn1(std::strlen(a)), Fn2(std::strlen(b))
    {
        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, stdin);
        std::fgets(b, 1000, stdin);
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Compiler output:
a.cc: In constructor 'TLcsSolver::TLcsSolver(const char*, const char*)':
a.cc:33:17: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
   33 |      , Fn1(std::strlen(a)), Fn2(std::strlen(b))
      |                 ^~~~~~
      |                 mbrlen
a.cc:33:38: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
   33 |      , Fn1(std::strlen(a)), Fn2(std::strlen(b))
      |                                      ^~~~~~
      |                                      mbrlen
a.cc: In member function 'int TLcsSolver::Answer() const':
a.cc:39:31: error: request for member 'size' in '((const TLcsSolver*)this)->TLcsSolver::FArray1', which is of non-class type 'const char* const'
   39 |         return FTable[FArray1.size()][FArray2.size()];
      |                               ^~~~
a.cc:39:47: error: request for member 'size' in '((const TLcsSolver*)this)->TLcsSolver::FArray2', which is of non-class type 'const char* const'
   39 |         return FTable[FArray1.size()][FArray2.size()];
      |                                               ^~~~
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>

class TLcsSolver
{
    int FTable[1000][1000];
    const char* FArray1;
    const char* FArray2;
    const int Fn1;
    const int Fn2;

    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 < Fn1; ++i){
            for(std::size_t j = 1; j < Fn2; ++j){
                FTable[i][j] = Count(i, j);
            }
        }
    }
public:
    TLcsSolver(const char* a, const char* b)
     : FArray1(a), FArray2(b)
     , Fn1(std::strlen(a)), Fn2(std::strlen(b))
    {
        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, stdin);
        std::fgets(b, 1000, stdin);
        std::printf("%d", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Compiler output:
a.cc: In member function 'int TLcsSolver::Answer() const':
a.cc:38:31: error: request for member 'size' in '((const TLcsSolver*)this)->TLcsSolver::FArray1', which is of non-class type 'const char* const'
   38 |         return FTable[FArray1.size()][FArray2.size()];
      |                               ^~~~
a.cc:38:47: error: request for member 'size' in '((const TLcsSolver*)this)->TLcsSolver::FArray2', which is of non-class type 'const char* const'
   38 |         return FTable[FArray1.size()][FArray2.size()];
      |                                               ^~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>

int constexpr MAX = 1000;
char ls[MAX];
char rs[MAX];
int table[MAX + 1][MAX + 1];


void calc_lcs() {
    scanf("%s", ls);
    scanf("%s", rs);
    int l_len = int(strlen(ls));
    int r_len = int(strlen(rs));
    for (int i = 0; i < l_len; i++) {
        table[i][0] = 0;
    }
    for (int i = 0; i < r_len; i++) {
        table[0][i] = 0;
    }

    for (int l_i = 1; l_i < l_len + 1; l_i++) {
        for (int r_i = 1; r_i < r_len + 1; r_i++) {
            if (ls[l_i - 1] == rs[r_i - 1]) {
                table[l_i][r_i] = table[l_i - 1][r_i - 1] + 1;
            } else {
                table[l_i][r_i] = std::max(table[l_i][r_i - 1], table[l_i - 1][r_i]);
            }
        }
    }
    std::cout << table[l_len][r_len] << std::endl;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        calc_lcs();
    }
}

Compiler output:
a.cc: In function 'void calc_lcs()':
a.cc:16:21: error: 'strlen' was not declared in this scope
   16 |     int l_len = int(strlen(ls));
      |                     ^~~~~~
a.cc:6:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <vector>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <iostream>
#include <cmath>
#include <vector>

constexpr int MAX = 1000;
char ls[MAX];
char rs[MAX];
int table[MAX + 1][MAX + 1];


void calc_lcs() {
    scanf("%s", ls);
    scanf("%s", rs);
    int l_len = int(strlen(ls));
    int r_len = int(strlen(rs));
    for (int i = 0; i < l_len; i++) {
        table[i][0] = 0;
    }
    for (int i = 0; i < r_len; i++) {
        table[0][i] = 0;
    }

    for (int l_i = 1; l_i < l_len + 1; l_i++) {
        for (int r_i = 1; r_i < r_len + 1; r_i++) {
            if (ls[l_i - 1] == rs[r_i - 1]) {
                table[l_i][r_i] = table[l_i - 1][r_i - 1] + 1;
            } else {
                table[l_i][r_i] = std::max(table[l_i][r_i - 1], table[l_i - 1][r_i]);
            }
        }
    }
    std::cout << table[l_len][r_len] << std::endl;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        calc_lcs();
    }
}

Compiler output:
a.cc: In function 'void calc_lcs()':
a.cc:14:21: error: 'strlen' was not declared in this scope
   14 |     int l_len = int(strlen(ls));
      |                     ^~~~~~
a.cc:4:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <vector>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <iostream>
#include <cmath>
#include <vector>

constexpr int MAX = 1000;
char ls[MAX];
char rs[MAX];
int table[MAX + 1][MAX + 1];


void calc_lcs() {
    scanf("%s", ls);
    scanf("%s", rs);
    int l_len = int(std::strlen(ls));
    int r_len = int(std::strlen(rs));
    for (int i = 0; i < l_len; i++) {
        table[i][0] = 0;
    }
    for (int i = 0; i < r_len; i++) {
        table[0][i] = 0;
    }

    for (int l_i = 1; l_i < l_len + 1; l_i++) {
        for (int r_i = 1; r_i < r_len + 1; r_i++) {
            if (ls[l_i - 1] == rs[r_i - 1]) {
                table[l_i][r_i] = table[l_i - 1][r_i - 1] + 1;
            } else {
                table[l_i][r_i] = std::max(table[l_i][r_i - 1], table[l_i - 1][r_i]);
            }
        }
    }
    std::cout << table[l_len][r_len] << std::endl;
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        calc_lcs();
    }
}

Compiler output:
a.cc: In function 'void calc_lcs()':
a.cc:14:26: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
   14 |     int l_len = int(std::strlen(ls));
      |                          ^~~~~~
      |                          mbrlen
a.cc:15:26: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
   15 |     int r_len = int(std::strlen(rs));
      |                          ^~~~~~
      |                          mbrlen
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

static const int N = 1000

int lcs(string x, string y) {
  int c[N + 1][N + 1];
  int m = x.size();
  int n = y.size();
  int maxl = 0;
  x = ' ' + x;
  y = ' ' + y;
  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 {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int q;
  cin >> q;

  for ( int i = 0; i < q; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }

  return 0;
}

Compiler output:
a.cc:8:1: error: expected ',' or ';' before 'int'
    8 | int lcs(string x, string y) {
      | ^~~
a.cc: In function 'int main()':
a.cc:36:13: error: 'lcs' was not declared in this scope
   36 |     cout << lcs(s1, s2) << endl;
      |             ^~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

static const int N = 1000;

int las(string x, string y) {
int c[N + 1][N + 1];
int m = x.size();
int n = y.size();
int mail = 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 {
c[i][j] = max(c[i - 1][j], c[i][j - 1]);
}
maxl = max(maxl, c[i][j]);
}
}

return mail;
}

int main() {
string s1, s2;
int n; cin >> n;
for ( int i = 0; i < n; i++ ) {
cin >> s1 >> s2;
cout << les(s1, s2) << endl;
}
return 0;
}

Compiler output:
a.cc: In function 'int las(std::string, std::string)':
a.cc:25:1: error: 'maxl' was not declared in this scope; did you mean 'mail'?
   25 | maxl = max(maxl, c[i][j]);
      | ^~~~
      | mail
a.cc: In function 'int main()':
a.cc:37:9: error: 'les' was not declared in this scope; did you mean 'las'?
   37 | cout << les(s1, s2) << endl;
      |         ^~~
      |         las
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
static const int N = 1000;
 
int las(string x, string y) {
int c[N + 1][N + 1];
int m = x.size();
int n = y.size();
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 {
c[i][j] = max(c[i - 1][j], c[i][j - 1]);
}
maxl = max(maxl, c[i][j]);
}
}
 
return mail;
}
 
int main() {
string s1, s2;
int n; cin >> n;
for ( int i = 0; i < n; i++ ) {
cin >> s1 >> s2;
cout << les(s1, s2) << endl;
}
return 0;
}

Compiler output:
a.cc: In function 'int las(std::string, std::string)':
a.cc:29:8: error: 'mail' was not declared in this scope; did you mean 'maxl'?
   29 | return mail;
      |        ^~~~
      |        maxl
a.cc: In function 'int main()':
a.cc:37:9: error: 'les' was not declared in this scope; did you mean 'las'?
   37 | cout << les(s1, s2) << endl;
      |         ^~~
      |         las
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
  
static const int N = 1000;
  
int las(string x, string y) {
int c[N + 1][N + 1];
int m = x.size();
int n = y.size();
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 {
c[i][j] = max(c[i - 1][j], c[i][j - 1]);
}
maxl = max(maxl, c[i][j]);
}
}
  
return maxl;
}
  
int main() {
string s1, s2;
int n; cin >> n;
for ( int i = 0; i < n; i++ ) {
cin >> s1 >> s2;
cout << lcs(s1, s2) << endl;
}
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:9: error: 'lcs' was not declared in this scope; did you mean 'las'?
   37 | cout << lcs(s1, s2) << endl;
      |         ^~~
      |         las
Language: C++

#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = " " + X;
	Y = " " + Y;
	for(int i = 0; i <= m; i++) c[i][0] = 0;
	for(int j = 0; 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 {
			c[i][j] = max(c[i - 1][j], c[i][j - 1]);
		}
		maxl = max(maxl, c[i][j]);
	    }
	}
	
	return maxl;
}  

int main() {
	string s1, s2;
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
	    cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;  
	}
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'cin' was not declared in this scope
   33 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:36:17: error: 'cout' was not declared in this scope
   36 |                 cout << lcs(s1, s2) << endl;
      |                 ^~~~
a.cc:36:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:36:40: error: 'endl' was not declared in this scope
   36 |                 cout << lcs(s1, s2) << endl;
      |                                        ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<algorithm>
  +++ |+#include <ostream>
    3 | using namespace std;
Language: C++

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

// ---------------------
// repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// ---------------------
#define INF 922337203685477580
typedef long long ll;

int dp[1000][1000];

int main() {
  int q;
  cin >> q;
  REP(loop, q) {
    char S[1000], T[1000];
    cin >> S >> T;

    FOR(i, strlen(S)) {
      FOR(j, strlen(T)) {
        dp[i][j] = 0;
      }
    }
    for (int i = 0; i < strlen(S); i++) {
      for (int j = 0; j < strlen(T); j++) {
        if (S[i] == T[j]) {
          dp[i + 1][j + 1] = dp[i][j] + 1;
        } else {
          dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
        }
      }
    }
    cout << dp[strlen(S) - 1][strlen(T) - 1] << endl;
  }

  return 0;
}

Compiler output:
a.cc:39:21: error: macro "FOR" requires 3 arguments, but only 2 given
   39 |     FOR(i, strlen(S)) {
      |                     ^
a.cc:19:9: note: macro "FOR" defined here
   19 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |         ^~~
a.cc:40:23: error: macro "FOR" requires 3 arguments, but only 2 given
   40 |       FOR(j, strlen(T)) {
      |                       ^
a.cc:19:9: note: macro "FOR" defined here
   19 | #define FOR(i,a,b) for(int i=(a);i<(b);++i)
      |         ^~~
a.cc: In function 'int main()':
a.cc:39:5: error: 'FOR' was not declared in this scope
   39 |     FOR(i, strlen(S)) {
      |     ^~~
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int lcs(string str1, string str2)
{
	int len[1001][1001] = { 0 };

	int len1 = str1.size();
	int len2 = str2.size();
	str1 = ' ' + str1;
	str2 = ' ' + str2;

	for (int i = 0; i <= len1; i++)
		for (int j = 0; j <= len2; j++) len[i][l] = 0;

	for (int i = 1; i <= len1; i++)
	{
		for (int j = 1; j <= len2; j++)
		{
			if (str1[i] == str2[j]) len[i][j] = len[i - 1][j - 1] + 1;
			else len[i][j] = max(len[i - 1][j], len[i][j - 1]);
		}
	}
	return len[len1][len2];
}

int main()
{
	int n;
	string str1, str2;

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> str1 >> str2;
		cout << lcs(str1, str2) << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:16:56: error: 'l' was not declared in this scope
   16 |                 for (int j = 0; j <= len2; j++) len[i][l] = 0;
      |                                                        ^
Language: C++

#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>
#define MAX_N 1000

int solve(std::string s,std::string t){
        int dp[MAX_N][MAX_N]={0};
        int n,m;
        n=s.size(),m=t.size();
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        if(s[i]==t[j])
                                dp[i+1][j+1]=dp[i][j]+1;
                        else
                                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
                }
        }
        return dp[n][m];
}

int main(){
        int q;
        std::cin>>q;
        for(int i=0;i<q;i++){
                std::string s,t;
                std::cin >> s>>t;
                std::cout<<solve(s,t)<<std::endl;
        }
        return 0;
}

Compiler output:
a.cc: In function 'int solve(std::string, std::string)':
a.cc:16:46: error: 'max' was not declared in this scope; did you mean 'std::max'?
   16 |                                 dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
      |                                              ^~~
      |                                              std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
Language: C++

#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>
#define MAX_N 1000

int solve(std::string s,std::string t){
        int dp[MAX_N][MAX_N]={0};
        int n,m;
        n=s.size();
       m=t.size();
        for(int i=0;i<n;i++){
                for(int j=0;j<m;j++){
                        if(s[i]==t[j])
                                dp[i+1][j+1]=dp[i][j]+1;
                        else
                                dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
                }
        }
        return dp[n][m];
}

int main(){
        int q;
        std::cin>>q;
        for(int i=0;i<q;i++){
                std::string s,t;
                std::cin >> s>>t;
                std::cout<<solve(s,t)<<std::endl;
        }
        return 0;
}

Compiler output:
a.cc: In function 'int solve(std::string, std::string)':
a.cc:17:46: error: 'max' was not declared in this scope; did you mean 'std::max'?
   17 |                                 dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
      |                                              ^~~
      |                                              std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int lcs(string X, string Y) {
  int dp[1000 + 1][1000 + 1];
  int max = 0;
  int m = X.size;
  int n = Y.size();
  X = ' ' + X;
  Y = ' ' + Y;
  for (unsigned int i = 1; i <= m; i++)
    dp[i][0] = 0;

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

      max = (max < dp[i][j]) ? dp[i][j] : max;
    }
  }

  return max;
}

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    string X, Y;
    cin >> X >> Y;

    cout << lcs(X, Y) << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:8:13: error: cannot convert 'std::__cxx11::basic_string<char>::size' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
    8 |   int m = X.size;
      |             ^~~~
Language: C++

#include <iostream>
#include <string>
using namespace std;

int lcs(string X, string Y) {
int max = 0;
int n = X.size();
int m = Y.size();
int dp[1000+1][1000+1];

X = ' '+X;
Y = ' '+Y;

for(int i = 1:i <= n; i++)
dp[i][0] = 0;

for(int i = 1; i <= m; i++)
dp[0][i] = 0;

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

if(max < dp[i][j])
max = dp[i][j];
}
}

return max;
}

int main() {
int N;
cin >> N;

string X, Y;
for (int i = 0; i < N; i++) {
cin >> X >> Y;

cout << lcs(X, Y) << endl;
}
return 0;
}

Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:14:11: error: initializer in range-based 'for' loop
   14 | for(int i = 1:i <= n; i++)
      |           ^
a.cc:14:21: error: expected ')' before ';' token
   14 | for(int i = 1:i <= n; i++)
      |    ~                ^
      |                     )
a.cc:14:23: error: 'i' was not declared in this scope
   14 | for(int i = 1:i <= n; i++)
      |                       ^
Language: C++

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

#define N 1000

int lsc(string x,string y){
    int c[N+1][N+1];
    int m=x.size();
    int n=y.size();
    int maxl=0;

    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 {
                c[i][j]=max(c[i-1][j],c[i][j-1]);
            }
            maxl=max(maxl,c[i][j]);
        }
    }

    return maxl;
}

using namespace std;

int main() {
    string x,y;
    int n;
    cin>>n;
    for (int i = 0; i <n ; ++i) {
        cin>>x>>y;
        cout<<lsc(x,y)<<endl;
    }
    return 0;
}

Compiler output:
a.cc:7:9: error: 'string' was not declared in this scope
    7 | int lsc(string x,string y){
      |         ^~~~~~
a.cc:7:9: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:18: error: 'string' was not declared in this scope
    7 | int lsc(string x,string y){
      |                  ^~~~~~
a.cc:7:18: note: suggested alternatives:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:26: error: expression list treated as compound expression in initializer [-fpermissive]
    7 | int lsc(string x,string y){
      |                          ^
a.cc: In function 'int main()':
a.cc:41:18: error: 'lsc' cannot be used as a function
   41 |         cout<<lsc(x,y)<<endl;
      |               ~~~^~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], max = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 1; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      max = max(max, c[i][j]);
    }
  }
  return max;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:21:25: error: 'max' cannot be used as a function
   21 |       else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:22:16: error: 'max' cannot be used as a function
   22 |       max = max(max, c[i][j]);
      |             ~~~^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 1; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(max, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:22:17: error: no matching function for call to 'max(<unresolved overloaded function type>, int&)'
   22 |       maxl = max(max, c[i][j]);
      |              ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:22:17: note:   couldn't deduce template parameter '_Tp'
   22 |       maxl = max(max, c[i][j]);
      |              ~~~^~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 1; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){
    for(j = 1; j <= n; j++){
      if(x[i] == y[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Compiler output:
a.cc:41:3: error: expected unqualified-id before 'for'
   41 |   for(i = 0; i < q; i++){
      |   ^~~
a.cc:41:14: error: 'i' does not name a type
   41 |   for(i = 0; i < q; i++){
      |              ^
a.cc:41:21: error: 'i' does not name a type
   41 |   for(i = 0; i < q; i++){
      |                     ^
a.cc:45:3: error: expected unqualified-id before 'return'
   45 |   return 0;
      |   ^~~~~~
a.cc:46:1: error: expected declaration before '}' token
   46 | }
      | ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
static const int N = 1000;

int lcs(string x, string y){
  int c[N + 1][N + 1], maxl = 0, i, j;
  int m = x.size();
  int n = y.size();

  x = ' ' + x;
  y = ' ' + y;
 
  for(i = 1; i <= m; i++) c[i][0] = 0;
  for(i = 1; i <= n; i++) c[0][i] = 0;

  for(i = 1; i <= m; i++){#include <iostream>

    for(j = 1; j <= n; j++){
      if(x[i] == y[j]) c[i][j] = c[i - 1][j - 1] + 1;
      else c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }
  }
  return maxl;
}

int main(){
  string x, y;
  int q, i;

  cin >> q;
  
  for(i = 0; i < q; i++){
    cin >> x >> y;
    cout << lcs(x, y) << endl;
  }
  return 0;
}

Compiler output:
a.cc:18:27: error: stray '#' in program
   18 |   for(i = 1; i <= m; i++){#include <iostream>
      |                           ^
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:18:28: error: 'include' was not declared in this scope
   18 |   for(i = 1; i <= m; i++){#include <iostream>
      |                            ^~~~~~~
a.cc:18:45: error: expected primary-expression before '>' token
   18 |   for(i = 1; i <= m; i++){#include <iostream>
      |                                             ^
a.cc:20:5: error: expected primary-expression before 'for'
   20 |     for(j = 1; j <= n; j++){
      |     ^~~
a.cc:20:27: error: expected ';' before ')' token
   20 |     for(j = 1; j <= n; j++){
      |                           ^
      |                           ;
Language: C++

#include <bits/stdc++.h>
#define REP0(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define REPB0(i,n) for(int i=n-1;i>=0;i--)
#define REPB1(i,n) for(int i=n;i>0;i--)
#define llong long long
#define INF 2000000000
#define NIL -1
#define N 1000
using namespace std;
int LCS(string X,string Y){
  int C[N+1][N+1];
  int m=X.size();
  int n=Y.size();
  int maxl=0;
  X=' '+X;
  Y=' '+Y;
  REP1(i,m) C[i][0]=0;
  REP1(i,n) C[0][i]=0;
  REP1(i,m){
    REP1(j,n){
      if(X[i]==Y[j]) C[i][j]=C[i-1][j-1]+1;
      else C[i][j]=max(C[i-1][j],[i][j-1]);
      maxl=max(maxl,C[i][j]);
    }
  }
  return maxl;
}
int main(){
  char a[1000],b[1000];
  string s1,s2;
  int n;
  scanf("%d",&n);
  REP0(i,n){
    scanf("%s %s",a,b);
    s1=a,s2=b;
    printf("%d\n",LCS(s1,s2));
  }
  return 0;
}

Compiler output:
a.cc: In lambda function:
a.cc:23:37: error: expected '{' before '[' token
   23 |       else C[i][j]=max(C[i-1][j],[i][j-1]);
      |                                     ^
a.cc: In function 'int LCS(std::string, std::string)':
a.cc:23:37: error: no match for 'operator[]' (operand types are 'LCS(std::string, std::string)::<lambda()>' and 'int')
Language: C++

#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;

static const int N = 1000;

int Lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  REP(i, m + 1) c[i][0] = 0;
  REP(i, n + 1) c[0][j] = 0;

  REP1(i, m + 1) {
    REP1(j, n + 1) {
      if ( X[i] == Y[j] ) {
        c[i][j] = c[i - 1][j - 1] + 1;
      } else {
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      }
      maxl = max(maxl, c[i][j]);
    }
  }

  return maxl;
}

int main() {
  string s1, s2;
  int n;
  cin >> n;
  REP(i, n) {
    cin >> s1 >> s2;
    cout << Lcs(s1, s2) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int Lcs(std::string, std::string)':
a.cc:18:22: error: 'j' was not declared in this scope
   18 |   REP(i, n + 1) c[0][j] = 0;
      |                      ^
Language: C++

#include "stdafx.h"
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
static const int N = 1000;
int lcs(string X, string Y) {
	int c[N+1][N+1];
	int m = X.size();
	int n = Y.size();
	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++) {
			cout << c[i][j];
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][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 << lcs(x, y) << endl;
	}

	
}

Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

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

using namespace std;

int main () {

    int N, m, n, i, j, k, c[1001][1001];
    string x, y;

    cin >> N;

    for (k = 0; k < n; k++) {
        cin >> x >> y;
        m = x.size ();
        n = y.size ();

        for (i = 1; i < m + 1; i++) {
            for (j = 1; j <= n + 1; j++) {

                if (x[i - 1] == y[j - 1]) {
                    c[i][j] = c[i - 1][j - 1] + 1;
                } else {
                    c[i][j] = max (c[i - 1][j], c[i][j - 1]);
                }

            }
        }

    cout << c[p][q] << endl;

    }

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:31:15: error: 'p' was not declared in this scope
   31 |     cout << c[p][q] << endl;
      |               ^
a.cc:31:18: error: 'q' was not declared in this scope
   31 |     cout << c[p][q] << endl;
      |                  ^