The teacher gave each of her $37$ students $36$ pencils in different colors. It turned out that each pair of students received exactly one pencil of the same color. Determine the smallest possible number of different colors of pencils distributed.
1. **Establish a lower bound on the number of colors used:**
   - Each student receives 36 pencils, and each pair of students shares exactly one pencil of the same color.
   - Consider the first student who gets 36 differently colored pencils.
   - The second student must get one pencil that is the same color as one of the first student's pencils, and 35 pencils of different colors.
   - Continuing this pattern, the \(k^{\text{th}}\) student gets exactly one pencil matching a color of each of the previous \(k-1\) students. Even if these are all different pencils, the \(k^{\text{th}}\) student still must have \(36 - (k-1)\) pencils of colors different from the previous students.
   - Therefore, the total number of colors is at least:
     \[
     36 + 35 + 34 + \dots + 1 = \sum_{i=1}^{36} i = \frac{36 \cdot 37}{2} = \binom{37}{2}
     \]

2. **Verify that this number of colors is attainable:**
   - We need to show that it is possible to distribute pencils using exactly \(\binom{37}{2}\) colors.
   - Consider pencils of \(\binom{37}{2}\) colors, and label each color with a unique pair of numbers from \(\{1, 2, \dots, 37\}\).
   - Give a pencil of color \(\{a, b\}\) to students \(a\) and \(b\).
   - This ensures that each student receives 36 pencils, and each pair of students shares exactly one pencil of the same color.

Since both the lower bound and the construction match, we conclude that the smallest possible number of different colors of pencils distributed is \(\binom{37}{2}\).

\[
\binom{37}{2} = \frac{37 \cdot 36}{2} = 666
\]

The final answer is \(\boxed{666}\)