Codeforces Round 243 (Div. 2)


A. Sereja and Mugs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
1 1 1
Output
YES
Input
3 4
3 1 3
Output
YES
Input
3 4
4 4 4
Output
NO
----------------------------------------------------------------------------------------------------
B. Sereja and Mirroring
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
0 0 1
1 1 0
1 1 0
0 0 1
Output
2
Input
3 3
0 0 0
0 0 0
0 0 0
Output
3
Input
8 1
0
1
1
0
0
1
1
0
Output
2
----------------------------------------------------------------------------------------------------
C. Sereja and Swaps
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2
10 -1 2 2 2 2 2 2 -1 10
Output
32
Input
5 10
-1 -1 -1 -1 -1
Output
-1
----------------------------------------------------------------------------------------------------
D. Sereja and Table
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 5 2
1 1 1 1 1
1 1 1 1 1
1 1 0 1 1
1 1 1 1 1
1 1 1 1 1
Output
1
Input
3 4 1
1 0 0 0
0 1 1 1
1 1 1 0
Output
-1
Input
3 4 1
1 0 0 1
0 1 1 0
1 0 0 1
Output
0
----------------------------------------------------------------------------------------------------
E. Sereja and Two Sequences
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 5 100000 1000
1 2 3 4 5
3 2 4 5 1
Output
3
Input
3 4 3006 1000
1 2 3
1 2 4 3
Output
2
----------------------------------------------------------------------------------------------------
