Compare https://www.acmicpc.net/problem/23679 and https://mirror.codeforces.com/contest/1710/problem/E, and you can find that there are crazy similarities in all of the legend, the input, the output, and the sample. Can the authors Rhodoks and zxyoi explain it?