Iterative dp/ Reccursive dp/ memoization/ Clean code 
For this we can use either Reccurision with memoization or iterative dp
We Have a 3 state dp/cache
[x][y][k]
x = i y = j and k = the robbers we can dodge from i

For this we can use either Reccurision with memoization or iterative dp

- We Have a 3 state dp/cache
- `[x][y][k]`
- x = i y = j and k = the robbers we can dodge from `i, j -> n - 1, m - 1`
Reccursive code: 
```
class Solution {
private:
    int cache[501][501][3];
    int f(vector<vector<int>>& coins, int i, int j, int neu){
        int n = coins.size();
        int m = coins[0].size();
        if(i == n - 1 && j == m - 1){
            if(neu > 0 && coins[i][j] < 0){
                return 0;
            }else{
                return coins[i][j];
            }
        }
        if(i >= n || j>= m){
            return INT_MIN;
        }
        if (cache[i][j][neu] != INT_MIN) {
            return cache[i][j][neu];
        }
        int take = INT_MIN;int nottake = INT_MIN;
        take = coins[i][j] + max(f(coins, i + 1, j, neu), f(coins, i, j + 1, neu));
        if(neu > 0 && coins[i][j] < 0)
            nottake =  max(f(coins, i + 1, j, neu - 1), f(coins, i, j + 1, neu - 1));
        return cache[i][j][neu] = max(take, nottake);
    }
public:
    int maximumAmount(vector<vector<int>>& coins) {
    for (int i = 0; i < 501; ++i)
        for (int j = 0; j < 501; ++j)
            for (int k = 0; k < 3; ++k)
                cache[i][j][k] = INT_MIN;
        return f(coins, 0, 0, 2);
    }
};
```
Iterative:
```
class Solution {
public:
    int maximumAmount(vector<vector<int>>& coins) {
        int m=coins.size();
        int n=coins[0].size();
        vector<vector<vector<int>>> dp(m, vector<vector<int>>(n, vector<int>(3, INT_MIN)));


        
        dp[0][0][0]=coins[0][0];
        if (coins[0][0]<0) {
            dp[0][0][1]=0; 
            dp[0][0][2]=0;
        } else {
            dp[0][0][1]=dp[0][0][2]=coins[0][0];
        }


        for (int i=0; i<m; ++i) {
            for (int j=0; j<n; ++j) {
                // if(k==2) break;
                for (int k=0; k<3; ++k) {
                    if (i==0 && j==0) continue; 
                    // int coins[i][j]=coins[i][j];

                        // cout<<dp[i][j][k];
                        // cout<<coins[i][j];
                    
                    if (i>0) {
                        dp[i][j][k]=max(dp[i][j][k], dp[i-1][j][k]+coins[i][j]);
                        if (coins[i][j]<0 && k>0) {
                            dp[i][j][k]=max(dp[i][j][k],dp[i-1][j][k-1]); 
                            
                        // cout<<dp[i][j][k];
                        }
                    }

                    if (j>0) {
                        // cout<<dp[i][j][k];
                        dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k]+coins[i][j]);
                        if (coins[i][j]<0 && k>0)
                        {
                            dp[i][j][k]=max(dp[i][j][k], dp[i][j-1][k-1]); 
                        
                        }
                    }
                }
            }
        }
        // cout<<dp[n-1][m-1];
        return max({dp[m-1][n-1][0], dp[m-1][n-1][1], dp[m-1][n-1][2]});
    }
};
```
Credits for iterative solution : Het_modi_25

['Dynamic Programming', 'Memoization', 'C++']