{"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":"HTML","content":"\u003cp\u003e孤岛上有n个人工少女。每个人工少女拥有三个属性:位置(x\u003csub\u003ei\u003c/sub\u003e),视野半径(r\u003csub\u003ei\u003c/sub\u003e),和智力(q\u003csub\u003ei\u003c/sub\u003e)。由于人工少女的腿部动作并不协调,所以她们无法移动,即x\u003csub\u003ei\u003c/sub\u003e不会变化。\u003c/p\u003e\n\n\u003cp\u003e时间长了,岛上的人工少女非常寂寞,她们会相互聊天。相互聊天需要满足两个条件:设聊天的两个少女编号为i,j \n\u003c/p\u003e\n\n\u003cp\u003e1.聊天的两个人能互相看见。即x\u003csub\u003ei\u003c/sub\u003e-r\u003csub\u003ei\u003c/sub\u003e\u0026le;x\u003csub\u003ej\u003c/sub\u003e\u0026le;x\u003csub\u003ei\u003c/sub\u003e+r\u003csub\u003ei\u003c/sub\u003e,且x\u003csub\u003ej\u003c/sub\u003e-r\u003csub\u003ej\u003c/sub\u003e\u0026le;x\u003csub\u003ei\u003c/sub\u003e\u0026le;x\u003csub\u003ej\u003c/sub\u003e+r\u003csub\u003ej\u003c/sub\u003e\u003c/p\u003e\n\n\u003cp\u003e2.两个人的智力不能相差超过K。即|q\u003csub\u003ei\u003c/sub\u003e-q\u003csub\u003ej\u003c/sub\u003e|\u0026le;K\u003c/p\u003e\n\n你现在想知道多少对人工少女可以相互聊天"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e第一行包含两个整数n(1\u0026le;n\u0026le;10\u003csup\u003e5\u003c/sup\u003e)和k(0\u0026le;k\u0026le;20)\u003c/p\u003e\n\n\u003cp\u003e接下来n行,每行用包含三个整数x\u003csub\u003ei\u003c/sub\u003e,r\u003csub\u003ei\u003c/sub\u003e,q\u003csub\u003ei\u003c/sub\u003e(0\u0026le;x\u003csub\u003ei\u003c/sub\u003e,r\u003csub\u003ei\u003c/sub\u003e,q\u003csub\u003ei\u003c/sub\u003e\u0026le;10\u003csup\u003e9\u003c/sup\u003e)。分别用来描述第i个人工少女的位置,视野半径和智力\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e一行一个整数。表示相互能聊天的少女对数。\u003c/p\u003e"}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e3 2\u003cbr\u003e3 6 1\u003cbr\u003e7 3 10\u003cbr\u003e10 5 8\u003cbr\u003e\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e1\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003e第一个少女能看到第二个,但第二个看不到第一个。第一个少女看不到第三个少女。只有第二个少女和第三个少女可以相互看见,且她们的智商只相差2。刚好可以相互聊天。\u003c/p\u003e"}}]}