text:
There's an echo in my array... echo in my array... my array
Help!  I seem to have an annoying echo in some of my arrays, and I'd like to get rid of it.  When this occurs, the original array repeats itself somewhere in the middle causing the values to be added to each other.
For example, the array [ 422, 375, 527, 375, 859, 451, 754, 451 ] contains an echo of itself like so:
[ 422, 375, 527, 375, 859, 451, 754, 451 ] <-- array with echo (input)

[ 422, 375, 105,   0, 754, 451           ] <-- original array (output)
[           422, 375, 105,   0, 754, 451 ] <-- echo of original array

Example 2:
[ 321, 526, 1072, 899, 6563, 798, 7038, 3302, 3032, 3478, 1806, 601 ] <-- input

[ 321, 526,  751, 373, 5812, 425, 1226, 2877, 1806,  601            ] <-- output
[            321, 526,  751, 373, 5812,  425, 1226, 2877, 1806, 601 ]

It's also possible that there is no echo in the array, in which case return the original array:
Example 3:
[ 623, 533, 494, 382 ] <-- input
[ 623, 533, 494, 382 ] <-- output

Challenge:
Given an array that may contain an echo, remove it and return the array without an echo.
Input:

An array, list, delimited string, punched cards or your platform-suitable equivalent, containing three or more integers, in the range of \$0\leq n\lt10000\$ with at least one element \$\gt 0\$.
The echo cannot begin at the first or after the last element.
The echo will only occur once or not at all within the input.

Output:

An array, list, etc of integers \$0\leq n\lt10000\$, with the echo removed.
If there is no echo, return the original array.

Rules and scoring:

This is code-golf, so shortest answer in bytes for each language wins.
Standard rules and default I/O rules apply.
Loopholes forbidden (of course).
Please provide link with a test for your code (TIO.run, etc).
A clear explanation for your answer is highly recommended.

Test cases:
With echo:
[ 422, 375, 527, 375, 859, 451, 754, 451 ]
[ 422, 375, 105, 0, 754, 451 ]

[ 321, 526, 1072, 899, 6563, 798, 7038, 3302, 3032, 3478, 1806, 601 ]
[ 321, 526, 751, 373, 5812, 425, 1226, 2877, 1806, 601 ]

[ 4330, 3748, 363, 135, 2758, 3299, 1674, 1336, 4834, 2486, 4087, 1099, 4098, 4942, 2159, 460, 4400, 4106, 1216, 3257, 1638, 2848, 3616, 3554, 1605, 490, 1308, 2773, 3322, 3284, 4037, 7109, 4171, 5349, 2675, 3056, 4702, 4229, 1726, 5423, 6039, 8076, 6047, 7088, 9437, 4894, 1946, 7501, 5331, 3625, 5810, 6289, 2858, 6610, 4063, 5565, 2200, 3493, 4573, 4906, 3585, 4147, 3748, 3488, 5625, 6173, 3842, 5671, 2555, 390, 589, 3553, 3989, 4948, 2990, 4495, 2735, 1486, 3101, 1225, 2409, 2553, 4651, 10, 2994, 509, 3960, 1710, 2185, 1800, 1584, 301, 110, 969, 3065, 639, 3633, 3544, 4268 ]
[ 4330, 3748, 363, 135, 2758, 3299, 1674, 1336, 4834, 2486, 4087, 1099, 4098, 4942, 2159, 460, 4400, 4106, 1216, 3257, 1638, 2848, 3616, 3554, 1605, 490, 1308, 2773, 3322, 3284, 4037, 2779, 423, 4986, 2540, 298, 1403, 2555, 390, 589, 3553, 3989, 4948, 2990, 4495, 2735, 1486, 3101, 1225, 2409, 2553, 4651, 10, 2994, 509, 3960, 1710, 2185, 1800, 1584, 301, 110, 969, 3065, 639, 3633, 3544, 4268 ]

[ 24, 12, 52, 125, 154, 3, 567, 198, 49, 382, 53, 911, 166, 18, 635, 213, 113, 718, 56, 811, 67, 94, 80, 241, 343, 548, 68, 481, 96, 79, 12, 226, 255, 200, 13, 456, 41 ]
[ 24, 12, 52, 125, 154, 3, 567, 198, 25, 370, 1, 786, 12, 15, 68, 15, 88, 348, 55, 25, 55, 79, 12, 226, 255, 200, 13, 456, 41 ]

[ 1, 3, 2 ]
[ 1, 2 ]

[ 0, 1, 3, 2, 0 ]
[ 0, 1, 2, 0 ]

Without echo:
[ 623, 533, 494, 382 ]
[ 623, 533, 494, 382 ]

[ 1141, 1198, 3106, 538, 3442, 4597, 4380, 3653, 1370, 3987, 1964, 4615, 1844, 5035, 2463, 6345, 4964, 4111, 5192, 8555, 5331, 3331, 4875, 6586, 5728, 4532, 5972, 2305, 3491, 6317, 2256, 2415, 5788, 4873, 6480, 2080, 5319, 4551, 6527, 5267, 4315, 2178, 2615, 5735, 5950, 6220, 7114, 6259, 5000, 4183, 6822, 6927, 7150, 8003, 5603, 3154, 8231, 5005, 5743, 6779, 4530, 4029, 5336, 6105, 4777, 6183, 6838, 5725, 6819, 8584, 3142, 3840, 3291, 4284, 2933, 4859, 2906, 5176, 2853, 2110, 2048, 4389, 4501, 2267, 2704, 431, 1495, 2712, 3008, 187, 3487, 630 ]
[ 1141, 1198, 3106, 538, 3442, 4597, 4380, 3653, 1370, 3987, 1964, 4615, 1844, 5035, 2463, 6345, 4964, 4111, 5192, 8555, 5331, 3331, 4875, 6586, 5728, 4532, 5972, 2305, 3491, 6317, 2256, 2415, 5788, 4873, 6480, 2080, 5319, 4551, 6527, 5267, 4315, 2178, 2615, 5735, 5950, 6220, 7114, 6259, 5000, 4183, 6822, 6927, 7150, 8003, 5603, 3154, 8231, 5005, 5743, 6779, 4530, 4029, 5336, 6105, 4777, 6183, 6838, 5725, 6819, 8584, 3142, 3840, 3291, 4284, 2933, 4859, 2906, 5176, 2853, 2110, 2048, 4389, 4501, 2267, 2704, 431, 1495, 2712, 3008, 187, 3487, 630 ]

[ 4791, 1647, 480, 3994, 1507, 99, 61, 3245, 2932, 8358, 6618, 1083, 5391, 3498, 4865, 1441, 3729, 5322, 5371, 6271, 2392, 1649, 5553, 9126, 3945, 2179, 3672, 2201, 4433, 5473, 4924, 6585, 6407, 3862, 6505, 1530, 5293, 4792, 6419, 6739, 3258, 3839, 3891, 7599, 2576, 5969, 5659, 6077, 5189, 1325, 4490, 5694, 6567, 6367, 5724, 5756, 6450, 5863, 4360, 2697, 3100, 3779, 4040, 4653, 1755, 3109, 2741, 3269 ]
[ 4791, 1647, 480, 3994, 1507, 99, 61, 3245, 2932, 8358, 6618, 1083, 5391, 3498, 4865, 1441, 3729, 5322, 5371, 6271, 2392, 1649, 5553, 9126, 3945, 2179, 3672, 2201, 4433, 5473, 4924, 6585, 6407, 3862, 6505, 1530, 5293, 4792, 6419, 6739, 3258, 3839, 3891, 7599, 2576, 5969, 5659, 6077, 5189, 1325, 4490, 5694, 6567, 6367, 5724, 5756, 6450, 5863, 4360, 2697, 3100, 3779, 4040, 4653, 1755, 3109, 2741, 3269 ]

[ 235, 121, 52, 1249, 154, 26, 5672, 1975, 482, 3817, 532, 9104, 1661, 171, 6347, 2124, 1122, 7175, 558, 8101, 667, 934, 798, 2404, 3424, 5479, 672, 4808, 956, 789, 123, 2255, 2549, 200, 126, 4562, 41 ]
[ 235, 121, 52, 1249, 154, 26, 5672, 1975, 482, 3817, 532, 9104, 1661, 171, 6347, 2124, 1122, 7175, 558, 8101, 667, 934, 798, 2404, 3424, 5479, 672, 4808, 956, 789, 123, 2255, 2549, 200, 126, 4562, 41 ]

[ 1, 1, 1, 1, 1 ]
[ 1, 1, 1, 1, 1 ]

What if there are multiple possible outputs? Input: [1, 2, 2, 2, 1]; Output: [1, 1, 1, 1] vs. [1, 2, 1]

What is the expected output for [1, 2, 3, 1, 2, 3], [1, 2, 3, 0, 1, 2, 3], [0, 1, 3, 2, 0]? Current answers do not agree on all of these inputs.

@tsh Either of those ([1, 1, 1, 1] vs. [1, 2, 1]) are acceptable.  I originally had a rule about which to choose, but took it off in sandbox because it seemed to only apply to a small number of edge cases.

@tsh, [0, 1, 3, 2, 0] should be [0, 1, 2, 0] - I've added to the test cases. An expected answer on the other two could be [1, 2, 3] though I wouldn't consider those valid test cases since according to the rules the original array repeats itself somewhere in the middle.

Yet another interesting test case: [0,0,0] which should result in [0,0].

@nimi Good one. I would say it's ambiguous whether [0,0,0] (or any sized all-0's array) represents an echo of anything or if [0,0,0] (no echo) would also be a valid answer for this special case as well, as there is simply not enough information to determine which it is. I will update the rules to restrict this from being a valid input, as that will not invalidate or alter any existing answers.

I think your [235, 121, 52, ...] example is wrong.

@Roman Fixed, thx.

What about outputting all possible outputs? (i.e. both [1, 1, 1, 1] and [1, 2, 1] for input [1, 2, 2, 2, 1])

Do we need to check if the echo is not in the specified range? ([2, -1, 2] for [2, 1, 1, 2])

@attinat no, you do not need to validate input. You can assume valid input and output per spec - 0 <= n < 10000.

@attinat you may return multiple results if you find them, but it's not required - any demonstrably correct answer is acceptable. I believe there are relatively few possible inputs with more than one valid output, though if you generate sequences that have two or more possible answers I'd be curious to see them!

MATL, 16 bytes
t"GX@WQB&Y-~?w]x

Try it online! Or verify all test cases.
Explanation
Polynomial division for the win!
t      % Implicit input. Duplicate
"      % For each (do the following as many times as input length)
  G    %   Push input again. This will be the output if no solution exists
  X@   %   Push current iteration index, k
  WQB  %   2 raised to that, add 1, convert to binary. Gives [1 0 ... 0 1] (k-1 zeros)
  &Y-  %   Two-output polynomial division (deconvolution). Gives quotient and remainder
  ~    %   Logical negate: transforms zeros into 1, nonzeros into 0
  ?    %   If all values are nonzero (i.e. if remainder was all zeros): solution found
    w  %      Swap. This moves the copy of the input to top (to be deleted)
  ]    %   End
  x    %   Delete. This deletes the quotient if it was not a solution, or else deletes
       %   the copy of the input
       % End (implicit). Since it is guaranteed that at most one solution exists, at this
       % point the stack contains either the solution or the input
       % Implicit display

No takers on the "eso" or "historic" language bounty on this... so bounty goes to popularity!

@640KB I didn't know there was a bounty on this challenge! Thank you!

Haskell, 167 bytes
First it is important to notice that if there is an echo present, then the input array is a convolution of another array with some array of the form [1,1],[1,0,1],[1,0,0,1],....
This means we just have to check this for all these arrays. But discrete convolution/deconvolution is the same as polynomial multiplication/long division, so this is just an implementation using polynomials, each time returning the quotient if possible.
One trick that shortened the whole thing a little bit was in addition to the arrays above also checking for [1] as a base case, because if no other array works, the deconvolution with [1] will work and will return the original polynomial.
import Math.Polynomial
import Data.Ratio
p=poly LE
c z=last[polyCoeffs LE q|k<-zipWith const[p(take k(1:repeat 0)++[1])|k<-[0..]]z,(q,r)<-[quotRemPoly(p z)k],r==zero]

Try it online!

Good trick with the base case! I tried to incorporate that into my answer but I could shorten the code

JavaScript, 211 171 145 bytes
s=>{for(n=x=0,y=s.length;++x<y/2&!n;)for(n=s.slice(i=0,x);i+x<y-x&&n;)n=(n[i+x]=s[i+x]-n[i++])<0?0:n;return n&&n.slice(1-x)+''==s.slice(1-x)?n:s}

Try it online
40 bytes from Kevin Cruijssen
Another 26 bytes from Arnauld
My first code golf answer, invalidates potential offsets, and returns either the original or the new array dependent on what it finds.
If anyone knows how to make it shorter pls let me know, seems like a fun game.

I'm not too skilled with JavaScript, but with some basic golfs (i.e. removing unnecessary brackets, changing the placements of the ++, changing && to & in the first check, changing both .toString() to +'', etc.) I got your code down to 181 bytes. If you haven't seen them yet, Tips for golfing in JavaScript and Tips for golfing in all languages might be interesting to read through. :)

Oh, forgot one (function q(s) can be s=>): 171 bytes. Enjoy your stay! :)

Thanks for that, I'll have a read. I'm not very handy with javascript but I've had to do a little lately and thought this might be a good way to brush up a little in my downtime

Golfed some more (without all tests so that it fits as a direct URL in this comment)

Welcome to Code Golf SE! We hope you enjoy your time golfing here!

Haskell, 112 111 110 bytes
l=length
(!)=splitAt
f a=last$a:[x|i<-[1..l a],let (h,t)=i!a;o=h++zipWith(-)t o;(x,y)=l t!o,all(>=0)o,sum y<1]

Try it online!
f a=
      i<-[1..l a]                -- for all indices 'i' of the input array 'a'
      (h,t)=i!a                  -- split 'a' at 'i' into 'h' and 't'
                                 -- e.g. a: [1,2,3,4], i: 1 -> h: [1], t:[2,3,4]
      o=                         -- calculate the original array by
        h++                      --   prepended 'h' to
        zipWith(-)t o            --   the (element-wise) difference of
                                 --   't' and itself
      (x,y)=l t!o                -- split 'o' at position <length of t>
                                 --
                                 -- example:
                                 --      a: [0,1,3,2,0]
                                 --      h: [0]
                                 --      t: [1,3,2,0]
                                 --   now
                                 --      o: [0,1,2,0,0]
                                 --      x: [0,1,2,0]
                                 --      y: [0]
                                 --
    ,                            -- 'o' is valid, if
     all(>=0)o                   --   all elements of 'o' are not negative
    ,sum y<1                     --   and 'y' is all zeros
  [x|         ]                  -- keep 'x' (a valid echo array) if 'o' is valid

 last $ a :[  ]                  -- if there's no echo, the list of 'x's is empty
                                 -- and 'a' is picked, else the last of the 'x's

Wolfram Language (Mathematica), 131 129 120 119 102 98 97 96 95 bytes
(w=#;Do[(w=v/.#)&/@Thread[#==PadLeft[v=Array[x,L-d],L]+v~PadRight~L]~Solve~v,{d,L=Tr[1^#]}];w)&

Try it online!
−1 byte thanks to attinat: we can write L=Tr[1^#] instead of L=Length@# when the argument is a list of numbers.
Code explanation: Iterate through the shrinkage d (difference between input and output lengths). For each output list length, construct a list of unknowns v={x[1],x[2],...,x[L-d]} and add it to itself left-padded and right-padded to length L (PadLeft[v,L]+PadRight[v,L]), then set this sum equal to the input list and solve for the unknowns x[1]...x[L-d]. Pick the shortest solution, which is the last one generated: just keep overwriting the variable w every time a solution is found.
Un-golfed version:
F = Function[A,                                  (* A is the input list *)
  Module[{L = Length[A],                         (* length of A *)
          v,                                     (* list of unknowns *)
          x,                                     (* unknowns in v *)
          w = A},                                (* variable for solution, defaults to A *)
    Do[                                          (* loop over shrinkage: d = Length[A]-Length[output] *)
      v = Array[x, L - d];                       (* list of unknowns to be determined *)
      (w = v /. #) & /@                          (* overwrite w with every... *)
        Solve[                                   (* ...solution of... *)
          Thread[PadLeft[v,L]+PadRight[v,L]==A], (* ...v added to itself, left-padded and right-padded, equals A *)
          v],                                    (* solve for elements of v *)
    {d, L}];                                     (* loop for shrinkage from 1 to L (the last case d=L is trivial) *)
    w]];                                         (* return the last solution found *)

-1 with Tr[1^#] instead of Length@#

Python 2, 113 123 128 127 123 122 bytes
def f(a,i=1):
 e=a[:i]
 for v in a[i:-i]:e+=v-e[-i],
 return i<=len(a)/2and(min(e)>=0<e[-i:]==a[-i:]and e or f(a,i+1))or a

Try it online!
1 byte thx to TFeld; and 1 byte thx to Sebastian Kreft.
On each call to f, we construct a potential echo of length len(a)-i. The first part is just the first i bytes of a; the remainder is calculated so that the 'echoed sum' will be correct for the 'overlapped' section of the echo sum (i.e., the echo-sum is correct up to a[:-i]).
Then the very short-cutted comparison, un-golfed, gives:
if i>=len(a)/2+1:
    return a # because it can't be that short, so there is no echo
else:
    if min(e)>=0                       # all elements are non-negative
                 and e[-i:]==a[-i:]:   # and the tails are the same
        return e                       # it's a match!
    else:
        return f(a,i+1)                # recurse

e+=[v-e[-i]] can be e+=v-e[-i],

you can shave one more character by doing i<=len(a)/2

PHP, 124 bytes
function($a){while(!$z&&++$y<$c=count($b=$a))for($x=0;$x<$c&$z=0<=$b[$x+$y]-=$b[$x++];);return array_slice($b,0,$c-$y)?:$a;}

Try it online!
Explanation:
Create a copy of the input array and loop through each possible offset of the echo. For each column, subtract the value in the offset position from the corresponding value in the original position to determine the value necessary to add up to the input. If it is valid (\$\gt 0\$), replace the contents of that column with that value. Continue to the end and if no values are invalid, it is a correct answer.
function( $a ) {
  // iterate through all possible offsets of echo
  while( ! $b && ++$y < $c = count( $b = $a ) ) {
    // create a copy of input array, iterate through all elements
    for( $x = 0; $b && $x < $c; ) {
      // if difference between the elements in the offset copy of
      // the array is positive, subtract the value in the input array
      // from the offset array in the same column
      if ( ( $b[ $x+$y ] -= $b[ $x++ ] ) < 0 ) {
        // result is not valid, erase array and break out of loop
        $b = 0;
      }
    }
  }
  // truncate output array to correct size. if still contains values,
  // it is a valid result. otherwise return the original array
  return array_slice( $b, 0, $c-$y ) ?: $a;
}

Wolfram Language (Mathematica), 93 bytes
(b=#;Do[a=#;Do[a[[i+j]]-=a[[j]],{j,2k}];a/.{__?(#>=0&),0}:>(b=a~Drop~-i),{i,k=Tr[1^#]/2}];b)&

Try it online!
Returns the shortest echo present in the list.

It looks like this fails on {1,1,1} and on {1,0,1}.

@Roman isn't there no echo for either of those cases?

For {1,1,1} there is no echo, so you need to return the original array. For {1,0,1} I'd say the echo is {1} but admit it's a bit unclear what the rules are.

Ah, right. Thanks for the catch!

Jelly, 25 24 bytes
ðsạ\FḣL_¥,+¥Ż⁹¡$µⱮLṪ⁼¥Ƈȯ

Try it online!
A monadic link that takes and returns a list of integers. Technically, the successful results are nested in two further lists, but when run as a full program the implicit output to stdout ignores the redundant lists.

Python 3, 111 bytes
def f(r,l=1):o=r[:l];o+=(v-o[-l]for v in r[l:]);return l<len(r)and(min(o)<any(o[-l:])and f(r,l+1)or o[:-l])or r

Try it online!
The solution takes some ideas from @Chas Brown's solution such as the recursive structure and the construction of the output array. Meanwhile, it also makes some changes in the judging criteria as well as putting the for loop into a generator expression to allow a single-line solution. The ungolfed version is shown in the following. Here, the array out is computed all the way to the end of the input array and then we check whether the last l elements of it are all zero. If so, the first len(arr)-l elements are returned as the answer if all of them are non-negative.
Ungolfed, non-recursive version
def remove_echo(arr):
    l = 1
    while l < len(arr):
        out = arr[:l]
        out += (v - out[-l] for v in arr[l:])
        if min(out) >= 0 and out[-l:] == [0] * l:
            return out[:-l]
        l += 1
    return arr

Try it online!

@640KB I checked whether the returned answer matches the expected result in my code and prints message only if there is an unmatch. So no output means everything is correct. I admit that this can be confusing at the first glance and I'll update it later to print "Correct" on a match.

@640KB Updated.

Charcoal, 62 bytes
≔⁰ζＦ⊘Ｌθ«≔Ｅ⊕ι⁰ηＦＬθ§≔ηκ⁻§θκ§ηκ¿⬤η¬κ≔⊕ιζ»Ｆ⁻Ｌθζ⊞υ⁻§θι∧ζ∧¬‹ιζ§υ±ζＩυ

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

Assume there's no echo.
Ｆ⊘Ｌθ«

Try all possible start points of echo. Note: I may have misread the question and might not be trying enough sizes of echo, in which case the ⊘ would not be necessary.
≔Ｅ⊕ι⁰η

Start with an array of zeros the same size as the start point of the echo.
ＦＬθ§≔ηκ⁻§θκ§ηκ

For each element in the original array, subtract the element in the echo array cyclically from it. Each element in the echo array thus builds up the alternating sum of the elements that distance apart.
¿⬤η¬κ≔⊕ιζ»

If all of the alternating sums are zero then save this as a possible start point. (So if there is more than one possibility then the largest possible start point is used.)
Ｆ⁻Ｌθζ⊞υ⁻§θι∧ζ∧¬‹ιζ§υ±ζ

Build up the echoing array by subtracting elements after the start point from the appropriate previously calculated element.
Ｉυ

Cast to string for implicit output on separate lines.


text:
Find the hardest OEIS sequence to golf!
Notice: This question originally had people write comments with a shorter program, rather than new answers. This has been changed so that people with shorter programs can get reputation too. Hopefully this doesn't become unmanageable...
There have been a couple of OEIS-related questions recently, so here's another:
Pick a sequence from the Online Encyclopedia of Integer Sequences, and write a full program or function which computes the sequence in one of the following ways:

It prints every term in the sequence in order
It takes an index in the sequence as input, and returns/outputs the term at that index.

You will be trying to pick the sequence with the longest possible shortest possible program/function to compute that sequence (see the example below if that's confusing). You must include which sequence you are using in your answer.
Try to make your program/function as short as possible. If anyone can find a shorter program which computes the same sequence, they should add a another answer with their shorter program. If you do find a shorter program than someone else, you should refer to their answer in yours. For all answers, a Try it Online link would be nice. If someone else has written a shorter program than yours, it would be nice if you put a link to it in your answer.
Of course, none of the programs should access the internet or the OEIS in any way, and they should all theoretically work on arbitrarily large inputs (you can ignore things like the maximum size of an integer type).
The sequence with the longest shortest program in bytes is the winner.
For example,
Let's say I pick the sequence A000027, the positive integers, and I submit this answer:
Python, 49 bytes, A000027
x = "o"
while True:
    print len(x)
    x += "o"

Obviously this is not a very short program for computing that sequence, so someone else (let's call them foo) might come along and add this answer:
Haskell, 2 bytes, A000027:
id

(id is the identity function, so it will just return whatever you pass into it, and because the nth positive integer is just n, it will compute that sequence).
Then, the person who posted the Python solution should edit their answer:
Python, 49 bytes, A000027
Superseded by foo's answer (link).
x = "o"
while True:
    print len(x)
    x += "o"

As long as no one else finds a shorter program, this sequence would get a score of 2 (because id is two bytes), and the sequence with the highest score wins.

Current best sequence: A014715, 252 bytes

Isn't this trivially just something like A060843?

@ExpiredData A060483 would be impossible to submit as an answer, because you have to actually write a program to compute the sequence and include it in your answer.

The answer with the longest sequence is the winner. don't you mean that the answer with the longest answer in bytes is the winner?

@ExpiredData Oops, yes...

Should one update their answer with the current shortest program?

@TFeld You can if you want, but you don't have to.

Honestly, the more I think about this question, the more it becomes obvious that the optimal strategy is finding challenges that are based on OEIS sequences and copying the shortest answer.

@TFeld The answer/sequence is scored by the longest solution, including all comments.

That's how I understood it as well, (which might encourage updating the answer), but it seems that others think that comments invalidate your answer.

This looks like a [tag:cops-and-robbers] done wrong because there's no incentive for the robbers. It might be worth taking it to the sandbox and enlisting mod help to lock it until it can be reworked.

@PeterTaylor I hadn't realized that comment upvotes don't give you reputation. I don't think that having the "robbers" post answers instead of comments would really work, because it would be hard to keep track of which person has the shortest solution for each question. Clearly this format is problematic, but I'm not sure if this question can be reworked.

@Stephen Maybe, but so far that doesn't seem to be the case.

Then again, maybe I'll just switch it to answers instead of comments.

Wolfram Language (Mathematica), 270 252 bytes A014715
252 bytes, by Expired Data
RealDigits[NSolve[3x-6==Plus@@({6,-12,4,-7,7,-1,0,-5,2,4,12,-2,-7,-12,7,10,4,-3,-9,7,0,8,-14,3,-9,-2,3,10,2,6,-1,-10,3,-1,-7,7,-7,12,5,-8,-6,-10,8,8,7,3,-9,-1,-6,-6,2,3,10,2,-3,-5,-2,1,1,1,1,1,-1,-2,-2,1,2,1,0,-1}x^2~Range~71),x,#][[-1,-1,-1]]][[1,#]]&

Try it online!
I've never golfed in mathematica before, but the sequence seemed like an obvious contender. The code is more or less a copy of the example on the OEIS page.
The sequence is the decimal expansion of Conway's constant, which itself is the root of this polynomial:
\$x^{71}-x^{69}-2x^{68}-x^{67}+2x^{66}+2x^{65}+x^{64}-x^{63}-x^{62}-x^{61}-x^{60}-x^{59}+2x^{58}+5x^{57}+3x^{56}-2x^{55}-10x^{54}-3x^{53}-2x^{52}+6x^{51}+6x^{50}+x^{49}+9x^{48}-3x^{47}-7x^{46}-8x^{45}-8x^{44}+10x^{43}+6x^{42}+8x^{41}-5x^{40}-12x^{39}+7x^{38}-7x^{37}+7x^{36}+x^{35}-3x^{34}+10x^{33}+x^{32}-6x^{31}-2x^{30}-10x^{29}-3x^{28}+2x^{27}+9x^{26}-3x^{25}+14x^{24}-8x^{23}-7x^{21}+9x^{20}+3x^{19}-4x^{18}-10x^{17}-7x^{16}+12x^{15}+7x^{14}+2x^{13}-12x^{12}-4x^{11}-2x^{10}+5x^{9}+x^{7}-7x^{6}+7x^{5}-4x^{4}+12x^{3}-6x^{2}+3x-6\$

Probably important to mention that the code is copied straight from the OEIS page for the sequence

261 bytes

And a few bytes more by jiggling the equation around

@Stephen Well, I did reverse the polynomial to save a few bytes :P

@ExpiredData I've edited it into the answer.

OEIS also lists a shorter solution in PARI/GP: P=Pol([1,0,-1,-2,-1,2,2,1,-1,-1,-1,-1,-1,2,5,3,-2,-10,-3,-2,6,6,1,9,-3,-7,-8,-8,10,6,8,-5,-12,7,-7,7,1,-3,10,1,-6,-2,-10,-3,2,9,-3,14,-8,0,-7,9,3,-4,-10,-7,12,7,2,-12,-4,-2,5,0,1,-7,7,-4,12,-6,3,-6]);polrootsreal(P)[3] – 219 bytes.

@AndriyMakukha I don't know any PARI, but feel free to turn that code into a function, and I'll edit the answer

Python 3, 3 bytes, A055642
Finally, a ridiculously short answer that isn't just A000027 or some other stupidly simple sequence.
len

This is a function. Number should be inputted as a string of its digits. Undefined behavior for non-integers and other strings.

cQuents, 1 byte, A000027
$

Try it online!
Just to have a baseline answer in case every other answer is cracked.

Jelly, 0 bytes: Try it online! (sorry). Arguments are added to the stack in Jelly, and the top thing on the stack is printed when the program finishes, so the program takes an index as input, and outputs the corresponding term (which is just the same number).

@LeoTenenbaum ah, I remembered having the shortest answer to this and forgot that you had two different input styles

The 0 bytes version also works in GolfScript. Try it online!

Wolfram Language (Mathematica), 490,453 bytes A002205
FromDigits[ToCharacterCode[StringReplace["$H\.06,\.1dVngsIno\.12RT",":3:"->FromCharacterCode[13]]]-1,127]

Where \.FF is a single byte of that value.
Try it online! - Limited to 2000 digits, I don't think the dev would appriciate ~1.5M of data coming through.
I took a while to search though the OEIS 'webcam', but I paused and looked at XKCD, where it mentioned the book "A Million Random Digits with 100,000 Normal Deviates". And what do you know, it's A002205. A pretty old entry too.
According to dieharder, a program for finding if a sequence of numbers is random, the sequence is pretty random, so I doubt there's going to be an algorithm to generate a given number. This makes it more of a Kolmogorov-complexity problem. Since every number is between 0 and 9 inclusive, then there are Log2[10] bits of information in a digit, or 1,000,000 * Log2[10]/Log2[256] bytes of information total, or just a tad under 415,242 bytes.
My final solution was to take the entire 1,000,000 digit number in as a number (big-int in other languages), convert it to base 127, and then put it in the range 1-127. 1,000,000 * Log2[10]/Log2[127] = 475,330 bytes. Character 13 is the Carriage Return, which is converted to a Line Feed on most systems, so it's replaced with the trigraph :3:, since all the digraphs are taken. Mathematica was surprisingly happy to convert a 1 million digit number to base 127. The answer can be optimized, since TIO allows the entire 127+ unicode space, but using this method the results would only reduce the score by 1%.
Here is the encoder I used, where str is a string containing all the digits:
StringReplace[FromCharacterCode[IntegerDigits[FromDigits[str],127]+1],{"\\"->"\\\\","\""->"\\\"",FromCharacterCode[13]->":3:"}]

BZIP2 can compress the data down to 431,122 bytes, which is pretty close, but I felt just BZipping the data and calling it an answer was a bit cheap since it's not a 'language', as much as those answers have been fun on other questions.

source: Stack Exchange

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

sort: votes


text:
Find X,Y,Z coordinates from index
Introduction
I began studying the Collatz Conjecture
And noticed these patterns;
0,1,2,2,3,3...A055086, and  0,1,2,0,3,1...A082375,
in the numbers that go to 1 in one odd step,
5,10,20,21,40,42...A062052
Related like so;
A062052()(n) = ( 16*2^A055086(n) - 2^A082375(n) ) /3
The formula for A055086 is $$\lfloor\sqrt{4n + 1}\rfloor - 1$$
and the formula for A082375 is $${\left\lfloor\sqrt{4\left\lfloor x\right\rfloor+1}\right\rfloor - 1 - \left\lfloor \frac12 \left(4\left\lfloor x\right\rfloor + 1 -\left\lfloor\sqrt{4\left\lfloor x\right\rfloor+1}\right\rfloor^2\right)\right\rfloor}$$
So the formula for A062052 most likely is
$$\frac{8\cdot2^{\left\lfloor\sqrt{4\left\lfloor x\right\rfloor+1}\right\rfloor} - 2^{\left\lfloor\sqrt{4\left\lfloor x\right\rfloor+1}\right\rfloor - 1 - \left\lfloor \frac12 \left(4\left\lfloor x\right\rfloor + 1 -\left\lfloor\sqrt{4\left\lfloor x\right\rfloor+1}\right\rfloor^2\right)\right\rfloor}}{3}$$
Then I looked at numbers going to 1 in two steps, like 3,6,12,13,24,26...
Where I found another pattern that I could not find a formula for on OEIS
long nth(int n){if(n>241)return -1;return (((1<<Y[n]+5)-(1<<1+Y[n]-((Z[n]&1)+Z[n]*3)))/3-(1<<Y[n]-2*X[n]-(2*(Z[n]&1)+Z[n]*3)))/3;}

With X[],Y[] and Z[] being these lookup-tables
 int[]X=new int[]{
 0,
 0,
 0,  1,
 0,  1,
 0,  1,  2,
 0,  1,  2,                              0,
 0,  1,  2,  3,                          0,                          0,
 0,  1,  2,  3,                          0,  1,                      0,
 0,  1,  2,  3,  4,                      0,  1,                      0,  1,
 0,  1,  2,  3,  4,                      0,  1,  2,                  0,  1,
 0,  1,  2,  3,  4,  5,                  0,  1,  2,                  0,  1,  2,
 0,  1,  2,  3,  4,  5,                  0,  1,  2,  3,              0,  1,  2,                  0,
 0,  1,  2,  3,  4,  5,  6,              0,  1,  2,  3,              0,  1,  2,  3,              0,              0,
 0,  1,  2,  3,  4,  5,  6,              0,  1,  2,  3,  4,          0,  1,  2,  3,              0,  1,          0,
 0,  1,  2,  3,  4,  5,  6,  7,          0,  1,  2,  3,  4,          0,  1,  2,  3,  4,          0,  1,          0,  1,
 0,  1,  2,  3,  4,  5,  6,  7,          0,  1,  2,  3,  4,  5,      0,  1,  2,  3,  4,          0,  1,  2,      0,  1,
 0,  1,  2,  3,  4,  5,  6,  7,  8,      0,  1,  2,  3,  4,  5,      0,  1,  2,  3,  4,  5,      0,  1,  2,      0,  1,  2,
 0,  1,  2,  3,  4,  5,  6,  7,  8,      0,  1,  2,  3,  4,  5,  6,  0,  1,  2,  3,  4,  5,      0,  1,  2,  3,  0,  1,  2,      0,
 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  0,  1,  2,  3,  4,  5,  6,  0,  1,  2,  3,  4,  5,  6,  0,  1,  2,  3,  0,  1,  2,  3,  1, 2
 };
 int[]Y=new int[]{
 0,
 1,
 2,  2,
 3,  3,
 4,  4,  4,
 5,  5,  5,                              5,
 6,  6,  6,  6,                          6,                          6,
 7,  7,  7,  7,                          7,  7,                      7,
 8,  8,  8,  8,  8,                      8,  8,                      8,  8,
 9,  9,  9,  9,  9,                      9,  9,  9,                  9,  9,
10, 10, 10, 10, 10, 10,                 10, 10, 10,                 10, 10, 10,
11, 11, 11, 11, 11, 11,                 11, 11, 11, 11,             11, 11, 11,                 11,
12, 12, 12, 12, 12, 12, 12,             12, 12, 12, 12,             12, 12, 12, 12,             12,             12,
13, 13, 13, 13, 13, 13, 13,             13, 13, 13, 13, 13,         13, 13, 13, 13,             13, 13,         13,
14, 14, 14, 14, 14, 14, 14, 14,         14, 14, 14, 14, 14,         14, 14, 14, 14, 14,         14, 14,         14, 14,
15, 15, 15, 15, 15, 15, 15, 15,         15, 15, 15, 15, 15, 15,     15, 15, 15, 15, 15,         15, 15, 15,     15, 15,
16, 16, 16, 16, 16, 16, 16, 16, 16,     16, 16, 16, 16, 16, 16,     16, 16, 16, 16, 16, 16,     16, 16, 16,     16, 16, 16,
17, 17, 17, 17, 17, 17, 17, 17, 17,     17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,     17, 17, 17, 17, 17, 17, 17,     17,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
};
int[]Z=new int[]{
0,
0,
0,  0,
0,  0,
0,  0,  0,
0,  0,  0,                              1,
0,  0,  0,  0,                          1,                          2,
0,  0,  0,  0,                          1,  1,                      2,
0,  0,  0,  0,  0,                      1,  1,                      2,  2,
0,  0,  0,  0,  0,                      1,  1,  1,                  2,  2,
0,  0,  0,  0,  0,  0,                  1,  1,  1,                  2,  2,  2,
0,  0,  0,  0,  0,  0,                  1,  1,  1,  1,              2,  2,  2,                  3,
0,  0,  0,  0,  0,  0,  0,              1,  1,  1,  1,              2,  2,  2,  2,              3,              4,
0,  0,  0,  0,  0,  0,  0,              1,  1,  1,  1,  1,          2,  2,  2,  2,              3,  3,          4,
0,  0,  0,  0,  0,  0,  0,  0,          1,  1,  1,  1,  1,          2,  2,  2,  2,  2,          3,  3,          4,  4,
0,  0,  0,  0,  0,  0,  0,  0,          1,  1,  1,  1,  1,  1,      2,  2,  2,  2,  2,          3,  3,  3,      4,  4,
0,  0,  0,  0,  0,  0,  0,  0,  0,      1,  1,  1,  1,  1,  1,      2,  2,  2,  2,  2,  2,      3,  3,  3,      4,  4,  4,
0,  0,  0,  0,  0,  0,  0,  0,  0,      1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,      3,  3,  3,  3,  4,  4,  4,      5,
0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  3,  3,  3,  3,  4,  4,  4,  4,  5, 5
};

Challenge
The challenge is to write a "reasonably fast" function or expression that replaces, and extends these lookup tables to index 719 or more.
Think of the lookup tables as a 3D structure of boxes.
Pictured is the top 720 boxes of this structure.

Input
An integer which is the index of a cube in the structure.
You can assume the input will be in the range 0 to 719 inclusive.
Output
The x,y,z coordinates for the given index.
Assuming the input is between 0 and 719 the output ranges are
    x, 0 to 13
    y, 0 to 27
    z, 0 to 8
It's fine to accept and return larger indexes correctly just not required.
Examples
    i  ->   x   y   z
    0  ->   0,  0,  0
   12  ->   0,  5,  1
   30  ->   4,  8,  0
   65  ->   2, 11,  1
  100  ->   0, 13,  2
  270  ->   1, 19,  3
  321  ->   1, 20,  6
  719  ->   1, 27,  8

If you collapse the z-coordinate, then the structure is indexed top-down left right like shown below; Examples are marked in square brackets []
Y,Z 0,
 0   | [0]
 1   |  1
 2   |  2   3
 3   |  4   5
 4   |  6   7   8                                1,
 5   |  9  10  11                                 |[12]                           2,
 6   | 13  14  15  16                             | 17                             | 18
 7   | 19  20  21  22                             | 23  24                         | 25
 8   | 26  27  28  29 [30]                        | 31  32                         | 33  34
 9   | 35  36  37  38  39                         | 40  41  42                     | 43  44
10   | 45  46  47  48  49  50                     | 51  52  53                     | 54  55  56                    3,
11   | 57  58  59  60  61  62                     | 63  64 [65] 66                 | 67  68  69                     | 70                4,
12   | 71  72  73  74  75  76  77                 | 78  79  80  81                 | 82  83  84  85                 | 86                 | 87
13   | 88  89  90  91  92  93  94                 | 95  96  97  98  99             [100] 101 102 103                |104 105             |106
14   |107 108 109 110 111 112 113 114             |115 116 117 118 119             |120 121 122 123 124             |125 126             |127 128
15   |129 130 131 132 133 134 135 136             |137 138 139 140 141 142         |143 144 145 146 147             |148 149 150         |151 152
16   |153 154 155 156 157 158 159 160 161         |162 163 164 165 166 167         |168 169 170 171 172 173         |174 175 176         |177 178 179        5,
17   |180 181 182 183 184 185 186 187 188         |189 190 191 192 193 194 195     |196 197 198 199 200 201         |202 203 204 205     |206 207 208         |209    6,
18   |210 211 212 213 214 215 216 217 218 219     |220 221 222 223 224 225 226     |227 228 229 230 231 232 233     |234 235 236 237     |238 239 240 241     |242     |243
19   |244 245 246 247 248 249 250 251 252 253     |254 255 256 257 258 259 260 261 |262 263 264 265 266 267 268     |269[270]271 272 273 |274 275 276 277     |278 279 |280
20   |281 282 283 284 285 286 287 288 289 290 291 |292 293 294 295 296 297 298 299 |300 301 302 303 304 305 306 307 |308 309 310 311 312 |313 314 315 316 317 |318 319 |320[321]
  X->|  0   1   2   3   4   5   6   7   8   9  10 |  0   1   2   3   4   5   6   7 |  0   1   2   3   4   5   6   7 |  0   1   2   3   4 |  0   1   2   3   4 |  0   1 |  0   1

Note that at even y-coordinates the structure expands in the x-direction,
and at 0 and 5 mod 6 in the z-direction.
Rules
This is code-golf, the shortest code in bytes wins.
Reasonably fast
As an additional requirement although not a competition of fastest code,
the code must still be shown to compute coordinates in a reasonable amount of time.
\$\ O(n)\$ or less time-complexity with regards to index is valid by default
Alternatively may for example use try it online or similar website and run a loop through all coordinates under 720 without exceeding the time limit of a minute, printing is optional.
Any time-complexity is valid as long as actual time is reasonably low.
Lookup tables are allowed but included in byte-count so aim to make them sparse if you choose to use them.
Example code
EDIT: Look at Nick Kennedy's solution
Original example;
coord coords(int index){
int a=0,b=0,c=0;
int x=0,y=0,z=0;
long n,k,one;
n = k = 3;
int t=0;
while(t<index){
int s=0;k++;n=k;
while(n>1 && s<4){ n/=n&-n;n=n*3+1; n/=n&-n;s++;}
if(s==2)t++;
}
n=k;
one=n&-n;k = one;while(k>1){k>>=1;c++;} n=3*n+one;
one=n&-n;k = one;while(k>1){k>>=1;b++;} n=3*n+one;
one=n&-n;k = one;while(k>1){k>>=1;a++;}
coord r;
r.x = (b-c-1)>>1;
r.y = a-5;
r.z = (a-b-2)/6 +(a-b-4)/6;
return r;
}

Try it online! Note it's too slow!

"storing information as you go" is forbidden. For example executing f(100) should not depend on having computed f(99) previously. I don't understand why you add this requirement on top of code-golf and restricted-time. It's also an unobservable requirement which is something that should be avoided in challenge writing. (Otherwise it's a good challenge I think)

To @JonathanAllan's point, if I'm reading that restriction correctly, you're essentially banning recursive functions, are you not?

@ Jonathan Allan and @Shaggy  , what I had in mind was something like this , but I'm open to dropping the rule if it's a problem

Are you sure you want this to be a shortest code in bytes challenge? This feels more like an efficiency challenge. Maybe a version of both? In my typical language of choice, this is going to take up some bytes.... But I think I could whip something together moderately efficient in C++.

didn't understand the link with A055086, but found : A062052, A062053 ... A062060

@NahuelFouilleul  You can use the A022332 and A055086 sequences to get the A062052 sequence
like so ... (16*2^2^A022332(n) - 2^A055086(n) )/3 = A062052(n)  ,  Similarly you can get the A062053 sequence from the X,Y,Z sequences in this challenge.

@ouflak Bytes is a simpler measure than efficiency. Also it naturally deters lookup-table based solutions.

@NahuelFouilleul might have messed that up but here is an example

I've tidied up the MathJax expressions by applying simple transformation rules, but I haven't a clue what the second one is supposed to show (what's $x$? In what way does this "plot these numbers in their natural order"?), and I can't make any sense out of the rest of the question.

@PrincePolka, thank you for the explanations, wouldn't be easier to generate first sequence from (m>=1,n>=0) (2^(2*m)-1)/3*2^n, and the second sequence from the first (2^(2*m)*S-1)/3*2^n where S is an element of first sequence (or element*2) so that (2^(2*m)*S-1) is a multiple of 3

@ Peter Taylor thanks for the help, by natural I mean t ascending. x is n just i used desmos to plot it and it doesn't accept n, also thats the reason behind floor()  ,  @NahuelFouilleul thanks for the idea, I'll look into it

@NahuelFouilleul I got A198584 which doesn't include the evens figured out.   Maybe with some modification this can generate A062053?https://pastebin.com/RqjDqk6k

Jelly, 31 bytes
5,1ṁ9ĖŒṙṚḊḊḊ$Ƭz0ZUṬ€€ỊŒṪ’ṙÞ1ị@‘

A monadic link accepting an integer in \$[0,719]\$ which yields a list of three integers \$[X, Y, Z]\$.
Try it online!
Or see the test-suite (which completes in around 12-20s on TIO)
How?
Builds a lookup table and indexes into it:
5,1ṁ9ĖŒṙṚḊḊḊ$Ƭz0ZUṬ€€ỊŒṪ’ṙÞ1ị@‘ - Link: integer, n
5,1                             - pair literal = [5,1]
   ṁ9                           - mould like 9 = [5,1,5,1,5,1,5,1,5]
     Ė                          - enumerate = [[1,5],[2,1],[3,5],[4,1],[5,5],[6,1],[7,5],[8,1],[9,5]]
      Œṙ                        - run-length-decode = [1,1,1,1,1,2,3,...,7,7,7,7,7,8,9,9,9,9,9]
        Ṛ                       - reverse = [9,9,9,9,9,8,7,7,7,7,7,...,3,2,1,1,1,1,1]
         Ḋ                      - dequeue = [9,9,9,9,8,7,7,7,7,7,...,3,2,1,1,1,1,1]
             Ƭ                  - collect until a fixed-point:
            $                   -   last two links as a monad:
          Ḋ                     -     dequeue
           Ḋ                    -     dequeue
                                - } = [[9,9,9,9,8,7,7,7,7,7,...,3,2,1,1,1,1,1],[9,9,8,7,...],[8,7,...],...,[1,1],[]]
              z0                - transpose with filler zero
                Z               - transpose
                 U              - reverse each list
                  Ṭ€€           - un-truth each int (e.g. 5 -> [0,0,0,0,1])
                     Ị          - insignificant? (abs(x)<=1) (e.g. [0,0,0,0,1]->[1,1,1,1,1])
                      ŒṪ        - truthy multi-dimensional 1-indexed indices
                        ’       - decrement (i.e. all the [X,Y,Z] values)
                          Þ     - sort by:
                         ṙ 1    -   the list value rotated left by one (i.e. by [Y,Z,X])
                              ‘ - increment (n) (since Jelly is 1-indexed)
                             @  - with swapped arguments:
                            ị   -   index into

@PrincePolka Note that it's quite common for askers on this stack to wait a good amount of time (a week or two) before accepting an answer.

Nice. If you don’t mind me asking, how did you end up with this approach?

@NickKennedy I saw the nice images of the 3d box structure and it just felt like it would probably be a good approach to "build that". I initially was trying to mould a range of the input numbers into the correct shape in order to find the first equal multidimensional index, but moved to building just the blocks. I do feel like there may be a way to build in a different orientation and avoid the sort and/or some of the z0ZU...

Python 3, 150 140 bytes
def f(n):
 a=b=x=y=z=0
 for i in range(n):
  a=x-~x<y--~z//2*6+z%2
  b=z<y//6+-~y//6
  x=-~x*a
  y+=not(a|b)
  z+=b>a
  z*=a|b
 return x,y,z

Try it online!
Has \$O(n)\$ complexity. TIO footer prints first 720 values in about 0.5 seconds.
Thanks to @ElPedro and @PrincePolka for each saving 5 bytes!

I'm not familiar with Python; what is the else:z,y=0,y+1 line doing?

@Shaggy if the condition from the previous line is not met, then z is set to zero and y is incremented by 1. Python allows tuple unpacking during assignment statements.

Since you apparently understand what the question is asking for, could you edit it to make it more intelligible for everyone else?

else:z=0;y+=1 does the same and is actually 1 byte shorter :)

And you can movex+=1 to the same line as if x<... to save another 4 bytes.

Ah, I see now; it was the equivalent of [z,y]=[0,y+1] in JS.

140 bytes

JavaScript, 93 85 bytes
A port of Nick's Python solution.
n=>(g=x=>n--?g(x<y+~z/2n*6n+z%2n>>1n?++x:z<y/6n-~y/6n?++z-z:z=++y-y):[x,y,z])(y=z=0n)

Try It Online!
Saved 8 bytes thank to Arnauld's suggestion of using BigInts, plus a couple of other tweaks.

Jelly, 54 41 bytes
HĊ×6_Ḃ{ạHḞ;;‘$:6SƊ}
<Ḋç/$T;3ḢṬ
0x3Ç+×¥$⁸¡

Try it online!
Loosely a Jelly translation of my Python 3 answer but much slower. Still \$O(n)\$ though. Outputs [x, z, y].

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


text:
How long's left?
How long's left?
Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the question. You see, if the timer at the current moment was at 3:47, by the time I had read out 'Three minutes and forty seven seconds' aloud, the time would have changed. Therefore, I need to find a time that the timer would reach just as I finish reading it out.
This is your challenge: to automate this process. Given a time in any appropriate format (":" delimited, or as a minute and second argument), output the earliest time from that current moment which would take an equal amount of time to read out as it would take for the timer to get to. We're assuming that each syllable takes 1 second to read out.
Further rules

You must count 'minutes' and 'seconds' as two of the syllables each, as well as an 'and' between them.
The pizza will never take more than 59:59 to cook.
'11 minutes and 0 seconds' is not 10 syllables: you must simplify to '11 minutes' (i.e 5 syllables). Same goes with minutes: '0 minutes and 7 seconds' is also only counted as 4 syllables.
Your program can give the output in any format: an array of [minutes, seconds], or even as <minutes> minutes and <seconds> seconds (normal text written out).
Standard loopholes apply.
This is code-golf, so shortest answer in bytes wins.

Test cases
All inputs as (minutes, seconds)
(4, 47) = (4, 38) (Four MiNutes And ThirTy Eight SeConds - 9 syllables/seconds)
(1, 1) = (0, 56) (FifTy-Six SeConds - 5 syllables/seconds)
(59, 57) = (59, 46) (FifTy Nine Minutes And Forty Six SeConds - 11 syllables/seconds)
(0, 10) = null/error/0 (no positive answer)

Syllable count reference
For reference, here are the number of syllables in each number up to 59.
0,0 (does not need to be counted)
1,1
2,1
3,1
4,1
5,1
6,1
7,2
8,1
9,1
10,1
11,3
12,1
13,2
14,2
15,2
16,2
17,3
18,2
19,2
20,2
21,3
22,3
23,3
24,3
25,3
26,3
27,4
28,3
29,3
30,2
31,3
32,3
33,3
34,3
35,3
36,3
37,4
38,3
39,3
40,2
41,3
42,3
43,3
44,3
45,3
46,3
47,4
48,3
49,3
50,2
51,3
52,3
53,3
54,3
55,3
56,3
57,4
58,3
59,3

For your first test case, would 4:37 also be a valid output, since that would take 10 syllable's to say?

@Quinn, the spec states that we should output the earliest time.

@Shaggy whoops, so it does thanks - by the time I sort my answer out I think my pizza will be burnt

Are we allowed to assume the input can be padded, i.e. 4 minutes and 43 seconds could be inputted as "04:43"?

@Vedvart1 OK, that's fine

Can I return a Datetime object with the two numbers in the minutes and seconds property?

@JoKing fixed now.

@EmbodimentofIgnorance of course - like I said, you can output in any (appropriate) format.

Is 0:00 a valid input?

@DaniilTutubalin Yes, but there are no possible outputs.

JavaScript (ES6),  112 106  105 bytes
A shorter version based on a suggestion by @EmbodimentofIgnorance
6 more bytes saved by @DaniilTutubalin
Takes input as (minutes)(seconds). Returns [minutes, seconds] or \$0\$ if there's no solution.
m=>d=F=s=>m|s?(g=n=>n&&(n%10!=7)-7+(n-11?n<13?2:n<21|n%10<1:0))(m)+g(s)^~d?F(s?s-1:m--&&59,d=-~d):[m,s]:0

Try it online!

JavaScript (ES6),  126  119 bytes
Takes input as (minutes)(seconds). Returns [minutes, seconds] or \$0\$ if there's no solution.
m=>d=F=s=>m|s?(g=n=>n&&2+(30774612>>2*n%(n>12?20:26)&3)+(n>12)+(n>19))(m)+g(s)+!!(m*s)^d?F(s?s-1:m--&&59,d=-~d):[m,s]:0

Try it online!
Commented
m =>                  // m = minutes
d =                   // d = delta in seconds between the initial time and the current time,
                      //     initialized to a non-numeric value (zero-ish)
F = s =>              // F is a recursive function taking s = seconds
  m | s ? (           // if either m or s is not 0:
    g = n =>          //   g is a helper function taking an integer n in [0..59]
      n &&            //     return 0 if n = 0
      2 + (           //     otherwise, start with 2 for either 'mi-nutes' or 'se-conds'
        30774612 >>   //     add the base number of syllables (0 to 3) corresponding to n
        2 * n %       //     using a bitmask of 13 entries x 2-bit:
                      //       12 11 10  9  8  7  6  5  4  3  2  1  0
                      //       01 11 01 01 01 10 01 01 01 01 01 01 00
        (n > 12 ? 20  //     using n MOD 10 if n is greater than 12
                : 26) //     or just n otherwise
        & 3           //     isolate the two least significant bits
      ) +             //
      (n > 12) +      //     add 1 syllable for '-teen' or '-ty' if n is greater than 12
      (n > 19)        //     add 1 more syllable for 'x-ty' if n is greater than 19
  )(m) +              //   invoke g for the minutes
  g(s) +              //   invoke g for the seconds
  !!(m * s)           //   add 1 syllable for 'and' if both m and s are non-zero
  ^ d ?               //   if the result is not equal to the delta:
    F(                //     otherwise, do a recursive call:
      s ? s - 1       //       decrement s if it's not 0,
        : m-- && 59,  //       or decrement m and restart with s = 59
      d = -~d         //       increment the delta
    )                 //     end of recursive call
  :                   //   else:
    [m, s]            //     success: return [m, s]
:                     // else:
  0                   //   failure: return 0

Could you please add an explanation?

@GezaKerecsenyi Done. :-)

Thanks. It was mostly the 30774612>>2*n%(n>12?20:26)&3 part I was confused about.

g=x=>x&&(x%10==7)+(x==11?6:x<13?4:x<21|x%10<1?5:6) might work (untested since Internet is down and using my phone)

@EmbodimentofIgnorance Thanks. It was off by 1, but nicely done without testing anyway. ;)

Bad news: for f(0)(0) it outputs [0, 0]. It should output 0.

@DaniilTutubalin Thanks for reporting this. Fixed.

Now I can safely propose improvement to 106 bytes: m=>d=F=s=>m|s?(g=n=>n&&(n%10==7)+6-(n-11?n<13?2:n<21|n%10<1:0))(m)+g(s)-1^d?F(s?s-1:m--&&59,d=-~d):[m,s]:0
I removed +!!(m*s). Instead I replaced 5 with 6 inside g() lambda. So we kinda count and both for minutes and seconds. If one of them is zero, then g(0) is zero as well, so and is not counted. Otherwise it is counted. But we get one extra and in this case, so I added -1 in the end of expression.

@DaniilTutubalin Cool. I saved another byte from there by having g() returning the opposite result and XOR'ing with ~d.

Nice trick! I felt that this -1 may be shaved, but didn't know how.

If somehow you make d=1 in the beginning instead of zero-ish, you may remove ~ and replace d=-~d with d++. But I am not sure how to do it without extra brackets.
(d=-1 should also work).

Python 3, 287 285 bytes
m=int(input())
s=int(input())
y=lambda w:3+(w[-1]=='7')-(w[-1]=='0')-(w[0]in'01')*(1+(w[0]=='0'))+(w=='11')-(w=='12')
z=lambda m,s:(2+y(f'{m:02d}'))*(m!=0)+(2+y(f'{s:02d}'))*(s!=0)+(m!=0!=s)
q=lambda t: (m-(t+60-s-1)//60,(s-t)%60)
print([q(t) for t in range(s+60*m) if z(*q(t))==t][0])

Try it online!
It's not a very clever solution - it's mostly striaghtforward. Takes 'm:s' m and s as separate inputs (doesn't need to be padded), and outputs (m,s). Throws an error if there's no valid output.
The program relies heavily on implicitly casting booleans to 0 and 1. The first line takes input. The second line defines a lambda function y which gives the syllables in a number - it assumes a base of 3 syllables, then adds 1 if it ends in 7, subtracts 1 if it ends in 0, and subtracts 1 if it's in the 10's and 2 if it's in the single digits. Twelve and eleven are manually adjusted at the end. The third line is a lambda for the syllables in the whole expression. Finally, fourth line gives the time after t seconds. Fifth line is the output - it builds an array of all the times that satisfy the problem, and outputs the first one.
EDIT 1: Thanks to Matthew Anderson in the comments, 2 bytes were shaved off by taking the inputs separately.

If you take input on two separate lines: m=int(input()) s=int(input()), you can save 2 bytes.

C# (Visual C# Interactive Compiler), 141 bytes
a=>b=>((a=Enumerable.Range(1,b+=a*60).Last(i=>new[]{i/60,i%60}.Sum(x=>x<1?0:(x%10==7?4:3)+(x==11?3:x<13?1:x<21|x%10<1?2:3))-1==b-i))/60,a%60)

Try it online!

Jelly, 46 bytes
ḅḶbɗ60Ṛµ“÷ṢḣxE⁻Ṇ⁹ƬƝwɼỤṡl’ḃ4+2;0⁸ịS+ṬS$’)=JTị⁸Ḣ

Try it online!
A monadic link taking as its argument the time as [minutes, seconds] and returning the appropriate time to say as [minutes, seconds] or [seconds] if less than a minute.

CJam, 102 bytes
60:X;q~\X*+:W_{;(__X%\X/{_196656821516111872\_A%K+e<_{(2*m>3&3.5+}{\;}?@}2*+i+\X*+_W=!2$0<-}g;_X%\X/S@

Try it online!
Just a boring old magic-number binary look-up-table, nothing to see here.


text:
Too many spies!
You are fighting an extensive network of enemy spies. You know that each spy has at least one (sometimes multiple) fake identities they like to use. You'd really like to know how many spies you're actually dealing with.
Luckily, your counter-intelligence agents are doing their job and can sometimes figure out when two fake identities are actually controlled by the same enemy spy.
That is to say:

Your agents don't always know when two fake identies have the same spy behind them, however
If an agent tells you two fake identities are controlled by the same spy, you trust they are right.

Agent messages
Agents send you cryptic messages telling you which identities have the same spy behind them. An example:
You have 2 agents and 5 fake identities to deal with.
The first agent sends you a message:
Red Red Blue Orange Orange

This means they think there are 3 spies:

the first one (Red) controls identities 1 and 2
the second one (Blue) controls identity 3
the third one (Orange) controls identities 4 and 5

The second agent sends you a message:
cat dog dog bird fly

This means they think there are 4 spies:

the first one (cat) controls identity 1
the second one (dog) controls identities 2 and 3
the third one (bird) controls identity 4
the fourth one (fly) controls identity 5

Compiling the intel we see:
Identities:   id1    id2    id3    id4    id5
Agent 1:    |--same-spy--|       |--same-spy--|
Agent 2:           |--same-spy--|
Conclusion: |-----same-spy------||--same-spy--|

This means there are at most 2 spies.
Notes
Identities owned by the same spy do not have to be consecutive, i.e. a message like:
dog cat dog

is valid.
Also, the same word might be used by two different agents - that does not mean anything, it's just a coincidence, e.g.:
Agent 1: Steam Water Ice
Agent 2: Ice Ice Baby

Ice is used by both agents - the Ice used by the first agent is unrelated to the two occurences of Ice used by the second agent.
Challenge
Compile all your agents' intel and figure out how many enemy spies there really are. (To be more precise, get the lowest upper bound, given the limited information you have.)
The shortest code in bytes wins.
Input and Output spec
The input is a list of n lines, which represent n messages from agents.
Each line consists of k space-separated tokens, same k for all lines. Tokens are alphanumeric, arbitrary length. Case matters.
The output should be a single number, representing the number of distinct spies, based on your agents' intel.
Examples
Example 1
Input:
Angel Devil Angel Joker Thief Thief
Ra Ra Ras Pu Ti N
say sea c c see cee

Output:
2

Example 2
Input:
Blossom Bubbles Buttercup
Ed Edd Eddy

Output:
3

Example 3
Input:
Botswana Botswana Botswana
Left Middle Right

Output:
1

Example 4
Input:
Black White
White Black

Output:
2

Example 5
Input:
Foo Bar Foo
Foo Bar Bar

Output:
1

Example 6
Input:
A B C D
A A C D
A B C C
A B B D

Output:
1

Example 7
Input:
A B A C

Output:
3

Example 8
Input:
A
B
C

Output:
1

Example 9
Input:
X

Output:
1

May we take each line as an array of words?

@Arnauld I'm afraid not - you can take the input as a list of lines, but each line is a string of characters.

@HenryHenrinson The only thing making the input strict does is add a short blurb at the start of the code to change the input format. It doesn't really add anything to the challenge itself

Sounds to me like that will give more opportunities to golf the code :)

Strict I/O formats are really discouraged since they detract from the core of the challenge. For example, enforcing that the input is in form of lines of space-separated words isn't necessary, since one can also represent each line as a list of words (what Arnauld said), and the only thing this rule adds to the challenge is the necessity to split the lines, something that's not necessarily a part of the challenge.

This title sounds like your average Team Fortress 2 game!

Sledgehammer 0.5.1, 16 15 bytes
⡡⠥⡀⡾⠥⢢⠍⣽⡷⣩⣅⡷⣡⢒⠅

Decompresses into this Wolfram Language function (the final & is implicit):
Length[ConnectedComponents[RelationGraph[Inner[Equal, ##1, Or] &,
    Transpose[StringSplit @ #1]]]] &

Try it online!
Transpose[StringSplit @ #1]: Split each string in the input list, and take the columns (spy identities)
RelationGraph[Inner[Equal, ##1, Or] &, ...]: Construct the graph where two vertices share an edge if at least one position is equal (if they are classified as the same spy by some friendly agent)
Length[ConnectedComponents[...]]: The number of connected components is the upper bound on the possible number of spies.

JavaScript (Node.js),  155 150 142  141 bytes
a=>new Set((a=a.map(s=>s.split` `))[0].map((_,x)=>a.flat(m=1<<x).map(o=_=>a.map((b,y)=>b.map((w,i)=>m>>i&1|o[w+=y]?o[w]=m|=1<<i:0)))|m)).size

Try it online!
How?
For each column \$x\$, we build a bitmask \$m\$ of linked columns (including the \$x\$th column). We eventually return the number of distinct bitmasks.
+---------+-------+-------+-------+-------+-------+-------+
| x       |   0   |   1   |   2   |   3   |   4   |   5   |
+---------+-------+-------+-------+-------+-------+-------+
| 2**x    |   1   |   2   |   4   |   8   |  16   |  32   |
+---------+-------+-------+-------+-------+-------+-------+
| words   | Angel | Devil | Angel | Joker | Thief | Thief |
|         | Ra    | Ra    | Ras   | Pu    | Ti    | N     |
|         | say   | sea   | c     | c     | see   | cee   |
+---------+-------+-------+-------+-------+-------+-------+
| bitmask |  15   |  15   |  15   |  15   |  48   |  48   |
+---------+-------+-------+-------+-------+-------+-------+

Commented
a =>                      // a[] = input
new Set(                  // we eventually convert the generated array into a set
  (a = a.map(s =>         // we first need to convert each line into
    s.split` `            // an array of words (*sigh*)
  ))                      //
  [0].map((_, x) =>       // for each word at position x in the first line:
    a.flat(m = 1 << x)    //   initialize a bitmask m with the x-th bit set and build an
                          //   array containing as many entries (N) as there are words in
                          //   the whole matrix
    .map(o =              //   the object o is used to store words
         _ =>             //   repeat N times to ensure that all relations are found:
      a.map((b, y) =>     //     for each line b[] at position y in a[]:
        b.map((w, i) =>   //       for each word w at position i in b[]:
          m >> i & 1 |    //         if the i-th bit is set in m (the relation already
                          //         exists)
          o[w += y] ?     //         or w + y is set in o (a relation exists in this line):
            o[w] =        //           set o[w + y] (the value doesn't matter as long as
                          //           it's non-zero)
              m |= 1 << i //           set the i-th bit in m
          :               //         else:
            0             //           do nothing
        )                 //       end of map() over the words
      )                   //     end of map() over the lines
    ) | m                 //   end of map() over all flatten entries; yield m
  )                       // end of map() over x
).size                    // return the size of the corresponding set

So... in practice, this would have a 32 or 64 identity limit?

@Vilx- I think he could switch to BigInt, although that would cost bytes of course.

Jelly, 19 bytes
ḲiⱮ`)ZŒc€ẎyⱮ@ƒƊÐLQL

Try it online!
Takes input as a list of space-separated lines (the footer accounts for that).
Note: ḲŒQ)PS does not work.

Python 3, 132 162 154 139 135 bytes
def f(a):r=[*zip(*[map(b.index,b)for b in map(str.split,a)])];return sum(i==min(min(u)for u in r if min(w)in u)for i,w in enumerate(r))

Try it online!
This is a very compact implementation of a graph algorithm identifying clusters.

For each agent, we create a map of profiles and their alias, which is the lowest index of appearance: [map(b.index,b)for b in map(str.split,a)]. I.e. [0,1,2,1,2] identifies three spies, where the first profile belongs to one, the second and fourth to another one and the third and fifth to the last one. The group index is also the index of the first profile in the group.
By transposing this matrix ([*zip(*m...)]), we get a group membership for each profile. This forms a directed, acyclic graph, because the group indices are a subset of the profile indices, and all edges go towards lower or equal indices. Profiles corresponding to the same spy now form a cluster with no connections to the other profiles. We still have duplicate paths though, because profile indices are linked to multiple groups indices.
With the following loops, we minimize the the graph to a flat forest, where all profiles are linked directly to the lowest index in their tree, i.e. the root: min(min(u)for u in r if min(w)in u)
Finally, return the number of roots in the forest, i.e. indices linked to themselves: return sum(i==...).

is the indentation necessary? it has been ages since I used python, but I seem to remember that you can make oneliners.

You can, but not if you use nested for loops. TIO for yourself ;)

Charcoal, 49 43 bytes
≔⪪Ｓ θＷＳ«≔⪪ι ιＦＬιＵＭθ⎇⁼λ§θκ§θ⌕ι§ικλ»ＩＬΦθ⁼κ⌕θι

Try it online! Link is to verbose version of code. Could possibly save a couple of bytes by using a cumbersome input format. Explanation:
≔⪪Ｓ θ

Input the first agent's list.
ＷＳ«

Repeat for the remaining agents.
≔⪪ι ι

Input their list.
ＦＬι

Loop over each element index.
ＵＭθ⎇⁼λ§θκ§θ⌕ι§ικλ»

Find the first element in this agent's list with the same identity and update the first agent's list to show that they are the same identity.
ＩＬΦθ⁼κ⌕θι

Count the number of unique identities remaining.

Jelly, 25 15 bytes
ḲĠ)ẎfƇFQɗⱮQ$ÐLL

Try it online!
A monadic link taking a list of space-separates agent claims and returning the lowest upper bound of the number of distinct spies.
Explanation
  )              | For each list:
Ḳ                | - Split at spaces
 Ġ               | - Group indices of equal items
   Ẏ             | Tighten lists, so we have a single list of grouped indices
           $ÐL   | Repeat the following until no change:
        ʋⱮQ      | - Do the following as a dyad, mapping through each element of the uniquified list as the right argument
    fƇ           |   - Keep only those list members with one or more items matching the right argument
      F          |   - Flatten
       Q         |   - Uniquify
              L  | Finally take the length of the resultant list

Thanks to @Arnauld and @JonathanAllan for identifying issues with previous versions, and to @JonathanAllan again for saving a byte! If the input spec were relaxed to allow a list of lists, this would save one byte.

I think the sort may actually be unnecessary, since the indices in the groups from Ġ are sorted and the flattened, de-duplicated filter result, fƇFQ, would always, after repeated application, end up with these in sorted order (e.g. 'a a b b c', 'a b a b c will not find an eventual [3,4,1,2], even though it would appear along the way). So ḲĠ)ẎfƇFQɗⱮQ$ÐLL might be good for 15?

@JonathanAllan good spot. I’ve had a bit of a play (and think about how it works) and think you’re right.

JavaScript (Node.js), 120 bytes
a=>a.map(l=>(s=l.split` `).map((w,i)=>r[o(i)]=o(s.indexOf(w)),o=i=>r[i]-i?o(r[i]):i),r=[])|r.map(g=(v,i)=>t+=v==i,t=0)|t

Try it online!
a=>a.map(l=>(                  // for each line
  (s=l.split` `).map((w,i)=>(  // for each words in line
    r[o(i)]=o(s.indexOf(w)),   // join(current index, first occurrence index)
  )),                          //   without updating nodes in path
  o=i=>r[i]-i?o(r[i]):i,       // a function to find root of some node
  r=[]                         // initial disjoint-set
))|
r.map(g=(v,i)=>t+=v==i,t=0)|   // count roots of tree
t                              // output

Python 3, 191 182 bytes
Thank you recursive
e=enumerate
def f(a):
	r=[list(map(b.index,b))for b in map(str.split,a)]
	for z in r:
		for i,v in e(z):
			for x in(i>v)*r:x[(i,x[i])[x[i]<i]]=z[v]
	return sum(i==v for i,v in e(z))

Try it online!

-9 bytes: https://tio.run/##ZVJNb6MwED0nv@L1hF2hSm1v1bJS6MehaqtVVWkPiIMJQzOqA8g2NMmfz3pIolZdwPabN/OeYUy/Dauuvd7vKaN2WJMzgeY1NWiU0TfzmcsKyz6otelVdcFtTZu00rrpHCpwC@F9cBe@txxSo8v5THI7ybmonyJOR4lJ7cTywG0io/j3qM/dzaZQnG4KLnUh8y8uy2xXjNHLURhcCz@sFWfZiB9uei9EIB9SOPKDDZIpVJEs2neyuKORLQ74sfsgh7cVx4@b5iRF8mowPR5/BrwxXoT0ZgtPBst4eyIsiZIyxZVOEZ1z23nfrZEPVWXJxzUEcsuhF@l9jft6GluRXB8lXfCfpjX4D4jmiZqAZ65rS3jl91UQ5eVpM7P8wN8VB5LSCWAiv73RQ9chNw5xlaJTGMc3pwVy3OJOChZYfEFhb08wj@wkKeM5sfwE0luNLDu2V46vd9wGdWh60hvvqU70fEbW01c6OftxxS2OksawFcn@Hw

Ruby, 123 117 bytes
Uses a similar idea to movatica's Python 3 solution but calculates the lowest spy index for each "tree" in a slightly different way (by keeping track of previous encountered profiles, finding an overlap if it exists, and combining them)
-6 bytes from @GB.
->a,*b{a.map{|s|e=s.split;e.map{|i|e.index i}}.transpose.map{|e|b<<(b.find{|i|i-e!=i}||[])+e}
b.map(&:min).uniq.size}

Try it online!
Explanation
->a,*b{                                             # Start lambda with input a, b=[]
       x=
         a.map{|s|                             }    # For each agent's report
                  e=s.split;                        # Split the words
                            e.map{|i|e.index i}     # Get spy number for each

   .transpose                                       # Transpose to get group membership
             .map{|e|                            }  # For each profile
                        (b.find{|i|i-e!=i}||[])     # Find a profile in b that overlaps
                                                    #  If one is not found, use []
                                               +e   # Add the profile onto the found one
                     b<<                            # Insert this modified profile into b

b.map(&:min)                                        # Get minimum of each modded profile
            .uniq                                   # Deduplicate
                 .size                              # Size of array
}                                                   # Implicit return

Instead of popping and zipping, you can just transpose.

113 bytes

@GB thanks for the heads up; I've been using pop-zip or shift-zip to transpose arrays forever! Also, your trick of using s.split.map{|i|s.index i} is nice, but it can create edge cases depending on the length of the inputs. This input should return 3, not 2.

Husk, 12 bytes
LωomΣknṁoηkw

Try it online!
Explanation
The idea is to create a list of all groups of spies that are known to be the same person, then progressively merge intersecting groups until a fixed point is reached.
The output is the number of remaining groups that couldn't be merged.
LωomΣknṁoηkw  Implicit input: list of strings, say ["a bc a","b g g"]
       ṁ      Map and concatenate:
           w   Split at spaces: "a bc a" becomes ["a","bc","a"]
         ηk    Group indices by equality of elements: [[1,3],[2]]
              Result: [[1,3],[2],[1],[2,3]]
 ω            Iterate until result doesn't change:
     k         Group greedily by
      n        (non-emptiness of) intersection: [[[1,3],[1]],[[2],[2,3]]]
   mΣ          Concatenate each part: [[1,3,1],[2,2,3]]
              Result: [[1,3,1,2,2,3]]
L             Length: 1

Python 2, 229 221 bytes
e=enumerate
def f(s):
 v=[];u=sum([(lambda a:[{i for i,x in e(a)if x==k}for k in set(a)])(a.split())for a in s.split('\n')],v)
 while u:
	x=u.pop()
	for i,y in e(u):
	 if x&y:u.pop(i);u+=[x|y];break
	else:v+=[x]
 return v

Try it online!
8 bytes thx to wilkben.

Since g is only used once, couldn't you define it inline? I kinda forget if that's possible in Python but I seem to remember it is.

221 Bytes

Clean, 137 bytes
import StdEnv,Text,Data.List
q=length
$l=q(iter(q l)(map flatten o groupBy isAnyMember)(transpose[[(s,n)\\s<-split" "z]\\z<-l&n<-[1..]]))

Try it online!
Associates the strings used by the agents with the line-number the appear in to prevent equality across agents, then repeatedly checks if any phrases for any position overlap and counts the number of resulting sets.

PHP, 271 bytes
This won't work if any of the identities are just numbers as I store the "spy number" in with the identities. I don't think it wouldn't be hard to fix that though.
$a=$argv;array_shift($a);if(count($a)==1)array_push($a,...$a);foreach($a as&$b)$b=explode(" ",$b);$c=array_map(null,...$a);foreach($c as&$d)foreach($d as$k=>$e){if(!$d[s])$d[s]=++$s;foreach($c as&$f)if($f[$k]==$e)$f[s]=$d[s];}echo count(array_unique(array_column($c,s)));

Try it online!
Explanation
Sort of confused myself writing this but it works for all the test cases!
$a=$argv;					//shorten the arguments variable
array_shift($a);				//removes the script name from the arguments variable
if(count($a)==1)array_push($a,...$a);		//the code needs at least 2 messages to run so if only 1 message duplicate it. "..." passes the stuff in the array rather than the array itself?
foreach($a as&$b)$b=explode(" ",$b);		//turns each string message into an array
$c=array_map(null,...$a);			//if you give array_map "null" for the callabck then it zips the arrays, turning a m by n 2D array into a n by m 2D array. this changes it from the messages being grouped to the identities being grouped
foreach($c as&$d)				//loop over the groups of identities
	foreach($d as$k=>$e)			//loop over the names the agents gave the identity and keep track of the key
	{
		if(!$d[s])$d[s]=++$s;		//if this identity doesn't have a "spy number" give it the next one
		foreach($c as&$f)		//loop over the groups of identities again
			if($f[$k]==$e)		//check if the agents gave any other identities this name
				$f[s]=$d[s];	//if they did then give those the same "spy number"
	}
echo count(array_unique(array_column($c,s)));	//use array_column to get the "spy number" of each identity, remove duplicates using array_unique and then count the size of the array giving the upper limit of spies

Try it online!


text:
Construct a pentagon avoiding compass use
Rules
You will start with only two elements: Points \$A\$ and \$B\$ such that \$A \neq B\$.  These points occupy a plane that is infinite in all directions.
At any step in the process you may do any of the three following actions:

Draw a line that passes through two points.
Draw a circle centered at one point such that another point lies on the circle.
Add a new point where two objects (lines and circles) intersect.

Your goal is to create 5 points such that they form the vertices of a regular pentagon (a convex polygon with 5 sides equal in length) using as few circles as possible.  You may, of course, have other points but 5 of them must for a regular pentagon.  You do not have to draw the edges of the pentagon for your scoring.
Scoring
When comparing two answers the one that draws fewer circles is better.  In the case of a tie in circles the answer that draws the fewest lines is better.  In the case of a tie in both circles and lines the answer that adds the fewest points is better.
Anti-Rules
While the rules list is exhaustive and details everything you can do, this list is not. Just because I don't say you can't do something does not mean you can.

You cannot create "arbitrary" objects.  Some constructions you will find will do things like add a point at an "arbitrary" location and work from there.  You cannot add new points at locations other than intersections.
You cannot copy a radius.  Some constructions will involve taking a compass setting it to a radius between two points and then picking it up and drawing a circle elsewhere.  You cannot do this.
You cannot perform limiting processes.  All constructions must take a finite number of steps.  It is not good enough to approach the answer asymptotically.
You cannot draw an arc or part of a circle in order to avoid counting it as a circle in your scoring.  If you want to visually use arcs when showing or explaining your answer because they take up less space go ahead but they count as a circle for scoring.

Tools
You can think through the problem on GeoGebra.  Just go over to the shapes tab.  The three rules are equivalent to the point, line and circle with center tools.
Burden of Proof
This is standard but I would like to reiterate.  If there is a question as to whether a particular answer is valid the burden of proof is on the answerer to show that their answer is valid rather than the public to show that the answer is not.
What is this doing on my Code-Golf site?!
This is a form of atomic-code-golf similar to proof-golf albeit in a bit of a weird programming language. There is currently a +22/-0 consensus on the meta that this sort of thing is allowed.

This is like the game I have on my phone called Euclidea.

closely related: https://codegolf.stackexchange.com/q/38653/15599

"setting it two a radius" a likely typo

Next time you should ask people to draw a heptagon, which would be slightly more challenging:)

@flawr "Slightly", hmm?

If I remember correctly, a 13-gon is possible, so that would be quite challenging.

It's the regular 17-gon which is constructible using ruler and compasses. I can give you a heptagon but it won't necessarily be regular!

Heptagon (7 sides) is not possible with only ruler and compass. Mathologer covered it.

If the 17-gon is too easy, there's always the regular 65537-gon...

Are answers supposed to actually prove/explain why the resulting pentagon is regular? It's not obvious to me just by following the construction.

@Minethlos Answers don't have to prove there correctness by default but the burden of proof is on the answerer.  If don't follow why an answer should be regular just leave a comment asking for clarification.

2 circles, 13 lines, 17 points

Try it on GeoGebra

Let circle(A, B) intersect circle(B, A) at C and D.
Let AB intersect circle(A, B) again at E.
Let AB intersect circle(B, A) again at F.
Let AD intersect circle(A, B) again at G.
Let AD intersect CF at H.
Let BG intersect DF at I.
Let HI intersect circle(A, B) at J and K.
Let BG intersect EJ at L.
Let BJ intersect EG at M.
Let BG intersect EK at N.
Let BK intersect EG at O.
Let LM intersect circle(A, B) at P and S.
Let NO intersect circle(A, B) at Q and R.

Then EPQRS is a regular pentagon.
Why it works
Let BE intersect GJ at T, and let BE intersect GK at U.  The complete quadrilateral BEGJ shows that T is the polar of LM, which is the intersection of the tangents at P and S.  Similarly, the complete quadrilateral BEGK shows that U is the polar of NO, which is the intersection of the tangents at Q and R.
Let FG intersect HI at V.  The diagonals DV and GI of the complete quadrilateral DGVI intersect FH at harmonic conjugates with respect to F and H; since the first is at ∞, the second is the midpoint C of FH, which is to say that C, D, V are collinear.
Let CG intersect HI at W.

Now for the fun part.  Line FUBAT is perspective about G to line VKIHJ, which is perspective about D to circle CKDGJ, which is perspective about C to line HKVWJ, which is perspective about G to line AUF∞T.  Composing these four perspecitivities yields a projectivity FUBAT ⌅ AUF∞T.  Since a one-dimensional projectivity is determined by three points, T and U are determined as the two fixed points of FBA ⌅ AF∞.
Assigning coordinates with A = 0, B = −1, F = −2, this projectivity is defined by x ↦ 4/x + 2, and its fixed points T = 1 + √5 = sec(2π/5) and U = 1 − √5 = −sec(2π/10), exactly as required to make EPQRS a regular pentagon.

How did you find this? Looks amazing.

How do you draw the third line? This seems like a perpendicular bisector, but how do you draw this without drawing circles? The same goes for the fourth line, and many more.

Please explain each step of your algorithm in words and symbols.

@Servaes This answer could use some explanation, but I can tell you that the third line is fine, it is a perpendicular bisector but it is defined in terms of two preexisting points rather than as a perpendicular bisector.  Same goes for the fourth one.

@RosieF Sorry about that, the labels were annoying to add with the way I had been producing the pictures. I redid this in GeoGebra with labelled points and added instructions and a link to the interactive app where you can play with the construction.

Looks like a neat solution, but do you care to explain why the result is a regular pentagon? I.e. why EP = PQ = QR = RS = SE?

@Minethlos It took a while to come up with a nice proof but I finally found one that I’m happy with. Be warned that it requires a fair amount of background in projective geometry.

Move over FOOBAR, we now have FUBAT

7 6 circles, 3 lines
This is a classical pentagon construction, a proof of its correctness can be found here.

4 circles, 7 lines
Since it has been beaten I thought I would just post my original solution to the problem.  This solution is modified from the method given by Dixon in Mathographics, a proof of correctness for that method can be found here.

Draw \$\mathrm{Circle}(A,B)\$
Draw \$\overline{AB}\$
Mark the intersection of \$\mathrm{Circle}(A,B)\$ and \$\overline{AB}\$ as \$C\$
Draw \$\mathrm{Circle}(B,C)\$
Draw \$\mathrm{Circle}(C,B)\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\mathrm{Circle}(B,C)\$ as \$D\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{AB}\$ as \$E\$
Draw \$\overline{DC}\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{DC}\$ as \$F\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\mathrm{Circle}(B,C)\$ as \$G\$
Draw \$\overline{BG}\$
Mark the intersection of \$\overline{BG}\$ and \$\overline{EF}\$ as \$H\$
Draw \$\overline{HC}\$
Mark the intersection of \$\overline{HC}\$ and \$\mathrm{Circle}(C,B)\$ as \$I\$
Draw \$\overline{IA}\$
Mark the intersection of \$\overline{IA}\$ and \$\mathrm{Circle}(A,B)\$ as \$J\$
Draw \$\mathrm{Cirlce}(I,J)\$
Mark the intersection of \$\mathrm{Circle}(I,J)\$ and \$\overline{HC}\$ as \$L\$
Mark the intersections of \$\mathrm{Circle}(I,J)\$ and \$\mathrm{Circle}(C,B)\$ as \$M\$ and \$K\$.
Draw \$\overline{ML}\$
Draw \$\overline{KL}\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{ML}\$ as \$N\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{HC}\$ as \$O\$
Mark the intersection of \$\mathrm{Circle}(C,B)\$ and \$\overline{KL}\$ as \$P\$

\$MKPON\$ is a regular pentagon.

This is marvellous! Some of your construction resembles Dixon's method, but your method cleverly avoids bisecting anything or constructing a perpendicular.

@RosieF It is modified from Dixon's method, I probably should have mentioned that.


text:
Using two linked programs, output ordinal numbers up to n

...Ordinal numbers (or ordinal numerals) are words representing position or rank in a sequential order.

From Wikipedia.
Your task is, using 2 separate programs (of which can be made from 2 different languages), to output the ordinal sequence from first to nth. You will be outputting the full word second as opposed to 2nd.
The challenge of ordinal numbers has been brought up before, particularly in this entry. In this challenge, ordinals are merely a vehicle to facilitate the unique conditions detailed below.

Part 1
You must make a program that, when given the input of n must output anything.
n will always be a positive, non-zero integer no larger than 999.
Valid output includes but is not limited to:

Any output to stdout / stderr / etc
Creation of files / folders / etc
A graphical interface or images of any kind

Anything goes.

Part 2
You must make a program that uses the output of part 1's program to output a sequence of ordinal numbers, starting from 1 (first), up to whatever n was parsed in part 1.
General Conditions:

The total bytes for part 2 must not exceed the total bytes for part 1 (less than or equal to).

Output conditions:

Not case sensitive.
Output must contain only the ordinal sequence (only characters a-Z) and whitespace (newlines allowed).
Can be output to any source, so long as it is visible either during or after execution.
Program does not need to terminate so long as its output is correct.
Output is not required to have any grammar, but may optionally include it (hyphens, commas, "ands", etc). nine hundred ninety ninth is just as acceptable as nine hundred and ninety-ninth.

Sample Output
Where n is 8
FIRST SECOND THIRD FOURTH FIFTH SIXTH SEVENTH EIGHTH

Scoring
The hierarchy of win conditions is:

The lowest number of bytes in part 1
The lowest number of bytes in part 2

Entry #1 | Part 1 = 32 bytes, Part 2 = 22 bytes
Entry #2 | Part 1 = 31 bytes, part 2 = 30 bytes

Entry #2 wins - Part 1 contains 31 bytes vs 32 bytes

---

Entry #1 | Part 1 = 21 bytes, Part 2 = 33 bytes
Entry #2 | Part 1 = 80 bytes, Part 2 = 70 bytes

Entry #2 wins - Entry #1 disqualified (Part 2 contains more bytes than Part 1)

---

Entry #1 | Part 1 = 50 bytes, Part 2 = 49 bytes
Entry #2 | Part 1 = 50 bytes, Part 2 = 50 bytes

Entry #1 wins - Part 1 is equal, Part 2 contains 49 bytes vs 50 bytes

What's the point in part 1 (as in, why couldn't this challenge just be scored on shortest submission for part 2)? Also, in your second scoring example, isn't the first entry invalid (part 2 > part 1), and if not, wouldn't it beat the second entry? Also, I recommend having at least a link to a formal ruleset for defining ordinals; for example, is 111 supposed to say one hundred and eleventh or one hundred eleventh?

@HyperNeutrino I think the idea is to try to split the work between the two as evenly as possible while golfing -- if I make p1 output [30, 'second'] for 32 then p2 has less work to do that if it had output, just 32.

Maybe I'm missing something stupid, but of the last two entries in the scoring examples, why doesn't entry 1 win? part 1 has same bytes, part 2 is less than or equal to part 1 for both, and entry 1 part 2 has less bytes than entry 2 part 2.

@PatrickRoberts Because Part 2 must contain equal or fewer bytes to Part 1.  Since Part 1 is 21 bytes, but Part 2 is 33 bytes, Entry #1 is disqualified.  Unfortunately, that information is tucked away and not explicitly stated in the win conditions at the moment.

@PatrickRoberts This is important, because otherwise you could use a language that implicitly passes input as output when a 0 byte program is run for Part 1

@Chronocidal I said last two entries. 50 49 and 50 50. Not 21 33 and 80 70. I understand why the second two entries are scored that way. It appears the question was edited after I pointed that out.

Sledgehammer 0.5.1 / Sledgehammer 0.5.1, 10 bytes
Program 1 (10 bytes):
⣘⢷⠾⣃⢖⣎⢅⡨⠱⢳

Decompresses into this Wolfram Language function:
{Range[#1], "Ordinal"} &

Program 2 (7 bytes):
⡾⡁⢚⣷⣬⠤⣾

Decompresses into this Wolfram Language function:
StringRiffle[IntegerName @@ #1, " "] &

Try it online!

R (with english package), 16 bytes / 16 bytes
 Part 1, 16 bytes
f=function(n)1:n

Part 2, 16 bytes
english::ordinal

Requires the english package (which is not installed on TIO, unfortunately).
english::ordinal(f(22)) outputs first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth thirteenth fourteenth fifteenth sixteenth seventeenth eighteenth nineteenth twentieth twenty first twenty second.
Of course, part 1 could be made much shorter (3 bytes: seq), but that would go against the constraint that part 2 has to be no longer than part 1.

@Giuseppe Sure. Although I would argue that CRAN packages are part of R, and so should be allowed as long as we count the characters needed to load and attach them.

I believe meta consensus is that using an external library essentially counts as "another language"; see for instance this post which is about compiler flags, but has a note about Python external libraries. The answer here is instructive with many examples but I can't seem to use the search function on meta to find the definitive statement.

@Giuseppe Continued in chat: https://chat.stackexchange.com/transcript/message/51052875#51052875

Wolfram Language (Mathematica) (both parts), 18 bytes / 15 bytes
-5/-1 thanks to lirtosiast
Part 1, 18 bytes
Range@#|"Ordinal"&

Part 2, 15 bytes
IntegerName@@#&

Try it online!
Two functions which output via return value.

Range@#|"Ordinal"& is shorter, and IntegerName vectorizes over the first argument. I think space-separated output might be required, though.

Python 3(part 1 & part 2)
Unfortunately Nodebox is very wordy... there is not much room for golfing.
Part 1 76 bytes
for  i  in  range  (  1 ,  int  (  input  (  ) ) + 1 ) : print ( i ,end=" ")

Part 2 (Uses the NodeBox library) 76 bytes
import en.number as n
for i in input().split():print(n.ordinal(n.spoken(i)))

Your answer must be valid; in this case, your part 2 is longer than your part 1, which is invalid. You cannot mark an answer as "non-competing" and submit an invalid submission; the "non-competing" label is a deprecated label for challenges submitted in languages or language versions that postdate the challenge, which used to be typically disallowed, but allowed under "non-competing" status for interesting submissions anyway.

@HyperNeutrino Sorry, I thought the rules required Part 1 to be shorter than Part 2. I marked this as non-competing because it used a library to solve this problem.

Technically, using external libraries seems to be alright: https://codegolf.meta.stackexchange.com/q/188

import en.number as n saves you four bytes in each part.

JavaScript (Node.js), 47 bytes / 47 bytes
Two functions in the same Node.js environment, invoked like g(f(n)). Uses the npm package number-to-words.
Part 1, 47 bytes (40 bytes + 7 spaces)
n=>H=>{for(i=0;i<n;)console.log(H(++i))}

Part 2, 47 bytes
F=>F(require("number-to-words").toWordsOrdinal)

Try it on Runkit!

JavaScript (Node.js), 48 bytes / 43 bytes
Part 1, 48 bytes
n=>[n,require("number-to-words").toWordsOrdinal]

Part 2, 43 bytes
([n,F])=>{for(i=0;i<n;)console.log(F(++i))}

Try it on Runkit!

Perl 5.10 / Common Lisp, 34 / 26 bytes
So, Common Lisp format has this as a built-in, because of course it does.
Program 1 (34 bytes)
say"(format t\"~:r \"$_)"for 1..<>

Perl does all the iterating. The equivalent Common Lisp code ((dotimes(i(read)) ...)) is longer than the much golfier Perl ... for 1..<>. Perl outputs a bunch of Common Lisp code.
Program 2 (26 bytes)
(loop(eval(read nil nil)))

It's a REPL, minus the P. It reads standard input and, well, executes it. Doesn't terminate, but the rules explicitly say that's fine.

Vyxal, 2/2 bytes
ɾ, # print range (1,n+1)

∆o # nth ordinal of each

Try it Online!