#include using namespace std; int CountPS(string str, int n) { // creat empty 2-D matrix that counts all palindrome // substring. dp[i][j] stores counts of palindromic // substrings in st[i..j] int dp[n][n]; memset(dp, 0, sizeof(dp)); // P[i][j] = true if substring str[i..j] is palindrome, // else false bool P[n][n]; memset(P, false , sizeof(P)); // palindrome of single lenght for (int i= 0; i< n; i++) P[i][i] = true; // palindrome of length 2 for (int i=0; i> s; int q; cin>>q; int i,l,r,n; for(i=0;i>l>>r; str=s.substr(l-1,r-1); n=r-l; cout<