Why am I getting wrong answer for this IARCS Archive problem?

,

For this problem http://opc.iarcs.org.in/index.php/problems/01TILES , I am getting fatal error for c++ code. so I tried with c code:


    #include<stdio.h>
    #include<stdlib.h>
    int getVal(unsigned long);
    int getVal(unsigned long n)
    {
    	unsigned long *vals, i, val;
    	vals=( long * )malloc(n*sizeof(long));
    	vals[0]=1;
    	vals[1]=2;
    	for(i=2;i<n;++i)
    		vals[i]=vals[i-1]+vals[i-2];
    	val=vals[n-1];
    	free(vals);
    	return val;
    }    
    int main()
    {    	
    	unsigned long int n;
    	scanf("%lu", &n);
    	printf("%lu\n", (getVal(n))%15746);
    	return 0;
    }
    


I am getting wrong answer for every test case. What is my mistake?