cf/mirror

Santa Claus and a Palindrome

CF
748D2100· master2s256 MB⌨ stdin/stdout

Examples

Sample 1of 3
Input
7 3
abb 2
aaa -3
bba -1
zyz -4
abb 5
aaa 7
xyx 4
Output
12
Sample 2of 3
Input
3 1
a 1
a 2
a 3
Output
6
Sample 3of 3
Input
2 5
abcde 10000
abcde 10000
Output
0
748D.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)