function part1(input) {
const gSize = input.length;
const costs = AOC.gInit(gSize, gSize, Number.MAX_SAFE_INTEGER);
costs[0][0] = 0;
const pq = new PriorityQueue(([pos1, a], [pos2, b]) => a < b);
pq.add([[0, 0], 0]);
while (pq.size > 0) {
const [[r, c], cost] = pq.poll();
if (r == gSize - 1 && c == gSize - 1) {
return cost;
}
neighbours.forEach(([dy, dx]) => {
const [row, col] = [r + dy, c + dx];
if (row >= 0 && col >= 0 && row < gSize && col < gSize) {
const newCost = cost + input[row][col];
if (newCost < costs[row][col]) {
costs[row][col] = newCost;
pq.add([[row, col], newCost]);
}
}
});
}
}