[Question]
  [
A [highly composite number](https://en.wikipedia.org/wiki/Highly_composite_number) is a positive integer that has more divisors than any smaller positive integer has. This is [OEIS sequence A002182](https://oeis.org/A002182). Its first 20 terms are
```
1, 2, 4, 6, 12, 24, 36, 48, 60, 120, 180, 240, 360, 720, 840, 1260, 1680, 2520, 5040, 7560
```
For example, `4` is in the sequence because it has 3 divisors (namely 1, 2, 4), whereas 3 only has 2 divisors, 2 also has 2 divisors, and 1 has 1 divisors.
### Challenge
Given a positive integer input *n*, output either the *n*-th highly composite number or the first *n* highly composite numbers, at your choice (but the choice must be the same for every input *n*).
### Rules
The program or function should theoretically work for arbitrarily large inputs given infinite time and memory, and without considering data type limitations. Essentially, this means no hardcoding a finite number of values.
In practice, the program or function should run in a reasonable amount of time, say less than 1 minute, for *n* up to 20. Maximum input or output may be limited by your language standard data type (but again, the algorithm should theoretically work for arbitrarily large numbers).
Any reasonable input and output format is allowed, including unary.
Code golf. Fewest bytes wins.
  
[Answer]
# Jelly, 15 bytes
```
,®ÆDL€ṛ©0>/?µƓ#
```
For input **n**, this prints the first **n** highly composite numbers.
For **n = 20**, it takes less than two seconds on [Try it online!](http://jelly.tryitonline.net/#code=LMKuw4ZETOKCrOG5m8KpMD4vP8K1xpMj&input=MjA)
### How it works
```
,®ÆDL€ṛ©0>/?µƓ#  Main link. No implicit input.
            µ    Push the chain to the left on the local link stack.
             Ɠ   Read an integer n from STDIN.
              #  Execute the chain for k = 0, 1, 2, ..., until it returned a truthy
                 value n times. Return the list of matches.
,®               Pair k with the value in the register (initially 0).
  ÆD             Compute the divisors of k and the register value.
    L€           Count both lists of divisors.
           ?     If
         >/        k has more divisors than the register value:
      ṛ©             Save k in the register and return k.
        0          Else: Return 0.
```
## Alternate version, 13 bytes (non-competing)
While the below code worked in the latest version of Jelly that precedes this challenge, the implementation of `M` was very slow, and it did not comply with the time limit. This has been fixed.
```
ÆDL®;©MḢ’>µƓ#
```
[Try it online!](http://jelly.tryitonline.net/#code=w4ZETMKuO8KpTeG4ouKAmT7CtcaTIw&input=MjA)
### How it works
```
ÆDL®;©MḢ’>µƓ#  Main link. No implicit input.
          µ    Push the chain to the left on the local link stack.
           Ɠ   Read an integer n from STDIN.
            #  Execute the chain for k = 0, 1, 2, ..., until it returned a truthy
               value n times. Return the list of matches.
ÆD             Compute the divisors of k.
  L            Count them.
   ®;          Append the count to the list in the register (initially 0 / [0]).
     ©         Save the updated list in the register.
      M        Obtain all indices the correspond to maximal elements.
       Ḣ       Retrieve the first result.
        ’>     Subtract 1 and compare with k.
               This essentially checks if the first maximal index is k + 2, where
               the "plus 2" accounts for two leading zeroes (initial value of the
               register and result for k = 0).
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~15~~ 14 bytes
The input in zero-indexed. That means that `n = 0` gives `1`, `n = 1` gives `2`, etc. Code:
```
$µ>DÑgD®›i©¼}\
```
Explanation:
```
$               # Pushes 1 and input
 µ              # Counting loop, executes until the counting variable is equal to input
  >             # Increment (n + 1)
   DÑ           # Duplicate and calculate all divisors
     gD         # Get the length of the array and duplicate
       ®        # Retrieve element, standardized to zero
        ›i  }   # If greater than, do...
          ©     #   Copy value into the register
           ¼    #   Increment on the counting variable
             \  # Pop the last element in the stack
```
Calculates *n = 19*, which should give `7560` in about 10 seconds.
[Try it online!](http://05ab1e.tryitonline.net/#code=JMK1PkTDkWdEwq7igLppwqnCvH1c&input=MTk)
Uses **CP-1252** encoding.
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), ~~26~~ 24 bytes
```
~XKx`K@@:\~s<?@5MXKx]NG<
```
[**Try it online!**](http://matl.tryitonline.net/#code=flhLeGBLQEA6XH5zPD9ANU1YS3hdTkc8&input=MTA)
The current largest number of divisors found is kept in clipboard K. Highly composite numbers (HCN) are kept directly on the stack. A loop keeps testing candidates to HCN. When one is found it is left on the stack, and clipboard K is updated. The loop exits when the desired number of HCN have been found.
```
~         % take input implicitly (gets stored in clipboard G). Transform into a 0 
          % by means of logical negation
XKx       % copy that 0 into clipboard K, and delete
`         % do...while
  K       %   push largest number of divisors found up to now
  @       %   push iteration index, i: current candidate to HCN
  @:      %   range [1,...,i]
  \       %   modulo operation
  ~s      %   number of zeros. This is the number of divisors of current candidate
  <       %   is it larger than previous largest number of divisors?
  ?       %   if so: a new HCN has been found
    @     %     push that number
    5M    %     push the number of divisors that was found
    XKx   %     update clipboard K, and delete
  ]       %   end if
  N       %   number of elements in stack
  G<      %   is it less than input? This the loop condition: exit when false
          % end do...while implicitly
          % display all numbers implicitly
```
[Answer]
## Perl, ~~60~~ 57 + 1 = 58 bytes
```
$,++;$==grep$,%$_<1,1..$,;$_--,$m=$=if$=>$m;$_?redo:say$,
```
Requires `-n` and the free `-M5.010`|`-E`:
```
$ perl -nE'$,++;$==grep$,%$_<1,1..$,;$_--,$m=$=if$=>$m;$_?redo:say$,' <<< 10 
120
```
How it works:
```
$,++;
     $==grep$,%$_<1,1..$,;                                # Calculate total numbers of divisors for `$,`
                          $_--,$m=$=if$=>$m;              # Set `$m`ax divisors to `$=`ivisors if `$m>$=`
                                            $_?redo:say$, # Repeat or print
```
[Answer]
# JavaScript (ES6) 72
Straightforward implementation. Time near 20 sec for input 20
```
x=>{for(i=e=n=0;i<x;d>e&&(++i,e=d))for(d=1,j=++n;--j;)n%j||++d;return n}
```
The eval trick could save a byte doubling the run time
```
x=>eval("for(i=e=n=0;i<x;d>e&&(++i,e=d))for(d=1,j=++n;--j;)n%j||++d;n")
```
**Less golfed**
```
x=>{
  for(i = e = 0, n = 1; i < x; n++)
  {
    for(d = 1, j = n; --j; )
    {
      if (n%j == 0) 
        ++d;
    }
    if (d > e)
      ++i,
      e = d;
  }
  return n;
}
```
[Answer]
# Pyth, ~~17~~ 16 bytes
*1 byte thanks to Jakube*
```
uf<Fml{yPd,GTGQ1
```
[Test suite](https://pyth.herokuapp.com/?code=uf%3CFml%7ByPd%2CGTGQ1&test_suite=1&test_suite_input=0%0A9%0A19&debug=0)
Takes a 0-indexed **n**, and returns the **nth** highly composite number.
Explanation:
```
uf<Fml{yPd,GThGQ1
                     Input: Q = eval(input())
u              Q1    Apply the following function Q times, starting with 1.
                     Then output the result. lambda G.
 f           hG      Count up from G+1 until the following is truthy, lambda T.
          ,GT        Start with [G, T] (current highly comp., next number).
    m                Map over those two, lambda d.
        Pd           Take the prime factorization of d, with multiplicity.
       y             Take all subsets of those primes.
      {              Deduplicate. At this point, we have a list of lists of primes.
                     Each list is the prime factorization of a different factor.
     l               Take the length, the number of factors.
  <F                 Check whether the number of factors of the previous highly
                     composite number is smaller than that of the current number.
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
1Æd€<Ṫ$PƊ#
```
[Try it online!](https://tio.run/##y0rNyan8/9/wcFvKo6Y1Ng93rlIJONal/P@/KQA "Jelly – Try It Online")
Returns the first \$n\$ highly composite numbers.
My guess is that this uses features unavailable when Dennis first posted a [Jelly answer](https://codegolf.stackexchange.com/a/74512/66833), but this uses a sufficiently different algorithm that I thought it was ok to post as a separate answer
## How it works
```
1Æd€<Ṫ$PƊ# - Main link. Takes no arguments
1       Ɗ# - Read an integer n from STDIN and run the following over k = 1, 2, 3, ... until n return true:
   €       -   Generate the range [1, 2, ..., k] and do the following over each:
 Æd        -     Calculate the divisor count of each, yielding [σ₀(1), σ₀(2), ..., σ₀(k)]
      $    -   Group the previous two commands together:
     Ṫ     -     Remove σ₀(k) from the list and return it
    <      -     Generate [σ₀(1)<σ₀(k), σ₀(2)<σ₀(k), ..., σ₀(k-1)<σ₀(k)]
       P   -   Are all values true?
```
[Answer]
# Ruby, ~~70~~ ~~69~~ ~~67~~ ~~66~~ ~~64~~ 62
```
->n{r=k=0
0until(r<t=(1..k+=1).count{|d|k%d<1})&&1>n-=t/r=t
k}
```
Straightforward implementation.
[Answer]
# C, 98 bytes
```
f,i,n,j;main(m){for(scanf("%d",&n);n--;printf("%d ",i))for(m=f;f<=m;)for(j=++i,f=0;j;)i%j--||f++;}
```
Try it [here](http://ideone.com/EyeFyl).
## Ungolfed
```
f,i,n,j;
main(m)
{
    for(scanf("%d",&n); /* Get input */
            n--; /* Loop while still HCN's to calculate... */
            printf("%d ",i)) /* Print out the last calculated HCN */
        for(m=f;f<=m;) /* Loop until an HCN is found... */
            for(j=++i,f=0;j;) /* Count the number of factors */
                i%j--||f++;
}
```
[Answer]
# Python 3, 97 bytes
```
i=p=q=0;n=int(input())
while q<n:
 c=j=0;i+=1
 while j<i:j+=1;c+=i%j==0
 if c>p:p=c;q+=1
print(i)
```
A full program that takes input from STDIN and prints the output to STDOUT. This returns the `n`th 1-indexed highly composite number.
**How it works**
This is a straightforward implementation. The input `n` is the highly composite number index.
The program iterates over the integers `i`. For each integer `j` less than `i`, `i mod j` is taken; if this is `0`, `j` must be a factor of `i` and the counter `c` is incremented, giving the number of divisors of `i` after looping. `p` is the previous highest number of divisors, so if `c > p`, a new highly composite number has been found and the counter `q` is incremented. Once `q = n`, `i` must be the `n`th highly composite number, and this is printed.
[Try it on Ideone](https://ideone.com/tax8lp)
(This takes ~15 seconds for `n = 20`, which exceeds the time limit for Ideone. Hence, the example given is for `n = 18`.)
[Answer]
# Python 2, 207 bytes
```
n,i,r,o=input(),1,[],[]
while len(o)<n:
 r+=[(lambda n:len(set(reduce(list.__add__,([i,n//i]for i in range(1,int(n**0.5)+1)if n%i==0)))))(i)];h=max(r)
 if r.index(h)>i-2 and r.count(h)<2:o+=[i]
 i+=1
print o
```
Uses the same method as Dennis' Jelly answer. Calculates the first 20 terms in `<2` seconds.
]