Codeforces Round 587 (Div. 3)


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

Examples
Input
4
bbbb
Output
2
abba
Input
6
ababab
Output
0
ababab
Input
2
aa
Output
1
ba
----------------------------------------------------------------------------------------------------
B. Shooting
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
20 10 20
Output
43
1 3 2 
Input
4
10 10 10 10
Output
64
2 1 4 3 
Input
6
5 4 5 4 4 5
Output
69
6 1 3 5 2 4 
Input
2
1 4
Output
3
2 1 
----------------------------------------------------------------------------------------------------
C. White Sheet
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 4 4
1 1 3 5
3 1 5 5
Output
NO
Input
3 3 7 5
0 0 4 6
0 0 7 4
Output
YES
Input
5 2 10 5
3 1 7 6
8 1 11 7
Output
YES
Input
0 0 1000000 1000000
0 0 499999 1000000
500000 0 1000000 1000000
Output
YES
----------------------------------------------------------------------------------------------------
D. Swords
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 12 6
Output
5 3
Input
2
2 9
Output
1 7
Input
7
2 1000000000 4 6 8 4 2
Output
2999999987 2
Input
6
13 52 0 13 26 52
Output
12 13
----------------------------------------------------------------------------------------------------
E1. Numerical Sequence (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
3
20
38
56
Output
1
2
5
2
0
Input
4
2132
506
999999999
1000000000
Output
8
2
9
8
----------------------------------------------------------------------------------------------------
E2. Numerical Sequence (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1
3
20
38
56
Output
1
2
5
2
0
Input
4
2132
506
999999999999999999
1000000000000000000
Output
8
2
4
1
----------------------------------------------------------------------------------------------------
F. Wi-Fi
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
00100
Output
3
Input
6 1
000000
Output
21
Input
4 1
0011
Output
4
Input
12 6
000010000100
Output
15
----------------------------------------------------------------------------------------------------
