text:
Arithmetic mean of prime Fibonacci Numbers up to the x Fibonacci Number
You should have heard about the Fibonacci Numbers, often called the Fibonacci Sequence. In this sequence the first two terms are 0 and 1, and every number after the first two is the sum of the two preceding ones. In other words, F(n) = F(n-1) + F(n-2).
Here are the first 20 Fibonacci numbers:
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181

Task:
Given an integer x, compute the arithmetic mean (the average) of the prime Fibonacci Numbers up to the x number of the Fibonacci Sequence.
Rules:

the Fibonacci sequence starts with 0 and 1 for this challenge
3 < x < 40, because higher values of x might cause some huge execution time or overflows and smaller values have no output
1 is NOT prime, since it only has 1 divisor
the arithmetic mean should include decimals, if it's the case, or should be displayed as an exact fraction
you are only allowed to take x as input and the code needed to take the input does not count (e.g: if you need something like x = input(), you should not take it into consideration when counting the bytes)

Examples:
Ex. 1: For x=10, the output is 5.75, because the 10th Fibonacci number is 55 and the prime Fibonacci numbers up to 55 are 2, 3, 5, 13, their average being 5.75
Following the explanation from example 1, other examples are:
Ex. 2: For x=15, the output is 57.5
Ex. 3: For x=20, the output is 277.428571428571, or any other close approximation. In this case 277.4286, for instance, is an accepted value
Ex. 4: For x=11, the output is 22.4
Ex. 5: For x=30, the output is 60536.4444444444, or any other close approximation, such as 60536.444

Leaderboard:

var QUESTION_ID=112025,OVERRIDE_USER=59487;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

To change the leader, submit a shorter valid solution. Your code should be as short as possible, since this is code-golf, so the shortest answer in bytes wins. Good luck!

Can the result be returned as an exact fraction instead of a rounded decimal?

Yes of course, as long as it is the correct value. Edited the question :))

If the answer is given as a fraction, does the fraction have to be reduced?

That's up to you. You can reduce it if you want, but I don't think that's necessary.

Please update accepted answer.

Actually, 10 bytes
Code:
R♂F;Mr♂P∩æ

Explanation:
R            # On the input, create the range [1 .. input].
 ♂F          # Map the nth Fibonacci command over it.
   ;M        # Duplicate and get the maximum of the list.
     r       # Create the range [0 .. maximum - 1].
      ♂P     # Map the nth prime operator over each element (zero-indexed).
        ∩    # Intersection of both.
         æ   # Get the mean and implicitly display.

Uses the CP-437 encoding. Try it online!

Wow, done such a job in just 10 bytes. Impressive!

Python 2, 71 bytes
s=2.;a=b=c=1
exec"p=2**a%a==2;c+=p;s+=a*p;a,b=b,a+b;"*input()
print s/c

Try it online!
Python doesn't have useful arithmetic built-ins for this, so we do things by hand. The code iterates through Fibonacci numbers via a,b=b,a+b starting from a=b=1.
The Fermat primality test with base 2 is used to identify primes as a where 2^a == 2 (mod a). Though this only checks for probable primes, none of the false positives are within the first 40 Fibonacci numbers.
The current sum s and count c of primes are updated each time a prime is encountered, and their ratio (the mean) is printed at the end. Because the prime check misses a=2 and it's guaranteed to be in the input range, the sum starts at 2 and the count starts at 1 to compensate.

Jelly, 11 bytes
ÆḞ€ÆPÐfµS÷L

Try it online!
How it works
ÆḞ€ÆPÐfµS÷L  Main link. Argument: n (integer)

ÆḞ€          Map the Fibonacci atom over [1, ..., n].
   ÆPÐf      Filter by primality.
       µ     Begin a new chain. Argument: A (array of Fibonacci primes)
        S    Yield the sum of A.
          L  Yield the length of A.
         ÷   Compute the quotient.

A solid 2 of 3 on math built-ins. Fibonacci, check. Primality, check. Arithmetic mean, nope.

I have changed the accepted answer, because a shorter one was posted.

Mathematica, 38 bytes
Mean@Select[Fibonacci@Range@#,PrimeQ]&

(* or *)

Mean@Select[Fibonacci~Array~#,PrimeQ]&

Explanation
Mean@Select[Fibonacci@Range@#,PrimeQ]&
                                     &  (* For input # *)
                      Range@#           (* List {1, 2, 3, ... #} *)
            Fibonacci@                  (* Find the corresponding fibonacci numbers *)
     Select[                 ,PrimeQ]   (* Select the prime terms *)
Mean@                                   (* Take the Mean *)

I think you want # and not #-1: the OP says that 55 is the 10th Fibonacci number, so their list must be 0-indexed (as is the best convention). Compare your output for inputs 10 and 11 with the OP. Fortunately this actually saves you three bytes!

You can drop the & and replace # with x (question says that input taking code is not scored)

Perl 6, 51 bytes
{sum($/=[grep *.is-prime,(0,1,*+*...*)[0..$_]])/$/}

Try it
Expanded:
{
  sum(
    $/ = [                # store as an Array in $/

      grep
        *.is-prime,       # find the primes
        (
          0, 1, *+* ... * # Fibonacci sequence
        )[ 0 .. $_ ]      # grab the indicated values in the sequence

    ]
  )

  /

  $/   # use the Array as a number (elems)
}

MATL, 16 bytes
lOi:"yy+]vtZp)Ym

Try it online!
Explanation
lO     % Push 1, then 0. This way the generated numbers with indices 1, 2, 3, ...
       % will be 1, 1, 2, ... as required
i      % Input n
:"     % Do the following n times
  yy   %   Duplicate top two numbers
  +    %   Add
]      % End
v      % Concatenate all numbers into a column vector
t      % Duplicate
Zp     % Vector of logical values: true for prime numbers, false otherwise
)      % Apply that vector as an index. This keeps only prime numbers
Ym     % Mean. Implicitly display

Octave, 75 71 bytes
@(n)mean((t=fix(((1+(s=5^.5)).^(x=1:n)-(1-s).^x)/s./2.^x))(isprime(t)))

Anonymous function that uses Binet's formula. Input and output are in the form of function arguments.
Try it online!

+1 for the interesting use of Binet's formula, combined with the built-in isprime which is perfect for this challenge.

Maxima, 49 bytes
f(n):=mean(sublist(makelist(fib(x),x,n),primep));

Prolog (SWI), 269 264 254 218 bytes

Thanks to Fatalize for saving 37 bytes!
Thanks to Emigna for saving 9 bytes!

I'm fairly certain that I could golf some more bytes down.
X/X:-X<3.
N/R:-A is N-1,B is N-2,A/C,B/D,R is C+D.
2^0^0.
C^S^E:-G is C-1,G/M,G^Q^R,(p(M)->S=M+Q,E is R+1;S=Q,E is R).
a(X,S):-X^R^Q,S is R/Q.
p(N):-N*(N-1).
p(2).
p(3).
N*2:-N mod 2=\=0.
N*C:-N mod C=\=0,D is C-1,N*D.

Run it as a(15, R). for x = 15, R is the output variable.
Try it online!

A more readable version:
fibonacci(1, 1) :- !.
fibonacci(2, 2) :- !.

fibonacci(N, R) :-
  N0 is N - 1,
  N1 is N - 2,
  fibonacci(N0, R1),
  fibonacci(N1, R2),
  R is R1 + R2.

listed(2, 0, 0) :- !.

listed(C, S, Successes) :-
  C0 is C - 1,
  fibonacci(C0, Result),
  listed(C0, S0, S1),
  (
    is_prime(Result)
    ->
      S = Result + S0, Successes is S1 + 1
    ; S = S0, Successes is S1
  ).

f(X, S) :-
  listed(X, R, Q),
  S is R / Q.

is_prime(Num) :- is_prime(Num, Num - 1).

is_prime(2).
is_prime(3).

is_prime(Num, 2) :- Num mod 2 =\= 0, !.

is_prime(Num, C) :-
  Num mod C =\= 0,
  C0 is C - 1,
  is_prime(Num, C0).

Golfing in SWI Prolog is golden (and very hard), so nice work!

I'm pretty sure things like N*C:- is allowed for head declarations in PPCG, which can save you some bytes.

@Fatalize I just learned this programming language about a week ago, so I'm not sure what you mean :p. Do you mean to substitute p(N,C):- with N*C:-?

@Adnan Exactly!

@Fatalize Oohhh, that's really neat! Thanks :).

You can save even more bytes using other operators for other predicates, e.g. / instead of f in much the same way.

Would f(X,X):-X<3. work instead of the first 2 rows (in addition to Fatalize's suggestion to replace f with an operator)?

@Emigna yes it would, saving 9 bytes, tested it.

@Fatalize Hahaha, that's some black magic going on right there. Thanks :).

@Emigna Yep, that works! Thank you :).

@Adnan please fix your byte count, your byte counts all look scratched off.

@Khaled.K Thanks, I have fixed the byte count

Röda, 98 94 93 bytes
f n{z=0;i=1;j=1;s=0;seq 2,n-1|{|_|c=i+j;i=j;j=c;seq 2,c-1|{z+=1;s+=c}if[c%p>0]()for p}_[s/z]}

It's a function that returns the result as a floating point number.
Ungolfed version:
function f(n) {
    i = 1
    j = 1
    sum = 0
    num = 0
    seq(2, n-1) | for _ do
        /* calculate next fibonacci number: */
        c = i+j
        i = j
        j = c
        /* if it's prime: */
        {
            num += 1
            sum += c
        /* primality test: */
        } if [c%p > 0]() for p in [seq(2, c-1)]
    done
    return sum/num
}

Can you do c%p>0 instead of c%p!=0?

@KritixiLithos Yes! Thank you.

05AB1E, 13 bytes
!ÅF¹£DpÏDOsg/

Try it online!
or as a Test suite
Explanation
!ÅF             # get a list of fibonacci numbers up to fac(input)
   ¹£           # take the first input elements of that list
     D          # duplicate
      p         # isprime on the copy
       Ï        # keep the fibonacci numbers which are true in the isprime list
        D       # duplicate the list of fibonacci primes
         O      # sum the list
          s     # swap the other copy to the top of the stack
           g    # get its length
            /   # divide sum by length

Pyke, 11 bytes
S.b#_P)'sl/

Try it online!

dc, 129 bytes
?sa0sb1sd0ss0sz[[lF1+sF]sqlelG!=q]si[ls+sslz1+sz]sw[lddlb+dsdrsbdsG2se0sF[lGdle%0=ile1+dse<p]dspxlF0=wla1-dsa1<c]dscxEkls1-lz1-/p

A Fibonacci number generator and primality checker all in one. Nice.
Try it online!

Japt -x, 14 12 bytes
ò!gM fj Ë/Fl

Try it

Wow, I love new answers to old questions. Also close to the other golfing languages, so +1.

Husk, 6 bytes
Afṗ↑İf

Try it online! Outputs the mean as an exact rational number.
Explanation
Afṗ↑İf  (Let X denote the argument.)
A       Take the arithmetic mean of
   ↑      the first X values of
    İf     the infinite list of Fibonacci numbers,
 fṗ      filtered for primality.

perl, 91 bytes
$b=1;map{($a,$b)=($b,$a+$b),$p=("x"x$b)!~/^(.|(..+)\2+)$/,$s+=$b*$p,$c+=$p}2..$x;print$s/$c

Cuold have been 8 bytes shorter if the modulo pseudoprime test worked as well in perl as in the python answer:
$b=1;$s=2;map{($a,$b)=($b,$a+$b),$p=2**$b%$b==2,$s+=$b*$p,$c+=$p}2..$x;print$s/++$c

...but this gives wrong answer for input > 16 in perl.

Axiom, 104 bytes
g(n)==(y:=x:=r:=0;repeat(x>n=>break;j:=fibonacci(x);x:=x+1;if prime?(j)then(r:=r+j;y:=y+1));y=0=>-1;r/y)

ungolfed, test code and results
f(n)==
  y:=x:=r:=0
  repeat
     x>n=>break
     j:=fibonacci(x)
     x:=x+1
     if prime?(j) then(r:=r+j;y:=y+1)
  y=0=>-1
  r/y

(3) -> [[i,g(i)::Float] for i in [1,2,3,10,15,20,11,30,50]]
   Compiling function g with type PositiveInteger -> Fraction Integer
   (3)
   [[1.0,- 1.0], [2.0,- 1.0], [3.0,2.0], [10.0,5.75], [15.0,57.5],
    [20.0,277.4285714285 7142857], [11.0,22.4], [30.0,60536.4444444444 44444],
    [50.0,309568576.1818181818 2]]

i try to duplicate the matematica, octave etc languages entry, if one not count the mean() function, to implement it would be here 62 bytes so good too
mean(a:List Float):Any==
    i:=1; s:=0.0
    repeat
       if~index?(i,a)then break
       s:=s+a.i
       i:=i+1
    i=1=>[]
    s/(i-1)

--62 bytes
f(x:NNI):Any==mean(select(prime?,[fibonacci(i)for i in 1..x]))

JavaScript ES6, 137 136 118 113 bytes

m=

n=>(a=[],(f=x=>a[x]=x<2?x:f(--x)+f(--x))(n),eval((a=a.filter(x=>eval("for(y=x;x%--y;);y==1"))).join`+`)/a.length)

console.log(m(10))
console.log(m(15))
console.log(m(20))
console.log(m(11))
console.log(m(30))

History
118 bytes
n=>(a=[0,1,1],(f=x=>a[--x]=a[x]||f(x)+f(--x))(n),eval((a=a.filter(x=>eval("for(y=x;x%--y;);y==1"))).join`+`)/a.length)

136 bytes
n=>(a=[0,1,1],(f=x=>a[--x]=a[x]||f(x)+f(--x))(n),eval((a=a.filter(x=>x>1&&!Array(x).fill().some((i,j)=>j>1&&!(x%j)))).join`+`)/a.length)

137 bytes
n=>(a=[0,1,1],(f=x=>a[--x]=a[x]||f(x)+f(--x))(n),eval((a=a.filter(x=>{d=x;while(--d>1)if(!(x%d))return 0;return x>1})).join`+`)/a.length)

Jelly, 7 bytes
ÆḞ€ẒƇÆm

Try it online!
The newest version of Jelly really helps with this. This is essentially identical to Dennis' answer but uses the newer features, so go upvote his answer.
How it works
ÆḞ€ẒƇÆm - Main link. Takes n on the left
ÆḞ€     - i'th Fibonacci number for each i in [1, 2, .., n]
    Ƈ   - Comb; Keep those for which the following is true:
   Ẓ    -   Is prime?
     Æm - Take the arithmetic mean

Whispers v3, 71 bytes
> Input
> fₙ
>> 2ᶠ1
>> L’
>> Select∧ 4 3
>> mean(5)
>> Output 6

Unfortunately, no TIO as this relies on v3 features, and v3 isn't on TIO. However, you can tell it by downloading and running the interpreter in the linked GitHub repo
How it works
> Input
Here, we "define" line 1 to hold our input integer, n

> fₙ
On line 2, we store an infinite list of Fibonacci numbers

>> 2ᶠ1
We then use the ᶠ dyad to take the ᶠirst n elements from the infinite list

>> L’
This line is a "functional operator line". It is passed a value on the Left and returns the ’ (prime) operator result on that value

>> Select∧ 4 3
We now take the list of Fibonacci numbers and Select those which return true when run through line 4

>> mean(5)
>> Output 6
Finally, we take the mean of the resulting list, before outputting it


text:
Find the original string, without the repetition without the repetition in the middle
Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession.
To make sure make sure other people are not bothered by this, your task is to write a program that resolves this problem!
Task
Given an input string (if it matters for your language, you may assume ASCII-only input that does not contain linefeeds.) str, that contains somewhere in its middle a substring that occurs twice in immediate succession, return the string with one instance of this substring removed.
In the case of multiple possibilities, return the shortest answer possible (that is, pick the longest consecutive repeating substring and remove that one).
In the case of multiple, equally-long consecutive repeating substrings, remove the first (that is, the first one encountered when reading through the string from front to back) one.
You may assume that the input is correct (i.e. always contains a consecutive repeating substring), which might help to golf it down.

Examples

Input: hello hello world -> Output: hello world.
Input: foofoo -> Output: foo. (So: Yes, the string might only consist of the repeating part twice).
Input: aaaaa -> Output: aaa, as the longest repeating consecutive substring is here aa.
Input: Slartibartfast -> This is not a valid input, as it does not contain a consecutive repeating substring, so you do not need to handle this case.
Input: the few the bar -> This is another invalid input, since the repeating part should immediately follow the original part. In this case, the and the are separated by something else in-between, so this input is invalid.
Input: ababcbc -> Output: abcbc. The two possible longest consecutive repeating substrings are ab and bc. As ab is encountered earlier in the string, this one is the correct answer.
Input: Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo. Output: Buffalo buffalo buffalo buffalo Buffalo buffalo. (The performed replacement should be case-sensitive).
Input: Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession. ->  Output: Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice in succession.. Only the longest consecutive repeating substring is removed.

Your code should be as short as possible, since this is code-golf, so the shortest answer in bytes wins. Good luck!

@manatwork When taking the first sentence, that is Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession. as input, the output should be Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice in succession.. Only the longest found duplication is removed.

I suggest adding a test that has two possible replacements, where the second one is longer than the first. I suspect most answers won't pass that one :)

@aross test case 8 is exactly  that :)

Unless me and my test code are mistaken, there is only one repeated string in there.

@aross there is a double p in happens

That's strange, I somehow thought that the minimum length of the repeated string was 2.

Retina, 35 33 bytes
Byte count assumes ISO 8859-1 encoding.
(?=(.+)(\1.*))
$2¶$`
O$#`
$.&
G1`

Try it online!
Explanation
Since regex engines look for matches from left to right, it's not trivial to find the longest match regardless of position. It can be done with .NET's balancing groups, but the result is rather unpleasantly long:
1`((.)+)\1(?<=(?!.*((?>(?<-2>.)+).+)\3)^.*)
$1

So I figured I'd try to avoid that by making use of some other Retina features.
(?=(.+)(\1.*))
$2¶$`

We start by essentially applying all possible substitutions, one on each line. To do this, we match the position in front of a match (instead of the match itself), to allow for overlapping matches. This is done by putting the real regex into a lookahead. That lookahead then captures the remaining except the duplicate we want to remove in group 2. We write back group 2 (deleting the duplicate), a linefeed, and then then the entire input up to the match, which gives us basically a fresh line to be substituted.
At the end we'll have one line for each match, with the corresponding duplicate removed. At the end there'll also be the full input again without any substitutions done.
Now that we have all the possible substitutions, we want the shortest result (which corresponds to the longest removed repetition).
O$#`
$.&

So we first sort the lines by length.
G1`

And then we only keep the first line.

Wow, that replacement technique is really clever!

Perl 6, 40 bytes
{.subst: m:ex/(.*))>$0/.max(*.chars),''}

Try it
{
  .subst:             # substitute

    m                 # match
    :exhaustive
    /
      ( .* )          # any number of chars

      )>              # don't include the following in what is returned

      $0              # the first match again
    /.max( *.chars ), # find the first longest submatch

    ''                # substitute it with nothing
}

Jelly, 22 19 bytes
-2 bytes thanks to Dennis (avoid an argument reversal, remove subtly redundant increment)
ẋ2³wȧ+¥J
ẆÇ€LÐṀḢṬœp

Try it online!
Full program (a bug has been found with ÐṀ not acting with the correct arity over dyads, which will be fixed soon; although I'm not sure it can make for shorter code here).
How?
Finds the first of the longest slices of the input such that a repetition exists in the input and removes it from the input.
ẋ2³wȧ+¥J - Link 1, removal indices for given slice if valid, else 0: slice, x
ẋ2       - repeat x twice, say y
  ³      - program input: s
   w     - index of first occurrence of y in s (1-based) or 0, say i
       J - range(length(x)): [1,2,3,...,length(x)]
      ¥  - last two links as a dyad
    ȧ    -     and (non-vectorising)
     +   -     addition: [1+i,2+i,3+i,...,length(x)+i] or 0
         - note: no need to decrement these since the last index will be the 1st index
         - of the repetition (thanks to Dennis for spotting that!)

ẆÇ€LÐṀḢṬœp - Main link: string, s
Ẇ          - all sublists of s (order is short to long, left to right, e.g. a,b,c,ab,bc,abc)
 Ç€        - call the last link (1) as a monad for €ach
    ÐṀ     - filter by maximal
   L       -     length
      Ḣ    - head: get the first (and hence left-most) one
       Ṭ   - untruth: make a list with 1s at the indexes given and 0s elsewhere
        œp - partition s at truthy indexes of that, throwing away the borders
           - implicit print

JavaScript (ES6), 81 74 bytes

f=
s=>s.replace(/(?=(.+)\1)/g,(_,m)=>r=m[r.length]?m:r,r='')&&s.replace(r,'')
<input oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 7 bytes by stealing @Arnauld's m[r.length] trick.

Haskell, 101 bytes
Main function is f, it takes and returns a String.
l=length
a=splitAt
f s|i<-[0..l s-1]=[p++t|n<-i,(p,(r,t))<-fmap(a$l s-n).(`a`s)<$>i,r==take(l r)t]!!0

Try it online!
When I started this, I imported Data.List and used maximum, tails, inits and isPrefixOf. Somehow that got turned into this. But I still only managed to shave off 11 bytes...
Notes

splitAt/a splits a string at a given index.
s is the input string.
i is the list of numbers [0 .. length s - 1], the -1 is to work around that splitAt splits at the end if given a too large index.
n is length s minus the current length goal for the repeated part, it's chosen that way so we don't have to use two number lists and/or the verbose decreasing list syntax.
p,r, and t are a threeway split of s, with r the intended repeated part. The fmap there uses the (,) String Functor to avoid a variable for an intermediate split.
!!0 selects the first element of the list of matches.

PowerShell, 87 bytes
param($s)([regex](([regex]'(.+)\1'|% *hes $s|sort L*)[-1]|% Gr*|% V*)[1])|% Re* $s '' 1

Try it online! (all test cases)
Explanation
Starting from the inside basically, we run Matches with the (.+)\1 regex, to return all match objects for the specified string. The regex matches any sequence of characters that is followed by itself.
Then the resulting match objects are piped into sort to be sorted by their Length property (shortened to wildcard). This results in an array of matches sorted by length, ascending, so index with [-1] to get the last element (the longest). That match's value is the match though, not the group, so it includes the repetition, so we retrieve the Group object (|% Gr*) and then the value of that (|% V*) to get the largest repeated string. Thing is the group object is actually an array because group 0 is always the match, but I want the actual group (1), so the resulting value is actually values, hence indexing to get the second element [1]. This value is casted to a regex object itself and then the Replace method is called against the original string, replacing with nothing, and only the first match is replaced (|% Re* $s '' 1).

Jelly, 23 21 bytes
ṚẆUẋ€2ẇÐf¹ṪðLHḶ+w@Ṭœp

Thanks to @JonathanAllan for his Ṭœp idea which saved 2 bytes.
Try it online!

Mathematica, 63 60 59 bytes
4 bytes saved due to Martin Ender.
#&@@StringReplaceList[#,a__~~a__->a]~SortBy~{StringLength}&

Anonymous function. Takes a string as input and returns a string as output.

This doesn't seem to work on example 6 — ~SortBy~StringLength sorts strings alphabetically if their lengths are the same...

@LegionMammal978 The shorter fix is keep SortBy and wrap StringLength in a list to get a stable sort.

JavaScript (ES6), 70 bytes
s=>s.replace(s.match(/(.+)(?=\1)/g).reduce((p,c)=>c[p.length]?c:p),'')

Test cases

let f =

s=>s.replace(s.match(/(.+)(?=\1)/g).reduce((p,c)=>c[p.length]?c:p),'')

console.log(f("hello hello world"))
console.log(f("foofoo"))
console.log(f("aaaaa"))
console.log(f("ababcbc"))
console.log(f("Sometimes it happens that while typing a sentence, I am distracted and I end up typing the same couple of words twice couple of words twice in succession."))

Fails on aaaabaaab, but nice use of reduce.

This should be a comment, but I don't have enough reputations to comment. I just want to tell @Neil that his code can be reduced to 77 bytes. You don't need to use forward assertion in regex. Here is reduced version:
s=>s.replace(/(.+)\1/g,(_,m)=>(n=m.length)>l&&(l=n,r=m),l=0)&&s.replace(r,'')

Hello, and welcome to PPCG! You can submit this as your own JavaScript  answer! If you'd like, I can edit your post and show you how it should look.

I need to use the forward assertion to deal with the case of overlapping matches. aabab is the shortest example of where your suggestion fails.

C#, 169 bytes
(s)=>{var x="";for(int i=0;i<s.Length-2;i++){for(int l=1;l<=(s.Length-i)/2;l++){var y=s.Substring(i,l);if(s.Contains(y+y)&l>x.Length)x=y;}}return s.Replace(x+x,x);}

Explanation
(s) => {                // Anonymous function declaration
    var x = "";         // String to store the longest repeating substring found
    for (int i = 0; i < s.Length - 2; i++) {               // Loop through the input string
        for (int l = 1; l <= (s.Length - i) / 2; l++) {    // Loop through all possible substring lengths
            var y = s.Substring(i, l);
            if (s.Contains(y + y) & l > x.Length) x = y;   // Check if the substring repeats and is longer than any previously found
        }
    }
    return s.Replace(x + x, x);    // Perform the replacement
}

This is the brute-force approach: try every possible substring until we find the longest repeating substring. Undoubtedly Regex is more efficient, but dealing with Regex in C# tends to be quite verbose.

Welcome to PPCG! All answers need to be either full programs or callable functions, not sure snippets with inputs in hardcoded variables. Also, please show the version of the code that you actually counted with all unnecessary whitespace removed. You can always include the more readable version with indentation in addition to the fully golfed one.

PHP, 84 82 bytes
Note: uses IBM-850 encoding.
for($l=strlen($argn);--$l&&!$r=preg_filter("#(.{0$l})\g-1#",~█╬,$argn,1););echo$r;

Run like this:
echo 'hello hello world' | php -nR 'for($l=strlen($argn);--$l&&!$r=preg_filter("#(.{0$l})\g-1#",~█╬,$argn,1););echo$r;';echo
> hello world

Explanation
for(
  $l=strlen($argn);   # Set $l to input length.
  --$l   &&           # Decrement $l each iteration until it becomes 0.
  !$r=preg_filter(    # Stop looping when preg_filter has a result
                      # (meaning a successful replace).
    "#(.{0$l})\g-1#", # Find any character, $l times (so the longest
                      # match is tried first), repeated twice.
    ~█╬,              # Replace with $1: first capture group, removing the
                      # duplicate.
    $argn,
    1                 # Only replace 1 match.
  );
);
echo$r;               # Print the result of the (only) successful
                      # search/replace, if any.

Tweaks

Saved 2 bytes because there is no minimum length of the repeated substring

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Find the frequency of triplets in a phrase
For context, this problem is based on a old chat-bot project I did.
Problem:
Given a string of words containing any of the characters:
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"

Find the frequency of each triplet of words. All non-alphanumeric characters should be ignored, and input/output will be case-insensitive.
For this challenge, the "triplets" of a phrase are each consecutive chunk of 3 words along the string.
For example, in the string
"Oh hi there guy. What's up? Oh hi there."

The "triplets" of the string are
[["oh", "hi", "there"], ["hi", "there", "guy"], ["there", "guy", "whats"], ["guy", "whats", "up"],
 ["whats", "up", "oh"], ["up", "oh", "hi"], ["oh", "hi", "there"]]

The frequency of each triplet is 1, except for ["oh", "hi", "there"], which appears twice.
Input
Input will be a string of space-delimited "words" that may contain any of the characters mentioned above. Although punctuation is to be ignored, it must be handled.
You can assume the input will always contain at least 3 words, and that there won't be consecutive whitespace.
Output
Output can be anything that shows the frequency of each triplet.
For the string "Oh hi there guy.", possible outputs could be:
{"oh hi there":1, "hi there guy":1}

["oh hi there", 1, "hi there guy", 1]

"oh hi there|1 hi there guy|1"
            ^ Or any other delimiter

Test Cases (Output order doesn't matter):
"Oh hi there guy. What's up? Oh hi there."
{["oh" "hi" "there"] 2,
 ["hi" "there" "guy"] 1,
 ["there" "guy" "whats"] 1,
 ["guy" "whats" "up"] 1,
 ["whats" "up" "oh"] 1,
 ["up" "oh" "hi"] 1}

"aa aa aa aa"
{["aa" "aa" "aa"] 2}

"aa bb a bb a bb a cc a bb a"
{["aa" "bb" "a"] 1,
 ["bb" "a" "bb"] 2,
 ["a" "bb" "a"] 3,
 ["bb" "a" "cc"] 1,
 ["a" "cc" "a"] 1,
 ["cc" "a" "bb"] 1}

"99 bottles of beer"
{["99" "bottles" "of"] 1,
 ["bottles" "of" "beer"] 1}

"There are two main types of chatbots, one functions based on a set of rules, and the other more advanced version uses artificial intelligence. The chatbots based on rules, tend to be limited in functionality, and are as smart as they are programmed to be. On the other end, a chatbot that uses artificial intelligence, understands language, not just commands, and continuously gets smarter as it learns from conversations it has with people."
{["main" "types" "of"] 1,
 ["rules" "and" "the"] 1,
 ["of" "chatbots" "one"] 1,
 ["to" "be" "limited"] 1,
 ["artificial" "intelligence" "understands"] 1,
 ["it" "has" "with"] 1,
 ["chatbots" "based" "on"] 1,
 ["smarter" "as" "it"] 1,
 ["the" "chatbots" "based"] 1,
 ["other" "more" "advanced"] 1,
 ["commands" "and" "continuously"] 1,
 ["chatbots" "one" "functions"] 1,
 ["tend" "to" "be"] 1,
 ["a" "chatbot" "that"] 1,
 ["continuously" "gets" "smarter"] 1,
 ["advanced" "version" "uses"] 1,
 ["functionality" "and" "are"] 1,
 ["are" "two" "main"] 1,
 ["based" "on" "rules"] 1,
 ["on" "a" "set"] 1,
 ["there" "are" "two"] 1,
 ["the" "other" "more"] 1,
 ["just" "commands" "and"] 1,
 ["the" "other" "end"] 1,
 ["that" "uses" "artificial"] 1,
 ["based" "on" "a"] 1,
 ["limited" "in" "functionality"] 1,
 ["smart" "as" "they"] 1,
 ["are" "as" "smart"] 1,
 ["from" "conversations" "it"] 1,
 ["other" "end" "a"] 1,
 ["intelligence" "the" "chatbots"] 1,
 ["functions" "based" "on"] 1,
 ["in" "functionality" "and"] 1,
 ["intelligence" "understands" "language"] 1,
 ["chatbot" "that" "uses"] 1,
 ["more" "advanced" "version"] 1,
 ["gets" "smarter" "as"] 1,
 ["rules" "tend" "to"] 1,
 ["on" "rules" "tend"] 1,
 ["as" "it" "learns"] 1,
 ["are" "programmed" "to"] 1,
 ["and" "the" "other"] 1,
 ["understands" "language" "not"] 1,
 ["and" "are" "as"] 1,
 ["of" "rules" "and"] 1,
 ["has" "with" "people"] 1,
 ["end" "a" "chatbot"] 1,
 ["set" "of" "rules"] 1,
 ["and" "continuously" "gets"] 1,
 ["as" "they" "are"] 1,
 ["they" "are" "programmed"] 1,
 ["as" "smart" "as"] 1,
 ["two" "main" "types"] 1,
 ["a" "set" "of"] 1,
 ["uses" "artificial" "intelligence"] 2, # <----- 2 Here
 ["it" "learns" "from"] 1,
 ["be" "limited" "in"] 1,
 ["programmed" "to" "be"] 1,
 ["types" "of" "chatbots"] 1,
 ["conversations" "it" "has"] 1,
 ["one" "functions" "based"] 1,
 ["be" "on" "the"] 1,
 ["not" "just" "commands"] 1,
 ["version" "uses" "artificial"] 1,
 ["learns" "from" "conversations"] 1,
 ["artificial" "intelligence" "the"] 1,
 ["to" "be" "on"] 1,
 ["on" "the" "other"] 1,
 ["language" "not" "just"] 1}

Your submission can be a function or full program, and can take input via stdin, or as an argument. It may output by returning, or printing to the stdout.
This is code golf, so the shortest number of bytes wins.

Should digits be removed or retained in the output?

Retained. Note the 4th test case. Do I have contradictory information somewhere? I changed that from when it was in the sandbox. Might have missed updating something.

Nevermind, overlooked that test case.

Are repeated spaces ever going to occur in the input, and if so how should they be treated? (At least one current solution would parse "spam  eggs  ham" (with double spaces, which markdown removes) as ["spam", "", "eggs", "", "ham"] and at least one as ["spam", "eggs", "ham"])

You can assume consecutive spaces won't exist. Updated input specification.

Given that you are not lost in another planet: do you think that 10 out of 13 answers do not even deserve an upvote?

@edc65 I've worked the past 2 nights, while dealing with an infected wisdom tooth, while packing for a trip. I glanced down the answers, which is why I commented on yours. Once I have a sec I'll go over and check and upvote the answers I can.

@edc65 Unless everyone needs exactly 10 rep now, I didn't think it would be an issue.

Of course it won't. Seeing so many answers with no feedback just gives a bad feeling. Best wishes for a speedy recovery

@edc65 Thanks. I should have internet on my computer tonight when I get to the hotel, so I'll go over them then. I'm low on data so I don't want to push my luck on the way there.

Jelly, 18 13 bytes
ŒlḲf€ØBṡ3ṢŒr'

A monadic link (function) that returns a list, each entry contains a list of 3 lists of characters (the words) and a count.
Try it online! - the footer formats the results (as a full program everything just gets smushed together by the implicit print).
How?
ŒlḲf€ØBṡ3ṢŒr' - Main link: s
Œl            - convert s to lowercase
  Ḳ           - split on spaces
     ØB       - base digit yield "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
   f€         - filter keep for €ach
       ṡ3     - all overlapping slices of length 3
         Ṣ    - sort
            ' - call the previous monadic link without vectorising
          Œr  -     run length encode

Perl 6,  67  57 bytes
*.words.map({[~] .lc.comb(/\w/)}).rotor(3=>-2)».join(' ').Bag.perl

Try it
*.words.rotor(3=>-2).map({lc S:g/<-:L-:N-:Z>//}).Bag.perl

Try it
Expanded:
*\                # WhateverCode lambda (this is the parameter)
.words            # get a list of words
.rotor( 3 => -2 ) # grab 3, back up 2, repeat

.map({            # take those list of 3 elements

  lc              # lower case the following

  S               # remove
  :global         # globally
  /
    <- :L         # not a letter
     - :N         # not a number
     - :Z         # not a space  (inserted when the current list is stringified)
    >
  //

})
.Bag              # turn it into a Bag
.perl             # return the structure as an `EVAL`able Str

returns something like
("bb a cc"=>1,"aa bb a"=>1,"a cc a"=>1,"a bb a"=>3,"bb a bb"=>2,"cc a bb"=>1).Bag

Retina, 50 bytes
T`lLd p`lld _
M!&`(\b\w+ ??){3}
O`
$
¶
D`
¶+
:$.&¶

Try it online!
Explanation
T`lLd p`lld _

Replace all uppercase letters with lowercase ones, keep other letters, digits and spaces unchanged and delete other characters.
M!&`(\b\w+ ??){3}

Find all possible matches of three words in a row.
O`

Sort the matches, so equal triplets end next to each other.
$
¶

Add a newline at the end.
D`

Remove duplicate lines (this will keep the newlines at the end of them).
¶+
:$.&¶

Sequences of newlines are now the counts we need, replace them with a delimiter (:) followed by the count and a newline.

T\w p`_dll _` saves a byte.

Ruby, 60 bytes
-1 byte thanks to Kevin Cruijssen
->s{s.upcase.gsub(/[^A-Z0-9 ]/,'').split.each_cons(3).tally}

Attempt This Online!

This fails on the first test case due to punctuation.

@chunes Ah, good catch. I’ve updated my answer(s).

You need to convert them to lowercase. The example test case of Oh hi there guy. What's up? Oh hi there. is incorrect right now. (You also seem to split incorrectly, since what and s are separated items. You only need to split on spaces, but remove all other non-alphanumeric characters.)

@KevinCruijssen It should be correct now. Please excuse me while I remove "attention to detail" from my résumé.

@Jordan Seems to be correct now; +1 from me. :) You can save a byte by doing the upcase before the gsub (with A-Z instead of a-z), so you don't need the case-invariant regex-flag i.

@KevinCruijssen Nice catch. Thanks!

Bash + Unix utilities, 117 bytes
s=[^\ ]*
p=s/^$s\ //
tr A-Z a-z|tr -cd \ a-z0-9|sed "p;$p;p;$p"|sed "s/\($s $s $s\) /\1\n/g"|grep ' .* '|sort|uniq -c

Try it online!
Input on stdin, output on stdout.
Sample run:
Input:
Oh hi there guy. What's up? Oh hi there.

Output:
      1 guy whats up
      1 hi there guy
      2 oh hi there
      1 there guy whats
      1 up oh hi
      1 whats up oh

JavaScript (ES6), 124
s=>s.toLowerCase().replace(/\S+/g,x=>t.push(x.replace(/[\W_]/g,''))>2&&(k[t]=-~k[t],t.shift()),t=[],k={})&&JSON.stringify(k)

Note that the output shows  the frequency of each triplet, as requested. If the output could just contain the frequency data in a machine usable format, I could save 16 bytes of JSON.stringify()
Less golfed
s => {
   s = s.toLowerCase() // force to lowercase
   t = [] // init current group (or triplet)
   k = {} // init frequency list
   s.replace(/\S+/g, x => ( // execute for each sequence of non space chars
     x = x.replace(/[\W_]/g,''), //remove non alphanumeric chars
     t.push(x) > 2 // add to end of current group
     && (          // if there are 3 elements in group (it's a triplet)
       k[t] = -~k[t], // add to frequency list incrementing count
       t.shift() // remove first element of current group
     )
   )
   return JSON.stringify(k) // return in human readable format
}

Test

let F=
s=>s.toLowerCase().replace(/\S+/g,x=>t.push(x.replace(/[\W_]/g,''))>2&&(k[t]=-~k[t],t.shift()),t=[],k={})&&JSON.stringify(k)

;["Oh hi there guy. What's up? Oh hi there."
,"aa aa aa aa"
,"aa bb a bb a bb a cc a bb a"
,"99 bottles of beer"
,"There are two main types of chatbots, one functions based on a set of rules, and the other more advanced version uses artificial intelligence. The chatbots based on rules, tend to be limited in functionality, and are as smart as they are programmed to be. On the other end, a chatbot that uses artificial intelligence, understands language, not just commands, and continuously gets smarter as it learns from conversations it has with people."]
.forEach(t=>{
  O.textContent += t + '\n'+ F(t).replace(/,"/g,'\n"')+'\n\n'
})

A JSON should be an acceptable output unless it contains a bunch of other irrelevant data.

@Carcigenicate JSON is a way to encode data in a stream of characters, and it' human readable. And JSON is exactly the output right now, and as you can see, it only contains relevant data.

CJam, 25 bytes
qel"␡{a:0!":,:^-S/3ew$e`p

␡ represents a Delete character (ASCII 127).
Try it online!
Explanation
q                          Read all input
 el                        Convert it to all lowercase
   "␡{a:0!"                Push this string
           :,              Map each character in the string to the range of chars up to,
                            but excluding it
             :^            Reduce the array of ranges with symmetric set differences
                           The result will be an array containing all disallowed characters
               -           Remove all instances of these characters from the input
                S/         Split the input on spaces
                  3ew      Take overlapping slices of length 3
                     $     Sort them
                      e`   Take the run-length encoding
                        p  Print it

Mathematica, 75 bytes
Tally@Partition[ToLowerCase@#~StringSplit~RegularExpression@"[_\\W]+",3,1]&

Pure function taking a string as input and returning a list of ordered triples of strings together with their number of appearances. For example, on the input "aa bb a bb a bb a cc a bb a" the output is {{{"aa", "bb", "a"}, 1}, {{"bb", "a", "bb"}, 2}, {{"a", "bb", "a"}, 3}, {{"bb", "a", "cc"}, 1}, {{"a", "cc", "a"}, 1}, {{"cc", "a", "bb"}, 1}}. The expression RegularExpression@"[_\\W]+" recognizes all runs of one or more non-word characters (that's what \\W does, except it calls _ a word character whereas we don't want to). ToLowerCase@#~StringSplit~ then splits the input string at all of those runs, after converting all letters to lowercase. Partition[...,3,1] partitions the resulting list into all triples of consecutive words, and Tally does exactly what we want to that list of triples.

The string shouldn't be split around non-word characters but only around spaces. Other non-word characters should simply be deleted. See e.g. the test case containing What's.

StringSplit splits around spaces by default.

JavaScript (ES6), 200 198 187 bytes
(-2 bytes thanks to Luke)
(-11 bytes thanks to edc65)
H=(h,k=[],i=0)=>i+2<(z=h.toLowerCase().replace(/[^\w ]|_/g,'').split` `).length?H(h,k.concat(z.slice(i,i+3)+''),-~i):new Set(k.map(a=>a+':'+k.filter(b=>b==a).length)).forEach(m=>alert(m))

A recursive solution. Takes input as a single string and outputs dialog boxes containing each triplet's count in the format <Triplet>:<Count>. As always, golfing tips are greatly appreciated.
Test Snippet

H=(h,k=[],i=0)=>i+2<(z=h.toLowerCase().replace(/[^\w ]|_/g,'').split` `).length?H(h,k.concat(z.slice(i,i+3)+''),-~i):new Set(k.map(a=>a+':'+k.filter(b=>b==a).length)).forEach(m=>alert(m))
<input type="text" id="i" value="Oh hi there guy._ What's up? Oh hi there."></input>
<input type="button" value="Submit" onclick="H(document.getElementById('i').value)"></input>

split(" ") can become split\`. I don't really understand your Regex. Don't you want to replace /\W|_/(anything that is (not a word character) or (an underscore))? The.forEach()at the end can probably be replaced bymap()`.

@Luke About the Regex, I also don't want to replace spaces (which are apparently referred to as non-word characters) so I can use .split(" ") on the result. As for your map() advice, the Set() object does not seem to have Set.prototype.map() defined according to Set.prototype, so that won't work. Still, thanks for your first tip.

[z[i],z[i+1],z[i+2]].join' ' -> z[i]+' '+z[i+1]+' '+z[i+2], but I don't see a reason to use a space to separate words, so why not z.slice(i,i+3)+''

@edc65 Because I am just starting out with JavaScript and did not really know/remember that built-in existed. Anyways, thanks for the tip! :)

Python 2, 164 159 bytes
s=filter(lambda k:k.isalnum()or k==' ',input()).lower().split()
k=[tuple(s[i:i+3])for i in range(len(s)-3)]
l={}
for i in k:l[i]=l[i]+1if i in l else 1
print l

Not a really great solution, I know. Pretty straightforward.
Thanks to @ovs for saving 5 bytes overall.

Some improvements: ' ' is the default parameter of split, you don't need the newline and tab after for and you can replace your conditional expression with l[i]=l.get(i,0)+1 Tio

@ovs Oh, nice. I didn't notice. Thanks!

Java 8, 376 372 bytes
import java.util.*;public interface T{static void main(String[]k)throws Exception{String s="";int c;while((c=System.in.read())>10)if(c==32|(""+(char)c).matches("[A-Za-z]"))s+=(char)c;k=s.toLowerCase().split(" ");Map<String,Integer>o=new HashMap<>();for(int i=0;i<k.length-2;i++){s=k[i]+" "+k[i+1]+" "+k[i+2];o.put(s,(o.containsKey(s)?o.get(s):0)+1);}System.out.print(o);}}

Ungolfed:
import java.util.HashMap;
import java.util.Map;

public interface T {
    static void main(String[] k) throws Exception {
        String s = "";
        int c;
        while ((c = System.in.read()) > 10)
            if (c == 32 | ("" + (char) c).matches("[A-Za-z]"))
                s += (char) c;
        k = s.toLowerCase().split(" ");
        Map<String, Integer> o = new HashMap<>();
        for (int i = 0; i < k.length - 2; i++) {
            s = k[i] + " " + k[i + 1] + " " + k[i + 2];
            o.put(s, (o.containsKey(s) ? o.get(s) : 0) + 1);
        }
        System.out.print(o);
    }
}

Never use Java for actual golfing.
EDIT: Saved 4 bytes by abusing the fact that the main method has a String[] as its parameter so I don't have to initialize one >:-)

I'm getting 376 bytes still. I think you forgot to update your code. (String[]a->String[]k and delete ,k[])

@CAD97 oh whoops, you're right. That was stupid. Thanks!

Submitting this as a lambda Function<String, String> that takes s as input and returns o.toString() should be shorter by a lot of bytes. So import java.util.*; & s->{String[]k=s.toLowerCase().split(" "); etc.

Python 3, 151 149 bytes
s="".join(c for c in input()if c.isalnum()or c==" ").lower().split()
k=[tuple(s[i:i+3])for i in range(len(s)-2)]
print(*((x,k.count(x))for x in{*k}))

Try it online!

05AB1E, 23 20 bytes
žLðìÃ#Œ3ù©Ùvyðý®y¢‚ˆ

Try it online!
Explanation
žL                    # push a string of alphanumeric characters
  ðì                  # prepend a space
    Ã                 # keep only those characters from input
     #                # split on spaces
      Œ3ù             # get all sublists of length 3
         ©            # save a copy in register
          Ù           # remove duplicates
           v          # for each unique triplet
            yðý       # join the triplet by spaces
               ®y¢    # count the triplets occurrences in the list saved to register
                  ‚   # pair the string with the count
                   ˆ  # push it to global list
                      # output global list at the end of the program

žLðìÃ# to #žLδÃ for -1; Œ3ù to ü3 for -1; vyðý®y¢‚ˆ to ε®y.¢‚ for -3: 15 bytes - try it online. Although a port of the Jelly answer resulted in 12 bytes. And I didn't knew the global array was output implicitly if something was added to it in the ancient version of 05AB1E.

Python, 143 bytes
lambda s:Counter(tuple(''.join(filter(str.isalnum,w))for w in s.lower().split())[i:i+3]for i in range(s.count(' ')-1))
from collections import*

Try it online!
Unnamed function which returns a dictionary (specifically a Counter object) which has keys that are tuples of the triples (in the correct order) and values that are their counts.

You can assume multiple consecutive spaces won't exist.

Thanks; best to update the question to specify this I think.

will do. I literally just woke up though.

R, 114 bytes
x=readline();y=strsplit(tolower(gsub('[[:punct:]]','',x)),' ')[[1]];s=3:length(y);table(paste(y[s-2],y[s-1],y[s]))

Reads input, removes punctuation, splits it into words and counts triplets.

J-uby, 58 bytes
-1 byte thanks to Kevin Cruijssen
:upcase|~:gsub&''&/[^A-Z0-9 ]/|:split|~:each_cons&3|:tally

Attempt This Online!

05AB1E, 12 bytes
#žLδÃlü3{Åγø

Port of @JonathanAllan's Jelly answer, so make sure to upvote him as well.
Try it online or verify all test cases.
Explanation:
#             # Split the (implicit) input-string by spaces
   δ          # Map over each word:
    Ã         #  Only keep all
 žL           #  alphanumeric characters (a-zA-Z0-9) of the word
     l        # Convert everything to lowercase
      ü3      # Convert it to a list of overlapping triplets
        {     # Sort this list of triplets
         Åγ   # Run-length encode it, resulting in a list of triplets and list of counts
              # pushed separately to the stack
           ø  # Pair the items in the two lists together
              # (after which the result is output implicitly)

Vyxal, 8 bytes
⇩⌈krF3lĊ

Try it Online!
Outputs a list of ⟨ triplet | count ⟩
Explained
⇩⌈krF3lĊ
⇩⌈         # Split the lowercase input on spaces
  krF      # remove all non-alphabet/non-number characters and keep only strings with alphabet letters
     3l    # group into windows of 3
        Ċ  # get the count of each triplet.

Your program currently only keeps letters instead of alphanumeric characters (99 bottles of beer test case fails).

@KevinCruijssen despite seeing the word "alphanumeric" in the post, I somehow managed to completely miss the "numeric" part :p (fixed now)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Convert singular to plural
There are two forms of nouns, singular and plural. The conversion between these two is quite easy.

Normally, you end it with s. ex. car => cars.

If it ends with s,x,z,ch or sh, end it with es. ex. bus=>buses.

If it ends with y with a consonant just before it, change the y to ies. ex. penny => pennies.

If it ends with f or fe, change it to ves. ex. knife => knives.

If it ends with o with a consonant just before it, change it to oes. ex.potato => potatoes.

Task
You will be given a singular noun. You have to convert the given noun to plural and output it.

Rules

You will not be given irregular nouns, like mouse and moose.

You will not be given exceptions, such as safe (safes; violating #4), piano (pianos; violating #5) and o (oes, violating #5).

You will not be given words which have two or more possible plural forms, such as mosquito (mosquitos or mosquitoes) and roof (roofs or rooves).

You will not be given uncountable nouns.

y doesn't count as a vowel.

Examples
car => cars
bus => buses
potato => potatoes
knife => knives
penny => pennies
exception => exceptions
wolf => wolves
eye => eyes
decoy => decoys
radio => radios

Edited question for clarity. Feel free to rollback.

Ahh, English - a huge pile of arbitrary rules and special cases :)

@Challenger5 Yep, but you can understand it through tough thorough thoughts, though. ;)

@MatthewRoh I've edited the consonant in front rule to make it clearer. Also added a couple of test cases for the same. If I've misunderstood, please edit it to clarify.

Do we need to handle o => os or oes?

@DLosc It's stated in Rule 5. o=>oes.

@Challenger5 If you compare English to Dutch there are barely any rules at all.. Dutch has rules and special cases, and special cases contradicting those special cases, and in some cases even special cases that contradict those special cases that those special cases contradict. ;)

I guess excluding proper nouns?

@KevinCruijssen you guys should see French...

@Quentin Yeah, French is a pain as well.. ;) I was glad I could drop the subject when I went to the fourth class in high school.. Always had around a 5 for French and German.. I kinda suck with languages (although I had an 8 for Dutch and English classes..) Ah, the memories.. XD

Mathematica, 9 bytes
Pluralize

Yes, there is a built-in for this!
Sample output
Pluralize["car"]

cars

Pluralize /@ {"bus", "potato", "knife", "penny", "exception", "wolf", "eye"}

{"buses", "potatoes", "knives", "pennies", "exceptions", "wolves", "eyes"}

Waaaaaat! Is there something Mathematica has no built-in for?

D: Builtins have attacked this challenge too

@KeyWeeUsr https://codegolf.stackexchange.com/a/71680/56033

Retina, 57 53 56 55 58 57 bytes
Thanks to MartinEnder for some golfing suggestions
Thanks to BusinessCat for golfing 1 byte
([^aeiou]o|sh?|ch|z|x)$
$1e
fe?$
ve
([^aeiou])y$
$1ie
$
s

Try it online!
Explanation (outdated)
([^aeiou])y$
$1ie

Changes {consonant}y to {consonant}ie
([^aeiou]o|[fxzs]|[sc]h)$
$&e

Appends an e to when the word ends with an {consonant}o, f,x,z,s,sh or ch.
fe$
ve

Changes an ending fe to ve
$
s

Finally append an s to the word.
Edits

Added bytes because I forgot the second rule
Added bytes to update with eye as an example

Sorry if this is a stupid question, I've not used Retina. Why are the round brackets needed in the first line?

Never mind, I think I've answered my own question. It's because of the lookback reference in the following line.

Yeah, it's because we want to capture the character before the y using $1

I think I got it in 57 bytes: Try it online

JavaScript (ES6),  109  97 bytes
s=>s[R='replace'](/([^aeiou])y$/,'$1ie')[R](/fe?$/,'ve')[R](/([^aeiou]o|[sxz]|[cs]h)$/,'$1e')+'s'

Try it online!

Why do you have a () in front of fe?

@KodosJohnson All replace() iterations include a reference to the first matching group (with $1). That's why I need an empty matching group here.

Have you tried (?<![aeiou])y?

@Titus Unfortunately, JS doesn't implement lookbehind assertions.

Batch, 325 bytes
@set/ps=
@for %%v in (a e i o u)do @(
for %%e in (o y)do @if %s:~-2%==%%v%%e goto s
if %s:~-2%==%%vf set s=%s:~,-1%ve&goto s
if %s:~-3%==%%vfe set s=%s:~,-2%ve&goto s
)
@if %s:~-1%==y set s=%s:~,-1%ie
@for %%e in (o s x z)do @if %s:~-1%==%%e set s=%s%e
@for %%e in (c s)do @if %s:~-2%==%%eh set s=%s%e
:s
@echo %s%s

What about @echo off at the beginning rather than @ everywhere? Also, @set/ps= seems a little bit rusty from a phone. Won't the s variable accept the slicing values anyway?

@KeyWeeUsr @echo off is already 9 bytes without the newline, so it doesn't save me anything. Also, @set/ps= is needed to input the value in the first place.

Haskell, 216 207 205 bytes
Thanks to @Lynn, @user1472751 and @Laikoni for the help!
import Data.List
(!)s=or.map(\x->x`isSuffixOf`s)
c=['b'..'z']\\"eiou"
p s|s!(words"s x z ch sh"++map(:"o")c)=s++"es"|s!map(:"y")c=init s++"ies"|s!["f"]=init s++"ves"|s!["fe"]=(init.init)s++"ves"|0<1=s++"s"

Readable
import Data.List;

endsWithOneOf :: String -> [String] -> Bool
endsWithOneOf str ends = (or . map (\end -> end `isSuffixOf` str)) ends

consonants :: [Char]
consonants = ['a'..'z'] \\ "aeiou"

pluralize :: String -> String
pluralize str
    | str `endsWithOneOf` (words "s x z ch sh" ++ (map (:"o") consonants)) = str ++ "es"
    | str `endsWithOneOf` (map (:"y") consonants) = init str ++ "ies"
    | str `endsWithOneOf` ["f"] = init str ++ "ves"
    | str `endsWithOneOf` ["fe"] = (init.init) str ++ "ves"
    | otherwise = str ++ "s"

Explanation
import Data.List for the function isSuffixOf.
endsWithOneOf (€ in the golfed version) returns whether one of the list elements is an ending of the string.
consonants(c) is just a list of all consonants.
Finally, pluralize(p) checks for the endings and returns the proper pluralization.
Example:
p "potato" == "potatoes"

Nice solution!
This is 216 characters, but € is multiple bytes long, making your solution 226 bytes. (Code golf challenges are explicitly scored in bytes, because counting characters lets you cheat sometimes.) You can just rename it to !, though!
Also, words"s x z ch sh" saves 5 bytes. Removing parens around (map(:"o")c)) and (map(:"y")c)) saves 4 more.

Thanks for the help, @Lynn! I implemented your suggestions.

You can save one byte by using c=['b'..'z']\\"eiou" since 'a' is always removed.

0<1 is one byte shorter than True. Also newlines are the same byte count as ; but make the golfed code a bit better readable.

PHP, 103 100 bytes
<?=preg_replace(['/([^aeiou]o|sh?|x|z|ch)$/','/(?<![aeiou])y$/','/fe?$/'],['\1e',ie,ve],$argv[1]).s;

Try it online!
The preg_replace function takes in an array of patterns and replacements.

Saved 2 bytes thanks to Titus.
Saved 1 byte thanks to Dewi Morgan.

I think You can save one byte with -R and $argn. And using an assertion with y saves two: (?<![aeiou])y$ allows ie as replacement: no  \1, no quotes.

Another byte from ([^aeiou]o|sh?|x|z|ch)$

@Titus Actually it looks like there is a 1 byte penalty for using -R (but not -r) so that doesn't change the byte count, unfortunately. But the lookbehind suggestion works great. Thanks.

Röda, 80 bytes
f&s{s~="([^aeiou])y$","$1ie","([sxz]|[cs]h|[^aeiuo]o)$","$1e","fe?$","ve"s.="s"}

The function modifies its argument. Usage: main word { f word; print word } Here's a version that uses a return value (83 bytes):
f s{s~="([^aeiou])y$","$1ie","([sxz]|[cs]h|[^aeiuo]o)$","$1e","fe?$","ve";[s.."s"]}

And below is a function that reads infinitely many values from the input stream and pushes plural forms to the output stream (87 83 bytes):
{replace"([^aeiou])y$","$1ie","([sxz]|[cs]h|[^aeiuo]o)$","$1e","fe?$","ve","$","s"}

It's an anonymous function, as that is shorter than creating a named function.

How do you get to display the result of the first function (the one starting with f&s)? Simply f("word") doesn't seem to display anything

@KritixiLithos The parameter is a reference, so the argument must be a variable.

Perl, 66 + 2 (-pl flag) = 68 bytes
$_.=/(ch|sh?|x|z|[^aeiou]o)$/+s/([^aeiou])y$/$1i/+s/fe?$/v/?es:"s"

Using:
perl -ple '$_.=/(ch|sh?|x|z|[^aeiou]o)$/+s/([^aeiou])y$/$1i/+s/fe?$/v/?es:"s"' <<< car

Try it on Ideone.

Python 3, 271 239 199 bytes
Thanks to @ovs for reducing it by 72 bytes!
lambda s,v="aeiou":(s[-2:]=="fe"and s[:-2]+"ve"or s[:-1]+((s[-1]=="y"and s[-2]not in v)*"ie"or s[-1]=="f"and"ve"or s[-1]+((s[-1]in"sxz"or s[-2:]in["ch","sh"])+(s[-1]=="o"and s[-2]not in v))*"e"))+"s"

Try it online!

You can remove some unnecessary whitespaces and combine the first and last elif. The single character lists can be replaced by strings. Switching to python saves additional 3 bytes. tio

@ovs Done, thanks! I didn't combine the elifs however, because that means potato becomes potaties.

I looked in the wrong line ;). You can combine the if with the last elif. To save some more bytes replace the last line with print(s+"s") and remove the else case as well every s you are appending to the word. Tio

When you replace your if/elif logic with and/* and or/+ and make an unnamed lambda function you can get it under 200 bytes (I swapped the cases a little bit)

@ovs Ooh, that print(s+"s") is clever. All changed; you pretty much rewrote the whole thing lol. Thanks! (I didn't even know you could do True and "string" like that)

Python 3, 131 125 118 121 bytes
Thanks to The Thonnu for -6 bytes!Golfed 7 bytes!Fixed an issue for +3 bytes!
lambda x:S("([sc]h?|x|z)$","\\1e",S(V+"y$","ie",S("fe?$","ve",S(V+"o$","oe",x))))+"s"
import re;S,V=re.sub,"(?<![aeiou])"

Try it online!
My first submission on here! Let me know if I did anything wrong.

Hi there, welcome to code golf! Very impressive first answer!

Welcome to Code Golf, and amazing first answer! You can save 5 bytes by assigning re.sub to a variable: Try it online!

And you can save another one by assigning the regex for a consonant to a variable: Try it online!

@The Thonnu Thanks a lot!

@lyxal Thank you!

All of the replacements end with e, there has to be some way to golf that...

sed, 70 79 bytes
69 78 + 1 for -E (BSD)/-r (GNU) flag
s/([^aeiou])y$/\1ie/
s/([^aeiou]o|[fxzs]|[sc]h)$/&e/
s/fe/ve/
s/$/s/

Direct port of the retina answer.

Pip, 63 61 bytes
Y`[^aeiou]`OaR[C`sh?|x|z|ch`Cy.'y`fe?`y.'o].'$[_B.'i'v_].'e's

So close to catching Retina! But it's probably not going to happen. :(
Try it online!
Explanation
Basic strategy: Replace performs several replacements one after the other when given lists of patterns and replacements. We want to make the following replacements:

(sh?|x|z|ch)$ -> add an e
[^aeiou]y -> change the y to i and add an e
fe? -> change to v and add an e
[^aeiou]o -> add an e

Then we want to tack on an s regardless.
Tricks:

The C operator, given a regex, wraps it in a capturing group; C`xyz` is one byte shorter than `(xyz)`.
A list of regexes or replacements that all end with the same character can be created by concatenating the character to the list instead of including it in all the items. Concatenating a Scalar (string) to a Pattern (regex/replacement) coerces to a Pattern.
Instead of concatenating the s (and having to deal with the precedence ordering of R and .), we can simply Output the main part of the word and then print the s separately.

Spaced and commented code:
                  a is 1st cmdline input (implicit)
Y`[^aeiou]`       Yank the consonant regex into the y variable
O a R             Output (without newline): a, with the following replacements:
 [                List of regexes to replace:
  C `sh?|x|z|ch`    (sh?|x|z|ch)
  Cy . 'y           ([^aeiou])y
  `fe?`             fe?
  y . 'o            [^aeiou]o
 ] . '$           End of list; concatenate $ to each item
 [                List of replacements:
  _                 Identity function (replace with whole match)
  B                 B is short for {b}, a function returning its second argument; as a
                    callback function for regex replacement, the second argument is
                    the value of capturing group 1 (the consonant before y)
    . 'i            To that, concatenate i
  'v                Scalar literal v
  _                 Identity function
 ] . 'e           End of list; concatenate e to each item
's                Return Scalar literal s, which is autoprinted

C#, 73 163 bytes:
Func<string,string>p=System.Data.Entity.Design.PluralizationServices.PluralizationService.CreateService(System.Globalization.CultureInfo.CurrentCulture).Pluralize

Yes, another language with it built-in (although you need to add a reference to System.Data.Entity.Design.dll)
To use:
var words = new[] { "car", "bus", "potato", "knife", "penny", "exception", "wolf", "eye", "decoy", "radio" };
foreach (var word in words)
{
    var plural = p(word);
    Console.Out.WriteLine($"{word} => {plural}");
}

Output:

car => cars
bus => buses
potato => potatoes
knife => knives
penny => pennies
exception => exceptions
wolf => wolves
eye => eyes
decoy => decoys
radio => radios

Welcome to the site.  How do I run this code?

@WheatWizard updated.  Should I have included more detail (using statements etc) in the byte count?

Interesting bit of trivia, the reverse of this (Singularize) fails quite a few simple test cases. For example, it's convinced the singular of "courses" is "cours".

I think the namespaces needs to be included in this one's byte count, especially given that it's not one of the 'normal' ones. But I think you also need to at least wrap this in a lambda, passing the argument to the method. As is this is just a method group

@pinkfloydx33 better now?

Python 199 187 176 Bytes
lambda s:s+'\bve'*(s[-1]=='f')+'\b\bve'*(s[-2:]=='fe')+'e'*(s[-1]in'sxz'or s[-2:]in('ch','sh')or s[-1]=='o'and s[-2]not in'aiueo')+'\bie'*(s[-1]=='y'and s[-2]not in'aiueo')+'s'

Rails runner, 18 bytes
$><<gets.pluralize

Example:
$ echo knife | rails r filename.rb
knives

Now that's an esoteric language.

Python, 296 bytes
z = input()
if z[-1]in['s','x','z','ch','sh']:print(z+'es')
elif z[-1]=='y'and z[-2]not in['a','e','i','o','u']:print(z[:-1]+'ies')
elif z[-2:]=='fe':print(z[:-2]+'ves')
elif z[-1]=='f':print(z[:-1]+'ves')
elif z[-1]=='o'and z[-2]not in['a','e','i','o','u']:print(z[:-1]+'oes')
else:print(z+'s')

Lexurgy, 102 bytes
Class v {a,e,i,o,u}
p:
*=>es/{s,x,z,ch,zh,!@v o} _ $
y=>ies/!@v _ $
f e?=>ves/_ $
Else:
*=>s/_ $

Ungolfed explanation:
# define vowels
Class vowel {a,e,i,o,u}

plural:
*=>es/{s,x,z,ch,zh,!@vowel o} _ $ # 2,5
y=>ies/!@vowel _ $                # 3
{f,fe}=>ves/_ $                   # 4
Else:                             # Run the rules below if the above rules don't apply
*=>s/_ $                          # 1

Java 7, 408 bytes
Golfed:
boolean b="bcdfghjklmnpqrstvwxyzs".contains(String.valueOf(s.charAt(s.length()-2))); String x=s.substring(0,s.length()-1);if(s.endsWith("s")||s.endsWith("x")||s.endsWith("z")||s.endsWith("ch")||s.endsWith("sh"))return s+"es";if(s.endsWith("y")&&b)return x+"ies";if(s.endsWith("f")) return x+"ves";if(s.endsWith("fe"))return s.substring(0,s.length()-2)+"ves";if(s.endsWith("o")&&b)return s+"es";return s+="s";

Basically testing what the end of the String is and adding / replacing letters depending on what case it is. The boolean and String at the beginning are just for removing repetition in the test cases and making the code smaller.
Readable version:
public static String pluralize(String s){

// Consonant at the 2nd last position?
boolean b = "bcdfghjklmnpqrstvwxyzs".contains(String.valueOf(s.charAt(s.length()-2)));

// Substring for cases where last letter needs to be replaced
String x = s.substring(0,s.length()-1);

if(s.endsWith("s") || s.endsWith("x") || s.endsWith("z") || s.endsWith("ch") || s.endsWith("sh"))
    return s + "es";
if(s.endsWith("y") && b)
    return x + "ies";
if(s.endsWith("f"))
    return x + "ves";
if(s.endsWith("fe"))
    return s.substring(0,s.length()-2) + "ves";
if(s.endsWith("o") && b)
    return s + "es";

return s += "s";
}

You can't use a snippet.

C, 321 bytes
#define E else if(
#define C unsigned char
C*p(C*b){static C r[999],i,w,n,m;for(n=w=i=0;r[i]=b[i];n=w,w=b[i++]);m=!strchr("aeiou",n);if(strchr("sxz",w)||(w=='h'&&strchr("cs",n))||(w=='o'&&m))r[i++]='e';E'y'==w&&m)r[i-1]='i',r[i++]='e';E'f'==w)r[i-1]='v',r[i++]='e';E'f'==n&&w=='e')r[i-2]='v';r[i++]='s';r[i]=0;return r;}

test:
C*mx[]={"car","bus","potato","knife","penny","exception","wolf","eye","decoy","radio",0};

main()
{unsigned i;
 for(i=0;mx[i];++i)
    printf("[%s] [%s]\n", mx[i], p(mx[i]));
 return 0;
}

results:
[car] [cars]
[bus] [buses]
[potato] [potatoes]
[knife] [knives]
[penny] [pennies]
[exception] [exceptions]
[wolf] [wolves]
[eye] [eyes]
[decoy] [decoys]
[radio] [radios]
[radio] [radios]

It should be wolves not wolfves.

@ceilingcat what about "static C r[256],/*Z="aeiou",i=0,w,n;" in the place of "static C r[256];C/*Z="aeiou",i=0,w,n;"?

260 bytes

Direct port of Retina:
Ruby, 111 bytes
'sub(/([^aeiou])y/){"#{$1}ie"};sub(/(.*)([^aeiou]o|[fxzs]|[sc]h)$/){"#{$1}#{$2}e"};sub(/fe/,"ve");sub(/$/,"s")'

Try it online!
Invoke via ruby -lpe and supply a file as input.txt for first CLI argument.

Can probably be more 'golfed'. Btw.: Can one add files to TIO?


text:
Additive Primes amongst first x Primes
Definition of Additive Primes:

Numbers which have exactly 2 divisors are called Prime numbers.
Numbers which are prime and their sum of digits is also a prime number are called Additive Primes

Task:
Given an integer x, compute all the additive primes amongst the first x prime numbers, with 2 being considered both the first prime and additive prime number. The numbers are represented in base 10.
Rules:

The output consists of all the additive primes amongst the first x primes
0 < x < 151, for this challenge, for functionality purposes
Since the additive primes are all integers, decimals are not allowed (e.g.: you should output 2, not 2.0) and they must not be displayed as a fraction.

Examples:
10 -> 2 3 5 7 11 23 29
Explanation:
The first 10 primes are 2 3 5 7 11 13 17 19 23 29, and only 2 3 5 7 11 23 29 have their sum of digits prime numbers, those being, respectively 2,3,5,7,2,5,11, so they are additive primes
Following the explanation from example 1, other test cases may be:
2 -> 2 3

25 -> 2 3 5 7 11 23 29 41 43 47 61 67 83 89

7 -> 2 3 5 7 11

Leaderboard:

var QUESTION_ID=112088,OVERRIDE_USER=59487;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left;font-family:"Helvetica Neue"}table thead{font-weight:700;font-family:"Helvetica Neue"}table td{padding:5px;font-family:"Helvetica Neue"}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

NOTE: Please read the newly-edited rule 1, it brings changes to the output format slightly

Your code should be as short as possible, since this is code-golf, so the shortest answer in bytes wins. Good luck!

That's fine. I'd recommend waiting around 24 hours though, because every time you accept the answer they get 15 rep, but they lose it when you un-accept. It's somewhat frustrating sometimes to ride the rollercoaster and continuously lose and gain rep.

Pyke, 9 7 bytes
~p>#Yss

Try it online!
The single byte is_prime was only pushed 3 hours ago. Github commit.
~p      -    All the prime numbers
  >     -   first input of them
   #Yss -  filter(^)
    Y   -     digits(^)
     s  -    sum(^)
      s -   is_prime(^)

Did you just edit your language to suit this challenge? :D

so... s means is_prime on numbers, and sum on lists?

@ConorO'Brien yes, I overload it for lists and integers

@Džuris no, I've been meaning to for a while because I haven't had a single node for doing prime checking, only factorising into primes and divisors. Before I would have had to do _P which is 1 byte longer in this case

a new contender for "youngest language feature to win a challenge"? under the wire by ~2 hours?

Röda, 136 135 bytes
f n{P=[2]S=[2]seq 3,863|{|i|{P|{P+=i;s=0;((""..i)/"")|parseInteger _|s+=_;S+=i if[s in P and not(i in S)]}if{|p|[i%p>0]}_}if[#P<n]}_;S}

Try it online!
It's a function that returns the requested additive primes.
Usage: main { f(25) | print ap for ap } The code uses version 0.12, which is in branch roda-0.12.
Ungolfed:
function f(n) {
    primes := [2]
    ultraprimes := [2]
    seq(3, 863) | for i do
        break if [ #primes = n ]
        if [ i%p != 0 ] for p in primes do
            primes += i
            sum := 0
            ((""..i)/"") | parseInteger _ | sum += digit for digit
            ultraprimes += i if [ sum in primes and not (i in ultraprimes) ]
        done
    done
    ultraprimes
}

Nice language! You made this yourself a long time ago it looks like? 10/10, looks pretty cool.

Neat language! How do you run the program?

Was just about to ask the same thing. Although I looked over the documentation, I cannot run or compile the source at all. What is your approach?

@KritixiLithos @Xcoder123 It requires Java 8 and Gradle. The version I use in this answer is 0.12 (in its own branch). The repository must be cloned recursively. To make a runnable jar, invoke gradle fatJar. Do you get any errors when compiling?

@fergusq Running gradle fatJar doesn't seem to create a jar for me

@KritixiLithos Does it output any errors? The jar should be located in build/libs.

@fergusq After running the program using the jar, I get [E] Syntax error on token }' in test.txt:1: Expected do'

@KritixiLithos The code uses version 0.12, which is in its own branch. You should do git checkout roda-0.12 before compiling. I edited the answer to clarify this.

@fergusq Thanks, it works now!

@fergusq I have some more questions about using this language. Would you mind coming to the PPCG chatroom?

Python 2, 124 118 bytes
With help from Riker:
n,f,P=input(),filter,lambda n:all(n%i for i in range(2,n))
f(lambda x:P(sum(map(int,`x`)))&P(x),f(P,range(2,n*n))[:n])

Original:
n,o,c,P=input(),0,2,lambda n:all(n%i for i in range(2,n))
while o<n:
 o+=P(c)
 if P(sum(map(int,`c`)))and P(c):print c
 c+=1

Checking primality in Python ain't fun.

I (read: got conor to write cool J code for me) have tested this with 9n, doesn't work. :/ n**2 does work, but at a cost of 1 byte.

Try n*n for n**2

Perl 6, 53 bytes
{grep *.comb.sum.is-prime,grep(*.is-prime,0..*)[^$_]}

Try it
Expanded:
{
  grep
    *.comb.sum.is-prime, # find the ultra primes from:
    grep(
      *.is-prime,        # find the primes
      0..*               # from all integers
    )[ ^$_ ]             # grab only the first x primes
}

If this challenge were changed so that you took the first x ultraprimes this could be shortened to just
{grep({($_&.comb.sum).is-prime},0..*)[^$_]}

Python 2, 96 87 bytes
p=-input(),0;m=k=1
while sum(p):
 m*=k*k;k+=1;p+=m%k,
 if m%k*p[int(`k`,36)%35]:print k

Thanks to @xnor for golfing off 9 bytes!
Try it online!

Looks like using a list of indicator variables is shorter.

The digit sum can be done shorter as is int(`k`,36)%35. All the inputs will be small enough that this suffices.

More golfing

Wow! I'm not sure how I thought of a Boolean dict but not a Boolean tuple (hindsight is 20/20), but sum(p) and int(`k`,36)%35 are something else... Thanks!

Mathematica, 61 47 bytes
Prime@Range@#~Select~PrimeQ@*Tr@*IntegerDigits&

Not entirely familiar with Mathematica's shorthand syntaxes - what's that @*? The * doesn't look like it's in the right place to be multiplication?

@numbermaniac it's function composition. f@*g is essentially f@g@##&.

Jelly, 10 bytes
ÆNDS$€ĖÆPM

Try it online!
How?
A slightly different approach...
ÆNDS$€ĖÆPM - Main link: n (>0)           e.g. 10
ÆN         - nth prime number                 29
     €     - for each in range(1,nth prime)   [1,    2,    3,   ..., 27,    28,     29]
    $      - last two links as a monad
  D        -     decimal digit list          [[1],  [2],  [3],  ...,[2,7], [2,8],  [2,9]]
   S       -     sum                          [1,    2,    3,   ..., 9,     10,     11]
      Ė    - enumerate                       [[1,1],[2,2],[3,3],...,[9,27],[10,28],[11,29]]
       ÆP  - is prime? (vectorises)          [[0,0],[1,1],[1,1],...,[0,1], [0,0],  [1,1]]
         M - indices of maximal elements     [       2,    3,   ...,                29]

Nice use of Ė.

05AB1E, 9 bytes
ÝØ¨vySOp—

Uses the CP-1252 encoding. Try it online!

Jelly, 11 bytes
ÆN€DS$ÆP$Ðf

Try it online!
Explanation:ÆN€DS$ÆP$Ðf Main link (args: z)
ÆN€         Generate first z primes.
   DS$      Take the digital sum.
      ÆP    Check if it's prime.
        $   Join last two links and make a monad.
         Ðf Only keep elements which conform to the criterion above.
I got outgolfed.

MATL, 15 13 bytes
2 bytes saved thanks to @Luis
:Yq"@V!UsZp?@

Try it at MATL Online
Explanation
        % Implicitly grab input as a number (N)
:       % Create an array [1...N]
Yq      % Get the k-th prime for each element k in that array
"       % For each element in this list
  @     % Get the current element
  V!U   % Break it into digits
  s     % Sum up the digits
  Zp    % Determine if this is a prime number
  ?@    % If it is, push the value to the stack
        % Implicit end of for loop and implicit display of the stack

@LuisMendo Ah! I knew there was some way to shorten that first part. Thanks

Fig, \$12\log_{256}(96)\approx\$ 9.877 bytes
FtxFmC@p'pSf

Try it online!
Explanation:
 t            # take the first
  x           # x items from
    mC        # all positive integers
   F          # filtered by
      @p      # is prime,
F       '     # then filter those by
          S   # the sum of
           f  # the digits
         p    # is prime

Ohm, 10 bytes (CP437)
@▓_π;░_}Σp

This would be much shorter if I had vectorization or a component for the first N primes, but alas, I did not before this challenge (but I do now!).
Explanation:
@▓_π;░_}Σp    Main wire, arguments: a

@▓  ;         Map...over the range (1..n)
  _π            nth prime
     ░        Select from ToS where...
      _}Σ       The sum of all digits
         p      is prime

Bash + coreutils, 97 bytes
p()(factor $1|wc -w)
for((;++n,c<$1;)){((`p $n`-2||(c++,`p $[n%10+n/10%10+n/100]`-2)))||echo $n;}

Try it online!

PowerShell, 120 bytes
for($n=$args[0];$n){for(;'1'*++$i-notmatch($s='^(?!(..+)\1+$)..')){}if('1'*([char[]]"$i"-join'+'|iex)-match$s){$i};$n--}

Try it online!
Prime checking in PowerShell sucks.
The outer for loop goes from input $n down to 0. In the inner loop, we use a prime generator on $i, then check if the digit-sum (-join'+'|iex) is also a prime. If so, we put $i on the pipeline. In either case, we decrement $n-- and the outer for loop continues. The resulting $is are gathered from the pipeline and an implicit Write-Output happens at program completion.

Bash + GNU utilities + bsd-games package, 69
primes 2|sed -rn 'h;s/./ + &/g;s/.*/expr &|factor/e;/\w\s/!{x;p};'$1q

Try it online.

Pari/GP, 59 bytes
f(x)=[p|p<-vector(x,i,prime(i)),isprime(vecsum(digits(p)))]

Try it online!

Vyxal, 5 bytes
ʁǎ'∑æ

Try it online, or verify more test cases.
Explanation:
ʁ      # Range from 0 to n-1
 ǎ     # Nth prime (vectorising)
  '    # Filtered by:
   ∑   #   The digit sum
    æ  #   Is prime

MathGolf, 9 bytes
♪╒g¶<gÅΣ¶

Try it online.
Explanation:
Since the input is guaranteed to be within the range \$[1,150]\$, where the \$150^{th}\$ prime is \$877\$, we'll use this to our advantage. (Although using ó (\$2^n\$ builtin using the implicit input) instead of ♪ would have worked as well, but would be way too slow for larger inputs.)
♪╒         # Push a list in the range [1,1000]
  g        # Filter it by:
   ¶       #  Check if the number is a prime
    <      # Then only keep the first (implicit) input amount of prime numbers
     g     # Filter it again,
      Å    # using 2 characters as inner code-block:
       Σ   #  Get the digit-sum of the current integer
        ¶  #  Check if it's also a prime
           # (after which the entire stack is output implicitly as result)

MATL, 13 bytes
:YqtFYA!XsZp)

Try it at MATL Online!
Explanation
:      % Range [1 2 ... n], where n is implicit input
Yq     % Array of first n prime numbers
t      % Duplicate
FYA    % Convert to decimal digits. Gives a matrix, where each original
       % number corresponds to a row. Left-pads with zeros if needed
!Xs    % Sum of rows
Zp     % Is prime? (element-wise)
)      % Use as logical index into the array of the first n prime numbers
       % Implicitly display

Husk, 8 bytes
fȯṗΣd↑İp

Try it online!

Japt, 12 bytes
Èj}jU fÈìx j

Try it

Factor + math.primes math.unicode math.text.utils, 47 bytes
[ nprimes [ 1 digit-groups Σ prime? ] filter ]

Try it online!
Explanation:
It's a quotation (anonymous function) that takes an integer from the data stack as input and leaves a sequence of integers on the data stack as output.

nprimes Obtain a list of the first n primes.
[ ... ] filter Take elements from the list that match a predicate.
1 digit-groups Obtain a list of digits from an integer.
Σ Sum a sequence.
prime? Is it prime?

05AB1E, 6 bytes
ÅpʒSOp

Try it online or verify all test cases.
Explanation:
Åp      # Get a list of the first (implicit) input amount of primes
  ʒ     # Filter this list by:
   S    #  Convert the prime to a list of digits
    O   #  Sum them together
     p  #  Check if this sum is a prime
        # (after which the filtered list is output implicitly as result)