  We study the instanton partition functions of 5d maximal super Yang-Mills
theories with all classical gauge groups. They are computed from the ADHM
quantum mechanics of the D0-D4-O4 systems. Our partition functions respect
S-dualities of the circle compactified Yang-Mills theories and various
orientifold backgrounds. We also compute and study the $S^5$ partition
functions that correspond to the 6d (2,0) superconformal indices. Our SO(2N)
index takes the form of the vacuum character of $\mathcal{W}_D$ algebra in a
special limit, supporting the $\mathcal{W}$ algebra conjecture. We propose new
indices for (2,0) theories with outer automorphism twists along the temporal
circle, obtained from non-simply-laced SYMs on $S^5$.
