func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   ostream& operator<<(ostream& os, const pair<A, B>& x) {     return os <<  (  << x.first <<  ,  << x.second <<  ) ;   }   vector<int> E[505][505];   long long dp[505][505], W[505][505];   vector<pair<int, int>> verts[505][505], hors[505][505];   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     vector<int> C(k);     for (int i = 0; i < k; ++i) {       int r, c, d, t;       scanf( %d%d%d%d%d , &r, &c, &d, &t, &C[i]);       vector<bool> has(4);       if (r + c >= t && (r + c - t) % 4 == 0) has[0] = true;       if (r + c >= t && (r + c - t) % 4 == 1) has[1] = true;       if (r + c + d >= t && (r + c + d - t) % 4 == 2) has[2] = true;       if (r + c + d >= t && (r + c + d - t) % 4 == 3) has[3] = true;       int tot = has[0] + has[1] + has[2] + has[3];       assert(tot <= 2);       if (!tot) continue;       if (has[0] && has[2])         verts[r][c].emplace_back(r + d, C[i]);       else if (has[0] && has[3])         hors[r][c].emplace_back(c + d, C[i]);       else if (has[1] && has[2])         hors[r + d][c - d].emplace_back(c, C[i]);       if (has[0]) W[r][c] += C[i];       if (has[1]) W[r + d][c - d] += C[i];       if (has[2]) W[r + d][c] += C[i];       if (has[3]) W[r][c + d] += C[i];     }     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         if (!i && !j) continue;         long long val = LLONG_MAX;         long long cost = 0;         for (int k = j; k >= 0; --k) {           cost += W[i][k];           for (auto& x : hors[i][k]) {             if (x.first <= j) cost -= x.second;           }           if (k < j) val = min(val, dp[i][k] + cost - W[i][k]);         }         cost = 0;         for (int k = i; k >= 0; --k) {           cost += W[k][j];           for (auto& x : verts[k][j]) {             if (x.first <= i) cost -= x.second;           }           if (k < i) val = min(val, dp[k][j] + cost - W[k][j]);         }         dp[i][j] = val;       }     printf( %lld n , dp[n - 1][m - 1]);   }   