Fuzzy Conversions

All submissions for this problem are available.
### Read problem statements in [Hindi](http://www.codechef.com/download/translated/LTIME73/hindi/FUZZYCON.pdf), [Bengali](http://www.codechef.com/download/translated/LTIME73/bengali/FUZZYCON.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/LTIME73/mandarin/FUZZYCON.pdf), [Russian](http://www.codechef.com/download/translated/LTIME73/russian/FUZZYCON.pdf), and [Vietnamese](http://www.codechef.com/download/translated/LTIME73/vietnamese/FUZZYCON.pdf) as well. Raj is a math pro and number theory expert. One day, he met his ageold friend Chef. Chef claimed to be better at number theory than Raj, so Raj gave him some fuzzy problems to solve. In one of those problems, he gave Chef a $3$tuple of nonnegative integers $(a_0, b_0, c_0)$ and told Chef to convert it to another tuple $(x, y, z)$. Chef may perform the following operations any number of times (including zero) on his current tuple $(a, b, c)$, in any order:  Choose one element of this tuple, i.e. $a$, $b$ or $c$. Either add $1$ to that element or subtract $1$ from it. The cost of this operation is $1$.  Merge: Change the tuple to $(a1, b1, c+1)$, $(a1, b+1, c1)$ or $(a+1, b1, c1)$, i.e. add $1$ to one element and subtract $1$ from the other two. The cost of this operation is $0$.  Split: Change the tuple to $(a1, b+1, c+1)$, $(a+1, b1, c+1)$ or $(a+1, b+1, c1)$, i.e. subtract $1$ from one element and add $1$ to the other two. The cost of this operation is also $0$. After each operation, all elements of Chef's tuple must be nonnegative. It is not allowed to perform an operation that would make one or more elements of this tuple negative. Can you help Chef find the minimum cost of converting the tuple $(a_0, b_0, c_0)$ to the tuple $(x, y, z)$? It can be easily proved that it is always possible to convert any tuple of nonnegative integers to any other. ### Input  The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.  The first and only line of each test case contains six spaceseparated integers $a_0$, $b_0$, $c_0$, $x$, $y$ and $z$. ### Output For each test case, print a single line containing one integer ― the minimum cost. ### Constraints  $1 \le T \le 10^5$  $0 \le a_0, b_0, c_0, x, y, z \le 10^{18}$ ### Subtasks **Subtask #1 (20 points):** $0 \le a_0, b_0, c_0, x, y, z \le 100$ **Subtask #2 (80 points):** original constraints ### Example Input ``` 2 1 1 1 2 2 2 1 2 3 2 4 2 ``` ### Example Output ``` 0 1 ``` ### Explanation **Example case 1:** The tuple $(1, 1, 1)$ can be converted to $(2, 2, 2)$ using only three Split operations, with cost $0$: $(1, 1, 1) \rightarrow (2, 0, 2) \rightarrow (1, 1, 3) \rightarrow (2, 2, 2)$. **Example case 2:** We can use one addition operation and one Split operation: $(1, 2, 3) \rightarrow (1, 3, 3) \rightarrow (2, 4, 2)$.Author:  hackslash_123 
Tags  bitwise, cases, hackslash_123, ltime73, observations, taran_1407 
Date Added:  10052019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions