[Question]
  [
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](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).
* [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) aren't allowed.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged '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"] -> ["&"]
```
  
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog) (v2), ~~3~~ 9 bytes
```
{sᵛ}ᶠlᵒtw
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/v7r44dbZtQ@3Lch5uHVSSfn//9FKuYl5lQqZeQWlJcVKOgpKqDwQJzMTxKpMzMurVIoFAA "Brachylog – 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.
[Answer]
# [Python 2](https://docs.python.org/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!](https://tio.run/##bY7NbsMgEITvfYqVq7i25R7SY6Scq1x6SHuzrIrYEEhhscxSlad3ja30B@UAzOx8g3YIJC0@TZPYa2ZOPQNZV7STwLAHw74KWTGtCwkKwYGw43zPkspaFLLZ7tqZXvXucbuaDx72mmM5DaNCKkRRNZnkWtushuxhEW1Z3v1JP/kYYmh8J@PbKyH4yJFSkJuBFjKe17fj4eU5RVQ/91THdER@TUI5mvU5Io6Oh1klOUnlwCJfPnHAwPnT2gEr4CdNWhfv6Nb8unE6NwwDWE@DJ7fu4gfyFgIyc5NVeEX/u2iUiiowxJB2Nxu0lMf44vN7R1E1ecv0INk7esNH1cXO9A0 "Python 2 – 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](https://docs.python.org/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!](https://tio.run/##bY8xT8MwEIX3/gqrqG2MQqQyRspcdWEobCFCJnESF/tsxWeEVfrbQxwoVaIOlt/d@96dbTy2Gh77OnvtJVPvFSMyVewrshwTAcg7y0sUGqJ7xUzUxJLS@IP7THKgiyb7y9jUEgbVyZ6/m8jm27Sgo0gftgXV3WmzOfemG@ZFdZQvWy6lXsZkuRlFQenian7yzgdPubINdyXqmncccMZxZXAEw3l@OeyfdjNCVENKlEwG4lpMIYuDbAJh8bAf1NTGVliigY8jhj@SJEnIf3PKHp3FG@3LG2dtxcAT7dA4tL/rnUGniQembqECLuS0CoUQQXkG4GfR1Qo0roN7dOs7i0Hl64JJ07I3cIp3ogyR/gc "Python 2 – 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.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~12~~ 6 bytes
```
Ẇ€f/ṫ0
```
[Try it online!](https://tio.run/##y0rNyan8///hrrZHTWvS9B/uXG3w/1HDHKVHDXOtraGMY5uAcllAjg5IFEjr2oHlD7fDVHAdbgcqifzPxaWUV6mQmZmppKOgVJmYl1ep9D9aKTcRJJhXUFpSDBJH5aGrj9WJVsoAOiofJKQOZoCEwGbkl5bAtBWXlBaUlOYrVOYl5oIVKOmAEYiZB9QL1FCSnKEUCwA "Jelly – Try It Online")
Thanks to @JonathanAllan for saving 6 bytes!
[Answer]
# [Ruby](https://www.ruby-lang.org/) 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!](https://tio.run/##TYyxDsIgFEV3v8IwGkvSua3@gGM3wvDagqBYySNKDPDtCNEYl3uSc5KLj@mV5ZCbA4SdH6DzVOp1CRGj73uks7rbQtZS2rS8AwrGHEN00THkKaVst5IxAtO8kD35DhDON59wgmKe2tnKUaBwf3FU2lVd8ZP1Sshz8Upfrua2lpTf "Ruby – 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
[Answer]
# [R](https://www.r-project.org/), ~~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!](https://tio.run/##VY/BTsMwDIbvPEVUtNKKgOCKqHZEUyUOLbdpYlnqkkytEyUO0KcvTacWLVJk@/8/O44bW/b6wMY2oCRtMKv5cXssUCrheFn04jfb1jn3RQVNkJBpJHAeJPFOWNsNE@/DyZPT@MWfXkruwGYxQlHeP@fT8fsfpaV6nEf5/DC2mcwSBV1nEp7czTHPb2b1G9yQcJb0QaoYG9224ABpJaC3NCPx1h/V7v1t9XQzkVqKLnr/xWJfloyep2o3ZYtBSntmEOY2zwRbf8RMy1Z3wc/B05WwrLMKvcCBmUA2kL@8FywFwwYU/TWkcWGuq1hoHbNBIA5r02aDhtKon0N66ylm@/QgOqvEJ4YenJYTPP4B "R – 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.](https://codegolf.stackexchange.com/users/78274/kirill-l)*
*-8 bytes using* `lapply` *instead of* `Map`
*-2 bytes thanks to Kirill L. again, removing braces*
[Answer]
# [Zsh](https://www.zsh.org/), ~~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!](https://tio.run/##rU7NboMwDL77KTwIJIGhajsOkPYEk3buegiQLZlCUhFQaRHPzkK3R5gP34/92fLNq@2itJE4SNFhMaDRVpbYOfByxKLAiCzs9Z0HvPF9tq7R9ulCDhZRo65hN4yVOs8rEpssey45F3nNiDk@5foQeo@Bk8AnDk3oL2RpCiLWl0ysfL3ve2Sk4cAYiedwxXOepnNNPFRVReZtsvszAhs0ITqjhs5ZuVk3Km2/UL9h6/reWaBKXnFUcpAU6S4DTbgzyP48XpFSvAugSRLW0zD/ntLY78FjehLmrISdejnoFlslBk8hopRGGP3Bb0WgpDHuAy9uMN0D/ouDHw "Zsh – Try It Online")
[Try it online!](https://tio.run/##rU5LUoQwEN33KVrIED5Sli4VruAFRhYBWhMrJFMJOIwUZ8cgHsFe9Hv9@vXn28vtKpUmdCR6LB1qZegFewv0JTR6GrEsMWK7HG3vNhhgETWqGhxdSIzIzizWef7UoCjqlOlzUaiHIBWP9@r0i00GbegsbGlLJtbnXKzZCvsujylrszRl8Vyx2GdZksw181BVFZu3yeznBbYYHsEZFfTW0GbsKJX5QPWKnR0Ga4BLuuEoyRFHvtMAE@4InCMNl/F2ZDg4D/rpFPYkwfg5JbHfJ85JI/RFCjMN5FSHnRTOc4g45xFGf@mICCRpbd/wap3u7/BfKvgB "Zsh – Try It Online")~~
[Try it online!](https://tio.run/##rU1BUoQwELznFW3IErBkq7wqfMEPbPYQlmhihWQrAZeV4u0YCv2Bc@jp6eme@Y56vWljFYKSHaoAa5x6ReeJ@pIWUQ2oKlC2yXR998mwb2QjCghmxWl@Ph5ZZpenPyLOEGWet03BZja3FZPLy6NcSrLFIwrWlkXBsqlmWSyTcWpYJHVds2kd3fZRokX6jQmGdN6p1flBG/cB84aL73vvCNfqjkGroDj4RlMbsXXCOVR/He47kp3zpB8O6U6ejJ9jnsUtccrP0l61dGOvgrngomWInFDOOQX9hb0o0cpaL3DzwXYP@JeJ/AA "Zsh – Try It Online")
We read all possible substrings into the array`a`, 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
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~14~~ ~~9~~ 8 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
€Œ.«ÃéθJ
```
-6 bytes thanks to *@Adnan*.
[Try it online](https://tio.run/##yy9OTMpM/f//UdOao5P0Dq0@3Hx45bkdXv//RyuVpBaXKOkogOnMvHQQswgkFAsA) or [verify all test cases](https://tio.run/##VY9BTsMwEEWvMjJq2ERcoUtUFiwKuyhCbuqQqWI7sseVvG0lDtBbIDgAayq2HKIXCR27pbCw/P9/fzQa6@UC1biOUwGHlx2IaRwPm/ev3c3n2367f/3@uBvLsapEp/reihLEdRJ1CZVYKxc50qHp@F9i2yqnDGWs9ECJ83t4nM/ubzPA5bGDjewZXExinhyaZwae5rOjSil16MEalQY8SPBhkZtgW/ilqbsKni7uvD87LU0EG2gI5POOMFCwEI3UfxpozoX/jg0iqyiNiXliMjGWCg5XobjyxKoqatkPnXwyQSuHzekKlSn/pyMdR3X9Aw).
**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)
```
[Answer]
# [Haskell](https://www.haskell.org/), 80 bytes
```
import Data.List
f(x:r)=last$sortOn(0<$)[s|s<-inits=<<tails x,all(isInfixOf s)r]
```
[Try it online!](https://tio.run/##Lcm9CsIwEADg3ac4QoYEqjhLsrkIQh@gdDh/gofXa8ndkMF3jw4u3/K9UN9P5t5p2dZqcEbDw5XUdiW0U42ZUc3rr0YJx@TjpB9NexIyzSkZEiu0AZkD6UUKtbGAxjr3BUkgw1ZJDDwUmBze7g83uD/o5v4F "Haskell – 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](https://codegolf.stackexchange.com/a/146634/56433)) and return the last.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 48 bytes
```
M&!`(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)
O#$^`
$.&
1G`
```
[Try it online!](https://tio.run/##K0otycxL/P/fV00xQcPexjZOT0tTQ09bU8PeVkNPKyYPiA01tfS0VDS5/JVV4hK4VPTUuAzdE/7/z03Mq1TIzCsoLSnmQmKCWJmZXJWJeXmVAA "Retina 0.8.2 – 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.
[Answer]
# 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](https://data.stackexchange.com/stackoverflow/query/1015685/greatest-common-substring)**
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
> 
> 
> 
[Answer]
## 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!](https://tio.run/##jZBfT9swFMXf@RRWphZnCpnEKyQV2zTUrQKJIu0BoclNbxKH5DqyrwELwVcvcUs6thdsyfK51@d3/KcwR4WRmx8Wi9OFNHRqSEus8uRtZSXLNm2W812d/lQSeZRESZsuoYWCuMlyhAcmkW5MugCsqP68F8e3o43LpImz/C3mm8JCDGy6vJM9b74cvYxInF6LO@DN5F1rGOlZVWmoBAHnIlkNSSKdI4E2Pnw1GM61sv1Xxx@z/HGfdanXoH2T@e4vcHG6EIYu9XcohW2Jx7Pxgi7LXTyb@be8/wg@HH6yOTn4rSXBQiLwkv/veYpqaFsVJSw63IrngfmAuAftPNDZovbrWpYlaEAKgaHraUv7uby@ml@ch2ByPeTLQrQe@1sEkDvhMUNX80EFMFRLwxTC9jDDBDN2tdtkqmT73YCkxhoK9Y6/EuLtBDqmLPWWzO5ttiermEPRBfMSR/zfyhdSeuUEogvJm0xQ0dQjjZ1@MuTVzfRWtH0t/qDtQMtim7N5BQ)
Props to @Expired Data and @dana
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~62~~ 60 bytes
```
{~sort(-*.comb,keys [∩] .map(*.comb[^*X.. ^*]>>.join))[0]}
```
[Try it online!](https://tio.run/##VVDLbsIwEDzDV6xSCEkEhl56qaDqoaqQqh5oVVUKoTLBKaaxHcV2pQjBub/S3@qPpLFDeByymdmZ2Ww2I3l6U7IC3ATG5XYvRa68QYBiwZb9L1JICP9@fiNADGde3Q4XwTtCsAiiyQRtBOW@H46iXZmIHLyUciJ92LZbbOjNQxTczSMfBUc4vG23JC4g8Toj9PB2/@T3oQfjCfT2nev2rgydNUlT4fTB6VkQwWACoVPjduh8k7wwKtPx2rxXNElITrhqnNZFWKaszTwvr7Pp8@OFTldVgsY4NfqJHCxnjcorVU75pzFKNZtW6OCSyvQMr0xqTSUITuw8CRikXtZBEAkc1UP0xKvoRkt1Lp54JTb/cLE9w7wAoVWmlaz30pnSAgqOWWNkRsB2Q1PsMcAUe1ttit0/swNOYylvpl4yQyi1ozDnRfMZg6pot8uFco260e5VfRnP9XGarfEH14zkNG4iXSf6Bw "Perl 6 – 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!](https://tio.run/##VVDLTsMwEDw3X7EKbV6UFC5cUIs4IFQJcSgIIaUpclOHusR2FNuIqJQzv8Jv8SMhdpo@Dl7PeGY2m81xkV1WtAQnhWG19ly3//WOSwHR389vDCFFuReECafzaBa8hCHMgng0ClecMN@v1U/vtJH9TZXyAryMMCx8WFsdOvCmURhcT2M/DHZwcGV1BCoh9brn4e3zzb3fBxeGI3C/uxfWporsJc4ybvfBdg2I4WwEkd1gK7I/cFFqlapkqe8FSVNcYCZbp3Fhmktj0@fxaTJ@uDvSyaJOkARlWt@TreXgofYKWRD2po1CTsY12rqE1G@a1ya5JAI4w6afAARCzZsg8BR26ja653V0pYQ8FPe8Ftt/OJqeIlYCVzJXUjRzqVwqDiVDtDVSLSAzoS5mGaCL2a3Sxcyfmwb7toS1XY@ZJoSYVoixsv2MRnW012NcOlpdKeek2Yzn@CjLl@iVKYoLkrQRx47/AQ "Perl 6 – Try It Online")).
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0 [`-hF`](https://codegolf.meta.stackexchange.com/a/14339/), 8 bytes
```
Îã f@eøX
```
Thanks to Shaggy for saving 3 bytes
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&flags=LWhG&code=zuMgZkBl%2bFg=&input=WyJraGVsbG8iLCAiJ2tlbGxvIiwgImt3ZWxsbyJd)
```
Îã              //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
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt) [`-h`](https://codegolf.meta.stackexchange.com/a/14339/), 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](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LWg=&code=beMgcmYgaVA=&input=WyJoZWxsbyIsICInZWxsbyJd) or [run all test cases](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&flags=LW1S&code=beMgcmYgaVA&footer=zA&input=WwpbImhlbGxvIiwgIidlbGxvIl0KWyJ2ZXJ5IiwgIm11Y2giLCAiZGlmZmVyZW50Il0KWyJlbXB0eSIsICIiLCAiU1RSSU5HIl0KWyJpZGVudGljYWwiLCAiaWRlbnRpY2FsIl0KWyJzdHJpbmciLCAic3RSSW5nIl0KWyJ0aGlzIG9uZSIsICJpcyBhIHN1YnN0cmluZyBvZiB0aGlzIG9uZSJdClsianVzdCBvbmUiXQpbIiIsICIiLCAiIl0KWyJtYW55IG91dHB1dHMiLCAic3R1cHR1byB5bmFtIl0KWyJtYW55IGlucHV0cyIsICJhbnkgaW5wdXRzIiwgIm55IGlpaSIsICJ5YW5ueSJdClsiJSVub3QmIiwgImp1JiNzdCIsICJbJl1hbHBoYV9udW1lcmljIl0KXQ)
```
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
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 6 bytes
```
►LFnmQ
```
[Try it online!](https://tio.run/##yygtzv7//9G0XT5uebmB////j1bKTcyrVMjMKygtKVbSUULhgNiZmUBGZWJeXqVSLAA "Husk – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/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!](https://tio.run/##bY4/T8MwEMVn@BSnLNiiA4itqHPVhaGwRRmc@Nw4JOfIfxD@9CF2VaJEHSzfe@/3fB6jbw29TZNEBYLVfN8cylKWao@VMhYQNIEVdEHWIzHJn1958tXi42xlViavrt4t@mAJBvHLSg0p0SlpypdKz0v6nmXd5ajLEa923xgP8wo@jVaTZ4KVRYt9b4odFE95qDh/XMIftDFlQ2jadEutFFokv@FwGH0G0/n8Op8@jhtCy7mlG9EnYhFryPl5vCTC@fNpntaxb7UDQ5ifcCDAhfpaAaPgP12XuuD8Hfv22Y09CIpggh@Dd9d/hNEHA5HEcA/VdCPXKgmt0xQFUUzVh@kP "Python 3 – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/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!](https://tio.run/##bY4xT8MwEIV3fsWpqCUWFUPHSsyoC0NhC1HkxOfGJT5H9hkRIX57iFuVKlEHy@/e@97pup4bR5tBwzN8DK20lZJQba38zjyqWGMWkJ/KUpIqy3X@o3K9xUI7DwiGwEs6YNYiZUo8bkTy9dVH8ZsclZyqEOtP7J9HVgydN8SZzvJFg23rFmtYPJxEIcTdNfxC36fMxrpJvzJao0fiGYe24xOY3tv7fvf6MiOMGlumlm0irsMUCjzKQyIC73ejmsbcmACO8LQigIQQq3MFnIb/dFo6xsA37MuxM9tK6sFF7iKH8x2x4@igJ2lvoYYu5HRKgzFJ9ZKon1WXS3K8Sukxru4DJ5WvCtl2jSwpWvSmTpXhDw "Python 2 – Try It Online")
This is an anonymous lambda that transforms each element into the set of all substrings, then `reduce`s it by set intersection (`set.__and__`) and then returns the `max` element by `len`gth.
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~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!](https://tio.run/##jZBda8IwFIbv/RWhQ9diFe/TCGOwIcgudLALkZHV1J7ankpyslHE3@6adu7jagkk533Jed58pGaSGrg8WEyTJRhKDGnA/Tz@qixjgl2kmJ8AiYGYxUVctetByM1sO10q3FPO@2ZmRBDEO2F4VuuQQ3LgMB5HzhSi4sV4nBwmwCPIQjm9K8uwEfNmel8jSUATmj5ybd/6uBDiImrHqRIFd6lnrchqZDt@vvDB4EUDqSWgCrMQ1Qf7ff1TkKuyrIOYBbedOEcR/4d4V7pxQGXT3NUdZJnSCskHVtWROtrN9fNq8fTog8GuzYdUlg77MR5kLxxmaLVolQdDORhWo@oOM0wyc/1rVmfse9cjqbCGfHuvv@LTW0lsWG3paMn0b7NHsjVrUFbePOAV/@ucAXCqkYiNT95wiDWNHFLY0Y0hpzajrSyPuXxFWykNaZdz@QQ "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# 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](https://tio.run/##TVBLTwIxGLz3V1RkF5BH5UBIII0bEyEkygH1JIaUpctWt49sW2ND9q@7tmuCXDrzzcw3bapoWUzq@4flan1qI9wBGGPQqQB3UT6vOVGoO@r3undXo5vt2OOpnZ/acdXvV0HsoUGymGviYCZLeCypOjmEUIoxJ9/Qb8NmHCT7Ktnj4CcLjEPFrhp8UqejvA7rLX9rq85pUUjQac7wjC9aOsBtmoMDyzJaUmEanXJlHADPL5vVetko7OA9lpLiggVdm5KJo4fNykNQTM40lIICDwRqu/@LQJnBsxVyH1ab88CJcFBao6zRvswqYyV0gvB/l4nGvKCBMQYcEcI1uSgS0sS@Ob7WBrzF76RQOdkJy2nJ0h@pDJNC10NSiNvpdLpAW4Hq4dMj02Y2ezWsCJ/qhcnodvwL)
[Answer]
# 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!](https://tio.run/##fVHBboMwDL3vKyKmMpBa2l0r0R6nXjap2w2hKUCAVCFBOKnKZb/O6qA269iKhPFz3nvGzoEeKeQdb/VCqoINZTzQeBNUcRZDvKERO7KuD07x5usUcVmw01sZQBhuszhLIBJMVrpOt9ka1lUAEQies2A1XzzPHXwO8QloskrDIVcSlGCRUFVQBolXMyGUNyfek03SMCTLJUm8ET38puPfILsxeY3fgpcl65jUTvmHijWttjJ83z/2u9eXu3xenB15TgXyHbhKfpQmWtAdlxUKQe935@yqAo1VrExEuuZAlGS2HxBKwGSjEVEluZ5erVxlYnUwoG/JrjIhX3ZydxsNlT1RRrdGwziXabVRpJe0ccIGj6idEINdN8Fgb9dgsPO31uK/NlxeutwiBJxbYypl79piPrGazaTSPrIPxn8c9574KRVtTT@laVjHc2fhe@nwDQ "JavaScript (Node.js) – Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 30 bytes
```
≔⊟θη≔⁰ζＦＬη«≔✂ηζ⊕ι¹ε¿⬤θ№κεＰε≦⊕ζ
```
[Try it online!](https://tio.run/##VY4/C8IwEMXn9lMcna4QQWen4iRYEBxLh1DT5jC99E8qVPGzx1Q76HBw7927H6/ScqisNN5n40gN49l22KcCdLqPV2sr4BFUbQfAk@LGadRpCs84WgMXQ5VCHWICjlwNqlXs1BUpcHZhVPiOqAbMjMFewMFO7PC2HAInn4yjbqBgfYLKjApy2a3wH@C3x8v7okhayTMQd5MbEwHJv1oE0bLNknlOytJv7uYN "Charcoal – 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.
[Answer]
# [Bash](https://www.gnu.org/software/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!](https://tio.run/##RYxBDoIwFET3nuKL36SlQaNLP7B14w2MJpW2UtKIAYwmTc9eARfuJvPezE32dYym7cCRZ8wIwTmpAv3KBbIFjYQxskLkKk33xLkHXdUtJOjdwW7VYSfsWoWkLNFQoLCYrhqwD0j/f/dOPyH7GGwAz43YXX6ynvvkuvHI3hVkpxwND5gAmhjju5YDSOisstXLta8e7q0zYJWWM5MwzvXo/OvjnPoJyGH5BQ)
Not pretty but at least it works. We write the substrings to files `$f`, then `(e)grep` for longest common line.  
  
[Answer]
# [Red](http://www.red-lang.org), ~~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!](https://tio.run/##ZVDBatwwEL3vVzxcsk0oYdmrG5JjyKWHbW9CFK0txRPkkZFGIf767Xi3NGuKBHp672nmjbLvTwffG7sJ7SlU7szRmtgien6V4QmlxXG3B7fYo7JQNLTAmNIENtKiS9O8m1wWOEEBISK3SIyQsnfdgLph/yE4GqUzHPe3nNjj4RGBuN91rnhUyJ2lgGyyl5oZYrUN4Rv2VlvzAnQ9YkmGe2Wbxp6mTCwIMM3gY0wNmq/n02LzKb37PKsy1m7Qo6cQfPYsjb3y@HGSxaT756/Dy4/nlUq9@qlzUeVPfO0oovBV5SKHFwUW@I7zYMTFcyGhd3/ll4GKfpFfChY4lHq8lEAK@CeuxnirRS7sFXmJvKJGxzNSlalKOQeqk9SEmd34v4/4r211WTCRgtkxz6tXNzecZKvSW91@KaLAbK2L0@B@cx19pk5Tn/4A "Red – Try It Online")
Changed the recursion to iteration and got rid of the sorting. 
[Answer]
# [Perl 5](https://www.perl.org/), 87 bytes
```
my$r;"$&@_"=~/(.{@{[$r=~y,,,c]},}).*(\n.*\1.*){@{[@_-1]}}/ and$r=$1while$_[0]=~s,.,,;$r
```
[Try it online!](https://tio.run/##TVDBasJAEL3vVwzbaKOsiR7EgwRCoYoXD7Y3I7LVTbOSzIbspiXYeOwH9BP7IU03KVgv896895gZJhdFOm0eHper9dnxAxphEAQR0jk4tO1oTXT5AvG5ySqnmFOnH@5pcPFd7xyet04RXCrG2GFXs3rgDd0IvWE08YaD1g33o8murn3geLRJZ/KeyFQ4@@14F1w08xibO0VTQ15INDHQ3mg61vD9@QU9bTczOCmJLoUPoCxcDBjEroUmEWmqyH1X7bHkTRQVycpDQo4yjkUh0HS6yHJTEfL0vFmtl50ij9aTB57esFbXxl7wamGzstAqJpEaFApigYP9wF8EVAxXq82dSm2uTcaxAlWavDTaDitzUyqokGf/rsTOvKEtk5JUHLHqcr0eKtO3k/t32pBtf8fTPOF7LDNRyMOPyo1UqJsRT3E8m80WfoT@Lw "Perl 5 – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 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!](https://tio.run/##VVLBboMwDL3zFRaXJRIgdm0XdpjUqVK1SdtuaFKzNrSpQoJIoOXruzjAuh4w9nvPDyf4xHtud61sXKrNXlwrduWsICtGVKKTM@Nl/p3Z7se6luhEUcoK9ayf8ucVSVOVbFJFFzyzphZkYMWQSb0Xl/eKnOlTTr3Iu6SPdHFexDElm9FOCX1wxySn12XU8xacsO6FW2GBwbaMj0IpEycQP4TkG9ICynjMozLuRTsgW3e7I773sqpEK7SblUEl6sYFGT6fXx/rt9c7Xu59h9xxhfytmCT/AK/1Z5f6gELrPtY@m1TWIYa1F7mjtGC0CH4WOIyX5hvBVPDHTq232reeOuv@k7fak/MZ7qavuR7AdK7pnB3n6hrXGRg0r2dhjQQPE2IIlwEYwt12GML8TTC42Uo9u95XWEgZrLjWw/wZzLaZbZR022ib1bwhF2AFXCYMVSM8ICx6rshAKV1GlWmB4P@X4YbmJaAR7Iy2RolMmQORfmMSkOWjj7ggVUDoCP2tm6VQMMjp8voL "JavaScript (Node.js) – 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
)
```
[Answer]
# [Gaia](https://github.com/splcurran/Gaia), 15 bytes
```
eḋ¦&⊢⟨:l¦:⌉=¦⟩∇
```
[Try it online!](https://tio.run/##S0/MTPz/P/Xhju5Dy9QedS16NH@FVc6hZVaPejptDy17NH/lo472//@jHzXM8UjNycl/1DBXQQHIUYdyYgE "Gaia – 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
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~165~~ ~~163~~ 87 bytes
*-76 bytes thanks to Nail for the [awesome regexp](https://codegolf.stackexchange.com/a/182199/80745).*
```
"$($args-join'
'|sls "(?<=^.*)(.+)(?=(.*\n.*\1)*.*$)"-a -ca|% m*|sort Le*|select -l 1)"
```
[Try it online!](https://tio.run/##ZZJRa8IwEMff@ymO2ta2s4KvY6JvQxh7cHscG1mNGkmT0iTbivrZXS5Bo1jI5e76@1@S41r5Szu1pZyfkjVMYX@Kkzwh3UZVO8nEMBoeFFcQ57On6ee4LPLxQ5HPpvm4/BB2TYpyXCZFXBGoanJIoSkPSnYaXqh1KKe1horDpIhPxyia5xHYb5TP8xiPlPEI4qFzCut5JyA/tOuRaEy9xX3F1mvaUaEdfU3SptUOxfX2vly8PiNzC7GVlbKacIRC4LirMAiU7pjYIK30cmE9hyqNGYwCqbdMgRTUVVZAQJlvrwa5hstfpw9R0O@M0oEIUSDOj7t/VkNED9Lo1mjl72pabST0gjSebjBN3K3RuEYBGtd/g8a9qXXyu9pMnEvfRhgw5ioSIXp/Fu5Bn6ZC6gyRnckGvnMZ4e2WfAnT0I7VXpVZUQEHSGHvxAkZQUL/Wjs@dGWnMvny6Y4qw7VNZHZY5wQGoFrCtbaNdgDOrmcqJi4FisezMo6Op38 "PowerShell – 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"
```
[Answer]
# [Java (JDK)](http://jdk.java.net/), 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!](https://tio.run/##ZVJNj9owEL3zK0apoHZJoj1vAKmXVit1e1h6W60qb3CIU8eOPGO0EcpvpzYBFsTBmo/33njG40bsRNZs/h1U21lH0IQ496R0/q2Y3OUqb0pS1kSw8@9alVBqgQjPQhnYTwBOWSRBweys2kAbMLYmp8z29Q2E2yI/UgF@nMotfimkxUhZpScL1RIOIlvtK@uYMgR6KfKtJPbAcy3NlmrGU7XUaVOo1fKhUFnGI7UJfrPQmSr4ficc4KcM/Tsei7NmPk@bueKFqpjIQ1KKlvFcaP0sqKzZR7b6yEtrKPSODDnnTpJ3BrAYRi9JiuFQHMc4zxamI4mEsDzNB7BPaqm1TVJIvh6dIYULtJOuj0jryzrajaoq6aShG5ZsOzrS4ln/eXn6/fMGV5ugUKXQEf8Mrinj0BFHenkK3jVItUKwRh7lCAIurwS2ggt6LWk80l3y3OJNshWmB@up84Tj/b4jb6E3or0nKnPm3UYxUCp6vTCmvxFOp8bSLGKNn31Bit7r7E3orhZ/jW@lU@VFMIwLi98kfo24rcdxZ/yysnWPJNs8NJ134RWoYskUH2GKUxNqf3dO9JiTHZfOopinUOWi63TPTrDA@KNHkPPx0mESzzCZHP4D "Java (JDK) – Try It Online")
## Credits
* -17 bytes thanks to [Sara J](https://codegolf.stackexchange.com/users/85386/sara-j).
[Answer]
# [Perl 5](https://www.perl.org/), 86 bytes
```
$_=join"\x1",<>;$p=".*\x1.*\\1"x($.-1);say+(sort{length$b-length$a}/(.+)(?=$p)/msg)[0]
```
[Try it online!](https://tio.run/##K0gtyjH9/18l3jYrPzNPKabCUEnHxs5apcBWSU8LyAMSMYZKFRoqerqGmtbFiZXaGsX5RSXVOal56SUZKkm6UEZirb6Gnramhr2tSoGmfm5xuma0Qez//0k5iRkKJRmZxQqZxVxQWgEk@C@/oCQzP6/4v66vqZ6BoQEA "Perl 5 – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 16 bytes
```
eolN.U@bZm{s./dQ
```
[Try it online!](https://tio.run/##K6gsyfj/PzU/x08v1CEpKre6WE8/JfD//2iljNScnHwlHQUldTAjFgA "Pyth – 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
```
]