{"trustable":false,"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":"MD","content":"\u003cp\u003eWe have a point $$$A$$$ with coordinate $$$x \u003d n$$$ on $$$OX$$$-axis. We\u0027d like to find an \u003cspan class\u003d\"tex-font-style-it\"\u003einteger point\u003c/span\u003e $$$B$$$ (also on $$$OX$$$-axis), such that the \u003cspan class\u003d\"tex-font-style-it\"\u003eabsolute difference\u003c/span\u003e between the distance from $$$O$$$ to $$$B$$$ and the distance from $$$A$$$ to $$$B$$$ is equal to $$$k$$$.\u003c/p\u003e\n\u003ccenter\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/a7d9c5826209b403e8f0de8fbd90ecf9?v\u003d1680534579\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003cspan class\u003d\"tex-font-size-small\"\u003eThe description of the first test case.\u003c/span\u003e\n\u003c/center\u003e\n\u003cp\u003eSince sometimes it\u0027s impossible to find such point $$$B$$$, we can, in one step, increase or decrease the coordinate of $$$A$$$ by $$$1$$$. What is the minimum number of steps we should do to make such point $$$B$$$ exist?\u003c/p\u003e"}},{"title":"简意","value":{"format":"MD","content":"在数轴 $OA$ 上 A 的坐标为 $n$,我们想找到一个整数点 B,使得 $\\left|\\operatorname{dist}(O,B) - \\operatorname{dist}(A,B) \\right| \u003d k$。$\\operatorname{dist}$ 是指两个点的距离。 A,B 都是整数点。\n\n有时找不出一个合法的 B,我们可以挪动一下 A。(使 A 的坐标增加或减少1)求挪动 A 的最少次数,使得有一个合法的 B。\n\n**多组数据**,$0 \\le n,k \\le 10^6$。"}},{"title":"Input","value":{"format":"MD","content":"\u003cp\u003eThe first line contains one integer $$$t$$$ ($$$1 \\le t \\le 6000$$$)\u0026nbsp;— the number of test cases.\u003c/p\u003e\n\u003cp\u003eThe only line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$0 \\le n, k \\le 10^6$$$)\u0026nbsp;— the initial position of point $$$A$$$ and desirable absolute difference.\u003c/p\u003e"}},{"title":"Output","value":{"format":"MD","content":"\u003cp\u003eFor each test case, print the minimum number of steps to make point $$$B$$$ exist.\u003c/p\u003e"}},{"title":"Sample 1","value":{"format":"MD","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\u003e6\n4 0\n5 8\n0 1000000\n0 0\n1 0\n1000000 1000000\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n3\n1000000\n0\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"MD","content":"\u003cp\u003eIn the first test case (picture above), if we set the coordinate of $$$B$$$ as $$$2$$$ then the absolute difference will be equal to $$$|(2 - 0) - (4 - 2)| \u003d 0$$$ and we don\u0027t have to move $$$A$$$. So the answer is $$$0$$$.\u003c/p\u003e\n\u003cp\u003eIn the second test case, we can increase the coordinate of $$$A$$$ by $$$3$$$ and set the coordinate of $$$B$$$ as $$$0$$$ or $$$8$$$. The absolute difference will be equal to $$$|8 - 0| \u003d 8$$$, so the answer is $$$3$$$.\u003c/p\u003e\n\u003ccenter\u003e\u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/1d50f1a15db9e92b6ce0900a9ee3e66a?v\u003d1680534579\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e\n\u003c/center\u003e"}}]}