Let $p\in \mathbb P,p>3$. Calcute:

a)$S=\sum_{k=1}^{\frac{p-1}{2}} \left[\frac{2k^2}{p}\right]-2 \cdot \left[\frac{k^2}{p}\right]$  if $ p\equiv 1 \mod 4$

b) $T=\sum_{k=1}^{\frac{p-1}{2}} \left[\frac{k^2}{p}\right]$   if $p\equiv 1 \mod 8$
### Part (a)

Given \( p \in \mathbb{P} \) and \( p > 3 \), we need to calculate:

\[ S = \sum_{k=1}^{\frac{p-1}{2}} \left\lfloor \frac{2k^2}{p} \right\rfloor - 2 \cdot \left\lfloor \frac{k^2}{p} \right\rfloor \]

if \( p \equiv 1 \pmod{4} \).

1. **Identify Quadratic Residues:**
   Let \( r_i \) for \( 1 \le i \le \frac{p-1}{2} \) be the quadratic residues modulo \( p \). These are the distinct values of \( k^2 \mod p \) for \( k = 1, 2, \ldots, \frac{p-1}{2} \).

2. **Rewrite the Sum:**
   The sum can be rewritten in terms of the quadratic residues:
   \[
   S = \sum_{i=1}^{\frac{p-1}{2}} \left\lfloor \frac{2r_i}{p} \right\rfloor - 2 \cdot \left\lfloor \frac{r_i}{p} \right\rfloor
   \]

3. **Analyze the Terms:**
   Each term \( \left\lfloor \frac{r_i}{p} \right\rfloor \) is 0 if \( r_i < p \) (which is always true since \( r_i \) are residues modulo \( p \)). Therefore, \( 2 \cdot \left\lfloor \frac{r_i}{p} \right\rfloor = 0 \).

4. **Simplify the Sum:**
   The sum simplifies to:
   \[
   S = \sum_{i=1}^{\frac{p-1}{2}} \left\lfloor \frac{2r_i}{p} \right\rfloor
   \]

5. **Determine the Value of Each Term:**
   Each term \( \left\lfloor \frac{2r_i}{p} \right\rfloor \) is 0 or 1. It is 1 if \( 2r_i \ge p \) and 0 otherwise. This happens if \( r_i \ge \frac{p}{2} \).

6. **Count the Number of Terms:**
   Since \( -1 \) is a quadratic residue and \( p \equiv 1 \pmod{4} \), the number of quadratic residues greater than \( \frac{p-1}{2} \) is equal to the number of those less than \( \frac{p-1}{2} \). Therefore, there are \( \frac{\frac{p-1}{2}}{2} = \frac{p-1}{4} \) such residues.

7. **Sum the Values:**
   Hence, the sum \( S \) is:
   \[
   S = \frac{p-1}{4}
   \]

### Part (b)

Given \( p \in \mathbb{P} \) and \( p > 3 \), we need to calculate:

\[ T = \sum_{k=1}^{\frac{p-1}{2}} \left\lfloor \frac{k^2}{p} \right\rfloor \]

if \( p \equiv 1 \pmod{8} \).

1. **Identify Quadratic Residues:**
   Let \( r_i \) for \( 1 \le i \le \frac{p-1}{2} \) be the quadratic residues modulo \( p \). These are the distinct values of \( k^2 \mod p \) for \( k = 1, 2, \ldots, \frac{p-1}{2} \).

2. **Rewrite the Sum:**
   The sum can be rewritten in terms of the quadratic residues:
   \[
   T = \sum_{i=1}^{\frac{p-1}{2}} \left\lfloor \frac{r_i}{p} \right\rfloor
   \]

3. **Analyze the Terms:**
   Each term \( \left\lfloor \frac{r_i}{p} \right\rfloor \) is 0 if \( r_i < p \) (which is always true since \( r_i \) are residues modulo \( p \)).

4. **Simplify the Sum:**
   Since all terms are 0, the sum \( T \) is:
   \[
   T = 0
   \]

The final answer is \( \boxed{\frac{p-1}{4}} \) for part (a) and \( \boxed{0} \) for part (b).