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

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

int lcs(string X, string Y){
  int c[1001][1001];
  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 = 1;i <= 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 lcs(std::string, std::string)':
a.cc:14:17: error: 'i' was not declared in this scope
   14 |   for(int j = 1;i <= n;j++) c[0][j] = 0;
      |                 ^
Language: C++

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

int lcs(string X, string Y){
  int c[1001][1001];
  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 = 1;i <= 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 lcs(std::string, std::string)':
a.cc:14:17: error: 'i' was not declared in this scope
   14 |   for(int j = 1;i <= n;j++) c[0][j] = 0;
      |                 ^
Language: C++

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

using namespace std;

int lcs (string x, string y) {

    int m, n, c[1001][1001], i, j, maxl = 0;

    m = x.size();
    n = y.size();

    x = ' ' + x;
    y= ' ' + y;

    for (i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for (j = 1; j <= n; j++) {
        c[0][j] = 0;
    }

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

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

            }
    }

    return maxl;

}



int main () {

    int N, i;
    string x, y;

    cin >> N;

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

    }

    return 0;

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:51:21: error: 'n' was not declared in this scope
   51 |     for (i = 0; i < n; i++) {
      |                     ^
Language: C++

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

using namespace std;

int lcs (string x, string y) {

    int m, n, c[1001][1001], i, j, maxl = 0;

    m = x.size();
    n = y.size();

    x = ' ' + x;
    y= ' ' + y;

    for (i = 0; i <= m; i++) {
        c[i][0] = 0;
    }
    for (j = 1; j <= n; j++) {
        c[0][j] = 0;
    }

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

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

            }
    }

    return maxl;

}



int main () {

    int N, i;
    string x, y;

    cin >> N;

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

    }

    return 0;

}

    

Compiler output:
a.cc: In function 'int main()':
a.cc:51:22: error: expected ';' before 'i'
   51 |     for (i = 0; i < N i++) {
      |                      ^~
      |                      ;
Language: C++

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

static const int N = 1000;

int longestCommonSubsequence(string X, stringY)  {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  intmax1 = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; i++) 
    c[i][0] = 0;
  for (int j = 1; j <= n; j++)
    s[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]);
      }
      max1 = max(max1, c[i][j]);
    }
  }
  return max1;
}
 
int main()  {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)  {
    cin >> s1 >> s2;
  cout << longestCommonSubsequence(s1, s2) << endl;
  }
  return ;
}

Compiler output:
a.cc:8:40: error: 'stringY' has not been declared
    8 | int longestCommonSubsequence(string X, stringY)  {
      |                                        ^~~~~~~
a.cc: In function 'int longestCommonSubsequence(std::string, int)':
a.cc:11:11: error: 'Y' was not declared in this scope
   11 |   int n = Y.size();
      |           ^
a.cc:12:3: error: 'intmax1' was not declared in this scope
   12 |   intmax1 = 0;
      |   ^~~~~~~
a.cc:18:5: error: 's' was not declared in this scope
   18 |     s[0][j] = 0;
      |     ^
a.cc:28:7: error: 'max1' was not declared in this scope
   28 |       max1 = max(max1, c[i][j]);
      |       ^~~~
a.cc:31:10: error: 'max1' was not declared in this scope
   31 |   return max1;
      |          ^~~~
a.cc: In function 'int main()':
a.cc:40:40: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int'
   40 |   cout << longestCommonSubsequence(s1, s2) << endl;
      |                                        ^~
      |                                        |
      |                                        std::string {aka std::__cxx11::basic_string<char>}
a.cc:8:40: note:   initializing argument 2 of 'int longestCommonSubsequence(std::string, int)'
    8 | int longestCommonSubsequence(string X, stringY)  {
      |                                        ^~~~~~~
a.cc:42:3: error: return-statement with no value, in function returning 'int' [-fpermissive]
   42 |   return ;
      |   ^~~~~~
Language: C++

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

static const int N = 1000;

int longestCommonSubsequence(string X, string Y)  {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int max1 = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for (int i = 0; i <= m; i++) 
    c[i][0] = 0;
  for (int j = 1; j <= n; j++)
    s[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]);
      }
      max1 = max(max1, c[i][j]);
    }
  }
  return max1;
}
 
int main()  {
  string s1, s2;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)  {
    cin >> s1 >> s2;
  cout << longestCommonSubsequence(s1, s2) << endl;
  }
  return ;
}

Compiler output:
a.cc: In function 'int longestCommonSubsequence(std::string, std::string)':
a.cc:18:5: error: 's' was not declared in this scope
   18 |     s[0][j] = 0;
      |     ^
a.cc: In function 'int main()':
a.cc:42:3: error: return-statement with no value, in function returning 'int' [-fpermissive]
   42 |   return ;
      |   ^~~~~~
Language: C++

#include <stdio.h>
#include <string.h>

void Ics(char *X, char *Y)
{
   int c[1000][1000];
   int m, n, i, j;

   m = strlen(X);
   n = strlen(Y);

   for ( i = 1; i <= m, i++ ) {
      c[i][0] = 0;
   }
   for ( j = 0; j <= n; j++ ) {
      c[0][j] =0;
   }

   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 if ( c[ i - 1 ][ j ] >= c[ i ][ j - 1 ] ){
            c[ i ][ j ] = c[ i - 1 ][ j ];
         } else {
            c[ i ][ j ] = c[ i ][ j - 1 ];
         }
      }
   }
   printf("%d\n", c[ m ][ n ]);
}
     
int main()
{
   int q, i;
   char X[1000], Y[1000];

   scanf("%d", &q);
   for ( i = 0; i < q; i++ ) {
      scanf("%s%s", X, Y);
      Ics(X, Y);
   }
   return 0;
}

Compiler output:
a.cc: In function 'void Ics(char*, char*)':
a.cc:12:28: error: expected ';' before ')' token
   12 |    for ( i = 1; i <= m, i++ ) {
      |                            ^~
      |                            ;
Language: C++

#include <stdio.h>

int judge(char A[], char B[]){
  int a=0, b=0, sw=0, ans=0;
  int i, j;
  int C[1001][1001];
  
  while(sw == 0){
    if(A[a] != '\0')
      a++;
    else
      sw = 1;
  }
  
  sw = 0;
  
  while(sw = 0){
    if(B[b] != '\0')
      b++;
    else
      sw = 1;
  }
  
  for(i=1; i<a+1; i++)
    C[i][0] = 0;
  for(i=1; i<b+1; i++)
    C[0][i] = 0;
  
  for(i=1; i<a+1 i++){
    for(j=1; j<b+1; j++){
      if(A[i-1] == B[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];
      if(max < C[i][j])
        max = c[i][j];
    }
  }
  
  return max;
}

int main(){
  char A[1000], B[1000];
  int n, i;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%s", a);
    scanf("%s", b);
    printf("%d\n", judge(a, b));
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int judge(char*, char*)':
a.cc:29:17: error: expected ';' before 'i'
   29 |   for(i=1; i<a+1 i++){
      |                 ^~
      |                 ;
a.cc:33:21: error: two consecutive '[' shall only introduce an attribute before '[' token
   33 |       else if(C[i-1][[j] >= C[i][j-1])
      |                     ^
a.cc:33:21: error: expected ')' before '[' token
   33 |       else if(C[i-1][[j] >= C[i][j-1])
      |              ~      ^
      |                     )
a.cc:37:10: error: 'max' was not declared in this scope
   37 |       if(max < C[i][j])
      |          ^~~
a.cc:38:15: error: 'c' was not declared in this scope
   38 |         max = c[i][j];
      |               ^
a.cc:42:10: error: 'max' was not declared in this scope
   42 |   return max;
      |          ^~~
a.cc: In function 'int main()':
a.cc:52:17: error: 'a' was not declared in this scope
   52 |     scanf("%s", a);
      |                 ^
a.cc:53:17: error: 'b' was not declared in this scope
   53 |     scanf("%s", b);
      |                 ^
Language: C++

#include <stdio.h>

int judge(char A[], char B[]){
  int a=0, b=0, sw=0, ans=0;
  int i, j;
  int C[1001][1001];
  
  while(sw == 0){
    if(A[a] != '\0')
      a++;
    else
      sw = 1;
  }
  
  sw = 0;
  
  while(sw = 0){
    if(B[b] != '\0')
      b++;
    else
      sw = 1;
  }
  
  for(i=1; i<a+1; i++)
    C[i][0] = 0;
  for(i=1; i<b+1; i++)
    C[0][i] = 0;
  
  for(i=1; i<a+1; i++){
    for(j=1; j<b+1; j++){
      if(A[i-1] == B[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];
      if(max < C[i][j])
        max = c[i][j];
    }
  }
  
  return max;
}

int main(){
  char A[1000], B[1000];
  int n, i;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    scanf("%s", a);
    scanf("%s", b);
    printf("%d\n", judge(a, b));
  }
  
  return 0;
}

Compiler output:
a.cc: In function 'int judge(char*, char*)':
a.cc:33:21: error: two consecutive '[' shall only introduce an attribute before '[' token
   33 |       else if(C[i-1][[j] >= C[i][j-1])
      |                     ^
a.cc:33:21: error: expected ')' before '[' token
   33 |       else if(C[i-1][[j] >= C[i][j-1])
      |              ~      ^
      |                     )
a.cc:37:10: error: 'max' was not declared in this scope
   37 |       if(max < C[i][j])
      |          ^~~
a.cc:38:15: error: 'c' was not declared in this scope
   38 |         max = c[i][j];
      |               ^
a.cc:42:10: error: 'max' was not declared in this scope
   42 |   return max;
      |          ^~~
a.cc: In function 'int main()':
a.cc:52:17: error: 'a' was not declared in this scope
   52 |     scanf("%s", a);
      |                 ^
a.cc:53:17: error: 'b' was not declared in this scope
   53 |     scanf("%s", b);
      |                 ^
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int LCS(char *x,char *y);
char x[1000], y[1000];
int lcs[1000][1000];
int main()
{
	int q,i,j;

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

int LCS(char *x, char *y)
{
	int i, j;
	int len_x, len_y;
	len_x = strlen(x);
	len_y = strlen(y);
	
	for (i = 0; i < len_x; i++) {
		if (x[0] == y[i]) {
			lcs[0][i] = 1;
		}
		else {
			lcs[0][i] = 0;
		}
	}
	for (i = 0; i < len_x; i++) {
		if (x[i] == y[0]) {
			lcs[i][0] = 1;
		}
		else {
			lcs[i][0] = 0;
		}
	}

	for (i = 0; i < len_x; i++) {
		for (j = 0; j < len_y; j++) {
			if (x[i] == y[j]) {
				lcs[i][j] = lcs[i - 1][j - 1] + 1;
				//printf("lcs[%d][%d]=%d\n", i, j, lcs[i - 1][j - 1] + 1);
			}
			if (x[i] != y[j]) {
				lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
				//printf("lcs[%d][%d]=%d\n", i, j, max(lcs[i - 1][j], lcs[i][j - 1]));
			}
		}
	}
	//cout << endl;

	for (i = 0; i < len_x; i++) {
		for (j = 0; j < len_y; j++) {
			//printf("%d ", lcs[i][j]);
		}
		//cout << endl;
	}
	//cout << "len_x=" << len_x << endl << "len_y=" << len_y << endl;
			
	return lcs[len_x-1][len_y-1];
}

Compiler output:
a.cc: In function 'int LCS(char*, char*)':
a.cc:23:17: error: 'strlen' was not declared in this scope
   23 |         len_x = strlen(x);
      |                 ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

using namespase 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 = 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 ( i = 0; i < n; i++ ){
        cin >> s1 >> s2;
        cout << lcs(s1, s2) << sndl;
    }
    
    return 0;
    
}

Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'namespase'
    1 | using namespase std;
      |       ^~~~~~~~~
a.cc:4:10: error: 'string' was not declared in this scope
    4 | int lcs( string X, string Y ) {
      |          ^~~~~~
a.cc:4:20: error: 'string' was not declared in this scope
    4 | int lcs( string X, string Y ) {
      |                    ^~~~~~
a.cc:4:29: error: expression list treated as compound expression in initializer [-fpermissive]
    4 | int lcs( string X, string Y ) {
      |                             ^
a.cc: In function 'int main()':
a.cc:28:5: error: 'string' was not declared in this scope
   28 |     string s1, s2;
      |     ^~~~~~
a.cc:29:12: error: 'cin' was not declared in this scope
   29 |     int n; cin >> n;
      |            ^~~
a.cc:30:11: error: 'i' was not declared in this scope
   30 |     for ( i = 0; i < n; i++ ){
      |           ^
a.cc:31:16: error: 's1' was not declared in this scope
   31 |         cin >> s1 >> s2;
      |                ^~
a.cc:31:22: error: 's2' was not declared in this scope
   31 |         cin >> s1 >> s2;
      |                      ^~
a.cc:32:9: error: 'cout' was not declared in this scope
   32 |         cout << lcs(s1, s2) << sndl;
      |         ^~~~
a.cc:32:20: error: 'lcs' cannot be used as a function
   32 |         cout << lcs(s1, s2) << sndl;
      |                 ~~~^~~~~~~~
a.cc:32:32: error: 'sndl' was not declared in this scope
   32 |         cout << lcs(s1, s2) << sndl;
      |                                ^~~~
Language: C++

import scala.io.StdIn._

object Main extends App {
  val q = readInt()

  var i = 0

  while (i < q) {
    val a = readLine().toString.split("").toSet
    val b = readLine().toString.split("").toSet

    var count = 0
    for (j <- a) {
      if (b contains j) count += 1
    }
    println(count)

    i += 1
  }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import scala.io.StdIn._
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define For(I,A,B) for(int I=(A); I < (B); ++I)
int main()
{
int t;
cin>>t;
while(t--){
int a[1000]={0},b[1000]={0},c[200][200];
int x,y,z,k=0,l,i,j;

 For(i,0,200)
 For(j,0,200)
 c[i][j]=0;


 cin>>x>>y;
 For(i,0,x+1)
 For(j,0,y+1)
 c[i][j]=0;
 For(i,1,x+1) cin>>a[i];
 For(i,1,y+1) cin>>b[i];

 For(i,1,x+1)
 For(j,1,y+1)
 {
     if(a[i]==b[j]) c[i][j]=c[i-1][j-1]+1;
     else  c[i][j]=max(c[i-1][j],c[i][j-1]);
 }
    cout<<c[x][y]<<endl;

}
}
    return 0;
}

Compiler output:
a.cc:34:5: error: expected unqualified-id before 'return'
   34 |     return 0;
      |     ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
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();
  
  for (int i = 0; i < m; i++) c[i][0] = 0;
  for (int i = 0; i < n; i++) c[0][j] = 0;

  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (X[i] == Y[j]) 
        if (i == 0 || j == 0) 
          c[i][j] = 1;
        else 
          c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i][j - 1], c[i - 1][j]);
    }
  }
  return c[m - 1][n - 1];
}

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 lcs(std::string, std::string)':
a.cc:15:36: error: 'j' was not declared in this scope
   15 |   for (int i = 0; i < n; i++) c[0][j] = 0;
      |                                    ^
Language: C++

#include <cstdio>
#include <algorithm>

using namespace std;
const int N_MAX = 1000;
char x[N_MAX+10], y[N_MAX+10];
int dp[N_MAX][N_MAX];

void solve() {
  int i, j;
  scanf("%s", x);
  scanf("%s", y);
  int N = strlen(x);
  int M = strlen(y);
  //printf("N = %d M = %d", N, M);
  for (i = 0; i < N+1; i++) {
    dp[i][0] = 0;
  }
  for (j = 0; j < M+1; j++) {
    dp[0][j] = 0;
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      if (x[i] == y[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]);
      }
    }
  }
  printf("%d\n", dp[N][M]);
} 

int main() {
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    solve();
  }
  return 0;
}



Compiler output:
a.cc: In function 'void solve()':
a.cc:13:11: error: 'strlen' was not declared in this scope
   13 |   int N = strlen(x);
      |           ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 |
Language: C++

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

using namespace std;
const int N_MAX = 1000;
char x[N_MAX+10], y[N_MAX+10];
int dp[N_MAX][N_MAX];

void solve() {
  int i, j;
  scanf("%s", x);
  scanf("%s", y);
  int N = strlen(x);
  int M = strlen(y);
  //printf("N = %d M = %d", N, M);
  for (i = 0; i < N+1; i++) {
    dp[i][0] = 0;
  }
  for (j = 0; j < M+1; j++) {
    dp[0][j] = 0;
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      if (x[i] == y[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]);
      }
    }
  }
  printf("%d\n", dp[N][M]);
} 

int main() {
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    solve();
  }
  return 0;
}



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

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>

int LCS(std::string s,std::string t){
    int n,m,c[n+1][m+1];
    n=s.size();
    m=t.size();
    int maxlen=0;
    for(int i=0;i<N;i++){
        c[i][0]=0; 
    }
    for(int i=0;i<M;i++){
        c[0][i]=0;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[i]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=std::max(c[i-1][j],c[i][j-1]);
            }
            maxlen=std::max(c[i][j],maxlen);
        }
    }
    return max
}
int main(){
	int N;
    
    std::cin >> N;
    std::string s1,s2;
    for(int i=0;i<N;i++){
        std::cin >> s1 >> s2;
        std::cout << LCS(s1,s2) <<std::endl;
    }
        
    
    return 0;
}


Compiler output:
a.cc: In function 'int LCS(std::string, std::string)':
a.cc:18:19: error: 'N' was not declared in this scope
   18 |     for(int i=0;i<N;i++){
      |                   ^
a.cc:21:19: error: 'M' was not declared in this scope
   21 |     for(int i=0;i<M;i++){
      |                   ^
a.cc:34:12: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |     return max
      |            ^~~
      |            std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:34:15: error: expected ';' before '}' token
   34 |     return max
      |               ^
      |               ;
   35 | }
      | ~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
#include <inttypes.h>

int LCS(std::string s,std::string t){
    int n,m,c[n+1][m+1];
    n=s.size();
    m=t.size();
    int maxlen=0;
    for(int i=0;i<n;i++){
        c[i][0]=0; 
    }
    for(int i=0;i<m;i++){
        c[0][i]=0;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i]==t[i]){
                c[i][j]=c[i-1][j-1]+1;
            }else{
                c[i][j]=std::max(c[i-1][j],c[i][j-1]);
            }
            maxlen=std::max(c[i][j],maxlen);
        }
    }
    return max
}
int main(){
	int N;
    
    std::cin >> N;
    std::string s1,s2;
    for(int i=0;i<N;i++){
        std::cin >> s1 >> s2;
        std::cout << LCS(s1,s2) <<std::endl;
    }
        
    
    return 0;
}


Compiler output:
a.cc: In function 'int LCS(std::string, std::string)':
a.cc:34:12: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |     return max
      |            ^~~
      |            std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:34:15: error: expected ';' before '}' token
   34 |     return max
      |               ^
      |               ;
   35 | }
      | ~
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1010;
char x[N],y[N];
int c[N][N];
int lcs(char x[],char y[]){

    int lenx = strlen(x+1);
    int leny = strlen(y+1);

    for (int i=0; i<=lenx; i++) {
        c[i][0] = 0;
    }
    for(int j=1;j<=leny;j++){
        c[0][j] = 0;
        
    }

    for(int i=1;i<lenx;i++){
        for(int j=1;j<leny;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]);
        }
    }
    return c[lenx][leny];
}
int main(){
    int q;
    scanf("%d",&q);
    for (int i=0; i<q; i++) {
        gets(x+1);
        gets(y+1);
        cout<<lcs(x, y)<<endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   36 |         gets(x+1);
      |         ^~~~
      |         getw
Language: C++

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 1010;

int c[N][N];
int lcs(char x[],char y[]){

    int lenx = strlen(x+1);
    int leny = strlen(y+1);

    for (int i=0; i<=lenx; i++) {
        c[i][0] = 0;
    }
    for(int j=1;j<=leny;j++){
        c[0][j] = 0;
        
    }

    for(int i=1;i<lenx;i++){
        for(int j=1;j<leny;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]);
        }
    }
    return c[lenx][leny];
}
int main(){
    int q;
    char x[N],y[N];
    scanf("%d",&q);
    for (int i=0; i<q; i++) {
        gets(x+1);
        gets(y+1);
        cout<<lcs(x, y)<<endl;
    }
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:37:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   37 |         gets(x+1);
      |         ^~~~
      |         getw
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
char A[N],B[N];
int dp[N][N];
void lcs(char A[],char B[]){
    int lenA = strlen(A+1);
    int lenB = strlen(B+1);
    
    for(int i=0;i<=lenA;i++){
        dp[i][0] = 0;
    }
    for(int i=0;i<lenB;i++){
        dp[0][i] = 0;
    }
    for (int i=1; i<=lenA; i++) {
        for(int j=1;j<=lenB;j++){
            if(A[i] == B[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    printf("%d\n",dp[lenA][lenB]);
}

int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        //从下标为1开始读入
        lcs(gets(A+1),gets(B+1));
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'gets' was not declared in this scope; did you mean 'getw'?
   34 |         lcs(gets(A+1),gets(B+1));
      |             ^~~~
      |             getw
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
char A[N],B[N];
int dp[N][N];
void lcs(char A[],char B[]){
    int lenA = strlen(A+1);
    int lenB = strlen(B+1);
    
    for(int i=0;i<=lenA;i++){
        dp[i][0] = 0;
    }
    for(int i=0;i<lenB;i++){
        dp[0][i] = 0;
    }
    for (int i=1; i<=lenA; i++) {
        for(int j=1;j<=lenB;j++){
            if(A[i] == B[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    printf("%d\n",dp[lenA][lenB]);
}

int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        //从下标为1开始读入
        gets(A+1);
        gets(B+1);
        lcs(A, B);
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   34 |         gets(A+1);
      |         ^~~~
      |         getw
Language: C++

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
char A[N],B[N];
int dp[N][N];
int main(){
    int n;
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        gets(A+1);  //从下标为1开始读入
        gets(B+1);
    int lenA = strlen(A+1);
    int lenB = strlen(B+1);
    for(int i=0;i<=lenA;i++){
        dp[i][0] = 0;
    }
    for(int i=0;i<lenB;i++){
        dp[0][i] = 0;
    }
    for (int i=1; i<=lenA; i++) {
        for(int j=1;j<=lenB;j++){
            if(A[i] == B[j]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }
    printf("%d\n",dp[lenA][lenB]);
}
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
   12 |         gets(A+1);  //从下标为1开始读入
      |         ^~~~
      |         getw
Language: C++

def lcs(str_a,str_b):    
    if len(str_a) == 0 or len(str_b) == 0:
        return 0
    dp = [[0 for kb in range(len(str_b) + 1)] for ka in range(len(str_a) + 1)]
    for i in range(1, len(str_a) + 1):
        for j in range(1, len(str_b) + 1):
            if str_a[i-1] == str_b[j-1]:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = max([dp[i-1][j], dp[i][j-1]])
  #print ("length of LCS is :",dp[len(str_a)][len(str_b)])
    return dp[len(str_a)][len(str_b)]

n=int(input())
for i in range(n):
    s1=input()
    s2=input()
    print(lcs(s1,s2))


Compiler output:
a.cc:11:4: error: invalid preprocessing directive #print
   11 |   #print ("length of LCS is :",dp[len(str_a)][len(str_b)])
      |    ^~~~~
a.cc:1:1: error: 'def' does not name a type
    1 | def lcs(str_a,str_b):
      | ^~~
Language: C++

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

using namespace std;


static const int int N = 1000;


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

    x = ' ' + x;
    y = ' ' + y;

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

    return 0;
}

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:8:8: error: two or more data types in declaration of 'N'
    8 | static const int int N = 1000;
      |        ^~~~~
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:12:11: error: 'N' was not declared in this scope
   12 |     int c[N + 1][N + 1];
      |           ^
a.cc:20:34: error: 'c' was not declared in this scope
   20 |     for (int i = 0; i <= m; i++) c[i][0] = 0;
      |                                  ^
a.cc:21:34: error: 'c' was not declared in this scope
   21 |     for (int i = 0; i <= n; i++) c[0][i] = 0;
      |                                  ^
a.cc:26:17: error: 'c' was not declared in this scope
   26 |                 c[i][j] = c[i - 1][j - 1] + 1;
      |                 ^
a.cc:28:17: error: 'c' was not declared in this scope
   28 |                 c[i][j] = max(c[i][j - 1], c[i - 1][j]);
      |                 ^
a.cc:30:28: error: 'c' was not declared in this scope
   30 |             res = max(res, 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];
  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 = 1; i < n; i++) {
    c[0][j] = 0;
  }

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[i]) {
        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 lcs(std::string, std::string)':
a.cc:17:5: error: 'c' was not declared in this scope
   17 |     c[i][0] = 0;
      |     ^
a.cc:19:19: error: 'i' was not declared in this scope
   19 |   for (int j = 1; i < n; i++) {
      |                   ^
a.cc:20:5: error: 'c' was not declared in this scope
   20 |     c[0][j] = 0;
      |     ^
a.cc:26:9: error: 'c' was not declared in this scope
   26 |         c[i][j] = c[i - 1][j - 1] + 1;
      |         ^
a.cc:28:9: error: 'c' was not declared in this scope
   28 |         c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      |         ^
a.cc:30:24: error: 'c' was not declared in this scope
   30 |       maxl = max(maxl, 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];
  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 = 1; i < n; i++) {
    c[0][j] = 0;
  }

  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      if (X[i] == Y[i]) {
        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 lcs(std::string, std::string)':
a.cc:19:19: error: 'i' was not declared in this scope
   19 |   for (int j = 1; i < n; i++) {
      |                   ^
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define MAX 100000

static const int N =100;

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

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


Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:18:22: error: 'c' was not declared in this scope
   18 |   for(int i;i<=m;i++)c[i][0]=0;
      |                      ^
a.cc:19:22: error: 'c' was not declared in this scope
   19 |   for(int j;j<=n;j++)c[0][j]=0;
      |                      ^
a.cc:24:9: error: 'c' was not declared in this scope
   24 |         c[i][j]=c[i-1][j-1]+1;
      |         ^
a.cc:27:9: error: 'c' was not declared in this scope
   27 |         c[i][j]=max(c[i-1][j],c[i][j-1]);
      |         ^
a.cc:29:19: error: 'c' was not declared in this scope
   29 |       ans=max(ans,c[i][j]);
      |                   ^
a.cc: In function 'int main()':
a.cc:41:13: error: 'lsc' was not declared in this scope; did you mean 'lcs'?
   41 |     cout << lsc(s1,s2) << endl;
      |             ^~~
      |             lcs
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
#define MAX 100000

static const int N =100;

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: 'lsc' was not declared in this scope; did you mean 'lcs'?
   41 |     cout << lsc(s1,s2) << endl;
      |             ^~~
      |             lcs
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;
  C[0][0] = 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]);
    }
  }javascript:void(0)

  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 lcs(std::string, std::string)':
a.cc:15:3: error: 'C' was not declared in this scope
   15 |   C[0][0] = 0
      |   ^
a.cc:16:20: error: 'i' was not declared in this scope
   16 |   for ( int i = 1; i <= m; i++ ) c[i][0] = 0;
      |                    ^
a.cc:28:22: error: expected ';' before 'return'
   28 |   }javascript:void(0)
      |                      ^
      |                      ;
   29 | 
   30 |   return maxl;
      |   ~~~~~~              
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
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;
  C[0][0] = 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]);
    }
  }javascript:void(0)

  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 lcs(std::string, std::string)':
a.cc:15:3: error: 'C' was not declared in this scope
   15 |   C[0][0] = 0;
      |   ^
a.cc:28:22: error: expected ';' before 'return'
   28 |   }javascript:void(0)
      |                      ^
      |                      ;
   29 | 
   30 |   return maxl;
      |   ~~~~~~              
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
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;
  c[0][0] = 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]);
    }
  }javascript:void(0)

  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 lcs(std::string, std::string)':
a.cc:28:22: error: expected ';' before 'return'
   28 |   }javascript:void(0)
      |                      ^
      |                      ;
   29 | 
   30 |   return maxl;
      |   ~~~~~~              
a.cc:31:1: warning: no return statement in function returning non-void [-Wreturn-type]
   31 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000
const int MOD = 1000000009

//マクロ
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define REP(i, n) FOR(i, 0, n);
#define ALL(a) (a).begin(),(a).end()

// 最長共通部分列問題
// 入力
// S T

// dp[i + 1][j + 1] := Sのi文字目までと、Tのj文字目までのLCSの長さ
// 計算量 O(|S||T|)

int main(){

    //入力
    int n; cin >> n;
    for(int roop = 0; roop < n; roop++){
        string S, T; cin >> S >> T;
        vector<vector<int> > dp(S.size() + 1, vector<int> (T.size() + 1, INF));

        //dp初期条件
        dp[0][0] = 0;

        //dp
        for(int i = 0; i < S.size(); i++){
            for(int j = 0; j < T.size(); j++){
                if(S[i] == T[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
                dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
            }
        }

        cout << dp[S.size()][T.size()];
        return 0;
    }
}


Compiler output:
a.cc:18:1: error: expected ',' or ';' before 'int'
   18 | int main(){
      | ^~~
Language: C++

#include <iostream>
#include <string>
#include <map>
#include <vector>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

// 最長共通部分列 ... len(s) == m, len(t) == n とすると, O(mn)
int lcs(std::string s, std::string t) {
  std::vector<std::vector<int> > dp(s.size() + 1, std::vector<int>(t.size() + 1, 0));

  for (int i = 0; i < s.size(); ++i) {
    for (int j = 0; j < t.size(); ++j) {
      if (s[i] == t[j]) {
        dp[i][j] = (i == 0 ? (j == 0 ? 1 : 0) : ;
      }
      else if (i >= 0 && j >= 0 && dp[i - 1][j] >= dp[j][i - 1]) {
        dp[i][j] = dp[i - 1][j];
      }
      else if (i >= 0 && j >= 0) {
        dp[i][j] = dp[i][j - 1];
      }
    }
  }

  return dp[s.size()][t.size()];
}

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

  return 0;
}


Compiler output:
a.cc: In function 'int lcs(std::string, std::string)':
a.cc:18:49: error: expected primary-expression before ';' token
   18 |         dp[i][j] = (i == 0 ? (j == 0 ? 1 : 0) : ;
      |                                                 ^
a.cc:18:48: error: expected ')' before ';' token
   18 |         dp[i][j] = (i == 0 ? (j == 0 ? 1 : 0) : ;
      |                    ~                           ^~
      |                                                )
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#define MAX 1000

using namespace std;

string s,t;
int dp[MAX + 1][MAX + 1];

int LCS(void){

  for( int i = 0 ; i < s.size() ; i++ ){
    for( int j = 0 ; j < t.size() ; 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]);
      }
    }
  }
  return dp[s.size()][t.size()];
}


int main(void){

  int n;
  cin >> n;
  while(n--){

    memset(dp, 0 , sizeof(dp) );

    cin >> s >> t;
    cout << LCS() << endl;

  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:5: error: 'memset' was not declared in this scope
   32 |     memset(dp, 0 , sizeof(dp) );
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 | #define MAX 1000
Language: C++

import java.io.PrintWriter
import java.util.*

data class PE(var p: Double, var e: Double)
data class Node(var center: PE, var left: PE, var right: PE, var lNode: Node?, var rNode: Node?) : Comparable<Node> {
    override fun compareTo(other: Node): Int {
        val a = center.e + center.p
        val o = other.center.e + other.center.p
        return if (a == o) 0
        else if( a < o ) -1
        else 1
    }
}

fun main(args: Array<String>) = with(PrintWriter(System.out)) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.trim().split(' ').map { it.toDouble() }
    val q = readLine()!!.trim().split(' ').map { it.toDouble() }

    val list = mutableListOf<Node>()
    for (i in 0 until n) {
        val c = p[i]
        val l = q[i]
        val r = q[i+1]
        list.add(Node(PE(c+l+r, c+(l+r)*2), PE(l, l), PE(r, r), null, null))
    }

    if ( n == 1 ) {
        print(list[0].center.e)
        flush()
        return
    }

    list[0].rNode = list[1]
    list[n-1].lNode = list[n-2]
    for (i in 1 until n-1) {
        list[i].lNode = list[i-1]
        list[i].rNode = list[i+1]
    }

    // pop min e+p
    val queue = PriorityQueue<Node>(n)
    queue.addAll(list)

    while (queue.size != 1) {
        val minNode = queue.poll()

        if (minNode.rNode != null) {
            val rNode = minNode.rNode!!
            queue.remove(rNode)
            rNode.center.p = rNode.center.p - rNode.left.p + minNode.center.p
            rNode.center.e = rNode.center.e - rNode.left.e - rNode.left.p + minNode.center.e + minNode.center.p
            rNode.left = minNode.center
            rNode.lNode = minNode.lNode
            queue.add(rNode)
        }

        if (minNode.lNode != null) {
            val lNode = minNode.lNode!!
            queue.remove(lNode)
            lNode.center.p = lNode.center.p - lNode.right.p + minNode.center.p
            lNode.center.e = lNode.center.e - lNode.right.e - lNode.right.p + minNode.center.e + minNode.center.p
            lNode.right = minNode.center
            lNode.rNode = minNode.rNode
            queue.add(lNode)
        }
    }

    val minNode = queue.poll()
    println(minNode.center.e)
    flush()
}



Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.PrintWriter
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:15:1: error: 'fun' does not name a type
   15 | fun main(args: Array<String>) = with(PrintWriter(System.out)) {
      | ^~~
Language: Java

package sample;

import java.io.*;
import java.util.*;
public class ProblemIntro11_A {
	int output[][] = new int[100][100];
	int dataset = 0;//????????°
	int touch = 0;//??£??\??°
	int number = 0;
	String input = null;
	BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String []args){
		ProblemIntro11_A run = new ProblemIntro11_A();
		run.Run();
	}
	public void Run(){
		for(int z = 0;z < 100;z++){
			for(int y = 0;y < 100;y++){
				output[z][y] = -1;
			}
		}
		while(true){
			try{
				input = read.readLine();
				if(dataset == 0){
					dataset = Integer.parseInt(input);
				}for(int z = 0;z < dataset;z++){
					input = read.readLine();
					String get[] = input.split(" ");
					for(int n = 0; n < get.length;n++){
						if(n == 0)number = Integer.parseInt(get[n]);
						if(n >= 2){
							touch = Integer.parseInt(get[n]);
							output[number-1][touch-1] = 1;
						}
					}
				}for(int z = 0;z < dataset;z++){
					for(int y = 0;y < dataset;y++){
						if(output[z][y] == -1)output[z][y] = 0;
					}
				}break;
			}catch(Exception e){
				
			}
		}
		for(int z = 0;z < dataset;z++){
			for(int y = 0;y < dataset;y++){
				if(y != dataset-1)System.out.print(output[z][y]+" ");
				else System.out.println(output[z][y]);
			}
		}
	}
}

Compiler output:
Main.java:5: error: class ProblemIntro11_A is public, should be declared in a file named ProblemIntro11_A.java
public class ProblemIntro11_A {
       ^
1 error
Language: Java

package aoj;

import java.util.Scanner;

public class ALDS1_11_A {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] m = new int[n][n];

        int u, k, v;
        for (int i = 0; i < n; i++) {
            u = scanner.nextInt();
            k = scanner.nextInt();
            for (int j = 0; j < k; j++) {
                v = scanner.nextInt();
                m[u-1][v-1] = 1;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                System.out.print(m[i][j] + " ");
            }
            System.out.println("");
        }
    }
}

Compiler output:
Main.java:5: error: class ALDS1_11_A is public, should be declared in a file named ALDS1_11_A.java
public class ALDS1_11_A {
       ^
1 error