Navvye/Olympiad-Problems-CSV huggingface dataset:
Problem: Each vertex of a regular dodecagon ( $12$ -gon) is to be colored either red or blue, and thus there are $2^{12}$ possible colorings. Find the number of these colorings with the property that no four vertices colored the same color are the four vertices of a rectangle.

Solution: Note that a rectangle is formed if and only if it's diagonals pass through the center of the dodecagon and the diagonal's endpoints are the same color.
Consider the $6$ diagonals that pass through the center. A rectangle is formed if the endpoints of some pair of them are all the same color. We can now perform casework on the diagonals:
Case $1:$ The endpoints of all the diagonals are all different (e.g. for all diagonals, the endpoints are red and blue in some order).
The amount of ways to do this is $2^6=64,$ since there are $2$ ways to order which vertice is red and which is blue for each diagonal.
Case $2:$ There exists one diagonal such that the endpoints are the same color.
There are $6$ ways to choose this diagonal, $2$ ways to choose which color it is, and $2^5$ ways to color the rest of the diagonals. Therefore, the total for this case is $6 \cdot 2 \cdot 2^5 = 384.$
Case $3:$ There exists two diagonals such that the endpoints are the same color, but they are different colors
Then, there are $6 \cdot 5=30$ ways to choose these two diagonals, and $2^4=16$ ways to color the rest, so the total for this case is $30 \cdot 16 = 480.$
Summing all of the cases, we have $64+384+480=\boxed{928}.$

Answer:  928
Problem: Each vertex of a regular dodecagon ( $12$ -gon) is to be colored either red or blue, and thus there are $2^{12}$ possible colorings. Find the number of these colorings with the property that no four vertices colored the same color are the four vertices of a rectangle.

Solution: \[\text{First, we notice that a rectangle is made from two pairs of vertices 1/2 turn away from each other.}\]
\[\textit{Note: The image is }\frac{\textit{280}}{\textit{841}}\approx\frac{\textit{1}}{\textit{3}}\textit{ size.}\]
\[\text{For there to be no rectangles, there can be at most one same-colored pair for each color and the rest need to have one red and blue.}\]
\[\textit{\underline{Case 1: \textbf{No pairs}}}\]
\[\text{Each pair has two ways to color: One red or the other red. Thus, there are }2^6=\boxed{64}\]

Answer:  64
Problem: Let $\omega = \cos\frac{2\pi}{7} + i \cdot \sin\frac{2\pi}{7},$ where $i = \sqrt{-1}.$ Find the value of the product \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right).\]

Solution: For any $k\in Z$ , we have, \begin{align*} & \left( \omega^{3k} + \omega^k + 1 \right) \left( \omega^{3\left( 7 - k \right)} + \omega^{\left( 7 - k \right)} + 1 \right) \\ & = \omega^{3 \cdot 7} + \omega^{2k + 7} + \omega^{3k} + \omega^{-2k + 3 \cdot 7} + \omega^7 + \omega^k + \omega^{3\left( 7 - k \right)} + \omega^{\left( 7 - k \right)} + 1 \\ & = 1 + \omega^{2k} + \omega^{3k} + \omega^{-2k} + 1 + \omega^k + \omega^{-3k} + \omega^{-k} + 1 \\ & = 2 + \omega^{-3k} \sum_{j=0}^6 \omega^{j k} \\ & = 2 + \omega^{-3k} \frac{1 - \omega^{7 k}}{1 - \omega^k} \\ & = 2 . \end{align*} The second and the fifth equalities follow from the property that $\omega^7 = 1$
Therefore, \begin{align*} \Pi_{k=0}^6 \left( \omega^{3k} + \omega^k + 1 \right) & = \left( \omega^{3 \cdot 0} + \omega^0 + 1 \right) \Pi_{k=1}^3 \left( \omega^{3k} + \omega^k + 1 \right) \left( \omega^{3\left( 7 - k \right)} + \omega^{\left( 7 - k \right)} + 1 \right) \\ & = 3 \cdot 2^3 \\ & = \boxed{024}

Answer:  024
Problem: Let $\omega = \cos\frac{2\pi}{7} + i \cdot \sin\frac{2\pi}{7},$ where $i = \sqrt{-1}.$ Find the value of the product \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right).\]

Solution: Because the answer must be a positive integer, it is just equal to the modulus of the product. Define $z_n = \left(\textrm{cis }\frac{2n\pi}{7}\right)^3 + \textrm{cis }\frac{2n\pi}{7} + 1$
Then, our product is equal to
\[|z_0||z_1||z_2||z_3||z_4||z_5||z_6|.\]
$z_0 = 0$ , and we may observe that $z_x$ and $z_{7-x}$ are conjugates for any $x$ , meaning that their magnitudes are the same. Thus, our product is
\[3|z_1|^2|z_2|^2|z_3|^2\] \[= 3\left((\cos \frac{6\pi}{7} + \cos \frac{2\pi}{7} + 1)^2 + (\sin \frac{6\pi}{7} + \sin \frac{2\pi}{7})^2\right) \left((\cos \frac{12\pi}{7} + \cos \frac{4\pi}{7} + 1)^2 + (\sin \frac{12\pi}{7} + \sin \frac{4\pi}{7})^2\right) \left((\cos \frac{4\pi}{7} + \cos \frac{6\pi}{7} + 1)^2 + (\sin \frac{4\pi}{7} + \sin \frac{6\pi}{7})^2\right)\]
Let us simplify the first term. Expanding, we obtain
\[\cos^2 \frac{6\pi}{7} + \cos^2 \frac{2\pi}{7} + 1 + 2\cos \frac{6\pi}{7}\cos \frac{2\pi}{7} + 2\cos \frac{6\pi}{7} + 2\cos \frac{2\pi}{7} + \sin^2 \frac{6\pi}{7} + \sin^2 \frac{2\pi}{7} + 2\sin \frac{6\pi}{7}\sin \frac{2\pi}{7}.\]
Rearranging and cancelling, we obtain
\[3 + 2\cos \frac{6\pi}{7} + 2\cos \frac{2\pi}{7} + 2\cos \frac{6\pi}{7}\cos \frac{2\pi}{7} + 2\sin \frac{6\pi}{7}\sin \frac{2\pi}{7}.\]
By the cosine subtraction formula, we have $2\cos \frac{6\pi}{7}\cos \frac{2\pi}{7} + 2\sin \frac{6\pi}{7}\sin \frac{2\pi}{7} = \cos \frac{6\pi - 2\pi}{7} = \cos \frac{4\pi}{7}$
Thus, the first term is equivalent to
\[3 + 2(\cos \frac{2\pi}{7} + \cos \frac{4\pi}{7} + \cos \frac{6\pi}{7}).\]
Similarly, the second and third terms are, respectively,
\[3 + 2(\cos \frac{4\pi}{7} + \cos \frac{8\pi}{7} + \cos \frac{12\pi}{7}),\textrm{ and}\] \[3 + 2(\cos \frac{6\pi}{7} + \cos \frac{12\pi}{7} + \cos \frac{4\pi}{7}).\]
Next, we have $\cos \frac{2\pi}{7} + \cos \frac{4\pi}{7} + \cos \frac{6\pi}{7} = -\frac{1}{2}$ . This is because
\[\cos \frac{2\pi}{7} + \cos \frac{4\pi}{7} + \cos \frac{6\pi}{7} = \frac{1}{2}(\textrm{cis }\frac{2\pi}{7} + \textrm{cis }\frac{4\pi}{7} + \textrm{cis }\frac{6\pi}{7} + \textrm{cis }\frac{8\pi}{7} + \textrm{cis }\frac{10\pi}{7} + \textrm{cis }\frac{12\pi}{7})\]
\[= \frac{1}{2}(-1)\] \[= -\frac{1}{2}.\]
Therefore, the first term is simply $2$ . We have $\cos x = \cos 2\pi - x$ , so therefore the second and third terms can both also be simplified to $3 + 2(\cos \frac{2\pi}{7} + \cos \frac{4\pi}{7} + \cos \frac{6\pi}{7}) = 2$ . Thus, our answer is simply
\[3 \cdot 2 \cdot 2 \cdot 2\] \[= \boxed{024}.\]

Answer:  024
Problem: Let $\omega = \cos\frac{2\pi}{7} + i \cdot \sin\frac{2\pi}{7},$ where $i = \sqrt{-1}.$ Find the value of the product \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right).\]

Solution: We write out the product in terms of $\omega$ \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=3(\omega^3+\omega+1)(\omega^6+\omega^2+1)(\omega^9+\omega^3+1)(\omega^{12}+\omega^4+1)(\omega^{15}+\omega^5+1)(\omega^{18}+\omega^6+1).\]
Grouping the terms in the following way exploits the fact that $\omega^{7k}=1$ for an integer $k$ , when multiplying out two adjacent products from left to right:
\[\frac{1}{3} \prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=(\omega^3+\omega+1)(\omega^{18}+\omega^6+1)(\omega^6+\omega^2+1)(\omega^{15}+\omega^5+1)(\omega^9+\omega^3+1)(\omega^{12}+\omega^4+1).\]
When multiplying two numbers with like bases, we add the exponents. We can now rewrite the exponents of each product (two at a time, where $1$ is treated as the identity) as a series of arrays:
\[\textbf{(A)}\begin{bmatrix} 3&1 &0 \\ 18&6&0\\ \end{bmatrix}\]
\[\textbf{(B)}\begin{bmatrix} 6&2 &0 \\ 15&5&0\\ \end{bmatrix}\]
\[\textbf{(C)}\begin{bmatrix} 9&3 &0 \\ 12&4&0\\ \end{bmatrix}.\]
Note that $\omega=e^{\frac{2\pi i}{7}}$ . When raising $\omega$ to a power, the numerator of the fraction is $2$ times whatever power $\omega$ is raised to, multiplied by $\pi i$ . Since the period of $\omega$ is $2\pi,$ we multiply each array by $2$ then reduce each entry $\mod{14},$ as each entry in an array represents an exponent which $\omega$ is raised to.
\[\textbf{(A)}\begin{bmatrix} 6&2 &0 \\ 8&12&0\\ \end{bmatrix}\]
\[\textbf{(B)}\begin{bmatrix} 12&4 &0 \\ 2&10&0\\ \end{bmatrix}\]
\[\textbf{(C)}\begin{bmatrix} 4&6 &0 \\ 10&8&0\\ \end{bmatrix}.\]
To obtain the correct exponents, we seperately add each element of the lower row to one element of the top row.
Therefore (after reducing $\mod 14$ again), we get the following sets:
\[\textbf{(A)}\ \{0, 4, 6, 10, 0, 2, 8, 12, 0\}\] \[\textbf{(B)}\ \{0, 8, 12, 6, 0, 4, 2, 10, 0\}\] \[\textbf{(C)}\ \{0, 12, 4, 2, 0, 8, 10, 8, 0\}.\]
Raising $\omega$ to the power of each element in every set then multiplying over $\textbf{(A)}, \textbf{(B)},$ and $\textbf{(C)}$ yields
\[\frac{1}{3} \prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=\left(\sum_{a\in \textbf{(A)}} \omega^a\right)\left(\sum_{b\in \textbf{(B)}} \omega^b\right)\left(\sum_{c\in \textbf{(C)}} \omega^c\right)\]
\[=\left(\sum_{a\in \textbf{(A)}} \omega^a\right)^3\]
\[=\left(\omega^0+\omega^4+\omega^6+\omega^{10}+\omega^0+\omega^2+\omega^8+\omega^{12}+\omega^0\right)^3\]
\[=\left(3+\omega^2+\omega^4+\omega^6+\omega^8+\omega^{10}+\omega^{12}\right)^3,\] as these sets are all identical.
Summing as a geometric series,
\[\frac{1}{3} \prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=\left(3+\frac{\omega^2(\omega^{12}-1)}{\omega^2-1}\right)^3\]
\[=\left(3+\frac{\omega^{14}-\omega^2}{\omega^2-1}\right)^3\]
\[=\left(3+\frac{1-\omega^2}{\omega^2-1}\right)^3\]
\[=(3-1)^3=8.\]
Therefore,
\[\frac{1}{3} \prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=8,\] and \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right)=3\cdot8=\boxed{024}.\]

Answer:  024
Problem: Let $\omega = \cos\frac{2\pi}{7} + i \cdot \sin\frac{2\pi}{7},$ where $i = \sqrt{-1}.$ Find the value of the product \[\prod_{k=0}^6 \left(\omega^{3k} + \omega^k + 1\right).\]

Solution: The product can be factored into $-(r-1)(s-1)(t-1)(r-w)(s-w)(t-w)(r-w^2)(s-w^2)(t-w^2)....(r-w^6)(s-w^6)(t-w^6)$
where $r,s,t$ are the roots of the polynomial $x^3+x+1=0$
This is then $-(r^7-1)(s^7-1)(t^7-1)$ because $(r^7-1)$ and $(r-1)(r-w)(r-w^2)...(r-w^6)$ share the same roots.
To find $-(r^7-1)(s^7-1)(t^7-1)$
Notice that $(r^7-1)=(r-1)(r^6+r^5+r^4+r^3+r^2+r+1)$ . Since r satisfies $x^3+x+1=0$ $r^6+r^4+r^3=0$
Substituting, you are left with $r^5+r^2+r+1$ . This is $r^2(r^3+1)+r+1$ , and after repeatedly substituting $r^3+x+1=0$ you are left with $-2r^3$
So now the problem is reduced to finding $-(r-1)(s-1)(t-1)(-2r^3)(-2s^3)(-2t^3)=8(rst)^3(r-1)(s-1)(t-1)$ , and vietas gives you the result of $\boxed{24}$ -resources

Answer:  24
Problem: Let $N$ be the number of ways to place the integers $1$ through $12$ in the $12$ cells of a $2 \times 6$ grid so that for any two cells sharing a side, the difference between the numbers in those cells is not divisible by $3.$ One way to do this is shown below. Find the number of positive integer divisors of $N.$ \[\begin{array}{|c|c|c|c|c|c|} \hline \,1\, & \,3\, & \,5\, & \,7\, & \,9\, & 11 \\ \hline \,2\, & \,4\, & \,6\, & \,8\, & 10 & 12 \\ \hline \end{array}\]

Solution: We replace the numbers which are 0 mod(3) to 0, 1 mod(3) to 1, and 2 mod(3) to 2.
Then, the problem is equivalent to arranging 4 0's,4 1's, and 4 2's into the grid (and then multiplying by $4!^3$ to account for replacing the remainder numbers with actual numbers) such that no 2 of the same numbers are adjacent.
Then, the numbers which are vertically connected must be different. 2 1s must be connected with 2 2s, and 2 1s must be connected with 2 2s (vertically), as if there are less 1s connected with either, then there will be 2s or 3s which must be connected within the same number.
For instance if we did did:
- 12 x 3
- 13 x 1
Then we would be left with 23 x1, and 2 remaining 3s which aren't supposed to be connected, so it is impossible. Similar logic works for why all 1s can't be connected with all 2s.
Thus, we are left with the problem of re-arranging 2x 12 pairs, 2x 13 pairs, 2x 23 pairs. Notice that the pairs can be re-arranged horizontally in any configuration, but when 2 pairs are placed adjacent there is only 1 configuration for the rightmost pair to be set after the leftmost one has been placed.
We have $\frac{6!}{2!2!2!}=90$ ways to horizontally re-arrange the pairs, with 2 ways to set the initial leftmost column. Thus, there are 180 ways to arrange the pairs. Accounting for the initial simplification of the problem with 1-12 -> 0-3, we obtain the answer is:
\[2488320=2^{11}\cdot3^5\cdot5^1\]
The number of divisors is: $12\cdot6\cdot2=\boxed{144}.$ ~SAHANWIJETUNGA

Answer:  144
Problem: Let $N$ be the number of ways to place the integers $1$ through $12$ in the $12$ cells of a $2 \times 6$ grid so that for any two cells sharing a side, the difference between the numbers in those cells is not divisible by $3.$ One way to do this is shown below. Find the number of positive integer divisors of $N.$ \[\begin{array}{|c|c|c|c|c|c|} \hline \,1\, & \,3\, & \,5\, & \,7\, & \,9\, & 11 \\ \hline \,2\, & \,4\, & \,6\, & \,8\, & 10 & 12 \\ \hline \end{array}\]

Solution: Let's carry out an archaeological study, that is, we will find the bones (the base) and "build up the meat."
1. Let "bones" of number $X$ be $X \pmod 3.$ Then the “skeleton” of the original table is
\[1 0 2 1 0 2\] \[2 1 0 2 1 0\] By condition, the table cannot have a column of two identical numbers (the difference of such numbers is a multiple of $3).$
There are $4$ zeros, $4$ ones and $4$ twos in the table (the order of the numbers in the columns is not important).
Therefore, there cannot be more than two identical columns (otherwise there will be four identical numbers in the remaining three, that is, the numbers in one column are the same).
Any such table has exactly $2$ columns $(0,1), 2$ columns $(0,2)$ and $2$ columns $(1,2).$
The number of possible tables of six elements of three types is \[m = \frac {6!}{2! \cdot 2! \cdot 2!} = 2 \cdot 3^2 \cdot 5.\] The number of possible tables of six elements, if the order of the digits is important, is \[M = 2^6 \cdot m = 2^7 \cdot 3^2 \cdot 5.\] 2. We are looking for the total number of options.
The column $(0,1)$ can contain the following $4^2 = 16$ pairs of numbers (the order is not important, it is already taken into account) \[(1,3), (1,6), (1,9), (1, 12), (4.3), (4.6), (4.9) (4.12), (7.3), (7.6), (7.9), (7.12), (11,3), (11,6), (11,9), (11,12).\] The second column $(0,1)$ can contain $3^2 = 9$ pairs of numbers (excluding the two that are in the first column).
Similarly with the other two columns, i.e. the total number of choices \[M \cdot 16 \cdot 9 \cdot 3 = 2^{11} \cdot 3^5 \cdot 5.\] Number of divisors \[(11+1) \cdot (5+1) \cdot (1 + 1) = \boxed{144}.\] vladimir.shelomovskii@gmail.com, vvsss

Answer:  144
Problem: Find the number of collections of $16$ distinct subsets of $\{1,2,3,4,5\}$ with the property that for any two subsets $X$ and $Y$ in the collection, $X \cap Y \not= \emptyset.$

Solution: Denote the $A$ as $\{ 1,2,3,4,5 \}$ and the collection of subsets as $S$
Case 1: There are only sets of size $3$ or higher in $S$ Any two sets in $S$ must have at least one element common to both of them (since $3+3>5$ ). Since there are $16$ subsets of $A$ that have size $3$ or higher, there is only one possibility for this case.
Case 2: There are only sets of size $2$ or higher in $S$ Firstly, there cannot be a no size $2$ set $S$ , or it will be overcounting the first case.
If there is only one such size $2$ set, there are $10$ ways to choose it. That size $2$ set, say $X$ , cannot be in $S$ with $Y = A/X$ (a three element set). Thus, there are only $15$ possible size $3$ subsets that can be in $S$ , giving us $10$ for this case.
If there are two sets with size $2$ in $S$ , we can choose the common elements of these two subsets in $5$ ways, giving us a total of $5\cdot 6 = 30$
If there are three sets with size $2$ , they can either share one common element, which can be done in $5 \cdot 4 = 20$ ways, or they can share pairwise common elements (sort of like a cycle), which can be done $\binom{5}{2} = 10$ ways. In total, we have $30$ possibilities.
If there are four sets with size $2$ , they all have to share one common element, which can be done in $5\cdot 1$ ways.
Thus, summing everything up, this will give us $75$ possible sets $S$
Case 3: There is a set with size $1$ in $S$ Notice that be at most one size $1$ subset. There are $5$ ways to choose that single element set. Say it's $\{ 1\}$ . All other subsets in $S$ must have a $1$ in them, but there are only $2^4-1 = 15$ of them. Thus this case yields $5\cdot 1 = 5$ possibilities.
Thus, the total number of sets $S$ would be $1+75+5 = \boxed{081}$

Answer:  081
Problem: Find the number of collections of $16$ distinct subsets of $\{1,2,3,4,5\}$ with the property that for any two subsets $X$ and $Y$ in the collection, $X \cap Y \not= \emptyset.$

Solution: Firstly, there cannot be two subsets with cardinality 1, or they will not intersect.
If there is one subset $A$ with cardinality $1$ ; let the element in $A$ be $a$ , then there are $2^4=16$ subsets that do not include $a$ so they do not work. Every remaining subsets $S$ will have $a$ as an element so $S\cap{A}\geq1$ , since we just excluded all that do not. Since there are 15 subsets left, all are forced into the group of 16 subsets, so we just choose the number of $a$ to determine the set $A$ $A\in\{1,2,3,4,5\}$ so there are 5 ways.
For the rest of the cases, we assume there are no sets $A$ with cardinality 1.  Notice that the only way to "violate" the condition is to have subsets $X$ and $Y$ with cardinalities 2 and 3 in some order. Otherwise, by the Pigeonhole Principle, if two sets both have cardinalities more than 3, they are bound to have one element of intersection. Say a set $S$ has $|S|=2$ , then there is clearly only one set $s$ that will make $S\cap{s}=0$ . By our previous claim, all other subsets that have cardinality $c\geq{3}$ will work.
Now if we generalize a bit: If a subset has $N$ 2-element subsets which belong to set $M$ , then there are exactly $N$ subsets with cardinality 3 that don't work. Therefore, the number of "violating subsets" are all subsets with cardinality $c\leq{1}$ , all 2-element subsets that are not in $M$ , and all corresponding cardinality 3 subsets. Subtracting from the total 32 subsets, we get that $32-(1+5+(10-N)+N)=16$ subsets that do work. This includes all subsets in $M$ , so the remaining non-violating subsets are forced. This is equivalent now to choosing $N$ 2 element subsets.
Following casework on the number of 2-element subsets:
If $N=1$ : There are $\binom{5}{2}=10$ ways.
If $N=2$ : There are $5$ ways to choose the intersection between the 2 sets (remember they have to have at least one element of intersection) and $\binom{4}{2}=6$ ways to choose the distinct elements in the subsets, so there are $5*6=30$ ways.
If $N=3$ : It can be a cycle, where WLOG let the elements be $a,b,c$ so the sets are $\{a,b\}$ $\{b,c\}$ , and $\{c,a\}$ . This is just $\binom{5}{3}=10$ . Alternatively, it can also be the case where all sets share one element. There are 5 ways to choose this element and $\binom{4}{2}=6$ ways to choose the remaining elements to assign to each set. There are $30$ ways.
If $N=4$ : By the Pigeonhole Principle, the only way all pairwise sets have at one common intersection is if all share one element in common. There are 5 ways to choose this element and the remaining numbers are forced. There are 5 ways.
$N\geq{5}$ does not provide any valid cases since to have all pairwise elements to intersect one element, they must be the same element by the Pigeonhole Principle, but there are not enough subsets.
If $N=0$ , then there is only one way since $\binom{5}{3}+\binom{5}{4}+\binom{5}{5}=16$
Adding all cases yields $5+10+30+30+5+1=\boxed{81}$ ways!

Answer:  81
Problem: In $\triangle ABC$ with side lengths $AB = 13,$ $BC = 14,$ and $CA = 15,$ let $M$ be the midpoint of $\overline{BC}.$ Let $P$ be the point on the circumcircle of $\triangle ABC$ such that $M$ is on $\overline{AP}.$ There exists a unique point $Q$ on segment $\overline{AM}$ such that $\angle PBQ = \angle PCQ.$ Then $AQ$ can be written as $\frac{m}{\sqrt{n}},$ where $m$ and $n$ are relatively prime positive integers. Find $m+n.$

Solution: Because $M$ is the midpoint of $BC$ , following from the Stewart's theorem, $AM = 2 \sqrt{37}$
Because $A$ $B$ $C$ , and $P$ are concyclic, $\angle BPA = \angle C$ $\angle CPA = \angle B$
Denote $\theta = \angle PBQ$
In $\triangle BPQ$ , following from the law of sines, \[ \frac{BQ}{\sin \angle BPA} = \frac{PQ}{\angle PBQ} \]
Thus, \[ \frac{BQ}{\sin C} = \frac{PQ}{\sin \theta} . \hspace{1cm} (1) \]
In $\triangle CPQ$ , following from the law of sines, \[ \frac{CQ}{\sin \angle CPA} = \frac{PQ}{\angle PCQ} \]
Thus, \[ \frac{CQ}{\sin B} = \frac{PQ}{\sin \theta} . \hspace{1cm} (2) \]
Taking $\frac{(1)}{(2)}$ , we get \[ \frac{BQ}{\sin C} = \frac{CQ}{\sin B} \]
In $\triangle ABC$ , following from the law of sines, \[ \frac{AB}{\sin C} = \frac{AC}{\sin B} . \hspace{1cm} (3) \]
Thus, Equations (2) and (3) imply \begin{align*} \frac{BQ}{CQ} & = \frac{AB}{AC} \\ & = \frac{13}{15} . \hspace{1cm} (4) \end{align*}
Next, we compute $BQ$ and $CQ$
We have \begin{align*} BQ^2 & = AB^2 + AQ^2 - 2 AB\cdot AQ \cos \angle BAQ \\ & = AB^2 + AQ^2 - 2 AB\cdot AQ \cos \angle BAM \\ & = AB^2 + AQ^2 - 2 AB\cdot AQ \cdot \frac{AB^2 + AM^2 - BM^2}{2 AB \cdot AM} \\ & = AB^2 + AQ^2 -  AQ \cdot \frac{AB^2 + AM^2 - BM^2}{AM} \\ & = 169 + AQ^2 - \frac{268}{2 \sqrt{37}} AQ .  \hspace{1cm} (5) \end{align*}
We have \begin{align*} CQ^2 & = AC^2 + AQ^2 - 2 AC\cdot AQ \cos \angle CAQ \\ & = AC^2 + AQ^2 - 2 AC\cdot AQ \cos \angle CAM \\ & = AC^2 + AQ^2 - 2 AC\cdot AQ \cdot \frac{AC^2 + AM^2 - CM^2}{2 AC \cdot AM} \\ & = AC^2 + AQ^2 -  AQ \cdot \frac{AC^2 + AM^2 - CM^2}{AM} \\ & = 225 + AQ^2 - \frac{324}{2 \sqrt{37}} AQ .  \hspace{1cm} (6) \end{align*}
Taking (5) and (6) into (4), we get $AQ = \frac{99}{\sqrt{148}}$
Therefore, the answer is $99 + 148 = \boxed{247}$

Answer:  247
Problem: In $\triangle ABC$ with side lengths $AB = 13,$ $BC = 14,$ and $CA = 15,$ let $M$ be the midpoint of $\overline{BC}.$ Let $P$ be the point on the circumcircle of $\triangle ABC$ such that $M$ is on $\overline{AP}.$ There exists a unique point $Q$ on segment $\overline{AM}$ such that $\angle PBQ = \angle PCQ.$ Then $AQ$ can be written as $\frac{m}{\sqrt{n}},$ where $m$ and $n$ are relatively prime positive integers. Find $m+n.$

Solution: Define $L_1$ to be the foot of the altitude from $A$ to $BC$ . Furthermore, define $L_2$ to be the foot of the altitude from $Q$ to $BC$ . From here, one can find $AL_1=12$ , either using the 13-14-15 triangle or by calculating the area of $ABC$ two ways. Then, we find $BL_1=5$ and $L_1C = 9$ using Pythagorean theorem. Let $QL_2=x$ . By AA similarity, $\triangle{AL_1M}$ and $\triangle{QL_2M}$ are similar. By similarity ratios, \[\frac{AL_1}{L_1M}=\frac{QL_2}{L_2M}\] \[\frac{12}{2}=\frac{x}{L_2M}\] \[L_2M = \frac{x}{6}\] Thus, $BL_2=BM-L_2M=7-\frac{x}{6}$ . Similarly, $CL_2=7+\frac{x}{6}$ . Now, we angle chase from our requirement to obtain new information. \[\angle{PBQ}=\angle{PCQ}\] \[\angle{QCM}+\angle{PCM}=\angle{QBM}+\angle{PBM}\] \[\angle{QCL_2}+\angle{PCM}=\angle{QBL_2}+\angle{PBM}\] \[\angle{PCM}-\angle{PBM}=\angle{QBL_2}-\angle{QCL_2}\] \[\angle{MAB}-\angle{MAC}=\angle{QBL_2}-\angle{QCL_2}\text{(By inscribed angle theorem)}\] \[(\angle{MAL_1}+\angle{L_1AB})-(\angle{CAL_1}-\angle{MAL_1})=\angle{QBL_2}-\angle{QCL_2}\] \[2\angle{MAL_1}+\angle{L_1AB}-\angle{CAL_1}=\angle{QBL_2}-\angle{QCL_2}\] Take the tangent of both sides to obtain \[\tan(2\angle{MAL_1}+\angle{L_1AB}-\angle{CAL_1})=\tan(\angle{QBL_2}-\angle{QCL_2})\] By the definition of the tangent function on right triangles, we have $\tan{MAL_1}=\frac{7-5}{12}=\frac{1}{6}$ $\tan{CAL_1}=\frac{9}{12}=\frac{3}{4}$ , and $\tan{L_1AB}=\frac{5}{12}$ . By abusing the tangent angle addition formula, we can find that \[\tan(2\angle{MAL_1}+\angle{L_1AB}-\angle{CAL_1})=\frac{196}{2397}\] By substituting $\tan{\angle{QBL_2}}=\frac{6x}{42-x}$ $\tan{\angle{QCL_2}}=\frac{6x}{42+x}$ and using tangent angle subtraction formula we find that \[x=\frac{147}{37}\] Finally, using similarity formulas, we can find \[\frac{AQ}{AM}=\frac{12-x}{x}\] . Plugging in $x=\frac{147}{37}$ and $AM=\sqrt{148}$ , we find that \[AQ=\frac{99}{\sqrt{148}}\] Thus, our final answer is $99+148=\boxed{247}$ . 
~sigma

Answer:  247