Time limit
2000 ms
Memory limit
262144 kB
Source
Codeforces Round #492 (Div. 1) [Thanks, uDebug!]
Tags
combinatorics dp math trees *2700
Editorial
Announcement (en) Tutorial (en)
Descriptions:

Cowmpany Cowmpensation

CodeForces - 995F