Codeforces Round 342 (Div. 2)


A. Guest From the Past
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
11
9
8
Output
2
Input
10
5
6
1
Output
2
----------------------------------------------------------------------------------------------------
B. War of the Corporations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
intellect
tell
Output
1
Input
google
apple
Output
0
Input
sirisiri
sir
Output
2
----------------------------------------------------------------------------------------------------
C. K-special Tables
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 1
Output
28
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Input
5 3
Output
85
5 6 17 18 19
9 10 23 24 25
7 8 20 21 22
3 4 14 15 16
1 2 11 12 13
----------------------------------------------------------------------------------------------------
D. Finals in arithmetic
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
Output
2
Input
11
Output
10
Input
5
Output
0
Input
33
Output
21
----------------------------------------------------------------------------------------------------
E. Frog Fights
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
2 1
5 3
4 3
Output
1
3 
Input
5 6
1 2
3 4
2 5
5 1
6 1
Output
2
1 4 
----------------------------------------------------------------------------------------------------
