code: def quadratic_residues(p) -> list[int]:
      """
      Returns the list of quadratic residues.
  
      Examples
      ========
  
      >>> from sympy.ntheory.residue_ntheory import quadratic_residues
      >>> quadratic_residues(7)
      [0, 1, 2, 4]
      """
      p = as_int(p)
      r = {pow(i, 2, p) for i in range(p // 2 + 1)}
      return sorted(r)
  
imports: from __future__ import annotations
  from sympy.external.gmpy import gcd, lcm, invert, sqrt, legendre, jacobi, kronecker, bit_scan1, remove
  from sympy.polys import Poly
  from sympy.polys.domains import ZZ
  from sympy.polys.galoistools import gf_crt1, gf_crt2, linear_congruence, gf_csolve
  from .primetest import isprime
  from .factor_ import factorint, _perfect_power
  from .modular import crt
  from sympy.utilities.decorator import deprecated
  from sympy.utilities.memoization import recurrence_memo
  from sympy.utilities.misc import as_int
  from sympy.utilities.iterables import iproduct
  from sympy.core.random import _randint, randint
  from itertools import product
label_desc: Use image node_id 18 for calling a global function with example usage: quadratic_residues(p) and returns: sorted