namespace; include rt; // push in o3 code: the quick path when there is room, dpush when there is not o3 int fill(int[?] a, int n) { for (int i = 0; i < n; i++) push(a, i * 3); return len(a); } o3 int sum(int[?] a) { int s = 0; for (int i = 0; i < len(a); i++) s += a[i]; return s; } o3 float fsum(float[?] a) { float s = 0.0; for (int i = 0; i < len(a); i++) s += a[i]; return s; } o3 int ffill(float[?] a, int n) { for (int i = 0; i < n; i++) push(a, 0.5 * i); return len(a); } int main() { int[?] a = rt.new(int[?], 0); rt.put_n(fill(a, 1000)); rt.put_c(' '); rt.put_n(sum(a)); rt.put_c(' '); rt.put_n(a[999]); rt.put_c(' '); rt.put_n(fill(a, 5)); rt.put_c(' '); rt.put_n(cap(a) >= 1005); rt.put_c(' '); float[?] f = rt.new(float[?], 0); ffill(f, 10); rt.put_n(len(f)); rt.put_c(' '); rt.put_n(fsum(f) == 22.5); rt.put_c(' '); rt.put_n(drain(a)); rt.put_c(' '); rt.put_n(len(a)); rt.put_c(10); rt.free(d*a); rt.free(d*f); return 0; } o3 int drain(int[?] a) { int s = 0; while (len(a) > 0) s += pop(a); return s; }