Codeforces Round 485 (Div. 1)


A. Fair
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 5 4 3
1 2 4 3 2
1 2
2 3
3 4
4 1
4 5
Output
2 2 2 2 3 
Input
7 6 3 2
1 2 3 3 2 2 1
1 2
2 3
3 4
2 5
5 6
6 7
Output
1 1 1 2 2 1 1 
----------------------------------------------------------------------------------------------------
B. Petr and Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 4 5 1 3
Output
Petr
----------------------------------------------------------------------------------------------------
C. AND Graph
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1 2 3
Output
2
Input
5 5
5 19 10 20 12
Output
2
----------------------------------------------------------------------------------------------------
D. Perfect Encoding
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
36
Output
10
Input
37
Output
11
Input
12345678901234567890123456789
Output
177
----------------------------------------------------------------------------------------------------
E. Prince's Problem
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
1 3
1 4
6 4 9 5
3
2 3 6
2 3 2
3 4 7
Output
36
4
1
Input
6
1 2
2 3
2 4
1 5
5 6
100000 200000 500000 40000 800000 250000
3
3 5 10000000
6 2 3500000
4 1 64000
Output
196000
12250
999998215
----------------------------------------------------------------------------------------------------
F. Oppa Funcan Style Remastered
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 7
3 8
5 6
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
