Compatible Numbers
HardRating 2200CodeforcesAdvanced DP (Bitmask, Digit, Interval)
Approach hintTry it first, then revealHide
A compatible partner of x is any element that is a submask of the complement of x. Use sum over subsets DP to store, for every mask, some array element contained in it, over the 22-bit universe in O(22 * 2^22).