{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eAyoub thinks that he is a very smart person, so he created a function $$$f(s)$$$, where $$$s$$$ is a binary string (a string which contains only symbols \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e0\u003c/span\u003e\" and \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\"). The function $$$f(s)$$$ is equal to the number of substrings in the string $$$s$$$ that contains at least one symbol, that is equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eMore formally, $$$f(s)$$$ is equal to the number of pairs of integers $$$(l, r)$$$, such that $$$1 \\leq l \\leq r \\leq |s|$$$ (where $$$|s|$$$ is equal to the length of string $$$s$$$), such that at least one of the symbols $$$s_l, s_{l+1}, \\ldots, s_r$$$ is equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\". \u003c/p\u003e\u003cp\u003eFor example, if $$$s \u003d $$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e01010\u003c/span\u003e\" then $$$f(s) \u003d 12$$$, because there are $$$12$$$ such pairs $$$(l, r)$$$: $$$(1, 2), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 4), (3, 5), (4, 4), (4, 5)$$$.\u003c/p\u003e\u003cp\u003eAyoub also thinks that he is smarter than Mahmoud so he gave him two integers $$$n$$$ and $$$m$$$ and asked him this problem. For all binary strings $$$s$$$ of length $$$n$$$ which contains exactly $$$m$$$ symbols equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\", find the maximum value of $$$f(s)$$$.\u003c/p\u003e\u003cp\u003eMahmoud couldn\u0027t solve the problem so he asked you for help. Can you help him? \u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \\leq t \\leq 10^5$$$) \u0026nbsp;— the number of test cases. The description of the test cases follows.\u003c/p\u003e\u003cp\u003eThe only line for each test case contains two integers $$$n$$$, $$$m$$$ ($$$1 \\leq n \\leq 10^{9}$$$, $$$0 \\leq m \\leq n$$$)\u0026nbsp;— the length of the string and the number of symbols equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\" in it.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor every test case print one integer number\u0026nbsp;— the maximum value of $$$f(s)$$$ over all strings $$$s$$$ of length $$$n$$$, which has exactly $$$m$$$ symbols, equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\".\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\n3 1\n3 2\n3 3\n4 0\n5 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n5\n6\n0\n12\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case, there exists only $$$3$$$ strings of length $$$3$$$, which has exactly $$$1$$$ symbol, equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\". These strings are: $$$s_1 \u003d $$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e100\u003c/span\u003e\", $$$s_2 \u003d $$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e010\u003c/span\u003e\", $$$s_3 \u003d $$$\"\u003cspan class\u003d\"tex-font-style-tt\"\u003e001\u003c/span\u003e\". The values of $$$f$$$ for them are: $$$f(s_1) \u003d 3, f(s_2) \u003d 4, f(s_3) \u003d 3$$$, so the maximum value is $$$4$$$ and the answer is $$$4$$$.\u003c/p\u003e\u003cp\u003eIn the second test case, the string $$$s$$$ with the maximum value is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e101\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eIn the third test case, the string $$$s$$$ with the maximum value is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e111\u003c/span\u003e\".\u003c/p\u003e\u003cp\u003eIn the fourth test case, the only string $$$s$$$ of length $$$4$$$, which has exactly $$$0$$$ symbols, equal to \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e\" is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e0000\u003c/span\u003e\" and the value of $$$f$$$ for that string is $$$0$$$, so the answer is $$$0$$$.\u003c/p\u003e\u003cp\u003eIn the fifth test case, the string $$$s$$$ with the maximum value is \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e01010\u003c/span\u003e\" and it is described as an example in the problem statement.\u003c/p\u003e"}}]}