text:
How many days in a month?
Given a textual representation (case-insensitive full name or 3 character abbreviation) of a month return the number of days in the month.
For example, december, DEC, and dec should all return 31.
February can have either 28 or 29 days.
Assume the input is a month in one of the correct forms.

You should probably list out all the variations of the month names that we should be able to accept.

what do you mean by case insensitive? do you mean we have to accept any case and give the right answer? or do you mean we can specify whether the input must be given in upper or lower case (presumably consistently)?

For anybody who can use it, the ASCII ordinal sums of the first 3 characters lowered are unique.

That was far, far too soon to accept a solution.

i think this would be nicer if input was just the month in a fixed format, as the format now basically requires converting to a fixed case and only looking at the first 3 letters.

As it stands it looks like you want answers to handle all of the listed forms - "For example, december, DEC, and dec should all return 31" - Is that the intention?

Pyke, 9 bytes
l4C9@~%R@

Try it here!
l4        -   input.title()
    @     -  v.index(^)
  C9      -   ['PADDING', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
        @ - v[^]
     ~%R  -  ['Padding', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

Or 15 bytes if all input formats are required
l43<C9 3L<@~%R@

Try it here!
l43<            -   input.title()[:3]
          @     -  v.index(^)
    C9 3L<      -   ['PAD', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
              @ - v[^]
           ~%R  -  ['Padding', 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

This returns 31 for FEB.

I believe @Laikoni's point is valid (it also returns 31 for Apr, Jun, Sep, and Nov) but also think that it requires a little clarification in the OP (see my question).

@JonathanAllan Well, the OP has accepted this answer, so I guess it's valid?

@EriktheOutgolfer I would not jump to that conclusion personally.

I was under the impression that it only needed to work for one form of inputs

Pyke looks really cool. Is there any documentation on it?

@EliR It's a simple stack based language. Some info on each of the instructions can be found here: https://pyke.catbus.co.uk/ and some more links here: https://github.com/muddyfish/PYKE/blob/master/README.md if you have any queries feel free to ping me in the Nineteenth Byte chat room here: https://chat.stackexchange.com/rooms/240/the-nineteenth-byte

JavaScript (ES6),  48 47 44 43  42 bytes
m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8]

Demo

let f =

m=>31^'311'[parseInt(m[1]+m[2],34)*3%49%8]

;(
  'JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,' +
  'JANUARY,FEBRUARY,MARCH,APRIL,MAY,JUNE,JULY,AUGUST,SEPTEMBER,OCTOBER,NOVEMBER,DECEMBER'
).split`,`
.forEach(m => console.log(m, '->', f(m)))

How?
These operations lead to a lookup table of 8 entries, which would not be very interesting if the values were randomly distributed. But any result greater than 2 is mapped to 31 days. Therefore, only the first 3 entries need to be stored explicitly.
Month | [1:2] | Base 34 -> dec. | * 3  | % 49 | % 8 | Days
------+-------+-----------------+------+------+-----+-----
  JAN |    AN |             363 | 1089 |   11 |   3 |  31
  FEB |    EB |             487 | 1461 |   40 |   0 |  28
  MAR |    AR |             367 | 1101 |   23 |   7 |  31
  APR |    PR |             877 | 2631 |   34 |   2 |  30
  MAY |    AY |              10 |   30 |   30 |   6 |  31
  JUN |    UN |            1043 | 3129 |   42 |   2 |  30
  JUL |    UL |            1041 | 3123 |   36 |   4 |  31
  AUG |    UG |            1036 | 3108 |   21 |   5 |  31
  SEP |    EP |             501 | 1503 |   33 |   1 |  30
  OCT |    CT |             437 | 1311 |   37 |   5 |  31
  NOV |    OV |             847 | 2541 |   42 |   2 |  30
  DEC |    EC |             488 | 1464 |   43 |   3 |  31

honestly how on earth do you keep making these amazing weird submissions with crazy maths stuff D: do you have a program to find these or are you just too good for the rest of us

@HyperNeutrino The first thing I try is always to find a base conversion, followed by an optional multiplication followed by one or several modulo operations. This one was found quickly that way. But I misread the challenge and first thought that this .substr(0,3) was not required. So, on second thought, this may not be the best approach.

substr? slice!

My trivial approach is only 2 3 bytes longer so it might not be optimal anymore because of that, but still very impressive :)

Sorry @Arnauld, i beat you using Javascript Dates (link)

@HermanLauenstein For the record, date built-ins were originally disallowed, so I didn't even try. :)

Someone's edit removed that part, but one of the reasons I originally disallowed it is I was wanting to see answers like this one. I love the use base 34 to sidestep the issue of capitalization and different formats.

Javascript (ES6), 36 33 bytes
-3 bytes thanks to @JustinMariner and @Neil
m=>31-new Date(m+31).getDate()%31

Sorry @Arnauld, abusing JavaScript weirdness is shorter than your fancy base conversions.
How it works
For some reason, JavaScript allows entering dates outside of the specified month. The code counts how many days outside the month the date is to determine how many days there are in the month. Examples:
"FEB31" → Thu Mar 02 2000 → 31 - 2 % 31 → 29
"October31" → Tue Oct 31 2000 → 31 - 31 % 31 → 31
Test cases

f=m=>31-new Date(m+31).getDate()%31
;(
 "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC,"+
 "January,February,Mars,April,May,June,July,August,September,October,November,December"
).split`,`.forEach(s=>console.log(s,"->",f(s)))

MS Excel also does this.. January 0 is always December Last Day, so =DAY("00/01/2017") will result in 31

It looks like Javascript only allows date strings where the day is up to 31. If you try to enter "feb 32", it translates to 2032-02-01, and if you try to force it with "0-feb-32" (or a similar string), it just says "Invalid Date". Oddly enough, if you set the day to 0 ("feb 0"), it translates to 2000-02-01 rather than 2000-01-31.

You might be able to save a byte by dropping the space before 31. It seems to work in Chrome as new Date("feb31") for example.

In fact you could probably use +31 saving three bytes overall. None of this works in Firefox though.

Python 2, 46 45 38 bytes
-1 byte thanks to @totallyhuman
lambda m:29-int(m[1:3],35)%238%36%-5/2

Try it online!

45 bytes.

Proton, 50 bytes
k=>31-((e=k.lower()[1to3])in"eprunov")-3*(e=="eb")

Try it online!
-14 bytes thanks to Jonathan Frech
Thirty days hath September, April, June, and November. All the rest had peanut butter. All except my grandmother; she had a little red trike, but I stole it. muahahahahaha
(I've been waiting to tell that joke (source: my math professor) for ages on this site :D :D :D)

@Riker oh whoops that wasn't there when I started writing this :/

There is a new rule that you have to check for not a valid month and return 0. I hope it gets deleted

Nevermind changing I'm deleting that part

I think you can use a single string 'sepaprjunnov' instead of a list of strings.

@JonathanFrech maybe; I'll try that, thanks

@JonathanFrech yup, that saved 12 bytes, thanks!

50 bytes.

The joke alone was worth an upvote. :)

Bash, 21 bytes
cal $1|xargs|tail -c3

Try it online!
Takes input as command-line argument and outputs with a trailing newline. The day count for February depends on that of the current year
Requires the util-linux 2.29 version of cal, which is the one available on TIO. Also is locale-dependent, so LC_TIME must be changed on non-English systems (thanks @Dennis for clarification).
Idea of piping through xargs to trim cal's output is from this SO answer.

This isn’t just bash. Generally it’s sh, but it’s probably almost every shell implementation that supports path lookups and pipes, on a system with cal, tail and xargs.

APL (Dyalog), 32 27 bytes (SBCS)
-2 thanks to ngn
Tacit prefix function. Assumes ⎕IO (Index Origin) 0, which is default on many systems.
32-1⌈∘⊃'.p|un|no|feb'⎕S 1⍠1

Try it online!
1⌈∘⊃ and use the maximum of one and the first element of that (0 if none) to pick from
32- thirty-two minus
1⌈∘ the maximum of one and
⊃ the first element (0 if none) of
'.p|un|no|f'⎕S the PCRE *Search for any-char,"p" or "un" or "no" or "f"
1 returning the length of the matches
⍠1 and done case insensitively

Apr, Sep, Jun, and Nov will give 32−2=30

Feb will give 32−3=29 (allowed by OP)

anything else will give 32−1=31

The programming language answering in itself.

yeah that's impressive!

C# (.NET Core), 52+13=65 38+24=62 bytes
m=>D.DaysInMonth(1,D.Parse(1+m).Month)

Try it online!
+24 for using D=System.DateTime;
Acknowledgements
-3 bytes thanks to Grzegorz Puławski.

Does this work without using System;? Or can you excluse that from the byte count?

@Matty That's a good point; now added.

Late tip, but -3 bytes: using D=System.DateTime; and m=>D.DaysInMonth(1,D.Parse(1+m).Month) like here: https://tio.run/##jc5BSwMxEAXgs/kVoacEa6DndQvFULC4ULAgHsc46MhmYjNZYSn97Wu7RcGTe3xvPh4T5CakjEMnxG/a14@9FIzOQ8EdRazU5XCp/yb3QLyvVGhBRG8PSgoUCnrdcbiVkk9wronLUjeJy7uHXnSth1gvvTuHex57s5h7t4UsaBbX0bqxtEOlfva@Er3qBoiNVQd1dZdYUovuKVPB0wdofufNbAM8s7b6R63xJXeQ@wk0Qp6gVp@Z2gmuWT1PUB8d48iO6jh8Aw

Shell/GNU Date, 39, 26 bytes
date -d1$1+1month-1day +%d

Where $1 is the name of the month.
Try it online!
edit: Thanks Dennis for saving many bytes!

Python 3, 60 bytes
x=input().lower()[1:3];print(31-(x in"eprunov")-3*(x=="eb"))

Try it online!
Porting my Proton solution
-10 bytes thanks to totallyhuman

Better than mine heh

um

:P builtins are sometimes too long :P

@totallyhuman oh rly wow. +1 thanks :P

umm

@totallyhuman lol nice

Mediawiki Template, 19 bytes
{{#time:t|{{{1}}}}}

AWK, 45 44 bytes
L=tolower($1){$0=L~/v|p|un/?30:L~/f/?28:31}1

Try it online!

Haskell, 65 63 62 bytes
f.map((`mod`32).fromEnum)
f(_:b:c:_)|c<3=28|c>13,b>3=30
f _=31

Try it online!
Pattern matching approach. The first line is to handle the case-insensitivity. Then we return 28 if the third letter is smaller than C (number 3), 30 if the second letter is larger than C and the third one larger than M, or 31 otherwise.
Edit: -1 byte thanks to Leo

Alternative (65 64 bytes)
f s|let i#n=n<mod(fromEnum$s!!i)32=sum$29:[2|2#2]++[-1|2#13,1#3]

Try it online!

Clever one! You can save a byte by checking for c<3 instead of a==6 (February is the first month if you order them by their third letter, followed by December)

Perl 5, 47 + 1 (-p) = 48 bytes
$_=substr$_,1,2;$_=31-("eprunov"=~/$_/i)-3*/b/i

Try it online!

-6 bytes : ($_)=/.(..)/; instead of $_=substr$_,1,2; and () around "eprunov"=~/$_/i can be removed.

q/kdb+, 36 bytes
Solution:
28 30 31@2^1&(*)"ebeprunov"ss(_)1_3#

Examples:
q)28 30 31@2^1&(*)"ebeprunov"ss(_)1_3#"January"
31
q)28 30 31@2^1&(*)"ebeprunov"ss(_)1_3#"FEB"
28
q)28 30 31@2^1&(*)"ebeprunov"ss(_)1_3#"jun"
30

Explanation:
There are a million ways to skin a cat. I think is slightly different to the others. Take the 2nd and 3rd letters of the input, lowercase them, then look them up in the string "ebeprunov". If they are at location 0, then this is February, if they are at a location >0 they are a 30-dayer, if they are not in the string, they are a 31-dayer.
28 30 31@2^1&first"ebeprunov"ss lower 1_3# / ungolfed solution
                                        3# / take first 3 items from list, January => Jan
                                      1_   / drop the first item from the list, Jan => an
                                lower      / lower-case, an => an
                  "ebeprunov"ss            / string-search in "ebeprunov", an => ,0N (enlisted null)
             first                         / take the first, ,0N => 0N
           1&                              / take max (&) with 1, 0N => 0N
         2^                                / fill nulls with 2, 0N => 2
        @                                  / index into
28 30 31                                   / list 28,30,31

Java 8, 47 bytes
m->31-new java.util.Date(m+"31 1").getDate()%31

Try it online!
Ended up using the same idea as Herman Lauenstein's JS answer, where setting the date to the 31st pushed into the next month. Java does require a year, so that has been set to 1.

PHP, 38 33+1 32+1 bytes
Saved 5 bytes thanks to Titus
<?=date(t,strtotime("$argn 1"));

Run as pipe with -nF
Try it online!

Hey, I don't think you need .' 1', it seems to work on TIO without it!

28+1 bytes: <?=date(t,strtotime($argn)); (run as pipe with -nF)

@DomHastings - so, before I posted, I had tested to see if it would work without the .' 1', but it wasn't working. After seeing your comment, I tried to figure out what I had done wrong. Because I was running it on the 31st of the month, it was taking the 31st (current) day for any month I put in, which would put it beyond the current month. Feb 31st turns into March 3rd, so the code returns 31 (the number of days in March). Because of this, every month was returning 31. So, it works without the .' 1' on any day <= 28th of the month.

Ahhh, I forget about how PHP fills in the blanks! Thanks for explaining!

@Titus Thank you. I'm such a golf newbie! I don't know why I didn't realize the 't' -> t. Also, I had to do a bunch of searching to figure out how to "run as pipe with -nF" but I got it figured out (I think). :)

$argn.' 1' -> "$argn 1" saves one more byte

MATL, 22 bytes
14L22Y2c3:Z)Z{kj3:)km)

Try it online!
Explanation
14L    % Push numeric array of month lengths: [31 28 ... 31]
22Y2   % Push cell array of strings with month names: {'January', ..., 'December'}
c      % Convert to 2D char array, right-padding with spaces
3:Z)   % Keep first 3 columns
Z{     % Split into cell array of strings, one each row
k      % Convert to lower case
j      % Input string
3:)    % Keep first 3 characcters
k      % Convert to lower case
m      % Ismember: gives a logical index with one match
)      % Use that as index into array of month lengths. Implicit display

Retina, 32 31 28 bytes
i`f
28
i`p|v|un
30
\D

^$
31

Try it online! Edit: Saved 1 byte thanks to @RobertBenson. Saved 3 bytes thanks to @ovs.

I believe you could save a byte by using 'f' instead of 'eb'

28 bytes

Python 3 - 93 86 84 82 bytes
Variants of answer (showing the progression of time, and bytes for each, with TIO links):
Original Answer (93 bytes)
-7 bytes thanks to Jonathan Frech. (86 bytes)
-2 more bytes thanks to my own further testing of the monthrange results, with the second value always being the higher value. (84 bytes) 1
-2 more by using import calendar as c and referencing it with c.monthrange. (82 bytes, current revision)

lambda x:c.monthrange(1,time.strptime(x[:3],'%b')[1])[1];import time,calendar as c

Obviously not as nice as HyperNeutrino's answer which doesn't use built-ins, but this still works.

Footnotes
1: Test cases via TIO.run showing the proof for how I'm handling those monthrange values, for a varying number of month test cases.

86 bytes.

@JonathanFrech Thanks.  Further revised downwards by my having tested more of how monthrange works, and also by using import ...,calendar as c so as not having to type 'calendar' twice.

Wolfram Language (Mathematica), 46 30 bytes
#~NextDate~"Month"~DayCount~#&

Try it online!
Will give either 28 or 29 for February depending on whether the current year is a leap year.
How it works
All date commands in Mathematica will interpret input such April, APR, ApRiL, and so on as the first day of the corresponding month in the current year. (As a bonus, input such as "February 2016" or {2016,2} also works as expected.)
#~NextDate~"Month" gives the first day of the month after that, and DayCount gives the number of days between its two arguments. The number of days between April 1st and May 1st is 30, the number of days in April.

Excel VBA, 47 43 Bytes
Anonymous VBE immediate window function that takes input, as month name, abbreviation, or number, from range [A1] and outputs the length of that month in the year 2001 to the VBE immediate window function.
?31-Day(DateValue("1 "&[A1]&" 1")+30)Mod 31

Old Version
d=DateValue(["1 "&A1&" 1"]):?DateAdd("m",1,d)-d

QBIC, 49 35 bytes
?31-(instr(@aprjunsepnov feb`,;)%3)

Significantly shorter with some trickery.
Explanation
?                          PRINT
31-(                       31 minus
  instr(                   the position of
                      ,;   our input string
    @aprjunsepnov feb`  )  in the string cntaining all non-31 months
    %3)                    modulo 3 (this yields a 1 for each month except feb=2)

Java (OpenJDK 8), 126 bytes
s->{for(java.time.Month m:java.time.Month.values())if(m.name().startsWith(s.toUpperCase()))System.out.print(m.length(false));}

Try it online!

I think you can shorten false to a boolean expression like 1<0 to save a couple bytes.

Perl 5, 24 bytes
23 bytes code + 1 for -p.
$_=31-/p|un|no/i-/f/i*3

Try it online!

Ruby, 45 bytes
->m{((Date.parse(m)>>1)-1).day}
require'date'

Try it online!
Ruby's Date.parse accepts a month name on its own. What would normally be a right-shift (>>) actually adds to the month of the Date object. Subtraction affects the day of the month, which will wrap backwards to the last day of the previous month.

Kotlin, 92 bytes
val d={m:String->arrayOf(0,31,30,30,31,30,31,28,31,0,30)[(m[1].toInt()+m[2].toInt())%32%11]}

Try it online!

JavaScript (V8), 100 bytes
(z,v=n=e=b=r=y=u=c=0,t=s=a=l=1,f=p=29,m=j=g=o=30,d=31)=>eval([z[0],z[1],z[2]].join`+`.toLowerCase())

Try it online!

Japt, 12 bytes
Uses Herman's method.
´H-ÐU+H f uH

Try it (includes all test cases, footer resets the H constant for the next case)


text:
Type the Alphabet - as fast as you can!
Your task is to make a program that measures how fast you can type the letters of the English alphabet.

The program shall only accept lowercase letters a to z in alphabetical order.
Each letter is echoed as typed on the same line (without new line or any other separators between letters).
If you type an invalid character the program shall output Fail on a new line and exit.
If you type all 26 letters the program shall, on a new line, output the time in milliseconds it took from the first to the last letter and exit.
The timer starts when you type the first letter, a.

Example outputs:
b
Fail

abcdefgg
Fail

abcdefghijklmnopqrstuvwxyz
6440

This is code-golf, so shortest answer in bytes wins.

Relevant project I made a while back. (the 15th level is basically this)

Can we output Fail without a heading newline? (e.g. abdFail\n or abd Fail\n))

@scottinet, no, the result (Fail or milliseconds) must be on a new line, like in the example. Most answers already assume this.

-1 as this "new" rule was not in the original specification and invalidates my suggestions on one of the Python answers which was within the original rules.

I was expecting this to be a [tag:fastest-code] challenge of printing the alphabet.

Q about precision: if I used the ~60Hz system IRQ on a C64 in machine code to calculate milliseconds, would this be acceptable? Or do I have to program a timer chip myself just because it can be done in machine code?

HTML (JavaScript (ES6)), 129 126 117 bytes

<input id=i onfocus=l=0,n=Date.now onkeypress=event.which-97-l?i.outerHTML='Fail':24<l?i.outerHTML=n()-t:t=l++?t:n()>

Click in the input and start typing! Also, my typing sucks; I take about 5 seconds even with practice. Edit: Saved 2 bytes thanks to @HermanLauenstein by switching language. Saved 3 bytes thanks to @qw3n. Saved 9 bytes thanks to @tsh.

-2 bytes by using html with a script tag: <input id=i><script>l=0;n=Date.now;i.onkeypress=e=>e.charCode-97-l?i.outerHTML='Fail':l>24?i.outerHTML=n()-t:t=l++?t:n()</script>, -11 bytes if the closing tag isn't needed

@HermanLauenstein The closing tag seems to be necessary for a snippet, at least, so I'll leave it in.

why not use up instead of press. 2. Also, you can attach event listeners to window by just saying onkeyup meaning you could remove the i.. 3. The rules also don't specify where the results have to be placed meaning you could replace the text in the input value < outerHTML. 4. which < charCode.

113 bytes <input id=i><script>l=0;n=Date.now;onkeyup=e=>e.which-65-l?i.value='Fail':l>24?i.value=n()-t:t=l++?t:n()</script>

@qw3n 1. because it's case insensitive. 2/3. The rules say I have to exit, so setting the outerHTML achieves that by removing the listeners and showing the answer at the same time.

keyup produces different which values for me if I press a or shift+A 65 and 16 respectively. For 2/3 I guess I never really thought of a javascript as something that "exits" except on page close.

@qw3n 16 is the shift key...

Which works except for the caps lock key :( oh well good answer anyways.

@qw3n Or just keeping the shift key held down fools it, I think.

This is too infuriating and fun at the same time.

What about put event on input? <input id=i onkeypress=event.which-97-l?i.outerHTML='Fail':24<l?i.outerHTML=n()-t:t=l++?t:n() onfocus=l=0,n=Date.now>

Also, you should avoid use the word outerHTML second time, as it is too long. i.onkeypress=e=>i.outerHTML=e.which-97-l?'Fail':24<l?n()-t:0(t=l++?t:n())

@tsh Thanks for your inline event handlers. I'm not so keen on the idea of throwing exceptions though; I'll have to think about it.

Doesn't echo the text on a new line

@Mendeleev - at the time that this answer was written, that was not a stated requirement and therefore this is valid imho.

6502 machine code (C64 PAL), 189 165 bytes
00 C0 A9 17 8D 18 D0 A9 40 85 FE E6 FE 20 E4 FF F0 FB 20 D2 FF C5 FE 38 D0 38
C9 5A 18 F0 33 C9 41 D0 E8 A9 00 85 FC 85 FD A9 18 85 FB A9 7F 8D 0D DD A9 7F
8D 18 03 A9 C0 8D 19 03 A9 D8 8D 04 DD A9 03 8D 05 DD A9 01 8D 0E DD A9 81 8D
0D DD D0 B9 A9 7F 8D 0D DD A9 47 8D 18 03 A9 FE AD 19 03 CE 0E DD B0 14 A9 0D
20 D2 FF A4 FC A5 FD 20 91 B3 20 DD BD A9 01 A8 D0 04 A9 9D A0 C0 4C 1E AB 48
AD 0D DD 29 01 F0 14 E6 FC D0 02 E6 FD C6 FB D0 0A A9 18 85 FB CE 0E DD EE 0E
DD 68 40 0D C6 41 49 4C 00

-24 bytes by inlining functions and not caring for other CIA2 interrupts

Online demo (Usage: sys49152)

Explanation:
This would be a tiny program if it wasn't for the problem of an exact measurement of milliseconds on the C64. The system interrupt occurs roughly 60 times per second, which isn't even close. So we have to use a hardware timer here that gets its input ticks from the system clock.
On a PAL machine, the system clock is exactly 985248 Hz. Initializing the timer to 985 therefore gives something close to millisecond ticks, but it's a bit too fast, we'd have to count 986 cycles for every fourth tick, or hold the timer for a single cycle. This isn't possible, but we can hold the timer for 6 cycles with the sequence DEC $DD0E, INC $DD0E: $DD0E is the timer control register with bit 0 switching it on and off, and both instructions take 6 cycles, so the exact writes that stop and start the timer are exactly 6 cycles apart. Therefore we have to execute this sequence every 6*4 = 24th tick. This still isn't absolutely exact, the timer will lag 1 millisecond behind after 8 minutes and 12 seconds, but it's probably good enough -- compensating for that one would take a lot of code.
edit: The start value for the timer must be 984, not 985, because these timers fire "on underflow", so a value of 0 will count one more cycle before firing. Code fixed, byte count unchanged.
Here's the commented disassembly listing:
         00 C0       .WORD $C000        ; load address
.C:c000  A9 17       LDA #$17           ; mode for upper/lower text
.C:c002  8D 18 D0    STA $D018          ; set in graphics chip
.C:c005  A9 40       LDA #$40           ; initialize expected character
.C:c007  85 FE       STA $FE            ; to 'a' - 1
.C:c009   .mainloop:
.C:c009  E6 FE       INC $FE            ; increment expected character
.C:c00b   .getchar:
.C:c00b  20 E4 FF    JSR $FFE4          ; read character from keyboard
.C:c00e  F0 FB       BEQ .getchar       ; until actual character entered
.C:c010  20 D2 FF    JSR $FFD2          ; output this character
.C:c013  C5 FE       CMP $FE            ; compare with expected
.C:c015  38          SEC                ; set carry as marker for error
.C:c016  D0 38       BNE .result        ; wrong character -> output result
.C:c018  C9 5A       CMP #$5A           ; compare with 'z'
.C:c01a  18          CLC                ; clear carry (no error)
.C:c01b  F0 33       BEQ .result        ; if 'z' entered, output result
.C:c01d  C9 41       CMP #$41           ; compare with 'a'
.C:c01f  D0 E8       BNE .mainloop      ; if not equal repeat main loop
.C:c021  A9 00       LDA #$00           ; initialize timer ticks to 0
.C:c023  85 FC       STA $FC
.C:c025  85 FD       STA $FD
.C:c027  A9 18       LDA #$18           ; counter for adjusting the timer
.C:c029  85 FB       STA $FB
.C:c02b  A9 7F       LDA #$7F           ; disable all CIA2 interrupts
.C:c02d  8D 0D DD    STA $DD0D
.C:c030  A9 7F       LDA #<.timertick   ; set NMI interrupt vector ...
.C:c032  8D 18 03    STA $0318
.C:c035  A9 C0       LDA #>.timertick
.C:c037  8D 19 03    STA $0319          ; ... to our own timer tick routine
.C:c03a  A9 D9       LDA #$D8           ; load timer with ...
.C:c03c  8D 04 DD    STA $DD04
.C:c03f  A9 03       LDA #$03
.C:c041  8D 05 DD    STA $DD05          ; ... 985 (-1) ticks (see description)
.C:c044  A9 01       LDA #$01           ; enable timer
.C:c046  8D 0E DD    STA $DD0E
.C:c049  A9 81       LDA #$81           ; enable timer interrupt
.C:c04b  8D 0D DD    STA $DD0D
.C:c04e  D0 B9       BNE .mainloop      ; repeat main loop
.C:c050   .result:
.C:c050  A9 7F       LDA #$7F           ; disable all CIA2 interrupts
.C:c052  8D 0D DD    STA $DD0D
.C:c055  A9 47       LDA #$47           ; set NMI interrupt vector ...
.C:c057  8D 18 03    STA $0318
.C:c05a  A9 FE       LDA #$FE
.C:c05c  AD 19 03    LDA $0319          ; ... back to system default
.C:c05f  CE 0E DD    DEC $DD0E          ; disable timer
.C:c062  B0 14       BCS .fail          ; if carry set, output fail
.C:c064  A9 0D       LDA #$0D           ; load newline
.C:c066  20 D2 FF    JSR $FFD2          ; and output
.C:c069  A4 FC       LDY $FC            ; load timer value in
.C:c06b  A5 FD       LDA $FD            ; A and Y
.C:c06d  20 91 B3    JSR $B391          ; convert to float
.C:c070  20 DD BD    JSR $BDDD          ; convert float to string
.C:c073  A9 01       LDA #$01           ; load address of
.C:c075  A8          TAY                ; string buffer
.C:c076  D0 04       BNE .out           ; and to output
.C:c078   .fail:
.C:c078  A9 9D       LDA #<.failstr     ; load address of "Fail" string
.C:c07a  A0 C0       LDY #>.failstr     ; in A and Y
.C:c07c   .out:
.C:c07c  4C 1E AB    JMP $AB1E          ; done; OS routine for string output
.C:c07f   .timertick:
.C:c07f  48          PHA                ; save accu
.C:c080  AD 0D DD    LDA $DD0D          ; load interrupt control register
.C:c083  29 01       AND #$01           ; to know whether it was a timer NMI
.C:c085  F0 14       BEQ .tickdone      ; if not -> done
.C:c087  E6 FC       INC $FC            ; increment timer ticks ...
.C:c089  D0 02       BNE .adjusttick
.C:c08b  E6 FD       INC $FD            ; high byte only on overflow
.C:c08d   .adjusttick:
.C:c08d  C6 FB       DEC $FB            ; decrement counter for adjusting
.C:c08f  D0 0A       BNE .tickdone      ; not 0 yet -> nothing to do
.C:c091  A9 18       LDA #$18           ; restore counter for adjusting
.C:c093  85 FB       STA $FB
.C:c095  CE 0E DD    DEC $DD0E          ; halt timer for exactly
.C:c098  EE 0E DD    INC $DD0E          ; 6 cycles
.C:c09b   .tickdone:
.C:c09b  68          PLA                ; restore accu
.C:c09c  40          RTI
.C:c09d   .failstr:
.C:c09d  0D C6 41    .BYTE $0D,"Fa"
.C:c0a0  49 4C 00    .BYTE "il",$00

Well, now I have a somewhat decent millisecond timer in my toolbox ;) might be useful some day.

Pay attention, script kiddies.  This is real golf.

@J... I could golf it further by inlining .starttimer -- will do soon :) (and even further by using the system TI like this BASIC answer, but I'm not sure this is valid, because you can do better in machine code)

Wow, I missed a factor of 985 when calculating the error in my time measurement first -- it's actually pretty good the way it is (if I made another error in my calculations, please point out!) :)

And do you see what this guy have in the GITHUB?: android boot recovery.... he is completely insane! favorited his profile.

Thanks for the nice comments and votes, but I just realized this has a bug :( the milliseconds here are a "tiny little bit" too long, because I forgot about the fact that a CIA timer fires "on underflow", not on reaching 0 -- so 0 will count one more cycle before firing. The start value for the timer has to be one less. I'm still editing this now, it doesn't change the byte code. Stupid stupid mistake :o

@LucianoAndressMartini the "boot recovery" is just a fork of a "clockworkmod" fork with little changes made by myself, just wanted to make it work on my back-then unsupported phone.

Bash + coreutils, 103 99 98 bytes
for((;c==p%26;r=`date +%s%3N`-(s=s?s:r),c=62#$c-9,p++))
{
read -N1 c
}
((c==p))||r=Fail
echo "
$r"

Must be run in a terminal.
Test run
$ bash type.sh
abcdefghijklmnopqrstuvwxyz
3479
$ bash type.sh
abcz
Fail
$ bash type.sh 2>&- # typing '@' would print to STDERR
ab@
Fail
$ bash type.sh
A
Fail

3479 is pretty fast! well done :)

Is there a specific version of bash required or something? On 4.4.12, typing a immediately gives me line 1: ((: r=15094100773N: value too great for base (error token is "15094100773N") and exits.

@numbermaniac The version of Bash shouldn't matter, but the one of date might. Mine is from GNU coreutils 8.23. What does date +%s%3N print on your system?

@Dennis it outputs 15094104833N - this is the built-in date utility on macOS, if that makes a difference.

@numbermaniac BSD's date seems to be using strftime, which doesn't recognize %N.

Pascal (FPC), 176 bytes
Uses CRT,SysUtils;Var c:char;a:Real;Begin
for c:='a'to'z'do
if c=ReadKey then
begin Write(c);if c='a'then a:=Now;end
else
begin
Write('Fail');Halt;end;Write((Now-a)*864e5)
End.

Try it online!
Some tricks used in code for golfing:

Use Real as a shorter alternative to TDateTime, because as defined here, TDateTime = Double, which is floating-point type.
Instead of using MilliSecondsBetween for calculating time gap, this code multiply the difference between two floating-point values by 864e5, which works because of the way Free Pascal encode TDateTime described here.

Note:

ReadKey function doesn't actually print the key on the console, so manual writing to console with Write(c) is necessary.
TIO get a score near 0 for typing the alphabet for obvious reason.
The program prints time in floating-point notation, I guess that's allowed.

Welcome to the site!

You can save 1 byte by moving the for c:='a'to'z'do to the same line as a:=Time;.

Maybe you should try Now instead of Time as it's shorter.

Why 86398338?? I can understand if you multiple 864e5 since there are 864e5 milliseconds in a day. but how does this magic number come?

@tsh I don't know either. By manual testing I happens to find that "magic" number, and I don't know how Pascal store TDateTime as Double. 864e5 sounds more correct, I will fix the issues.

Python 2 + getch, 116 bytes
import time,getch
t=[i+97-ord(getch.getche())and exit("Fail")or time.time()for i in range(26)]
print(t[-1]-t[0])*1e3

Thanks to ovs and ElPedro for fixing the code and saving 57 bytes.

SOGL V0.12, 35 bytes
"ζ¦F‘→I
]I!}Su[I:lzm≠?■Fail←z=?Suκ←

Try it Here! - click run, and enter the alphabet in the input box. Note that it may be a little laggy because SOGL only pauses for input every 100 executed tokens (and SOGL is quite slow). If that bothers you, run sleepBI=true in the console.
note: don't run this in the compatibility mode - it'll just loop forever.
Explanation:
"ζ¦F‘    push "inputs.value" (yes, that is a word in SOGLs english dictionary)
     →   execute as JS, pushing the inputs contents
      I  named function I

]  }                do while POP is truthy
 I                    execute I
  !                   negate it - check if it's empty
    Su              push the current milliseconds since start
[                   loop
 I                    execute I
  :                   duplicate the result
   l                  let its length
    zm                mold the alphabet to that size
      ≠?              if that isn't equal to one of the result copies
        ■Fail           push "Fail"
             ←          and exit, implicitly outputting that
              z=?     if the other copy is equal to the alphabet
                 Su     push the milliseconds since start
                   κ    subtract the starting milliseconds from that
                    ←   and exit, implicitly outputting the result

@HyperNeutrino I knew it would come in handy :p

Who would expect SOGL to be able to do that...by the way isn't "Fail" a word in the dictionary?

@EriktheOutgolfer well, SOGL was supposed to be an all-purpose language, but that didn't work out :p

BTW I don't know if this is completely valid, but then again I think that might be an issue with the interface and not the interpreter behind...

@EriktheOutgolfer yeah, I don't know how valid that is, I guess I'm waiting for the OP. At first I thought that this is something like the HTML answer, but it's quite different now that I look at it

Java, 404 388 354 348 320 318 bytes
import java.awt.*;import java.awt.event.*;interface M{static void main(String[]a){new Frame(){{add(new TextArea(){{addKeyListener(new KeyAdapter(){long t,i=64;public void keyPressed(KeyEvent e){t=t>0?t:e.getWhen();if(e.getKeyChar()!=++i|i>89){System.out.print(i>89?e.getWhen()-t:"Fail");dispose();}}});}});show();}};}}

And here I thought Java Console was already verbose..
Since Java has no way to raw listen for key-presses in the Console a.f.a.i.k., I use a GUI with java.awt.
-78 bytes thanks to @OlivierGrégoire.
Explanation:
import java.awt.*;                 // Required import for Frame and TextField
import java.awt.event.*;           // Required import for KeyAdapter and KeyEvent
interface M{                       // Class
  static void main(String[]a){     //  Mandatory main-method
    new Frame(){                   //   Create the GUI-Frame
      {                            //    With an initialization-block
        add(new TextArea(){        //     Add an input-field
          {                        //      With it's own initialization-block
            addKeyListener(new KeyAdapter(){
                                   //       Add a KeyAdapter to the input-field
              long t,              //        Long to save the time
                   i=64;           //        Previous character, starting at code of 'a' -1
              public void keyPressed(KeyEvent e){
                                   //        Override the keyPressed-method:
                t=t>0?             //         If `t` is already set:
                   t               //          Leave it the same
                  :                //         Else:
                   e.getWhen();    //          Save the current time (== start the timer)
                if(e.getKeyCode()!=++i
                                   //         As soon as an incorrect character is pressed,
                   |i>89){         //         or we've reached 'z':
                  System.out.print(i>89?
                                   //          If we're at 'z':
                    e.getWhen()-t  //           Print the end-time in ms to the Console
                   :               //          Else (an incorrect character was pressed)
                    "Fail");       //           Print "Fail" to the Console
                  dispose();}      //          And exit the application
              }                    //        End of keyPressed-method
            });                    //       End of KeyAdapter
          }                        //      End of input-field initialization-block
        });                        //     End of input-field
        show();                    //     Initially show the Frame
      }                            //    End of Frame initialization-block
    };                             //   End of Frame
  }                                //  End of main-method
}                                  // End of class

Example gif of success: (Yes, I type the alphabet pretty slowly here..)
Note: This is an old gif. Current version no longer prints key-presses to Console. And it no longer prints the time with digits after the decimal point.

Example gif of fail:
Note: This is an old gif. Current version no longer prints key-presses to Console.

impressive answer considering it has a gui!

388 bytes. I took the liberty to fix your code in addition to golfing because you used setVisible(false) instead of exiting.

@OlivierGrégoire Thanks. Forgot about show and dispose, which is even shorter than setVisible. I almost never use Java's GUI.. And smart to use class-initialization instead of putting it in the main-method. I should remember that.

@KevinCruijssen Thanks, and no problem ;-) Though some more general comments: you don't need to output the letters twice. Echoing is already provided by TextField. Also, you could use TextArea instead of TextField to gain two bytes. Finally, KeyEvent has a getWhen method that gives the time between epoch and the event in milliseconds. Just need to use those instead of System.nanoTime() to gain even more bytes.

@OlivierGrégoire Thanks! Didn't even knew KeyEvent had a getWhen method. In total 50 bytes saved thanks to you.

You're welcome! But I got it down further to 320 bytes. ;-)

@OlivierGrégoire Yeah, keeping c when I only use it one was just dumb.. And smart way of using initialization-blocks for both the Frame and TextArea.

@OlivierGrégoire Been able to golf it by two more bytes. keyChar 'a' through 'z' is 97-122, but keyCode is from 65-90, so using keyCode I can change both 121 (three bytes) to 89 (two bytes). :)

@KevinCruijssen Cheers! ;-)

C# (.NET Core), 245 + 13 183 + 41 177 + 41 bytes
+41 bytes for using System;using static System.Console.
Untested since I am on mobile and this does not run on TIO.
n=>{int c=ReadKey().KeyChar,x=0;try{if(c!=97)x/=x;var s=DateTime.Now;while(c<149)if(ReadKey().KeyChar!=c++)x/=x;Write((DateTime.Now-s).TotalMilliseconds);}catch{Write("Fail");}}

+1 for creating a functioning program without being able to test it. Golfing:

One shorter way I've found to produce the exception: int x=0; and then do x=1/x;. This should save 14 bytes. Unfortunately you need x. If you try to do 1/0 you get a Division by constant zero compiler error. 2) -5 bytes for combining the declaration of c with the first ReadKey. 3) Change the condition in the inner if to ReadKey!=++c and remove the c++;else for another -9 bytes.

@raznagul Thanks! x=1/x can be reduced to x/=x. And i added using static System.Console; to save some more bytes :)

Some more bytes can be saved by removing i and using c in the loop condition instead.

Node.js, 240 213 bytes
require('readline',{stdin:i,stdout:o,exit:e}=process).emitKeypressEvents(i)
w=s=>o.write(s)
n=0
i.on('keypress',c=>w(c)&&c.charCodeAt()-97-n?e(w(`
Fail`)):!n++?s=d():n>25&&e(w(`
`+(d()-s)))).setRawMode(d=Date.now)

EDIT: Saved 27 bytes thanks to Jordan
Ungolfed version:
const readline = require('readline')

let index = 0
let start

readline.emitKeypressEvents(process.stdin)
process.stdin.setRawMode(true)

process.stdin.on('keypress', character => {
  process.stdout.write(character )

  // Lookup character in ASCII table
  if (character !== String.fromCharCode(97 + index) {
    process.stdout.write('\nFail')
    process.exit()
  }

  index++

  if (index === 1) {
    start = Date.now()
  }

  if (index === 26) {
    process.stdout.write('\n' + (Date.now() - start))
    process.exit()
  }
})

C# (.NET Core), 184+13=197 173+13=186 bytes
()=>{var s=DateTime.Now;var i=97;while(i<123&&Console.ReadKey().KeyChar==i)if(i++<98)s=DateTime.Now;Console.Write(i>122?$"\n{(DateTime.Now-s).TotalMilliseconds}":"\nFail");}

Try it online!
Unfortunately TIO can't run this, but it's handy for getting byte count.
+13 for using System;
-1 by changing i==123 to i>122. I was tempted to make this i>'z'.
Acknowledgements
-10 bytes thanks to @raznagul
Ungolfed
()=>{
    var s=DateTime.Now;
    var i=97;

    while(i<123&&Console.ReadKey().KeyChar==i)
        if(i++<98)
            s=DateTime.Now;

    Console.Write(i>122?
        $"\n{(DateTime.Now-s).TotalMilliseconds}":
        "\nFail"
    );
}

You can save some bytes by moving the ReadKey to the loop condition so you can remove the first if and the break.

C (gcc), 303 bytes
Works on *nix systems. Standalone code removing the current terminal's canonical mode to allow reading characters without waiting for newlines:
/!\ Running this program will make the terminal almost unusable.
#import <stdlib.h>
#import <termios.h>
#define x gettimeofday(&t,0)
#define r t.tv_sec*1000+t.tv_usec/1000
c,i=97;main(){long s=0;struct termios n;struct timeval t;cfmakeraw(&n);n.c_lflag|=ECHO;tcsetattr(0,0,&n);for(;i<'d';){c=getchar();if(c!=i++)puts("\nFail"),exit(0);x;s=s?:r;}x;printf("\n%ld",r-s);}

Ungolfed and commented:
// needed in order to make gcc aware of struct termios
// and struct timeval sizes
#import <stdlib.h>
#import <termios.h>

// gets the time in a timeval structure, containing
// the number of seconds since the epoch, and the number
// of µsecs elapsed in that second
// (shorter than clock_gettime)
#define x gettimeofday(&t,0)
// convert a timeval structure to Epoch-millis
#define r t.tv_sec*1000+t.tv_usec/1000

// both integers
// c will contain the chars read on stdin
// 97 is 'a' in ASCII
c,i=97;

main(){
  long s=0; // will contain the timestamp of the 1st char entered
  struct timeval t; // will contain the timestamp read from gettimeofday

  // setting up the terminal
  struct termios n;
  cfmakeraw(&n);//create a raw terminal configuration
  n.c_lflag|=ECHO;//makes the terminal echo each character typed
  tcsetattr(0,0,&n);//applies the new settings

  // from 'a' to 'z'...
  for(;i<'{';){
    // read 1 char on stdin
    c=getchar();

    // if int value of the input char != expected one => fail&exit
    if(c!=i++)puts("\nFail"),exit(0);

    // macro x: get current timestamp
    x;

    // if not already set: set starting timestamp
    s=s?:r;
  }

  // get end of sequence timestamp
  x;

  // prints the end-start timestamps difference
  printf("\n%ld",r-s);
}

Alternative solution (218 bytes):
If configuring the terminal beforehand is allowed, then we can get rid of the portion of code handling that part.
Here is the same code without terminal manipulation:
#import <stdlib.h>
#define x gettimeofday(&t,0)
#define r t.tv_sec*1000+t.tv_usec/1000
c,i=97;main(){long s=0;struct timeval t;for(;i<'{';){c=getchar();if(c!=i++)puts("\nFail"),exit(0);x;s=s?:r;}x;printf("\n%ld",r-s);}

To make it work:
$ gcc golf.c
$ stty -icanon
$ a.out

runtime example:

Commodore BASIC v2 - 113 bytes
Capital letters must be shifted.
Thanks to Felix Palmen for pointing out some typos, specs
try it
0d=64
1on-(f=26)gO5:gEa$:ifa$=""tH1
2iff=0tHt=ti
3f=f+1:ifa$<>cH(d+f)tH6
4?cH(14)a$;:gO1
5?:?(ti-t)/60*1000:eN
6?"Fail"

Click edit to see the corrected markdown code.

Welcome to the site! Could you add a link to an interpreter (if one exists), so that others can test your code?

Well, this uses the system IRQ (TI is incremented in it) I deemed unsuitable for its lack of precision, but I guess it's fair game here because there's just no way to do better in BASIC :) Still, pasting this in vice, I get a syntax error in 1 -- any help?

Figured it out myself, you have a typo in line one, should be 1on-(f=26)gO4:gEa$:ifa$=""tH1 Nitpicks: 1.) output is on the same line, 2.) output is all-caps -- I think you should fix those, won't take many bytes anyways :)

Adressed the issues, any typos left?

@mondlos everything fixed I guess, you can use this link for online demo :)

MSX-BASIC, 126 characters
1C=97:GOSUB3:TIME=0
2IFASC(C$)<>CTHEN?"Fail":ENDELSEIFC=122THEN?TIME*20:ENDELSEC=C+1:GOSUB3:GOTO2
3C$=INKEY$:IFC$=""GOTO3
4RETURN

TIME is an internal MSX-BASIC variable that increases by one every 20 milliseconds.

Perl 5, 79 93 +31 (-MTerm::ReadKey -MTime::HiRes=time) bytes
$|=1;map{ReadKey eq$_||exit print"
Fail";$s||=time}a..z;print$/,0|1e3*(time-$s)

$|=1 is not sufficient to set terminal in raw mode, stty -icanon should be run before or
ReadMode 3;map{ReadKey eq$_||exit print"
Fail";print;$s||=time}a..z;print$/,0|1e3*(time-$s)

to see characters in the terminal after running command : stty echo or stty echo icanon

Good old ReadKey! You can save a few bytes here and there, 1e3 for 1000, $s||=time and if you set $s first and then call ReadKey, you can swap out the map to a postfix for. I'd like to say die instead of exit print, but I think you're right there... I tinkered with printf"\n%i" but that ended up larger, and I thought about using $- instead of $s, but that was stupid! :)

@DomHastings, thank you for your help, I could save 4 bytes, but i added 5 bytes to set unbuffered input $|=1;, also $s||=time can't be swap out the map because timer must start after first key pressed, and die would echo Fail on stderr instead of stdout.

Happy to help, hope you don't mind me offering ideas! Yeah, it's s shame, exit print is so long! Sorry, I don't think I explained my thought for the for properly: $s||=time,ReadKey eq$_||exit print" Fail"for a..z should work I think... Maybe even $|=$s||=... or $|=map... if you prefer that approach! Think you pretty much nailed it though!

$|=map.. doesn't set unbuffered input in new terminal (I had the error when removing, ReadMode 3, because I was testing in the same session), and $s||=time before first ReadKey would start timer too early

Ahh, I misunderstood, I get it now, didn't wait long enough after starting to script to check that... :) Shame about $|, but again, it's storing after the loop which is too late! You're one step ahead!

Mathematica (notebook expression), 248 bytes
DynamicModule[{x={},s=0,t=0},EventHandler[Framed@Dynamic[If[x=={"a"}&&s<1,s=SessionTime[]];Which[x==a,If[t==0,t=SessionTime[]-s];1000t,x==a~Take~Length@x,""<>x,1>0,"Fail"]],Table[{"KeyDown",c}:>x~AppendTo~CurrentValue@"EventKey",{c,a=Alphabet[]}]]]

How it works
DynamicModule[{x={},s=0,t=0},
  EventHandler[
    Framed@Dynamic[
      If[x=={"a"} && s<1,s=SessionTime[]];
      Which[
        x==a,If[t==0,t=SessionTime[]-s];1000t,
        x==a~Take~Length@x,""<>x,
        1>0,"Fail"]],
    Table[{"KeyDown",c}:>x~AppendTo~CurrentValue@"EventKey",
      {c,a=Alphabet[]}]]]

A DynamicModule with an EventHandler that responds to lowercase letter keypresses. The variables x, s, and t hold the letters pressed so far, the start time, and the end time, respectively. As soon as we notice x being equal to {"a"}, we start the time; we display either the total time spent, or the string built so far, or "Fail" depending on which condition is met.
We could save another byte with t<1 rather than t==0 if we can assume that nobody is fast enough to type the alphabet in less than one second :)
If you're trying this out in a Mathematica notebook, keep in mind that you have to click inside the frame before your keypresses will be registered. (This is the reason that we need the frame to begin with; if Framed is not there, then the entire object selected changes when a key is pressed, so it stops being selected and you'd have to click again.)

APL (Dyalog), SBCS, 114 153 bytes
Using a GUI form to handle keypress events:
t←⍬
a←819⌶⎕A
f←{⍬≡t:f ⍵⊣t⊢←⎕AI⋄⊃a≠⍞←3⊃⍵:⎕EX⎕A⊣⎕←'Fail'⋄'z'=a~←⊃a:⎕←3⊃⎕AI-t}
⎕DQ⎕A⎕WC'Form'('Event' 'KeyPress' 'f')

(Golfed by Adám; I think it would be odd for him to be awarding a bounty for an answer which is now mostly his golf rewrite, so that's here, and my original is below. This version handles the "exit on failure" part of the spec, too.]
t←⍬
a←(819⌶)⎕A
∇w
'W'⎕WC'Form'('Event' 'KeyPress' 'f')
⎕DQ'W'
∇
∇f e
{26=≢a:t⊢←⎕TS}⍬
{e[3]=1↑a:{⍞←1↑a⋄a⊢←1↓a}⍬⋄⎕←'Fail'}⍬
{0=≢a:⎕←60 60 1e3⊥4↓⎕TS-t}⍬
∇
w

Image of it (the first posted version) in use, Dyalog APL 17.1:

Explanation.
It's a function w which loads a GUI form and adds an event handler to it, and starts listening for events, and the call back which handles the alphabet.
Lambda functions are used to get guard pattern matching, instead of longer :If ⋄ cond ⋄ code ⋄ :Else ⋄ code ⋄ :EndIF syntax. Guards are {cond: code} pattern, and the {}⍬ pattern is calling a function on an empty numeric vector just to make it run
t←⍬  ⍝ Variable for the time of starting typing

a←(819⌶)⎕A  ⍝ Variable for lowercase alphabet,
               cast from uppercase with I-beam 819

⍝ Function "w" makes window of type 'Form', called 'W', with event handler.
⍝ Callback function "f", and starts event loop.
∇w
'W'⎕WC'Form'('Event' 'KeyPress' 'f')
⎕DQ'W'
∇

⍝ event handler function "f" takes event "e"
∇f e

{26=≢a:t⊢←⎕TS}⍬    ⍝ lambda function (dfn)
                   ⍝ checks if there are 26 letters,
                   ⍝ (i.e. started typing) starts the timer.
                   ⍝ "t" is initialised first, for global scoping.

{e[3]=1↑a:{⍞←1↑a⋄a⊢←1↓a}⍬⋄⎕←'Fail'}⍬ ⍝ guard, if event[3] (key pressed)
                                     ⍝ is the next alphabet letter (first of "a")
                                     ⍝ print 1 from "a", drop 1 from "a"
                                     ⍝ else print "Fail".

{0=≢a:⎕←60 60 1e3⊥4↓⎕TS-t}⍬  ⍝ guard, if all the letters are gone,
                             ⍝ subtract current timestamp from stored,
                             ⍝ drop 4 elements (year, month, day, hour)
                             ⍝ base-convert min, sec, ms to pure ms
                             ⍝ and print.
∇

⍝ run it by calling function "w"
w

C#, 154 152 + 13 = 165 bytes
Saved 2 bytes thanks to Ayb4btu's comments
x=>{
  long t=0,c=97;
  for(;Console.ReadKey().KeyChar==c++&&c<123;t=t<1?DateTime.Now.Ticks:t);
  Console.Write(c>122?"\n"+(DateTime.Now.Ticks-t)/1e4:"\nFail");
}

The code above has whitespace to make it fit in SE without a scrollbar. Whitespace isn't part of the byte count
and 13 bytes for using System;
It's similar to Ayb4btu's version but with the following differences:

Storing datetime as a long, allows us to make c a long also, and short cut the declaration
Loop doesn't need a separate break
It's not actually shorter to use $"interpreted strings" versus adding a needed "\n" onto the milliseconds to make it a string for the inline if
Using a for loop sometimes allows us to save chars over a while, though I think this one wouldn't save over the equivalent while

From Ayb4btu:

s=s==0 can become s=s<1, and c==123 can become c>122

Ungolfed
long t=0,c=97;

for (;                                         //no loop vars declared
  Console.ReadKey().KeyChar == c++ && c < 123; //loop test
  t = t < 1 ? DateTime.Now.Ticks : t          //post-loop assigns
) ;                                            //empty loop body!

//now just need to turn ticks into millis, 10,000 ticks per millis
Console.Write(c>122?"\n"+(DateTime.Now.Ticks-t)/1e4:"\nFail");

Nice solution with how you used DateTime. You can save a couple more bytes by changing s=s==0 to s=s<1 (counting on the fact that s will not be negative), and changing i==123 to i>122.

Also, has this been tested? As I found that i<123 had to go before the ReadKey(), otherwise it waits for another character after z before displaying the time.

Odd, because at the end of the alphabet, z should mean readkey.keychar returns 122 when the user types z, c is also 122, hence 'z' == 122 succeeds, c is then incremented, then c (now 123) is tested against c<123 and fails, stopping the loop .. ?

You're right, I missed the c++ increment when I was looking at it. However, I just tried it and when I type in abcdefghijklmnopqrstuvwxys it gives me a time instead of failing. I believe it is because c still increments even though the KeyChar check fails, therefore passing the c>122 check.

Good point - maybe moving the ++ to the c<123 check will keep the bytecount the same and prevent the c from incrementing if the last char is wrong - no time to debug right now, but I'll take a look at it! cheers :)

Aceto, 70 bytes
d'|d 't9
$z=p zp1
!=   >#v
d,   1 +
cTpaXpn3
Io$'p"*F
|'!=ilnu
@ad,aF"

I start by setting a catch mark and mirroring horizontally(@|), if the value on the stack is truthy. It isn't initially, and later always will be. We will jump back here later if a wrong key is entered.
Next, we push an a on the stack ('a), then we duplicate it and read a single character from the user (d,). If the two characters are not equal (=!), we "crash" ($) and jump back to the catch mark.
Otherwise, we push another "a" and print it, then we set the current time ('apT).
Then we enter our "main loop": We "increment" the current character and "increment" the character ('apToIc), then we duplicate it, read a new character, compare it, and "crash" if it the characters aren't identical (d,=!$).
If we didn't crash, we compare the current character to "z" (d'z=|), if it isn't equal, we print the character, then we push a 1 and jump "conditionally" (in this case: always) to the only o in the code (the begin of our main loop).
If it was equal to z, we mirrored horizontally to some empty space on top. We print "z", then push the current time (minus the starting time; t) and then multiply the number 1000 (gotten by raising 10 to the third power; 91+3F) by it (because we get seconds, not milliseconds). Then we print a newline, the time, and exit (pX).
If we ever crash (bad input by the user), we jump all the way to the beginning. Since we will now have some truthy value on the stack, we will mirror horizontally onto the u, which reverses the direction we're moving in. n prints a newline character, then we push "Fail" on the stack, print it, and exit (pX).

Processing.org 133 142
first code didn't exit
char k=97;int m;void draw(){if(key==k){m=m<1?millis():m;print(key=k++,k>122?"\n"+(millis()-m):"");}if(m>0&&key!=k-1){print("\nFail");exit();}}

GCC, windows, 98 bytes
t;main(i){for(;i++<27;t=t?:clock())if(95+i-getche())return puts("\nFail");printf("\n%d",clock()-t);}

Requires no instantly input for the first key

Ruby: 194 bytes
require 'io/console'
a=[*"a".."z"]
c=0
s=
loop do
i=STDIN.getch
if i==a[c]
print i
s=Time.now if i=='a'
else
puts "\nFail"
exit
end
if i=='z'
puts "\n"+((Time.now-s)*1000).to_s
exit
end
c+=1
end

Python 3, 107 bytes
from time import*;x=time();a=input();print((time()-x)*1000 if a=="abcdefghijklmnopqrstuvwxyz" else "Fail");

Outputs a floating point number. Relies on lowercase alphabet.

Java (Android), 709 bytes

And here I thought Java Console was already verbose.

Imagine complaining about AWT :omegalul:
package a;import android.widget.*;import android.text.*;public class Z extends android.app.Activity{long g;long f(){return System.currentTimeMillis();}public void onCreate(android.os.Bundle b){super.onCreate(b);EditText t=new EditText(this);t.setSingleLine();t.setInputType(144);t.addTextChangedListener(new TextWatcher(){public void beforeTextChanged(CharSequence s,int a,int b,int c){if(g<1)g=f();}public void onTextChanged(CharSequence s,int a,int b,int c){}public void afterTextChanged(Editable s){}});t.setOnEditorActionListener((x,y,z)->{t.setError((""+t.getText()).equals("abcdefghijklmnopqrstuvwxyz")?f()-g+"":"Fail");return true;});addContentView(t,new android.view.ViewGroup.LayoutParams(-1,-2));}}

Commented version:
// Android requires all Activities to be in a package.
package a;
// EditText
import android.widget.*;
// TextWatcher, Editable
import android.text.*;
// just use full package names for the rest

// yes, we need this entire signature.
public class Z extends android.app.Activity {
    // timer
    long g;
    // Wrapper because it is shorter than calling this behemoth
    // Gets the current time
    long f() {
        return System.currentTimeMillis();
    }

    // Activity entry point
    public void onCreate(android.os.Bundle b) {
        super.onCreate(b);
        // Android Studio doesn't have var. They abandoned Java 10 in favor of Kotlin.
        //  geeeeeeeeee I wonder why ANYone would abandon programming for Android in Java... :P
        EditText t = new EditText(this);
        // This sets the enter key to a submit key, allowing us to catch OnEditorAction
        t.setSingleLine();
        // no autocomplete 4 u
        // InputType.VISIBLE_PASSWORD
        t.setInputType(144);
        // The main reason this is so verbose is because the requirement needs us to start
        // timing on the first character TYPED. It would be much easier to add an onClick or onFocus
        // listener instead, but nooooo. :(
        t.addTextChangedListener(new TextWatcher() {
            // why
            public void beforeTextChanged(CharSequence s, int a, int b, int c) {
                // Start our timer the first time the user types something.
                if (g < 1) g = f();
            }
            // three
            public void onTextChanged(CharSequence s, int a, int b, int c) {
            }
            // methods?
            public void afterTextChanged(Editable s) {
            }
        });
        // When they hit submit, verify using the obvious way.
        // I _may_ be able to verify in TextWatcher, but TextWatcher is not char by char. IDK, I haven't experimented with it yet.
        t.setOnEditorActionListener((x, y, z) -> {
            // Show the result via setError, which is on a new line. :)
            t.setError(("" + t.getText()).equals("abcdefghijklmnopqrstuvwxyz") ? f() - g + "" : "Fail");
            return true;
        });
        // Append to the root view.
        // -1 == LayoutParams.MATCH_PARENT
        // -2 == LayoutParams.WRAP_CONTENT
        addContentView(t, new android.view.ViewGroup.LayoutParams(-1, -2));
    }
}

https://streamable.com/7xb1xl
Edit: I have gotten very good at this by the way, look at my mad skills.

source: Stack Exchange

license: 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/

sort: votes


text:
Triangles of Hexagons
Suppose an infinite tiling of hexagons composed of |/\ characters.
 / \ / \ / \ / \
|   |   |   |   |
 \ / \ / \ / \ /  etc.
  |   |   |   |
   \ / \ / \ /

Given input n > 0, output a triangular portion of that tiling as depicted in the below examples, anchored with a _ in the middle of a hexagon:
n=1
\_/

n=2
\/ \/
 \_/

n=3
\  |  /
 \/ \/
  \_/

n=4
\/ \ / \/
 \  |  /
  \/ \/
   \_/

n=5
\  |   |  /
 \/ \ / \/
  \  |  /
   \/ \/
    \_/

n=6
\/ \ / \ / \/
 \  |   |  /
  \/ \ / \/
   \  |  /
    \/ \/
     \_/

n=7
\  |   |   |  /
 \/ \ / \ / \/
  \  |   |  /
   \/ \ / \/
    \  |  /
     \/ \/
      \_/

n=8
\/ \ / \ / \ / \/
 \  |   |   |  /
  \/ \ / \ / \/
   \  |   |  /
    \/ \ / \/
     \  |  /
      \/ \/
       \_/

and so on

Rules

Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.
Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
Output can be to the console, saved as an image, returned as a list of strings, etc.
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

If you count the number of end points along the top of the result, you get A029578 (the natural numbers interleaved with the even numbers) with an offset of 4. 2,4,3,6,4,8,5,10,6,12,7,14,...

What does "saved as an image" mean? is this tagged ascii-art?

@tsh For things like HyperCard or something, where output to a canvas is their equivalent of "stdout" output. I'm not picky on how the output is displayed.

Python 2, 86 bytes
i=k=input()
while i:i-=1;print(" "*(k+~i)+"\\"+i*' /  |\  '[i%2::2])[:k-~i]+"_/"[i>0:]

Try it online!
One of Erik’s tricks allowed me to golf 3 bytes! Saved 3 bytes thanks to Jonathan Allan.
How this works
First off, this gets input from STDIN and assigns it to two separate variables i and k. Then, while the variable i is truthy, we decrement it and generate the strings accordingly; this is a shorthand for looping from the input - 1 all the way down to 0.
Generating the Strings
I'll split this into more parts:

First off, getting the leading spacing is achieved with " "*(k+~i). Since i is mapped through the range (input, 0], we must subtract it from k (our safely stored original input), decrement and repeat a space that many times.
+"\\" - Adds the character "\" to the spaces above.
' /  |\  '[i%2::2] - Generates our two strings, namely "/ \ " and "  | ", in the following manner:

If i is odd, i % 2 is 1, thus [i%2::2] returns each 2 characters of our larger string, starting at index 1 (0-indexed).
If i is even, i % 2 is 1, thus the mechanism above does the same except it starts at index 0.

+~-i* - Repeats the string generated above, either "/ \ " or "  | ", i-1 times, and appends it to the other strings. The benefit of the bitwise operator (~ - Bitwise Complement, Equivalent to i subtracted from -1) is that it doesn't require parenthesis in this context.
[:k-~i] - Gets all the characters of the strings concatenated above until index k-~i = k - (-1 - i) = k + 1 + i.
+"_/"[i>0:] - This only adds "/" if i ≥ 1, else it appends _/.

Full example / execution details
Let's grab an example of how things work for an input of 4:
i=k=input()        # i and k are assigned to 4.
while i:           # Starts the loop. The initial value of i is 4.
i-=1;              # Decrement i. i is now 3.
" "*(k+~i)         # A space repeated k - 1 - i = 4 - 1 - 3 = 0 times.
+"\\"              # Plus the character "\". CS (Current string): "\".
' /  |\  '[i%2::2] # The string ' /  |\  '[3%2::2] = ' /  |\  '[1::2] = "/ \ ".
i*                 # ^ repeated i = 3 times: "/ \ / \ / \ ".
+                  # And concatenate. CS: "\/ \ / \ / \ "
[:k-~i]            # Get the characters of ^ up to index k + 1 + i = 4 + 1 + 3 = 8.
                   # CS: "\/ \ / \".
+"_/"[i>0:]        # Append "_/"[i>0:] = "_/"[3>0:] = "_/"[1:] = "/".
                   # CS: "\/ \ / \/".
print              # Output the result "\/ \ / \/".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i becomes 2.
" "*(k+~i)         # " " repeated 4 - 2 - 1 = 1 time.
+"\\"              # Plus "\". CS: " \".
' /  |\  '[i%2::2] # ' /  |\  '[2%2::2] = ' /  |\  '[::2] = "  | ".
+i*                # Repeat i = 2 times and append: "  | ". CS: " \  |  |".
[:k-~i]            # CS up until k + 1 + i = 4 + 2 + 1 = 7. CS: " \  |  ".
+"_/"[i>0:]        # Append "/". CS: " \  |  /".
print              # Outputs the CS: " \  |  /".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i is now 1.
" "*(k+~i)         # " " repeated 4 - 1 - 1 = 2 times.
+"\\"              # Plus "\". CS: "  \".
' /  |\  '[i%2::2] # ' /  |\  '[2%2::2] = ' /  |\  '[::2] = "/ \ ".
+i*                # Repeat i = 1 time and append: "/ \ ". CS: "  \/ \ ".
[:k-~i]            # CS up until k + i + 1 = 4 + 2 = 6. CS: "  \/ \".
+"_/"[i>0:]        # Append "/". CS: "  \/ \/".
print              # Outputs the CS: "  \/ \/".
while i:           # i is truthy (> 0), thus we loop again.
i-=1;              # Decrement i. i is now 0.
" "*(k+~i)         # " " repeated 4 - 1 - 0 = 3 times.
+"\\"              # Plus "\". CS: "   \".
' /  |\  '[i%2::2] # ' /  |\  '[1%2::2] = ' /  |\  '[1::2] = "  | ".
+i*                # Repeat i = 0 times and append: "   \". CS: "   \".
[:k-~i]            # CS up until k + i + 1 = 4 + 0 + 1 = 5. CS: "   \".
+"_/"[i>0:]        # Append "_/" (because i > 0 is False since i == 0). CS: "  \_/".
print              # Outputs the CS: "  \_/".
while i:           # i == 0, hence the condition is falsy and the loop ends.
                   # Program terminates.

Move the i-=1 to the start of the loop and use a slightly different right-hand-side formation to get it down to 87 bytes.

...in fact even better at 86 bytes using something like your right-hand-side formation :)

@JonathanAllan ... Thanks! (Although redoing the explanation will be... tough!... sigh)

@JonathanAllan I found an alternative that does not reverse the order of the decrement statement.

Python 2, 90 bytes
n=N=input()
while N:print' '*(n-N)+'\\'+(('/   \|  '[N%2::2]*n)[:N*2-1],'_')[N<2]+'/';N-=1

Try it online!

Python 2, 123 112 110 109 100 98 96 bytes
i=n=input()
while i:a=i%2;print' '*(n-i)+'\%s/'%['_',((-~i/2)*'/   \  |'[a::2])[a:~a]][i>1];i-=1

Try it online!

Saved a bunch of bytes by using input and string formatting as in Rod's answer
Saved 2 bytes thanks to Mr. Xcoder

You can save 2 bytes by replacing -1-a with ~a (as I did in my answer).

@Mr.Xcoder Thanks :)

05AB1E, 33 bytes
1ŸεÐi'_ë"/ \   | "4ôsès∍}'\ì.∞}.c

Try it online!

Try it online! - Tried exploiting the "0300" and "2010" pattern, didn't go so hot.

@MagicOctopusUrn That doesn't print an underscore too :p

Mathematica, 131 bytes
Join[Table[s=StringRiffle@Table[If[OddQ@i,"/ \\"," | "],⌈i/2⌉];""<>{"\\",If[!OddQ@i,{" ",s," "},s],"/"},{i,#-1,1,-1}],{"\_/"}]&

returns a list of strings
Try it online!

Retina, 129 119 112 bytes
\d+
$*

¶$`a $'$'
m`$
/
  /$
_/
^.¶

a(    )*/
a$#1/
\d+
$*
1
/ a
 (    )*/
$#1/
\d+
$*
1
 |
a /¶
a/¶
a
\

Try it online!

Charcoal, 26 bytes
ＮθＧ↖→↓θ“ ″✂=ＡＬ«Q"η\`”←_↖θ‖Ｂ

Try it online! Link is to verbose version of code.

Python 2, 103 bytes
i=n=input()
while i:print' '*(n-i)+'\%s/'%' '.join(['/\\'*(-~i/2),['_',' '+'| '*(i/2)][i>1]][i%2]);i-=1

Try it online!

APL (Dyalog), 97 93 bytes
{⍵=1:1 3⍴'\_/'⋄x←' ',' ',⍨∇⍵-1⋄y←1+2×⍵-1⋄2|⍵:x⍪⍨'\','/',⍨y⍴'  | '⋄x⍪⍨'\/','\/',⍨(y-2)⍴' \ /'}

Try it online!

SOGL V0.12, 28 27 bytes
╔.H∫"C↕‽«‘4nwιF«Im}¹⌡¾\/¹№╚

Try it Here!

Haskell, 96 95 bytes
f n=[([1..n-x]>>" ")++'\\':take(2*x+1)(cycle$("_":a)!!x)++"/"|x<-[n,n-1..0]]
a="/ \\ ":"  | ":a

Try it online!
0-indexed and returns a list of lines.

Haskell, 101 99 bytes
j 1=["\\_/"]
j n|r<-([1,3..n-1]>>)=('\\':cycle[init$r"/ \\ ",' ':r" |  "]!!n++"/"):map(' ':)(j$n-1)

Returns a list of lines.
Try it online!
How it works:
j 1=["\\_/"]               -- base case, n=1

j n                        -- for all other n
   |r<-([1,3..n-1]>>)      -- let r be the function that makes n/2 copies of
                           -- it's argument
   =                       -- the result is
      '\\':                --  a backslash, followed by
      cycle[  ]!!n         --  the inner part, which is
          init$r"/ \\ "    --    all but the last char of some copies of
                           --    "/ \ " for even line numbers, or
          ' ':r" |  "      --    some copies of " |  " prepended by a space
                           --    for odd line numbers
                           --    (chosen by indexing an infinite list of
                           --     both values alternating)
      ++"/"                --  followed by a slash
    :                      --  and append a
               j$n-1        --  recursive call with n-1
      map(' ':)            --  where each line is prepended by a space

Edit: @Laikoni saved two bytes. Thanks!

([1,3..n-1]>>) can be used instead of ([1..div n 2]>>) .

Java (OpenJDK 8), 315 306 bytes
i->{String r="";int j=0,k,u=i*2;char[][]c=new char[i][u+1];c[i-1][i]=95;for(;j<i;r+="".valueOf(c[j++]).replace('\0',' ')+"\n")for(k=0;k<u+1;k++){if(k==j)c[j][k]=92;if(k==u-j)c[j][k]=47;if(k>j&k<u-j)if((i-j)%2<1)c[j][k]=(k-j-1)%2<1?(char)(47+((k-j-1)/2)%2*45):32;else if((k-j-1)%4==2)c[j][k]='|';}return r;}

Try it online!

Java (OpenJDK 8), 198 bytes
Finally got it below 200 bytes. Will probably post an explanation later.
i->{for(int k=i+1;i>0;System.out.println(("".format("%"+(k-i)+"s","")+"\\"+(i<2?"":"".format("%"+(i-1)+"s","")).replace(" ","/ \\ ,  | ".split(",")[i%2])).substring(0,i<2?k:k+i)+(--i<1?"_/":"/")));}

Try it online!

JavaScript (ES6), 89 85 bytes
f=(y,s='\\')=>--y?s+(y&1?' / \\':' |  ').repeat(y).slice(~y-y)+`/
`+f(y,' '+s):s+'_/'

Demo

f=(y,s='\\')=>--y?s+(y&1?' / \\':' |  ').repeat(y).slice(~y-y)+`/
`+f(y,' '+s):s+'_/'

console.log(f(1))
console.log(f(2))
console.log(f(3))
console.log(f(4))
console.log(f(5))
console.log(f(6))
console.log(f(7))

CJam, 43
ri_{S*'\@(:X"  | / \ "4/=X*X2*)<'_e|'/NX}/;

Try it online

PHP, 89+1 bytes
while($k=$argn-$n)echo($p=str_pad)("",$n++),$p("\\",2*$k,$k>1?$k&1?"  | ":"/ \ ":_),"/
";

Run as pipe with -nR or try it online.

Pyth,  46  44 bytes
j_m+<++*;t-Qd\\*d%2>" /  |\  "%d2h+Qd>"_/"._

Try it here!

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


text:
Magic email transformation! Or: help the NSA extract your metadata from your email address
Given an email address, the result of a transformation applied to that email address, and a second email address, return the output of the same transformation applied to the second email address.
The email addresses will all have the following structure:
A string of positive length containing alphanumeric characters and at most one . (the local part), followed by an @ symbol, followed by a string of positive length containing alphanumeric sumbols (the domain), followed by a . symbol, and a final string of positive length containing alphanumeric characters (the TLD).
There are four allowed transformations:

Identity (no change). (a.b@c.d -> a.b@c.d)
Returning just the local part (everything before the @) unmodified (a.b@c.d -> a.b).
Returning the local part split on the . if present, with the first symbol of each half capitalised. (a.b@c.d -> A B).
Returning just the domain (everything between the @ and the final .) unmodified. (a.b@c.d -> c).

When more than one transformation is possible, you can give the output of any of the possibilities. Whitespace at the start and end of output don't matter, but in the middle does (i.e. if you split a.b to A B there should be just one space in the middle [and any number at the start and end of output], but if you split a., then A with any number of spaces on either side are all acceptable).
Examples (input | output):
john.doe@gmail.com, John Doe, phillip.maini@gmail.com         | Phillip Maini
John.Doe@gmail.com, John Doe, Phillip.Maini@gmail.com         | Phillip Maini
foo.bar@hotmail.com, foo.bar, gee.whizz@outlook.com           | gee.whizz
foo.bar@hotmail.com, foo.bar, gEe.Whizz@outlook.com           | gEe.Whizz
rodney.dangerfield@comedy.net, comedy, michael.scott@office.0 | office
.jones@x.1, Jones, a.@3.z                                     | A
.jones@x.1, .jones@x.1, a.@3.z                                | a.@3.z
.jones@x.1, .jones, a.@3.z                                    | a.
.jones@x.1, x, a.@3.z                                         | 3
.@b.c, .@b.c, 1@2.3                                           | 1@2.3
john.jones@f.f, John Jones, 1in.thehand@2inthe.bush           | 1in Thehand
chicken.soup@q.z, Chicken Soup, fab@ulou.s                    | Fab
lange@haare.0, lange, fat.so@fat.net                          | fat.so
Lange@haare.0, Lange, fat.so@fat.net                          | {fat.so, Fat So} # either acceptable
chicken@chicken.chicken, chicken, horse@pig.farm              | {horse, pig} # either acceptable

Usual rules and loopholes apply.

Shouldn't the last test case return "horse"? I don't see why it can return "pig" instead.

@EriktheOutgolfer because the 4th transformation is to return just the domain (the part between @ and final .). Since the local part and domain are both chicken, it's ambiguous whether it's the 2nd or 4th transformation

Oh, I misinterpreted that.

May we require that the relevant input is formatted with the space in all cases (e.g. in the test where the output is A [with a trailing space] that the second input be Jones [with a leading space])?

I don't understand why .jones@x.1, Jones, a.@3.z is A - if jones is matched that means the matching part is the part between the first period and the @ symbol.  But that would result in an empty string because the a is before the first period and not after.

@JerryJeremiah .jones@x.1 -> Jones is only possible by the third transformation (splitting on the . in the local part and doing Camel Case). There is no transformation that matches just between a period in the local part and the @ (and if there were, this would still not be an example of it - note that capitalisation is significant)

@JonathanAllan Hmm I'll allow it (bc I don't want to apply restrictions that will undermine existing good answers - wish I had thought about this in advance!)

Java 8, 254 240 236 bytes
(a,b,c)->{String A[]=a.split("@"),C[]=c.split("@"),x="";for(String p:C[0].split("\\."))x+=(p.charAt(0)+"").toUpperCase()+p.substring(1)+" ";return a.equals(b)?c:A[0].equals(b)?C[0]:A[1].split("\\.")[0].equals(b)?C[1].split("\\.")[0]:x;}

-4 bytes thanks to @LukeStevens.
Explanation:
Try it here.
(a,b,c)->{                  // Method with three String parameters and String return-type
  String A[]=a.split("@"),  //  Split `a` by "@" into two parts
         C[]=c.split("@"),  //  Split `c` by "@" into two parts
         x="";              //  Temp-String
  for(String p:C[0].split("\\."))
                            //  Loop over the first part of `c`, split by dots
    x+=                     //   Append String `x` with:
       (p.charAt(0)+"").toUpperCase()
                            //    The first character as uppercase
       +p.substring(1)      //    + the rest of the String
       +" ";                //    + a space
                            //  End of loop (implicit / single-line body)
  return a.equals(b)?       //  If input `a` and `b` are exactly the same:
    c                       //   Return `c`
   :A[0].equals(b)?         //  Else-if the first part of `a` equals `b`:
    C[0]                    //   Return the first part of `c`
   :A[1].split("\\.)[0].equals(b)?
                            //  Else-if the domain of `a` equals `b`
    C[1].split("\\.)[0]     //   Return the domain of `c`
   :                        //  Else:
    x;                      //   Return String `x`
}                           // End of method

You can knock off 4 bytes by using (p.charAt(0)+"").toUpperCase() instead of Character.toUpperCase(p.charAt(0)).

@LukeStevens Thanks! I had (char)(p.charAt(0)&~32) at first, but this didn't work due to the 1in Thehand test case. But uppercasing it as String is indeed shorter than Character.toUpperCase, so thanks!

Jelly, 40 bytes
Pre-emptive thanks to Erik the Outgolfer for noticing the failure of using Œt (title-case) and hence Œu1¦€K over ŒtK
-1 byte thanks to Erik the Outgolfer (rearrangement of ⁵⁸ç⁹¤Ŀ to çµ⁵⁸Ŀ)

ÑṪṣ”.Ḣ
ṣ”@
ÇḢ
Çṣ”.Œu1¦€K
⁹ĿðÐ€5i
çµ⁵⁸Ŀ

A full program taking exampleEmail, exampleOutput, realEmail and printing the result.
Try it online!
How?
Performs all four transforms (plus a precursor one), finds the first one that yields the example from the first email, then applies it to the second email:
            - Link 1, do nothing: email
            - do nothing but return the input

ÑṪṣ”.Ḣ      - Link 2, the domain: email
Ñ           - call the next link (3) as a monad (split at "@")
 Ṫ          - tail
  ṣ”.       - split at "."
     Ḣ      - head

ṣ”@         - Link 3, split at @: email
ṣ”@         - split at "@"

ÇḢ          - Link 4, local part: email
Ç           - call the last link (3) as a monad (split at "@")
 Ḣ          - head

Çṣ”.Œu1¦€K  - Link 5, name-ified: email
Ç           - call the last link (4) as a monad (get the local part)
 ṣ”.        - split at "."
       ¦€   - for €ach sparsley apply:
      1     - ...to index: 1
    Œu      - ...action: uppercase
         K  - join with space(s)

⁹ĿðÐ€5i     - Link 6, index of first correct link: exampleEmail; exampleOutput
   Ð€5      - map across (implicit range of) 5 (i.e. for each n in [1,2,3,4,5]):
  ð         -   dyadicly (i.e. with n on the right and exampleEmail on the left):
 Ŀ          -     call referenced link as a monad:
⁹           -     ...reference: chain's right argument, n
      i     - first index of exampleOutput in the resulting list

çµ⁵⁸Ŀ       - Main link: exampleEmail; exampleOutput
ç           -   call the last link (6) as a dyad (get the first "correct" link index)
 µ          - monadic chain separation (call that L)
   ⁸        - chain's left argument, L
    Ŀ       - call the link at that reference as a monad with input:
  ⁵         -   program's third input, realEmail

Notes:

Assumes the input exampleOutput is strictly the same as the output would be.
The "precursor" (the result of link 3) is tested for matching the exampleOutput, but it won't match unless the exampleOutput itself is a list of lists of characters. As such the inputs should probably be quoted (Python formatting may be used here) to avoid the possibility of interpreting it as such.

39 bytes

Haskell, 208 bytes
import Data.Char
s c""=[]
s c a=w:f t where
 (w,t)=span(/=c)a
 f(_:y)=s c y
 f _=[]
h=head
u""=""
u(x:y)=toUpper x:y
l=h.s '@'
f x y=h[t|t<-[id,l,unwords.filter(/="").map u.s '.'.l,h.s '.'.last.s '@'],t x==y]

Try it online!
It is sad I had to spend 59 bytes on reinventing split (s).
The solution creates a list of transformations and returns the first one that leads to the expected result.

Welcome to the site! I don;t know Haskell, but is it possible to remove any of the whitespace characters, such as newlines and spaces?

Nice first answer! You might be interested in our collection of tips for golfing in Haskell, especially this and this should save some bytes.

Also feel free to join us in Of Monads and Men, a  chat room for golfing and general discussion of Haskell.

Python 2, 135 bytes
s,r,x=input()
def f(x):S,D=x.split('@');return x,S,' '.join(map(str.capitalize,S.split('.'))),D.split('.')[0]
print f(x)[f(s).index(r)]

Try it online!

-3 bytes by moving strip

@ovs thanks, anyways rules changed to remove the need for it

JavaScript (ES6), 145 bytes
Invoke with currying syntax, e.g. f('chicken.soup@q.z')('Chicken Soup')('fab@ulou.s')
x=>y=>[x=>x,s=x=>x.split`@`[0],x=>s(x).split`.`.map(w=>w&&w[0].toUpperCase()+w.slice(1)).join` `.trim(),x=>/@(.+)\./.exec(x)[1]].find(f=>f(x)==y)

f=x=>y=>[x=>x,s=x=>x.split`@`[0],x=>s(x).split`.`.map(w=>w&&w[0].toUpperCase()+w.slice(1)).join` `.trim(),x=>/@(.+)\./.exec(x)[1]].find(f=>f(x)==y)

for(const [x, y, z] of [
['john.doe@gmail.com', 'John Doe', 'phillip.maini@gmail.com'], // Phillip Maini
['John.Doe@gmail.com', 'John Doe', 'Phillip.Maini@gmail.com'], // Phillip Maini
['foo.bar@hotmail.com', 'foo.bar', 'gee.whizz@outlook.com'], // gee.whizz
['foo.bar@hotmail.com', 'foo.bar', 'gEe.Whizz@outlook.com'], // gEe.Whizz
['rodney.dangerfield@comedy.net', 'comedy', 'michael.scott@office.0'], // office
['.jones@x.1', 'Jones', 'a.@3.z'], // A
['.jones@x.1', '.jones@x.1', 'a.@3.z'], // a.@3.z
['.jones@x.1', '.jones', 'a.@3.z'], // a.
['.jones@x.1', 'x', 'a.@3.z'], // 3
['.@b.c', '.@b.c', '1@2.3'], // 1@2.3
['john.jones@f.f', 'John Jones', '1in.thehand@2inthe.bush'], // 1in Thehand
['chicken.soup@q.z', 'Chicken Soup', 'fab@ulou.s'], // Fab
['lange@haare.0', 'lange', 'fat.so@fat.net'], // fat.so
['Lange@haare.0', 'Lange', 'fat.so@fat.net'], // {fat.so, Fat So} # either acceptable
['chicken@chicken.chicken', 'chicken', 'horse@pig.farm'], // {horse, pig} # either acceptable
]) console.log( f(x)(y)(z) )

Mathematica, 217 bytes
(L=Capitalize;T@x_:=(M=StringSplit)[x,"@"];P@x_:=#&@@T[x];W@x_:=If[StringContainsQ[P@x,"."],StringRiffle@L@M[P@x,"."],L@P@x];Z@x_:=#&@@M[T[x][[2]],"."];If[#==#2,#3,If[#2==P@#,P@#3,If[#2==W@#,W@#3,If[#2==Z@#,Z@#3]]]])&

Try it online!

Ruby, 117 106 102 bytes
->a,b,c{r=[/.*/,/(?<=@)\w*/,/[^@]*/].find{|x|r=c[x];a[x]==b}?r:r.sub(?.," ").gsub(/\b(.)/){$1.upcase}}

Try it online!

Jelly, 43 bytes
ḢŒlṣ”.Œu1¦€K
ṣ”@Wẋ4j”@$ḷ/ÇṪṣ”.Ḣ$$4ƭ€
Çiị⁵Ç¤

Try it online!

Would ŒtK work in place of Œu1¦€K to save 3?

...and what's the need for Œl?

^ ah I see that 1in.thehand would not work with ŒtK.

@JonathanAllan Yep, that's the reason why I didn't use that, and also the reason ovs's (now deleted) answer was invalid (str.title).

CJam, 42
q~@{[_\'@/~'./0=\_'.%{(eu\+}%S*]}:T~@a#\T=

Try it online
Explanation:
q~        read and evaluate the input (given as 3 quoted strings)
@         bring the first string to the top of the stack
{…}:T     define a function T that calculates the 4 transformations of a string:
  [       begin array
  _\      duplicate the string, and swap with the other copy to bring it in the array
           (1st transformation)
  '@/~    split by '@' and put the 2 pieces on the stack
  './0=   split the 2nd piece by '.' and keep the first part
           (4th transformation)
  \_      swap with the piece before '@' and duplicate it
           (2nd transformation)
  '.%     split by '.', removing the empty pieces
  {…}%    transform the array of pieces
    (eu   take out the first character and capitalize it
    \+    prepend it back to the rest
  S*      join the pieces by space
           (3rd transformation)
  ]       end array
~         execute the function on the first string
@a        bring the 2nd string to the top of the stack, and wrap it in an array
#         find the position of this string in the array of transformations
\T        bring the 3rd string to the top and call function T
=         get the transformation from the array, at the position we found before

PHP 7.1, 176 bytes
<?$e=explode;[,$p,$q,$r]=$argv;echo$p==$q?$r:($e('@',$p)[0]==$q?$e('@',$r)[0]:($e('.',$e('@',$p)[1])[0]==$q?$e('.',$e('@',$r)[1])[0]:ucwords(join(' ',$e('.',$e('@',$r)[0])))));

Try it online!
PHP < 7.1, 180 bytes
Versions under 7.1 would need to change the [,$p,$q,$r]=$argv to list(,$p,$q,$r)=$argv, adding 4 bytes.

GNU sed, 105 + 1(r flag) = 106 bytes
The first three s commands check for the identity, local part and domain transformations respectively. If one transformation matches, then it is applied to the second email address and the following s commands will fail due to a lack of the input format.
s:^(.*),\1,::
s:(.*)@.*,\1,(.*)@.*:\2:
s:.*@(.*)\..*,\1,.*@(.*)\..*:\2:
s:.*,([^.]*)\.?(.*)@.*:\u\1 \u\2:

Try it online!
The local part split transformation (last s command) is the most expensive to check, in terms of bytes, therefore I placed it at the end and assumed it matches (since the other ones failed by that time), going directly to its application.


text:
Don't repeat yourself in Rock-Paper-Scissors
Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, P, S is square-free if it does not contain a sequence that repeats twice. That is to say, the word can not be written as
a x x b

where a and b are words of any length and x is a word of length at least one, all made of the letters R, P, S.
Task
Write a program that generates the square-free words of the letters R, P, S of length n where the number 1 <= n <= 10 is taken as input.
Example
For example the square-free words of length 3 are
RPR, RSR, RPS, RSP, SPS, SRS, SRP, SPR, PRP, PSP, PSR, PRS
and those of length 4 are
RPRS, RPSR, RPSP, RSRP, RSPR, RSPS, PRPS, PRSR, PRSP, PSRP, PSRS, PSPR, SRPR, SRPS, SRSP, SPRP, SPRS, SPSR
and note that for example SPSP or PRPR are not square-free
Rules

This is codegolf, shortest program wins, standard loopholes are closed.
You may print the words or create them in memory.
Your program may be written as a function.

References
Wikipedia entry on square-free words
The number of square-free ternary words of given length are
in https://oeis.org/A006156
Related: Arbitrary-Length Ternary Squarefree Words

A test case for n>3 would be a good idea, because there has been some confusion about repeated characters vs. repeated sequences.

Please comment on the planned follow-up in the sand-box: https://codegolf.meta.stackexchange.com/a/14133/45211

I don't think the "natural-language" tag should apply here

Ah, "words" got expanded in "natural-language", I removed it.

Is RSPSP square free?

No, it contains the square SP SP

Ruby, 39 bytes
->n{(?P*n..?S*n).grep_v /[^RPS]|(.+)\1/}

This hilariously inefficient function generates all strings of length N that lie alphabetically between N Ps and N Ss, then filters out the vast majority that contain non-RPS characters. The actual squarefree check just uses a Regexp backreference: (.+)\1.
More idiomatic 65 bytes that finish in a reasonable amount of time for N=10:
->n{%w[R P S].repeated_permutation(n).map(&:join).grep_v /(.+)\1/}

Edit: Saved a byte thanks to G B.

You don't need parentheses on grep_v, just a space between it and the slash (save 1 byte)

"hilariously inefficient" probably describes quite a few answers on this site.

Jelly, 15 14 bytes
“RPS”ṗẆ;"f$$Ðḟ

Try it online!
How it works
“RPS”ṗẆ;"f$$Ðḟ  Main link. Argument: n

“RPS”ṗ          Cartesian power; yield all strings of length n over this alphabet.
            Ðḟ  Filterfalse; keep only strings for which the quicklink to the left
                returns a falsy result.
           $      Monadic chain. Argument: s (string)
      Ẇ             Window; yield the array A of all substrings of s.
          $         Monadic chain. Argument: A
       ;"             Concatenate all strings in A with themselves.
         f            Filter; yield all results that belong to A as well.

Retina, 28 bytes
+%1`1
R$'¶$`P$'¶$`S
A`(.+)\1

Try it online!
Takes input in unary.
Explanation
+%1`1
R$'¶$`P$'¶$`S

This generates all strings made up of RPS of length n. The way we do this is that we repeatedly replace the first 1 in each line. Let's think about the line as <1>, where < is everything in front of the match and > is everything after the match (they're $` and $' respectively in regex substitution syntax, but those look less intuitive). We replace the 1 with R>¶<P>¶<S, where ¶ are linefeeds. So the full result of this substitution is actually <R>¶<P>¶<S>, which is three copies of the line, with the 1 replace with R, P, S, respectively, in each of the three copies. This process stops once all 1s have substituted.
A`(.+)\1

Finally, we simply discard all lines that contain a repetition.

I would have repeatedly replaced 1(.*) with $1R¶$1P¶$1S but the byte-count is the same.

Mathematica, 61 bytes
""<>#&/@{"R","P","S"}~Tuples~#~DeleteCases~{___,x__,x__,___}&

Try it online!

Husk, 15 14 bytes
-1 byte thanks to Zgarb!
fȯεfoE½QΠR"RPS

Try it online!
Builds all possible sequences of the correct length and keeps only the ones whose all substrings (except the empty one) are composed by two different halves.
Damn, I really wanted to beat Jelly here.

14 bytes to tie with Jelly.

Java 8, 285 277 bytes
import java.util.*;Set r=new HashSet();n->p("",((1<<3*n)+"").replaceAll(".","PRS"),n)void p(String p,String s,int n){int l=s.length(),i=0;if(l<1&&(s=p.substring(0,n)).equals(s.replaceAll("(.*)\\1","")))r.add(s);for(;i<l;p(p+s.charAt(i),s.substring(0,i)+s.substring(++i,l),n));}

Although Java is almost always verbose, in this case it's definitely not the right language for a challenge like this. Generating permutations with substrings is bad for performance and inefficient.
Can definitely be golfed some more, though.
-8 bytes thanks to @Jakob.
Explanation:
Try it here. (Performance is too bad for test cases above 3, but it does work locally..)
import java.util.*;   // Required import for Set and HashSet

Set r=new HashSet();  // Result-Set on class-level

n->                   // Method with integer parameter and no return-type
  p("",((1<<3*n)+"").replaceAll(".","PRS"),n)
                      //  Get all permutations and save them in the Set
                      // End of method (implicit / single-line return-statement)

void p(String p,String s,int n){
                      // Separated method with 2 String & int parameters and no return-type
  int l=s.length(),   //  The length of the second input-String
      i=0;            //  Index-integer, starting at 0
  if(l<1              //  If the length is 0,
     &&(s=p.substring(0,n)).equals(s.replaceAll("(.*)\\1","")))
                      //  and it doesn't contain a repeated part:
    r.add(s);         //   Add it to the result-Set
  for(;i<l;           //  Loop (2) from 0 to `l`
    p(                //   Recursive-call with:
      p+s.charAt(i),  //    Prefix-input + the character of the second input at index `i`
      s.substring(0,i)+s.substring(++i,l),
                      //    and the second input except for this character
      n)              //    and `n`
  );                  //  End of loop (2)
}                     // End of separated method

How about this lambda: n->p("",((1<<3*n)+"").replaceAll(".","PRS"),n). Also, why not refactor for(;i<1;p(...)); to while(i<l)p(...);?

@Jakob Thanks. And I always use for(;...;) out of codegolfing-habbit to be honest. Worst case it's the same byte-count as while(...), best case something can be placed inside the for-loop to save bytes. So I try to just not use while at all in codegolfing, because it never benefits the byte-count anyway. It either increases it, or remains the same, so I personally don't bother with the better readability. ;)

Yeah, I always try to make my golfed code as readable as possible at a given byte count. Probably a futile pursuit!

Wait, does my lambda actually work here? I was a bit careless... It generates a string of n PRS sequences, whereas your original loop generated one with 2^(n-2) sequences.

@Jakob n times "PRS" is correct. Mine was generating more because it saved bytes (and decreased performance, but who cares about that with codegolf). ;)

Python 3, 97 96 bytes
f=lambda n:{c+s for c in'RPS'*n for s in f(n-1)or{''}if all(k-s.find(c+s[:k])for k in range(n))}

Returns a set of strings.
Try it online!

Julia 0.6, 65 bytes
!n=n>0?["$c"s for s=!~-n,c="RPS"if~ismatch(r"(.+)\1","$c"s)]:[""]

Try it online!

Perl 5, 37 bytes
sub r{grep!/(.+)\1/,glob"{R,S,P}"x<>}

Try it online!
Function returns an array of the square free strings.
Explained:
The glob generates all combinations of R, S, & P with length equal to the input.  The grep statement filters out the ones that are not square free.

Great use of brace expansion!

R, 97 bytes
cat((x=unique(combn(rep(c('p','r','s'),n),n<-scan(),paste,collapse='')))[!grepl("(.+)\\1",x,,T)])

Try it online!
combn(rep(c('p','r','s'),n),n,paste,collapse='') computes all n-character strings with p, r, s, but it unfortunately duplicates many(*), so we uniquify it, and take those that match the regex (.+)\1, using perl-style matching, then we print out the resultant list.
(*) technically, it generates all combinations of the 3n letters in p,r,s repeated 3 times taken n at a time, then applies paste(..., collapse='') to each combination rather than computing the 3^n strings directly, but this is golfier than an expand.grid (the true Cartesian product).

JavaScript (Firefox 30-57), 69 bytes
f=n=>n?[for(x of f(n-1))for(y of'RPS')if(!/(.+)\1/.test(y+=x))y]:['']

Since all substrings of square-free words are also square-free the check can be done recursively.

Haskell, 101 98 bytes
f n=[x:r|x:r<-mapM(\_->"RPS")[1..n],[x]#r]
h#t@(x:r)=h/=take(length h)t&&(h++[x])#r&&[x]#r
h#t=1<3

Try it online!

JavaScript (ES7), 93 bytes
n=>[...Array(3**n)].map(g=(d=n,i)=>d?'RPS'[i%3]+g(d-1,i/3|0):'').filter(s=>!/(.+)\1/.test(s))

Converts all the integers from 0 to 3ⁿ to (reversed padded) base 3 using RPS as digits and filters them for square-free words.

Julia, 88
f(n)=[filter(A->!ismatch.(r"(.+)\1",join(A)),Iterators.product(repeated("RPS",n)...))...]

Nothing fancy.

C# / LINQ, 169
Enumerable.Range(0,(int)Math.Pow(3,n)).Select(i=>string.Concat(Enumerable.Range(1,n).Select(p=>"PRS"[(i/(int)Math.Pow(3,n-p))%3]))).Where(s=>!Regex.IsMatch(s,@"(.+)\1"))

There has to be a better way to do this :)

F#, 143
let f n=[1..n]|>List.fold(fun l _->List.collect(fun s->["R";"P";"S";]|>List.map((+)s))l)[""]|>Seq.filter(fun x->not(Regex.IsMatch(x,"(.+)\1")))

Nice a F# answer!

It's not the most compact of languages, but hey, any excuse to use it :)

I feel you. This language is so nice.

k, 56 bytes
f:{$[x;(,/"RPS",/:\:f x-1){x@&~~/'(2,y)#/:x}/1_!x;,""]}

The lack of native regex puts k well behind the curve for once. I went with a recursive solution, since the characters to implement it were saved by a simpler squarefree check.
$[ test ; if-true ; if-false ]

is k's ternary operator, here we do interesting stuff for non-zero length, and return a single empty string if asked for zero-length words.
(,/"RPS",/:\:f x-1)

takes the cartesian product of "RPS" and all n-1 length squarefree words. ,/:\: joins each element of the right to the left, giving a length 3 array of length n arrays. ,/ flattens this into a length 3n array.
{x@&~~/'(2,y)#/:x}

takes the first n letters of each string and compares it to the second n, then reduces the array to only where they do not match. Because we know the previous result is square-free, only the substrings starting at the first character need matching - simplifying the check here was worth the characters spent implementing recursion. Finally,
/1_!x

applies the lambda to the initial result set to its left, iterating over each substring length from 1 to (word length)-1. !x generates a list from 0 to x-1, then 1_ removes the first element (since 0-length substrings will always match)
Sacrificing a few characters we can use .z.s to self-reference rather than rely on the function name, and instead of checking substrings up to length n-1 only check floor(n/2) for performance. It finds all length 49 words (of which there are 5207706) in about 120 seconds on a 7700k, above that I run into the 4GB limit of free 32-bit k.
{$[x;(,/"RPS",/:\:.z.s x-1){x@&~~/'(2,y)#/:x}/1+!_x%2;,""]}

Python 2, 99 bytes
import re
f=lambda n:n and[c+s for c in'RPS'for s in f(n-1)if not re.search(r'(.+)(\1)',c+s)]or['']

Try it online!


text:
Five Character ASCII Map
Note: In this post, the terms 'character' and 'color' mean essentially the same thing
This image:

can be represented as
....'''333
.eeee'''3e
..dddd33ee
%%%dd####e

(mapping colors to ascii characters)
The four color theorem states that
"given any separation of a plane into contiguous regions, producing a figure called a map, no more than four colors are required to color the regions of the map so that no two adjacent regions have the same color. Two regions are called adjacent if they share a common boundary that is not a corner, where corners are the points shared by three or more regions." - Wikipedia (link)
This means that it should be possible to color a map using four colors so that no two parts which share an edge share a color.
The algorithm to color a map using only four colors is complicated so in this challenge your program only needs to color the map using five or less colors.
The previous map recolored could look like this:

which could be represented as
....'''333
.eeee'''3e
..dddd33ee
333dd....e

or equivalently
@@@@$$$!!!
@^^^^$$$!^
@@<<<<!!^^
!!!<<@@@@^

Challenge:
Given a "map" made of ascii characters (where each character represents a different color), "recolor" the map (represent the map using different ascii characters) so that it only uses five or less colors.
Example:
Input:
%%%%%%%%%%%%##########$$$$$$$$%%
*****%%%####!!!!!!!%%%%%%%%%#^^^
(((((((***>>>>??????????%%%%%%%%
&&&&&&&&$$$$$$$^^^^^^^))@@@%%%%%
^^^^^^%%%%%%%%%%%%##############

Possible output:
11111111111122222222223333333311
44444111222255555551111111112444
22222224441111444444444411111111
55555555222222255555553355511111
22222211111111111122222222222222

Clarifications:

The input map will always use six or more characters
You may use any five different characters in the output
You can use less than different five characters in the output
You may take the input in any reasonable format (including an array of arrays, or an array of strings)
This is code-golf so the shortest answer wins.

Sandbox link

I see, at least in your example, that the "maps" aren't actually planar graphs, given that non-contiguous regions seem to have to be the same color. This means that you could easily create a graph that needed 6 or more colors to color. Should we treat the map 121 as 3 separate regions to avoid this problem, even though the example implies otherwise, or should we treat it as 2, and assume that no map will be given that needs more than 5 colors?

There isn't an error in the example, it's just that the example could work either way - its not wrong, just ambiguous. It would help to specify whether different regions labeled with the same character are the same or multiple regions in the rules.

Funnily enough, I'm writing an essay on the proof of the four color theorem right now. I have to say, the proof for the five color theorem is a lot less complicated

Python 2, 375 361 359 357 355 353 350 347 bytes
e=enumerate
C=set('12345')
def f(s):
 s=[map(ord,l)for l in s]
 for i,v in e(s):
	for j,w in e(v):
	 if{w}-C:
		F,N=g([],s,i,j,w)
		for y,x in F:s[y][x]=min(C-N)
 return s
def g(m,s,i,j,c):
 n={s[i][j]}
 if(n^{c}or(i,j)in m)<1:
	m+=(i,j),
	for x,y in(0,1),(0,-1),(1,0),(-1,0):
	 if len(s)>i+x>-1<j+y<len(s[0]):m,N=g(m,s,i+x,j+y,c);n|=N
 return m,n

Try it online!
Takes input as a list of strings, and returns a list of lists
f takes the map input and colors it, g returns all connected characters and the set of their neighbors, to the area can be colored with a distinct color.

361 bytes

359 bytes

if~-(n!={c}or(i,j)in m): for -2 bytes

s=map(list,s) for -11 bytes

you can receive the input as a list of list of characters, it would save, that would save 24 bytes from your current solution

@FelipeNardiBatista
I know, but then if there are any of '12345' in the input, it might not work. That's why i map each char to its ordinal