text:
Greatest common substring
Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.

This may mean outputting the empty string.
If there are several valid outputs, you may output any one of them. You are not required to give consistent output for a given input so long as the output is always valid.
There will always be at least one string in the input, but there might not be a non-empty string.
All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.
You may take input or produce output by any of the default methods.
Standard loopholes aren't allowed.
This is code-golf - the fewer bytes of code, the better.

Test cases:
[Inputs] -> [Valid outputs (choose one)]
["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["&"]

Possible duplicate

@Adám That question asks for the longest common subsequence, not substring.

Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?

@EmbodimentofIgnorance All printable ASCII characters can appear in the input.

@JoKing Yeah, it can. Apparently I'm too tired for this.

Can we ouput undefined instead of the empty string?

@Shaggy Generally, no. If the two can be distinguished, undefined implies there's no valid output string. If the empty string (or any other string) is a valid output, claiming there is no valid output is incorrect.

@Adám plus, if this were subsequence based then the duple target has a time to complete requirement, which would affect the submissions substantially.

Related

Brachylog (v2), 3 9 bytes
{sᵛ}ᶠlᵒtw

Try it online!
Full program. Input from standard input (as a JSON-style list of strings), output to standard output.
Explanation
{sᵛ}ᶠlᵒtw
 s         Find a substring
  ᵛ          of every element {of the input}; the same one for each
{  }ᶠ      Convert generator to list
     lᵒt   Take list element with maximum length
        w  Output it

Apparently, the tiebreak order on s is not what it is in nearly everything else in Brachylog, so we need to manually override it to produce the longest output. (That's a bit frustrating: four extra characters for the override, plus two grouping characters because Brachylog doesn't parse two metapredicates in a row.)
Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.

I tried this with the input ["many inpuabts", "any inabputs", "ny iabii", "yanabny"]. I expected the results ab and ny. But only got the result a. Am I doing something wrong ?

Ugh, seems I remembered the tiebreak order for s wrong, and overriding the tiebreak order is rather expensive byte-wise. Doing that now anyway, though, because it's important for the answer to be correct. Somehow none of the test cases I tried noticed the difference.

@ais523 The order s produces substrings is by first giving all prefixes of the input (longest first), then dropping the first one and repeat

Python 2, 82 bytes
f=lambda h,*t:h and max(h*all(h in s for s in t),f(h[1:],*t),f(h[:-1],*t),key=len)

Try it online!
Takes input splatted. Will time out for inputs where the first string is long.
The idea is to take substrings of the first strings h to find the longest one that appears in all the remaining strings t. To do so, we recursively branch on removing the first or last character of h.

Python 2, 94 bytes
lambda l:max(set.intersection(*map(g,l)),key=len)
g=lambda s:s and{s}|g(s[1:])|g(s[:-1])or{''}

Try it online!
A more direct method. The auxiliary function g generates the set all substrings of s, and the main function takes the longest one in their intersection.

Jelly, 12 6 bytes
Ẇ€f/ṫ0

Try it online!
Thanks to @JonathanAllan for saving 6 bytes!

I believe Ẇ€œ&/Ṫḟ0 would do the job and save four bytes since the sub-strings are already ordered by length, hence the filtered result will be; then all that remains is that when there are no matches tail produces a zero, and since we are guaranteed lists of characters we can simply filter those out.

also I think œ&/ may be replaced by f/ here saving another

I submitted a pull request to (hopefully) make the result of reducing an empty list be an empty list (rather than raising a TypeError). If that gets merged in I believe that this answer could then become a six-byter with Ẇ€f/ṛ/.

@JonathanAllan sounds good. Thanks for the other tips - hope you were happy for me to incorporate them.

Yes, my reason for those comments was to allow you to incorporate the ideas into your post.

...in fact even without the pull request being merged in we can have a full-program implementation in 6 bytes with Ẇ€f/ṫ0 (tailing from index zero, the rightmost, onward) and implicitly printing the result (as a monadic Link it yields an empty list or a list containing a single list of characters, but the implicit printing just prints the characters that are present).

Ruby 2.6, 76 59 54 bytes
->a{*w=a;w.find{|r|w<<r.chop<<r[1..];a.all?{|s|s[r]}}}

Try it online! - Ruby 2.5 version (56 bytes)
How?
Create a list of potential matches, initially set to the original array. Iterate on the list, and if a string does not match, add 2 new strings to the tail of the list, chopping off the first or the last character. At the end a match (eventually an empty string) will be found.
Thanks Kirill L for -2 bytes and histocrat for another -2

Zsh, 126 ... 96 bytes
-3 bytes from arithmetic for, -6 bytes from implicit "$@" (thanks roblogic), -5 bytes from removing unneeded { }, -1 byte from short form of for, -1 byte by using repeat, -1 byte by concatenating for s ($b) with its body, -13 bytes by changing the repeat loop out for some eval jank.
for l
eval a=\( \$l\[{1..$#l},{1..$#l}\] \)&&b=(${${b-$a}:*a})
for s ($b)(($#x<$#s))&&x=$s
<<<$x

Try it online!
Try it online!
Try it online!
We read all possible substrings into the arraya, and then set b to the intersection of the arrays a and b. The construct ${b-$a} will only substitue $a on the first iteration: Unlike its sibling expansion ${b:-$a}, it will not substitute when b is set but empty.
for l;                              # implicit "$@"

# === OLD ===
{
    a= i=                           # empty a and i
    repeat $[$#l**2]                # compound double loop using div/mod
        a+=($l[++i/$#l+1,i%$#l+1])  # append to a all possible substrings of the given line
#               1+i/$#l             # 1,1,1...,  1,1,2,2,2,... ...,  n,n
#                       1+i%$#l     # 1,2,3...,n-1,n,1,2,3,... ...,n-1,n
#       a+=( $l[       ,     ] )    # append that substring to the array
# === NEW ===
    eval a=\( \
        \$l\[{1..$#l},{1..$#l}\] \  # The {bracket..expansions} are not escaped
    \) &&
# ===     ===
    b=( ${${b-$a}:*a} )
#         ${b-$a}                   # if b is unset substitute $a
#       ${       :*a}               # take common elements of ${b-$a} and $a
#   b=(               )             # set b to those elements
}
for s ($b)                          # for every common substring
    (( $#x < $#s )) && x=$s         # if the current word is longer, use it
<<<$x                               # print to stdout

How does this bit work? a+=( $l[1+i/$#l,1+i%$#l] )

@roblogic I think I explained it better now, check the edit. The idea is to loop to n^2  and use / and % instead of using 2 nested for loops

you might be able to cut for l in "$@" to simply for l; - it's a bash trick

i gotta say, zsh is so much more elegant than bash. There's nothing analogous to this nice array comparison AFAIK b=(${${b-$a}:*a})}

There's some neat things you can do with it, and it isn't all that popular. That translates into me adding a zsh answer to most questions I come across. :P
If you want to learn zsh, I recommend man zshexpn and man zshparam especially. I always have them open when writing an answer.

R, 119 116 108 106 bytes
function(S,`?`=nchar,K=max(?S),s=Reduce(intersect,lapply(S,substring,0:K,rep(0:K,e=K+1))))s[which.max(?s)]

Try it online!
Find all substrings of each string, find the intersection of each list of substrings, then finally return (one of) the longest.
-3 bytes thanks to Kirill L.
-8 bytes using lapply instead of Map
-2 bytes thanks to Kirill L. again, removing braces

I don't have time to check, but if I'm not mistaken, 2 occurrences of nchar are enough to save something by declaring nchar as an unary operator.

@KirillL. yes, it is shorter by 2 bytes. Thanks! Aliasing list similarly gives us -3 bytes.

You can also drop braces for another -2

@KirillL. thanks! I'm a bit worried I'm going to start doing that with production code...

that's the problem with golfing a language you use every day

05AB1E, 14 9 8 bytes
€Œ.«ÃéθJ

-6 bytes thanks to @Adnan.
Try it online or verify all test cases.
Explanation:
€Œ       # Get the substring of each string in the (implicit) input-list
  .«     # Right-reduce this list of list of strings by:
    Ã    #  Only keep all the strings that are present in both list of strings
     é   # Sort by length
      θ  # And pop and push its last item
         # The substrings exclude empty items, so if after the reduce an empty list remains,
         # the last item will also be an empty list,
       J # which will become an empty string after a join
         # (after which the result is output implicitly)

I think €Œ.«Ãõªéθ should work for 9 bytes.

@Adnan Wait, we do have a reduce.. How did I miss that. :S I tried Å«Ã, but didn't realize I should have used .«Ã instead.. Thanks!

Actually, I think €Œ.«ÃéθJ should work for 8.

Perl 6, 62 60 bytes
{~sort(-*.comb,keys [∩] .map(*.comb[^*X.. ^*]>>.join))[0]}

Try it online!
I'm a little annoyed the Perl 6 can't do set operations on lists of lists, which is why there's an extra .comb and >> in there.
Another annoying thing is that max can't take an function for how to compare items, meaning I have to use sort instead. As pointed out in the comments, max can take an argument, however it ends up longer since I have to take into account max returning negative infinity when there are common substrings (Try it online!).

max can take such a function (arity 1 though), either by position when called in OO mode, or a named :by argument in procedural mode.

Haskell, 80 bytes
import Data.List
f(x:r)=last$sortOn(0<$)[s|s<-inits=<<tails x,all(isInfixOf s)r]

Try it online!
Get all suffixes (tails) of the first word x in the list and take all prefixes (inits) of those suffixes to get all substrings s of x. Keep each s that isInfixOf all strings in the remaining list r. Sort those substrings by length (using the (0<$) trick) and return the last.

TSQL query, 154 bytes
USE master
DECLARE @ table(a varchar(999)collate Latin1_General_CS_AI,i int identity)
INSERT @ values('string'),('stRIng');

SELECT top 1x FROM(SELECT
distinct substring(a,f.number,g.number)x,i
FROM spt_values f,spt_values g,@ WHERE'L'=g.type)D
GROUP BY x ORDER BY-sum(i),-len(x)

Try it online
Made case sensitive by declaring the column 'a' with collation containing CS (case sensitive).
Splitting all strings from 2540 starting positions(many identical) but the useful values range between 1 and 2070 and ending 0 to 22 characters after starting position, the end position could be longer by changing the type to 'P' instead of 'L', but would cripple performance.
These distinct strings within each rownumber are counted. The highest count will always be equal to the number of rows in the table variable '@'. Reversing the order on the same count will leave the substring with most matches on top of the results followed by reversed length of the substring will leave longest match with most matches on top. The query only select the top 1 row.
In order to get all answers, change the first part of the query to

SELECT top 1with ties x FROM

C# (Visual C# Interactive Compiler), 320 257 bytes
l=>(string.Join(",",l.Select(s=>new int[s.Length*s.Length*2].Select((i,j)=>string.Concat(s.Skip(j/-~s.Length).Take(j%-~s.Length))))
.Aggregate((a,b)=>a.Intersect(b)).GroupBy(x=>x.Length).OrderBy(x =>x.Key).LastOrDefault()?.Select(y=>y)??new List<string>()));

Try it online!
Props to @Expired Data and @dana

You can just return the string from a function.
So in Interactive compiler it might look something like this:
294 bytes

Here's the solution golfed down some bytes 215 bytes

@ExpiredData ah perfect this is the example I needed :)

186

184

Retina 0.8.2, 48 bytes
M&!`(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)
O#$^`
$.&
1G`

Try it online! Explanation:
M&!`(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)

For each suffix of the first string, find the longest prefix that's also a substring of all of the other strings. List all of those suffix prefixes (i.e. substrings). If there are no matching substrings, we just end up with the empty string, which is what we want anyway.
O#$^`
$.&

Sort the substrings in reverse order of length.
1G`

Keep only the first, i.e. the longest substring.

Let n is number of argument strings. Then (?=(.*\n.*\1)*.*$) should be (?=(.*\n.*\1){n-1}.*$), isn't it? Test case: ["very", "different", "much"] -> [""]

@mazzy I don't see the problem: Try it online!

it is not a problem. with {n} you could remove start and end patterns and keep (.+)(?=(.*\n.*\1){n} if Retina allows to write n shorter than (?<=^.*).*$

@mazzy I can't in Retina 0.8.2, and in Retina 1 I'd have to mess around with eval, which would probably be longer anyway.

Japt v2.0a0 -hF, 8 bytes
Îã f@eøX

Thanks to Shaggy for saving 3 bytes
Try it
Îã              //Generate all substrings of the first string
 f@             //Filter; keep the substrings that satisfy the following predicate:
   e            //    If all strings of the input...
    øX          //    Contain this substring, then keep it
-h              //Take last element
-F              //If last element is undefined, default to empty string

You shouldn't need to sort by length at the end, saving 3 bytes. Also, -F defaults to the empty string.

Japt -h, 8 bytes
(I could knock off the last 3 bytes and use the -Fh flag instead but I'm not a fan of using -F)
mã rf iP

Try it or run all test cases
mã rf iP     :Implicit input of array
m            :Map
 ã           :  Substrings
   r         :Reduce by
    f        :  Filter, keeping only elements that appear in both arrays
      i      :Prepend
       P     :  An empty string
             :Implicit output of last element

Husk, 6 bytes
►LFnmQ

Try it online!

Python 3, 137 bytes
def a(b):c=[[d[f:e]for e in range(len(d)+1)for f in range(e+1)]for d in b];return max([i for i in c[0]if all(i in j for j in c)],key=len)

Try it online!

You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.

@JoKing https://tio.run/##RctBCsIwEEDRqwxZSAa7sLir9CQhizSZsUU7lSEVg3j2aFauPjz4j5LnTc61JmIIdsIhju6dHA/keVMgWAQ0yJXsncQmPPbYnP9O@GmSmkz@opR3FVjDy0Z38ofoet/dqIy/H2uwzjxJi@nArHucW9PCTEqSjcf6BQ

Right, here's a fixed version of the 135 byte program

Python 2, 103 bytes
lambda b:max(reduce(set.__and__,[{d[f:e]for e in range(len(d)+2)for f in range(e)}for d in b]),key=len)

Try it online!
This is an anonymous lambda that transforms each element into the set of all substrings, then reduces it by set intersection (set.__and__) and then returns the max element by length.

1 byte shorter with set.intersection.

C# (Visual C# Interactive Compiler), 147 145 bytes
a=>{int i=0,j,m=0,k=a[0].Length;string s="",d=s;for(;i<k;i++)for(j=m;j++<k-i;)if(a.All(y=>y.Contains(s=a[0].Substring(i,j)))){m=j;d=s;}return d;}

Try it online!

JavaScript (ES6),  98  92 bytes
a=>(g=b=s=>a.every(x=>~x.indexOf(s))?b=b[s.length]?b:s:g(s.slice(0,-1,g(s.slice(1)))))(a[0])

Try it online!

Charcoal, 30 bytes
≔⊟θη≔⁰ζＦＬη«≔✂ηζ⊕ι¹ε¿⬤θ№κεＰε≦⊕ζ

Try it online! Link is to verbose version of code. This algorithm is more efficient as well as shorter than generating all substrings. Explanation:
≔⊟θη

Pop the last string from the input list into a variable.
≔⁰ζ

Zero out the substring start index.
ＦＬη«

Loop over all possible substring end indices. (Actually this loops from 0 excluding the length, so the value is adjusted later.)
≔✂ηζ⊕ι¹ε

Obtain the current substring.
¿⬤θ№κε

Check whether this substring is contained in all of the other input strings.
Ｐε

If it is then overprint any previously output substring.
≦⊕ζ

Otherwise try incrementing the substring start index.

Perl 5 (-aln0777F/\n/ -M5.01 -MList::util=max), 99 bytes
may be golfed more certainly
map/(.+)(?!.*\1)(?{$h{$&}++})(?!)/,@F;say for grep{y///c==max map y///c,@b}@b=grep@F==$h{$_},keys%h

TIO

Bash, 295 166 145
for l;{((f++));d=${#l};i=;for((;i++<d**2;)){ echo "${l:i/d:1+i%d}">>$f;};}
for j in *;{((f++));grep -xf$j $[j+1]>$f;};egrep "^.{$(wc -L<$f)}$" $f

Try it Online!
Not pretty but at least it works. We write the substrings to files $f, then (e)grep for longest common line.
. (Old) 166b with arrays
. Prototype script with comments

Save 2 more: You can replace ((k==$#))&& with ((k-$#))||. This also lets you use k= instead of setting it to 0.

I think "Not pretty but at least it works" is the MO for bash scripts :)

JavaScript (Node.js), 106 bytes
a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.indexOf(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)

Try it online!
a=>(                      // Main function
 F=(                      //  Helper function to run through all substrings in a[0]
  l,                      //   Length
  n,                      //   Start position
  w=a[0].substr(n,l)      //   The substring
 )=>
 l?                       //   If l > 0:
  n<0?                    //    If n < 0:
   F(--l,L-l)             //     Check another length
  :a.some(                //    If n >= 0:
   y=>y.indexOf(w)<0      //     Check whether there is any string not containing the substring
                          //     (indexOf used because of presence of regex special characters)
  )?                      //     If so:
   F(l,n-1)               //      Check another substring
  :w                      //     If not, return this substring and terminate
                          //     (This function checks from the longest substring possible, so
                          //      it is safe to return right here)
 :""                      //   If l <= 0: Return empty string (no common substring)
)(
 L=a[0].length,           //  Starts from length = the whole length of a[0]
 0                        //  And start position = 0
)

Java (JDK), 158 bytes
a->{for(int l=a.get(0).length(),i=l,j;i>=0;i--)for(j=0;j<l-i;){var s=a.get(0).substring(j++,j+i);if(a.stream().allMatch(x->x.contains(s)))return s;}return"";}

Try it online!
Credits

-17 bytes thanks to Sara J.

159 bytes (removed test cases to fit TIO link into a comment)

Red, 266 174 bytes
func[b][l: length? s: b/1 n: 1 until[i: 1 loop n[t: copy/part at s i l r: on foreach u
next b[r: r and(none <> find/case u t)]if r[return t]i: i + 1]n: n + 1 1 > l: l - 1]""]

Try it online!
Changed the recursion to iteration and got rid of the sorting.

PowerShell, 165 163 87 bytes
-76 bytes thanks to Nail for the awesome regexp.
"$($args-join'
'|sls "(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)"-a -ca|% m*|sort Le*|select -l 1)"

Try it online!
Less golfed:
$multilineArgs = $args-join"`n"
$matches = $multilineArgs|sls "(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)" -AllMatches -CaseSensitive|% matches
$longestOrNull = $matches|sort Length|select -Last 1
"$longestOrNull"

JavaScript (Node.js), 90 88 bytes
f=(a,s=e=0,w='')=>a[0][e++]?f(a,s+(r=a.some(x=>!x.includes(t=a[0].slice(s,e)))),r?w:t):w

Try it online! Test cases shamelessly stolen from @Arnauld. Port of my Charcoal answer. Edit: Saved 2 bytes thanks to @l4m2.

88

Perl 5, 87 bytes
my$r;"$&@_"=~/(.{@{[$r=~y,,,c]},}).*(\n.*\1.*){@{[@_-1]}}/ and$r=$1while$_[0]=~s,.,,;$r

Try it online!

Gaia, 15 bytes
eḋ¦&⊢⟨:l¦:⌉=¦⟩∇

Try it online!
e		| eval as code
 ḋ¦		| find all non-empty substrings
   &⊢		| Reduce by set intersection
              ∇	| and return the first element where
      ⟨:l¦:⌉=¦⟩	| the length is equal to the max length

Perl 5, 86 bytes
$_=join"\x1",<>;$p=".*\x1.*\\1"x($.-1);say+(sort{length$b-length$a}/(.+)(?=$p)/msg)[0]

Try it online!

Pyth, 16 bytes
eolN.U@bZm{s./dQ

Try it online!
       m     Q    # Map Q (parsed input) over the following function (lambda d:
          ./d     # Partitions of d (all substrings)
         s        # Reduce on + (make one list)
        {         # deduplicate
    .U            # reduce the result on the following lambda, with starting value result[0]
      @bZ         # lambda b,Z: Intersection between b and Z
                  # Result so far: all common substrings in random order
 o                # sort the resulting sets by the following lambda function:
  lN              # lambda N: len(N)
e                 # last element of that list


text:
Is there a smaller tautogram checker?
I got into code-golfing recently and tried to write the smallest tautogram checker.
A tautogram is a sentence in which all words start with the same letter, for example: Flowers flourish from France.
Given a sentence as input, determine whether it is a tautogram.
Test Cases
Flowers flourish from France
    True

This is not a Tautogram
    False

I came up with this python code (because it is my main language):
print(True if len(list(set([x.upper()[0] for x in __import__('sys').argv[1:]]))) == 1 else False)

Usage:
python3 tautogram.py Flowers flourish from France
# True
python3 tautogram.py This is not a Tautogram
# False

The sentence may contain commas and periods, but no other special characters, only upper and lower case letters and spaces.
Its size is 98 bytes. Is there a smaller solution in any language?

Is it intended as a tips question limited to Python? If so, these both tags should be added.

Heya friend! This site is usually reserved for explicitly defined problems. Things like "can the input contain punctuation" should be answered before posting, but other than that this is a great first question comparatively to the other new-user questions we usually see. Judging by your examples I'd just clarify that the only characters in the input will be "[A-Za-z ]" and your question will be purely objective. I'd scope out some other questions around here, else this may honestly be a better fit on overflow.

What do you mean by punctuation? Which characters are included?

@MagicOctopusUrn Sometimes when you ask for a short solution in stackOverflow the refer to this site :)

@EmbodimentofIgnorance Commas and periods, since others are special characters

Welcome to PPCG! A few more test cases (including punctuation) would be a great addition to this challenge.

Btw, in your code, you can take out the if, printing the boolean works

Need the 2 outputs be consistent or will any truthy/falsey values suffice?

Some potential extra test cases, to clarify: Flowers flourish, from France, Flowers flourish ,from France, Flowers flourish from France., Flowers flourish from France ., .Flowers flourish from France, Flo.wers flourish fr,om France

With no definition of a sentence structure this is unclear. Is ", ," a valid input? Is ",This tolerable" or " This tolerable"? What about "This , ,tolerable, "? ...and what should they output?

I'm surprised so many regulars answered rather than seeking clarity!

@JonathanAllan, it was pretty clear to me when originally posted that we should split on spaces and then check if the first character of every string was the same.

@Shaggy only because you made assumptions (I agree they were most likely correct, but as it stands they may not be).

@JonathanAllan I answered based on the logical definition of "given a sentence." This , ,tolerable,  isn't a sentence, for example.

@AdmBorkBork "may contain" does not specify this and could allow perfectly normal (English?) sentences to be edited to less normal ones. Regardless, this is not a fruitful discussion; I already said "most likely correct", but I cannot make it so; that is the OPs prerogative.

05AB1E, 5 bytes
l#€нË

Try it online!

l      # Lowercase input.
 #     # Split on spaces.
  €н   # a[0] of each.
    Ë  # All equal?

Did this on mobile excuse the no explanation.

Python 2, 47 bytes
lambda s:len(set(zip(*s.lower().split())[0]))<2

Try it online!
Came up with this on mobile. Can probably be golfed more.

PowerShell, 57 50 41 bytes
(-split$args|% s*g 0 1|sort -u).count-eq1

Try it online!
Takes input and splits it on whitespace. Loops through each word, and grabs the first letter by taking the substring starting at position 0 and going for 1 character. Then sorts the letters (case-insensitive by default) with the -unique flag to pull out only one copy of each letter, and verifies the count of those names are -equal to 1. Output is implicit.
-9 bytes thanks to mazzy.

41 bytes

35 bytes with regexp

@mazzy fixed trying to understand the intention

@mazzy I'll let you post the regex version when the question is reopened. It's different enough to warrant its own answer.

I'm agree. but this question is put on hold, so I can't create a new answer.

Clojure, 80 bytes
Try it online!. TIO doesn't support Clojure's standard String library though, so the first version will throw a "Can't find lower-case" error.
(fn[s](use '[clojure.string])(apply =(map first(map lower-case(split s #" ")))))

Ungolfed:
(defn tautogram? [s]
  (use '[clojure.string])
  (->> (split s #" ") ; Get words
       (map lower-case)
       (map first) ; Get first letter of each word
       (apply =))) ; And make sure they're all the same

I made a version that avoids the import:
(fn [s](apply =(map #(if(<(-(int %)32)65)(int %)(-(int %) 32))(map first(take-nth 2(partition-by #(= %\ )s))))))

 ; -----

(defn tautogram? [s]
  (->> s
       (partition-by #(= % \ )) ; Split into words
       (take-nth 2) ; Remove spaces
       (map first) ; Get first letter
       ; Convert to uppercased letter code
       (map #(if (< (- (int %) 32) 65) ; If attempting to uppercase puts the letter out of range,
               (int %) ; Go with the current code
               (- (int %) 32))) ; Else go with the uppercased  code
       (apply =))) ; And check if they're all equal

But it's 112 Bytes.

Here's my Racket solution:
(define(f s)(apply char=?(map(λ(x)(char-upcase(car(string->list x))))(string-split s))))

Much shorter in PicoLisp: (de f(s)(apply =(mapcar car(split(chop(lowc s))" "))))

Haskell, 71 bytes
f s|c<-fromEnum.head<$>words s=all(`elem`[-32,0,32]).zipWith(-)c$tail c

Try it online!

Haskell, 61 58 bytes (using Data.Char.toLower)

Saved three bytes thanks to nimi.

import Data.Char
(all=<<(==).head).(toLower.head<$>).words

Try it online!

05AB1E (legacy), 5 bytes
#€¬uË

Try it online!
#     // split on spaces
 €¬   // get the first letter of each word
   uË // check if they're the same (uppercase) letter

Perl 5 (-p), 20 bytes
$_=!/^(.).* (?!\1)/i

TIO
following comments in case bad punctuation (31 bytes)
$_=!/^\W*+(.).*(?=\b\w)(?!\1)/i

31 bytes
otherwise there's another approach, also with 31 bytes:
$h{ord()%32}++for/\w+/g;$_=2>%h

31 bytes other

what about punctuations? what about spaces or punctuations at the strart of string?

this answer works for the given test cases, could be improved depending the requirements could be $_=!/^\W*+(.).*(?=\b\w)(?!\1)/i

but reading carefuly the question and the given solution, spaces at beginning can't occur because the spaces are used by the shell to split the arguments. The program checks only that all arguments start with the same character

Brachylog, 5 bytes
ḷṇ₁hᵛ

Try it online!
         The input
ḷ        lowercased
 ṇ₁      and split on spaces
   hᵛ    is a list of elements which all start with the same thing.

I just now noticed that this has to be able to handle punctuation, but without any punctuated test cases I can't tell if this does or doesn't still work...

JavaScript (Node.js), 54 bytes
s=>!s.match(/\b\w+/g).some(p=s=>p-(p=Buffer(s)[0]&31))

Try it online!
Or 47 bytes if each word (but the first) is guaranteed to be preceded by a space.

or in one regex or with a space instead of \W

@NahuelFouilleul, using test saves another byte.

@NahuelFouilleul You should probably post is separately.

already posted the perl version, i don't master as well javascript, i'm happy to give you a hint

Japt -¡, 5 bytes
¸mÎro

Try it
¸mÎro     :Implicit input of string
¸         :Split on spaces
 m        :Map
  Î       :  Get first character
   r      :Reduce by
    o     :  Keeping the characters that appear in both, case-insensitive
          :Implicit output as boolean

C# (Visual C# Interactive Compiler), 41 bytes
n=>n.Split().GroupBy(c=>c[0]|32).Single()

Throws an exception if false, nothing if true.
Try it online!

Perl 6, 19 bytes
{[eq] m:g/<<./}o&lc

Try it online!

Java, (36 bytes)
s->!s.matches("(?i)(.).* (?!\\1).*")

TIO

I think the input is allowed to start with a space, and this doesn't work for input like that.

indeed it's not a test case, but this can be handled adding (?> *), using atomic group to match space at beginning and to pevent bactracking. just  * doesn't work because after failing matches will backtrack  * to match empty string

however reading the question again spaces can occur at the beginning beause in the example the usage is to pass the words as argument and spaces are shell argument delimiter

source: Stack Exchange

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

sort: votes


text:
Counting the number of restricted forests on the Möbius ladder of length n
OEIS sequence A020872 counts the number of restricted forests on the Möbius ladder Mn.
The Challenge
The challenge is to write a program that takes an integer as an input n > 1 and returns A020872(n), the number of restricted forests on the Möbius ladder Mn. This is code-golf, so shortest code wins.
(An ulterior motive is to perhaps extend the length of this sequence by a bit.)
Definitions
A restricted forest is a partition of the graph such that each part is either a (undirected) path or an isolated vertex.
The Möbius ladder Mn is a graph which can be thought of the 2n-gon with diagonals drawn between all opposite vertices.
Example
Here are the 34 restricted forests on M2 (a square with diagonals drawn). Notice that the first graph is partitioned into four isolated vertices, the second is partitioned into one path and two isolated vertices, etc.

Test cases from 2 to 12: 34, 241, 1582, 10204, 65197, 415076, 2638366, 16759249, 106427154, 675771276, 4290678337. I'm not sure why input 1 isn't also required, with output 2.

@PeterTaylor, Thanks for adding those terms to OEIS! I excluded input 1 because M_1 isn't clearly defined in the Wikipedia article. (In particular, either it has multiple edges or it is not a cubic graph.)

This actually sounds like a good candidate for a fastest-code or fastest-algorithm challenge.

Further test cases (generation code): 13 to 17 are 27242281044, 172964658642, 1098170541121, 6972388689086, 44268329738124

Right, I think your ulterior motive is more than satisfied.

CJam (58 56 chars)
Some characters unprintable, and one is a tab which will be mangled by the StackExchange software:
"¶3¬î¿Á·    7ÛÈmÈÚÚ¡"256b454b212f-{__W%.*A<1b+}qi*-4=

Online demo. This will run online for n=400 in about three seconds.
Encoded by xxd:
0000000: 22b6 0233 93ac eebf c1b7 0609 3794 dbc8  "..3........7...
0000010: 6dc8 1015 dada a122 3235 3662 3435 3462  m......"256b454b
0000020: 3231 3266 2d7b 5f5f 5725 2e2a 413c 3162  212f-{__W%.*A<1b
0000030: 2b7d 7169 2a2d 343d                      +}qi*-4=

Explanation
A Möbius ladder is basically a ladder with two extra edges. Given a restricted forest on a ladder, it can be lifted to between 1 and 4 restricted forests on the Möbius ladder. The edges can be added provided that doesn't create a vertex of degree 3 or a cycle. The degrees of the four corners and their interconnections form 116 classes of restricted forest on the ladder, although some of them are equivalent due to symmetries of the rectangle. I wrote a program to analyse the extensions of a ladder of length n to one of length n+1, and then merged the classes into 26 equivalence classes. This gives a closed form
$$\begin{bmatrix} 1 \\ 1 \\ 1 \\ 1\end{bmatrix}^T
\begin{bmatrix}
    1 & 2 & 2 & 0 \\
    1 & 2 & 1 & 1 \\
    2 & 3 & 4 & 1 \\
    0 & 0 & 1 & 0 \\
\end{bmatrix}^{n-2}
\begin{bmatrix} 0 \\ 1 \\ 0 \\ 0\end{bmatrix} + $$
$$\begin{bmatrix} 2 \\ 2 \\ 1 \\ 1 \\ 1 \\ 1 \\ 1 \\ 2 \\ 2\end{bmatrix}^T
\begin{bmatrix}
    2 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
    1 & 0 & 1 & 0 & 0 & 1 & 0 & 1 & 0 \\
    0 & 0 & 2 & 0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 \\
    0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 \\
    1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\
    0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 1 \\
    3 & 2 & 2 & 1 & 1 & 2 & 1 & 4 & 2 \\
    0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 2 \\
\end{bmatrix}^{n-2}
\begin{bmatrix} 0 \\ 0 \\ 2 \\ 2 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0\end{bmatrix} + $$
$$\begin{bmatrix} 1 \\ 2 \\ 4 \\ 4 \\ 1 \\ 1 \\ 3 \\ 2 \\ 2 \\ 2 \\ 3 \\ 4 \\ 4\end{bmatrix}^T
\begin{bmatrix}
    0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
    0 & 2 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
    0 & 1 & 2 & 0 & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 & 1 \\
    1 & 0 & 0 & 4 & 0 & 0 & 3 & 0 & 0 & 2 & 0 & 0 & 0 \\
    0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 2 & 1 & 0 \\
    0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 \\
    1 & 0 & 0 & 1 & 0 & 0 & 2 & 0 & 0 & 1 & 0 & 0 & 0 \\
    0 & 1 & 2 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 2 \\
    0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\
    0 & 0 & 0 & 2 & 0 & 0 & 2 & 0 & 0 & 1 & 0 & 0 & 0 \\
    0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\
    0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 2 & 2 & 0 \\
    0 & 2 & 3 & 0 & 1 & 1 & 0 & 2 & 1 & 0 & 1 & 2 & 4 \\
\end{bmatrix}^{n-2}
\begin{bmatrix} 1 \\ 0 \\ 1 \\ 1 \\ 2 \\ 0 \\ 1 \\ 0 \\ 0 \\ 0 \\ 1 \\ 2 \\ 1\end{bmatrix}$$
so values can be computed fast by taking three linear recurrences and then adding them, but this isn't looking very golfy.
However, if we take the irreducible factors of the various characteristic polynomials and multiply together one of each (ignoring multiplicity) we get a polynomial of degree 10 which gives a working single linear recurrence.
Constructive approach (58 chars)
qi:Q2*,Wa*e!{Wa/{_W%e<}%$}%_&{{,1>},2few:~{:-z(Q(%}%0-!},,

Online demo. It will run online for n=2 without problems and for n=3 with a bit of patience. For n=1 it crashes, but since OP has chosen to exclude that case from the requirements it's not a fundamental problem.
Dissection
qi:Q          e# Take input from stdin, parse to int, store in Q
2*,Wa*e!      e# Take all permutations of (0, -1, 1, -1, 2, -1, ..., -1, 2*Q-1)
{             e# Map to canonical form...
  Wa/         e#   Split around the -1s
  {_W%e<}%    e#   Reverse paths where necessary to get a canonical form
  $           e#   Sort paths
}%
_&            e# Filter to distinct path sets
{             e# Filter to path sets with valid paths:
  {,1>},      e#   Ignore paths with fewer than two elements (can't be invalid; break 2ew)
  2few:~      e#   Break paths into their edges
  {:-z(Q(%}%  e#   The difference between the endpoints of an edge should be +/-1 or Q (mod 2Q)
              e#   So their absolute values should be 1, Q, 2Q-1.
              e#   d => (abs(d)-1) % (Q-1) maps those differences, and no other possible ones, to 0
              e#   NB {:-zQ(%}% to map them all to 1 would save a byte, but wouldn't work for Q=2
  0-!         e#   Test that all values obtained are 0
},
,             e# Count the filtered distinct path sets

A more efficient version takes 98 bytes:
qi2*:Q{a{__0=[1Q2/Q(]f+Qf%_&1$-\f{+E}~}:E~}/]{_W%>!},:MW=0{_{M\f{__3$_@&@:e<@|^{=}{^j}?}1b}{,)}?}j

Online demo
This builds the possible paths by depth-first search, then uses a memoised function which counts the possible restricted forests for a given set of vertices. The function works recursively on the basis that any restricted forest for a given non-empty set of vertices consists of a path containing the smallest vertex and a restricted forest covering the vertices not in that path.

On the grid graph, this can be described with a linear recursion, so it wouldn’t surprise me to find out that this is nice.

JavaScript (ES6),  160 158  146 bytes
n=>(g=(e,v,p)=>[...Array(N=2*n),N-1,1,n].reduce((s,x,i)=>(m=1<<(x=i<N?i:(p+x)%N))&v?s:s+g((i>=N)/p?[...e,1<<p|m]:e,v|m,x),g[e.sort()]^(g[e]=1)))``

Try it online!
Notes:

This is quite inefficient and will time-out on TIO for \$n>4\$.
\$a(5) = 10204\$ was found in a bit less than 3 minutes on my laptop.

Commented
n => (                        // n = input
  g = (                       // g = recursive function taking:
    e,                        //   e[] = array holding visited edges
    v,                        //   v   = bitmask holding visited vertices
    p                         //   p   = previous vertex
  ) =>                        // we iterate over an array of N + 3 entries, where N = 2n:
    [ ...Array(N = 2 * n),    //   - 0...N-1: each vertex of the N-gon (starting points)
      N - 1,                  //   - N      : previous vertex \
      1,                      //   - N+1    : next vertex      }-- connected to p
      n                       //   - N+2    : opposite vertex /
    ].reduce((s, x, i) =>     // reduce() loop with s = accumulator, x = vertex, i = index:
      ( m = 1 << (            //   m is a bitmask where only the x-th bit is set
          x = i < N           //   and x is either:
              ? i             //   - i if i < N
              : (p + x) % N   //   - or (p + x) mod N otherwise
      )) & v ?                //   if this vertex was already visited:
        s                     //     leave s unchanged
      :                       //   else:
        s +                   //     add to s
        g(                    //     the result of a recursive call:
          (i >= N) / p ?      //       if p and x are connected (i >= N and p is defined):
            [ ...e,           //         append to e[]:
              1 << p | m      //           the edge formed by p and x
            ]                 //           and uniquely identified by 1 << p | 1 << x
          :                   //       else:
            e,                //         leave e[] unchanged
          v | m,              //       mark the vertex x as visited
          x                   //       previous vertex = x
        ),                    //     end of recursive call
      g[e.sort()] ^           //   sort the edges and yield 1 if this list of edges has not
      (g[e] = 1)              //   already been encountered; either way, save it in g
    )                         // end of reduce()
)``                           // initial call to g with e = ['']

Jelly, 61 58 bytes
®R,³;Ø+
Ḥ©Ḷµ1ị+¢%®ḟ€;€€1¦-Ẏ;€)Ẏ$ƬẎṣ€-Ẉ’ẠƊƇU¹Ø.ị>/Ɗ?€€Ṣ€QL‘

Try it online!
This is the shorter version; it is optimised for shorter length versus algorithmic complexity and speed.
Jelly, 85 bytes
%®ḟ
1ị+³;Ø+¤ç,1ị+®_3¤R‘¤Ʋç;€-Ʋ“”2ị>-Ʋ?Ẏ;€
Ḥ©Ḷ;€-Ç€Ẏ$ƬẎṣ€-Ẉ=1ẸƊÐḟU¹1ị>0ị$Ʋ?€€Ṣ€QL‘+=2$

Try it online!
Here’s a longer version that adds extra code to avoid trying redundant paths. The check for n=2 at the end is to cope with the specific case for n=2 which looks like a red/blue cross in the example and isn’t generated by this code. This second version completed n=4 in less than 13 seconds on TIO, but times out for higher numbers.

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


text:
Next number with k fives
Challenge:
Your program will take two integers n and k as input, and output the smallest integer greater than (but not equal to) n that contains at least k occurrences of the digit 5.
You can assume 1 ≤ k ≤ 15 and 1 ≤ n < 10**15.
This is a restricted-time challenge. Your program must run on TIO for all of the test cases and complete within 10 seconds in total.
General rules:

This is code-golf, so the shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for any programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call. The function parameters may be taken in either order, but please specify in your answer.
Default Loopholes are forbidden.
You must add a link with a test for your code (i.e. TIO).
The answer header should list the score in bytes but also the total time taken for all test cases on TIO
If your language is not on TIO, the code should finish far under 10 seconds on your machine so that you're confident it's fast enough on any reasonable computer.
Adding an explanation for your answer is highly recommended.

Test Cases:
(n, k) ->  output
(53, 2) -> 55
(55, 1) -> 56
(65, 1) -> 75
(99, 1) -> 105
(555, 3) -> 1555
(557, 1) -> 558
(5559, 3) -> 5565
(6339757858743, 5) -> 6339757859555
(99999999999999, 15) -> 555555555555555

Program Example:
This program is correct.

Note that timing on TIO is not perfectly reliable, though while insufficient for [tag:fastest-code] it probably suffices for [tag:restricted-time].

I assume the correct answer for (n, k) = (45, 1) is 50? Some of the answers get this wrong.

R, 85 84 76 74 bytes, 0.250s on TIO
f=function(n,k,m=nchar(gsub("[^5]","",n+1))-k)`if`(m<0,f(n+.1^m/50,k),n+1)

Try it online!
-1 byte thanks to Robert S.
-8 bytes thanks to Giuseppe.
The nchar(gsub(...)) part counts the number of 5s.
A simple recursive solution would be to increment by 1 until the answer is found, but this would not meet the time restriction. To meet the time restriction, this function makes use of the fact that if there are p missing 5s, we can increment by 2*10^(p-2) (represented as the golfier .1^m/50, with m=-p).
Note that when p=1, the increment becomes 0.2. This is OK, since after 5 steps we come back to an integer, and none of the decimal numbers encountered in the mean time have an extra 5. If instead we were to increment by 5*10^(p-2) or by 1*10^(p-2), then we would find f(24, 1)=24.5 instead of 25 for example.

Save 1 byte by using an if function variant.

@RobertS. Thanks. I didn't know about that variant; is there somewhere I can read more about it?

Definitely. Check out the tips for golfing in R post!

Also you can ask questions in the R golfer chat which isn't very active but it's better than nothing :-)

76 bytes -- I'm not really sure what the a was doing, so I removed it and it seems to be OK.

@Giuseppe Of course, thanks! I needed the a in a previous version to avoid outputting e.g. f(55, 2)=55, and didn't realize that it wasn't needed anymore.

Jelly, 37 bytes 0.113 s on TIO
»DL‘Ɗ}©5xḌ_DḌÐƤ;®ŻṬ€UḌ¤+⁹D=5S>ʋƇ⁸’¤ḟṂ

Try it online!
This works by

working out the maximum of the number of digits in the input plus one and k, and making a number with that many fives
Subtracting the input from that number
Generating all of the suffixes of that number
Also generating all the powers of ten from 1 up to the next one greater than the input
Adds each of the numbers in 3 and 4 to the input
Removes answers with too few 5’s
Filters out the input from the answers
And returns the minimum

@KevinCruijssen sorry I meant that many fives

Hmm.. Seems to fail for [557,1] (results in 558 instead of 560); test case in the description seems incorrect, since [557,2] should result in 558 instead.

@KevinCruijssen I asked about this: it’s at least k 5s not exactly k.

Ah ok, then it's correct. :)

05AB1E, 33 32 31 bytes
sg>‚à©5s×α.s0š®Ý°0šâO+IKʒ5¢¹@}ß

Port of @NickKennedy's amazing approach in his Jelly answer, so make sure to upvote him!!
Takes \$k\$ as first input; \$n\$ as second.
Try it online or verify all test cases.
Explanation:
sg>                # Get the length+1 of the second (implicit) input-integer
   ‚à              # Pair it with the first input-integer, and leave the maximum
     ©             # Store this maximum in the register (without popping)
      5s×          # Create an integer (actually, create a string..) with that many 5s
         α         # Take the absolute difference with the second (implicit) input
          .s       # Get the prefixes of that number
            0ª     # Prepended with an additional 0
    ®              # Get the maximum from the register again
     Ý             # Create a list in the range [0, max]
      °            # Raise 10 to the power of each integer
       0ª          # And also prepend an additional 0 to this list
              â    # Then create each possible pair of these two lists
               O   # Sum each pair
                +  # Add the second input to each sum
IK                 # Then remove the second input from this list (if present)
  ʒ                # And filter this list by:
   5¢              #  Count the amount of 5s in the integer
     ¹@            #  And check if this count is larger than or equal to the first input
       }ß          # After the filter: only leave the lowest number
                   # (which is output implicitly as result)

Stax, 17 bytes (6.861 total seconds on TIO)
≈ª╞¥é£ôñτ←╝α┴╢JLd

Run and debug it
This program takes k and n on standard input separated by space.  Stax doesn't have a convenient way to run multiple test cases on TIO, so I ran each input separately and added up the time.  99% of the time is in the interpreter process startup.  Using the javascript interpreter on staxlang.xyz, all test cases run in 50 milliseconds.
Last test case on Try it online!
Procedure:

Increment input
If there are enough 5s, terminate and print
t= number of trailing 5s in the number
Add 10 ** t
Goto 2

Python 3, 144 98 86 75 bytes
f=lambda N,k,d=1:k>str(-~N).count("5")and f(N+-(-~N//d+5)%10*d,k,d*10)or-~N

Try it online!
This is \$\mathcal{O}(k)\$, (system time .008 on TIO) and has golfed well with some advice from ASCII-only.
The algorithm is to round up each digit (starting from the least-significant one) to the nearest value of 5 until the new number's decimal representation has the desired count.
The original approach used an abortable (D=iter(range(k)) and list(D) at work here) list comprehension, but @ASCII-only has convinced me that will never win code-golf. I dislike recursion, but if the algorithm is written to minimize recursion-depth, then a future compiler/interpreter will be smart enough to re-implement it as a while loop.

94?

93?

88?

86?

good-golfing @ASCII-only You are going to have to explain to me why N+-(...) works but N-(...) fails.

it's (-(-~n//l+5))%10 is why

Good old unary minus.  In this case, (15-(n+N)//d)%10 also works.

also Stackless Python is a thing, basically turns all recursion into while loops :P

Perl 5 -pl, 44 bytes
$k=<>;$_++;s/.*?(?=5*$)/1+$&/e while$k>y/5//

Try it online!
Finds what the number is without its trailing 5s.  Increments that portion by 1.  Continues until sufficient 5s are in the number.  Takes about .012s on TIO to run all test cases.

PHP, 109 97 bytes, (< 0.03s on TIO)
function($n,$k){++$n;do if(count_chars($n)[53]>=$k)return$n;while($n+=10**strspn(strrev($n),5));}

Try it online!
Based on @recursive's algorithm.

Retina, 63 bytes
.+$
*
^.+
$.(*__
/((5)|.)+¶(?<-2>_)+$/^+`^.*?(?=5*¶)
$.(*__
1G`

Try it online! Takes n and k on separate lines, but link includes header that converts the test suite into the appropriate format. Explanation:
.+$
*

Convert k to unary.
^.+
$.(*__

Increment n. The * repeats its right argument (here the first _ character) the number of times given by its left argument (which, as here, defaults to the match). This results in a string of that length. The $( (the ) is implied) then concatenates that with the second _ and the . causes the resulting length to be taken. (Actually Retina 1 is cleverer than that and just performs the calculation on the underlying lengths in the first place.)
/((5)|.)+¶(?<-2>_)+$/

Test whether enough 5s can be found in n to match the _s of the unary representation of k. This test has been golfed and would be three times faster with ^ added after the initial / and faster still if [^5] was used instead of ..
^+`

Until the test passes...
^.*?(?=5*¶)
$.(*__

... increment n but exclude trailing 5s.
1G`

Delete k.

C (gcc), 159 158 152 150 149 bytes, ~0.04 s
Outputs the answer to STDOUT, with leading zeroes.
-3 byte thanks to ceilingcat
m,j;f(n,k)long n;{char*t,s[17];for(t=s+sprintf(s,"%016ld",++n),m=n=0;m<k&--t>s;m<k&&*t-53?n=*t>53,*t=53:0)for(*t+=n,m=j=17;j--;)m-=s[j]!=53;puts(s);}

Try it online!

Ruby, 41 bytes
->n,k{(n+1..).find{_1.to_s.count(?5)>=k}}

Attempt This Online!


text:
Lay out the Carpet
Inspired by this SO question.
Challenge:
Input:

A string \$s\$
A character \$c\$

Output:
Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may sound pretty vague, so here's an example:
Input: \$s\$ = string, \$c\$ = .
Output:
..........g..........
........g.n.g........
......g.n.i.n.g......
....g.n.i.r.i.n.g....
..g.n.i.r.t.r.i.n.g..
g.n.i.r.t.s.t.r.i.n.g
..g.n.i.r.t.r.i.n.g..
....g.n.i.r.i.n.g....
......g.n.i.n.g......
........g.n.g........
..........g..........

Challenge rules:

Input-string may also be a list of characters
Output may also be a list of string-lines or matrix of characters
Input-string and character are guaranteed to be non-empty
The string is guaranteed to not contain the character
Both string and character will only be printable ASCII (unicode range [32,126], space ' ' to and including tilde '~')

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
Input: \$s\$ = 11111, \$c=\$ = 0
Output:
00000000100000000
00000010101000000
00001010101010000
00101010101010100
10101010101010101
00101010101010100
00001010101010000
00000010101000000
00000000100000000

Input: \$s\$ = 12345ABCDEF, \$c\$ = #
Output:
####################F####################
##################F#E#F##################
################F#E#D#E#F################
##############F#E#D#C#D#E#F##############
############F#E#D#C#B#C#D#E#F############
##########F#E#D#C#B#A#B#C#D#E#F##########
########F#E#D#C#B#A#5#A#B#C#D#E#F########
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
F#E#D#C#B#A#5#4#3#2#1#2#3#4#5#A#B#C#D#E#F
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
########F#E#D#C#B#A#5#A#B#C#D#E#F########
##########F#E#D#C#B#A#B#C#D#E#F##########
############F#E#D#C#B#C#D#E#F############
##############F#E#D#C#D#E#F##############
################F#E#D#E#F################
##################F#E#F##################
####################F####################

Input: \$s\$ = @+-|-o-|-O, \$c\$ = :
Output:
::::::::::::::::::O::::::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
O:-:|:-:o:-:|:-:+:@:+:-:|:-:o:-:|:-:O
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::::::O::::::::::::::::::

Input: \$s\$ = AB, \$c\$ = c
Output:
ccBcc
BcAcB
ccBcc

Input: \$s\$ = ~, \$c\$ = X
Output:
~

Input: \$s\$ = /\^/\, \$c\$ = X
Output:
XXXXXXXX\XXXXXXXX
XXXXXX\X/X\XXXXXX
XXXX\X/X^X/X\XXXX
XX\X/X^X\X^X/X\XX
\X/X^X\X/X\X^X/X\
XX\X/X^X\X^X/X\XX
XXXX\X/X^X/X\XXXX
XXXXXX\X/X\XXXXXX
XXXXXXXX\XXXXXXXX

Can the string contain spaces?

@Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.

This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().

What should happen if $s$ is empty?

@SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)

@KevinCruijssen Oops, missed that! Note that the character is non-empty by definition, but there's nothing wrong with a bit of clarification (what you already have).

Canvas, 8 bytes
Ｒ±［］／┼┼＊

Try it here!
7 bytes but mirrors a bunch of chars.

R, 118 95 92 bytes
function(a,d,n=length(a),I=c(n:1,1:n)[-n])for(i in I-1)write(c(a,d)[pmin(I+i,n+1)],1,n*2,,d)

Try it online!
Thanks to:

Giuseppe for fixing an error and a golf
Aaron Hayman for 22 bytes worth of golf

I guess I need to drop my aversion to for loops in R, at least for golfing.

@Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!

This for 98 looks closer to your solution than mine Try it online!

@Aaron, Wow, wouldn't even think that this approach could be pushed down so much! Golfed a few more bytes on top of that.

can take off another two with a bit of rearrangement: Try it online!

Alternately, if you prefer outer to for loops, you can get 93 bytes this way

@AaronHayman or else this 92 byter combining the pmin logic with the rearrangement :-)

J, 59 56 bytes
,{~[:((0-2*#)}.\[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#\@]

Try it online!
Too long solution for J ... (entirely my fault)

Here’s 39

@FrownyFrog Thanks, I think you should post it as your own solution

R,  an ugly 118 bytes version
By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.
function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)

Try it online!
R, 161 157 bytes
saved 4 bytes by using ifelse instead of conditionally modifying y
function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
'),sep='')

Try it online!
ungolfed and commented
function(S,C){
    s=el(strsplit(S,''))
    l=nchar(S)
    L=4*l-3
    k=2*l-1
    y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
    y[!!y%%1]=l+1  # set non integers to one more than length of string
    y[y>l]=l+1     # set number beyond length of string to one more than length of string
    M = rbind(matrix(c(s,C)[y],L),'\n') # build matrix and add line returns
    cat(M,sep='') # print the matrix as a string
}

hmmm, seems like the longest answer so far!

Oh dear, should have looked at the question better

@KevinCruijssen I have fixed it now

for +15 bytes, you can make your ugly answer ascii-art: Try it online!

K (ngn/k), 39 bytes
{1_',/'y,''2{+x,1_|x}/(#x)':1_,/+y,'|x}

Try it online!
{ } function with arguments x (the string s) and y (the character c)
|x reverse x
y,' prepend y to each
+ transpose
,/ concat
1_ drop first char
at this point we have a string of length(x) instances of y followed by the characters from x
#x length of x
(#x)': sliding window of that many consecutive chars
2{ }/ do twice
+x,1_|x join x with the reversed x without its first element, and transpose
y,'' prepend y to each each
,/' concat each
1_' drop one from each

J, 35 34  33 bytes
,{~1j1(}:@#"1{:(<*-)1-|+/|)i:@-&#

Try it online!
Right to left:
-&# Length of \$c\$ minus the length of \$s\$
i: Range from negative n to n
1-|+/| Absolute value, outer sum with absolute value, subtract from 1
{: (<*-) Compare the matrix with the end of the range (the -&#), 0 for less than or equal, 1 otherwise. Also subtract the matrix from the end of range. Multiply together. The double subtraction saves a byte and gives something like this
 0  0 _1  0  0
 0 _1 _2 _1  0
_1 _2 _3 _2 _1
 0 _1 _2 _1  0
 0  0 _1  0  0

Negative indices start from -1 like in python. The only thing left is to insert the columns of zeroes.
1j1(   #"1 for each row, repeat each element 1 time and pad with one 0
    }:@    then drop the last one (zero)
,{~concat \$c\$ and \$s\$ and index into that
Many thanks to Galen Ivanov for the algorithm.

Would you mind adding an explanation? I'm not that familiar with J.

Python 2, 97 96 90 84 bytes
def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]

Try it online!

05AB1E, 15 11 bytes
.sûsζøsýí€û

Try it online!
or as a Test Suite
Explanation
.s            # push suffixes of input
  û           # palendromize this list
   sζ         # transpose using the second input as filler
     ø        # transpose back
      sý      # merge each on the second input
        í     # reverse each row
         €û   # palendromize each row

@KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.

"Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)

@KevinCruijssen Ah right. I glanced over that part. Thanks :)

Ruby, 95 84 75 bytes
->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}

Try it online!
Takes input string as an array of chars. Returns an array of strings.

Japt, 15 bytes
Returns an array of lines
Ôå+ ®¬qV êÃûV ê

Try it
Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
Ô                   :Reverse U
 å+                 :Prefixes
    ®               :Map
     ¬              :  Split
      qV            :  Join with V
         ê          :  Palindromise
          Ã         :End map
           ûV       :Centre pad each string with V, to the length of the longest
              ê     :Palindromise

Charcoal, 15 bytes
ＵＢηＥθ✂θκ‖Ｏ↑←ＵＥ¹

Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:
ＵＢη

Set the background to the second input c.
Ｅθ✂θκ

Map over the first input s to generate all suffixes and implicitly print them on separate lines.
‖Ｏ↑←

Reflect horizontally and vertically.
ＵＥ¹

Add extra space horizontally.

APL (Dyalog Classic), 32 31 bytes
(⍉1↓¯1↓⊖⍪1↓⊢)⍣2∘↑(≢⊣),/,¨,2⍴¨⊢¨

Try it online!

Pip, 24 20 bytes
QPRV:_JbMa@>RV,#aZDb

Use the -l flag to get human-readable output. Try it online!
Explanation
QPRV:_JbMa@>RV,#aZDb
                      a,b are cmdline args (implicit)
                a     1st cmdline arg (the string)
               #      Length
              ,       Range
            RV        Reverse
         a@>          Take slices of a starting at those indices
                 ZDb  Zip the list of slices together, filling out missing values in
                      the matrix with b (the character)
        M             To each row, map this function:
     _Jb               Join on b
  RV:                 Reverse (making top row the bottom and vice versa)
QP                    Quad-palindromize: reflect downward and rightward, with overlap

For example, with inputs of abcd and .:
RV,#a
 [3 2 1 0]
a@>
 ["d" "cd" "bcd" "abcd"]
ZDb
 [['d 'c 'b 'a] ['. 'd 'c 'b] ['. '. 'd 'c] ['. '. '. 'd]]
_JbM
 ["d.c.b.a" "..d.c.b" "....d.c" "......d"]
RV:
 ["......d" "....d.c" "..d.c.b" "d.c.b.a"]
QP
 ["......d......" "....d.c.d...." "..d.c.b.c.d.." "d.c.b.a.b.c.d" "..d.c.b.c.d.." "....d.c.d...." "......d......"]

Perl 6, 79 bytes
->\c{{map {join c,g $_ X||c},g .[^*X+(^$_,)]}o*.comb}
my&g={.[$_-1...0...$_-1]}

Try it online!
Anonymous codeblock that takes input curried (like f(char)(string)) and returns a list of lines. I think a different approach would be shorter.
Explanation:
my&g={.[$_-1...0...$_-1]}  # Helper function to palindromise a list
->\c{                                                }  # Code block that takes a char
     {                                       }o*.comb   # And returns a function
                                .[^*X+(^$_,)]  # Get all prefixes with end padding
                                               # e.g. "str" => [["r",Nil,Nil]
                                                                ["t","r",Nil]
                                                                ["s","t","r"]]
                              g   # Palindromise the lsit
       map {                },    # Map each element to
                     $_ X||c      # Replace all Nils with the character
                   g              # Palindromise it
            join c,               # And join by the character

Attache, 57 bytes
${q:=#x-1Bounce!Bounce@Join&y@PadLeft&y&#x=>x[q::(q::0)]}

Try it online! Output is a list of lines.
Explanation
?? parameters: x, y
${
    ?? q is length of x - 1
    q:=#x-1
    ?? Reflect, collapsing middle:
    Bounce!
        ?? Function:
            ?? Reflect,
            Bounce@
            ?? Joined by y,
            Join&y@
            ?? padded to the length of x with y
            PadLeft&y&#x
        ?? Mapped over
        =>
            ?? The elements of x at
            x[
                ?? decreasing range from q to
                q::(
                    ?? each element in the range from q to 0
                    q::0
                )
            ]
}

Wolfram Language (Mathematica), 121 bytes
Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&

Try it online!

Japt, 16 bytes
Note: I'll golf it :)
Ôå+ ®¬qVÃùV mê ê

Try it online!

It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)

@KevinCruijssen Yeah, both are almost the same, for now

@KevinCruijssen, Luis developed this independently from my solution.

PowerShell, 120 bytes
param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]

Try it online!
Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).

Japt, 15 bytes
Ôå+ ê ®ê ¬qV
ûV

Try it

PowerShell, 82 83 bytes
+2 bytes thanks Veskah: the single character case bug fixed
-1 byte: The rule Input-string may also be a list of characters used
$c,$s=$args
($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}

Try it online!
Less golfed:
$c,$s=$args
$southEast = $s|%{
    (-join$s|% substring $i) + $c*$i++
}
$range=$i..0+1..$i
$southEast[$range]|%{
    "$_"[$range]-join$c
}

Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~

Jelly, 11 bytes
jÐƤṚzṚŒḄZŒḄ

Try it online!
Left argument: \$s\$.
Right argument: \$c\$ (as a single character, not as a string).
Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the \n-joined output).

TSQL query, 191 bytes
In MS-SQL Server Management Studio press Ctrl-T before running this query, this will change the output to text.
This script is building up the output from left to right in one long "string", calculating the value to put in each position. The output is limited to 4096 characters.
Golfed:
SELECT
string_agg(iif(h>k/2,@y,substring(@,h+1,1))+iif(-~n%k=0,'
',@y),'')FROM(SELECT
abs(k/2-n%k)+abs(k/2-n/k)h,*FROM(SELECT
number n,len(@)*2-1k,*FROM spt_values)c)d
WHERE n<k*k and'P'=type

Ungolfed:
USE master
DECLARE
@y char='.',
@ varchar(20) = 'abcd'

SELECT
  string_agg(iif(h>k/2,@y,substring(@,h+1,1))+iif(-~n%k=0,'
',@y),'')
FROM
(
  SELECT
    abs(k/2-n%k)+abs(k/2-n/k)h,*
  FROM
  (
    SELECT
      number n,
      len(@)*2-1k,*
    FROM spt_values
  )c
)d
WHERE n<k*k and'P'=type

I had to make some changes to format the output in the online version.
Try it online

C# (Visual C# Interactive Compiler), 249 bytes
s=>c=>{var r=s.Select((x,_)=>{int k=s.Length;var m=s.Substring(_,k-_).Aggregate("",(a,b)=>a+c+b);return new string(m.Skip(2).Reverse().Concat(m.Skip(1)).ToArray()).PadLeft(2*k-3+m.Length,c).PadRight(4*k-3,c);});return r.Skip(1).Reverse().Concat(r);}

Try it online!
This must be improvable...

213

JavaScript (Node.js), 143 bytes
(s,c)=>{q=Math.abs;m=(l=s.length*4-3)-1;for(i=j=0;j<l/2;(i=(++i)%l)?0:++j){p=s[q(i-m/2)/2+q(j-m/4)];process.stdout.write((i?"":"\n")+(p?
p:c))}}

Try it online!
A bit more thinkering would lead to calculating in terms of a one-dimensional array, and less bytes.

Perl 5 with -lF, -M5.010, 71 bytes
$"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F

Try it online!

Kotlin, 250 bytes
Note: Kotlin tio currently fails to return a new class so this code gets an null pointer exception. This also occurs for codes I previously posted that worked at that time. I assume it will eventually get fixed, but couldn't find a support contact to report the issue to. It can also be run here.
{s:String,c:Char->val h=s.length*2-1
val w=h*2-1
val m=Array(h){Array(w){c}}
for(i in s.indices)for(r in 0..h-1){val o=(i-Math.abs(h/2-r))*2
if(o>=0){m[r][w/2+o]=s[i].toChar()
m[r][w/2-o]=s[i].toChar()}}
m.map{it.joinToString("")}.joinToString("\n")}

Try it online!

You can contact @Dennis in The Ninteenth Byte chat. He's the moderator for TIO. Also, I allow returning a list of strings instead of actually printing, so I think (not sure) you can remove the .joinToString("\n") from the byte-count (and do that in the footer outside the function).

Gaia, 19 bytes
:ṫl¤┅v;@&Z¦<¦v¦ṫ¦ṫṣ

Try it online!
Explanation to follow.

JavaScript (Node.js), 101 bytes
s=>c=>[l=s.length-1,...Array(l*2)].map((x,i,a,m=Math.abs)=>a.map((y,j)=>s[m(l-i)+m(l-j)]||c).join(c))

Try it online!

close :(

Java (JDK), 213 199 198 bytes
a->b->{int i=0,l=a.length()-1;String s=a,r[]=new String[l-~l],p;for(;i<=l;s=s.substring(1))r[l+i]=r[l-i]=new StringBuffer(p=b.join(b,s.split(""))+b.repeat(2*i++)).reverse()+p.substring(1);return r;}

Try it online!
-14 bytes thanks to @KevinCruijssen
-1 byte thanks to @ceilingcat
Ungolfed
a->
    b-> {
        int i = 0, l = a.length() - 1;
        String s = a, r[]=new String[a.length()*2-1],p;
        for (; i<=l; s=s.substring(1))
            r[l+i]
              = r[l-i++]
              =   new StringBuffer(
                                   p =   String.join(b,s.split(""))
                                       + b.repeat(2*i)
                                  ).reverse()
                + p.substring(1);
        return r;
    }

Nice answer, you can golf it by 14 bytes below 200 however. :)

@KevinCruijssen Well spotted, thanks!

@ceilingcat Nice thinking, thanks!

Wolfram Language (Mathematica), 68 67 65 64 bytes
cTable[c&@@#[[1+{,y}~Norm~1]],{y,l=1-Tr[1^#],-l},{,l,-l,.5}]&

Try it online!
Input [c][s], where s is a list of characters, and returns a matrix of characters.
Table[                      ,{y,l=1-Tr[1^#],-l},{,l,-l,.5}] table from 1-len to len-1; resolution 1 (y) and .5 (x)
          #[[1+{,y}~Norm~1]]                                  get the (1+|x|+|y|)th character
      c&@@                                                    if indexing failed, use filler character instead

list[[index]] is equivalent to Part[list, index]. If the index is not valid, i.e. it's not an integer or is out of bounds, that expression remains unevaluated.
Then, c&@@... replaces the head of the expression it's acting on. This doesn't affect atomic expressions, such as characters (Strings), but it does affect unevaluated Part expressions.

Vyxal j, 14 bytes
Ṙ¦₅↳ømƛð⁰V⁰jøm

Try it Online!
Ṙ              # Reverse
 ¦             # Prefixes
  ₅↳           # Pad right to correct width
    øm         # Mirror
      ƛ        # Map...
       ð⁰V     # Replace spaces with other char
          ⁰j   # Join by other char
            øm # Mirror
               # (j flag) join by newlines.

Pip, 28 bytes
PZRV(PZRV(a@>_Jb).bX2*_M,#a)

Try it online!
There's probably a shorter way with a single palindromize use, but I was unable to find it.
Explanation
PZRV(PZRV(a@>_Jb).bX2*_M,#a) a → input
                        ,#a  range from 0  to length of a
                       M     map the lambda on the left to each item in range
                             _ → argument(each element of list)
          a@>_               Slice of input after index _
              Jb             Join characters with second input
                 bX2*_       repeat second input _ times
                .            concatenate the two
       RV                    reverse it: 'b..' → '..b'
     PZ                      palindromize the string '..b' → '..b..'
  RV(                      ) reverse the whole mapped list to get top part of the mat
PZ                           palindromize for full mat

Since I don't know Pip, would you mind adding an explanation?

surely, just a bit.


text:
Implement the Thanos sorting algorithm
The sorting algorithm goes like this:
While the list is not sorted, snap half of all items (remove them from the list). Continue until the list is sorted or only one item remains (which is sorted by default). This sorting algorithm may give different results based on implementation.
The item removal procedure is up to the implementation to decide, but the list should be half as long as before after one pass of the item removal procedure. Your algorithm may decide to remove either the first half or the list, the last half of the list, all odd items, all even items, one at a time until the list is half as long, or any not mentioned.
The input list can contain an arbitrary amount of items (within reason, let’s say up to 1000 items), not only perfectly divisible lists of 2^n items. You will have to either remove (n+1)/2 or (n-1)/2 items if the list is odd, either hardcoded or decided randomly during runtime. Decide for yourself: what would Thanos do if the universe contained an odd amount of living things?
The list is sorted if no item is smaller than any previous item. Duplicates may occur in the input, and may occur in the output.
Your program should take in an array of integers (via stdin or as parameters, either individual items or an array parameter), and return the sorted array (or print it to stdout).
Examples:
// A sorted list remains sorted
[1, 2, 3, 4, 5] -> [1, 2, 3, 4, 5]

// A list with duplicates may keep duplicates in the result
[1, 2, 3, 4, 3] -> [1, 3, 3] // Removing every second item
[1, 2, 3, 4, 3] -> [3, 4, 3] -> [4, 3] -> [3] // Removing the first half
[1, 2, 3, 4, 3] -> [1, 2] // Removing the last half

[1, 2, 4, 3, 5] could give different results:
// Removing every second item:
[1, 2, 4, 3, 5] -> [1, 4, 5]

or:
// Removing the first half of the list
[1, 2, 4, 3, 5] -> [3, 5] // With (n+1)/2 items removed
[1, 2, 4, 3, 5] -> [4, 3, 5] -> [3, 5] // With (n-1)/2 items removed

or:
// Removing the last half of the list
[1, 2, 4, 3, 5] -> [1, 2] // With (n+1)/2 items removed
[1, 2, 4, 3, 5] -> [1, 2, 4] // With (n-1)/2 items removed

or:
// Taking random items away until half (in this case (n-1)/2) of the items remain
[1, 2, 4, 3, 5] -> [1, 4, 3] -> [4, 3] -> [4]

Having a test case which actually requires multiple snaps for multiple different snapping algorithms would be very helpful.

Don't we need to sort and eliminate half of the answers...

Suggested test case: [9, 1, 1, 1, 1]. My own algorithm failed on this input

Python 3, 38 42 39 bytes
q=lambda t:t>sorted(t)and q(t[::2])or t

Try it online!
-3 bytes thanks to @JoKing and @Quuxplusone

40 bytes

39 bytes thanks to TFeld's observation that any permutation != sorted(t) must be > sorted(t).

R, 41 bytes
x=scan();while(any(x-sort(x)))x=x[!0:1];x

Try it online!

is.unsorted rather than any(...) would also be 41 bytes.

This base method is 44 bytes as a recursive function, might be golfable: Try it online!

Python 2, 39 bytes
f=lambda l:l>sorted(l)and f(l[::2])or l

Try it online!

Brachylog (v2), 6 bytes
≤₁|ḍt↰

Try it online!
This is a function submission. Input from the left, output to the right, as usual. (The TIO link uses a command-line argument that automatically wraps the function into a full program, so that you can see it in action.)
Explanation
≤₁|ḍt↰
≤₁       Assert that {the input} is sorted {and output it}
  |      Handler for exceptions (e.g. assertion failures):
   ḍ     Split the list into two halves (as evenly as possible)
    t    Take the last (i.e. second) half
     ↰   Recurse {and output the result of the recursion}

Bonus round
≤₁|⊇ᵇlᵍḍhtṛ↰

Try it online!
The snap's meant to be random, isn't it? Here's a version of the program that choses the surviving elements randomly (while ensuring that half survive at each round).
≤₁|⊇ᵇlᵍḍhtṛ↰
≤₁            Assert that {the input} is sorted {and output it}
  |           Handler for exceptions (e.g. assertion failures):
   ⊇ᵇ         Find all subsets of the input (preserving order)
     lᵍ       Group them by length
       ḍht    Find the group with median length:
         t      last element of
        h       first
       ḍ        half (split so that the first half is larger)
          ṛ   Pick a random subset from that group
           ↰  Recurse

This would be rather shorter if we could reorder the elements, but whyever would a sorting algorithm want to do that?

One byte per infinity stone.

@djechlin the infinity byte is why you must go for the head and especially the jaw.

Perl 6, 30 bytes
$!={[<=]($_)??$_!!.[^*/2].&$!}

Try it online!
Recursive function that removes the second half of the list until the list is sorted.
Explanation:
$!={                         }    # Assign the function to $!
    [<=]($_)??                    # If the input is sorted
              $_                  # Return the input
                !!                # Else
                  .[^*/2]         # Take the first half of the list (rounding up)
                         .&$!     # And apply the function again

C# (Visual C# Interactive Compiler), 76 bytes
g=>{while(!g.OrderBy(x=>x).SequenceEqual(g))g=g.Take(g.Count()/2);return g;}

Try it online!

Wolfram Language (Mathematica), 30 bytes
#//.x_/;Sort@x!=x:>x[[;;;;2]]&

Try it online!
@Doorknob saved 12 bytes

Instead of taking the first half, you could save some bytes by taking every other element (x[[;;;;2]]).

@Doorknob yes of course...

thought there could be some savings by using OrderedQ, but couldn't make it work

@GregMartin I used OrderedQ in my very first approach (see edits)

Java 10, 106 97 bytes
L->{for(;;L=L.subList(0,L.size()/2)){int p=1<<31,f=1;for(int i:L)f=p>(p=i)?0:f;if(f>0)return L;}}

-9 bytes thanks to @OlivierGrégoire.
Try it online.
Only leave the first halve of the list every iteration, and removes \$\frac{n+1}{2}\$ items if the list-size is odd.
Explanation:
L->{               // Method with Integer-list as both parameter and return-type
  for(;;           //  Loop indefinitely:
      L=L.subList(0,L.size()/2)){
                   //    After every iteration: only leave halve the numbers in the list
    int p=1<<31,   //   Previous integer, starting at -2147483648
        f=1;       //   Flag-integer, starting at 1
    for(int i:L)   //   Inner loop over the integer in the list:
      f=p>(p=i)?   //    If `a>b` in a pair of integers `a,b`:
         0         //     Set the flag to 0
        :          //    Else (`a<=b`):
         f;        //     Leave the flag the same
    if(f>0)        //   If the flag is still 1 after the loop:
      return L;}}  //    Return the list as result

n->{for(;n.reduce((1<<31)+0d,(a,b)->a==.5|b<a?.5:b)==.5;n=n.skip(n.count()/2));return n;}  is shorter using streams, but I haven't been able to figure out how to avoid the java.lang.IllegalStateException: stream has already been operated upon or closed error after returning the stream

@EmbodimentofIgnorance this happens because reduce is a terminal operation that closes the stream. You won't ever be able to call reduce twice on the same stream. You can create a new stream, though.

97 bytes

@OlivierGrégoire That order looks so simple now that I see it.. Sometimes it takes a look from another angle to see the obvious others initially miss I guess. :) Thanks!

No worries, it wasn't obvious: I worked to get there. I tested at least 10 versions before finding that one ;)

JavaScript (ES6),  49  48 bytes
Saved 1 byte thanks to @tsh
Removes every 2nd element.
f=a=>a.some(p=c=>p>(p=c))?f(a.filter(_=>a^=1)):a

Try it online!

p++&1 -> a^=1

05AB1E, 8 7 bytes
[Ð{Q#ιн

-1 byte thanks to @Emigna.
Removes all odd 0-indexed items every iteration, so removes \$\frac{n-1}{2}\$ items if the list-size is odd.
Try it online or verify some more test cases (or verify those test cases with step-by-step for each iteration).
7 bytes alternative by @Grimy:
ΔÐ{Ê>äн

Removes the last \$\frac{n}{2}\$ items (or \$\frac{n-1}{2}\$ items if the list-size is odd) every iteration.
Try it online or verify some more test cases (or verify those test cases with step-by-step for each iteration).
Explanation:
[        # Start an infinite loop:
 Ð       #  Triplicate the list (which is the implicit input-list in the first iteration)
  {Q     #  Sort a copy, and check if they are equal
    #    #   If it is: Stop the infinite loop (and output the result implicitly)
  ι      #  Uninterweave: halve the list into two parts; first containing all even-indexed
         #  items, second containing all odd-indexed items (0-indexed)
         #   i.e. [4,5,2,8,1] → [[4,2,1],[5,8]]
   н     #  And only leave the first part

Δ        # Loop until the result no longer changes:
 Ð       #  Triplicate the list (which is the implicit input-list in the first iteration)
  {Ê     #  Sort a copy, and check if they are NOT equal (1 if truthy; 0 if falsey)
    >    #  Increase this by 1 (so 1 if the list is sorted; 2 if it isn't sorted)
     ä   #  Split the list in that many parts
      н  #  And only leave the first part
         # (and output the result implicitly after it no longer changes)

You can use ι instead of 2ä if you switch to a keep every other element strategy.

Alternative 7 using the "remove the last half" strategy: ΔÐ{Ê>äн

@Grimy That's a pretty nice approach as well. Shall I add it to my post (crediting you of course), or do you want to post it as a separated answer?

Feel free to add it.

TI-BASIC (TI-84), 47 42 45 44 bytes
-1 byte thanks to @SolomonUcko!
Ans→L1:Ans→L2:SortA(L1:While max(L1≠Ans:iPart(.5dim(Ans→dim(L2:L2→L1:SortA(L1:End:Ans

Input list is in Ans.
Output is in Ans and is implicitly printed out.
Explanation:
Ans→L1                  ;store the input into two lists
Ans→L2
SortA(L1                ;sort the first list
                        ; two lists are needed because "SortA(" edits the list it sorts
While max(L1≠Ans        ;loop until both lists are strictly equal
iPart(.5dim(Ans→dim(L2  ;remove the latter half of the second list
                        ; removes (n+1)/2 elements if list has an odd length
L2→L1                   ;store the new list into the first list (updates "Ans")
SortA(L1                ;sort the first list
End
Ans                     ;implicitly output the list when the loop ends

Note:  TI-BASIC is a tokenized language.  Character count does not equal byte count.

I think you can replace not(min(L1=Ans with max(L1≠Ans to save a byte.

Ruby, 37 bytes
->r{r=r[0,r.size/2]while r.sort!=r;r}

Try it online!

36 bytes recursively

Jelly, 7 bytes
m2$⁻Ṣ$¿

Try it online!

Octave, 49 bytes
l=input('');while(~issorted(l))l=l(1:2:end);end;l

Try it online! This was a journey where more boring is better. Note the two much more interesting entries below:
50 bytes
function l=q(l)if(~issorted(l))l=q(l(1:2:end));end

Try it online! Instead of the uninteresting imperative solution, we can do a recursive solution, for only one additional byte.
53 bytes
f(f=@(g)@(l){l,@()g(g)(l(1:2:end))}{2-issorted(l)}())

Try it online! Yep. A recursive anonymous function, thanks to @ceilingcat's brilliant answer on my tips question. An anonymous function that returns a recursive anonymous function by defining itself in its argument list. I like anonymous functions. Mmmmm.

Haskell, 57 55 bytes (thanks to ASCII-only)
f x|or$zipWith(>)x$tail x=f$take(div(length x)2)x|1>0=x

Try it online!

Original Code:
f x|or$zipWith(>)x(tail x)=f(take(div(length x)2)x)|1>0=x

Try it online!

Ungolfed:
f xs | sorted xs = f (halve xs)
     | otherwise = xs

sorted xs = or (zipWith (>) xs (tail xs))

halve xs = take (length xs `div` 2) xs

Welcome to PPCG!

56

57 :(

55

Gaia, 9 8 bytes
eo₌⟨2%⟩↻

Try it online!
Explanation:
e		| eval input as a list
       ↻	| until
 o		| the list is sorted
  ₌		| push additional copy
   ⟨2%⟩  	| and take every 2nd element

Julia 1.0, 30 bytes
-x=x>sort(x) ? -x[1:2:end] : x

Try it online!
Takes every second element of the array if not sorted.

use an ASCII operator like - for 20 bytes. also we almost always don't count chars :| so it'd be nice if that was removed from the header

Changed that. Thanks for 2 bytes!

K (oK), 22 20 bytes
Solution:
{(*2 0N#x;x)x~x@<x}/

Try it online!
Iterate over the input until it's sorted... if it's not sorted take first n/2 items.
{(*2 0N#x;x)x~x@<x}/ / the solution
{                 }/ / lambda that iterates
                <x   / indices that sort x ascending (<)
              x@     / apply (@) these indices back to x
            x~       / matches (~) x? returns 0 or 1
 (       ; )         / 2-item list which we index into
          x          / original input (ie if list was sorted)
       #x            / reshape (#) x
   2 0N              / as 2 rows
  *                  / take the first one

Edits:

-2 bytes thanks to ngn

(.5*#x)#x -> *2 0N#x

I considered doing 2 0N but assumed it would be longer (without testing), thanks!

Java (JDK), 102 bytes
n->{for(;n.stream().reduce((1<<31)+0d,(a,b)->a==.5|b<a?.5:b)==.5;n=n.subList(0,n.size()/2));return n;}

There's already a C# answer, so I decided to try my hand on a Java answer.
Try it online!

Time to try F# :)

Husk, 6 5 bytes
1 byte saved thanks to Zgarb
ΩΛ<Ċ2

Try it online!
Explanation
ΩΛ<Ċ2
Ω         Repeat until
 Λ<         all adjacent pairs are sorted (which means the list is sorted)
   Ċ2         drop every second element from the list

This is 11 bytes, not 6.
› echo -n "ΩΛ<(←½" | wc --bytes
11

@MikeHoller https://github.com/barbuz/Husk/wiki/Codepage

@MikeHoller As many other golfing languages, Husk uses a custom code page, in order to have access to more different characters: https://github.com/barbuz/Husk/wiki/Codepage

Thank you, I learned something today :)

Use Ċ2 instead of (←½ to save a byte.

MATL, 11 bytes
tv`1L)ttS-a

Try it online!
This works by removing every second item.
Explanation
t      % Take a row vector as input (implicit). Duplicate
v      % Vertically concatenate the two copies of the row vector. When read with
       % linear indexing (down, then across), this effectively repeats each entry
`      % Do...while
  1L)  %   Keep only odd-indexed entries (1-based, linear indexing)
  t    %   Duplicate. This will leave a copy for the next iteration
  tS   %   Duplicate, sort
  -a   %   True if the two arrays differ in any entry
       % End (implicit). A new iteration starts if the top of the stack is true
       % Display (implicit). Prints the array that is left on the stack

Broken for initially sorted list: [1, 2, 3, 4, 5] should remain [1, 2, 3, 4, 5]

@Falco Thanks! Corrected now

Japt, 10 9 bytes
£=ëÃæÈeXñ

Try it
£=ëÃæÈeXñ     :Implicit input of array U
£             :Map
 =            :  Reassign to U
  ë           :  Every second element, starting with the first
   Ã          :End map
    æ         :Get the first element that returns true
     È        :When passed through the following function as X
      e       :  Test for equality with
       Xñ     :  X sorted

Crystal, 59 50 bytes
With Array#sort (59 50 bytes):
def f(a);while a!=a.sort;a.pop a.size//2;end;a;end

Try it online!
Without Array#sort (102 93 bytes):
def f(a);while a.map_with_index{|e,i|e>a.fetch i+1,Int32::MAX}.any?;a.pop a.size//2;end;a;end

Try it online!

C++ (gcc), 103 bytes
I can't comment, but I improved the version from movatica by reducing the includes, and using auto.
-2 Bytes: ceilingcat
-2 Bytes: ASCII-only
#include<regex>
auto f(auto l){while(!std::is_sorted(l.begin(),l.end()))l.resize(l.size()/2);return l;}

Try it online!

any reason you can't just use l.size()/2?

Yes, it does not work that way :)

what do you mean? returning a list of size (n+1)/2 or (n-1)/2 are both valid. hmm....

Ohh oops did'nt see that thanks

Pyth, 10 bytes
.W!SIHhc2Z

Try it online here. This removes the second half on each iteration, rounding down. To change it to remove the first half, rounding up, change the h to e.
.W!SIHhc2ZQ   Q=eval(input())
              Trailing Q inferred
  !SIH        Condition function - input variable is H
   SIH          Is H invariant under sorting?
  !             Logical not
      hc2Z    Iteration function - input variable is Z
       c2Z      Split Z into 2 halves, breaking ties to the left
      h         Take the first half
.W        Q   With initial value Q, execute iteration function while condition function is true

Taking every other element of the list is shorter. Replace hc with %.
This also lets you delete the trailing lambda variable Z and let Pyth fill it implicitly, for a total 2 bytes saved.

VDM-SL, 99 bytes
f(i)==if forall x in set inds i&x=1or i(x-1)<=i(x) then i else f([i(y)|y in set inds i&y mod 2=0])

Never submitted in vdm before, so not certain on language specific rules. So I've submitted as a function definition which takes a seq of int and returns a seq of int
A full program to run might look like this:
functions
f:seq of int +>seq of int
f(i)==if forall x in set inds i&x=1or i(x-1)<=i(x) then i else f([i(y)|y in set inds i&y mod 2=0])

C++ (gcc), 139 137 116 bytes
-2 bytes thanx to ceilingcat, -21 bytes thanx to PeterZuger
#include<regex>
auto f(std::vector<int>l){while(!std::is_sorted(l.begin(),l.end()))l.resize(-~l.size()/2);return l;}

Resize the vector to its first half until it's sorted.
Try it online!

Imports are rquired to be included in the byte count, so you have to add the includes

Thanx, i'll add them.

Julia 1.0, 33 bytes
-a=issorted(a) ? a : -a[1:end÷2]

Try it online!

Python 2, 51 bytes
a=input()
while a!=sorted(a):a=a[:len(a)/2]
print a

nice!

Husk, 7 bytes
ΩS=Oo←½

Try it online!
removes last half.

Jelly, 6 bytes
m⁻Ṣ$¿2

Try it online!
Very similar to Erik's existing answer, but I came up with this independently, and Erik's no longer active.
How it works
m⁻Ṣ$¿2 - Main link. Takes a list L on the left
    ¿  - Loop while the condition is false, updating L each time:
   $   -   Condition:
  Ṣ    -     L sorted
 ⁻     -     L ≠ L sorted
m    2 -   Body: Take every second element of L

Pip -xp, 12 11 bytes
$<=a?afVUWa

Takes the list as a command-line argument in Pip list format, e.g. [1;2;4;3;5]. The -x flag makes sure this is treated as a list rather than a string, and the -p flag formats the output list in the same way. Try it here!
(Pip Classic doesn't support the -x flag, but here's a simulated version: Try it online!)
Explanation
A recursive solution:
$<=a?afVUWa
   a         ; First argument (the list)
$<=          ; Fold on <= (truthy if each element is <= the one after it)
    ?        ; If truthy, return:
     a       ;  The list unchanged
             ; Otherwise, return:
      f      ;  The main function
       V     ;  called with the following arglist:
        UWa  ;   Unweave the list into two sublists of every other element

For example, UW[1;2;4;3;5] returns [[1;4;5];[2;3]]. This list is passed as the arglist to the recursive call, as if we had called f with the arguments [1;4;5] and [2;3]. Since our function only uses its first argument, though, this is equivalent to simply recursing with an argument of [1;4;5].

C (gcc), 66 bytes
Snaps off the second half of the list each iteration (n/2+1 elements if the length is odd).
Try it online!
Takes input as a pointer to the start of an array of int followed by its length. Outputs by returning the new length of the array (sorts in-place).
t(a,n,i)int*a;{l:for(i=0;i<n-1;)if(a[i]>a[++i]){n/=2;goto l;}a=n;}

Ungolfed version:
t(a, n, i) int *a; { // take input as a pointer to an array of int, followed by its length; declare a loop variable i
  l: // jump label, will be goto'ed after each snap
  for(i = 0; i < n - 1; ) { // go through the whole array …
    if(a[i] > a[++i]) { // … if two elements are in the wrong order …
      n /= 2; // … snap off the second half …
      goto l; // … and start over
    }
  }
  a = n; // implicitly return the new length
}

Suggest ~i+n instead of i<n-1

Clojure, 65 bytes
(defn t[l](if(apply <= l)l(recur(take(/(count l)2)(shuffle l)))))

Try it online!

45?

43? 42?

Retina, 38 bytes
\d+
*
/(_+),(?!\1)/+`,_+(,?)
$1
_+
$.&

Try it online! Takes comma-separated numbers. Explanation:
\d+
*

Convert to unary.
/(_+),(?!\1)/+`

Repeat while the list is unsorted...
,_+(,?)
$1

... delete every even element.
_+
$.&

Convert to decimal.

MATLAB, 57 bytes
Callable as f(a), where a=[1,2,3,4,5]
f=@(x)eval('while~isequal(sort(x),x);x=x(1:end/2);end;x')

Example of usage:
>> a = [1, 2, 4, 3, 5];
>> f(a)

a =
     1     2

Zsh, 51 bytes
56 (+5) to call the function, 47 (-4) if not a function, but saved as an executable with a proper #! header (replace the recursive f call with $0).
f(){[ "$*" = "${${(n)@}[*]}" ]&&<<<$@||f $@[0,#/2]}

Try it online!
There is no "is-sorted" builtin in zsh, but there are some "sort-array" builtins. We use the parameter expansion flag n, but o or i would also work. We then have to use [*] and quote to induce joining. This is shorter than alternatives (like zipping them together and comparing pairwise).

TI-Basic (TI-84), 29 30 36 bytes
Ans->L₁
While 1<dim(L₁
If 0≤min(ΔList(L₁:Then
L₁
Return:End
iPart(.5dim(L₁->dim(L₁
End

Input and output are through Ans.

L1 is not legal input; you need to either use Ans or write Input L1. Same for output, either Ans or display.

C++ 17 , 589 bytes
I used recursion to solve it. Submitted this solution in codeforces and got accepted. Btw, I still can't stop laughing! I mean seriously, Thanos sort!
#include <bits/stdc++.h>
using namespace std;int n, *a; int f(int start123, int end123){int start, end;start = start123; end = end123;if(start == end){    return 1; }int ret=0, temp=0;bool flag  = true;for(int i=start; i<end; i++){ if(a[i]<=a[i+1]){   ret++; }else{    flag=false; break; } }int mid = (start+end)>>1; if(flag){    ret=ret+1; }else{ int a,b; a =  f(start, mid);b = f(mid+1, end);ret = max( a, b );}return ret;}int main(int argc, char const *argv[]){    cin>>n;a = new int[n+10];for(int i=1; i<=n; i++){cin>>a[i];}int ans = f(1,n);cout<<ans<<"\n";if(!a)delete[] a;return 0;}

Hi and welcome to PPCG, the criterion of this question is code-golf, that means we are trying to solve the problem in as few bytes as possible. Typically people will post the number of bytes for their answer along with the answer (so for yours: 1120 bytes), your aim should be to reduce this! May I recommend starting by removing all unneccesary whitespace, naming your variables with single characters and looking at tips for golfing in c++

Thank you Expired Data. I'll try to do better next time

F# (.NET Core), 67 61 bytes
let rec t l=if l=(List.sort l)then l else t l.[0..l.Length/2]

Try it online!

Perl 6, 32 bytes
{($_,*[^*/2]...{[<=] @$_})[*-1]}

-2 bytes thanks to Jo King
Try it online!

Perl 5 -a, 50 bytes
@b=sort{$a-$b}@F while"@b"ne"@F"&&($#F/=2);say"@F"

Try it online!

Rust (2018 edition), 79 78 bytes
|v:&mut Vec<_>|while{let q=&mut v.clone();q.sort();q<v}{v.resize(v.len()/2,0)}

Try it online!
This will be golfable if slice::is_sorted gets stabilized, but right now the required feature flag offsets all gains.

feature flags are free though :P - they just count as a separate language

@ASCII-only for Rust, feature flags are not commandline arguments, but special syntax in the code itself.

Huh, no commandline option (like C# and Haskell) huh

PHP, 86 bytes
function t($a){for(;$n=$a[+$i++];$l=$n)$f|=$n<$l;return$f?t(array_slice($a,$i/2)):$a;}

Try it online!

Python 3, 60 bytes
a=list(input())
while a!=sorted(a):a=a[0:len(a)//2]
print(a)

Try it online!
If it has to be a list:
a=[1,34,2,42,3,4,5,23,4,12,34,53,65]
while a!=sorted(a):a=a[0:len(a)//2]
print(a)

this one even has a self scrambling thingy!
import random
a=list(input())
random.shuffle(a)
while a!=sorted(a):a=a[0:len(a)//2]
print(a)

Explanation:
a=list(input())       #ask for a string(that will be converted to a list)
while a!=sorted(a):   #while the actual sorted list *isn't* sorted,
    a=a[0:len(a)//2]  #it now equals the first half of it.
print(a)              #print it out!

Welcome to the site and nice first answer! I've edited it slightly so that other users can run and test your code, and that the formatting's fixed. One thing to note: list(input()) doesn't give you an actual list, it just converts the input string into a list (hence why the TIO link outputs ['[']. Changing it to eval(input()) works for no extra bytes: Try it online!

@cairdcoinheringaahing thanks! I doubt that this will win, but it was fun!

Factor, 50 bytes
[ [ dup [ <= ] monotonic? ] [ halves nip ] until ]

Try it online!
Removes the first half of the list, where the first half is shorter when there's an odd number of elements.

Scala, 84 bytes
def q(t:List[Int]):List[Int]=if(t==t.sorted)t else q(t.grouped(2).map(_.max).toList)

Try it online!