Educational Codeforces Round 103 (Rated for Div. 2)


A. K-divisible Sum
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 5
4 3
8 8
8 17
Output
5
2
1
3
----------------------------------------------------------------------------------------------------
B. Inflation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4 1
20100 1 202 202
3 100
1 1 1
Output
99
0
----------------------------------------------------------------------------------------------------
C. Longest Simple Cycle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
3 4 3 3
-1 1 2 2
-1 2 2 3
2
5 6
-1 5
-1 1
3
3 5 2
-1 1 1
-1 3 5
Output
7
11
8
----------------------------------------------------------------------------------------------------
D. Journey
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
6
LRRRLL
3
LRL
Output
1 3 2 3 1 3 2
1 4 1 4
----------------------------------------------------------------------------------------------------
E. Pattern Matching
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 4
_b_d
__b_
aaaa
ab__
_bcd
abcd 4
abba 2
dbcd 5
Output
YES
3 2 4 5 1 
Input
1 1 3
__c
cba 1
Output
NO
Input
2 2 2
a_
_b
ab 1
ab 2
Output
NO
----------------------------------------------------------------------------------------------------
F. Lanterns
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
8
0 0 3 1 1 1 1 2
2
1 1
2
2 2
2
0 1
Output
YES
RRLLLLRL
YES
RL
YES
RL
NO
----------------------------------------------------------------------------------------------------
G. Minimum Difference
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12 11
2 1 1 2 1 1 3 2 1 1 3 3
1 2 10 3
1 2 11 3
2 7 2
1 3 9 2
1 1 12 1
1 1 12 4
2 12 4
1 1 12 4
2 1 5
1 3 12 2
1 1 4 3
Output
5
4
1
0
-1
5
0
1
----------------------------------------------------------------------------------------------------
