参考 lc62

let str;
while (str = readline()) {
//   let n = parseInt(str.split(" ")[0])
//   let m = parseInt(str.split(" ")[1])
  let [n, m] = str.split(" ").map(el => parseInt(el) + 1) // 这里的 m, n 需要 + 1
  let dp = new Array(m);
  for (let i = 0; i < n; i++) {
    dp[i] = new Array(n);
    dp[i][0] = 1;
  }
  for (let i = 0; i < m; i++) {
    dp[0][i] = 1;
  }
  for (let i = 1; i < n; i++) {
    for (let j = 1; j < m; j++) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
    }
  }
  print(dp[n - 1][m - 1]);
}