Codeforces Round 643 (Div. 2)


A. Sequence with Digits
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
1 4
487 1
487 2
487 3
487 4
487 5
487 6
487 7
Output
42
487
519
528
544
564
588
628
----------------------------------------------------------------------------------------------------
B. Young Explorers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 1 1
5
2 3 1 2 2
Output
3
2
----------------------------------------------------------------------------------------------------
C. Count Triangles
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2 3 4
Output
4
Input
1 2 2 5
Output
3
Input
500000 500000 500000 500000
Output
1
----------------------------------------------------------------------------------------------------
D. Game With Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 4
Output
YES
4
2
Input
3 4
Output
NO
Input
3 8
Output
YES
2 1 5
4
----------------------------------------------------------------------------------------------------
E. Restorer Distance
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 100 100
1 3 8
Output
12
Input
3 100 1 100
1 3 8
Output
9
Input
3 100 100 1
1 3 8
Output
4
Input
5 1 2 4
5 5 3 6 5
Output
4
Input
5 1 2 2
5 5 3 6 5
Output
3
----------------------------------------------------------------------------------------------------
F. Guess Divisors Count
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1
1
1
1024
1048576
4194304
Output
? 982306799268821872
? 230856864650023977
? 134690134760714371
! 5
? 1024
? 1048576
? 1073741824
! 42
----------------------------------------------------------------------------------------------------
