Codeforces Round 671 (Div. 2)


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

Examples
Input
4
1
2
1
3
3
102
4
2069
Output
2
1
1
2
----------------------------------------------------------------------------------------------------
B. Stairs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
8
6
1000000000000000000
Output
1
2
1
30
----------------------------------------------------------------------------------------------------
C. Killjoy
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 69
68 70
6 4
4 4 4 4 4 4
9 38
-21 83 50 -59 -77 15 -71 -78 20
Output
1
0
2
----------------------------------------------------------------------------------------------------
D1. Sage's Birthday (easy version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
2
3 1 4 2 5 
----------------------------------------------------------------------------------------------------
D2. Sage's Birthday (hard version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3
6
4
30
Output
2 3 6 
1
2 4 
0
2 30 6 3 15 5 10 
0
----------------------------------------------------------------------------------------------------
F. Rain of Fire
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
100 0
0 100
-100 0
0 -100
Output
100
Input
7
0 2
1 0
-3 0
0 -2
-1 -1
-1 -3
-2 -3
Output
-1
Input
5
0 0
0 -1
3 0
-2 0
-2 1
Output
2
Input
5
0 0
2 0
0 -1
-2 0
-2 1
Output
2
----------------------------------------------------------------------------------------------------
