Language: C++

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
for(;sc.hasNext();){
String s=sc.next();
String t=sc.next();
System.out.println(lcs(s,t).length());
}
}

	static String lcs(String s, String t){
		int m=s.length(), n=t.length();
		int[][] d=new int[n+1][m+1];
		int[][] v=new int[n+1][m+1];
		for(int j=1; j<=n; j++){
			for(int i=1; i<=m; i++){
				if(s.charAt(i-1)==t.charAt(j-1)){
					d[j][i]=d[j-1][i-1]+1;
					v[j][i]=0;
				}else if(d[j][i-1]>d[j-1][i]){
					d[j][i]=d[j][i-1];
					v[j][i]=+1;
				}else{
					d[j][i]=d[j-1][i];
					v[j][i]=-1;
				}
			}
		}
		String r="";
		for(int i=m, j=n; i>0&&j>0;){
			if(v[j][i]>0)
				i--;
			else if(v[j][i]<0)
				j--;
			else{
				r=s.charAt(i-1)+r;
				i--;
				j--;
			}
		}
		return r;
	}

}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.lang.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.math.*;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.io.*;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
    6 | import static java.lang.Math.*;
      | ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
    7 | import static java.util.Arrays.*;
      | ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:7: error: expected ':' before 'static'
   10 | public static void main(String[] args){
      |       ^~~~~~~
      |       :
a.cc:10:25: error: 'String' has not been declared
   10 | public static void main(String[] args){
      |                         ^~~~~~
a.cc:10:34: error: expected ',' or '...' before 'args'
   10 | public static void main(String[] args){
      |                                  ^~~~
a.cc:19:16: error: 'String' does not name a type
   19 |         static String lcs(String s, String t){
      |                ^~~~~~
a.cc:52:2: error: expected ';' after class definition
   52 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:11:1: error: 'Scanner' was not declared in this scope
   11 | Scanner sc=new Scanner(System.in);
      | ^~~~~~~
a.cc:12:6: error: 'sc' was not declared in this scope
   12 | for(;sc.hasNext();){
      |      ^~
a.cc:13:1: error: 'String' was not declared in this scope
   13 | String s=sc.next();
      | ^~~~~~
a.cc:14:8: error: expected ';' before 't'
   14 | String t=sc.next();
      |        ^
a.cc:15:1: error: 'System' was not declared in this scope
   15 | System.out.println(lcs(s,t).length());
      | ^~~~~~
a.cc:15:24: error: 's' was not declared in this scope
   15 | System.out.println(lcs(s,t).length());
      |                        ^
a.cc:15:26: error: 't' was not declared in this scope
   15 | System.out.println(lcs(s,t).length());
      |                          ^
a.cc:15:20: error: 'lcs' was not declared in this scope
   15 | System.out.println(lcs(s,t).length());
      |                    ^~~