Sum of Binom(A, B)

AtCoder
IDabc432_g
Time2000ms
Memory256MB
Difficulty
You are given a sequence of positive integers $A=(A_1,A_2,\dots,A_N)$ of length $N$ and a sequence of positive integers $B=(B_1,B_2,\dots,B_M)$ of length $M$. Find the value of $\displaystyle \sum_{i=1}^{N} \sum_{j=1}^{M} \binom{A_i}{B_j}$, modulo $998244353$. Here, $\displaystyle \binom{x}{y}$ represents the number of ways to choose $y$ objects from $x$ objects (binomial coefficient), and particularly, it is $0$ if $x < y$. ## Constraints * $1\leq N,M \leq 5\times 10^5$ * $1\leq A_i,B_j \leq 5\times 10^5$ * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $A_1$ $A_2$ $\dots$ $A_N$ $B_1$ $B_2$ $\dots$ $B_M$ [samples]
Samples
Input #1
3 2
2 5 4
1 3
Output #1
25

The answer is $\displaystyle \binom{2}{1}+\binom{2}{3}+\binom{5}{1}+\binom{5}{3}+\binom{4}{1}+\binom{4}{3}=2+0+5+10+4+4=25$.
Input #2
4 4
2 5 1 5
2 1 2 4
Output #2
65
Input #3
6 8
203497 47202 407775 394325 463982 304784
468417 302156 131932 235902 395728 78537 223857 330739
Output #3
602855848
API Response (JSON)
{
  "problem": {
    "name": "Sum of Binom(A, B)",
    "description": {
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\dots,A_N)$ of length $N$ and a sequence of positive integers $B=(B_1,B_2,\\dots,B_M)$ of length $M$. Find the value of $\\displaystyle \\sum_{i=",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc432_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a sequence of positive integers $A=(A_1,A_2,\\dots,A_N)$ of length $N$ and a sequence of positive integers $B=(B_1,B_2,\\dots,B_M)$ of length $M$.\nFind the value of $\\displaystyle \\sum_{i=...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments