Codeforces Round 667 (Div. 3)


A. Yet Another Two Integers Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
5 5
13 42
18 4
1337 420
123456789 1000000000
100500 9000
Output
0
3
2
92
87654322
9150
----------------------------------------------------------------------------------------------------
B. Minimum Product
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
10 10 8 5 3
12 8 8 7 2
12343 43 4543 39 123212
1000000000 1000000000 1 1 1
1000000000 1000000000 1 1 1000000000
10 11 2 1 5
10 11 9 1 10
Output
70
77
177177
999999999000000000
999999999
55
10
----------------------------------------------------------------------------------------------------
C. Yet Another Array Restoration
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1 49
5 20 50
6 20 50
5 3 8
9 13 22
Output
1 49 
20 40 30 50 10
26 32 20 38 44 50 
8 23 18 13 3 
1 10 13 4 19 22 25 16 7 
----------------------------------------------------------------------------------------------------
D. Decrease the Sum of Digits
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1
Output
8
0
500
2128012501878
899999999999999999
----------------------------------------------------------------------------------------------------
E. Two Platforms
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
7 1
1 5 2 3 1 5 4
1 3 6 7 2 5 4
1 1
1000000000
1000000000
5 10
10 7 5 15 8
20 199 192 219 1904
10 10
15 19 8 17 20 10 9 2 10 19
12 13 6 17 1 14 7 9 19 3
Output
6
1
5
10
----------------------------------------------------------------------------------------------------
F. Subsequences of Length Two
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
bbaa
ab
Output
3
Input
7 3
asddsaf
sd
Output
10
Input
15 6
qwertyhgfdsazxc
qa
Output
16
Input
7 2
abacaba
aa
Output
15
----------------------------------------------------------------------------------------------------
