Language: C++

#include<bits/stdc++.h>
int dp[101][101];
int lcs(int x, int y, string s1, string s2)
{
    // your code here
    if(x==0 || y==0)
    return 0;
    for(int i=0;i<100;i++)
    {
        for(int j=0;j<100;j++)
        {
            dp[i][j]=0;
        }
    }
    if(s1[0]==s2[0])
    dp[0][0]=1;
    for(int i=1;i<x;i++)
    {
        if(dp[0][i-1]==1)
        {
            dp[0][i]=1;
        }
        else
        {
            if(s2[0]==s1[i])
            {
                dp[0][i]=1;
            }
            else
            {
                dp[0][i]=0;
            }
        }
    }
    for(int i=1;i<y;i++)
    {
        for(int j=0;j<x;j++)
        {
            if(s2[i]==s1[j])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    return dp[y-1][x-1];
}
int main()
{
  string s,t;
  cin>>s>>t;
  cout<<lcs(s.length(),t.length(),s,t);
}

Compiler output:
a.cc:3:23: error: 'string' has not been declared
    3 | int lcs(int x, int y, string s1, string s2)
      |                       ^~~~~~
a.cc:3:34: error: 'string' has not been declared
    3 | int lcs(int x, int y, string s1, string s2)
      |                                  ^~~~~~
a.cc: In function 'int lcs(int, int, int, int)':
a.cc:15:10: error: invalid types 'int[int]' for array subscript
   15 |     if(s1[0]==s2[0])
      |          ^
a.cc:15:17: error: invalid types 'int[int]' for array subscript
   15 |     if(s1[0]==s2[0])
      |                 ^
a.cc:25:18: error: invalid types 'int[int]' for array subscript
   25 |             if(s2[0]==s1[i])
      |                  ^
a.cc:25:25: error: invalid types 'int[int]' for array subscript
   25 |             if(s2[0]==s1[i])
      |                         ^
a.cc:39:18: error: invalid types 'int[int]' for array subscript
   39 |             if(s2[i]==s1[j])
      |                  ^
a.cc:39:25: error: invalid types 'int[int]' for array subscript
   39 |             if(s2[i]==s1[j])
      |                         ^
a.cc:44:22: error: 'max' was not declared in this scope; did you mean 'std::max'?
   44 |             dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
      |                      ^~~
      |                      std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/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: In function 'int main()':
a.cc:51:3: error: 'string' was not declared in this scope
   51 |   string s,t;
      |   ^~~~~~
a.cc:51:3: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/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:52:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   52 |   cin>>s>>t;
      |   ^~~
      |   std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:52:8: error: 's' was not declared in this scope
   52 |   cin>>s>>t;
      |        ^
a.cc:52:11: error: 't' was not declared in this scope; did you mean 'tm'?
   52 |   cin>>s>>t;
      |           ^
      |           tm
a.cc:53:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   53 |   cout<<lcs(s.length(),t.length(),s,t);
      |   ^~~~
      |   std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~