## K-Palindromes

Points: 1 (partial)
Time limit: 3.0s
Python 12.0s
Memory limit: 512M

Author:
Problem type

A string is a $$k$$-palindrome iff it can be turned into a palindrome by deleting exactly $$k$$ characters. For example, the string CABBCAD is a 3-palindrome, since D and both C characters could be deleted to form ABBA. On the other hand,CCCXCC is a 1-palindrome, since the first C could be deleted to get CCXCC. Note that deleting the X would also yield a palindrome. Further, CCCXCC is also a 2-palindrome, since one could delete the X, then any C to get a palindrome.

Can you find the minimum $$k$$ such that some string is a $$k$$-palindrome?

#### Input Specification

The first line contains an integer $$T$$, the number of test cases to follow. The next $$T$$ lines each contain a string $$S$$ containing only uppercase English letters. Each such line defines a test case.

#### Output Specification

For each test case, output a single line containing a single integer. The minimum $$k$$ such that the test case's string is a $$k$$-palindrome.

#### Bounds

Note this problem includes sub-problems of increasing difficulty worth different numbers of points:

• 40 points: $$1 \leq |S| \leq 10$$
• 100 points: $$1 \leq |S| \leq 2000$$

For all sub-problems:

$$1 \leq T \leq 10$$

#### Sample Input

4
CCCXCC
A
TOPKEKGOODMEME

#### Sample Output

3
1
0
9
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.5312289595603943, "perplexity": 2126.6929144898354}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-45/segments/1603107879537.28/warc/CC-MAIN-20201022111909-20201022141909-00050.warc.gz"}