{"problem":{"name":"B. Singhal and Equality","description":{"content":"_If you want to practice topicwise questions in the ladder way like a2oj , do register on my site *http://codedigger.tech* after the contest. Here you will get Handpicked Topicwise Questions from code","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10276B"},"statements":[{"statement_type":"Markdown","content":"_If you want to practice topicwise questions in the ladder way like a2oj , do register on my site *http://codedigger.tech* after the contest. Here you will get Handpicked Topicwise Questions from codeforces, codechef, uva and spoj for your better practice. Best of Luck._\n\nSinghal loves Equality. He has a string $S$ consisting of lowercase English Letters.\n\nHe wants to equalize the frequency of all distinct characters in his string $S$. He can do the following operation any number of times: pick any single character in the string and replace with another lowercase English alphabet.\n\nHe wants to perform minimum number of operations to equalize the frequency of distinct characters.\n\nFrequency of a character is number of times it appear in the string.\n\nThe first line contains a single integer $t (1 <= t <= 10^5)$ — the number of test cases in the input. Then $t$ test cases follow.\n\nEach query contains a single string consisting of lowercase English letters $S (1 <= | S | <= 10^5)$. $| S |$ is the length of the string. \n\nIt is guaranteed that the total sum of $| S |$ is at most $10^5$.\n\nPrint $t$ answers to the test cases. Each answer must be consisting of single integer — the minimum number of operations required to equalize the frequency of distinct characters of string.\n\nIn the first query — We can replace letter $b arrow.r a$ to form _aaa_. Now frequency of all distinct character is same i.e. $3$ or another possibility is replace one $a arrow.r c$ to form _abc_. In this case frequency is $1$.\n\nIn the second query — Frequency of all distinct character is Same i.e. $2$. No need to apply operation.\n\n## Input\n\nThe first line contains a single integer $t (1 <= t <= 10^5)$ — the number of test cases in the input. Then $t$ test cases follow.Each query contains a single string consisting of lowercase English letters $S (1 <= | S | <= 10^5)$. $| S |$ is the length of the string. It is guaranteed that the total sum of $| S |$ is at most $10^5$.\n\n## Output\n\nPrint $t$ answers to the test cases. Each answer must be consisting of single integer — the minimum number of operations required to equalize the frequency of distinct characters of string.\n\n[samples]\n\n## Note\n\nIn the first query — We can replace letter $b arrow.r a$ to form _aaa_. Now frequency of all distinct character is same i.e. $3$ or another possibility is replace one $a arrow.r c$ to form _abc_. In this case frequency is $1$.In the second query — Frequency of all distinct character is Same i.e. $2$. No need to apply operation.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ n, m, Q \\in \\mathbb{Z} $ denote the grid dimensions and number of queries.  \n- Let $ G \\in \\{ \\texttt{'}.\\texttt{'} , \\texttt{'}#\\texttt{'} \\}^{n \\times m} $ be the grid, where $ G[i][j] = \\texttt{'}#\\texttt{'} $ means dry, $ \\texttt{'}.\\texttt{'} $ means wet.  \n- Let $ \\mathcal{Q} = \\{ (t_i, x_i, y_i) \\mid i \\in \\{1, \\dots, Q\\} \\} $ be the sequence of queries, where $ t_i \\in \\{1, 2\\} $.\n\n**Constraints**  \n1. $ 1 \\le T \\le 1000 $  \n2. $ 1 \\le n, m, Q \\le 10^3 $  \n3. $ \\sum \\max(n, m, Q) \\le 2 \\times 10^4 $ over all test cases  \n4. For each query:  \n   - If $ t_i = 1 $: toggle state of cell $ (x_i, y_i) $ (dry ↔ wet)  \n   - If $ t_i = 2 $: compute maximum area of axis-aligned $ a \\times b $ rectangular frame (width 1) with dry boundary only, where $ a \\ge 1, b \\ge 1 $\n\n**Objective**  \nFor each query with $ t_i = 2 $:  \nCompute  \n$$\n\\max \\left\\{ a \\cdot b \\ \\middle|\\ \n\\begin{array}{c}\n1 \\le a \\le n,\\ 1 \\le b \\le m, \\\\\n\\text{the frame of } a \\times b \\text{ rectangle has all boundary cells dry}\n\\end{array}\n\\right\\}\n$$  \nIf no such frame exists, output $ 0 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10276B","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}