Codeforces Round 957 (Div. 3)


A. Only Pluses
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3 4
10 1 10
Output
100
600
----------------------------------------------------------------------------------------------------
B. Angry Monk
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 3
3 1 1
5 2
3 2
11 4
2 3 1 5
16 6
1 6 1 1 1 6
Output
2
3
9
15
----------------------------------------------------------------------------------------------------
C. Gorilla and Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 2 5
3 1 3
10 3 8
Output
5 3 4 1 2
3 2 1
10 9 8 4 7 5 6 1 2 3
----------------------------------------------------------------------------------------------------
D. Test of Love
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
6 2 0
LWLLLW
6 1 1
LWLLLL
6 1 1
LWLLWL
6 2 15
LWLLCC
6 10 0
CCCCCC
6 6 1
WCCCCW
Output
YES
YES
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
E. Novice's Mistake
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
3
10
Output
3
20 18 
219 216 
2218 2214 
1
165 162 
1
1262 2519 
----------------------------------------------------------------------------------------------------
F. Valuable Cards
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
8
6 4
2 3 6 2 1 2
9 100000
50000 25000 12500 6250 3125 2 4 8 16
5 2
1 1 1 1 1
8 6
4 3 4 3 4 3 4 3
7 12
6 11 1 3 11 10 2
10 5
2 4 4 2 4 4 4 3 1 1
7 8
4 6 5 1 2 4 1
8 27
3 9 17 26 2 20 9 3
Output
3
2
1
1
2
1
3
3
----------------------------------------------------------------------------------------------------
G. Ultra-Meow
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
3
4999
5
1
Output
12
31
354226409
184
4
----------------------------------------------------------------------------------------------------
