Good Bye 2020


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

Examples
Input
8
4
1 2 4 5
3
1 3 5
3
2 6 8
2
1 2
1
50
5
3 4 5 6 8
3
1 25 26
6
1 2 4 8 16 32
Output
4
2
3
1
0
5
3
15
----------------------------------------------------------------------------------------------------
B. Last minute enhancements
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
6
1 2 2 2 5 6
2
4 4
6
1 1 3 4 4 5
1
1
6
1 1 1 2 2 2
Output
5
2
6
1
3
----------------------------------------------------------------------------------------------------
C. Canine poetry
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
babba
abaac
codeforces
zeroorez
abcdcba
bbbbbbb
a
Output
1
1
0
1
1
4
0
----------------------------------------------------------------------------------------------------
D. 13th Labour of Heracles
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
3 5 4 6
2 1
3 1
4 3
2
21 32
2 1
6
20 13 17 13 13 11
2 1
3 1
4 1
5 1
6 1
4
10 6 6 6
1 2
2 3
4 1
Output
18 22 25
53
87 107 127 147 167
28 38 44
----------------------------------------------------------------------------------------------------
E. Apollo versus Pan
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2
1 7
3
1 2 4
4
5 5 5 5
5
6 2 2 1 0
1
0
1
1
6
1 12 123 1234 12345 123456
5
536870912 536870911 1152921504606846975 1152921504606846974 1152921504606846973
Output
128
91
1600
505
0
1
502811676
264880351
----------------------------------------------------------------------------------------------------
F. Euclid's nightmare
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 1
1 2
2 2 1
Output
4 2
1 2 
Input
2 3
2 1 3
2 1 2
Output
4 2
1 2 
Input
3 5
2 1 2
1 3
1 4
Output
8 3
1 2 3 
----------------------------------------------------------------------------------------------------
G. Song of the Sirens
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
aa
bcd
2 aba
3 ca
3 aa
Output
2
2
8
Input
4 5
aba
bbac
1 a
3 baca
3 ab
2 bab
4 aba
Output
4
0
14
6
28
----------------------------------------------------------------------------------------------------
H. Finding satisfactory solutions
time limit per test: 5 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1
Output
1
Input
3
1 2 3
Output
98
Input
4
2 1 3 4
Output
27408
----------------------------------------------------------------------------------------------------
I. The Riddle of the Sphinx
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
yes
no
no
no
no
yes
Output
5 101
5 110
4 100
3 101
2 001
1 000
0 110
Input
4 3
no
no
no
no
Output
1 000
2 000
3 000
4 000
0 000
Input
1 1
Output
0 0
----------------------------------------------------------------------------------------------------
