Codeforces Round 246 (Div. 2)


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

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

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

Examples
Input
3
3 2 1
Output
1
1 3
Input
2
1 2
Output
0
Input
4
4 2 3 1
Output
3
2 4
1 2
2 4
----------------------------------------------------------------------------------------------------
D. Prefixes and Suffixes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
ABACABA
Output
3
1 4
3 2
7 1
Input
AAA
Output
3
1 3
2 2
3 1
----------------------------------------------------------------------------------------------------
E. Square Tiling
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 3
Output
ABA
Input
2 2
Output
AA
AA
Input
3 4
Output
AAAB
AAAC
AAAB
----------------------------------------------------------------------------------------------------
