  Let $p$ be a fixed prime. A triangle in $\mathbb{F}_p^n$ is an ordered triple
$(x,y,z)$ of points satisfying $x+y+z=0$. Let $N=p^n=|\mathbb{F}_p^n|$. Green
proved an arithmetic triangle removal lemma which says that for every
$\epsilon>0$ and prime $p$, there is a $\delta>0$ such that if $X,Y,Z \subset
\mathbb{F}_p^n$ and the number of triangles in $X \times Y \times Z$ is at most
$\delta N^2$, then we can delete $\epsilon N$ elements from $X$, $Y$, and $Z$
and remove all triangles. Green posed the problem of improving the quantitative
bounds on the arithmetic triangle removal lemma, and, in particular, asked
whether a polynomial bound holds. Despite considerable attention, prior to this
paper, the best known bound, due to the first author, showed that $1/\delta$
can be taken to be an exponential tower of twos of height logarithmic in
$1/\epsilon$.
  We solve Green's problem, proving an essentially tight bound for Green's
arithmetic triangle removal lemma in $\mathbb{F}_p^n$. We show that a
polynomial bound holds, and further determine the best possible exponent.
Namely, there is a computable number $C_p$ such that we may take $\delta =
(\epsilon/3)^{C_p}$, and we must have $\delta \leq \epsilon^{C_p-o(1)}$. In
particular, $C_2=1+1/(5/3 - \log_2 3) \approx 13.239$, and $C_3=1+1/c_3$ with
$c_3=1-\frac{\log b}{\log 3}$, $b=a^{-2/3}+a^{1/3}+a^{4/3}$, and
$a=\frac{\sqrt{33}-1}{8}$, which gives $C_3 \approx 13.901$. The proof uses
Kleinberg, Sawin, and Speyer's essentially sharp bound on multicolored sum-free
sets, which builds on the recent breakthrough on the cap set problem by
Croot-Lev-Pach, and the subsequent work by Ellenberg-Gijswijt,
Blasiak-Church-Cohn-Grochow-Naslund-Sawin-Umans, and Alon.
