Digit DP
Typical state: position, tight bound, leading-zero state, and the problem-specific state.
See Counting Numbers for a complete template and implementation.
Balanced Digit Sums
https://leetcode.com/problems/number-of-balanced-integers-in-a-range/description/
The only optim is to use the offset trick and reduce state to even - odd
- Impl trick, use offset like this, you only need to translate on array access
int& mem = dp[pos][ti][lz][sum+off];
if(mem != -1) return mem;