Codeforces Round 163 (Div. 2)


A. Stones on the Table
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
RRG
Output
1
Input
5
RRRRR
Output
4
Input
4
BRBG
Output
0
----------------------------------------------------------------------------------------------------
B. Queue at the School
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1
BGGBG
Output
GBGGB
Input
5 2
BGGBG
Output
GGBGB
Input
4 1
GGGB
Output
GGGB
----------------------------------------------------------------------------------------------------
C. Below the Diagonal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
Output
2
2 1 2
1 1 2
Input
3
3 1
1 3
Output
3
2 2 3
1 1 3
1 1 2
Input
3
2 1
3 2
Output
0
----------------------------------------------------------------------------------------------------
D. BerDonalds
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 2 1
Output
0.50
Input
3 3
1 2 1
2 3 1
1 3 1
Output
1.00
Input
3 2
1 2 100
2 3 1
Output
50.50
----------------------------------------------------------------------------------------------------
E. More Queries to Array...
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 5
5 10 2 1
? 1 2 1
= 2 2 0
? 2 4 3
= 1 4 1
? 1 4 5
Output
25
43
1300
Input
3 1
1000000000 1000000000 1000000000
? 1 3 0
Output
999999986
----------------------------------------------------------------------------------------------------
