Language: Java

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int r, c, k;
    cin >> r >> c >> k;
    vvl g(r, vl(c, 0));
    int y, x;
    ll v;
    REP(i, k) {
        cin >> y >> x >> v;
        y--;
        x--;
        g[y][x] = v;
    }
    vvl dp(r, vl(c));
    function<ll(int, int, int)> rec = [&](int h, int w, int t) {
        if (h == r - 1 and w == c - 1) return x;
        if (h + 1 < r) {
            if (chmax(dp[h + 1][w], dp[h][w])) rec(h + 1, w, 0);
            if (g[h + 1][w] > 0) if (chmax(dp[h + 1][w], dp[h][w] + g[h + 1][w])) rec(h + 1, w, 1);
        }
        if (w + 1 < c) {
            if (chmax(dp[h][w + 1], dp[h][w])) rec(h, w + 1, 0);
            if (g[h][w + 1] > 0) if (chmax(dp[h][w + 1], dp[h][w] + g[h][w + 1])) rec(h, w + 1, 1);
        }
    };
    rec(0, 0, 0);
    cout << dp[r - 1][c - 1] << endl;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
using ll = long long;
^
  (use --enable-preview to enable unnamed classes)
Main.java:4: error: '.class' expected
using ll = long long;
                ^
Main.java:5: error: '.class' expected
using ld = long double;
                ^
Main.java:6: error: '.class' expected
using vi = vector<int>;
                     ^
Main.java:6: error: illegal start of expression
using vi = vector<int>;
                      ^
Main.java:7: error: '.class' expected
using vvi = vector<vector<int>>;
                             ^
Main.java:7: error: illegal start of expression
using vvi = vector<vector<int>>;
                               ^
Main.java:8: error: '.class' expected
using vvvi = vector<vector<vector<int>>>;
                                     ^
Main.java:8: error: illegal start of expression
using vvvi = vector<vector<vector<int>>>;
                                        ^
Main.java:9: error: illegal start of expression
using vl = vector<ll>;
                     ^
Main.java:10: error: illegal start of expression
using vvl = vector<vector<ll>>;
                              ^
Main.java:11: error: illegal start of expression
using vvvl = vector<vector<vector<ll>>>;
                                       ^
Main.java:12: error: illegal start of expression
using vs = vector<string>;
                         ^
Main.java:14: error: illegal character: '#'
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
^
Main.java:14: error: class, interface, enum, or record expected
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
        ^
Main.java:14: error: class, interface, enum, or record expected
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
                                       ^
Main.java:14: error: class, interface, enum, or record expected
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
                                                ^
Main.java:15: error: illegal character: '#'
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
^
Main.java:15: error: class, interface, enum, or record expected
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
                                        ^
Main.java:15: error: class, interface, enum, or record expected
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
                                                  ^
Main.java:16: error: illegal character: '#'
#define REP(i, n) FOR(i, 0, (n))
^
Main.java:17: error: illegal character: '#'
#define REPR(i, n) FORR(i, (n) - 1, 0)
^
Main.java:18: error: illegal character: '#'
#define REP1(i, n) FOR(i, 1, (n) + 1)
^
Main.java:19: error: illegal character: '#'
#define REPS(c, s) for (char c : s)
^
Main.java:20: error: illegal character: '#'
#define ALL(c) (c).begin(), (c).end()
^
Main.java:21: error: illegal character: '#'
#define SORT(c) sort(ALL(c))
^
Main.java:22: error: illegal character: '#'
#define REV(c) reverse(ALL(c))
^
Main.java:23: error: illegal character: '#'
#define sz(v) (int)v.size()
^
Main.java:24: error: illegal character: '#'
#define endl '\n'
^
Main.java:25: error: '{' expected
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
                ^
Main.java:25: error: illegal start of type
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
                                                ^
Main.java:25: error: <identifier> expected
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
                                                     ^
Main.java:25: error: <identifier> expected
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
                                                         ^
Main.java:25: error: illegal start of type
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
                                                                                 ^
Main.java:26: error: class, interface, enum, or record expected
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
^
Main.java:26: error: '{' expected
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
                ^
Main.java:26: error: illegal start of type
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
                                                ^
Main.java:26: error: > or ',' expected
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
                                                         ^
Main.java:26: error: illegal start of type
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
                                                                                 ^
Main.java:27: error: class, interface, enum, or record expected
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
^
Main.java:27: error: '{' expected
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
                ^
Main.java:27: error: not a statement
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
                                                                                       ^
Main.java:27: error: <identifier> expected
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
                                           ^
Main.java:27: error: ';' expected
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
                                                                         ^
Main.java:28: error: class, interface, enum, or record expected
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
^
Main.java:28: error: '{' expected
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
                ^
Main.java:28: error: not a statement
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
                                                                                          ^
Main.java:28: error: <identifier> expected
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
                                              ^
Main.java:28: error: ';' expected
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
                                                                            ^
Main.java:29: error: class, interface, enum, or record expected
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
^
Main.java:29: error: '{' expected
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
                ^
Main.java:29: error: <identifier> expected
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
                                                       ^
Main.java:30: error: class, interface, enum, or record expected
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
^
Main.java:30: error: '{' expected
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
                ^
Main.java:30: error: not a statement
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
                                                                                            ^
Main.java:30: error: <identifier> expected
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
                                                ^
Main.java:30: error: ';' expected
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
                                                                              ^
Main.java:31: error: class, interface, enum, or record expected
const int MOD = 1000000007;
^
Main.java:32: error: class, interface, enum, or record expected
const int INF = 1000000001;
^
Main.java:33: error: class, interface, enum, or record expected
const ll LINF = 1000000001000000001LL;
^
Main.java:38: error: not a statement
    ios::sync_with_stdio(false);
    ^
Main.java:40: error: not a statement
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
                  ^
Main.java:38: error: ';' expected
    ios::sync_with_stdio(false);
                        ^
Main.java:47: error: not a statement
    cin >> r >> c >> k;
                  ^
Main.java:48: error: not a statement
    vvl g(r, vl(c, 0));
          ^
Main.java:52: error: not a statement
        cin >> y >> x >> v;
                      ^
Main.java:57: error: not a statement
    vvl dp(r, vl(c));
           ^
Main.java:58: error: not a statement
    function<ll(int, int, int)> rec = [&](int h, int w, int t) {
            ^
Main.java:58: error: not a statement
    function<ll(int, int, int)> rec = [&](int h, int w, int t) {
                ^
Main.java:58: error: not a statement
    function<ll(int, int, int)> rec = [&](int h, int w, int t) {
                     ^
Main.java:58: error: not a statement
    function<ll(int, int, int)> rec = [&](int h, int w, int t) {
                          ^
Main.java:59: error: variable declaration not allowed here
        if (h == r - 1 and w == c - 1) return x;
                           ^
Main.java:59: error: not a statement
        if (h == r - 1 and w == c - 1) return x;
                                  ^
Main.java:70: error: n