Codeforces Round 116 (Div. 2, ACM-ICPC Rules)


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

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

Examples
Input
10 10
Output
2-type
1
Input
2 3
Output
11-type
----------------------------------------------------------------------------------------------------
C. Letter
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
PRuvetSTAaYA
Output
5
Input
OYPROSTIYAOPECHATALSYAPRIVETSTASYA
Output
0
Input
helloworld
Output
0
----------------------------------------------------------------------------------------------------
D. Name
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aad
aac
Output
aad
Input
abad
bob
Output
daab
Input
abc
defg
Output
-1
Input
czaaab
abcdef
Output
abczaa
----------------------------------------------------------------------------------------------------
E. Cubes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 3 2
1 2 1 1 3 2 1 1 2 2
Output
4
Input
10 2 2
1 2 1 2 1 1 2 1 1 2
Output
5
Input
3 1 2
1 1 1
Output
3
----------------------------------------------------------------------------------------------------
F. Mathematical Analysis Rocks!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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