{"raw_statement":[{"iden":"statement","content":"Heaviside function is defined as the piecewise constant function whose value is zero for negative argument and one for non-negative argument:\n\nYou are given the function f(x) = θ(s1x - a1) + θ(s2x - a2) + ... + θ(snx - an), where si =  ± 1. Calculate its values for argument values x1, x2, ..., xm.\n\nThe first line contains a single integer n (1 ≤ n ≤ 200000) — the number of the summands in the function.\n\nEach of the next n lines contains two integers separated by space — si and ai (si =  ± 1,  - 109 ≤ ai ≤ 109) — parameters of the i-th summand.\n\nThe next line contains a single integer m (1 ≤ m ≤ 200000) — the number of the argument values you should calculate the value of the function for.\n\nThe last line contains m integers x1, ..., xm ( - 109 ≤ xi ≤ 109) separated by spaces — the argument values themselves.\n\nOutput m lines. i-th line should contain the value of f(xi).\n\n"},{"iden":"input","content":"The first line contains a single integer n (1 ≤ n ≤ 200000) — the number of the summands in the function.Each of the next n lines contains two integers separated by space — si and ai (si =  ± 1,  - 109 ≤ ai ≤ 109) — parameters of the i-th summand.The next line contains a single integer m (1 ≤ m ≤ 200000) — the number of the argument values you should calculate the value of the function for.The last line contains m integers x1, ..., xm ( - 109 ≤ xi ≤ 109) separated by spaces — the argument values themselves."},{"iden":"output","content":"Output m lines. i-th line should contain the value of f(xi)."},{"iden":"examples","content":"Input61 3-1 21 9-1 21 7-1 280 12 2 8 4 -3 7 9Output03021323"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $\\theta : \\mathbb{R} \\to \\{0,1\\}$ be the Heaviside function:  \n$$\n\\theta(x) = \n\\begin{cases}\n0 & \\text{if } x < 0 \\\\\n1 & \\text{if } x \\geq 0\n\\end{cases}\n$$\n\nLet $n \\in \\mathbb{Z}^+$ be the number of summands.  \nFor $i \\in \\{1, \\dots, n\\}$, let $s_i \\in \\{-1, 1\\}$ and $a_i \\in \\mathbb{Z}$ define the $i$-th term.  \nDefine the function $f : \\mathbb{R} \\to \\mathbb{Z}$ as:  \n$$\nf(x) = \\sum_{i=1}^{n} \\theta(s_i x - a_i)\n$$\n\nLet $m \\in \\mathbb{Z}^+$ be the number of query points.  \nLet $X = (x_1, x_2, \\dots, x_m)$ be a sequence of real numbers where $x_j \\in \\mathbb{Z}$ for all $j$.\n\n**Constraints**  \n1. $1 \\leq n \\leq 200000$  \n2. $s_i \\in \\{-1, 1\\}$, $-10^9 \\leq a_i \\leq 10^9$ for all $i \\in \\{1, \\dots, n\\}$  \n3. $1 \\leq m \\leq 200000$  \n4. $-10^9 \\leq x_j \\leq 10^9$ for all $j \\in \\{1, \\dots, m\\}$\n\n**Objective**  \nFor each $j \\in \\{1, \\dots, m\\}$, compute:  \n$$\nf(x_j) = \\sum_{i=1}^{n} \\theta(s_i x_j - a_i)\n$$","simple_statement":"Given a function f(x) = θ(s₁x - a₁) + θ(s₂x - a₂) + ... + θ(sₙx - aₙ), where each sᵢ is either +1 or -1, and θ is the Heaviside function (0 for negative, 1 for non-negative). For m given x values, compute f(x) for each.","has_page_source":false}