you should do modulo 20011 both in arr[i][j] = (arr[i-1][j] + arr[i][j-1] ) % 20011;
and when you return the final value : return arr[R-1][C-1] % 20011;
you should do modulo 20011 both in arr[i][j] = (arr[i-1][j] + arr[i][j-1] ) % 20011;
and when you return the final value : return arr[R-1][C-1] % 20011;