How is kinetic energy $T$ given by $T=\dfrac{1}{2}\sum_{i}p_{i}\dot{q_{i}}$ in Hamiltonian and Lagrangian mechanics? Im going through a website teaching Hamiltonian mechanics and I know the below
$$-\dot{p}_{i}=\dfrac{\partial H}{\partial q_{i}} \tag{14.3.12}$$
$$\dot{q}_{i}=\dfrac{\partial H}{\partial p_{i}} \tag{14.3.13}$$
$$p_{i}=\dfrac{\partial L}{\partial\dot{q_{i}}} \tag{A}$$
$$\dot{p_{i}}=\dfrac{\partial L}{\partial q_{i}} \tag{B}$$
$$H=\sum_{i}p_{i}\dot{q_{i}}-L$$
Based on these how can I write (as quoted on the site):

Now the kinetic energy of a system is given by  $T=\dfrac{1}{2}\sum_{i}p_{i}\dot{q_{i}}$.

Website: https://phys.libretexts.org/Bookshelves/Classical_Mechanics/Book%3A_Classical_Mechanics_(Tatum)/14%3A_Hamiltonian_Mechanics/14.03%3A_Hamilton's_Equations_of_Motion
 A: The analysis you quote assumes that the system is not constrained (in the sense of Dirac). Let us assume this simple case. The Lagrangian formulation uses variables $ (q^i, \dot{q}^i), i \in\{1, 2, 3\}$, while the Hamiltonian one uses variables $ (q^i, p_i), i \in\{1, 2,3\}$ (for simplicity I take one particle with 3 DoF, otherwise another index would be necessary to count particles). The author of that paragraph (or course) mixes the formulations, which is confusing, if not utterly wrong.
So it is either:
$$T_{\text{Lag}}=\frac{1}{2}\sum_{i,j=1}^{3} m g_{ij}(q^i)\dot{q}^i\dot{q}^j,\tag{1}$$
or:
$$T_{\text{Ham}}=\frac{1}{2}\sum_{i,j=1}^{3} m g^{ij}(q^i)p_i p_j,\tag{2}$$
with the so-called "kinetic matrix" or "metric tensor" $g$ plugged in in order to account for possible non-Cartesian coordinates in configurations space (think of a particle constrained to move on the surface of a sphere, one has 2 DoF, but must use non-Cartesian coordinates).
And clearly $T$ is not/should not be something in between.
