pat乙级1040发生运行时错误

pat给出的解释是c语言数组越界或python抛出异常,可我每个索引变量都小于数组长度啊,不懂
01测试点过了,234测试点发生运行时错误,求解


```c
#include<stdio.h>
#include<string.h>
int main()
{
    char str[10001];
    gets(str);
    int len=strlen(str);
    long sum=0;
    for(int i=0;i<len;i++)
    {
        if(str[i]=='A')
        {
            int cp=0,ct=0;
            for(int j=0;j<i;j++)
                if(str[j]=='P')
                    cp++;
            for(int j=i+1;j<len;j++)
                if(str[j]=='T')
                    ct++;
            sum+=cp*ct;
        }    
    }
    printf("%ld\n",sum%1000000007);
    return 0;   
        
}


题目是啥啊

供参考:https://blog.csdn.net/qq_42865772/article/details/105896015