Codeforces Round 635 (Div. 2)


A. Ichihime and Triangle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 5 7
1 5 5 7
100000 200000 300000 400000
1 1 977539810 977539810
Output
3 4 5
5 5 5
182690 214748 300999
1 977539810 977539810
----------------------------------------------------------------------------------------------------
B. Kana and Dragon Quest game
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
100 3 4
189 3 4
64 2 3
63 2 3
30 27 7
10 9 1
69117 21 2
Output
YES
NO
NO
YES
YES
YES
YES
----------------------------------------------------------------------------------------------------
C. Linova and Kingdom
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 4
1 2
1 3
1 4
3 5
3 6
4 7
Output
7
Input
4 1
1 2
1 3
2 4
Output
2
Input
8 5
7 5
1 7
6 1
3 7
8 3
2 1
4 5
Output
9
----------------------------------------------------------------------------------------------------
D. Xenia and Colorful Gems
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2 3
7 8
6 3
3 1 4
1 1 1
1
1
1000000000
2 2 2
1 2
5 4
6 7
2 2 2
1 2
3 4
6 7
3 4 1
3 2 1
7 3 3 4
6
Output
14
1999999996000000002
24
24
14
----------------------------------------------------------------------------------------------------
E. Kaavi and Magic Spell
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
abab
ba
Output
12
Input
defineintlonglong
signedmain
Output
0
Input
rotator
rotator
Output
4
Input
cacdcdbbbb
bdcaccdbbb
Output
24
----------------------------------------------------------------------------------------------------
F. Yui and Mahjong Set
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 6
2 9
5 12
5 24
6 24
Output
+ 1
+ 1
+ 2
+ 5
! 2 1 3 0 2
----------------------------------------------------------------------------------------------------
