Codeforces Round 476 (Div. 2) [Thanks, Telegram!]


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

Examples
Input
5 3 2 3
Output
4
Input
5 3 100 1
Output
5
----------------------------------------------------------------------------------------------------
B. Battleship
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
#..#
#.#.
....
.###
Output
3 2
Input
10 4
#....##...
.#...#....
..#..#..#.
...#.#....
.#..##.#..
.....#...#
...#.##...
.#...#.#..
.....#..#.
...#.#...#
Output
6 1
Input
19 6
##..............###
#......#####.....##
.....#########.....
....###########....
...#############...
..###############..
.#################.
.#################.
.#################.
.#################.
#####....##....####
####............###
####............###
#####...####...####
.#####..####..#####
...###........###..
....###########....
.........##........
#.................#
Output
1 8
----------------------------------------------------------------------------------------------------
C. Greedy Arkady
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
20 4 5 2
Output
8
Input
30 9 4 1
Output
4
----------------------------------------------------------------------------------------------------
D. Single-use Stones
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 5
0 0 1 0 2 0 0 1 0
Output
3
Input
10 3
1 1 1 1 2 1 1 1 1
Output
3
----------------------------------------------------------------------------------------------------
E. Short Code
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
codeforces
codehorses
code
Output
6
Input
5
abba
abb
ab
aa
aacada
Output
11
Input
3
telegram
digital
resistance
Output
3
----------------------------------------------------------------------------------------------------
