Codeforces Beta Round 94 (Div. 2 Only)


A. Cookies
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
1
Output
1
Input
10
1 2 2 3 4 4 4 2 2 2
Output
8
Input
11
2 2 2 2 2 2 2 2 2 2 99
Output
1
----------------------------------------------------------------------------------------------------
B. Students and Shoelaces
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
.......A
........
........
........
........
........
........
M.......
Output
WIN
Input
.......A
........
........
........
........
........
SS......
M.......
Output
LOSE
Input
.......A
........
........
........
........
.S......
S.......
MS......
Output
LOSE
----------------------------------------------------------------------------------------------------
D. String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aa
2
Output
a
Input
abc
5
Output
bc
Input
abab
7
Output
b
----------------------------------------------------------------------------------------------------
E. Games with Rectangle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 1
Output
1
Input
4 4 1
Output
9
Input
6 7 2
Output
75
----------------------------------------------------------------------------------------------------
