For this Question: Given a matrix of N * M. Find the maximum path sum in matrix. The maximum path sum is sum of path elements from first row to last row where you are allowed to move only down(from (i,j) to (i+1,j)) or diagonally to left(from (i,j) to (i+1,j-1)) or right(from (i,j) to (i+1,j+1)). You can start from any element in first row. You can finish on any element of the last row.First line contains T, the number of test case.
For each test case you will be given two integers, N and M, denoting dimensions of the matrix
Each of the next N lines contains M integers, A[i][j] denoting the value of element at cell (i, j) of the matrix.
1 <= T <= 100
1 <= N, M <= 100
1 <= A[i][j] <= 1000For each test case, print a single line containing the maximum path sum as described in the problem statementSample input 1:
2
1 2
4 8 
4 3
1 8 5 
5 3 4 
6 2 3 
4 1 7 

Sample Output 1:
8
23

Explanation:
For 2nd test case, max path sum is of the following path: (1, 2) -> (2, 1) -> (3, 1) -> (4, 1), I have written this Solution Code: #include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 500 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18 + 9;

int a[N], dp[N][N];

void solve(){
	int n, m, ans = 0;	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			int p;	cin >> p;
			dp[i][j] = p + max({dp[i-1][j-1], dp[i-1][j], dp[i-1][j+1]});
			if(i == n)
				ans = max(ans, dp[i][j]);
		}
	}
	cout << ans << endl;
}

void testcases(){
	int tt = 1; 
	cin >> tt;
	while(tt--){
		solve();
	}
}

signed main() {
	IOS;
		clock_t start = clock();
	
	testcases();

	cerr << (double)(clock() - start)*1000/CLOCKS_PER_SEC << " ms" << endl;
	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?