Language: Java

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> MakeVector2D(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<class T> inline bool UpdateMin(T& a, T b) {
  if (a > b) { a = b; return 1; } return 0;
}

template<class T> inline bool UpdateMax(T& a, T b) {
  if (a < b) { a = b; return 1; } return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, k;
  vector<int> scores(3);
  cin >> n >> k >> scores[0] >> scores[1] >> scores[2];

  string t;
  cin >> t;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    if (t[i] == 'r') {
      xs[i] = 2;
    } else if (t[i] == 's') {
      xs[i] = 0;
    } else {
      xs[i] = 1;
    }
  }

  vector<vector<int>> mod_xs(k);
  for (int i = 0; i < n; i++) {
    mod_xs[i % k].push_back(xs[i]);
  }

  int ans = 0;
  for (int mod = 0; mod < k; mod++) {
    const vector<int>& ys = mod_xs[mod];
    int m = ys.size();
    vector<vector<int>> dp = MakeVector2D(m + 1, 3, 0);
    for (int i = 0; i < m; i++) {
      for (int j1 = 0; j1 < 3; j1++) {
        for (int j2 = 0; j2 < 3; j2++) {
          if (j1 == j2) continue;
          int d = 0;
          if (j2 == ys[i]) d = scores[j2];
          UpdateMax(dp[i + 1][j2], dp[i][j1] + d);
        }
      }
    }
    ans += max(dp[m][0], max(dp[m][1], dp[m][2]));
  }

  cout << ans << 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 int64 = long long;
^
  (use --enable-preview to enable unnamed classes)
Main.java:4: error: '.class' expected
using int64 = long long;
                   ^
Main.java:6: error: class, interface, enum, or record expected
constexpr int DEBUG = 0;
^
Main.java:8: error: class, interface, enum, or record expected
template<typename T>
^
Main.java:11: error: class, interface, enum, or record expected
}
^
Main.java:13: error: '{' expected
template<class T> inline bool UpdateMin(T& a, T b) {
                ^
Main.java:14: error: illegal start of type
  if (a > b) { a = b; return 1; } return 0;
  ^
Main.java:14: error: <identifier> expected
  if (a > b) { a = b; return 1; } return 0;
       ^
Main.java:14: error: <identifier> expected
  if (a > b) { a = b; return 1; } return 0;
           ^
Main.java:14: error: illegal start of type
  if (a > b) { a = b; return 1; } return 0;
                                  ^
Main.java:17: error: class, interface, enum, or record expected
template<class T> inline bool UpdateMax(T& a, T b) {
^
Main.java:17: error: '{' expected
template<class T> inline bool UpdateMax(T& a, T b) {
                ^
Main.java:18: error: illegal start of type
  if (a < b) { a = b; return 1; } return 0;
  ^
Main.java:18: error: > or ',' expected
  if (a < b) { a = b; return 1; } return 0;
           ^
Main.java:18: error: illegal start of type
  if (a < b) { a = b; return 1; } return 0;
                                  ^
Main.java:22: error: not a statement
  ios::sync_with_stdio(false);
  ^
Main.java:27: error: not a statement
  cin >> n >> k >> scores[0] >> scores[1] >> scores[2];
                                          ^
Main.java:30: error: not a statement
  cin >> t;
      ^
Main.java:31: error: not a statement
  vector<int> xs(n);
                 ^
Main.java:42: error: not a statement
  vector<vector<int>> mod_xs(k);
                             ^
Main.java:49: error: not a statement
    const vector<int>& ys = mod_xs[mod];
                ^
Main.java:65: error: not a statement
  cout << ans << endl;
              ^
Main.java:22: error: ';' expected
  ios::sync_with_stdio(false);
                      ^
Main.java:26: error: ';' expected
  vector<int> scores(3);
                    ^
Main.java:31: error: ';' expected
  vector<int> xs(n);
                ^
Main.java:31: error: ';' expected
  vector<int> xs(n);
                  ^
Main.java:42: error: ';' expected
  vector<vector<int>> mod_xs(k);
                            ^
Main.java:42: error: ';' expected
  vector<vector<int>> mod_xs(k);
                              ^
Main.java:49: error: illegal start of expression
    const vector<int>& ys = mod_xs[mod];
    ^
Main.java:49: error: ';' expected
    const vector<int>& ys = mod_xs[mod];
                     ^
32 errors