Language: C++

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Q5
{
    class Program
    {
        static void Main(string[] args)
        {
            long divide = (long)Math.Pow(10, 9) + 7;
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int N = int.Parse(strs[0]);
            int M = int.Parse(strs[1]);
            long[] S = new long[N];
            long[] T = new long[M];
            line = Console.ReadLine();
            strs = line.Split(' ');
            for (int i = 0; i < N; i++)
            {
                S[i] = long.Parse(strs[i]);
            }
            line = Console.ReadLine();
            strs = line.Split(' ');
            for (int i = 0; i < M; i++)
            {
                T[i] = long.Parse(strs[i]);
            }
            long count = 0;

            long[,] dp = new long[N, M];
            long[,] sum = new long[N, M];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    dp[i, j] = 0;
                }
            }
            for (int i = 0; i < N; i++)
            {
                for(int j = 0; j < M; j++)
                {
                    if (S[i] == T[j])
                    {
                        dp[i, j] = 1;
                        if (i > 0 && j > 0) dp[i, j] += sum[i - 1, j - 1];
                    }
                    sum[i, j] = dp[i, j];
                    if (i > 0 && j > 0) sum[i, j] -= sum[i - 1, j - 1];
                    if (i > 0) sum[i, j] += sum[i - 1, j];
                    if (j > 0) sum[i, j] += sum[i, j - 1];
                    sum[i, j] %= divide;
                }
            }
            count = sum[N-1, M-1] + 1;
            Console.WriteLine(count % divide);
        }
    }
}


Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
    4 | using System.Text;
      |       ^~~~~~
a.cc:5:7: error: expected nested-name-specifier before 'System'
    5 | using System.Threading.Tasks;
      |       ^~~~~~
a.cc:11:26: error: 'string' has not been declared
   11 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:11:35: error: expected ',' or '...' before 'args'
   11 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:62:6: error: expected ';' after class definition
   62 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void Q5::Program::Main(int*)':
a.cc:13:33: error: 'Math' was not declared in this scope
   13 |             long divide = (long)Math.Pow(10, 9) + 7;
      |                                 ^~~~
a.cc:14:13: error: 'string' was not declared in this scope
   14 |             string line = Console.ReadLine();
      |             ^~~~~~
a.cc:15:20: error: expected primary-expression before ']' token
   15 |             string[] strs = line.Split(' ');
      |                    ^
a.cc:16:21: error: expected primary-expression before 'int'
   16 |             int N = int.Parse(strs[0]);
      |                     ^~~
a.cc:17:21: error: expected primary-expression before 'int'
   17 |             int M = int.Parse(strs[1]);
      |                     ^~~
a.cc:18:17: error: structured binding declaration cannot have type 'long int'
   18 |             long[] S = new long[N];
      |                 ^~
a.cc:18:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:18:17: error: empty structured binding declaration
a.cc:18:20: error: expected initializer before 'S'
   18 |             long[] S = new long[N];
      |                    ^
a.cc:19:17: error: structured binding declaration cannot have type 'long int'
   19 |             long[] T = new long[M];
      |                 ^~
a.cc:19:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:19:17: error: empty structured binding declaration
a.cc:19:20: error: expected initializer before 'T'
   19 |             long[] T = new long[M];
      |                    ^
a.cc:20:13: error: 'line' was not declared in this scope
   20 |             line = Console.ReadLine();
      |             ^~~~
a.cc:20:20: error: 'Console' was not declared in this scope
   20 |             line = Console.ReadLine();
      |                    ^~~~~~~
a.cc:21:13: error: 'strs' was not declared in this scope
   21 |             strs = line.Split(' ');
      |             ^~~~
a.cc:24:17: error: 'S' was not declared in this scope
   24 |                 S[i] = long.Parse(strs[i]);
      |                 ^
a.cc:24:24: error: expected primary-expression before 'long'
   24 |                 S[i] = long.Parse(strs[i]);
      |                        ^~~~
a.cc:30:17: error: 'T' was not declared in this scope
   30 |                 T[i] = long.Parse(strs[i]);
      |                 ^
a.cc:30:24: error: expected primary-expression before 'long'
   30 |                 T[i] = long.Parse(strs[i]);
      |                        ^~~~
a.cc:34:18: error: expected identifier before ',' token
   34 |             long[,] dp = new long[N, M];
      |                  ^
a.cc:34:18: error: expected ']' before ',' token
a.cc:34:17: error: structured binding declaration cannot have type 'long int'
   34 |             long[,] dp = new long[N, M];
      |                 ^
a.cc:34:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:34:17: error: empty structured binding declaration
a.cc:34:21: error: expected initializer before 'dp'
   34 |             long[,] dp = new long[N, M];
      |                     ^~
a.cc:35:18: error: expected identifier before ',' token
   35 |             long[,] sum = new long[N, M];
      |                  ^
a.cc:35:18: error: expected ']' before ',' token
a.cc:35:17: error: structured binding declaration cannot have type 'long int'
   35 |             long[,] sum = new long[N, M];
      |                 ^
a.cc:35:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:35:17: error: empty structured binding declaration
a.cc:35:21: error: expected initializer before 'sum'
   35 |             long[,] sum = new long[N, M];
      |                     ^~~
a.cc:40:21: error: 'dp' was not declared in this scope
   40 |                     dp[i, j] = 0;
      |                     ^~
a.cc:47:25: error: 'S' was not declared in this scope
   47 |                     if (S[i] == T[j])
      |                         ^
a.cc:47:33: error: 'T' was not declared in this scope
   47 |                     if (S[i] == T[j])
      |                                 ^
a.cc:49:25: error: 'dp' was not declared in this scope
   49 |                         dp[i, j] = 1;
      |                         ^~
a.cc:50:57: error: 'sum' was not declared in this scope
   50 |                         if (i > 0 && j > 0) dp[i, j] += sum[i - 1, j - 1];
      |                                                         ^~~
a.cc:52:21: error: 'sum' was not declared in this scope
   52 |                     sum[i, j] = dp[i, j];
      |                     ^~~
a.cc:52:33: error: 'dp' was not declared in this scope
   52 |                     sum[i, j] = dp[i, j];
      |                                 ^~
a.cc:59:21: error: 'sum' was not declared in this scope
   59 |             count = sum[N-1, M-1] + 1;
      |                     ^~~