Codeforces Round 774 (Div. 2)


A. Square Counting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7 0
1 1
2 12
3 12
Output
0
1
3
1
----------------------------------------------------------------------------------------------------
B. Quality vs Quantity
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 3
5
2 8 6 3 1
4
3 5 4 2
5
1000000000 1000000000 1000000000 1000000000 1000000000
Output
NO
YES
NO
NO
----------------------------------------------------------------------------------------------------
C. Factorials and Powers of Two
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7
11
240
17179869184
Output
2
3
4
1
----------------------------------------------------------------------------------------------------
D. Weight the Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
2 3
2 4
Output
3 4
1 1 1 1 
Input
3
1 2
1 3
Output
2 3
1 1 1 
Input
2
1 2
Output
2 2
1 1
Input
9
3 4
7 6
2 1
8 3
5 6
1 8
8 6
9 6
Output
6 11
1 1 1 1 1 1 1 3 1 
----------------------------------------------------------------------------------------------------
E. Power Board
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
Output
7
Input
2 4
Output
5
Input
4 2
Output
6
----------------------------------------------------------------------------------------------------
F. Playing Around the Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
1 2
Output
1
2 1 
Input
3
1 1 1
2 2 2
3 3 3
Output
6
1 2 3
3 1 2
2 3 1
1 2 3
3 1 2
2 3 1
----------------------------------------------------------------------------------------------------
