European Girls Olympiad in Informatics 2022. Day 2
A. Data Centers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
5 4
20 12 10 15 18
3 4
4 1
1 3
4 2
Output
11 10 10 9 8

B. Superpiece
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Examples
Input
2
NKP
3 3 5 1
NKP
2 6 5 3
Output
2
2
Input
2
B
2 8 3 6
B
2 8 5 5
Output
-1
1
Input
2
Q
3 3 4 5
QR
4 1 1 4
Output
2
1

C. Toy Design
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Example
Input
4 1 20
3 4
Output
894784738

D. Chika Wants to Cheat
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Example
Input
2
3
1
Output
940984729