1 for (int c0 = -n + 1; c0 <= n; c0 += 1) {
2   if (c0 <= 0)
3     for (int c2 = -c0 + 4; c2 <= 2 * n - c0 + 2; c2 += 2)
4       S1(1, -c0 + 1, ((c0 + c2) / 2) - 1);
5   for (int c1 = max(c0 + 2, -c0 + 4); c1 <= min(2 * n - c0, 2 * n + c0); c1 += 2) {
6     for (int c2 = c1 + 2; c2 <= 2 * n + c1; c2 += 2)
7       S1((c0 + c1) / 2, (-c0 + c1) / 2, (-c1 + c2) / 2);
8     for (int c2 = 1; c2 <= n; c2 += 1)
9       S2(((c0 + c1) / 2) - 1, (-c0 + c1) / 2, c2);
10   }
11   if (c0 >= 1)
12     for (int c2 = 1; c2 <= n; c2 += 1)
13       S2(n, n - c0 + 1, c2);
14 }
15