Language: Java

#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

const int MOD = 1e9+7;

int pow(int v, int k){
	int res(1),tmp(v);
	while(k){
		if(k&1) res=(res*tmp)%MOD;
		tmp=(tmp*tmp)%MOD;
		k>>=1;
	}
	return res;
}

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> s(n);
	rep(i,n) std::cin >> s[i];
	std::vector<int> t(m);
	rep(i,m) std::cin >> t[i];
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	rep(i,n)rep(j,m) {
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		if(s[i]==t[j]) dp[i+1][j+1] = dp[i][j]+1;
	}
	print(pow(2,dp[n][m]));
  return 0;
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream> // cin, cout, cerr, clog
^
Main.java:2: error: illegal character: '#'
#include <algorithm> // minmax, sort, swap
^
Main.java:3: error: illegal character: '#'
#include <numeric> // iota, accumulate, inner_product
^
Main.java:4: error: illegal character: '#'
#include <cstdio> // printf, scanf
^
Main.java:5: error: illegal character: '#'
#include <climits> // INT_MIN, LLONG_MIN
^
Main.java:6: error: illegal character: '#'
#include <cmath> // long, trig, pow
^
Main.java:7: error: illegal character: '#'
#include <string> // string, stoi, to_string
^
Main.java:8: error: illegal character: '#'
#include <vector> // vector
^
Main.java:9: error: illegal character: '#'
#include <queue> // queue, priority_queue
^
Main.java:10: error: illegal character: '#'
#include <stack> // stack
^
Main.java:11: error: illegal character: '#'
#include <map> // key-value pairs sorted by keys
^
Main.java:12: error: illegal character: '#'
#include <set> // set
^
Main.java:13: error: illegal character: '#'
#include <unordered_map> // hashed by keys
^
Main.java:14: error: illegal character: '#'
#include <unordered_set> // hashed by keys
^
Main.java:15: error: illegal character: '#'
#include <iomanip> // cout<<setprecision(n)
^
Main.java:17: error: illegal character: '#'
#define rep(i,n) for(int i = 0; i < n; i++)
^
Main.java:17: error: class, interface, enum, or record expected
#define rep(i,n) for(int i = 0; i < n; i++)
                                ^
Main.java:17: error: class, interface, enum, or record expected
#define rep(i,n) for(int i = 0; i < n; i++)
                                       ^
Main.java:18: error: illegal character: '#'
#define ENDL "\n"
^
Main.java:19: error: illegal character: '#'
#define print(i) std::cout << (i) << "\n"
^
Main.java:21: error: illegal character: '#'
#define int long long // at least int64 > 9*10^18
^
Main.java:22: error: illegal character: '#'
#define all(v) v.begin(), v.end()
^
Main.java:26: error: unnamed classes are a preview feature and are disabled by default.
int pow(int v, int k){
^
  (use --enable-preview to enable unnamed classes)
Main.java:27: error: ';' expected
	int res(1),tmp(v);
	       ^
Main.java:38: error: not a statement
	std::cin >> n >> m;
	              ^
Main.java:39: error: not a statement
	std::vector<int> s(n);
	               ^
Main.java:40: error: not a statement
	rep(i,n) std::cin >> s[i];
	                  ^
Main.java:41: error: not a statement
	std::vector<int> t(m);
	               ^
Main.java:42: error: not a statement
	rep(i,m) std::cin >> t[i];
	                  ^
Main.java:43: error: not a statement
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	                             ^
Main.java:45: error: not a statement
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		                               ^
Main.java:45: error: not a statement
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		                                        ^
Main.java:40: error: ';' expected
	rep(i,n) std::cin >> s[i];
	        ^
Main.java:42: error: ';' expected
	rep(i,m) std::cin >> t[i];
	        ^
Main.java:43: error: '.class' expected
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	                           ^
Main.java:43: error: '.class' expected
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	                                                     ^
Main.java:43: error: ')' expected
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	                                                          ^
Main.java:43: error: ';' expected
	std::vector<std::vector<int> > dp(n+1,std::vector<int>(m+1,0));
	                                                             ^
Main.java:44: error: ';' expected
	rep(i,n)rep(j,m) {
	        ^
Main.java:44: error: ';' expected
	rep(i,n)rep(j,m) {
	                ^
Main.java:45: error: ';' expected
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		                       ^
Main.java:45: error: ';' expected
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		                                  ^
Main.java:45: error: ';' expected
		dp[i+1][j+1] = std::max(dp[i+1][j],dp[i][j+1]);
		                                             ^
43 errors