Codeforces Round 271 (Div. 2)


A. Keyboard
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
R
s;;upimrrfod;pbr
Output
allyouneedislove
----------------------------------------------------------------------------------------------------
B. Worms
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 7 3 4 9
3
1 25 11
Output
1
5
3
----------------------------------------------------------------------------------------------------
C. Captain Marmot
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 1 0 0
-1 1 0 0
-1 1 0 0
1 -1 0 0
1 1 0 0
-2 1 0 0
-1 1 0 0
1 -1 0 0
1 1 0 0
-1 1 0 0
-1 1 0 0
-1 1 0 0
2 2 0 1
-1 0 0 -2
3 0 0 -2
-1 1 -2 0
Output
1
-1
3
3
----------------------------------------------------------------------------------------------------
D. Flowers
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3
2 3
4 4
Output
6
5
5
----------------------------------------------------------------------------------------------------
E. Pillars
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 3 6 7 4
Output
4
1 2 3 5 
Input
10 3
2 1 3 6 9 11 7 3 20 18
Output
6
1 4 6 7 8 9 
----------------------------------------------------------------------------------------------------
F. Ant colony
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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