Let $p$ be a given odd prime. Find the largest integer $k'$ such that it is possible to partition $\{1,2,\cdots,p-1\}$ into two sets $X,Y$ such that for any $k$ with $0 \le k \le k'$,

$$\sum_{a \in X}a^k \equiv \sum_{b \in Y}b^k \pmod p$$

[i]houkai[/i]
1. **Rephrasing the Problem:**
   We need to partition the set \(\{1, 2, \ldots, p-1\}\) into two sets \(X\) and \(Y\) such that for any \(k\) with \(0 \leq k \leq k'\), the following congruence holds:
   \[
   \sum_{a \in X} a^k \equiv \sum_{b \in Y} b^k \pmod{p}
   \]
   Given that \(p\) is an odd prime, we need to find the largest integer \(k'\) for which this is possible.

2. **Initial Setup:**
   Let \(X\) be the set of nonzero quadratic residues modulo \(p\), and let \(g\) be a primitive root modulo \(p\). The set \(X\) will have \(\frac{p-1}{2}\) elements.

3. **Sum of Powers of Elements in \(X\):**
   For \(1 \leq k \leq \frac{p-3}{2}\), we need to show that:
   \[
   \sum_{j=1}^{p-1} j^k \equiv 0 \pmod{p}
   \]
   Using the properties of primitive roots, we have:
   \[
   \sum_{j=1}^{p-1} j^k \equiv \frac{g^{(p-1)k} - 1}{g^k - 1} \pmod{p}
   \]
   Since \(g\) is a primitive root, \(g^{p-1} \equiv 1 \pmod{p}\), making the numerator zero and the denominator non-zero. Thus, the sum is zero modulo \(p\).

4. **Sum of Powers of Elements in \(X\) for Even Powers:**
   We also need to show that:
   \[
   2 \sum_{j \in X} j^k \equiv \sum_{j=1}^{p-1} j^{2k} \pmod{p}
   \]
   For \(k = 1, \ldots, \frac{p-3}{2}\), we have:
   \[
   \sum_{j=1}^{p-1} j^{2k} \equiv \frac{g^{2(p-1)k} - 1}{g^{2k} - 1} \pmod{p}
   \]
   Again, the numerator is zero and the denominator is non-zero, so the sum is zero modulo \(p\).

5. **Failure for \(k' = \frac{p-1}{2}\):**
   Let \(n = \frac{p-1}{2}\). We need to show that the condition fails for \(k = n\).

6. **Using the Legendre Symbol:**
   For all \(t = 0, \ldots, p-1\), consider:
   \[
   \sum_{j \in X} (j + t)^n = \sum_{j \in X} \sum_{m=0}^n \binom{n}{m} j^m t^{n-m} = \sum_{m=0}^n \binom{n}{m} t^{n-m} \left( \sum_{j \in X} j^m \right)
   \]
   The inner sum vanishes whenever \(m > 0\). Therefore, this is simply equal to:
   \[
   \frac{p-1}{2} \left( \frac{t}{p} \right)
   \]

7. **Contradiction Using Quadratic Residues:**
   Select two \(t\) such that \(-t \notin S\). Observe each term \(\left( \frac{j+t}{p} \right) \in \{-1, 1\}\) and their sum is either \(\frac{p-1}{2}\) or \(\frac{1-p}{2}\). This means all of \(j+t\)'s are quadratic residues or non-quadratic residues. Picking two of them gives a contradiction because the set of quadratic residues \(S\) satisfies \(S+t\) having \(\frac{p-1}{2}\) elements in common for any \(t\).

8. **Symmetric Polynomials Method:**
   Let \(P(x) = \prod_{j \in X} (x - j)\). We know that \(S_k\) vanishes for all \(k = 1, \ldots, n\). By our lemma, we can induct on \(k\) to prove that \([x^{n-k}]P(x)\) is zero modulo \(p\) for all \(k = 1, \ldots, n\) because no coefficients vanish modulo \(p\) and noting the existence of a \(\prod r_j\) term exists. But this implies \(p \mid \prod_{j \in X} j\), which is absurd.

\(\blacksquare\)

The final answer is \( \boxed{ k' = \frac{p-3}{2} } \)