Good Bye 2017


A. New Year and Counting Cards
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ee
Output
2
Input
z
Output
0
Input
0ay1
Output
2
----------------------------------------------------------------------------------------------------
B. New Year and Buggy Bot
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
.....#
S....#
.#....
.#....
...E..
333300012
Output
1
Input
6 6
......
......
..SE..
......
......
......
01232123212302123021
Output
14
Input
5 3
...
.S.
###
.E.
...
3
Output
0
----------------------------------------------------------------------------------------------------
C. New Year and Curling
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 2
5 5 6 8 3 12
Output
2 6.0 9.87298334621 13.3370849613 12.5187346573 13.3370849613
----------------------------------------------------------------------------------------------------
D. New Year and Arbitrary Arrangement
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 1
Output
2
Input
3 1 4
Output
370000006
----------------------------------------------------------------------------------------------------
E. New Year and Entity Enumeration
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
11010
00101
11000
Output
4
Input
30 2
010101010101010010101010101010
110110110110110011011011011011
Output
860616440
----------------------------------------------------------------------------------------------------
F. New Year and Rainbow Roads
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 G
5 R
10 B
15 G
Output
23
Input
4
1 G
2 R
3 B
10 G
Output
12
----------------------------------------------------------------------------------------------------
G. New Year and Original Order
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
21
Output
195
Input
345342
Output
390548434
----------------------------------------------------------------------------------------------------
H. New Year and Boolean Bridges
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
-AAA
A-AA
AA-A
AAA-
Output
4
Input
3
-XX
X-X
XX-
Output
2
----------------------------------------------------------------------------------------------------
