#include #include #include #include #include #include #include void initialize(char* s) { } int answerQuery(int l, int r,char* s) { char* s1 = (char *)malloc(512000 * sizeof(char)); int count=0,n,max; for(int i=l;i=0;m--) { s2[f]=s1[m]; f++; } if(strcmp(s1,s2)==0) { n=strlen(s1); if(n==max) count++; if(n>max) { max=n; count=1; } } } } return count; } int main() { char* s = (char *)malloc(512000 * sizeof(char)); scanf("%s", s); initialize(s); int q; scanf("%i", &q); for(int a0 = 0; a0 < q; a0++){ int l; int r; scanf("%i %i", &l, &r); int result = answerQuery(l, r,s); printf("%d\n", result); } return 0; }