Codeforces Round 470 (rated, Div. 1, based on VK Cup 2018 Round 1)


A. Primal Sport
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
14
Output
6
Input
20
Output
15
Input
8192
Output
8191
----------------------------------------------------------------------------------------------------
B. Producing Snow
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
10 10 5
5 7 2
Output
5 12 4
Input
5
30 25 20 15 10
9 10 12 4 13
Output
9 20 35 11 25
----------------------------------------------------------------------------------------------------
C. Perfect Security
time limit per test: 3.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
8 4 13
17 2 7
Output
10 3 28
Input
5
12 7 87 22 11
18 39 9 12 16
Output
0 14 69 6 44
Input
10
331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951
226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667
Output
128965467 243912600 4281110 112029883 223689619 76924724 429589 119397893 613490433 362863284
----------------------------------------------------------------------------------------------------
D. Picking Strings
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3
Output
10011
----------------------------------------------------------------------------------------------------
E. Perpetual Subtraction
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
0 0 1
Output
332748118 332748118 332748118
Input
2 2
0 0 1
Output
942786334 610038216 443664157
Input
9 350
3 31 314 3141 31415 314159 3141592 31415926 314159265 649178508
Output
822986014 12998613 84959018 728107923 939229297 935516344 27254497 413831286 583600448 442738326
----------------------------------------------------------------------------------------------------
F. Public Service
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2
2 3
3 4
5 6
6 7
7 8
Output
Yes
6 8 5 7
Input
4
1 2
2 3
3 4
5 6
5 7
5 8
Output
No
Input
7
1 2
1 3
1 4
1 5
5 6
6 7
8 9
9 10
10 11
11 12
12 13
13 14
Output
Yes
9 14 11 12 13 10 8
----------------------------------------------------------------------------------------------------
