INTEST : Getting RTE, what should I do?

It’s not working… what wrong did i do???

#include
#include<stdio.h>
#define MAX 1000000000 // Is this where I did the mistake?
using namespace std;
char t[MAX];

int modd(char t[],unsigned long d)
{
unsigned long temp=0;
int i=0;
while(t[i])
{
temp = temp*10 + (t[i] -48);
if(temp>=d)
temp = temp % d;
i++;
}
return temp;
}

int main()
{
unsigned long k,n,count =0,r;
std::cin>>n>>k;

for(long int i=0;i<=n;i++)
{
    gets(t);
    r = modd(t,k);
    if(r==0)
       {
           count++;
           //cout<<"Woah";
       }
}
std::cout<<count-1;

return 0;

}