xxxxxxxxxx
import core.stdc.stdio: printf;
int foo1(int x, int y) {
static int[int[2]] cache;
int[2] args = [x, y];
cache[args] = x;
return x;
}
int foo2(int x, int y) {
static struct Pair { int x, y; }
static int[Pair] cache;
Pair args = Pair(x, y);
cache[args] = x;
return x;
}
void main() {
enum int N = 600;
int tot;
foreach (x; 1 .. N)
foreach (y; 1 .. N)
tot += foo1(x, y);
printf("%d\n", tot);
tot = 0;
foreach (x; 1 .. N)
foreach (y; 1 .. N)
tot += foo2(x, y);
printf("%d\n", tot);
}