text:
An OEIS polyglot
This is an answer-chaining challenge relating to the OEIS.
Oh, the justification for this is because a company needs one program to print out their OEIS sequences real bad and they have every language.
The answer-chaining format works in the following way:
Someone posts the first answer, from which all further solutions stem. This answer is a program that, given  a number N, inputs the Nth number in OEIS sequence of whatever index they choose (we'll call it sequence 1), in whatever language they choose (language 1)
Someone else comes along and chooses their own sequence (that has to be different from the previous, and from all previous sequences). They make a program, in another language (which has to be different from all previous languages), that given a number N in the language 1 outputs the Nth number of sequence 1 and, given a number in language 2 outputs the Nth number of sequence 2.
This process continues ad infinitum.
The nth term of a sequence is the term that comes n times after the first, working from the first item. Here we use 0 and 1-indexing, to be easy on the coders!
No language or sequence reusing.
Input must be an integer or a string representation of an integer and output must be the correct value of the sequence. Error handling (non-int input) is not needed.
You must not post twice in a row.
You must wait an hour or more before posting again.
Whoever is the SECOND-to-last to post after a week of no answers (the person who didn't break the chain) wins, though the contest can continue indefinitely. If you're last and can show that you can add one more language to it, you continue the challenge until the next winner.
You can assume that the input or the output won't be outside the numerical range of your language (for example, assuming that IEEE's limit won't be surpassed by any sequence) but don't be a trickster and abuse this by using a language that only has 1.
Any sequence can be chosen, as long as it hasn't been used before.
The input cannot be out-of-bounds for the sequence you are using.
Two different language versions are different languages (Python 2 and Python 3 are considered different langs of their own). This isn't rigid, but as a rule of thumb, if it's separated from another version of the same language on TIO, it's different.
This isn't banned, but try once not to use the formula the OEIS gives.
If your resulting code is over 65536 characters long, provide a link to access it (e. g. Pastebin).
That's it and that's all. Ready? Set? FUN!
Yes, this IS "One OEIS after another" but put on multiplayer. I thought it'd be cool.

I greatly enjoyed One OEIS after another but I'm not very good at polyglots, so I'll probably watch this one from the sidelines.

Oh boy this sounds familiar :sweating:

Yeah. Thought it'd be cool and I haven't seen it.

@HyperNeutrino "ah shoot, here we go again"

caird coinheringaahing: Look at my OEIS polyglot.
Everyone after looking at my post: Ah shoot, here we go again.

@Giuseppe yeah that's what i was thinking immediately LOL

Come on, guys, at least try to not use something that is all ones, or threes, or twos.

Sequences of single digits are valid OEIS sequences. They may be boring, but they are sequences. However, I've been doing my best to do math-y sequences, I just had to give up with whitespace because I couldn't figure out where the input value was going. If you didn't want boring sequences, you should have banned boring sequences. ;P

Not even against them, just saying. Besides, how do you ban boring sequences without shutting down your challenge because of an unobjective rule?

Oh sure, hence the ;P

Let us continue this discussion in chat.

Some submissions use 0-indexing and others use 1-indexing (see the comments under submission #10). I suggest you allow both.

@Andrew Uh, SECOND-to-last? If I posted #17 too late ("after a week of no answers"), that makes #15 the accepted answer, not #16.

15. Commentator, A020739
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC//*/0#
/*
박망희		   		0#
;*/

n=>5/2>2?1:40-n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
C#
Brainfuck
Runic Enchantments
Jelly
Gol><>
Javascript (Node.js) (All 1s)
Parenthetic
Whitespace (All 3s)
05AB12 (All 0s)
Unreadable
Grass
Width
AlphaBeta
Aheui (All 2s)
I had a few plans with Commentator, but only one survived contact with all the other languages. One caused errors in the Jelly (iirc) and I wasn't able to resolve it because I don't know why Jelly interpreted the bytes the way it did.

Remaining languages left (up from before, I found some new ones!): about 6-12.

Could you give me some starting pointers/tips for Runic Enchantments.. I was able to add code for the new language, and the only thing left to fix is Runic Enchantments. If I understand correctly RE is a 2D path-walking language which starts at the top-left and changes directions based on things like /\ and its mana. Could you give a brief explanation of what the execution flow is in this latest nr. 15 answer is for Runic Enchantments?

@KevinCruijssen It doesn't start at the top-left, different from ><> and a lot of other 2D languages. It starts at any (and all) of ><^v. The only time it starts at the top left is if the code contains none of those bytes and is only one line long.  So this polyglot has a lot of IPs in Runic, but the only one that does anything (currently) is this one: >2?1:40-n/. The 2? skips the 1: and so the first instructions are push 4, push 0, subtract (4-0 → 4). Then a lot of nothing happens until it gets to /ip@ which results in take input, pow(y,x), print-and-terminate.

And I do mean a lot of IPs. Most end up performing a stack-underflow in some manner and terminating without generating output.

Ah ok, that makes sense, thanks! And I just realized I forgot to build in your latest Commentator as well. Will see if I can fix both to complete my answer.

4. Jelly, A000312
n=>40-n//
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
       //ip@
       //
;/**/

C# (Visual C# Interactive Compiler)
brainfuck
Runic Enchantments
Jelly
Explanation:
We only account for the last line, all of the other lines are ignored.
;/**/ Argument: z
;/    Reduce z by ; (concatenation) [1]
      z is an integer, so this just returns z itself.
   */ Reduce z by * (exponentiation) [2]
      Again, this returns z itself.
  *   Exponentiation: return [1] ** [2]
      This resolves to (z ** z).

To make C# ignore the code, we're trying to put it in a comment. However, a line starting with / isn't valid in Jelly, because / needs an operand. The operand we're using here is ;, since that also fits perfectly as a semicolon in C#. In fact, the semicolon and empty multi-line comment together make a link that calculates \$^2z=z^z\$. Note that the function submission in C# is still valid, as there's no general consensus disallowing multiple statements in an anonymous function submission (e.g. imports).

I'd love am explanation of how the Jelly code does its thing.

@Draco18s Added.

Ah, perfect. Explains that. Thanks much.

16. Java 8, A000290
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC//*/0e#'
/*
박망희             0#
;*/
    //\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip@
                          //
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Never thought I'd see the day where I would be able to add a Java answer as 16th answer in a polyglot-chain! :D
1. Try it in C#: \$a(n)=40-n\$
2. Try it in brainfuck: \$a(n)=1+n\text{ mod }2\$
3. Try it in Runic Enchantments: \$a(n)=4^n\$
4. Try it in Jelly: \$a(n)=n^n\$
5. Try it in Gol><>: \$a(n)=-n\$
6. Try it in JavaScript: \$a(n)=1\$
7. Try it in Parenthetic: \$a(n)=1\text{ if }x^n+y^n=z^n\text{ has a nontrivial solution in integers, otherwise }a(n)=0\$
8. Try it in Whitespace: \$a(n)=3\$
9. Try it in 05AB1E: \$a(n)=0\$
10. Try it in Unreadable: \$a(n)=n\$
11. Try it in Grass: \$a(n) = \lfloor n/10^\left(\lfloor log_{10}(n)\rfloor\right)\rfloor\$
12. Try it in Width: \$a(n)=n+1\text{ with }n\geq2\$
13. Try it in AlphaBeta: \$a(n)=1\Vert n\$
14. Try it in Aheui: \$a(n)=2\$
15. Try it in Commentator. \$a(n)=2n+6\$
16. Try it in Java 8: \$a(n)=n^2\$
Explanation:
Let me start by saying that although I've heard from each of these languages before here on CGCC, I'm only skilled with Java, C#, 05AB1E, and Whitespace, and apart from that can read the JavaScript part of the code. The other languages are mostly unfamiliar for me, so I hoped after the changes I had in mind to make the Java interact with C#/JavaScript, most other languages would still work.
The first main thing to tackle was Java's n-> vs C#/JavaScript's n=>. Java support unicode values as part of the code, so using the following:
//\u000A\u002F\u002A
n=>//\u002A\u002Fn->

Will be interpret as this in C#/JavaScript:
//\u000A\u002F\u002A
n=>//\u002A\u002Fn->

But as this in Java:
//
/*
n=>//*/n->

This is because \u000A is a line-break, \u002F is / and \u002A is * in Java.
Then to differentiate the sequence between Java vs C#/JavaScript I added the following:
""+n==""+n?...:n*n

where ... is the existing 5/2>2?1:40-n, and n*n is the Java part of the code for oeis sequence A000290 (squares a.k.a. \$a(n)=n^2\$).
Why does this work? In Java Strings are Objects, where == is used to check if references of objects are pointing to the same place (or to check if primitives are equal), and the actual Object.equals(Object) has to be used to check if the values of these Objects are the same. So ""+n==""+n will be falsey in Java, but truthy in C#/JavaScript.

After that was tackled (by re-using the existing newlines to not break the Whitespace program), some things had to be fixed. Four of the existing programs were failing now: Runic Enchantments, Jelly, Unreadable, and Commentator.
The fix for Unreadable was easy. We added four """" before the first ', so we simply put the ' somewhere earlier (I placed it at the end of the first line), and remove the leading '"""" from the Unreadable part of the code at the bottom.
After that came Jelly, which was giving an IndexError: pop from empty list. I'm not too skilled in Jelly, so I don't exactly know why it gave this error. If I remember correctly the last line will be the main-link of a Jelly program, and because the code in that last line doesn't use any of the other links, everything else should be ignored. But somehow the part ""+n==""+n still gave some issues. I was able to fix this by adding /**/ in front of that line.
As for Runic Enchantments, it didn't output anything anymore. @Draco18s pointed out to me that Runic Enchantments starts at all > simultaneously, but only the >2?1:40-n/ and /ip@ were relevant. This was a huge help to understand the flow of the Runic Enchantments program, and I was able to fix the path by adding a /**/ at >2?1:40-/**/n:n*n, and changing the positions of the //ip@, //, and space on the last line.
All that's left was Commentator. At that point I realized that my previous fixes of adding /**/ weren't such a good idea after all, since it would output a bunch of additional rubbish due to the builtins /* (convert active to unicode character and output) and */ (output active as number).. >.> After a bit of fiddling around and trying some things, the fix turned out to be very easy: I've added an e before the # on the first line. e# is the builtin to negate an active, fixing the issues caused by the code I added (apparently).

Wow, good job on that. I didn't anticipate seeing Java get added at this point either.

@Draco18s I'm glad this polyglot challenge didn't start with Python, since then it would have already been impossible to add Java. JavaScript/C# are rather similar as Java in terms of comments and execution, so that helped a lot here. Glad I have it working. Good luck on the next chains. I'm probably not able to make any more chains, but I hope to see it grow at least a few more times. :)

The ones I have prepped are ones that either use a character set that non-interferes and ignores characters not in its instruction set, or 2D languages that use different rules.

6. JavaScript (Node.js), A000012
//
n=>5/2>2?1:40-n//
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
               //ip@
               //
;/**/
//I01-* h
//
 ;/**/

C# (A022996): Since 5/2==2 the function returns 40-n (Line 2)
BF (A000034): The added part only pushes the whole tape one cell to the right, others unchanged (Line 2-3)
Runic (A000302): The ? after 2 skips the 1:, and other operations follows from 4 (Line 2)
Jelly (A000312): Unchanged last line
Gol><> (A001489): Unchanged first column
JS(ES6) (A000012): Since 5/2>2 the function returns 1 (Line 2)
Sneaked the ternary 5/2>2?1:40-n into the C# part. In C# since 5/2==2 the function returns 40-n, while in JS 5/2>2 the functions returns 1. The C-style comments made it nearly impossible to add more practical languages (specifically C and Python). More spaces are added on lines 4-5 to ensure that the Runic part works.

The C-style comments made it nearly impossible to add more practical languages (specifically C and Python). Such is the way of polyglot challenges.

8. Whitespace, A010701
//

n=>5/2>2?1:40-n//(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
               //ip@
               //
;/**/
//I01-* h
//
 ;/**/

Try it online!
C#
Brainfuck
Runic
Jelly
Gol><>
Javascript
Paranthetic
I have no idea how Whitespace works. I tried super hard to multiply the input with another value, but it kept complaining about infix arithmetic, so as I had input working, output working, and push-value-to-stack working, so I just went with that.
The input value appears to get lost when pushing 3 to the stack, but oh well. Enjoy a sequence of 3s. The program does technically take input it just ends up discarding it.
I also don't know how Paranthetic works, so I can't actually verify that submission as valid, but as far as I can tell the Whitespace code doesn't interfere.
Future answers: be aware that tabs in Runic are a single instruction wide and play havoc with code layout.

I don't know Whitespace either, but reading from the documentation, it seems input values are actually stored at the heap location pointed to by the top of the stack, not on the stack itself.

@ArBo Possible. I just know that if I did "read, print" I would get my input back. But if I did "read, push 10, print, print" I would get 10 and an error. So I went "heck with it" and just did what I knew I could.

FYI: input in Whitespace is indeed pushed to the heap, which acts as a dictionary/map. So let's say you do: push 10, read STDIN. The stack will be empty, and the heap will contain [{10: input}]. To make a cat program that reads and outputs immediately in Whitespace, you usually want to do something like: Push 0; duplicate 0; read STDIN; retrieve (this will pop the 0 we duplicated, and push the value from heap-address 0 to stack); pop and output to STDOUT. PS: Here a useful online debugger I always use.

@KevinCruijssen Useful!

11. Grass, A000030
//0q

n=>5/2>2?1:40-n//(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
Grass ignores all characters except w, v and W; conveniently, these three characters are ignored by several of the previously used languages. Luckily, sequence A000030 (return the initial digit in base 10) was still available, as coding even slightly complicated functions in Grass is beyond my ability.
C#
brainfuck
Runic
Jelly
Gol><>
JavaScript
Parenthetic
Whitespace
05AB1E
Unreadable
The relevant part for Grass is wvWwwWWwwwwwwWwWWWw. Here is my (probably flawed) understanding of how it works: the stack is initialized as OUT::SUCC::w::IN::ε (that w is just the character w). Each instruction adds an element to the stack (they are never popped); the number of ws or Ws indicates how deep to go in the stack; v separates instructions.
wv        # identity
Www       # identity OUT
WWwwwwww  # identity IN (read in 1 character)
Ww        # apply the function identity IN
WWWw      # apply the function identity OUT to the value at the top of the stack

If the input is 1234, at the end, the stack probably looks like this: 1::1::id IN::id OUT::id::OUT::SUCC::w::IN::ε.
It could be made shorter (don't need to define id OUT for example), but I stopped as soon as I found a version which worked.
If someone who knows Grass wants to correct/improve the explanation, please edit my answer!

This is one of the languages I identified as workable, but wasn't able to understand the documentation and write the code for. +1

@Draco18s I've tried to add an explanation of how it works.

Certainly helps, but still head-scratching. I've had to rework one of my future answers as you yoinked A000030 (languages that take input as single bytes are a pain; 3 byte program turned into nearly 60 (yes, I really have planned that far ahead)).

17. Pepe, A000578
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC//*/0e#'
/*
박망희		   		0#
;*/
 	//\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip@
                          //rEeE rEeeEe reEE
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Online Interpreter
C#
Brainfuck
Runic Enchantments
Jelly
Gol><>
Javascript (Node.js) (All 1s)
Parenthetic
Whitespace (All 3s)
05AB12 (All 0s)
Unreadable
Grass
Width
AlphaBeta
Aheui (All 2s)
Commentator
Java
You'll have to excuse the Pepe link for not containing the full source: The interpreter disregards any code that is not Pepe (lit. any character not in the set RE re) and so its short link doesn't bother encoding it. Ditto input values.
Computes \$a(n) = n^3\$
The AlphaBeta has started throwing errors after writing output, but as a prior answer injected that issue I left it alone. I had planned on fixing it for this answer, but I need to spend some time digging into the jump offsets to resolve the issue. The error with inputs >0 are easy to fix, but giving it 0 will produce the same error and it will take time to relearn the code in order to fix the offset for it. I wish I could use W instead of UUUUUUUUUU, but it plays havoc with the Grass code.

Another 4-11 languages to go. One of the ones I'd templated out decided to make the Brainfuck throw a hissy fit, so I didn't use that one for this answer (I was going to!). Given how early the BF was done, I'm questioning if it ever worked and I just didn't check the BF.

[Full disclosure regarding accept mark] I forgot that Thursday the 4th was a holiday and didn't have access to my notes in time to post this answer before a week had gone by. I had slowed down my answering rate in an attempt to allow others to find and post answers; I had not intended to outlast the grace period (had I wished to do so, I could have by not posting #15 at all, letting #13 get accepted) as I was interested in seeing how far this would go and I intend to post the other 4 or 5 languages I've solved for before listing the remaining langs I think could still work, if I can't do them.

7. Parenthetic, A019590
//
n=>5/2>2?1:40-n//(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
               //ip@
               //
;/**/
//I01-* h
//
 ;/**/

C# (A022996)
BF (A000034)
Runic (A000302)
Jelly (A000312)
Gol><> (A001489)
JS(ES6) (A000012)
Parenthetic (A019590)
Parenthetic ignores everything but the ( and ) characters. I've had to insert 1s before every closing parenthesis to stop Jelly from freaking out though (EDIT: I left one ) unpreceded by a 1, so apparently not all of them need one, but it's too late to golf it down now). The actual code defines a lambda called ((())), that can be called on a number to yield the result (1-indexed).

I would like to understand how to pass input to Paranthetic, because I can see that the sequence is not constant, but don't know how to actually get the program to change its output. Nope. Nope. Nope.

@Draco18s It doesn't take input in the sense you're trying to do. The code itself defines a function, called ((())). The footer calls that function, with whatever argument you want. The set of parentheses under the number 2 means 2 in Parenthetic. Changing the final ()() to ()*n will call the function on n.

Ahh...That makes sense now. It was just something I'd been poking at because I had no good way to verify the submission and insuring is validity moving forward (I was in a "it still outputs the same thing, so it must be fine, I guess?" mode). That helped.

9. 05AB1E, A000004
//0q

n=>5/2>2?1:40-n//(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
               //ip@
               //
;/**/
//I01-* h
//
 ;/**/

C# (Visual C# Interactive Compiler)
brainfuck
Runic Enchantments
Jelly
Gol><>
JavaScript (Node.js)
Parenthetic
Whitespace
05AB1E

10. Unreadable, A001477
//0q

n=>5/2>2?1:40-n//(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
C#
Brainfuck
Runic
Jelly
Gol><>
Javascript
Paranthetic
Whitespace
05AB1E
Unreadable, as its name suggests, is unreadable. In order to program it I had to use a template and then convert from readable text to Unreadable code.
[A=READ()];DO{(A+1)?:BOTH(PRINT(A),[A=READ()])}
[A=READ()]: '""""""'"""'""""""""""
PRINT(A): '"'"""""""'"""
A?: '""'"""
Functioning:
['""""""'"""'""""""""""];'"""""{('""'"""""""'""")?:'""""('"('"""""""'"""),['""""""'"""'""""""""""])}

All it does is read each character in the input and output it. One of the more boring sequences, but good for a language that's difficult to work with. I also toyed with using the sequence A000030 before getting the loop to work.
Working via remote desktop is a pain, you think things work, do all the links, then realize that one of them broke and didn't notice.

I forgot to remove it, but the ;/**/ in the middle area is not doing anything and could be removed. 99% sure. It was a Jelly chunk, but it got duplicated somewhere along the way and no longer serves a purpose.

@RobinRyder Ditto, also fixed link to Runic (bad copy-paste somewhere along the way). See #3 for an explanation of why it works in Runic.

For reference: I know for a fact that it is possible to add at least 5 more to the chain from here, but probably closer to 15.

1. C# (Visual C# Interactive Compiler)  A022996
n=>40-n

Also works in C# (.NET Core), C# (Mono C# compiler), C# (Mono C# Shell), and C# (Visual C# Compiler)
Try it online!

Also works in Javascript.

14. Aheui, A007395
Slightly changed to make AlphaBeta works.
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC
/*
박망희*/

n=>5/2>2?1:40-n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
Aheui dismiss any non-Korean character, so 박망희 excuted, which prints 2 and terminates.
C#
Brainfuck
Runic Enchantments
Jelly
Gol><>
Javascript (Node.js)
Parenthetic
Whitespace
05AB12
Unreadable
Grass
Width
AlphaBeta
Aheui

So we have all 1, all 2 and all 3 now lol

@ShieruAsakoto oh, was there all 3? I didn't knew that.

#8 is the all-3. Mine (#6) is the all-1.

*Crosses that one off the list.* Knew it would work, but didn't know how to program in it and the documentation wasn't easy to understand at a brief glance. Now to make sure the other answers I've written still have a place to squeeze into.

You also need to tweak the AlphaBeta section: you changed the length of the first line, so the sequence breaks after 999 due to the loop jump offset not being in the right spot. Or move the /*

@Draco18s oops. I didn't knew that. I'll fix my code.

@Draco18s moved /* and it works now. And Aheui code is (slightly more) good to see.

Yeah, those jumps have messed me up on occasion too.

2. brainfuck, A000034
n=>40-n
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.

Try it online!
C#

3. Runic Enchantments, A000302
n=>40-n//
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
       //ip@
       //

Try it online!
C#
BF
If you need help keeping the Runic functional, there is the Esoteric IDE as well as my own IDE (built in Unity3D) in the master branch of Runic's git repo. Esoteric IDE doesn't handle displaying the IP directionality very well (primarily my own inability to add such to the existing framework).
All the BF creates a bunch of IPs that self terminate due to performing invalid actions (mainly due to stack underflow) while the > in the C# populates the stack with a 4, bounces of the comment makers (mirrors in Runic), reaching ip@ to execute x^4 on an input x and print the result.

5. Gol><>, A001489
//
n=>40-n//
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.
       //ip@
       //
;/**/
//I01-* h
//
 ;/**/

Try it online!
C#
Brainfuck
Runic
Jelly
Use single-line comment markers in C# to redirect the Fish IP to the operative code, I01-*h, reading input, multiplying by -1, and outputting the result. Gol><> made reading input and dumping the stack as a number easy compared to raw ><>.
Spaces inserted to insure the proper flow of the Fish and Runic IPs, where both C# and Jelly ignore the leading whitespace on the last line (and is a NOP cell in both fungoids).

12. Width, A020725
//0q

n=>5/2>2?1:40-n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

1-indexed. Outputs by exit code.
Try it online!
The only relevant characters to Width are a-zA-Z. The code Width runs is the following:
qnnAcaAcAAI

The first three characters, qnn, are no-ops. Ac reads an integer from input, a is a no-op, and then AcAA increments the integer by one. I ends the program, and the top of the stack is becomes the exit code. All other letters in the program are ignored since the program terminated.
C#
brainfuck
Runic Enchantments
Jelly
Gol><>
JavaScript
Parenthetic
Whitespace
05AB1E
Unreadable
Grass

I vaguely maybe remember running across this one in my search of eslolangs to consider for this challenge. I think I dropped it due to a conflict with another language I was considering, but I think I'm still good. Cursory check suggests I can make the two play nice.

13. AlphaBeta, A162672
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC

n=>5/2>2?1:40-n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
               //ip@
               //
;/**/
//I01-* h
//
 ;/*'""""""'""" '""""""""""'"""""'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
I had originally planned to use sequence A000030 and the code JCL, but that got yoinked (I don't blame them, its a good sequence for languages that take input as single bytes). The original code for this entry after having to pick a new sequence was:
JiiiiihhZUUUUUNYAxcccccbCLDLxyzUUUUTTxxyzJCLOzWRxyxyzcccccbbCL
^                                                                 Read input (single byte)
                 ^          ^^^      ^^^^    ^  ^^^^^             Clear regisers
        ^                                            ^^^^^^^^^    Input = 0: print 0
 ^^^^^^^ ^^^^^                 ^^^^^^         ^                   Set jump locations
                  ^^^^^^^^                                        Print `1`
                          ^^                                      Print initial byte
                                         ^^^                      Read and print input
                                            ^                     (and loop)

Sequences of xxx or xyzxyz are useful spacers to make the jump-to targets easy values (46 is easier as "5*10-4"--9 instructions--than "4*10+6--ten instructions--but 50 is even simpler: only five). You'll see a fair few of those.
But as there are other bytes on the first line, the jump-to codels needed some new values and that turned into:
//0q   xxxJiiiiihhZUUUUUUNYAxcccccbCLDLxyzUUUUUTxxyzJCLOzWRxyxyzcccccbbCL

Avoiding executing this code as Width code just involved wrapping it in G to make it a string literal (which does nothing important in AlphaBeta), a command to pop the top of the stack, and then some extra W to make alpha beta not crash when exiting:
//0q   GxxJiiiiihhZUUUUUUNYAxcccccbCLDLxyzUUUUUTxxyzJCLOzWWWWWWRxyxyzcccccbbCLGw

To avoid conflicts with Grass, though, instead of popping the command with w C is used instead. Then the "exit program" jump is replaced with UUUUUU instead of WWWWWW This does leave the IP somewhere in the middle of the rest of the junk code, but far enough out that it doesn't print any errors. Any number of additional Us can be added in pairs if this becomes a problem.
//0q   GxxJiiiiihhZUUUUUUNYAxcccccbCLDLxyzUUUUUTxxyzJCLOzUUUUUURxyxyzcccccbbCLGC

The additional i that Runic ends up executing is a NOP on valid inputs as no-input-left-to-read pushes nothing to the stack ("reading all input" is a pain in Runic).
C#
brainfuck
Runic Enchantments
Jelly
Gol><>
JavaScript
Parenthetic
Whitespace
05AB1E
Unreadable
Grass
Width

Anywhere between 4 and 11 more languages to go. But here's some languages that could use some investigation: Ook!, Jolf, Blank, and Brackets. I don't know if they can be used or not, and my intuition says probably not, but haven't given them a bash (mainly because they're not on TIO).

19. Actually, A005843 (2*n)
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC//*/0e#,2*1z⌂'[=====[===]]=[[==========]]=[
/*]
박망희		   		0#
;*/
 	//\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip@
                          //rEeE rEeeEe reEE
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
Operational part: ,2*1z⌂ (first line)
As ⌂ terminates the program, none of the code after it has any effect, and none of the symbols before it result in any output or pollute operational memory adversely. Section exists within a comment (C#, JS, Java), only contains ignored characters (Commentator, ]=[, Pepe, Aheui...), is not on the last line (Jelly), or otherwise in un-executed parts of the code (Gol><>, Runic, AlphaBeta).
C#
Brainfuck
Runic
Jelly
Gol><>
JavaScript (Node.js)
Paranthetic
Whitespace
05AB1E
Unreadable
Grass
Width
AlphaBeta
Aheui (esotope)
Commentator
Java (OpenJDK 8)
Pepe
]=[ (link not possible, see #18 for instructions)

Still have 2 already worked out and a third that will be easy. Also, the sequence ]=[ can't be turned into a url.

18. ]=[, A010716, the all 5's sequence
//0q   GxxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLGC//*/0e#'[=====[===]]=[[==========]]=[
/*]
박망희             0#
;*/
    //\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip@
                          //rEeE rEeeEe reEE
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

This language isn't on TIO and its only interpreter is written itself in another interpreted language, which is also not on TIO. And the one that didn't play nice with Brainfuck last week at the last minute, but I figured out what was wrong a few hours after posting the Pepe answer, so I saved it for this week. Being a language not on TIO I was considering this one an ace-in-the-hole that could easily be tacked onto just about ANY entry and continue the chain.

Interpreter code: https://pastebin.com/raw/yqtpynnh
Interpreter interpreter: https://12me21.github.io/12-basic/

Put the interpretter code into the "code" box at the top, code from the answer in the input, and click run and get an output (plus some extra junk that is always printed).
The operational portion of the ]=[ is this at the end of the first line:
[=====[===]]=[[==========]]=[

Its that trailing [ that played havoc with the Brainfuck (the rest being ignored, due to how [ and ] are handled by Brainfuck) and once I looked at the Brainfuck spec again I realized the problem and that all I had to do was insert a ] somewhere after the first line (as the ]=[ interpreter does not read newlines) and before the Brainfuck. I chose the 2nd line.
C#
Brainfuck
Runic
Jelly
Gol><>
JavaScript (Node.js)
Paranthetic
Whitespace
05AB1E
Unreadable
Grass
Width
AlphaBeta
Aheui (esotope)
Commentator
Java (OpenJDK 8)
Pepe

I still have 3 more languages worked out in detail and another 10 that should work, but which I haven't attempted.

21. Flobnar, A010709 (All 4s)
//0q   ÷GxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLxGC//*/0e#§≈2*1z⌂'>[=====[===]]=[[==========]]=[
/*]
박망희		   		0#
;*/
 	//\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip!4@
                          //rEeE rEeeEe reEE
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
Flobnar starts at @ and expands outwards evaluating items as the rules dictate (@ evaluates to whatever's on its left, 4 evaluates to 4, + evaluates to whatever's on the left summed with whatever's on the right, etc). As the placement of the @ only comes into contact with Runic, a simple ! prevents alteration of Runic's stack.
Given that Flobnar's input metric is "one byte" and goes into an infinite loop if there are no bytes to read, I decided not to bother with anything more complex.
Previous languages
C#
Brainfuck
Runic
Jelly
Gol><>
JavaScript (Node.js)
Paranthetic
Whitespace
05AB1E
Unreadable
Grass
Width
AlphaBeta
Aheui (esotope)
Commentator
Java (OpenJDK 8)
Pepe
]=[ (link not possible, see #18)
Actually
Neim

Input evaluates the term to the south on EOF, it doesn't go into an infinite loop

Ah, thanks. Even so, at one-byte-per-evaluation, it's a difficult thing to actually utilize. 4@ worked easily enough that I just went with that.

20. Neim, A008592 (10*n)
//0q   ÷GxJiiiiihhZUUUUUUUNYAxcccccbCLDLxyzUUUUUTxyzJCLOzUUUUUURzyzxyzxyzcccccbbCLxGC//*/0e#§≈2*1z⌂'>[=====[===]]=[[==========]]=[
/*]
박망희		   		0#
;*/
 	//\u000A\u002F\u002A
n=>//\u002A\u002Fn->
/**/""+n==""+n?5/2>2?1:40-/**/n:n*n//AcaAcAAI(((1)(1)(1)1)((1)(((1)1)1)1)(((1)(1)1)(((1)((1)1)(1)1)1)(((1)(1)(1)(1)1)(((1)(1)((1))(1)1)((1)((1)1)(1)1)(((1)1)(1)(1)1)1)(((1)1)(1)1)(((1)1)1)1)1)1)
//[>[-]<[>+<-],]>>+<[->[>>+<<-]>[<+>-]>[<+>-]<<<]>>>>++++++[<++++++++>-]<<[>+<-]>+.wvWwwWWwwwwwwWwWWWw
                          //ip@
                          //rEeE rEeeEe reEE
;/**/
//I01-* h
//
 ;/*""'"""'""""""""""'"""" "'""'"""""""'"""'""""'"'"""""""'"""'""""""'"""'""""""""""*/

Try it online!
I have no idea how the heck Neim works. I know what the code here ends up doing, but I have no idea how the language itself works.
Also turns out I messed up the Brainfuck with #19. Due to command conflicts between multiple languages, changing Actually's input to § and then coercing it to an int with ≈ was the optimal solution.
C#
Brainfuck
Runic
Jelly
Gol><>
JavaScript (Node.js)
Paranthetic
Whitespace
05AB1E
Unreadable
Grass
Width
AlphaBeta
Aheui (esotope)
Commentator
Java (OpenJDK 8)
Pepe
]=[ (link not possible, see #18)
Actually

Can you believe I've still got 2 more I can do?

let's see how long it takes until wipeout

Oh, I forgot to post another yesterday. Life's been real busy, trying to figure out who it is that keeps waking me up at 6:30 and/or 7:30 with a loud engine so I can report them to housing management and/or the city for noise disturbance. Also the new gold battle KOTH. Just creating the 20+ links for all the languages takes up about an hour now (even if there's no issues).


text:
Nth term of Van Eck Sequence
Output the Nth term of the Van Eck Sequence.
Van Eck Sequence is defined as:

Starts with 0.
If the last term is the first occurrence of that term the next term is 0.
If the last term has occurred previously the next term is how many steps back was the most recent occurrence.

https://oeis.org/A181391
https://www.youtube.com/watch?v=etMJxB-igrc
https://www.youtube.com/watch?v=8VrnqRU7BVU
Sequence:
0,0,1,0,2,0,2,2,1,6,0,5,0,2,...
Tests:
Input | Output

1  | 0
8  | 2
19 | 5
27 | 9
52 | 42
64 | 0

EDIT
1 indexed is preferred, 0 indexed is acceptable; that might change some of the already submitted solutions.
Just the Nth term please.
Same (except for the seeing it already posted part), it seems code golfers and numberphile watchers have a decent overlap.

Watched the numpherphile video at work and was going to post this when I got home. Curse you for getting there first. :P

Does it have to be 1-indexed, or may we use 0-indexing?

May we return or output the infinite sequence instead?

... or the first n terms?

@Draco18s The same thing happened to me. :P

JavaScript (ES6),  46 41  37 bytes
n=>(g=p=>--n?g(g[p]-n|0,g[p]=n):p)(0)

Try it online!
How?
We don't need to store the full sequence. We only need to keep track of the last position of each integer that appears in the sequence. We use the underlying object of the recursive function \$g\$ for that purpose.
For a given term \$p\$, we don't need either to set \$g[p]\$ to its actual absolute position in the sequence because we're only interested in the distance with the current position. That's why we can just store the current value of the input \$n\$, which is used as a decrementing counter in the code.
Therefore, the distance is given by \$g[p]-n\$. Conveniently, this evaluates to NaN if this is the first occurrence of \$p\$, which can be easily turned into the expected \$0\$.
Commented
n => (           // n = input
  g = p =>       // g = recursive function taking p = previous term of the
                 //     sequence; g is also used as an object to store the
                 //     last position of each integer found in the sequence
    --n ?        // decrement n; if it's not equal to 0:
      g(         //   do a recursive call:
        g[p] - n //     subtract n from the last position of p
                 //     if g[p] is undefined, the above expression evaluates
        | 0,     //     to NaN, in which case we coerce it to 0 instead
        g[p] = n //     update g[p] to n
      )          //   end of recursive call
    :            // else:
      p          //   we've reached the requested term:
                 //   stop the recursion and return it
)(0)             // initial call to g with p = 0

Python 3, 69 63 62 bytes
f=lambda n,l=0,*s:f(n-1,l in s and~s.index(l),l,*s)if n else-l

Try it online!
 Note: as Erik the Outgolfer mentioned, this code works fine in Python 2 as well.
0-indexed (although, just to be utterly perverse, you can make it -1-indexed by changing if n to if~n :P)
Makes use of Python's gorgeous unpacking "star operator", to recursively build up the series, until n reaches zero.
The function builds up the series in the reverse order, to avoid having to reverse it for the search. Additionally, it actually stores the negations of all the elements, because converting them back at the end was free (else the - would have had to be a space) and it saves us a byte along the way, by using ~s.index(l) instead of -~s.index(l).
Could be 51 bytes if Python tuples had the same find functions strings do (returning -1 if not found, instead of raising an error), but no such luck...

Actually, the "star operator" you're using isn't Python 3's unpacking operator, but rather the vararg operator which also exists in Python 2.

The first one is, but isn't the second one unpacking s for the recursive call?

I've tested it in Python 2 and it works.

@EriktheOutgolfer hmm, but isn't the second use unpacking though? The function doesn't have to support varargs to use such syntax.

@ArBo: It's no different than def func(f, *args): f(*args); unpacking inside function calls is valid py2. What's py3-only is unpacking inside list/dict comprehensions (i.e. [1, 2, *s]) or unpacking variables: a, *b = [1,2,3,4].

@EhsanKia Yes, I now know it's also Python 2. But it is an unpacking operator and not a varargs operator, since something like def f(a, b):pass and then t=(1,2); f(*t) works as well, without f having varargs.

Perl 6, 47 42 bytes
-5 bytes thanks to nwellnhof
{({+grep(@_[*-1],:k,[R,] @_)[1]}...*)[$_]}

Try it online!
Anonymous codeblock that outputs the 0-indexed element in the sequence.
Explanation:
{                                            } # Anonymous codeblock
 (                                      )[$_]  # Return the nth element
                                    ...*       # Of the infinite sequence
  {                            }  # Where each element is
    grep(        :k        )[1]   # The key of the second occurrence
         @_[*-1],                 # Of the most recent element
                   ,[R,] @_       # In the reversed sequence so far
   +     # And numify the Nil to 0 if the element is not found

R, 62 bytes
function(n){while(sum(F|1)<n)F=c(match(F[1],F[-1],0),F)
+F[1]}

Try it online!
Builds the list in reverse; match returns the first index of F[1] (the previous value) in F[-1] (the remainder of the list), returning 0 if no match is found.
F is initialized to FALSE and is coerced to 0 on the first pass of the while loop.

I'm kind of in awe of how good match is for this problem when you construct it this way. Really clean.

Does the plus on the second line do anything here? I assumed it fixed an edge case, but I can't find one for it.

@CriminallyVulgar it should coerce F to 0 when n==1 else it would return FALSE.

Ahh, I see. Makes sense, I was trying lots of ranges but not the single value.

Bourne shell, 102 bytes
until [ 0"$i" -eq $1 ];do i=$((${i:-0}+1)) a=${n:-0};eval 'n=$(($i-${m'$a:-$i'}))' m$a=$i;done;echo $a

try it online

Welcome to PPCG!

Python, 51 bytes
f=lambda n,i=1:n>i and[f(n,i+1),i][f(n-1)==f(n+~i)]

Try it online!
Outputs False for 0. Implements the spec pretty literally, looking for the lowest positive integer i such that f(n-1)==f(n-i-1). If such a search leads to i>=n, the previous element hasn't appeared before and we produce 0.
Instead of doing something reasonable like storing earlier values in a list, the function just recomputes them recursively from scratch whenever they're needed, and sometimes when they're not needed. This makes the function run very slowly for inputs above 10 or so.

J, 29 23 bytes
1{(,~#|1+}.i.{.)@]^:[&0

Try it online!
The real work is done in the iteration verb of the power verb ^:, which iterates as many times as the argument [, starting the iteration with the constant value 0 &0...

(#|1+}.i.{.) This is what iterates.  Breaking it down...
}.i.{. Find the index of i. of the head of the list {. within the tail of the list }..  This will return a 0-based index, so if the current item is found 1 previous it will return 0.  If it is not found, it will return the length of the list, ie, the length of the tail.
1+ Add one to the value to correct for the 0-based indexing, since the Ven Eck's "how far back" is 1-based.  Note that if it was not found, the value will now be the length of the full list.
#| Return the remainder of the value calculated in the previous step, when divided by the length of the full list.  Note that this turns "not found" into 0, but leaves all other values unchanged.
,~ Append the new value to the front of the list.  We use the front rather than last merely for convenience.
1{ return the 2nd item in the list, since we calculated one too many times because it's shorter that way.

Stax, 10 9 bytes
é"▬π²"ô↕j

Run and debug it
If 0-based indexing is allowed:
Stax, 8 bytes
à┐æ8Å/[┤

Run and debug it

Wolfram Language (Mathematica), 48 bytes
#<1||Last[#-1-Array[#0,#-2]~Position~#0[#-1],0]&

Try it online!
Nonzero values are returned as singleton lists.

APL (Dyalog Unicode), 19 17 bytesSBCS
Many thanks to ngn, Adám, Richard Park and H.PWiz for their help in writing and golfing this answer in The APL Orchard, a great place to learn APL and get APL help.
Edit: -2 bytes from Adám.
⊃(⊢,⍨≢|1∘↓⍳⊃)⍣⎕-1

Try it online!
Explanation
⊃(⊢,⍨≢|1∘↓⍳⊃)⍣⎕-1

                 -1  We initialize our array of results with -1.
 (           )⍣⎕    ⍣ repeats the train (in parentheses) our input, ⎕, times.
        1∘↓⍳⊃        We take the index of the head (our last element in the sequence).
                     To signify "element not found", this returns the length of the array.
      ≢|             We take our index modulo the length of the array.
                     This turns our "element not found" from the length of the array to 0.
  ⊢,⍨                And we prepend to our array.
⊃                    Finally, we return the first element of the array,
                     which is the most recently-generated.
                     This is the ⍵-th element of the Van Eck sequence.

05AB1E, 8 bytes
F¯Rćk>Dˆ

Try it online or output the first \$n\$ values in the list.
Explanation:
F         # Loop the (implicit) input amount of times:
 ¯        #  Push the global array
  R       #  Reverse it
   ć      #  Extract the head; push the remainder and the head to the stack
    k     #  Get the 0-based index of the head in the remainder (-1 if not found)
     >    #  Increase it by 1 to make it 1-indexed (or 0 if not found)
      Dˆ  #  Add a copy to the global array
          # (after the loop, output the top of the stack implicitly as result,
          #  which is why we need the `D`/duplicate)

That's a weird way to censor profanity!

@negativeseven Lol, took me a few minutes to know what you meant, but I guess you're referring to the F¯Rćk? ;)

Java, 96 80 76 bytes
n->{int i,v=0,m[]=new int[n];for(;--n>0;m[v]=n,v=i<1?0:i-n)i=m[v];return v;}

Not obfuscated:
Function<Integer, Integer> vanEck =
n -> {

    int i;                  // i is the value of n when v was previously encountered
    int v = 0;              // v is the current element of vanEck sequence
    int[] m = new int[n];   // m[v] is the value of n when v was previously encountered

    while (--n > 0) {       // n is used as a decrementing counter

        i = m[v];
        m[v] = n;
        v = i == 0 ? 0 : i - n;
    }

    return v;
};

You should be able to remove a few bytes by changing the while loop to a for loop.

Hello, you could golf more by inlining the declaration of int[] in the int declaration, and also use <1 instead of ==0. Example: int f(int n){int l[]=new int[n],i=0,j,v=0;while(++i<n){j=l[v];l[v]=i;v=j<1?0:i-j;}return v;}

And now a lambda, as well as the golf mentioned by @MegaTom for a total of 80 bytes: n->{int l[]=new int[n],i=0,j,v=0;for(;++i<n;l[v]=i,v=j<1?0:i-j)j=l[v];return v;}

Finally, you can check for tips for golfing in Java.

Jelly, 7 bytes
Ḷß€ṚiḢ$

Try it online!
0-indexed.

Charcoal, 23 bytes
≔⁰θＦ⊖Ｎ«≔⊕⌕⮌υθη⊞υθ≔ηθ»Ｉθ

Try it online! Link is to verbose version of code. Explanation:
≔⁰θ

Set the first term to 0.
Ｆ⊖Ｎ«

Loop n-1 times. (If 0-indexing is acceptable, the ⊖ can be removed for a 1-byte saving.)
≔⊕⌕⮌υθη

The next term is the incremented index of the current term in the reversed list of previous terms.
⊞υθ

Add the current term to the list of previous terms.
≔ηθ

Set the current term to the next term.
»Ｉθ

Print the current term at the end of the loop.

Perl 5 (-p), 42 bytes
map{($\,$\{$\})=0|$\{$\};$_++for%\}1..$_}{

Try it online!

Husk, 8 7 bytes
!¡oΓ€↔ø

Try it online! The behavior of € is surprisingly helpful here.

Haskell, 42 bytes
f n=last$0:[n-j-1|j<-[0..n-2],f j==f(n-1)]

Try it online!
Other Haskell answers: 66 bytes by flawr and 61 bytes by nimi.

Jelly, 8 bytes
ẎiḢ$;µ¡Ḣ

A monadic Link accepting a positive integer, \$n\$, which yields the \$n^{th}\$ term of the Van Eck Sequence.
Try it online!
How?
ẎiḢ$;µ¡Ḣ - Link: n
     µ¡  - repeat this monadic link n times - i.e. f(f(...f(n)...)):
         - (call the current argument L)
Ẏ        -   tighten (ensures we have a copy of L, so that Ḣ doesn't alter it)
   $     -   last two links as a monad:
  Ḣ      -     head (pop off & yield leftmost of the copy)
 i       -     first index (of that in the rest) or 0 if not found
    ;    -   concatenate with L
       Ḣ - head

Note that without the final Ḣ we've actually collected [a(n), a(n-1), ..., a(2), a(1), n]

C (gcc), 63 bytes
f(n){n=g(n,--n);}g(n,i){n=n>0?f(--n)-f(i)?g(n,i)+!!g(n,i):1:0;}

Try it online!
0-indexed.

Haskell, 68 67  66 bytes
Quite straightforward implementation (using 0 based indexing).
f n|all((/=f(n-1)).f)[0..n-2]=0|m<-n-1=[k|k<-[1..],f(m-k)==f m]!!0

Try it online!

Haskell, 61 bytes
(([]#0)1!!)
(l#n)i=n:(((n,i):l)#maybe 0(i-)(lookup n l))(i+1)

0-based indexing.
Try it online!

Japt -h, 11 bytes
@ÒZÔÅbX}hTo

Try it

CJam (15 bytes)
0a{_(#)\+}qi*0=

Online demo. This is a full program and 0-indexed.
Dissection
0a      e# Push the array [0]
{       e# Loop...
  _(#   e#   Copy the array, pop the first element, and find its index in the array
  )\+   e#   Increment and prepend
}qi*    e# ... n times, where n is read from stdin
0=      e# Take the first element of the array

C# (Visual C# Interactive Compiler), 77 bytes
n=>{int i,v=0;for(var m=new int[n];--n>0;m[v]=n,v=i<1?0:i-n)i=m[v];return v;}

Try it online!
Pretty much a port of the Java answer at this point.

Python 3, 128 114 111 102 99 bytes
102 -> 99 bytes, thanks to Jonathan Frech
f=lambda n,i=1,l=[0]:f(n,i+1,l+[l[i-2::-1].index(l[-1])+1if l[-1]in l[:-1]else 0])if n>i else l[-1]

Try it online!

You can negate your condition and use - instead of != to save a byte.

Also, since your golf appears to be side-effect-less, you can use lists instead of tuples.

@JonathanFrech But if I have a list as default argument it will not work correctly for consecutive calls?

Why should it not?

Weird, I had a list as a default argument before and it didn't clear between function call, making the result wrong.

Never mind, I used l.append() that time.

Most likely because your previous script modified the list, i.e. was not side-effect-less: example.

Vyxal, 8 bytes
W?(p:ḣḟ›

Try it Online! 1-indexed.
Explanation:
Since \$a(n) < n\$, we can push \$n\$ to the beginning of the list. Also builds the sequence backwards.
W?(p:ḣḟ› # whole program

W        # []
 ?       #            input
  (      # repeat for       times:
   p     #  prepend to list (uses implicit input the first time)
    :    #  duplicate
     ḣ   #  split head from the rest
      ḟ  #  find its index on the list (-1 if none)
       › #  increment
         # as we didn't prepend the last item, output it

Red, 106 95 bytes
func[n][b: copy[0]loop n[insert b either not find t: next b
b/1[0][-1 + index? find t b/1]]b/2]

Try it online!

Python 3, 112 bytes
a=[0]
for _ in a*int(input()):k=a[-1];a+=k in a[:-1]and[a[::-1].index(k)+~a[-2::-1].index(k)]or[0]
print(-a[-2])

Try it online!
-3 bytes thanks to mypetlion

Second line can become for _ in a*int(input()):k=a[-1];a+=k in a[:-1]and[a[::-1].index(k)+~a[-2::-1].index(k)]or[0] to save 3 bytes.

Pyth, 18 bytes
VQ=Y+?YhxtYhY0Y;hY

Try it online!
Builds up the sequence in reverse and prints the first element (last term of the sequence).
VQ                 # for N in range(Q) (Q=input)
  =Y+         Y    # Y.prepend(
        xtY        #   Y[1:].index(    )
           hY      #               Y[0]
       h           #                     +1
     ?Y      0     #                        if Y else 0)
               ;hY # end for loop and print Y[0]

Arn -f, 13 bytes
f→S›J⁻åƒƒN5═%

Try it!
0-indexed
Explained
Unpacked: &.{++.{:i:{)|}[
&.            Mutate S N times
  {             With block, key of `_`
      ++        Increment
            _   Implicit
          .{    Behead
        :i      Index of
            _   Implicit
          :{    Head
      )     Don't ask
    |           Concatenated with
      _         Implicit
  }             End block
  [           Where S is an array
  ]             Ending implicit
  _           And N is STDIN; implicit
            Then take the head

Nibbles, 5.5 bytes (11 nibbles)
=$.~~0?`)$

=$           # get the input-th element of:
  .~~        #   append until null (=for ever)
     0       #   starting with 0
      ?      #     get the index (or 0 if absent)
       `)$   #     in the list-so-far without its first element
             #     of its first element

I expected to need to reverse (\) the list-so-far (so: =$.~~0?`)\$ for 6 bytes), but somehow this works without doing that.  I'm not sure why.

Uiua 0.10.0, 17 bytes SBCS
⊢⍥(⊂⬚0⊡1⊚⌕⊢..):¤0

Try on Uiua Pad! Constructs the sequence in reverse order and then just takes the first entry. Golfed from a solution by @5imon in the Uiua Discord

Clojure, 69 bytes
#((fn f[i c t](if(= i 1)t(f(dec i)(assoc c t i)(-(or(c t)i)i))))%{}0)

Sadly a more functional approach seems to be longer.

C++ (clang), 241 235 234 219 197 189 bytes
197 -> 189 bytes, thanks to ceilingcat
#import<bits/stdc++.h>
int f(int n,int i=0,std::vector<int>l={0}){return~-n>i?l.push_back(find(begin(l),end(l)-1,l[i])-end(l)+1?find(rbegin(l)+1,rend(l),l[i])-rbegin(l):0),f(n,i+1,l):l[i];}

Try it online!

DC, 94 91 90 bytes
Input is taken during the program. Save this to a file and then do "dc " to run. Definitely not the shortest, but I have fun with challenges like these in dc. Input is 1-based index, as preferred.
[st1si0swlbxltlwlu1-sulu0!=m]sm[dlt=qSsli1+siz0!=b0siLs]sb[0pq]sf[lisw2Q]sq?2-dsu1>f0dlmxp

Main control macro
[st                         ]sm   save top value as target
[  1si0sw                   ]sm   reset i to 1 and w to 0
[        lbx                ]sm   execute macro b to get next value in w
[           ltlw            ]sm   restore target to the stack and add w to the stack
[               lu1-su      ]sm   decrement the user inputted variable
[                     lu0!=m]sm   if the user inputted variable is not 0 recurse

Next value finder macro
[dlt=q                  ]sb     if the value on the stack is the target, quit
[     Ss                ]sb     save top value to s register
[       li1+si          ]sb     increment i register
[             z0!=b     ]sb     recurse if still more values
[                  0si  ]sb     set i to 0 (will be saved to w if relevant)
[                     Ls]sb     move top value of s register to stack

[lisw2Q]sq   Load i, save it to w, and then quit this macro and the one that called it

[0pq]sf print 0 and quit the program
```

source: Stack Exchange

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

sort: votes


text:
Manhattan Directions Code Golf
This code golf challenge is to show directions through numbers.
When the user enters a number, then that means a direction change as follows:
0 means stay still
1 means forward (initially from left to right and initially start with `:`)
2 means turn right
3 means turn left
4 means go backward

I will show you an example: 122123333114
1 means 1 step forward
:═>

2 means 1 step to the right
   :═╗
     ‖
     V

2 means 1 step to the right
    :═╗
      ‖
    <═╝

1 means 1 step forward
    :═╗
      ‖
   <══╝

2 means 1 step to the right
   ^:═╗
   ‖  ‖
   ╚══╝

3 means 1 step to the left
 <═╗:═╗
   ‖  ‖
   ╚══╝

3 means 1 step to the left
 ╔═╗:═╗
 ‖ ‖  ‖
 V ╚══╝

3 means 1 step to the left
 ╔═╗:═╗
 ‖ ‖  ‖
 ╚═>══╝

3 means 1 step to the left
 ╔═^:═╗
 ‖ ‖  ‖
 ╚═╝══╝

1 means 1 step forward
   ^
 ╔═‖:═╗
 ‖ ‖  ‖
 ╚═╝══╝

1 means 1 step forward
   ^
   ‖
 ╔═‖:═╗
 ‖ ‖  ‖
 ╚═╝══╝

4 means 1 step backward
   ‖
 ╔═V:═╗
 ‖ ‖  ‖
 ╚═╝══╝

These are the rules:

Start with : and the initial direction will be from left to right

If starting with 0, then start with:
:

If starting with 1, then start with:
:=>

If starting with 2 then start with:
:╗
 ‖
 V

If starting with 3, then start with:
 ^
 ‖
:╝

If starting with 4, then start with:
<=:

Any other numbers or letters in the input will be ignored

T6@1 92J;{4 will mean 124

If two arrows came on top of each other, the new arrow should overwrite the old one

An example of this:
 ╔═╗:═╗
 ‖ ‖  ‖
 V ╚══╝

3 means 1 step to the left
 ╔═╗:═╗
 ‖ ‖  ‖
 ╚═>══╝

Arrow head should be > for left to right direction
Arrow head should be < for right to left direction
Arrow head should be V for top to bottom direction
Arrow head should be ^ for bottom to top direction

Do not forget the joint if you turn.
:╗
 ‖
 V

  :
<═╝

^
‖
╚:

╔═>
:

I hope I did not miss anything.
If you have any questions or if I missed anything, I will be editing this post.

Any other numbers or letters will be ignored This is rather annoying. There's enough challenge in the question itself without also having to add filtering the input string

Why does the second 2 in your first example make two "steps" forward after turning instead of just one?

@ValueInk mistake, got fixed

Some examples use ═ while others use =. Which one should we use?

In addition to @Grimy's question, wouldn't using ║ (unicode value 9553) instead of ‖ (unicode value 8214) make more sense? The unicode values of the corners are [9559,9565,9562,9556], so the ═ (unicode value 9552) and ║ (unicode value 9553) would align a lot better. See the current output in my 05AB1E answer in comparison to the previous 120 bytes version.

So to be clear, and is how the examples are, 4 steps you backwards AND reverses your direction, yeah?

05AB1E, 78 73 bytes
4LÃ3ÝÐ<T**‡D₁Í«S4Ê>ćVs.¥Ì8%•2ß1Í'£Jθ•14вsxs¦©;+èŽb[+ç':š"^>V<"®;θèª®₂YèšΛ

Try it online!
Explanation:
# The canvas built-in takes 3 arguments: lengths, strings to draw, and angles.
# First, we map the input to a list of angles, coded as multiples of 45°:
# Forward = 0, right = 2, U-turn = 4, left = 6.
# Conveniently, 4 already means U-turn in the input format.
# Since each turn is implicitly followed by a step in the new direction,
# we actually want to map 2 to [2, 0] and 3 to [6, 0].
4L                    # range 1..4
  Ã                   # remove everything else from the input
   3Ý                 # range 1..3
     Ð                # triplicate
      <  *            # multiply one copy by the other -1
       T*             # multiply by 10
                      # stack is now [filtered input, [1, 2, 3], [0, 20, 60]]
          ‡           # transliterate: 1 => 0, 2 => 20, 3 => 60

# Now we compute the lengths. 05AB1E's canvas is a bit finnicky: to get the
# desired output, we need to use length 2 for each character, except right
# before U-turns and at the end, where we want length 1.
D                     # copy the list of angles
 ₁Í«                  # append 254
    S4Ê               # != 4 over each digit
       >              # increment each
        ćV            # remove the first element, save it in Y
          s           # swap so the list of angles is at the top again

# Cconvert relative angls to absolute angles.
# 05AB1E's 0 is up, but the default direction is right, so we start at 2.
.¥                    # undelta (eg [6, 0, 4] => [0, 6, 6, 10])
  Ì                   # add 2 to each
   8%                 # modulo 8

# Now, we find the character to print at each step using a lookup table.
# For each pair of directions, we compute the index = first / 2 + second * 2.
# This maps each pair to a unique integer in 0..15.
•2ß1Í'£Jθ•14в         # compressed list: [1,4,1,7,13,0,7,0,1,10,1,13,10,0,4,0]
s                     # swap
 x                    # * 2 without popping
  s                   # swap (yes we're doing that a lot...)
   ¦                  # remove the first element
    ©                 # save in variable `r` without popping
     ;                # / 2
      +               # sum
       è              # index into the lookup table
        Žb[+          # add 9552
            ç         # map codepoints to characters
':š                   # prepend a ":"
         ®;θ          # half of the last angle
   "^>V<"   è         # nth character of "^>V<"
             ª        # append

# If the first command is 4, the initial angle should be 6, otherwise 2.
®                    # push list of angles
 ₂Yè                 # Yth digit of 26 (we set Y earlier, remember)
    š                # prepend

# Finally, call the canvas built-in:
Λ

@asmgx How did you get this error? The code works just fine on TIO.

Ruby, 302 306 322 327 bytes

+4 bytes to fix the edge case with the \$-i\$ direction (its angle is negative so we need to mod 4)
+16 bytes for even more edge case fixes in the stepping algorithm...
+5 bytes to fix the edge case where no inputs from 1-4 are present.

P=Math::PI/2
b=0i;f=d=p
c={b=>?:}
gsub(/[1-4]/){x=$&.to_i;d||=1
c[b+=d]="╗╝╚╔╗"[d.arg/P%4+x%2]if x[1]>0
d*=[0,1,1i,-1i,-1][x]
c[b+=d]="═║"[d.imag.abs]if x<4||!f
f=1}
c[b+=d]=">V<^"[d.arg/P]if d
q=c.keys.map &:rect
q=q.pop.zip *q
i,j=q[0].minmax
k,l=q[1].minmax
puts (k..l).map{|y|(i..j).map{|x|c[x+y*1i]||' '}*''}

Try it online!
Explanation
We initiate the grid as a hash table where the keys are complex numbers (real is the X-axis, imaginary is the Y-axis, lower numbers are closer to the top-left corner). This is convenient because we can initialize the direction variable as \$1\$, multiply by \$i\$ to turn right, and multiply by \$-i\$ to turn left. Also, we can quickly determine which way we're facing by dividing the direction's angle by \$\pi/2\$ and use that in our lookup tables.
Our algorithm, then, is roughly as follows:

Get the next number from the input in the range 1-4.
If the number is 2-3, step once and add the correct corner piece.
Look up the corresponding direction change and multiply.
Step once and add the correct straight piece. (Don't need to step if we turn around.)
Repeat until done.
Step and add the arrow piece.
Print the grid.

Code explanation (out of date, will fix later)
P=Math::PI/2                            # Save PI/2
b=0i;d=1                                # Set initial coordinates and direction
c={b=>?:}                               # Create grid with starting `:`
gsub(/[1-4]/){x=$&.to_i                 # For each number 1-4
c[b+=d]="╗╝╚╔╗"[d.arg/P+x%2]if x[1]>0   # If 2-3 (second bit is a 1), step and write the corner piece
                                        # If turning left (3), +1 to the index
d*=[0,1,1i,-1i,-1][x]                   # Multiply direction to turn accordingly
c[b+=d]="═‖"[d.imag.abs]                # Step and write the straight piece
}                                       # (end the loop)
c[b]=">V<^"[d.arg/P]                    # Write the corresponding arrow piece
q=c.keys.map &:rect                     # Get the filled-in grid spaces as X,Y coordinates
i,*_,j=q.map(&:first).sort              # Find the min and max X coordinate
k,*_,l=q.map(&:last).sort               # Find the min and max Y coordinate
puts (k..l).map{|y|                     # For each Y coordinate in range
      (i..j).map{|x|                    # For each X coordinate in range
                    c[x+y*1i]||' '      # Get the character, or space if not present
                }*''                    # Join characters on that Y coordinate and print
        }

I have to say wow.. you did amazing job, but need to fix this case 11113121

@asmgx fixed...

The 0 case is wrong, it should output :, not :>.

@Grimy ok, done.

You can save a handful of bytes by changing the two minmax lines to (i,j),(k,l)=q.map &:minmax

Then you can change q=c.keys.map &:rect⏎q=q.pop.zip *q⏎(i,j),(k,l)=q.map &:minmax to *q,r=c.keys.map &:rect⏎(i,j),(k,l)=r.zip(*q).map &:minmax for a few more bytes: https://tio.run/##TY3NTsJAFIX38xSVCP1hmHZqV4WLaxcmrNxMRtMfigMUSluSqUzfQRMbExNfrg9iBULUk9zkntzv3JPvw6rrZnAflM@@P7uzXRSCI8YJxJChCA4hTG/9Gi2KfWjYjI48bpsHCdcDUm6fxDhWCiiKWDiEmEOvbT7a5qttPtvm/bj3WEyCfGHP@t5Q9l0uEk0yyqcOii1gDqaYCjw6D2eS///z2jZvp7hIgwUJwuKcnXhKXSUoAVr/sdOHyeNv0QmLkbXDOURkNa8KkgaZNvDzeVQiQ@CliY0VXpuQkxeRGdbOvACp2KSBRNm@LDRjRcj6fDioShmCkOXFSRUxOawsKrhSuqbXlq7XXUddl7o3R1HqfW@zUmw3RTfa/AA

Also, x[1]>0 can be replaced with x&2>0.

05AB1E, 129 126 120 118 bytes
Žb_3Ý3*+ΣŽBÙNè}U4LÃ23SD1«‡©D4Å?Vε¾ˆ3%iŽb[D>‚¾èy≠i¼¼}ëy<iX¾è¼ëXÀ¾è.¼]¾ˆç':š®õQi`ë">V<^"¾èªDgÅ2¯¥2Q1Ý«-ćY+šsŽ9¦¯èYi¦6š}Λ

Sigh.. what a mess. Almost don't want to post it, but took too much time to not post it now. The challenge has quite a bit of edge cases I wasn't expecting when I started with it.. Can definitely be golfed (by a lot), though.
-3 bytes thanks to @Grimy.
-2 bytes by using ║ (unicode value 9553) instead of ‖ (unicode value 8214). If this is not allowed, 2 bytes has to be added again.
Try it online. (No test suite for all test cases at once, because there is no way to reset the Canvas, so outputs would overlap..)
Explanation:
Žb_              # Push the compressed integer 9556
   3Ý            # Push the list [0,1,2,3]
     3*          # Multiplied by 3: [0,3,6,9]
       +         # Added to the integer: [9556,9559,9562,9565]
        Σ     }  # Sort it:
         ŽBÙNè   #  Based on the order in the compressed integer 3021
                 # (so it's now in the order [9559,9565,9562,9556] ("╗╝╚╔"))
               U # Then pop and store it in variable `X`
4L               # Push a list [1,2,3,4]
  Ã              # And only keep those digits from the (implicit) input-string
   23S           # Push [2,3]
      D1«        # Duplicate it, and append a 1 to each: [21,31]
         ‡       # Replace all "2" with "21" and all "3" with "31"
©                # Store the string in variable `r` (without popping) to use later on
D4Å?             # Check if it starts with a 4 (without popping by duplicating first)
    V            # Pop and store it in variable `Y` to use later on
ε                # Map over each digit:
 ¾ˆ              #  Add counter `c` to the global array
                 #  (counter `c` is 0 by default)
 3%i             #  If the current digit is a 1 or 4:
    Žb[          #   Push compressed integer 9552
       D>‚       #   Pair it with it's increment: [9552,9553] ("═║")
          ¾è     #   And index the counter `c` into it
    y≠i  }       #   If the current digit is NOT 1 (so it's a 4):
       ¼¼        #    Increase counter `c` twice to reverse the direction
 ëy<i            #  Else-if the current digit is a 2:
     X¾è         #   Index the counter `c` into the list of variable `X`
     ¼           #   And increase the counter `c` by 1
 ë               #  Else (the current digit is a 3):
  X              #   Push the list of variable `X`
   À             #   Rotated it once toward the left: [9565,9562,9556,9559] ("╝╚╔╗")
    ¾è           #   Index the counter `c` into it again
  .¼             #   And decrease counter `c` by 1
]                # Close all if-else statements and the map
 ¾ˆ              # And also add the current counter `c` to the global array after the map
   ç             # Now convert all integers to ASCII characters with these unicode values
    ':š         '# Prepend a ":" to this list
®õQi             # If the input we saved in variable `r` was empty:
    `            #  Push (and implicitly output) this single ":" as result
ë                # Else:
 ">V<^"¾è        #  Index the counter `c` in the string ">V<^"
         ª       #  And append it to the list
 Dg              #  Get the length of the list (without popping by duplicating first)
   Å2            #  Create a list with that many 2s
     ¯¥          #  Push the deltas/forward differences of the global array
       2Q        #  Check if a delta is equal to 2 (which means we reversed direction)
                 #  (1 if truthy; 0 if falsey)
         1Ý«     #  Append a trailing [0,1]
            -    #  Subtract them from the list of 2s
  Y              #  If the input started with a 4:
 ć +š            #   Increase the very first integer by 1 (from 1 to a 2)
 s               #  Swap this integer list for the lengths and string list on the stack
 Ž9¦             #  Push compressed integer 2460
    ¯è           #  Index each value of the global array into it
      Yi   }     #  If the input started with a 4:
        ¦6š      #   Replace the first integer with a 6
 Λ               # Use the Canvas builtin (which is output immediately implicitly)

See this 05AB1E tip of mine (section How to compress large integers?) to understand why Žb_ is 9556; ŽBÙ is 3021; Žb[ is 9552; and Ž9¦ is 2460.
As for a brief explanation of the Canvas builtin Λ and its three arguments:
First argument: length(s): the sizes of the lines we want to draw. Since we have to keep in mind overlapping, we use size 2 for every character, except if we reverse the direction and we want to overlap or for the final character (one of >V<^), for which we'll use size 1 instead.
Second argument: string(s): the characters we want to display. Which are the characters in this case, with the prepended :, and if the input wasn't empty/0 the appended appended final character (one of >V<^).
Third argument: direction(s): the directions these character-lines of the given length should be drawn in. In general we have the directions [0,7] which map to these directions:
7   0   1
  ↖ ↑ ↗
6 ← X → 2
  ↙ ↓ ↘
5   4   3

Which is why we have the integer 2460 for the directions \$[→,↓,←,↑]\$ respectively.
See this 05AB1E tip of mine for a more detailed explanation about the Canvas builtin Λ.

0ª1ª => 1Ý«. Yić>š} => ćY+š.

@Grimy Ah of course. I'm stupid for not using 1Ý.. Thought about using 01S«, but figured it wouldn't change the byte-count.. >.> I guess these are the easy golfs and you're now working on a ~75 bytes version yourself, haha? ;p

Yep, I'd like to make my own solution. 75 sounds a tad bit optimistic, but we'll see.

Here's what I have so far. I know this fails when 4 is the first command; are you aware of other edge cases I have missed?

@Grimy Apart from the 4 as first or only input, an additional edge case that's currently incorrect is an input 0 (or 000...). It currently results in :> but should be : instead. This is why I have the ®õQi in my code. And nice, I wasn't too far off with my guess of 75 bytes. Although we still have to see how many bytes you need to fix these two edge cases. The 0 isn't too hard to fix, but the 4 as first is indeed a bit annoying.

Oh, thanks for the tip about the 0 edge case! Thankfully I can fix it with a single byte =D.

@Grimy Haha, nice. That's even better than I thought. ;p Good luck fixing the leading 4 edge case. I'll make sure to upvote you when it's posted. ;)

Let us continue this discussion in chat.

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


text:
Who won a Game of Bar Dice?
Challenge
Bar Dice is a simple game played in a Bar with Dice (hence the name). You roll 5 six-sided dice and attempt to make the best hand.

Scoring is based on amassing the largest number of dice with the same digits. Each hand must include at least a single "Ace", or one, in order to be a valid hand; Aces act as "wilds", and can be paired with any other digit. The strength of a player's hand depends first on the number of digits and then value of those digits. As an example, a hand (counting wilds) with four 3's is better than a hand with three 5's, but not better than a hand with five 2's.
Taken from the Wikipedia article

This means the highest ranked hand is made entirely of 6's and 1's, and the lowest ranked is any hand without a 1.
Your challenge is to take two hands and return which player won, or if they tied.
Input
Two unsorted lists of 5 numbers, ranging from 1 to 6. Each list represents a player's hand. The input format is flexible.
Output
Any three distinct but consistent, static values (ranges are not allowed) signifying whether player 1 or player 2 won, or if it was a tie. Please state in your answer what values you are using for what. For example, you can return -1 if P1 wins, 0 if it's a tie, and 1 if P2 wins.
Rules

Input will always be valid
Only the best possible score of each hand is used to determine a winner. There are no tie-breakers. E.g., [1,4,4,3,3] will tie [1,4,4,2,2] instead of using the 3's and 2's as a tie-breaker.
Output must be one of the 3 chosen values every time. Simply mapping all negative numbers to P1 Wins is not allowed and must be normalized.
Invalid hands, i.e. those with no 1's, lose to all valid hands but tie with all other invalid hands. E.g., [2,2,2,2,2] ties [3,3,3,3,3].
A hand of [1,1,1,1,1] counts as a valid set of 6's for ranking purposes.
This is code-golf so shortest byte count wins.

Examples
#You guys are pretty good at finding edge-cases that break things. Good job!
Input:  [2,1,5,6,6], [6,2,6,6,6]
Output: P1 Wins

Input:  [2,4,5,6,6], [6,2,6,6,6]
Output: Tie

Input:  [1,2,3,4,5], [5,4,3,2,1]
Output: Tie

Input:  [1,5,5,3,2], [5,4,1,6,6]
Output: P2 Wins

Input:  [3,2,2,2,1], [4,1,3,6,6]
Output: P1 Wins

Input:  [1,1,1,1,1], [6,1,1,6,6]
Output: Tie

Input:  [1,3,3,4,4], [1,2,2,5,5]
Output: P2 Wins

Input:  [1,3,3,5,5], [1,3,3,2,2]
Output: P1 Wins

Input:  [1,3,3,3,4], [1,1,3,3,3]
Output: P2 Wins

Input:  [2,2,2,6,1], [5,3,3,1,2]
Output: P1 Wins

Input:  [5,5,5,1,5], [1,1,1,1,1]
Output: P2 Wins

Input:  [1,1,1,1,1], [1,1,5,1,1]
Output: P1 Wins

Jelly, 17 14 bytes
ċⱮ6Ḣ©+$®aĖUṀ)M

Try it online!
A monadic link that takes a list of the two lists as its argument and returns [1] for player 1 wins, [2] for player 2 wins and [1, 2] for a tie. TIO link tidies this up for display.
Thanks to @JonathanAllan for saving 3 bytes!
Explanation
            )   | For each input list (e.g. of one list 1,1,3,3,4)
ċⱮ6             | - Count each of 1..6 (e.g. 2,0,2,1,0,0)
      $         | - Following as a monad:
   Ḣ            |   - Head (number of 1s)
    ©           |   - Copy to register
     +          |   - Add (e.g. 2,4,3,0,0)
       ®a       | - Register logical and with this
         Ė      | - Enumerate (e.g. [1,2],[2,4],[3,3],[4,0],[5,0])
          U     | - Reverse each (e.g. [2,1],[4,2],[3,3],[0,4],[0,5])
            Ṁ   | - Max (e.g. 4,2)
              M | Index/indices of maximal score

You could replace the IṠ with M and output a list of the winner(s).

@JonathanAllan Good point! Thanks

15 bytes by making use of the register.

I think the Ḍ may now be redundant too since the lists sort the same as the integers.

This is a lovely approach.  Well done.

R, 115 96 bytes
-6 bytes thanks to Giuseppe.
-6 bytes thanks to Aaron Hayman.
-2 bytes thanks to Arnauld, following the output format in his JavaScript answer.
function(i,j)(f(i)-f(j))/0
f=function(x,s=tabulate(x,6),l=s[1]+s[-1]*!!s[1])max(l)*6+order(l)[5]

Try it online!
Returns Inf for P1, NaN for a tie, -Inf for P2.
Uses the helper function f which computes a score for each hand. The score is defined as follows: let d be the digit which is repeated the most, and n the number of times it is repeated. Then the score is 6*n+d if there is at least one ace, and 0 if there are no aces. We then just need to find the player with the highest score.
Ungolfed:
f = function(x) {
  s = tabulate(x, 6)         # number of occurrences of each integer
  l = s[1] + s[-1] * !!s[1]  # add the number of wild aces to all values; set to 0 if s[1] == 0
  max(l) * 6 +               # highest number of repetitions (apart from aces)
    order(l)[5]              # most repeated integer (take largest in case of tie)
}
function(i, j){
  sign(f(i) - f(j))
}

You can use order(l)[5] instead of max.col(t(l),"l") to get a 96 byte solution: Try it online!

@AaronHayman Very nice, thanks!

Python 2, 85 81 80 bytes
lambda p:cmp(*[max((h.count(i)+h.count(i>1),i)*(1in h)for i in[6]+h)for h in p])

Try it online!
Returns 1 for P1, 0 for tie, and -1 for P2.
-1 byte, thanks to squid

Whitespace between 1 and in can go

05AB1E, 16 15 bytes
-1 byte thanks to JonathanAllan
εWΘ*6L¢ć+°ƶà}ZQ

Try it online!
Returns [1, 0] for P1 wins, [1, 1] for ties, [0, 1] for P2 wins.
Rather than using lexicographic order on a 2-tuple (dice count, dice value), this computes the score as 10**dice count * dice value. Hands without a 1 score 5.
ε           }           # map each hand to its computed score
 WΘ                     # minimum == 1 (1 if the hand contains a 1, 0 otherwise)
   *                    # multiply (sets hands without 1 to [0, 0, 0, 0, 0])
    6L                  # range [1..6]
      ¢                 # count occurences of each in the hand
       ć                # head extract (stack is now [2-count, ..., 6-count], 1-count)
        +               # add the 1-count to all the other counts
         °              # 10**x
          ƶ             # multiply each element by its 1-based index
           à            # take the maximum

Z                       # maximum
 Q                      # equality test (vectorizes)

Ohhh.. I like the ć+ (now that I see it I cannot believe I hadn't thought about it..)! That's so much better than what I was attempting.. I did had a similar idea with °. :) Except that I was already at 20 bytes and still had to fix an issue for test case [[1,1,1,1,1],] [6,1,1,6,6]].. So thanks for saving me time so I can put my attempt in the garbage bin.. ;p

@KevinCruijssen Yeah it's amazing how well ć+ works. My initial idea started with æʒW}ʒ1KË, but this gets killed by the [1,1,1,1,1] issue.

Yeah, my approach was along the lines of ε1¢©Āy{γéθ¬sg®+°P}`.S, but the [1,1,1,1,1] screwed that over as well indeed. Your entire answer got a nice synergy with the WΘ*, 6L¢, ć+, and °ƶ. Especially the builtins Wćƶ really show their strength here.

W isn't actually needed, 6L¢¬Ā* is the same byte-count as WΘ*6L¢.

Hmm, good point. :) Thought W without popping and then * showed it's strength, but ¬ without popping and then * is basically the same. The fact that it doesn't pop is the strength I was implying to, saving a byte. But it's indeed mainly ćƶ.

JavaScript (ES6),  97  90 bytes
Takes input as (a)(b). Returns +Infinity for P1, -Infinity for P2 or NaN for a tie.
a=>b=>((g=(x,m)=>x>6?m*/1/.test(a):g(-~x,a.map(k=>n+=k<2|k==x,n=x/6)|m>n?m:n))()-g(a=b))/0

Try it online!
Commented
a => b => (                 // a[] = dice of P1; b[] = dice of P2
  ( g = (                   // g is a recursive function taking:
      x,                    //   x = dice value to test; initially, it is either undefined
                            //       or set to a non-numeric value
      m                     //   m = maximum score so far, initially undefined
    ) =>                    //
      x > 6 ?               // if x is greater than 6:
        m * /1/.test(a)     //   return m, or 0 if a[] does not contain any 1
      :                     // else:
        g(                  //   do a recursive call:
          -~x,              //     increment x (or set it to 1 if it's non-numeric)
          a.map(k =>        //     for each dice value k in a[]:
            n +=            //       add 1 to n if:
              k < 2 |       //         k is equal to 1
              k == x,       //         or k is equal to x
            n = x / 6       //       start with n = x / 6
          ) |               //     end of map()
          m > n ?           //     if m is defined and greater than n:
            m               //       pass m unchanged
          :                 //     else:
            n               //       update m to n
        )                   //   end of recursive call
  )()                       // first call to g, using a[]
  - g(a = b)                // subtract the result of a 2nd call, using b[]
) / 0                       // divide by 0 to force one of the 3 consistent output values

Perl 6, 60 49 bytes
&[cmp]o*.map:{.{1}&&max (.{2..6}X+.{1})Z ^5}o&bag

Try it online!
Returns More, Same, Less for P1 Wins, Tie, P2 Wins.
Explanation
       *.map:  # Map input lists
                                             &bag  # Convert to Bag
             {                             }o  # Pass to block
              .{1}&&  # Return 0 if no 1s
                    max  # Maximum of
                         .{2..6}  # number of 2s,3s,4s,5s,6s
                                X+.{1}  # plus number of 1s
                        (             )Z     # zipped with
                                         ^5  # secondary key 0,1,2,3,4
&[cmp]o  # Compare mapped values

T-SQL query, 147 bytes
Using table variable as input

p: player
v: value for roll

DECLARE @ table(p int,v int)
INSERT @ values(1,5),(1,5),(1,5),(1,5),(1,5)
INSERT @ values(2,4),(2,3),(2,3),(2,1),(2,4)

SELECT sign(min(u)+max(u))FROM(SELECT(p*2-3)*(s+sum(1+1/~s-1/v))*(s/5*5+v+30)u
FROM(SELECT*,sum(1/v)over(partition by p)s FROM @)c GROUP BY v,s,p)x

Try it online
Player 1 wins returns -1
Tie returns 0
Player 2 wins returns 1

Java 8, 244 240 236 215 199 bytes
a->b->{int c[][]=new int[2][7],m[]=new int[2],p,i=5;for(;i-->0;c[1][b[i]]++)c[0][a[i]]++;for(i=14;i-->4;)m[p=i%2]=Math.max(m[p],c[p][1]>0?i/2+9*(c[p][i/2]+c[p][1]):0);return Long.compare(m[0],m[1]);}

-4 bytes thanks to @someone.
-21 bytes thanks to @Neil.
-16 bytes thanks to @ceilingcat.
Returns 1 if P1 wins; -1 if P2 wins; 0 if it's a tie.
Try it online.
Explanation:
a->b->{                        // Method with 2 integer-array parameters & integer return
  int c[][]=new int[2][7],     //  Create a count-array for each value of both players,
                               //  initially filled with 0s
      m[]=new int[2],          //  The maximum per player, initially 0
      p,                       //  Temp-value for the player
  i=5;for(;i-->0;              //  Loop `i` in the range (5, 0]:
    c[1]                       //   For player 2:
        [b[i]                  //    Get the value of the `i`'th die,
             ]++)              //    and increase that score-count by 1
    c[0][a[i]]++;              //   Do the same for player 1
  for(i=14;i-->4;)             //  Then loop `i` in the range (14, 4]:
    m[p=i%2]=                  //   Set the score of a player to:
                               //   (even `i` = player 1; odd `i` = player 2)
      Math.max(                //    The max between:
        m[p],                  //     The current value,
                               //     And the value we calculate as follows:
        c[p][1]>0?             //     If this player rolled at least one 1:
          i/2                  //      Use the current value `i` integer-divided by 2
          +9*                  //      With 9 times the following added:
             (c[p][i/2]        //       The amount of dice for value `i//2`
              +c[p][1])        //       Add the amount of dice for value 1
        :                      //     Else (no 1s were rolled):
         0);                   //      Use 0
  return Long.compare(m[0],m[1]);}
                               //  Finally compare the maximum scores of the players,
                               //  resulting in -1 if a<b; 0 if a==b; 1 if a>b

In the for loop over p, you can replace ...*(c[p][1]>0?1:0) with c[p][1]>0?...:0. I canot post a TIO link, as it's too long and I don't want to shorten it. The ungolfed version has unbalanced parentheses somewhere around there.

@someone Ah, of course, thanks. I added the c[p][1]>0? check later on as bug-fix, but apparently without thinking a lot. Thanks for the -4. :)

Why the *(i<2?6:i)? You're just duplicating effort for i=6 and i=1. This can be just *i (and stop looping when you get to 2).

Also, the 9 can be any magic number between 5 and about 32, right? If you use 8 then instead of (int)Math.pow(8,(...)*i) you can use i<<3*(...).

Or just i+9*(...) seems like it should work.

@Neil As for your first comment regarding *(i<2?6:i) and looping in the range (7, 2], that would fail for test case [1,1,1,1,1], ..., which should count as five 6s. As for the (int)Math.pow(8,c[p][i]+(i>1?c[p][1]:0))*... going to (c[p][i]+(i>1?c[p][1]:0)<<3)*..., it seems to give an incorrect result for test case [3,2,2,2,1],[4,1,3,6,6].

I ended up with a->b->{int c[][]=new int[2][7],m[]=new int[2],s,p,i=5;for(;i-->0;c[1][b[i]]++)c[0][a[i]]++;for(i=7;i-->2;)for(p=2;p-->0;m[p]=s>m[p]?s:m[p])s=c[p][1]>0?i+9*(c[p][i]+(i>1?c[p][1]:0)):0;return Long.compare(m[0],m[1]);} which seems to pass all of your test cases...

@Neil Ah, of course. I was using the power because I multiple with i, but if I just add the i instead I can use the 9* instead of 9**. Thanks for -21 bytes!

Jelly, 21 bytes
crushed before I even posted it by Nick Kennedy :)
’-oÆṃṀ$$Ạ?fÆṃ$L;$o5)M

A monadic Link accepting a list of players which outputs a list of (1-indexed) winners.
So P1 is [1], P2 is [2] and a tie is [1,2].
Try it online!

PowerShell, 112 126 123 121 bytes
Takes input as (a)(b). Returns -1 for P1 win, 1 for P2 or 0 for a tie.
$args|%{$d=$($_-ne1|group|sort c*,n*|%{$m=$_};(7*(($o=($_-eq1).Count)+$m.Count)+$m.Name+6*!$m)[!$o])-$d}
[math]::Sign($d)

Try it online!
Test case @( @(1,1,5,1,1), @(1,1,1,1,1), 1) added.
Unrolled:
$args|%{
    $score=$(                                            # powershell creates a new scope inside expression $(...)
        $_-ne1|group|sort count,name|%{$max=$_}          # $max is an element with the widest group and the maximum digit except 1
        $ones=($_-eq1).Count                             # number of 1s in a player's hand
        $scoreRaw=7*($ones+$max.Count)+$max.Name+6*!$max # where $max.Name is digit of the widest group
        $scoreRaw[!$ones]                                # output $scoreRaw if the array contains 1, otherwise output $null
    )                                                    # powershell deletes all variables created inside the scope on exit
    $diff=$score-$diff
}
[math]::Sign($diff)                                     # output the score difference

Wolfram Language (Mathematica), 78 75 74 bytes
-1 byte by Greg Martin
Order@@(#~FreeQ~1||Last@Sort[Reverse/@Tally@Flatten[#/. 1->Range@6]]&)/@#&

Try it online!
Outputs -1 when player 1 wins, 1 when player 2 wins, and 0 for a tie.
                                    Helper function to score a list:
FreeQ[#,1] ||                       If there are 0 1s, score is True
Last@Sort[                          Otherwise, take the largest element of
    Reverse/@Tally@                 the {frequency, number} pairs in the flat list
       Flatten[ #/. 1->Range@6]     where each 1 is replaced by {1,2,3,4,5,6}.
]&                              e.g. {1,3,3,5,5} -> {1,2,3,4,5,6,3,3,5,5} -> {3,5}

Order @@ (...) /@ #&                Apply this function to both lists,
                                    then find the ordering of the result.

You can save one byte by replacing FreeQ[#,1] with #~FreeQ~1.

Jelly, 27 bytes
’o5Rṗ5¤ṢŒr$€UẎṀ1e⁸¤×µ€_/Ṡo/

Try it online!
1 for P1, -1 for P2, 0 for tie
Explanation
’o5Rṗ5¤ṢŒr$€UẎṀ1e⁸¤×µ€_/Ṡo/  Main link
                    µ€       For each list
’                            Decrement each value (so 1s become falsy)
 o                           Vectorized logical or (this replaces previous 1s (now 0s) with the test values)
  5Rṗ5¤                      1..5 cartesian-power 5 (1,1,1,1,1; 1,1,1,1,2; 1,1,1,1,3; ...)
          $€                 For each test list
       ṢŒr                   Sort and run-length encode (gives [digit, #digit])
            U                Reverse each list (gives [#digit, digit])
             Ẏ               Tighten by one (gives a list containing each possible hand for each possible wildcard)
              Ṁ              Take the maximum
               1e⁸¤×         Multiply the list values by (whether or not the original contained a 1) - becomes [0, 0] if not
                      _/Ṡ    Take the sign of the difference between the #digits and the digits
                         o/  If the number of digits differs, then 1/-1 is returned; otherwise, check the value of the digit (could still be 0)

Charcoal, 48 45 bytes
ＵＭθ⮌Ｅ⁷№ι∨λ¹ＵＭθ×¬¬⊟ι⁺⊟ιιＵＭθ⟦⌈ι±⌕ι⌈ι⟧Ｉ⁻⌕θ⌈θ⌕θ⌊θ

Try it online! Link is to verbose version of code. Takes input as an array of arrays and outputs -1 if player 1 wins, 0 for a tie, and 1 if player 2 wins. Explanation:
ＵＭθ⮌Ｅ⁷№ι∨λ¹

Replace each hand with the count of how many times the values 6..1 appear in the hand. The list is reversed because a) it makes it easier to find the highest value with the highest count and b) it makes it easier to remove the count of 1s. The count of 1s is doubled because it needs to be removed twice, once to check that it is nonzero and once to add it to the other counts.
ＵＭθ×¬¬⊟ι⁺⊟ιι

Add the count of 1s to the counts for 6..2, but set all of the counts to zero if the count of 1s was zero.
ＵＭθ⟦⌈ι±⌕ι⌈ι⟧

For each hand find the highest count and the highest value with that count. (Actually we find value minus 6 as that's golfier.)
Ｉ⁻⌕θ⌈θ⌕θ⌊θ

Determine which hand won by subtracting the positions of the winning and losing hands. (If the hands are tied then the first hand is both winning and losing so the result is 0 as desired.)

Sledgehammer 0.4, 27 bytes
⢱⢙⢂⠠⡾⢃⠐⢈⠸⣞⠴⠻⠎⡥⡳⡐⢒⠘⢛⣩⡓⣮⡕⡠⣢⣡⠿

Decompresses into this Wolfram Language function:
Order @@ (FreeQ[#1, 1] || Last[Sort[Reverse[Tally[Flatten[#1 /. 1 -> Range[6]]], 2]]] & ) /@ #1 &

which turns out to be exactly the same as my Mathematica answer.

C (gcc) / 32 bit, 117 bytes
t;m;s(int*r){int c[6]={};for(m=0;t=*r++;m=t>m?t:m)c[--t]+=5,t=t?c[t]+t:5;t=*c?*c+m:0;}f(a,b){t=s(a)-s(b);t=(t>0)-!t;}

Try it online!
Takes two zero-terminated integer arrays. Returns 1, 0, -1 for P1 Wins, P2 Wins, Tie.

J, 47 44 bytes
*@-&([:({.([:>./#\@]+9^*@[*+)}.)1#.i.@6=/<:)

Try it online!
Inspired by Nick Kennedy's idea.
ungolfed
*@-&([: ({. ([: >./ #\@] + 9 ^ *@[ * +) }.) 1 #. i.@6 =/ <:)

Perl 5 -MList::Util=max -pl, 80 bytes
sub t{$t=pop;$_=max map$_ x$t=~s/$_//g,2..6;/./;$t&&$_.$t*($&||6)}$_=t($_)<=>t<>

Try it online!
Input:
Each player on a separate line, no spaces
Output:
1 Line one wins
0 Tie
-1 Line two wins

Changed based on your clarification of the rules of the game