text: #include<bits/stdc++.h>
  using namespace std;
  
  int lps(string a){
  	int n = a.length();
  	int dp[n+1][n+1];
  	for(int i=0;i<n+1;i++){
  		for(int j=0;j<n+1;j++){
  			if(i==0 or j==0) dp[i][j] = 0;
  			else if(a[i-1]==a[n-j]) dp[i][j] = dp[i-1][j-1]+1;
  			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
  		}
  	}
  	return dp[n][n];
  }
  
  int main(){
  	string a = "MALAYALAM", b = "abcdeed";
  
  	cout<<lps(a)<<endl;
  	cout<<lps(b)<<endl;
  	
  	return 0;
  }
  