Educational Codeforces Round 41 (Rated for Div. 2)


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

Examples
Input
3 9
1 1 2 2 2 3 1 2 3
Output
2
----------------------------------------------------------------------------------------------------
B. Lecture Sleep
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
1
0
0
1
0
Output
1
Input
3
101
010
101
101
000
101
010
101
011
010
101
010
Output
2
----------------------------------------------------------------------------------------------------
D. Pair Of Lines
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
0 0
0 1
1 1
1 -1
2 2
Output
YES
Input
5
0 0
1 0
2 1
1 1
2 3
Output
NO
----------------------------------------------------------------------------------------------------
E. Tufurama
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
0
Input
3
8 12 7
Output
3
Input
3
3 2 1
Output
2
----------------------------------------------------------------------------------------------------
F. k-substrings
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
15
bcabcabcabcabca
Output
9 7 5 3 1 -1 -1 -1
Input
24
abaaabaaaabaaabaaaabaaab
Output
15 13 11 9 7 5 3 1 1 -1 -1 1
Input
19
cabcabbcabcabbcabca
Output
5 3 1 -1 -1 1 1 -1 -1 -1
----------------------------------------------------------------------------------------------------
G. Partitions
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
2 3 2 3
Output
160
Input
5 2
1 2 3 4 5
Output
645
----------------------------------------------------------------------------------------------------
