Pair-golfing Twin primes and the Collatz sequence This is a new kind of challenge inspired by the Recover the mutated source code problem.

You should write two programs or functions both in the same language. The first one should solve Task #1 and the second one should solve Task #2. 

Your score will be the sum of the longer program and the Levenshtein distance between the two programs source code. Lower score is better so you should try to make the two solutions similar while keeping the lengths of the programs short.

Task #1

You are given a positive integer N and you should output the Collatz sequence of N separated by spaces or newline.  Trailing separator is allowed. 

The first element of the Collatz sequence is N. The rest of the elements are generated based on their successor \$a_{i-1}\$:

$$ a_i =
\begin{cases}
\frac{a_{i-1}}{2} &amp; \text{ if } a_{i-1} \text{ is even} \\
3a_{i-1} + 1 &amp; \text{ if } a_{i-1} \text{ is odd}
\end{cases}
$$

As soon as the sequence reaches 1 no new elements are generated.

Input => Output examples:

6 =&gt; 6 3 10 5 16 8 4 2 1
8 =&gt; 8 4 2 1
1 =&gt; 1


Task #2

A pair of twin primes is a pair of positive integer whose difference is 2 and they are both primes. 

You are given a positive integer N and you should output the smallest pair of twin primes where both primes are bigger than N The first number should be the smaller one and the two primes should be separated by spaces or newline.  Trailing separator is allowed.

Input => Output examples:

6 =&gt; 11 13
42 =&gt; 59 61
1 =&gt; 3 5


Snippet for calculating the score

(Modification of the one in the Recover the mutated source code problem.)



var f=document.getElementById("f"),g=document.getElementById("s");function h(){var a=f.value,e=g.value,m=Math.max(a.length,e.length);if(10000&lt;a.length)a="&lt;span style='color:red'&gt;First program is too long!&lt;/span&gt;";else if(10000&lt;e.length)a="&lt;span style='color:red'&gt;Second program is too long!&lt;/span&gt;";else{if(0===a.length)a=e.length;else if(0===e.length)a=a.length;else{var d=[],b;for(b=0;b&lt;=e.length;b++)d[b]=[b];var c;for(c=0;c&lt;=a.length;c++)d[0][c]=c;for(b=1;b&lt;=e.length;b++)for(c=1;c&lt;=a.length;c++)d[b][c]=e.charAt(b-1)===a.charAt(c-1)?d[b-1][c-1]:Math.min(d[b-1][c-1]+1,Math.min(d[b][c-1]+1,d[b-1][c]+ 1));a=d[e.length][a.length]}a="Distance = "+a+"   Longer length = "+m+"   Score = &lt;strong&gt;"+(a+m)+"&lt;/strong&gt;"}document.getElementById("d").innerHTML=a}f.onkeyup=h;g.onkeyup=h;
First program&lt;textarea id=f rows=2 cols=80 style="width:100%"&gt;&lt;/textarea&gt;Second program&lt;textarea id=s rows=2 cols=80 style="width:100%"&gt;&lt;/textarea&gt;&lt;p id=d&gt;&lt;/p&gt;




Edit

In the answers' header let's use the format

[Language], [longer length] + [distance] = [final score]. 

E.g. 

Python 2, 60 + 32 = 92
CJam, 24 + 17 = 41 42
Collatz program:
ri2*{:N2%N3*)N2/?__p(}g;

Twin primes program:
ri_2+]{:)_{mp}/&amp;_+((}gS*

Both take input from STDIN and print space/newline separated numbers to STDOUT
Try them online here