Yandex.Algorithm 2011: Qualification 2


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

Examples
Input
1
Output
Sheldon
Input
6
Output
Sheldon
Input
1802
Output
Penny
----------------------------------------------------------------------------------------------------
B. Sets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2 7 4
3 1 7 3
3 5 4 2
3 1 3 5
4 3 1 2 4
2 5 7
Output
1 7 
2 2 4 
2 1 3 
1 5 
Input
4
5 6 7 8 9 100
4 7 8 9 1
4 7 8 9 2
3 1 6 100
3 2 6 100
2 1 2
Output
3 7 8 9 
2 6 100 
1 1 
1 2 
Input
3
2 1 2
2 1 3
2 2 3
Output
1 1 
1 2 
1 3 
----------------------------------------------------------------------------------------------------
C. General Mobilization
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
40 10 30 20
1 2 1
2 3 1
4 2 1
Output
0 1 3 2 
Input
5
5 4 3 2 1
1 2 1
2 3 1
2 4 1
4 5 1
Output
0 1 4 2 3 
----------------------------------------------------------------------------------------------------
D. Two out of Three
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
1 1 2
-1 1
Output
10.0000000000
Input
2 2 4
-1 0
1 2
Output
23.3333333333
----------------------------------------------------------------------------------------------------
