[Question]
  [
Given \$k\$ arrays of length \$n\$, output the maximum sum possible using one element from each array such that no two elements are from the same index. It is guaranteed that \$k\le n\$.
# Input
A nonempty list of nonempty arrays of integers.
# Output
An integer that represents the maximum sum.
# Examples
```
Input -> Output
[[1]] -> 1
[[1, 3], [1, 3]] -> 4
[[1, 4, 2], [5, 6, 1]] -> 9
[[-2, -21],[18, 2]] -> 0
[[1, 2, 3], [4, 5, 6], [7, 8, 9]] -> 15
[[1, 2, 3, 4], [5, 4, 3, 2], [6, 2, 7, 1]] -> 16
[[-2, -1], [-1, -2]] -> -2
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~10~~ 6 bytes
```
ZŒ!ÆṭṀ
```
[Try it online!](https://tio.run/##y0rNyan8/z/q6CTFw20Pd659uLPh////0dGGOgpGOgrGOgomsToK0aZAGswzAvHMwHLmOgqGsbEA "Jelly – Try It Online")
(4 bytes saved by @Dennis, who pointed out that Jelly had a "sum of main diagonal" builtin. I was *not* expecting it to have one of those; the previous solution implemented the operation without using the builtin. The operation in question, `Æṭ`, is defined as "trace", but the trace is only defined for square matrices; Jelly implements a generalisation to rectangular matrices too.)
The improvement over the other answers is mostly from a simpler (thus terser to express) algorithm; this program was originally written in Brachylog v2 (`{\p\iᶠ∋₎ᵐ+}ᶠot`), but Jelly has some builtins for parts of the program that have to be spelled out in Brachylog, so this came out shorter.
## Explanation
```
ZŒ!ÆṭṀ
Z            Swap rows and columns
 Œ!          Find all permutations of rows (thus columns of the original)
   Æṭ        {For each permutation}, take the sum of the main diagonal
     Ṁ       Take the maximum
```
It should be clear that for any solution to the problem, we can permute the columns of the original matrix to put that solution onto the main diagonal. So this solution simply reverses that, finding all possible main diagonals of permutations.
Note that the "permute the columns" operation is done as "transpose, permute the rows" without bothering to transpose back; the rest of the algorithm happens to be symmetrical about the main diagonal, so we don't need to undo the transpose and thus can save a byte.
[Answer]
# [J](http://www.jsoftware.com), 28 bytes
```
>./@({.+1$:@|:\.|:@}.)@[^:]#
```
[Try it online!](https://tio.run/##XYzNCsJADITv@xSDLtRSid3dtmqgsu/h36G4qBcPPdo@@xoXS0GSgcmXSZ4x9C2hBKOMB9r41ZsKo9kPfKKB/Ui5P174vIy5WhCy0FKGNUZG6JW6dfcXAgyMNtNgpbQg99UMXYKVuBoN/tJXKy1fdrDTwv0uCjxoP8MqQZtcLXLiG9EWJn4A "J – Try It Online")
```
 >./ @  (   {.   +         1 $:@|:\. |:@}.       )       @[^:] #
(max of (1st row + recursive call on each "minor")) or count of arg if 0
```
Here the recursive call is done by `$:` which represents the largest anonymous function containing it. We are lucky in J to have the primitive `x u\. y`, which applies `u` to successive "outfixes" of `y` obtained by suppressing successive infixes of length `x` of the items in `y`; here we want to surpress successive columns to get "minors", so we transpose `|:` the lower rows (or tail `}.`) of `y`, and then recurse on the transpose of their outfixes.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~94 90 89 84~~ 80 bytes
-4 bytes thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor) (using sets instead of lists)!
```
f=lambda x,y={-1}:x>[]and max(e+f(x[1:],y|{i})for(i,e)in enumerate(x[0])if{i}-y)
```
[Try it online!](https://tio.run/##XVDLasMwELz7K@YWia5K5KRJa3B@RNVBJTIV1EqwHZBx/e3uyqQ09KTR7Mzs4zoOn5e4W5am/nLtx9kh0VhPSs9VOhnr4hmtS8I/NSIZXVkav6cwy@bSiUBehggfb63v3OBZsLUyNFxXo1xS6lHjvQAMjNHWMqKMCDvLYH0fyD2hzPwL4UD406uSoEptyejXLHmwlPcotmZXhkcCq97@qzj@nr1ff2unw1o7/jazRcFrgcfmrXj6irlrF@IgNtMMdcI0b55Z0bpBpJ74IL2UcvkB "Python 3 – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~12 11~~ 9 bytes
```
▲mȯΣ►L∂PT
```
[Try it online!](https://tio.run/##yygtzv6fG5yvnaCtpKBrp6B0Yn3xo6bGokPb/j@atin3xPpzix9N2@XzqKMpIOT//@how9hYBTxAF2iEIRdQmY5xrA6YjMWlzASszETHCKjQVMdMB4vJIGWWQGW6Rjq6RoYgAy2AyrEqMwCbZgS21kQHaB6QNtex0LFEKAe7zRSmTscEbK8JkAVygRlQzBziBrA6M4i1CrpAaxWidQ2BLHSbQep0jSBhguplTJ9hegK3ewm5EGoWyCigu0DOAgA "Husk – Try It Online")
Thanks to [BMO](https://codegolf.stackexchange.com/users/48198/bmo) for suggesting a port of [ais523's answer](https://codegolf.stackexchange.com/a/177714/59487) and a 2-byte save, which I managed to improve on further, and in turn BMO shaved off 2 more bytes.
---
## Previous solution (14 bytes)
```
▲moΣz!¹fS=uΠmŀ
```
[Try it online!](https://tio.run/##yygtzv7//9G0Tbn55xZXKR7amRZsW3puQe7Rhv//o6MNY2MV8ABdXTsFQy6gMh3jWB0wGYtLmQlYmYmOEVChqY6ZDhaTQcosgcp0jXR0jQxBBloAlWNVZgA2zQhsrYkO0Dwgba5joWOJUA52mylMnY4J2F4TIAvkAjOgmDnEDWB1Zv9xmgcA "Husk – Try It Online")
I wasn't able to make a test suite because this answer uses the *first command line argument* command explicitly. But Husk doesn't use STDIN at all so I included all the test cases there, so you can just copy paste in the argument field to check it out. Also note that arrays in Husk may not contain spaces between elements while being inputted.
### How it works?
**Code breakdown**
```
▲moΣz!¹fS=uΠmŀ     Full program. Takes a 2D list from CLA 1 and outputs to STDOUT.
            mŀ     Length range of each list. 
           Π       Cartesian product.
       fS=u        Discard those combinations which have at least 1 non-unique element.
 mo                Map over the combinations with the following predicate:
    z!¹            Zip the 2D list input with the current combination and index accordingly.
   Σ               Sum the resulting elements.
▲                  Finally, pick the maximum.
```
**Example**
Let's pick an example: $$\left(\begin{matrix}1&4&2\\5&6&1\end{matrix}\right)$$
One must pick exactly one index from each such that no two indices correspond. So, we generate the length ranges of the rows and only keep those without duplicates, yielding the following combinations (each combination is a column instead of a row to save space):
$$\left(\begin{matrix}\color{red}{1}&\color{blue}{2}&\color{green}{1}&\color{orange}{3}&2&\color{pink}{3}\\\color{red}{2}&\color{blue}{1}&\color{green}{3}&\color{orange}{1}&3&\color{pink}{2}\end{matrix}\right)$$
Then, the program indexes in the input lists with each element of the combination, returning:
$$\left(\begin{matrix}
\color{red}{1}&\color{blue}{4}&\color{green}{1}&\color{orange}{2}&4&\color{pink}{2}\\
\color{red}{6}&\color{blue}{5}&\color{green}{1}&\color{orange}{5}&1&\color{pink}{6}
\end{matrix}\right)$$
Summing all those results (here, each column, for the aforementioned reason), one obtains all possible valid sums according to the criteria, in this case \$9\$.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~13~~ 12 bytes
```
ẈŒpQƑƇị"€¹§Ṁ
```
[Try it online!](https://tio.run/##y0rNyan8///hro6jkwoCj0081v5wd7fSo6Y1h3YeWv5wZ8P/w@1AjkLk///R0dGGsbFcOkBKR8E4VkcBQsNETHQUjECCpjoKZjoKUJW6RjoKukaGYMUWIAUw1UZQI4C6QBpATHMdBaASSxQlQGOhZpqAeWAbzMBy5hBLYgE "Jelly – Try It Online")
### Alternate version, 11 bytes
```
ZLœ!Lị"€¹§Ṁ
```
This uses the newly added `œ!` built-in, which generates all permutations of a given length.
[Try it online!](https://tio.run/##y0rNyan8/z/K5@hkRZ@Hu7uVHjWtObTz0PKHOxv@H24HchQi//@Pjo42jI3l0gFSOgrGsToKEBomYqKjYAQSNNVRMNNRgKrUNdJR0DUyBCu2ACmAqTaCGgHUBdIAYprrKACVWKIoARoLNdMEzAPbYAaWM4dYEgsA "Jelly – Try It Online")
### How it works
```
ẈŒpQƑƇị"€¹§Ṁ  Main link. Argument: M (matrix)
Ẉ             Widths; compute the length of each row.
              For an n×m matrix, this yields an array m copies of n.
 Œp           Cartesian product; promote each n to [1, ..., n], then form all arrays
              that pick one k out of all m copies of [1, ..., n].
   QƑƇ        Comb by fixed unique; keep only arrays that do not change by
              deduplicating their entries.
         ¹    Identity; yield M.
      ị"€     For each of the arrays of unique elements, use its m entries to index
              into the m rows of M.
          §   Take the sums of all resulting vectors.
           Ṁ  Take the maximum.
```
[Answer]
# JavaScript (ES6), ~~74~~ 71 bytes
*Thanks to @tsh for identifying 2 useless bytes that were used to fix a bug*  
*Saved 3 bytes thanks to @tsh*
```
f=([a,...r],k,i=1)=>a?Math.max(...a.map(n=>k&(i+=i)?-1/0:n+f(r,k|i))):0
```
[Try it online!](https://tio.run/##jZFNjsIwDEb3cwqvRolw0iZTyo8UOAEnqLKIgEIotKggxIK7F6cgFlPoTDZ25Ojpe/HOXdxpWfvjWZTVat00uWGZQyllbbFAbxQ3MzdfuPNWHtyV0cBRc2SlmRXfzA@M53OhonhaDnJWY3HznPNp3Cyr8lTt13JfbVjOskxZyzn870QRqK8OAOHHIjzqHywCJO8ACYIOjCFCitATiQCTDkBoBKGVxUyNA6gvBAHidwn004KShBChHSEQbvILF/5g@IlAJk@NpL21Umk7G728AiHtSqggEd63Or1rIYLQzR0 "JavaScript (Node.js) – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), 65 bytes
```
f(u:v)=maximum[e+f(take i<>drop(i+1)<$>v)|(i,e)<-zip[0..]u]
f _=0
```
[Try it online!](https://tio.run/##RYw9b4MwEIZ3fsWpymCLAwVKk7QyLO3YTB0RqixhghVsIzBJVPW/0wOGLs99PO9dK8er6rpZm94NHj6kl/HZWadrYMBEwYEHc8OmtxvPjXxoM5lShQ3z8qpAi6IeXM90mHCxK278l2lUXEQ/ui/3cVxNVdDAd76fjdQWcjCyPwOwfvJffvi0EMPFcWKnrRohFwIuyr8765X1I9xbNagAKAMPsgvCEJ4gKgjUja27A2tgB4OSNWk@l2VSVQERnytcuU0ZpjS/4AE3H6UYpckSOZHZMul6kyGlqB7xhK//BrP1PqNu@XSg3XH59Qc "Haskell – Try It Online")
## Explanation & Ungolfed
The function `take i<>drop(i+1)` takes a list and removes the element at position `i`.
The function `f` gets each possible element `e` at position `i`, removes the elements at position `i` from the remaining elements and adds `e` to the recursively computed optimum:
```
f(u:v)=maximum[e+f(removeElementAt i<$>v)|(i,e)<-zip[0..]u]
```
And the base case for the empty list is just `0`:
```
f _=0
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 18 bytes
```
{hl⟦kp;?z₀∋₍ᵐ+}ᶠot
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/vzoj59H8ZdkF1vZVj5oaHnV0P2rqfbh1gnbtw20L8kv@/4@ONtRRMNJRMNZRMInVUYg2BdJgnhGIZwaWM9dRMIyN/R8FAA "Brachylog – Try It Online")
### Explanation
```
                ot      The output is the biggest result of…
{             }ᶠ        …finding all outputs to the following predicate:
 hl⟦k                     Construct the range [0, …, n-1]
     p                    Take a permutation of that range
      ;?z₀                Zip that permutation with the Input, stopping when all elements of
                            the input are used (important because the range is possibly
                            bigger than the length of the input)
          ∋₍ᵐ             In each element of the zip, take the head'th element of the tail
             +            Sum the result
```
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 40, 32, 28, 19 bytes
-13 bytes thanks to ngn!
```
{|/+/(prm'x)@''!#x}
```
[Try it online!](https://tio.run/##y9bNz/7/P82qukZfW1@joChXvULTQV1dUbmi9n@agoahgpGCsYKJtYKpggmQYWStYAYUMVcw1PwPAA "K (oK) – Try It Online")
## Initial solution:
```
{|/+/'x./:/:(*t),'/:t:{x~?x}#+!(#x)##*x}
```
[Try it online!](https://tio.run/##Dcg7DoAgDADQq9R04Kc2IGpSBm/DwuDC0ETx6sj28spyl94zPy85UrISE2tbzayIKz/yXdLQTRrFIFppPYP2EGCDmGCHOBASHGNO8Kb/ "K (oK) – Try It Online")
Note: Doesn't work for the first test case [[1]]
## Explanation:
`{ }` - function with argument `x`
```
                                   #     - creata a list
                               (#x)      - with length number of rows of x
                                    #*x  - of the length of the first row
                              !          - odometer (ranged permutations)
                             +           - transpose
                            #            - filter out the rows
                      {x~?x}             - that have duplicates
                    t:                   - save it to t 
                ,'/:                     - pair up each number in each row with
            (*t)                         - a number from the first row
      x./:/:                             - index x with each of the above
   +/'                                   - find the sum of each row
 |/                                      - reduce by max
```
[Answer]
# [Haskell](https://www.haskell.org/), 65 bytes
```
([]%)
p%(h:t)=maximum[x+(i:p)%t|(i,x)<-zip[0..]h,all(/=i)p]
p%_=0
```
[Try it online!](https://tio.run/##RYxNT4QwEIbv/IqJWZI2DLiL7Icb6sWrnjxiY5q1QGOBBrpZYvzt4gAHL09n@rzv1Gr40tZOpXifWCFDHriQ1WfPRaNG01ybYoyYOTse@h9mcOR5/G1csU0SWaOylt0Lw52k1ofYTo0yLQholHsFYO7q33z/0kICVceJ1rR6AJHnUGn/3LVet36AW617HQBlYCQ7I4rgDuInAk1D3d2AlbCBXqtP0nwqip2UAREfJC5ctwxT2vd4wNXHKcbpbo6cyKyZdOlkSCl6j3jCx3@D2dLPaJovHejvON/6vZRWVcMUX5z7Aw "Haskell – Try It Online")
---
**71 bytes**
```
f m=maximum[sum b|(a,b)<-unzip<$>mapM(zip[0..])m,[x|x<-a,y<-a,x==y]==a]
```
[Try it online!](https://tio.run/##RYyxbsIwEIZ3nuJUMSTiHEGaApVsFtZ26mh5MKohUWMnih1hKt49PSdDl8//@f/uau1/TNtO0xWssDo2drTSjxYuz0zjJedsdL9Nz9cnq/vPjKLcFoXKLcr4jJxpfCREIR5KCK0mqxsHApINkPVj@ArDh4MCbl1ObBtnPAjO4WbCuXPBuODhXpvBrIAciNQmbDbwAuxEoOTr7g7ZFdYwGP1NdT5JuVNqRcRXhTOXqcKS5jfc49KzElm5S8qRmsUp550KyaL3gEd8/2@wmvcrSunSnv4O6dYf "Haskell – Try It Online")
The `[x|x<-a,y<-a,x==y]==a` checks that the elements of `a` are distinct. This uses up a surprising number of characters, but I didn't see a shorter way.
[Answer]
# [J](http://jsoftware.com/), 14 bytes
```
{:@$>./ .+@{.]
```
[Try it online!](https://tio.run/##RY7NCgIxDITvfYpBhEVMq8l2/wqKIHjy5HUpe/PgK/jwa9JdFdomzTfT6WveBFRPnBIqwhFJtw@4Pu63@Z0u23M4IOwv75Dn3fwEg7fsrNaU9ChthFBq0MLIJLpYYQ8pVFQaoZhShx7Dd4hIjVprM7c66H52dU@snXNVNZYvuXHknOHPqtGWUGfCUss0LtNIEAMNaRpWx6DMC8ELZxq5N00Bx8Uk62tqNp@1HUFlw5rY/HUasb4fy62ktYV1v0Buv4ls2LNlL8iL230A "J – Try It Online")
When I saw [xnor's comment](https://codegolf.stackexchange.com/questions/177673/non-overlapping-matrix-sum?rq=1#comment428500_177673)
> 
> For square arrays, this is the matrix permanent over the tropical semiring which uses the operations (max, +) in place of (+, \*).
> 
> 
> 
I immediately realized that it must be a job for J's generalized determinant/permanent built-in `f . g`. The permanent is `+/ .*`, so the modified permanent is `>./ .+` (6 bytes). Unfortunately this only works with square arrays (horizontally longer arrays give negative infinity `__` for some reason), so I needed to pad the input with zeros to make it square.
```
{:@$>./ .+@{.]    NB. Tacit function, input: a matrix
{:@$              NB. The horizontal length of the matrix
           {.]    NB. Pad the matrix with zeros at the bottom to make it square
    >./ .+@       NB. Compute the modified permanent over the square matrix
```
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), ~~50~~ 49 bytes
```
{max map *.map({.[$++]}).sum,permutations [Z] $_}
```
[Try it online!](https://tio.run/##bU7bCoJAEH3vK86DhOYo7GZaRD/SssQ@KARtLV4gEb992zUJEl9m5nBuY8r6kVvdY1vhAjto9YZWBrvUzXBIRRDHcozSptNkylp3rWrvr2cDcZUIbqNtVI8qFIJJGZ03P0TYS8J3L4iMwD13IOSEf1/CCQlnkgQ7etnCyudYF@Hd/iwITnlaU7qquSeb0NSaT1yxWsy8IGH@BU/aDw "Perl 6 – Try It Online")
Decently short, even despite the long `permutations` call. This is an anonymous code block that takes a list of lists and returns a number.
### Explanation:
```
{                                               } # Anonymous code block
 max                                              # Finds the maximum
                             permutations         # Of all permutations
                                          [Z] $_  # Of the transposed input
     map                                          # When mapped to
                        .sum # The sum of
         *.map({.[$++]})     # The diagonal of the matrix
```
[Answer]
# Pyth, ~~15~~ 12 bytes
```
[[email protected]](/cdn-cgi/l/email-protection)
```
Try it online [here](https://pyth.herokuapp.com/?code=eSms%40VQd.plh&input=%5B%5B1%2C2%2C3%5D%2C%5B4%2C5%2C6%5D%2C%5B7%2C8%2C9%5D%5D&debug=0).
```
[[email protected]](/cdn-cgi/l/email-protection)   Implicit: Q=eval(input())
                Trailing Q inferred
          lhQ   Length of first element of Q
        .p      Generate all permutaions of 0 to the above
  m             Map the elements of the above, as d, using:
    @VQd          Vectorised index into Q using d
                    For i in [0-length(Q)), yield Q[i][d[i]]
   s              Take the sum of the above
 S              Sort the result of the map
e               Take the last element of the above, implicit print
```
*Edit: saved 3 bytes courtesy of issacg*
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~18~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
нgLœε‚øε`è]OZ
```
~~I have the feeling it's overly long, but I'm not sure how to do vectorized indexing byte-efficiently in 05AB1E..~~ And I was indeed right that it was too long.. -5 bytes thanks to *@Emigna*.
[Try it online](https://tio.run/##ATEAzv9vc2FiaWX//9C9Z0zFk8614oCaw7jOtWDDqF1Pw6D//1tbMSw0LDJdLFs1LDYsMV1d) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WeXhCqL2SwqO2SQpK9v8v7E33OTr53NaIykcNsw7vOLc14fCK2lr/wwv@6/yPjo42jI3VUQBSOsaxOmASyjXRMQIKmOqY6UBV6Brp6BoZghRZAKWgqozA2kx0gOqAtLmOhY4lkpSOCdgIEyALZJgZUMwcZFwsAA).
**Explanation:**
```
н                # Take the first inner list (of the implicit input list of lists)
 g               # Pop and take its length
  L              # Create a list in the range [1, inner-length]
   œ             # Create each possible permutation of this range-list
    ε            # Map each permutation to:
     ‚           #  Pair it with the (implicit) input
      ø          #  Transpose; swap rows/columns
       ε         #  Map each to:
        `        #   Push both to the stack
         è       #   Index the permutation-nr into the inner list of the input
    ]            # Close both maps
     O           # Take the sum of each inner list
      à          # Pop and push the maximum (and output implicitly)
```
**Example run:**
* Input: `[[1,4,2],[5,6,1]]`
* After step 1 (`нgL`): `[1,2,3]`
* After step 2 (`œ`): `[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]`
* After step 3 (`ε‚`): `[[[[1,4,2],[5,6,1]],[1,2,3]],[[[1,4,2],[5,6,1]],[1,3,2]],[[[1,4,2],[5,6,1]],[2,1,3]],[[[1,4,2],[5,6,1]],[2,3,1]],[[[1,4,2],[5,6,1]],[3,1,2]],[[[1,4,2],[5,6,1]],[3,2,1]]]`
* After step 4 (`ø`): `[[[[1,4,2],1],[[5,6,1],2]],[[[1,4,2],1],[[5,6,1],3]],[[[1,4,2],2],[[5,6,1],1]],[[[1,4,2],2],[[5,6,1],3]],[[[1,4,2],3],[[5,6,1],1]],[[[1,4,2],3],[[5,6,1],2]]]`
* After step 5 (`ε`è]`): `[[4,1],[4,5],[2,6],[2,5],[1,6],[1,1]]` (NOTE: 05AB1E is 0-indexed (with automatic wraparound), so indexing `3` into `[5,6,1]` results in `5`.)
* After step 6 (`O`): `[5,9,8,7,7,2]`
* Output / after step 7 (`à`): `9`
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
øœ€Å\Oà
```
Port of [*@ais523*'s Jelly CW answer](https://codegolf.stackexchange.com/a/177714/52210), so make sure to upvote it as well!
[Try it online](https://tio.run/##yy9OTMpM/f//8I6jkx81rTncGuN/eMH//9HRhjomOkaxOtGmOmY6hrGxAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/wzuOTn7UtOZwa4z/4QX/df5HR0cbxsbqKAApHeNYHTAJ5ZroGAEFTHXMdKAqdI10dI0MQYosgFJQVUZgbSY6QHVA2lzHQscSSUrHBGyECZAFMswMKGYOMi4WAA).
**Explanation:**
```
ø          # Transpose the (implicit) input; swapping row/columns
 œ         # Get all permutations
  €Å\      # Take the main diagonal of each
     O     # Sum each
      à    # Pop and push the maximum (which is output implicitly)
```
[Answer]
## Haskell, 84 bytes
```
import Data.List
h l=maximum[sum$snd<$>r|r<-mapM id$zip[1..]<$>l,(==)=<<nub$fst<$>r]
```
[Try it online!](https://tio.run/##ZY3NCsIwEITvPsUceqiwLaT@Q@PJoz5B2ENEpcGmliYFEd@9NrWg6Gl3Z7@ZKbS7nsuy64ytb43HTnud7o3zkwKltPpubGuVa23kqlMebZtnkydW1weYU/QwtRJpyr1eUizlVOZ51R6ji/MB5c5qU0Fi4OO6MZVHimIKNQGglGCmcSPMmPCeX@KckAV9QVgSPnySEZJMMCmxDsiXJRujemtwhXVF6KnNL9XHj9nz4RqalsNv9VcmwjMRoZYZ4O4F "Haskell – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~74~~ ~~72~~ 69 bytes
```
->a{[*0...a[0].size].permutation.map{|x|a.zip(x).sum{|y,z|y[z]}}.max}
```
[Try it online!](https://tio.run/##RY3LDoIwEEX3fMUkbtRMJ4A8ZCE/0syiGogsUMIj4VG@HVsguGpnzr1z6u45LPljEama5NUlIiVdpqYYM6Yqq8uuVW3x/VCpqkn3WtFYVOf@Qk1XTnrAUQ9y5Hk2vJ8X6UjpMeMJRAqeHRBujLC9@z7Y9gGCb1GIECEcrcRQ4SMI32OU3t2mduRuRX@/aQ7Yrv3GCCaYHObwnzSi3RKs0@qMVhav2q0ROUyZer0n3eoKctnyvPwA "Ruby – Try It Online")
]