wel again xD kindly , can someone help me figure out where my logic fails ?

#include <iostream>

#include<algorithm>

using namespace std;

int memo[300][300];

int themap[300][300];

int c, r;

int d;

long long path(int i, int j,int n1,int n2) {

if (i == 0 && j == 0)

return 1;