Codeforces Round 297 (Div. 2)


A. Vitaliy and Pie
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
aAbB
Output
0
Input
4
aBaCaB
Output
3
Input
5
xYyXzZaZ
Output
2
----------------------------------------------------------------------------------------------------
B. Pasha and String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abcdef
1
2
Output
aedcbf
Input
vwxyz
2
2 2
Output
vwxyz
Input
abcdef
3
1 2 3
Output
fbdcea
----------------------------------------------------------------------------------------------------
C. Ilya and Sticks
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2 4 4 2
Output
8
Input
4
2 2 3 5
Output
0
Input
4
100003 100004 100005 100006
Output
10000800015
----------------------------------------------------------------------------------------------------
D. Arthur and Walls
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 5
.*.*.
*****
.*.*.
*****
.*.*.
Output
.*.*.
*****
.*.*.
*****
.*.*.
Input
6 7
***.*.*
..*.*.*
*.*.*.*
*.*.*.*
..*...*
*******
Output
***...*
..*...*
..*...*
..*...*
..*...*
*******
Input
4 5
.....
.....
..***
..*..
Output
.....
.....
.....
.....
----------------------------------------------------------------------------------------------------
E. Anya and Cubes
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 30
4 3
Output
1
Input
2 2 7
4 3
Output
1
Input
3 1 1
1 1 1
Output
6
----------------------------------------------------------------------------------------------------
