Hi Codeforces community!
I'm glad to invite you to the online replay of 2019 MIST IUPC, which will be hosted on Codeforces Gym on Sunday, March 17, 2019, 1 PM MSK, and will run for 5 hours. This is an ICPC style contest comprising of 9 problems of varying difficulties.
ICPC style national level contests are frequent in Bangladesh, and they are commonly referred to Inter University Programming Contest (IUPC). From now on, we plan to regularly upload these contests to CF Gym.
MIST IUPC 2019 was organized by Military Institute of Science and Technology. 120 teams participated in the onsite contest, which took place on February 23, 2019.
Bangladesh Association of Problem Setters (BAPS) was in charge of the problem set. Problems were prepared, reviewed, and tested by Shahriar Manzoor, Jami_CSEDU, shovonshovo, shibly, Imran_Bin_Azad, ridowan007, Shafaet, Mehdi Rahman, Rafsan, sgtlaugh, bhadra, flash_7, Z0RR0, and prophet_ov_darkness.
GLHF.
UPD 1: The contest was over a couple of hours ago. We are currently working on an editorial. We will share it as soon as it is ready.
UPD 2: Here is the editorial.










. Simply iterate over all the bottles and add the amount of liquid spilled to the answer.
. Now if you take the highest end of your binary search range too large, then you will get TLE as you can see the range you take has direct effect on the complexity. You can do some calculation to find that answer can never be more than around 



. If we are certain that at least one number with parity
segment tree query on the range specified by the left interval), we go to the left child, otherwise to the right. Once we reach a leaf of a tree, the array element represented by it is the answer to the query.
optimized brute force solution to this problem. Here we'll fix a subroot in linear time. Then from each of those subroots we'll run DFS in the corresponding subtree. For each edge in a subtree, we'll count the number of times it appears in all possible simple paths present in that subtree. Let's take an edge
with 
