↵
↵
<spoiler summary="A">↵
print `7 - a + 7 - b + 7 - c` because the sum of the numbers on opposite faces is 7.↵
</spoiler>↵
↵
<spoiler summary="B">↵
Reverse the string & replace `6 with 9` and `9 with 6`.↵
</spoiler>↵
↵
<spoiler summary="C">↵
For all `b[i]`, find how many values are there in `C` with value `i`. Then for every `a[i]`, just add those values you have computed before.↵
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22804387)↵
</spoiler>↵
↵
<spoiler summary="D">↵
I solved this in python to avoid any overflow issues. The idea is for each index starting from `0` to `len(a + b) - 1`, you try to see if it's possible to put `b` here. How to check that? You need to find how many ways are there if we put `a` at current index which will be `choose(a + b - 1, a - 1)` and if this value exceeds `k` then we put `b`(also subtract this value from `k`) else put `a`.↵
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22823749)↵
</spoiler>↵
↵
<spoiler summary="E">↵
In thisyourwe are given a tree and for given queries, we are required to find how many nodes are under subtree `u` with distance `d` from root. ↵
↵
First we will need euler tour to define which nodes are under any subtree. While doing euler tour, keep track of at what depth we have which nodes. While querying, you(their start time). Then for each query you need to find how many values are there in range `start_time[u]` to `end_time[u]` with value `d`. So we can use binary search in the above depth vector atbove at given depth `d` to find how many nodes are at depth `d` from rootvalues it has from `start_time[u]` to `end_time[u]`.↵
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22827823)↵
</spoiler>↵
↵
↵
<spoiler summary="A">↵
print `7 - a + 7 - b + 7 - c` because the sum of the numbers on opposite faces is 7.↵
</spoiler>↵
↵
<spoiler summary="B">↵
Reverse the string & replace `6 with 9` and `9 with 6`.↵
</spoiler>↵
↵
<spoiler summary="C">↵
For all `b[i]`, find how many values are there in `C` with value `i`. Then for every `a[i]`, just add those values you have computed before.↵
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22804387)↵
</spoiler>↵
↵
<spoiler summary="D">↵
I solved this in python to avoid any overflow issues. The idea is for each index starting from `0` to `len(a + b) - 1`, you try to see if it's possible to put `b` here. How to check that? You need to find how many ways are there if we put `a` at current index which will be `choose(a + b - 1, a - 1)` and if this value exceeds `k` then we put `b`(also subtract this value from `k`) else put `a`.↵
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22823749)↵
</spoiler>↵
↵
<spoiler summary="E">↵
In this
↵
First we will need euler tour to define which nodes are under any subtree. While doing euler tour, keep track of at what depth we have which nodes
↵
[Code](https://atcoder.jp/contests/abc202/submissions/22827823)↵
</spoiler>↵
↵